]> git.ipfire.org Git - thirdparty/linux.git/blame - Documentation/power/regulator/machine.rst
docs: power: convert docs to ReST and rename to *.rst
[thirdparty/linux.git] / Documentation / power / regulator / machine.rst
CommitLineData
151f4e2b 1==================================
e7d0fe34 2Regulator Machine Driver Interface
151f4e2b 3==================================
e7d0fe34
LG
4
5The regulator machine driver interface is intended for board/machine specific
a5766f11 6initialisation code to configure the regulator subsystem.
e7d0fe34 7
151f4e2b 8Consider the following machine::
e7d0fe34
LG
9
10 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
11 |
12 +-> [Consumer B @ 3.3V]
13
14The drivers for consumers A & B must be mapped to the correct regulator in
3a4c6959 15order to control their power supplies. This mapping can be achieved in machine
a5766f11 16initialisation code by creating a struct regulator_consumer_supply for
151f4e2b 17each regulator::
a5766f11 18
151f4e2b 19 struct regulator_consumer_supply {
2c1ba398 20 const char *dev_name; /* consumer dev_name() */
a5766f11 21 const char *supply; /* consumer supply - e.g. "vcc" */
151f4e2b 22 };
e7d0fe34 23
151f4e2b 24e.g. for the machine above::
e7d0fe34 25
151f4e2b 26 static struct regulator_consumer_supply regulator1_consumers[] = {
983ba99a 27 REGULATOR_SUPPLY("Vcc", "consumer B"),
151f4e2b 28 };
e7d0fe34 29
151f4e2b 30 static struct regulator_consumer_supply regulator2_consumers[] = {
983ba99a 31 REGULATOR_SUPPLY("Vcc", "consumer A"),
151f4e2b 32 };
e7d0fe34
LG
33
34This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2
35to the 'Vcc' supply for Consumer A.
36
a5766f11
LG
37Constraints can now be registered by defining a struct regulator_init_data
38for each regulator power domain. This structure also maps the consumers
151f4e2b 39to their supply regulators::
a5766f11 40
151f4e2b 41 static struct regulator_init_data regulator1_data = {
a5766f11 42 .constraints = {
c3035a23 43 .name = "Regulator-1",
a5766f11
LG
44 .min_uV = 3300000,
45 .max_uV = 3300000,
46 .valid_modes_mask = REGULATOR_MODE_NORMAL,
47 },
48 .num_consumer_supplies = ARRAY_SIZE(regulator1_consumers),
49 .consumer_supplies = regulator1_consumers,
151f4e2b 50 };
e7d0fe34 51
c3035a23
MB
52The name field should be set to something that is usefully descriptive
53for the board for configuration of supplies for other regulators and
54for use in logging and other diagnostic output. Normally the name
55used for the supply rail in the schematic is a good choice. If no
56name is provided then the subsystem will choose one.
57
e7d0fe34 58Regulator-1 supplies power to Regulator-2. This relationship must be registered
a33f3224 59with the core so that Regulator-1 is also enabled when Consumer A enables its
492c826b 60supply (Regulator-2). The supply regulator is set by the supply_regulator
151f4e2b 61field below and co::
a5766f11 62
151f4e2b 63 static struct regulator_init_data regulator2_data = {
c3035a23 64 .supply_regulator = "Regulator-1",
a5766f11
LG
65 .constraints = {
66 .min_uV = 1800000,
67 .max_uV = 2000000,
68 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
69 .valid_modes_mask = REGULATOR_MODE_NORMAL,
70 },
71 .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers),
72 .consumer_supplies = regulator2_consumers,
151f4e2b 73 };
e7d0fe34 74
151f4e2b 75Finally the regulator devices must be registered in the usual manner::
a5766f11 76
151f4e2b 77 static struct platform_device regulator_devices[] = {
983ba99a
JN
78 {
79 .name = "regulator",
80 .id = DCDC_1,
81 .dev = {
82 .platform_data = &regulator1_data,
83 },
a5766f11 84 },
983ba99a
JN
85 {
86 .name = "regulator",
87 .id = DCDC_2,
88 .dev = {
89 .platform_data = &regulator2_data,
90 },
a5766f11 91 },
151f4e2b
MCC
92 };
93 /* register regulator 1 device */
94 platform_device_register(&regulator_devices[0]);
e7d0fe34 95
151f4e2b
MCC
96 /* register regulator 2 device */
97 platform_device_register(&regulator_devices[1]);