machine.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 supplies. 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. const char *dev_name; /* consumer dev_name() */
  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_name = "dev_name(consumer B)",
  21. .supply = "Vcc",
  22. },};
  23. static struct regulator_consumer_supply regulator2_consumers[] = {
  24. {
  25. .dev = "dev_name(consumer A"),
  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 regulators :-
  33. static struct regulator_init_data regulator1_data = {
  34. .constraints = {
  35. .name = "Regulator-1",
  36. .min_uV = 3300000,
  37. .max_uV = 3300000,
  38. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  39. },
  40. .num_consumer_supplies = ARRAY_SIZE(regulator1_consumers),
  41. .consumer_supplies = regulator1_consumers,
  42. };
  43. The name field should be set to something that is usefully descriptive
  44. for the board for configuration of supplies for other regulators and
  45. for use in logging and other diagnostic output. Normally the name
  46. used for the supply rail in the schematic is a good choice. If no
  47. name is provided then the subsystem will choose one.
  48. Regulator-1 supplies power to Regulator-2. This relationship must be registered
  49. with the core so that Regulator-1 is also enabled when Consumer A enables its
  50. supply (Regulator-2). The supply regulator is set by the supply_regulator
  51. field below and co:-
  52. static struct regulator_init_data regulator2_data = {
  53. .supply_regulator = "Regulator-1",
  54. .constraints = {
  55. .min_uV = 1800000,
  56. .max_uV = 2000000,
  57. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  58. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  59. },
  60. .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers),
  61. .consumer_supplies = regulator2_consumers,
  62. };
  63. Finally the regulator devices must be registered in the usual manner.
  64. static struct platform_device regulator_devices[] = {
  65. {
  66. .name = "regulator",
  67. .id = DCDC_1,
  68. .dev = {
  69. .platform_data = &regulator1_data,
  70. },
  71. },
  72. {
  73. .name = "regulator",
  74. .id = DCDC_2,
  75. .dev = {
  76. .platform_data = &regulator2_data,
  77. },
  78. },
  79. };
  80. /* register regulator 1 device */
  81. platform_device_register(&regulator_devices[0]);
  82. /* register regulator 2 device */
  83. platform_device_register(&regulator_devices[1]);