Skip to content

Commit 9582fdc

Browse files
Stephen WarrenSamuel Ortiz
authored andcommitted
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>
1 parent 48a364b commit 9582fdc

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎Documentation/devicetree/bindings/regulator/max8907.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Required properties:
1616
property, with valid values listed below. The content of each sub-node
1717
is defined by the standard binding for regulators; see regulator.txt.
1818

19+
Optional properties:
20+
- maxim,system-power-controller: Boolean property indicating that the PMIC
21+
controls the overall system power.
22+
1923
Valid regulator-compatible values are:
2024

2125
sd1, sd2, sd3, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8, ldo9, ldo10,
@@ -29,6 +33,8 @@ Example:
2933
reg = <0x3c>;
3034
interrupts = <0 86 0x4>;
3135

36+
maxim,system-power-controller;
37+
3238
mbatt-supply = <&some_reg>;
3339
in-v1-supply = <&mbatt_reg>;
3440
...

‎drivers/mfd/max8907.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,26 @@ static const struct regmap_irq_chip max8907_rtc_irq_chip = {
176176
.num_irqs = ARRAY_SIZE(max8907_rtc_irqs),
177177
};
178178

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+
179186
static __devinit int max8907_i2c_probe(struct i2c_client *i2c,
180187
const struct i2c_device_id *id)
181188
{
182189
struct max8907 *max8907;
183190
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");
184199

185200
max8907 = devm_kzalloc(&i2c->dev, sizeof(struct max8907), GFP_KERNEL);
186201
if (!max8907) {
@@ -251,6 +266,11 @@ static __devinit int max8907_i2c_probe(struct i2c_client *i2c,
251266
goto err_add_devices;
252267
}
253268

269+
if (pm_off && !pm_power_off) {
270+
max8907_pm_off = max8907;
271+
pm_power_off = max8907_power_off;
272+
}
273+
254274
return 0;
255275

256276
err_add_devices:

‎include/linux/mfd/max8907.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
#define MAX8907_MASK_OUT5V_VINEN 0x10
168168
#define MAX8907_MASK_OUT5V_ENSRC 0x0E
169169
#define MAX8907_MASK_OUT5V_EN 0x01
170+
#define MAX8907_MASK_POWER_OFF 0x40
170171

171172
/* Regulator IDs */
172173
#define MAX8907_MBATT 0
@@ -231,6 +232,7 @@ enum {
231232

232233
struct max8907_platform_data {
233234
struct regulator_init_data *init_data[MAX8907_NUM_REGULATORS];
235+
bool pm_off;
234236
};
235237

236238
struct regmap_irq_chips_data;

0 commit comments

Comments
 (0)