diff options
author | Stephen Warren <swarren@nvidia.com> | 2012-09-18 18:51:19 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-19 06:07:56 -0400 |
commit | 9582fdcb6fcf1b596a83b161a2ea886272d2a62f (patch) | |
tree | d880190567065d64e86b29194a0ec0ca23cfb50b | |
parent | 48a364b758f861b21747a5148f26aedc504edb7f (diff) |
mfd: max8907: Add power off control
Add DT property "maxim,system-power-controller" to indicate whether the
PMIC is in charge of controlling the system power. If this is set, the
driver will provide the pm_power_off() function.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | Documentation/devicetree/bindings/regulator/max8907.txt | 6 | ||||
-rw-r--r-- | drivers/mfd/max8907.c | 20 | ||||
-rw-r--r-- | include/linux/mfd/max8907.h | 2 |
3 files changed, 28 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/regulator/max8907.txt b/Documentation/devicetree/bindings/regulator/max8907.txt index 4fd847f0afc0..51e683b2bf47 100644 --- a/Documentation/devicetree/bindings/regulator/max8907.txt +++ b/Documentation/devicetree/bindings/regulator/max8907.txt | |||
@@ -16,6 +16,10 @@ Required properties: | |||
16 | property, with valid values listed below. The content of each sub-node | 16 | property, with valid values listed below. The content of each sub-node |
17 | is defined by the standard binding for regulators; see regulator.txt. | 17 | is defined by the standard binding for regulators; see regulator.txt. |
18 | 18 | ||
19 | Optional properties: | ||
20 | - maxim,system-power-controller: Boolean property indicating that the PMIC | ||
21 | controls the overall system power. | ||
22 | |||
19 | Valid regulator-compatible values are: | 23 | Valid regulator-compatible values are: |
20 | 24 | ||
21 | sd1, sd2, sd3, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8, ldo9, ldo10, | 25 | sd1, sd2, sd3, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8, ldo9, ldo10, |
@@ -29,6 +33,8 @@ Example: | |||
29 | reg = <0x3c>; | 33 | reg = <0x3c>; |
30 | interrupts = <0 86 0x4>; | 34 | interrupts = <0 86 0x4>; |
31 | 35 | ||
36 | maxim,system-power-controller; | ||
37 | |||
32 | mbatt-supply = <&some_reg>; | 38 | mbatt-supply = <&some_reg>; |
33 | in-v1-supply = <&mbatt_reg>; | 39 | in-v1-supply = <&mbatt_reg>; |
34 | ... | 40 | ... |
diff --git a/drivers/mfd/max8907.c b/drivers/mfd/max8907.c index 6497c98e030d..2303641dd052 100644 --- a/drivers/mfd/max8907.c +++ b/drivers/mfd/max8907.c | |||
@@ -176,11 +176,26 @@ static const struct regmap_irq_chip max8907_rtc_irq_chip = { | |||
176 | .num_irqs = ARRAY_SIZE(max8907_rtc_irqs), | 176 | .num_irqs = ARRAY_SIZE(max8907_rtc_irqs), |
177 | }; | 177 | }; |
178 | 178 | ||
179 | struct max8907 *max8907_pm_off; | ||
180 | static void max8907_power_off(void) | ||
181 | { | ||
182 | regmap_update_bits(max8907_pm_off->regmap_gen, MAX8907_REG_RESET_CNFG, | ||
183 | MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF); | ||
184 | } | ||
185 | |||
179 | static __devinit int max8907_i2c_probe(struct i2c_client *i2c, | 186 | static __devinit int max8907_i2c_probe(struct i2c_client *i2c, |
180 | const struct i2c_device_id *id) | 187 | const struct i2c_device_id *id) |
181 | { | 188 | { |
182 | struct max8907 *max8907; | 189 | struct max8907 *max8907; |
183 | int ret; | 190 | int ret; |
191 | struct max8907_platform_data *pdata = dev_get_platdata(&i2c->dev); | ||
192 | bool pm_off = false; | ||
193 | |||
194 | if (pdata) | ||
195 | pm_off = pdata->pm_off; | ||
196 | else if (i2c->dev.of_node) | ||
197 | pm_off = of_property_read_bool(i2c->dev.of_node, | ||
198 | "maxim,system-power-controller"); | ||
184 | 199 | ||
185 | max8907 = devm_kzalloc(&i2c->dev, sizeof(struct max8907), GFP_KERNEL); | 200 | max8907 = devm_kzalloc(&i2c->dev, sizeof(struct max8907), GFP_KERNEL); |
186 | if (!max8907) { | 201 | if (!max8907) { |
@@ -251,6 +266,11 @@ static __devinit int max8907_i2c_probe(struct i2c_client *i2c, | |||
251 | goto err_add_devices; | 266 | goto err_add_devices; |
252 | } | 267 | } |
253 | 268 | ||
269 | if (pm_off && !pm_power_off) { | ||
270 | max8907_pm_off = max8907; | ||
271 | pm_power_off = max8907_power_off; | ||
272 | } | ||
273 | |||
254 | return 0; | 274 | return 0; |
255 | 275 | ||
256 | err_add_devices: | 276 | err_add_devices: |
diff --git a/include/linux/mfd/max8907.h b/include/linux/mfd/max8907.h index 283531fde4e0..b06f7a6a1e80 100644 --- a/include/linux/mfd/max8907.h +++ b/include/linux/mfd/max8907.h | |||
@@ -167,6 +167,7 @@ | |||
167 | #define MAX8907_MASK_OUT5V_VINEN 0x10 | 167 | #define MAX8907_MASK_OUT5V_VINEN 0x10 |
168 | #define MAX8907_MASK_OUT5V_ENSRC 0x0E | 168 | #define MAX8907_MASK_OUT5V_ENSRC 0x0E |
169 | #define MAX8907_MASK_OUT5V_EN 0x01 | 169 | #define MAX8907_MASK_OUT5V_EN 0x01 |
170 | #define MAX8907_MASK_POWER_OFF 0x40 | ||
170 | 171 | ||
171 | /* Regulator IDs */ | 172 | /* Regulator IDs */ |
172 | #define MAX8907_MBATT 0 | 173 | #define MAX8907_MBATT 0 |
@@ -231,6 +232,7 @@ enum { | |||
231 | 232 | ||
232 | struct max8907_platform_data { | 233 | struct max8907_platform_data { |
233 | struct regulator_init_data *init_data[MAX8907_NUM_REGULATORS]; | 234 | struct regulator_init_data *init_data[MAX8907_NUM_REGULATORS]; |
235 | bool pm_off; | ||
234 | }; | 236 | }; |
235 | 237 | ||
236 | struct regmap_irq_chips_data; | 238 | struct regmap_irq_chips_data; |