syscon.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2015 Google, Inc
  3. * Written by Simon Glass <sjg@chromium.org>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef __SYSCON_H
  8. #define __SYSCON_H
  9. /**
  10. * struct syscon_uc_info - Information stored by the syscon UCLASS_UCLASS
  11. *
  12. * @regmap: Register map for this controller
  13. */
  14. struct syscon_uc_info {
  15. struct regmap *regmap;
  16. };
  17. /* So far there are no ops so this is a placeholder */
  18. struct syscon_ops {
  19. };
  20. #define syscon_get_ops(dev) ((struct syscon_ops *)(dev)->driver->ops)
  21. #if CONFIG_IS_ENABLED(OF_PLATDATA)
  22. /*
  23. * We don't support 64-bit machines. If they are so resource-contrained that
  24. * they need to use OF_PLATDATA, something is horribly wrong with the
  25. * education of our hardware engineers.
  26. */
  27. struct syscon_base_platdata {
  28. u32 reg[2];
  29. };
  30. #endif
  31. /**
  32. * syscon_get_regmap() - Get access to a register map
  33. *
  34. * @dev: Device to check (UCLASS_SCON)
  35. * @info: Returns regmap for the device
  36. * @return 0 if OK, -ve on error
  37. */
  38. struct regmap *syscon_get_regmap(struct udevice *dev);
  39. /**
  40. * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
  41. *
  42. * Each system controller can be accessed by its driver data, which is
  43. * assumed to be unique through the scope of all system controllers that
  44. * are in use. This function looks up the controller given this driver data.
  45. *
  46. * @driver_data: Driver data value to look up
  47. * @devp: Returns the controller correponding to @driver_data
  48. * @return 0 on success, -ENODEV if the ID was not found, or other -ve error
  49. * code
  50. */
  51. int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp);
  52. /**
  53. * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
  54. *
  55. * Each system controller can be accessed by its driver data, which is
  56. * assumed to be unique through the scope of all system controllers that
  57. * are in use. This function looks up the regmap given this driver data.
  58. *
  59. * @driver_data: Driver data value to look up
  60. * @return register map correponding to @driver_data, or -ve error code
  61. */
  62. struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data);
  63. /**
  64. * syscon_get_first_range() - get the first memory range from a syscon regmap
  65. *
  66. * @driver_data: Driver data value to look up
  67. * @return first region of register map correponding to @driver_data, or
  68. * -ve error code
  69. */
  70. void *syscon_get_first_range(ulong driver_data);
  71. #endif