aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/power/regulator/machine.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/power/regulator/machine.txt')
-rw-r--r--Documentation/power/regulator/machine.txt140
1 files changed, 66 insertions, 74 deletions
diff --git a/Documentation/power/regulator/machine.txt b/Documentation/power/regulator/machine.txt
index c9a35665cf70..ce3487d99abe 100644
--- a/Documentation/power/regulator/machine.txt
+++ b/Documentation/power/regulator/machine.txt
@@ -2,17 +2,8 @@ Regulator Machine Driver Interface
2=================================== 2===================================
3 3
4The regulator machine driver interface is intended for board/machine specific 4The regulator machine driver interface is intended for board/machine specific
5initialisation code to configure the regulator subsystem. Typical things that 5initialisation code to configure the regulator subsystem.
6machine drivers would do are :-
7 6
8 1. Regulator -> Device mapping.
9 2. Regulator supply configuration.
10 3. Power Domain constraint setting.
11
12
13
141. Regulator -> device mapping
15==============================
16Consider the following machine :- 7Consider the following machine :-
17 8
18 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V] 9 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
@@ -21,81 +12,82 @@ Consider the following machine :-
21 12
22The drivers for consumers A & B must be mapped to the correct regulator in 13The drivers for consumers A & B must be mapped to the correct regulator in
23order to control their power supply. This mapping can be achieved in machine 14order to control their power supply. This mapping can be achieved in machine
24initialisation code by calling :- 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};
25 22
26int regulator_set_device_supply(const char *regulator, struct device *dev, 23e.g. for the machine above
27 const char *supply);
28 24
29and is shown with the following code :- 25static struct regulator_consumer_supply regulator1_consumers[] = {
26{
27 .dev = &platform_consumerB_device.dev,
28 .supply = "Vcc",
29},};
30 30
31regulator_set_device_supply("Regulator-1", devB, "Vcc"); 31static struct regulator_consumer_supply regulator2_consumers[] = {
32regulator_set_device_supply("Regulator-2", devA, "Vcc"); 32{
33 .dev = &platform_consumerA_device.dev,
34 .supply = "Vcc",
35},};
33 36
34This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2 37This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2
35to the 'Vcc' supply for Consumer A. 38to the 'Vcc' supply for Consumer A.
36 39
37 40Constraints can now be registered by defining a struct regulator_init_data
382. Regulator supply configuration. 41for each regulator power domain. This structure also maps the consumers
39================================== 42to their supply regulator :-
40Consider the following machine (again) :- 43
41 44static struct regulator_init_data regulator1_data = {
42 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V] 45 .constraints = {
43 | 46 .min_uV = 3300000,
44 +-> [Consumer B @ 3.3V] 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};
45 53
46Regulator-1 supplies power to Regulator-2. This relationship must be registered 54Regulator-1 supplies power to Regulator-2. This relationship must be registered
47with the core so that Regulator-1 is also enabled when Consumer A enables it's 55with the core so that Regulator-1 is also enabled when Consumer A enables it's
48supply (Regulator-2). 56supply (Regulator-2). The supply regulator is set by the supply_regulator_dev
49 57field below:-
50This relationship can be register with the core via :- 58
51 59static struct regulator_init_data regulator2_data = {
52int regulator_set_supply(const char *regulator, const char *regulator_supply); 60 .supply_regulator_dev = &platform_regulator1_device.dev,
53 61 .constraints = {
54In this example we would use the following code :- 62 .min_uV = 1800000,
55 63 .max_uV = 2000000,
56regulator_set_supply("Regulator-2", "Regulator-1"); 64 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
57 65 .valid_modes_mask = REGULATOR_MODE_NORMAL,
58Relationships can be queried by calling :- 66 },
59 67 .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers),
60const char *regulator_get_supply(const char *regulator); 68 .consumer_supplies = regulator2_consumers,
61
62
633. Power Domain constraint setting.
64===================================
65Each power domain within a system has physical constraints on voltage and
66current. This must be defined in software so that the power domain is always
67operated within specifications.
68
69Consider the following machine (again) :-
70
71 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
72 |
73 +-> [Consumer B @ 3.3V]
74
75This gives us two regulators and two power domains:
76
77 Domain 1: Regulator-2, Consumer B.
78 Domain 2: Consumer A.
79
80Constraints can be registered by calling :-
81
82int regulator_set_platform_constraints(const char *regulator,
83 struct regulation_constraints *constraints);
84
85The example is defined as follows :-
86
87struct regulation_constraints domain_1 = {
88 .min_uV = 3300000,
89 .max_uV = 3300000,
90 .valid_modes_mask = REGULATOR_MODE_NORMAL,
91}; 69};
92 70
93struct regulation_constraints domain_2 = { 71Finally the regulator devices must be registered in the usual manner.
94 .min_uV = 1800000, 72
95 .max_uV = 2000000, 73static struct platform_device regulator_devices[] = {
96 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, 74{
97 .valid_modes_mask = REGULATOR_MODE_NORMAL, 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},
98}; 88};
89/* register regulator 1 device */
90platform_device_register(&wm8350_regulator_devices[0]);
99 91
100regulator_set_platform_constraints("Regulator-1", &domain_1); 92/* register regulator 2 device */
101regulator_set_platform_constraints("Regulator-2", &domain_2); 93platform_device_register(&wm8350_regulator_devices[1]);