From e1053d40cdd47eb919c5246c2e3935749d3f46b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Thu, 15 May 2014 16:31:23 +0800 Subject: [PATCH] rk3288:pmic:act8846:support act8846 device shutdown --- arch/arm/boot/dts/rk3288-tb.dts | 1 + arch/arm/configs/rockchip_defconfig | 1 + drivers/regulator/act8846.c | 14 ++++++++++++-- include/linux/regulator/act8846.h | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/rk3288-tb.dts b/arch/arm/boot/dts/rk3288-tb.dts index e9f787f4605f..23ec27379ef2 100755 --- a/arch/arm/boot/dts/rk3288-tb.dts +++ b/arch/arm/boot/dts/rk3288-tb.dts @@ -726,6 +726,7 @@ rockchip,power_type = ; /include/ "act8846.dtsi" &act8846 { gpios =<&gpio7 GPIO_A1 GPIO_ACTIVE_LOW>,<&gpio0 GPIO_B2 GPIO_ACTIVE_HIGH>; + act8846,system-power-controller; regulators { diff --git a/arch/arm/configs/rockchip_defconfig b/arch/arm/configs/rockchip_defconfig index 690a64f7dca1..a211f5651946 100755 --- a/arch/arm/configs/rockchip_defconfig +++ b/arch/arm/configs/rockchip_defconfig @@ -333,6 +333,7 @@ CONFIG_MFD_RICOH619=y CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_ACT8846=y +CONFIG_ACT8846_SUPPORT_RESET=y CONFIG_ROCKCHIP_PWM_REGULATOR=y CONFIG_REGULATOR_SYR82X=y CONFIG_REGULATOR_RICOH619=y diff --git a/drivers/regulator/act8846.c b/drivers/regulator/act8846.c index 15db2a2a71a6..0903b63a1e88 100755 --- a/drivers/regulator/act8846.c +++ b/drivers/regulator/act8846.c @@ -779,6 +779,7 @@ static struct act8846_board *act8846_parse_dt(struct act8846 *act8846) if (!gpio_is_valid(gpio)) printk("invalid gpio: %d\n",gpio); pdata->pmic_hold_gpio = gpio; + pdata->pm_off = of_property_read_bool(act8846_pmic_np,"act8846,system-power-controller"); return pdata; } @@ -798,7 +799,11 @@ int act8846_device_shutdown(void) struct act8846 *act8846 = g_act8846; printk("%s\n",__func__); - +#if 1 + if (act8846->pmic_hold_gpio) { + gpio_direction_output(act8846->pmic_hold_gpio,0); + } +#else ret = act8846_reg_read(act8846,0xc3); ret = act8846_set_bits(act8846, 0xc3,(0x1<<3),(0x1<<3)); ret = act8846_set_bits(act8846, 0xc3,(0x1<<4),(0x1<<4)); @@ -806,6 +811,7 @@ int act8846_device_shutdown(void) printk("act8846 set 0xc3 error!\n"); return err; } +#endif return 0; } EXPORT_SYMBOL_GPL(act8846_device_shutdown); @@ -923,7 +929,7 @@ static int act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id } gpio_direction_output(act8846->pmic_hold_gpio,1); ret = gpio_get_value(act8846->pmic_hold_gpio); - gpio_free(act8846->pmic_hold_gpio); + // gpio_free(act8846->pmic_hold_gpio); printk("%s: act8846_pmic_hold=%x\n", __func__, ret); } #endif @@ -977,6 +983,10 @@ static int act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id act8846->rdev[i] = act_rdev; } } + + if (pdev->pm_off && !pm_power_off) { + pm_power_off = act8846_device_shutdown; + } #ifdef CONFIG_HAS_EARLYSUSPEND act8846->act8846_suspend.suspend = act8846_early_suspend, diff --git a/include/linux/regulator/act8846.h b/include/linux/regulator/act8846.h index a2679afe25a2..866291fbd3bb 100755 --- a/include/linux/regulator/act8846.h +++ b/include/linux/regulator/act8846.h @@ -40,6 +40,7 @@ struct act8846_board { unsigned int dcdc_mode[3]; /* buckx_voltage in uV */ bool pmic_sleep; unsigned int ldo_slp_voltage[7]; + bool pm_off; }; struct act8846_regulator_subdev { -- 2.34.1