blob: ce63af0a8e35ecab32e2f326d13a9a2b33b62909 [file] [log] [blame]
Liam Girdwoode7d0fe32008-04-30 17:22:50 +01001Regulator Machine Driver Interface
2===================================
3
4The regulator machine driver interface is intended for board/machine specific
Liam Girdwooda5766f12008-10-10 13:22:20 +01005initialisation code to configure the regulator subsystem.
Liam Girdwoode7d0fe32008-04-30 17:22:50 +01006
Liam Girdwoode7d0fe32008-04-30 17:22:50 +01007Consider the following machine :-
8
9 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
10 |
11 +-> [Consumer B @ 3.3V]
12
13The drivers for consumers A & B must be mapped to the correct regulator in
14order to control their power supply. This mapping can be achieved in machine
Liam Girdwooda5766f12008-10-10 13:22:20 +010015initialisation code by creating a struct regulator_consumer_supply for
16each regulator.
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010017
Liam Girdwooda5766f12008-10-10 13:22:20 +010018struct regulator_consumer_supply {
Mark Brown2c1ba392011-09-08 10:37:31 -070019 const char *dev_name; /* consumer dev_name() */
Liam Girdwooda5766f12008-10-10 13:22:20 +010020 const char *supply; /* consumer supply - e.g. "vcc" */
21};
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010022
Liam Girdwooda5766f12008-10-10 13:22:20 +010023e.g. for the machine above
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010024
Liam Girdwooda5766f12008-10-10 13:22:20 +010025static struct regulator_consumer_supply regulator1_consumers[] = {
26{
Mark Brown2c1ba392011-09-08 10:37:31 -070027 .dev_name = "dev_name(consumer B)",
28 .supply = "Vcc",
Liam Girdwooda5766f12008-10-10 13:22:20 +010029},};
30
31static struct regulator_consumer_supply regulator2_consumers[] = {
32{
Mark Brown2c1ba392011-09-08 10:37:31 -070033 .dev = "dev_name(consumer A"),
Liam Girdwooda5766f12008-10-10 13:22:20 +010034 .supply = "Vcc",
35},};
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010036
37This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2
38to the 'Vcc' supply for Consumer A.
39
Liam Girdwooda5766f12008-10-10 13:22:20 +010040Constraints can now be registered by defining a struct regulator_init_data
41for each regulator power domain. This structure also maps the consumers
42to their supply regulator :-
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010043
Liam Girdwooda5766f12008-10-10 13:22:20 +010044static struct regulator_init_data regulator1_data = {
45 .constraints = {
Mark Brownc3035a22011-09-08 10:38:59 -070046 .name = "Regulator-1",
Liam Girdwooda5766f12008-10-10 13:22:20 +010047 .min_uV = 3300000,
48 .max_uV = 3300000,
49 .valid_modes_mask = REGULATOR_MODE_NORMAL,
50 },
51 .num_consumer_supplies = ARRAY_SIZE(regulator1_consumers),
52 .consumer_supplies = regulator1_consumers,
53};
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010054
Mark Brownc3035a22011-09-08 10:38:59 -070055The name field should be set to something that is usefully descriptive
56for the board for configuration of supplies for other regulators and
57for use in logging and other diagnostic output. Normally the name
58used for the supply rail in the schematic is a good choice. If no
59name is provided then the subsystem will choose one.
60
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010061Regulator-1 supplies power to Regulator-2. This relationship must be registered
Francis Galieguea33f3222010-04-23 00:08:02 +020062with the core so that Regulator-1 is also enabled when Consumer A enables its
Mark Brown492c826b2011-05-08 22:30:18 +010063supply (Regulator-2). The supply regulator is set by the supply_regulator
Mark Brownc3035a22011-09-08 10:38:59 -070064field below and co:-
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010065
Liam Girdwooda5766f12008-10-10 13:22:20 +010066static struct regulator_init_data regulator2_data = {
Mark Brownc3035a22011-09-08 10:38:59 -070067 .supply_regulator = "Regulator-1",
Liam Girdwooda5766f12008-10-10 13:22:20 +010068 .constraints = {
69 .min_uV = 1800000,
70 .max_uV = 2000000,
71 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
72 .valid_modes_mask = REGULATOR_MODE_NORMAL,
73 },
74 .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers),
75 .consumer_supplies = regulator2_consumers,
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010076};
77
Liam Girdwooda5766f12008-10-10 13:22:20 +010078Finally the regulator devices must be registered in the usual manner.
Liam Girdwoode7d0fe32008-04-30 17:22:50 +010079
Liam Girdwooda5766f12008-10-10 13:22:20 +010080static struct platform_device regulator_devices[] = {
81{
82 .name = "regulator",
83 .id = DCDC_1,
84 .dev = {
85 .platform_data = &regulator1_data,
86 },
87},
88{
89 .name = "regulator",
90 .id = DCDC_2,
91 .dev = {
92 .platform_data = &regulator2_data,
93 },
94},
95};
96/* register regulator 1 device */
Wolfram Sang2e7e65c2009-09-18 22:44:43 +020097platform_device_register(&regulator_devices[0]);
Liam Girdwooda5766f12008-10-10 13:22:20 +010098
99/* register regulator 2 device */
Wolfram Sang2e7e65c2009-09-18 22:44:43 +0200100platform_device_register(&regulator_devices[1]);