machine.txt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. Regulator Machine Driver Interface
  2. ===================================
  3. The regulator machine driver interface is intended for board/machine specific
  4. initialisation code to configure the regulator subsystem.
  5. Consider the following machine :-
  6. Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
  7. |
  8. +-> [Consumer B @ 3.3V]
  9. The drivers for consumers A & B must be mapped to the correct regulator in
  10. order to control their power supply. This mapping can be achieved in machine
  11. initialisation code by creating a struct regulator_consumer_supply for
  12. each regulator.
  13. struct regulator_consumer_supply {
  14. struct device *dev; /* consumer */
  15. const char *supply; /* consumer supply - e.g. "vcc" */
  16. };
  17. e.g. for the machine above
  18. static struct regulator_consumer_supply regulator1_consumers[] = {
  19. {
  20. .dev = &platform_consumerB_device.dev,
  21. .supply = "Vcc",
  22. },};
  23. static struct regulator_consumer_supply regulator2_consumers[] = {
  24. {
  25. .dev = &platform_consumerA_device.dev,
  26. .supply = "Vcc",
  27. },};
  28. This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2
  29. to the 'Vcc' supply for Consumer A.
  30. Constraints can now be registered by defining a struct regulator_init_data
  31. for each regulator power domain. This structure also maps the consumers
  32. to their supply regulator :-
  33. static struct regulator_init_data regulator1_data = {
  34. .constraints = {
  35. .min_uV = 3300000,
  36. .max_uV = 3300000,
  37. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  38. },
  39. .num_consumer_supplies = ARRAY_SIZE(regulator1_consumers),
  40. .consumer_supplies = regulator1_consumers,
  41. };
  42. Regulator-1 supplies power to Regulator-2. This relationship must be registered
  43. with the core so that Regulator-1 is also enabled when Consumer A enables it's
  44. supply (Regulator-2). The supply regulator is set by the supply_regulator_dev
  45. field below:-
  46. static struct regulator_init_data regulator2_data = {
  47. .supply_regulator_dev = &platform_regulator1_device.dev,
  48. .constraints = {
  49. .min_uV = 1800000,
  50. .max_uV = 2000000,
  51. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  52. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  53. },
  54. .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers),
  55. .consumer_supplies = regulator2_consumers,
  56. };
  57. Finally the regulator devices must be registered in the usual manner.
  58. static struct platform_device regulator_devices[] = {
  59. {
  60. .name = "regulator",
  61. .id = DCDC_1,
  62. .dev = {
  63. .platform_data = &regulator1_data,
  64. },
  65. },
  66. {
  67. .name = "regulator",
  68. .id = DCDC_2,
  69. .dev = {
  70. .platform_data = &regulator2_data,
  71. },
  72. },
  73. };
  74. /* register regulator 1 device */
  75. platform_device_register(&regulator_devices[0]);
  76. /* register regulator 2 device */
  77. platform_device_register(&regulator_devices[1]);