syscon.h 2.4 KB

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