syscon.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. /**
  22. * syscon_get_regmap() - Get access to a register map
  23. *
  24. * @dev: Device to check (UCLASS_SCON)
  25. * @info: Returns regmap for the device
  26. * @return 0 if OK, -ve on error
  27. */
  28. struct regmap *syscon_get_regmap(struct udevice *dev);
  29. /**
  30. * syscon_get_regmap_by_driver_data() - Look up a controller by its ID
  31. *
  32. * Each system controller can be accessed by its driver data, which is
  33. * assumed to be unique through the scope of all system controllers that
  34. * are in use. This function looks up the controller given this driver data.
  35. *
  36. * @driver_data: Driver data value to look up
  37. * @devp: Returns the controller correponding to @driver_data
  38. * @return 0 on success, -ENODEV if the ID was not found, or other -ve error
  39. * code
  40. */
  41. int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp);
  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 regmap given this driver data.
  48. *
  49. * @driver_data: Driver data value to look up
  50. * @return register map correponding to @driver_data, or -ve error code
  51. */
  52. struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data);
  53. /**
  54. * syscon_get_first_range() - get the first memory range from a syscon regmap
  55. *
  56. * @driver_data: Driver data value to look up
  57. * @return first region of register map correponding to @driver_data, or
  58. * -ve error code
  59. */
  60. void *syscon_get_first_range(ulong driver_data);
  61. #endif