Merge remote-tracking branch 'linusw-gpio/for-next' into devm_gpiochip
[deliverable/linux.git] / Documentation / power / regulator / machine.txt
CommitLineData
e7d0fe34
LG
1Regulator Machine Driver Interface
2===================================
3
4The regulator machine driver interface is intended for board/machine specific
a5766f11 5initialisation code to configure the regulator subsystem.
e7d0fe34 6
e7d0fe34
LG
7Consider 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
3a4c6959 14order to control their power supplies. This mapping can be achieved in machine
a5766f11
LG
15initialisation code by creating a struct regulator_consumer_supply for
16each regulator.
17
18struct regulator_consumer_supply {
2c1ba398 19 const char *dev_name; /* consumer dev_name() */
a5766f11
LG
20 const char *supply; /* consumer supply - e.g. "vcc" */
21};
e7d0fe34 22
a5766f11 23e.g. for the machine above
e7d0fe34 24
a5766f11
LG
25static struct regulator_consumer_supply regulator1_consumers[] = {
26{
2c1ba398
MB
27 .dev_name = "dev_name(consumer B)",
28 .supply = "Vcc",
a5766f11 29},};
e7d0fe34 30
a5766f11
LG
31static struct regulator_consumer_supply regulator2_consumers[] = {
32{
2c1ba398 33 .dev = "dev_name(consumer A"),
a5766f11
LG
34 .supply = "Vcc",
35},};
e7d0fe34
LG
36
37This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2
38to the 'Vcc' supply for Consumer A.
39
a5766f11
LG
40Constraints can now be registered by defining a struct regulator_init_data
41for each regulator power domain. This structure also maps the consumers
3a4c6959 42to their supply regulators :-
a5766f11
LG
43
44static struct regulator_init_data regulator1_data = {
45 .constraints = {
c3035a23 46 .name = "Regulator-1",
a5766f11
LG
47 .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};
e7d0fe34 54
c3035a23
MB
55The 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
e7d0fe34 61Regulator-1 supplies power to Regulator-2. This relationship must be registered
a33f3224 62with the core so that Regulator-1 is also enabled when Consumer A enables its
492c826b 63supply (Regulator-2). The supply regulator is set by the supply_regulator
c3035a23 64field below and co:-
a5766f11
LG
65
66static struct regulator_init_data regulator2_data = {
c3035a23 67 .supply_regulator = "Regulator-1",
a5766f11
LG
68 .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,
e7d0fe34
LG
76};
77
a5766f11
LG
78Finally the regulator devices must be registered in the usual manner.
79
80static 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},
e7d0fe34 95};
a5766f11 96/* register regulator 1 device */
2e7e65ce 97platform_device_register(&regulator_devices[0]);
e7d0fe34 98
a5766f11 99/* register regulator 2 device */
2e7e65ce 100platform_device_register(&regulator_devices[1]);
This page took 0.409652 seconds and 5 git commands to generate.