From 942b86cab9cfb105fb3e531c774a647f9a08ce13 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Mon, 12 May 2014 17:48:17 +0800 Subject: [PATCH] rk3288:pmic:act8846:support pmic act8846 for new hardware --- arch/arm/boot/dts/act8846.dtsi | 75 ++++++------------- arch/arm/boot/dts/rk3188-tb.dts | 49 +++++++------ arch/arm/boot/dts/rk3288-tb.dts | 118 ++++++++++++++++++++++++++++++ drivers/regulator/act8846.c | 52 +++++++++++-- include/linux/regulator/act8846.h | 1 + 5 files changed, 216 insertions(+), 79 deletions(-) mode change 100755 => 100644 arch/arm/boot/dts/rk3188-tb.dts mode change 100755 => 100644 arch/arm/boot/dts/rk3288-tb.dts diff --git a/arch/arm/boot/dts/act8846.dtsi b/arch/arm/boot/dts/act8846.dtsi index 33032f0c3526..421a09a52e14 100644 --- a/arch/arm/boot/dts/act8846.dtsi +++ b/arch/arm/boot/dts/act8846.dtsi @@ -11,112 +11,85 @@ dcdc1_reg: regulator@0{ reg = <0>; regulator-compatible= "act_dcdc1"; + regulator-always-on; + regulator-boot-on; }; dcdc2_reg: regulator@1 { reg = <1>; regulator-compatible = "act_dcdc2"; - regulator-min-microvolt = <800000>; - regulator-max-microvolt = <1500000>; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - regulator-state-uv = <1200000>; - }; + regulator-always-on; + regulator-boot-on; }; dcdc3_reg: regulator@2 { reg = <2>; regulator-compatible = "act_dcdc3"; - regulator-min-microvolt = <800000>; - regulator-max-microvolt = <1500000>; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - regulator-state-uv = <1200000>; - }; + regulator-always-on; + regulator-boot-on; }; dcdc4_reg: regulator@3 { reg = <3>; regulator-compatible = "act_dcdc4"; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - regulator-state-uv = <3300000>; - }; + regulator-always-on; + regulator-boot-on; }; ldo1_reg: regulator@4 { reg = <4>; regulator-compatible= "act_ldo1"; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - }; + regulator-always-on; + regulator-boot-on; }; ldo2_reg: regulator@5 { reg = <5>; regulator-compatible = "act_ldo2"; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - }; + regulator-always-on; + regulator-boot-on; }; ldo3_reg: regulator@6 { reg = <6>; regulator-compatible = "act_ldo3"; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - }; + regulator-always-on; + regulator-boot-on; }; ldo4_reg:regulator@7 { reg = <7>; regulator-compatible = "act_ldo4"; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - }; + regulator-always-on; + regulator-boot-on; }; ldo5_reg: regulator@8 { reg = <8>; regulator-compatible= "act_ldo5"; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - }; + regulator-always-on; + regulator-boot-on; }; ldo6_reg: regulator@9 { reg = <9>; regulator-compatible = "act_ldo6"; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - }; + regulator-always-on; + regulator-boot-on; }; ldo7_reg: regulator@10 { reg = <10>; regulator-compatible = "act_ldo7"; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - }; + regulator-always-on; + regulator-boot-on; }; ldo8_reg: regulator@11 { reg = <11>; regulator-compatible = "act_ldo8"; - regulator-initial-state = <3>; - regulator-state-mem { - regulator-state-enabled; - }; + regulator-always-on; + regulator-boot-on; }; }; diff --git a/arch/arm/boot/dts/rk3188-tb.dts b/arch/arm/boot/dts/rk3188-tb.dts old mode 100755 new mode 100644 index 60acca2cc54e..2d8c2fc9bf76 --- a/arch/arm/boot/dts/rk3188-tb.dts +++ b/arch/arm/boot/dts/rk3188-tb.dts @@ -518,86 +518,91 @@ dcdc2_reg: regulator@1 { regulator-name= "vdd_logic"; - regulator-always-on; - regulator-boot-on; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1500000>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1200000>; + }; }; dcdc3_reg: regulator@2 { regulator-name= "vdd_arm"; - regulator-always-on; - regulator-boot-on; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1500000>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1200000>; + }; }; dcdc4_reg: regulator@3 { regulator-name= "vccio"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <3300000>; - regulator-always-on; - regulator-boot-on; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <3300000>; + }; }; ldo1_reg: regulator@4 { regulator-name= "act_ldo1"; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <1000000>; - regulator-always-on; - regulator-boot-on; + }; ldo2_reg: regulator@5 { regulator-name= "act_ldo2"; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <1200000>; - regulator-always-on; - regulator-boot-on; + }; ldo3_reg: regulator@6 { regulator-name= "act_ldo3"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; - regulator-always-on; - regulator-boot-on; + }; ldo4_reg:regulator@7 { regulator-name= "act_ldo4"; regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; - regulator-always-on; - regulator-boot-on; + }; ldo5_reg: regulator@8 { regulator-name= "act_ldo5"; regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; - regulator-always-on; - regulator-boot-on; + }; ldo6_reg: regulator@9 { regulator-name= "act_ldo6"; regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; - regulator-always-on; - regulator-boot-on; + }; ldo7_reg: regulator@10 { regulator-name= "act_ldo7"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; - regulator-always-on; - regulator-boot-on; + }; ldo8_reg: regulator@11 { regulator-name= "act_ldo8"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <2800000>; - regulator-always-on; - regulator-boot-on; + }; }; }; diff --git a/arch/arm/boot/dts/rk3288-tb.dts b/arch/arm/boot/dts/rk3288-tb.dts old mode 100755 new mode 100644 index 078bc6b4f6c5..114645f8a042 --- a/arch/arm/boot/dts/rk3288-tb.dts +++ b/arch/arm/boot/dts/rk3288-tb.dts @@ -388,6 +388,10 @@ }; }; }; + act8846: act8846@5a { + reg = <0x5a>; + status = "okay"; + }; ricoh619: ricoh619@32 { reg = <0x32>; @@ -712,6 +716,120 @@ rockchip,power_type = ; auto-freq=<1>; status="okay"; }; +/include/ "act8846.dtsi" +&act8846 { + gpios =<&gpio7 GPIO_A1 GPIO_ACTIVE_LOW>,<&gpio0 GPIO_B2 GPIO_ACTIVE_HIGH>; + + regulators { + + dcdc1_reg: regulator@0{ + regulator-name= "act_dcdc1"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; + regulator-boot-on; + }; + + dcdc2_reg: regulator@1 { + regulator-name= "vccio"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <3300000>; + }; + }; + + dcdc3_reg: regulator@2 { + regulator-name= "vdd_logic"; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1500000>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1200000>; + }; + + }; + + dcdc4_reg: regulator@3 { + regulator-name= "act_dcdc4"; + regulator-min-microvolt = <2000000>; + regulator-max-microvolt = <2000000>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <2000000>; + }; + }; + + ldo1_reg: regulator@4 { + regulator-name= "vccio_sd"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + }; + + ldo2_reg: regulator@5 { + regulator-name= "act_ldo2"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + + }; + + ldo3_reg: regulator@6 { + regulator-name= "act_ldo3"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + + }; + + ldo4_reg:regulator@7 { + regulator-name= "act_ldo4"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + }; + + ldo5_reg: regulator@8 { + regulator-name= "act_ldo5"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + }; + + ldo6_reg: regulator@9 { + regulator-name= "act_ldo6"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + + }; + + ldo7_reg: regulator@10 { + regulator-name= "vcc_18"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + + }; + + ldo8_reg: regulator@11 { + regulator-name= "act_ldo8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + + }; + }; +}; + /include/ "rk808.dtsi" &rk808 { diff --git a/drivers/regulator/act8846.c b/drivers/regulator/act8846.c index 9046baee8bba..badf442e32c2 100755 --- a/drivers/regulator/act8846.c +++ b/drivers/regulator/act8846.c @@ -57,6 +57,7 @@ struct act8846 { int irq_base; int chip_irq; int pmic_sleep_gpio; /* */ + int pmic_hold_gpio; /* */ unsigned int dcdc_slp_voltage[3]; /* buckx_voltage in uV */ bool pmic_sleep; struct regmap *regmap; @@ -383,6 +384,9 @@ static int act8846_dcdc_set_voltage(struct regulator_dev *dev, #else ret = act8846_set_bits(act8846, act8846_BUCK_SET_VOL_REG(buck) ,BUCK_VOL_MASK, val); #endif + + if(ret < 0) + printk("##################:set voltage error!voltage set is %d mv\n",vol_map[val]); return ret; } @@ -622,7 +626,7 @@ static int act8846_i2c_read(struct i2c_client *i2c, char reg, int count, u16 *de DBG("***run in %s %d msgs[1].buf = %d\n",__FUNCTION__,__LINE__,*(msgs[1].buf)); - return 0; + return ret; } static int act8846_i2c_write(struct i2c_client *i2c, char reg, int count, const u16 src) @@ -655,10 +659,15 @@ static int act8846_i2c_write(struct i2c_client *i2c, char reg, int count, const static u8 act8846_reg_read(struct act8846 *act8846, u8 reg) { u16 val = 0; + int ret; mutex_lock(&act8846->io_lock); - act8846_i2c_read(act8846->i2c, reg, 1, &val); + ret = act8846_i2c_read(act8846->i2c, reg, 1, &val); + if(ret < 0){ + mutex_unlock(&act8846->io_lock); + return ret; + } DBG("reg read 0x%02x -> 0x%02x\n", (int)reg, (unsigned)val&0xff); @@ -675,13 +684,24 @@ static int act8846_set_bits(struct act8846 *act8846, u8 reg, u16 mask, u16 val) mutex_lock(&act8846->io_lock); ret = act8846_i2c_read(act8846->i2c, reg, 1, &tmp); + if(ret < 0){ + mutex_unlock(&act8846->io_lock); + return ret; + } DBG("1 reg read 0x%02x -> 0x%02x\n", (int)reg, (unsigned)tmp&0xff); tmp = (tmp & ~mask) | val; - if (ret == 0) { - ret = act8846_i2c_write(act8846->i2c, reg, 1, tmp); - DBG("reg write 0x%02x -> 0x%02x\n", (int)reg, (unsigned)val&0xff); + ret = act8846_i2c_write(act8846->i2c, reg, 1, tmp); + if(ret < 0){ + mutex_unlock(&act8846->io_lock); + return ret; + } + DBG("reg write 0x%02x -> 0x%02x\n", (int)reg, (unsigned)val&0xff); + + ret = act8846_i2c_read(act8846->i2c, reg, 1, &tmp); + if(ret < 0){ + mutex_unlock(&act8846->io_lock); + return ret; } - act8846_i2c_read(act8846->i2c, reg, 1, &tmp); DBG("2 reg read 0x%02x -> 0x%02x\n", (int)reg, (unsigned)tmp&0xff); mutex_unlock(&act8846->io_lock); @@ -754,6 +774,11 @@ static struct act8846_board *act8846_parse_dt(struct act8846 *act8846) printk("invalid gpio: %d\n",gpio); pdata->pmic_sleep_gpio = gpio; pdata->pmic_sleep = true; + + gpio = of_get_named_gpio(act8846_pmic_np,"gpios", 1); + if (!gpio_is_valid(gpio)) + printk("invalid gpio: %d\n",gpio); + pdata->pmic_hold_gpio = gpio; return pdata; } @@ -887,6 +912,21 @@ static int act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id if (act8846->dev->of_node) pdev = act8846_parse_dt(act8846); + + #ifdef CONFIG_OF + act8846->pmic_hold_gpio = pdev->pmic_hold_gpio; + if (act8846->pmic_hold_gpio) { + ret = gpio_request(act8846->pmic_hold_gpio, "act8846_pmic_hold"); + if (ret < 0) { + dev_err(act8846->dev,"Failed to request gpio %d with ret:""%d\n", act8846->pmic_hold_gpio, ret); + return IRQ_NONE; + } + gpio_direction_output(act8846->pmic_hold_gpio,1); + ret = gpio_get_value(act8846->pmic_hold_gpio); + gpio_free(act8846->pmic_hold_gpio); + printk("%s: act8846_pmic_hold=%x\n", __func__, ret); + } + #endif /******************************set sleep vol & dcdc mode******************/ #ifdef CONFIG_OF diff --git a/include/linux/regulator/act8846.h b/include/linux/regulator/act8846.h index 1e9cbaaa3d1b..a2679afe25a2 100755 --- a/include/linux/regulator/act8846.h +++ b/include/linux/regulator/act8846.h @@ -35,6 +35,7 @@ struct act8846_board { struct regulator_init_data *act8846_init_data[act8846_NUM_REGULATORS]; struct device_node *of_node[act8846_NUM_REGULATORS]; int pmic_sleep_gpio; /* */ + int pmic_hold_gpio; /* */ unsigned int dcdc_slp_voltage[3]; /* buckx_voltage in uV */ unsigned int dcdc_mode[3]; /* buckx_voltage in uV */ bool pmic_sleep; -- 2.34.1