Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stephen Warren and committed by
Samuel Ortiz
9582fdcb 48a364b7

+28
+6
Documentation/devicetree/bindings/regulator/max8907.txt
··· 16 16 property, with valid values listed below. The content of each sub-node 17 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 23 Valid regulator-compatible values are: 20 24 21 25 sd1, sd2, sd3, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8, ldo9, ldo10, ··· 32 28 compatible = "maxim,max8907"; 33 29 reg = <0x3c>; 34 30 interrupts = <0 86 0x4>; 31 + 32 + maxim,system-power-controller; 35 33 36 34 mbatt-supply = <&some_reg>; 37 35 in-v1-supply = <&mbatt_reg>;
+20
drivers/mfd/max8907.c
··· 176 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 186 static __devinit int max8907_i2c_probe(struct i2c_client *i2c, 180 187 const struct i2c_device_id *id) 181 188 { 182 189 struct max8907 *max8907; 183 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 200 max8907 = devm_kzalloc(&i2c->dev, sizeof(struct max8907), GFP_KERNEL); 186 201 if (!max8907) { ··· 264 249 if (ret != 0) { 265 250 dev_err(&i2c->dev, "failed to add MFD devices %d\n", ret); 266 251 goto err_add_devices; 252 + } 253 + 254 + if (pm_off && !pm_power_off) { 255 + max8907_pm_off = max8907; 256 + pm_power_off = max8907_power_off; 267 257 } 268 258 269 259 return 0;
+2
include/linux/mfd/max8907.h
··· 167 167 #define MAX8907_MASK_OUT5V_VINEN 0x10 168 168 #define MAX8907_MASK_OUT5V_ENSRC 0x0E 169 169 #define MAX8907_MASK_OUT5V_EN 0x01 170 + #define MAX8907_MASK_POWER_OFF 0x40 170 171 171 172 /* Regulator IDs */ 172 173 #define MAX8907_MBATT 0 ··· 232 231 233 232 struct max8907_platform_data { 234 233 struct regulator_init_data *init_data[MAX8907_NUM_REGULATORS]; 234 + bool pm_off; 235 235 }; 236 236 237 237 struct regmap_irq_chips_data;