]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - Documentation/power/regulator/machine.txt
Documentation/: it's -> its where appropriate
[mirror_ubuntu-artful-kernel.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
14order to control their power supply. 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 {
19 struct device *dev; /* consumer */
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{
27 .dev = &platform_consumerB_device.dev,
28 .supply = "Vcc",
29},};
e7d0fe34 30
a5766f11
LG
31static struct regulator_consumer_supply regulator2_consumers[] = {
32{
33 .dev = &platform_consumerA_device.dev,
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
42to their supply regulator :-
43
44static struct regulator_init_data regulator1_data = {
45 .constraints = {
46 .min_uV = 3300000,
47 .max_uV = 3300000,
48 .valid_modes_mask = REGULATOR_MODE_NORMAL,
49 },
50 .num_consumer_supplies = ARRAY_SIZE(regulator1_consumers),
51 .consumer_supplies = regulator1_consumers,
52};
e7d0fe34
LG
53
54Regulator-1 supplies power to Regulator-2. This relationship must be registered
a33f3224 55with the core so that Regulator-1 is also enabled when Consumer A enables its
a5766f11
LG
56supply (Regulator-2). The supply regulator is set by the supply_regulator_dev
57field below:-
58
59static struct regulator_init_data regulator2_data = {
60 .supply_regulator_dev = &platform_regulator1_device.dev,
61 .constraints = {
62 .min_uV = 1800000,
63 .max_uV = 2000000,
64 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
65 .valid_modes_mask = REGULATOR_MODE_NORMAL,
66 },
67 .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers),
68 .consumer_supplies = regulator2_consumers,
e7d0fe34
LG
69};
70
a5766f11
LG
71Finally the regulator devices must be registered in the usual manner.
72
73static struct platform_device regulator_devices[] = {
74{
75 .name = "regulator",
76 .id = DCDC_1,
77 .dev = {
78 .platform_data = &regulator1_data,
79 },
80},
81{
82 .name = "regulator",
83 .id = DCDC_2,
84 .dev = {
85 .platform_data = &regulator2_data,
86 },
87},
e7d0fe34 88};
a5766f11 89/* register regulator 1 device */
2e7e65ce 90platform_device_register(&regulator_devices[0]);
e7d0fe34 91
a5766f11 92/* register regulator 2 device */
2e7e65ce 93platform_device_register(&regulator_devices[1]);