Skip to content

Commit b079fa7

Browse files
Bill HuangSamuel Ortiz
authored andcommitted
mfd: dt: tps65910: Add power off control
Add DT property "ti,system-power-controller" telling whether or not this pmic is in charge of controlling the system power, so the power off routine can be hooked up to system call "pm_power_off". Based on the work by: Dan Willemsen <dwillemsen@nvidia.com> Signed-off-by: Bill Huang <bilhuang@nvidia.com> Tested-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 004c15a commit b079fa7

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎Documentation/devicetree/bindings/mfd/tps65910.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Optional properties:
5959
in TPS6591X datasheet)
6060
- ti,en-gpio-sleep: enable sleep control for gpios
6161
There should be 9 entries here, one for each gpio.
62+
- ti,system-power-controller: Telling whether or not this pmic is controlling
63+
the system power.
6264

6365
Regulator Optional properties:
6466
- ti,regulator-ext-sleep-control: enable external sleep
@@ -79,6 +81,8 @@ Example:
7981
#interrupt-cells = <2>;
8082
interrupt-controller;
8183

84+
ti,system-power-controller;
85+
8286
ti,vmbch-threshold = 0;
8387
ti,vmbch2-threshold = 0;
8488
ti,en-ck32k-xtal;

‎drivers/mfd/tps65910.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
198198

199199
board_info->irq = client->irq;
200200
board_info->irq_base = -1;
201+
board_info->pm_off = of_property_read_bool(np,
202+
"ti,system-power-controller");
201203

202204
return board_info;
203205
}
@@ -210,6 +212,21 @@ struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
210212
}
211213
#endif
212214

215+
static struct i2c_client *tps65910_i2c_client;
216+
static void tps65910_power_off(void)
217+
{
218+
struct tps65910 *tps65910;
219+
220+
tps65910 = dev_get_drvdata(&tps65910_i2c_client->dev);
221+
222+
if (tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL,
223+
DEVCTRL_PWR_OFF_MASK) < 0)
224+
return;
225+
226+
tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL,
227+
DEVCTRL_DEV_ON_MASK);
228+
}
229+
213230
static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
214231
const struct i2c_device_id *id)
215232
{
@@ -267,6 +284,11 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
267284
tps65910_ck32k_init(tps65910, pmic_plat_data);
268285
tps65910_sleepinit(tps65910, pmic_plat_data);
269286

287+
if (pmic_plat_data->pm_off && !pm_power_off) {
288+
tps65910_i2c_client = i2c;
289+
pm_power_off = tps65910_power_off;
290+
}
291+
270292
return ret;
271293
}
272294

‎include/linux/mfd/tps65910.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@
366366

367367

368368
/*Register DEVCTRL (0x80) register.RegisterDescription */
369+
#define DEVCTRL_PWR_OFF_MASK 0x80
370+
#define DEVCTRL_PWR_OFF_SHIFT 7
369371
#define DEVCTRL_RTC_PWDN_MASK 0x40
370372
#define DEVCTRL_RTC_PWDN_SHIFT 6
371373
#define DEVCTRL_CK32K_CTRL_MASK 0x20
@@ -809,6 +811,7 @@ struct tps65910_board {
809811
int vmbch2_threshold;
810812
bool en_ck32k_xtal;
811813
bool en_dev_slp;
814+
bool pm_off;
812815
struct tps65910_sleep_keepon_data *slp_keepon;
813816
bool en_gpio_sleep[TPS6591X_MAX_NUM_GPIO];
814817
unsigned long regulator_ext_sleep_control[TPS65910_NUM_REGS];

0 commit comments

Comments
 (0)