1 Regulator Machine Driver Interface
2 ===================================
4 The regulator machine driver interface is intended for board/machine specific
5 initialisation code to configure the regulator subsystem.
7 Consider the following machine :-
9 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
11 +-> [Consumer B @ 3.3V]
13 The drivers for consumers A & B must be mapped to the correct regulator in
14 order to control their power supply. This mapping can be achieved in machine
15 initialisation code by creating a struct regulator_consumer_supply for
18 struct regulator_consumer_supply {
19 struct device *dev; /* consumer */
20 const char *supply; /* consumer supply - e.g. "vcc" */
23 e.g. for the machine above
25 static struct regulator_consumer_supply regulator1_consumers[] = {
27 .dev = &platform_consumerB_device.dev,
31 static struct regulator_consumer_supply regulator2_consumers[] = {
33 .dev = &platform_consumerA_device.dev,
37 This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2
38 to the 'Vcc' supply for Consumer A.
40 Constraints can now be registered by defining a struct regulator_init_data
41 for each regulator power domain. This structure also maps the consumers
42 to their supply regulator :-
44 static struct regulator_init_data regulator1_data = {
48 .valid_modes_mask = REGULATOR_MODE_NORMAL,
50 .num_consumer_supplies = ARRAY_SIZE(regulator1_consumers),
51 .consumer_supplies = regulator1_consumers,
54 Regulator-1 supplies power to Regulator-2. This relationship must be registered
55 with the core so that Regulator-1 is also enabled when Consumer A enables its
56 supply (Regulator-2). The supply regulator is set by the supply_regulator_dev
59 static struct regulator_init_data regulator2_data = {
60 .supply_regulator_dev = &platform_regulator1_device.dev,
64 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
65 .valid_modes_mask = REGULATOR_MODE_NORMAL,
67 .num_consumer_supplies = ARRAY_SIZE(regulator2_consumers),
68 .consumer_supplies = regulator2_consumers,
71 Finally the regulator devices must be registered in the usual manner.
73 static struct platform_device regulator_devices[] = {
78 .platform_data = ®ulator1_data,
85 .platform_data = ®ulator2_data,
89 /* register regulator 1 device */
90 platform_device_register(®ulator_devices[0]);
92 /* register regulator 2 device */
93 platform_device_register(®ulator_devices[1]);