From 4b91865e1cc735a18f7b583efc21f3ab271a5ddd Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Tue, 11 Feb 2014 16:37:30 +0800 Subject: [PATCH] rk31:pmu:support pmu sleep voltage and sleep mode setting by dts --- .../devicetree/bindings/mfd/rk808.txt | 188 ++++++++++++++++++ .../devicetree/bindings/regulator/act8846.txt | 167 ++++++++++++++++ arch/arm/boot/dts/act8846.dtsi | 47 +++++ arch/arm/boot/dts/rk3188-tb.dts | 6 - arch/arm/boot/dts/rk808.dtsi | 71 ++++++- drivers/mfd/rk808.c | 94 +-------- drivers/regulator/act8846.c | 65 +----- drivers/regulator/of_regulator.c | 37 ++++ 8 files changed, 518 insertions(+), 157 deletions(-) create mode 100755 Documentation/devicetree/bindings/mfd/rk808.txt create mode 100755 Documentation/devicetree/bindings/regulator/act8846.txt mode change 100644 => 100755 drivers/regulator/of_regulator.c diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt b/Documentation/devicetree/bindings/mfd/rk808.txt new file mode 100755 index 000000000000..1b4f161690e6 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/rk808.txt @@ -0,0 +1,188 @@ +rk808 Power Management Integrated Circuit + +Required properties: +- compatible: "rockchip,rk808" +- reg: I2C slave address +- gpios: the interrupt pin or sleep pin + use gpio get IRQ number +- regulators: This is the list of child nodes that specify the regulator + initialization data for defined regulators. Not all regulators for the given + device need to be present. The definition for each of these nodes is defined + using the standard binding for regulators found at + Documentation/devicetree/bindings/regulator/regulator.txt. + The regulator is matched with the regulator-compatible. + + The valid regulator-compatible values are: + rk808: rk_dcdc1, rk_dcdc2, rk_dcdc3, rk_dcdc4, rk_ldo1, rk_ldo2, rk_ldo3, rk_ldo4, rk_ldo5, rk_ldo6, + rk_ldo7, rk_ldo8 + +Optional properties: +- gpios: + gpios 0 :irq pin gpio + gpios 1 :sleep pin gpio +- regulator-initial-mode: default mode to set on startup +- regulator-initial-state: suspend state to set at init +- regulator-state-mem, regulator-state-disk, regulator-state-standby: + defines regulator suspend to memory, suspend to disk (hibernate) and standby respectively. + have following sub-constarints: + - regulator-state-uv: suspend voltage + - regulator-state-mode: suspend regulator operating mode + - regulator-state-enabled: is regulator enabled in this suspend state + - regulator-state-disabled: is the regulator disbled in this suspend state +-regulator-initial-mode and regulator-state-mode is set as: + REGULATOR_MODE_FAST 0x1 + REGULATOR_MODE_NORMAL 0x2 + REGULATOR_MODE_IDLE 0x4 + REGULATOR_MODE_STANDBY 0x8 + +Example: + + rk808: rk808@1b { + reg = <0x1b>; + status = "okay"; + }; + + gpios =<&gpio0 GPIO_B3 GPIO_ACTIVE_HIGH>,<&gpio0 GPIO_A1 GPIO_ACTIVE_LOW>; + +&rk808 { + compatible = "rockchip,rk808"; + + regulators { + #address-cells = <1>; + #size-cells = <0>; + + rk808_dcdc1_reg: regulator@0 { + reg = <0>; + regulator-compatible = "rk_dcdc1"; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1500000>; + regulator-initial-mode = <0x2>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-mode = <0x2>; + regulator-state-enabled; + regulator-state-uv = <900000>; + }; + }; + + rk808_dcdc2_reg: regulator@1 { + reg = <1>; + regulator-compatible = "rk_dcdc2"; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1500000>; + regulator-initial-mode = <0x2>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-mode = <0x2>; + regulator-state-enabled; + regulator-state-uv = <900000>; + }; + }; + + rk808_dcdc3_reg: regulator@2 { + reg = <2>; + regulator-compatible = "rk_dcdc3"; + regulator-initial-mode = <0x2>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-mode = <0x2>; + regulator-state-enabled; + regulator-state-uv = <1200000>; + }; + }; + + rk808_dcdc4_reg: regulator@3 { + reg = <3>; + regulator-compatible = "rk_dcdc4"; + regulator-initial-mode = <0x2>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-mode = <0x2>; + regulator-state-enabled; + regulator-state-uv = <2800000>; + }; + }; + + rk808_ldo1_reg: regulator@4 { + reg = <4>; + regulator-compatible = "rk_ldo1"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <3300000>; + }; + }; + + rk808_ldo2_reg: regulator@5 { + reg = <5>; + regulator-compatible = "rk_ldo2"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <3300000>; + }; + }; + + rk808_ldo3_reg: regulator@6 { + reg = <6>; + regulator-compatible = "rk_ldo3"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1000000>; + }; + }; + + rk808_ldo4_reg: regulator@7{ + reg = <7>; + regulator-compatible = "rk_ldo4"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1800000>; + }; + }; + + rk808_ldo5_reg: regulator@8{ + reg = <8>; + regulator-compatible = "rk_ldo5"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <2800000>; + }; + }; + + rk808_ldo6_reg: regulator@9{ + reg = <9>; + regulator-compatible = "rk_ldo6"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1200000>; + }; + }; + + rk808_ldo7_reg: regulator@10 { + reg = <10>; + regulator-compatible = "rk_ldo7"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1800000>; + }; + }; + + rk808_ldo8_reg: regulator@11{ + reg = <11>; + regulator-compatible = "rk_ldo8"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1800000>; + }; + }; + + }; +}; + diff --git a/Documentation/devicetree/bindings/regulator/act8846.txt b/Documentation/devicetree/bindings/regulator/act8846.txt new file mode 100755 index 000000000000..71b2a46f7659 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/act8846.txt @@ -0,0 +1,167 @@ +act8846 Power Management Integrated Circuit + +Required properties: +- compatible: "act,act8846" +- reg: I2C slave address +- gpios: the interrupt pin or sleep pin + use gpio get IRQ number +- regulators: This is the list of child nodes that specify the regulator + initialization data for defined regulators. Not all regulators for the given + device need to be present. The definition for each of these nodes is defined + using the standard binding for regulators found at + Documentation/devicetree/bindings/regulator/regulator.txt. + The regulator is matched with the regulator-compatible. + + The valid regulator-compatible values are: + act8846: act_dcdc1, act_dcdc2, act_dcdc3, act_dcdc4, act_ldo1, act_ldo2, act_ldo3, act_ldo4, act_ldo5, act_ldo6, + act_ldo7, act_ldo8 + +Optional properties: +- gpios: + gpios 0 :vsel pin gpio + use vsel pin switch dcdc voltage when reset or power down +- regulator-initial-mode: default mode to set on startup +- regulator-initial-state: suspend state to set at init +- regulator-state-mem, regulator-state-disk, regulator-state-standby: + defines regulator suspend to memory, suspend to disk (hibernate) and standby respectively. + have following sub-constarints: + - regulator-state-uv: suspend voltage + - regulator-state-mode: suspend regulator operating mode + - regulator-state-enabled: is regulator enabled in this suspend state + - regulator-state-disabled: is the regulator disbled in this suspend state +-regulator-initial-mode and regulator-state-mode is set as: + REGULATOR_MODE_FAST 0x1 + REGULATOR_MODE_NORMAL 0x2 + REGULATOR_MODE_IDLE 0x4 + REGULATOR_MODE_STANDBY 0x8 + +Example: + + act8846: act8846@5a { + reg = <0x5a>; + status = "okay"; + }; + + gpios =<&gpio3 GPIO_D3 GPIO_ACTIVE_LOW>; +&act8846{ + + compatible = "act,act8846"; + + regulators { + + #address-cells = <1>; + #size-cells = <0>; + + dcdc1_reg: regulator@0{ + reg = <0>; + regulator-compatible= "act_dcdc1"; + }; + + 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>; + }; + }; + + 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>; + }; + }; + + dcdc4_reg: regulator@3 { + reg = <3>; + regulator-compatible = "act_dcdc4"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <3300000>; + }; + }; + + ldo1_reg: regulator@4 { + reg = <4>; + regulator-compatible= "act_ldo1"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; + + ldo2_reg: regulator@5 { + reg = <5>; + regulator-compatible = "act_ldo2"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; + + ldo3_reg: regulator@6 { + reg = <6>; + regulator-compatible = "act_ldo3"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; + + ldo4_reg:regulator@7 { + reg = <7>; + regulator-compatible = "act_ldo4"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; + + ldo5_reg: regulator@8 { + reg = <8>; + regulator-compatible= "act_ldo5"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; + + ldo6_reg: regulator@9 { + reg = <9>; + regulator-compatible = "act_ldo6"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; + + ldo7_reg: regulator@10 { + reg = <10>; + regulator-compatible = "act_ldo7"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; + + ldo8_reg: regulator@11 { + reg = <11>; + regulator-compatible = "act_ldo8"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; + }; + +}; \ No newline at end of file diff --git a/arch/arm/boot/dts/act8846.dtsi b/arch/arm/boot/dts/act8846.dtsi index a69b8ba9b2f8..33032f0c3526 100644 --- a/arch/arm/boot/dts/act8846.dtsi +++ b/arch/arm/boot/dts/act8846.dtsi @@ -18,6 +18,11 @@ 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>; + }; }; dcdc3_reg: regulator@2 { @@ -25,51 +30,93 @@ 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>; + }; }; dcdc4_reg: regulator@3 { reg = <3>; regulator-compatible = "act_dcdc4"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <3300000>; + }; }; ldo1_reg: regulator@4 { reg = <4>; regulator-compatible= "act_ldo1"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; }; ldo2_reg: regulator@5 { reg = <5>; regulator-compatible = "act_ldo2"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; }; ldo3_reg: regulator@6 { reg = <6>; regulator-compatible = "act_ldo3"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; }; ldo4_reg:regulator@7 { reg = <7>; regulator-compatible = "act_ldo4"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; }; ldo5_reg: regulator@8 { reg = <8>; regulator-compatible= "act_ldo5"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; }; ldo6_reg: regulator@9 { reg = <9>; regulator-compatible = "act_ldo6"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; }; ldo7_reg: regulator@10 { reg = <10>; regulator-compatible = "act_ldo7"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; }; ldo8_reg: regulator@11 { reg = <11>; regulator-compatible = "act_ldo8"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; }; }; diff --git a/arch/arm/boot/dts/rk3188-tb.dts b/arch/arm/boot/dts/rk3188-tb.dts index 6c5f22e4ba00..6ae2aa4ffb40 100644 --- a/arch/arm/boot/dts/rk3188-tb.dts +++ b/arch/arm/boot/dts/rk3188-tb.dts @@ -135,8 +135,6 @@ /include/ "act8846.dtsi" &act8846 { gpios =<&gpio3 GPIO_D3 GPIO_ACTIVE_LOW>; - act,pmic-dcdc-sleep-voltage = <1200000>,<1200000>,<1200000>,<3000000>; - act,pmic-ldo-sleep-voltage = <1000000>,<1200000>,<1800000>,<3300000>,<3300000>,<3300000>,<1800000>,<2800000>; regulators { @@ -236,8 +234,6 @@ regulators { /include/ "rk808.dtsi" &rk808{ gpios =<&gpio0 GPIO_B3 GPIO_ACTIVE_HIGH>,<&gpio0 GPIO_A1 GPIO_ACTIVE_LOW>; - rockchip,pmic-dcdc-sleep-voltage = <900000>,<900000>,<1200000>,<3000000>; - rockchip,pmic-ldo-sleep-voltage = <3300000>,<3300000>,<1000000>,<1800000>,<2800000>,<1200000>,<1800000>,<1800000>; regulators { @@ -245,14 +241,12 @@ regulators { regulator-name= "vdd_arm"; regulator-always-on; regulator-boot-on; - /* regulator-initial-mode = <2>;*/ }; rk808_dcdc2_reg: regulator@1 { regulator-name= "vdd_logic"; regulator-always-on; regulator-boot-on; - /* regulator-initial-mode = <2>;*/ }; rk808_dcdc3_reg: regulator@2 { diff --git a/arch/arm/boot/dts/rk808.dtsi b/arch/arm/boot/dts/rk808.dtsi index 2ad195719137..10829ad669c3 100644 --- a/arch/arm/boot/dts/rk808.dtsi +++ b/arch/arm/boot/dts/rk808.dtsi @@ -1,5 +1,4 @@ - &rk808 { compatible = "rockchip,rk808"; @@ -12,63 +11,131 @@ regulator-compatible = "rk_dcdc1"; regulator-min-microvolt = <700000>; regulator-max-microvolt = <1500000>; + regulator-initial-mode = <0x2>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-mode = <0x2>; + regulator-state-enabled; + regulator-state-uv = <900000>; + }; }; rk808_dcdc2_reg: regulator@1 { reg = <1>; regulator-compatible = "rk_dcdc2"; regulator-min-microvolt = <700000>; - regulator-max-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; + regulator-initial-mode = <0x2>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-mode = <0x2>; + regulator-state-enabled; + regulator-state-uv = <900000>; + }; }; rk808_dcdc3_reg: regulator@2 { reg = <2>; regulator-compatible = "rk_dcdc3"; + regulator-initial-mode = <0x2>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-mode = <0x2>; + regulator-state-enabled; + regulator-state-uv = <1200000>; + }; }; rk808_dcdc4_reg: regulator@3 { reg = <3>; regulator-compatible = "rk_dcdc4"; + regulator-initial-mode = <0x2>; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-mode = <0x2>; + regulator-state-enabled; + regulator-state-uv = <2800000>; + }; }; rk808_ldo1_reg: regulator@4 { reg = <4>; regulator-compatible = "rk_ldo1"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <3300000>; + }; }; rk808_ldo2_reg: regulator@5 { reg = <5>; regulator-compatible = "rk_ldo2"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <3300000>; + }; }; rk808_ldo3_reg: regulator@6 { reg = <6>; regulator-compatible = "rk_ldo3"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1000000>; + }; }; rk808_ldo4_reg: regulator@7{ reg = <7>; regulator-compatible = "rk_ldo4"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1800000>; + }; }; rk808_ldo5_reg: regulator@8{ reg = <8>; regulator-compatible = "rk_ldo5"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <2800000>; + }; }; rk808_ldo6_reg: regulator@9{ reg = <9>; regulator-compatible = "rk_ldo6"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1200000>; + }; }; rk808_ldo7_reg: regulator@10 { reg = <10>; regulator-compatible = "rk_ldo7"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1800000>; + }; }; rk808_ldo8_reg: regulator@11{ reg = <11>; regulator-compatible = "rk_ldo8"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + regulator-state-uv = <1800000>; + }; }; }; diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index f8c17039ea9f..6ec645c5df9c 100755 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -993,84 +993,15 @@ static struct rk808_board *rk808_parse_dt(struct rk808 *rk808) return NULL; } - if (of_get_property(rk808_pmic_np, "rockchip,pmic-dcdc-sleep-voltage", NULL)) - pdata->pmic_sleep = true; - - if (of_get_property(rk808_pmic_np, "rockchip,pmic-ldo-sleep-voltage", NULL)) - pdata->pmic_sleep = true; - if (pdata->pmic_sleep){ - pdata->pmic_sleep_gpio = of_get_named_gpio(rk808_pmic_np,"gpios",1); + pdata->pmic_sleep_gpio = of_get_named_gpio(rk808_pmic_np,"gpios",1); if (!gpio_is_valid(pdata->pmic_sleep_gpio)) { printk("invalid gpio: %d\n", pdata->pmic_sleep_gpio); - } - } - if (of_property_read_u32_array(rk808_pmic_np, - "rockchip,pmic-dcdc-sleep-voltage", - pdata->dcdc_slp_voltage, 4)) { - printk("dcdc sleep voltages not specified\n"); - } - - if (of_property_read_u32_array(rk808_pmic_np, - "rockchip,pmic-ldo-sleep-voltage", - pdata->ldo_slp_voltage, 8)) { - printk("ldo sleep voltages not specified\n"); - } - + } + pdata->pmic_sleep = true; + return pdata; } -static int rk808_dcdc_sleep_voltage_get_val(int min_uV,int buck) -{ - u16 vsel =0; - - if (buck == 0 || buck == 1){ - if (min_uV < 700000) - vsel = 0; - else if (min_uV <= 1500000) - vsel = ((min_uV - 700000) / 12500) ; - else - return -EINVAL; - } - else if (buck ==3){ - if (min_uV < 1800000) - vsel = 0; - else if (min_uV <= 3300000) - vsel = ((min_uV - 1800000) / 100000) ; - else - return -EINVAL; - } - return vsel; -} -static int rk808_ldo_sleep_voltage_get_val(int min_uV,int ldo) -{ - const int *vol_map; - int min_vol = min_uV / 1000; - int num =0; - u16 val; - - if (ldo ==2){ - vol_map = ldo3_voltage_map; - num = 15; - } - else if (ldo == 5 || ldo ==6){ - vol_map = ldo6_voltage_map; - num = 17; - } - else { - vol_map = ldo_voltage_map; - num = 16; - } - - if (min_vol < vol_map[0] || - min_vol > vol_map[num]) - return -EINVAL; - for (val = 0; val <= num; val++){ - if (vol_map[val] >= min_vol) - break; - } - - return val; -} #else static struct rk808_board *rk808_parse_dt(struct i2c_client *i2c) { @@ -1192,6 +1123,7 @@ static int rk808_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i } rk808_set_bits(rk808,0x21,(1<<4),(1 <<4)); rk808_set_bits(rk808,0x21,(7<<0),(7 <<0)); + rk808_set_bits(rk808,0x23,(7<<4),(7 <<4)); //enable boost &swith0\1 if (ret < 0) goto err; @@ -1208,24 +1140,10 @@ static int rk808_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i dev_err(rk808->dev,"Failed to request gpio %d with ret:""%d\n", rk808->pmic_sleep_gpio, ret); return IRQ_NONE; } - gpio_direction_input(rk808->pmic_sleep_gpio); + gpio_direction_output(rk808->pmic_sleep_gpio,0); ret = gpio_get_value(rk808->pmic_sleep_gpio); gpio_free(rk808->pmic_sleep_gpio); pr_info("%s: rk808_pmic_sleep=%x\n", __func__, ret); - } - for (i = 0;i <4 ; i ++){ - rk808->dcdc_slp_voltage[i] = pdev->dcdc_slp_voltage[i]; - if (rk808->dcdc_slp_voltage[i]){ - if (i ==2) - continue; - ret = rk808_set_bits(rk808, (rk808_BUCK_SET_VOL_REG(i) + 0x01), BUCK_VOL_MASK, rk808_dcdc_sleep_voltage_get_val(rk808->dcdc_slp_voltage[i],i)); - } - } - for (i = 0;i <8 ; i ++){ - rk808->ldo_slp_voltage[i] = pdev->ldo_slp_voltage[i]; - if (rk808->ldo_slp_voltage[i] ==0) - ret = rk808_set_bits(rk808, RK808_LDO_EN_REG, 1 << i, 0); - ret = rk808_set_bits(rk808, (rk808_LDO_SET_VOL_REG(i) + 0x01), LDO_VOL_MASK, rk808_ldo_sleep_voltage_get_val(rk808->ldo_slp_voltage[i],i)); } #endif /**********************************************************/ diff --git a/drivers/regulator/act8846.c b/drivers/regulator/act8846.c index be07922ce36c..65129800aa71 100755 --- a/drivers/regulator/act8846.c +++ b/drivers/regulator/act8846.c @@ -716,7 +716,7 @@ static struct act8846_board *act8846_parse_dt(struct act8846 *act8846) struct act8846_board *pdata; struct device_node *regs; struct device_node *act8846_pmic_np; - int i, count,sleep_voltage_nr =1; + int i, count; int gpio; printk("%s,line=%d\n", __func__,__LINE__); @@ -748,59 +748,15 @@ static struct act8846_board *act8846_parse_dt(struct act8846 *act8846) pdata->irq = act8846->chip_irq; pdata->irq_base = -1; - if (of_get_property(act8846_pmic_np, "act,pmic-dcdc-sleep-voltage", NULL)) - pdata->pmic_sleep = true; - - if (of_get_property(act8846_pmic_np, "act,pmic-ldo-sleep-voltage", NULL)) - pdata->pmic_sleep = true; - gpio = of_get_named_gpio(act8846_pmic_np,"gpios", 0); if (!gpio_is_valid(gpio)) printk("invalid gpio: %d\n",gpio); - pdata->pmic_sleep_gpio = gpio; - - if (of_property_read_u32_array(act8846_pmic_np, - "act,pmic-dcdc-sleep-voltage", - pdata->dcdc_slp_voltage, sleep_voltage_nr)) { - printk("dcdc sleep voltages not specified\n"); - } + pdata->pmic_sleep_gpio = gpio; + pdata->pmic_sleep = true; return pdata; } -static int act8846_dcdc_sleep_voltage_get_val(int min_uV,int buck) -{ - int min_vol = min_uV / 1000, max_vol = min_uV / 1000; - const int *vol_map = buck_voltage_map; - u16 val; - - if (min_vol < vol_map[VOL_MIN_IDX] || - min_vol > vol_map[VOL_MAX_IDX]) - return -EINVAL; - for (val = VOL_MIN_IDX; val <= VOL_MAX_IDX; val++){ - if (vol_map[val] >= min_vol) - break; - } - - if (vol_map[val] > max_vol) - printk("WARNING:this voltage is not support!voltage set is %d mv\n",vol_map[val]); - return val; -} -static int act8846_dts_dcdc_set_mode(unsigned int mode,int buck) -{ - struct act8846 *act8846 = g_act8846; - u16 mask = 0x80; - switch(mode) - { - case REGULATOR_MODE_STANDBY: - return act8846_set_bits(act8846, act8846_BUCK_CONTR_REG(buck), mask, 0); - case REGULATOR_MODE_NORMAL: - return act8846_set_bits(act8846, act8846_BUCK_CONTR_REG(buck), mask, mask); - default: - printk("error:pmu_act8846 only powersave and pwm mode\n"); - return -EINVAL; - } -} #else static struct act8846_board *act8846_parse_dt(struct i2c_client *i2c) { @@ -940,24 +896,11 @@ static int act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id dev_err(act8846->dev,"Failed to request gpio %d with ret:""%d\n", act8846->pmic_sleep_gpio, ret); return IRQ_NONE; } - gpio_direction_input(act8846->pmic_sleep_gpio); + gpio_direction_output(act8846->pmic_sleep_gpio,0); ret = gpio_get_value(act8846->pmic_sleep_gpio); gpio_free(act8846->pmic_sleep_gpio); printk("%s: act8846_pmic_sleep=%x\n", __func__, ret); } - for (i = 0;i <4 ; i ++){ - act8846->dcdc_slp_voltage[i] = pdev->dcdc_slp_voltage[i]; - if (act8846->dcdc_slp_voltage[i]){ - if (i ==0) - continue; - - #ifdef CONFIG_ACT8846_SUPPORT_RESET - ret = act8846_set_bits(act8846, act8846_BUCK_SET_VOL_REG(i) ,BUCK_VOL_MASK, act8846_dcdc_sleep_voltage_get_val(act8846->dcdc_slp_voltage[i],i)); - #else - ret = act8846_set_bits(act8846, (act8846_BUCK_SET_VOL_REG(i) +0x01),BUCK_VOL_MASK, act8846_dcdc_sleep_voltage_get_val(act8846->dcdc_slp_voltage[i],i)); - #endif - } - } #endif if (pdev) { diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c old mode 100644 new mode 100755 index 66ca769287ab..a90e3d89221c --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -16,11 +16,21 @@ #include #include +static void set_regulator_state_constraints(struct device_node *np, + struct regulator_state *state) +{ + of_property_read_u32(np, "regulator-state-uv", &state->uV); + of_property_read_u32(np, "regulator-state-mode", &state->mode); + state->enabled = of_property_read_bool(np, "regulator-state-enabled"); + state->disabled = of_property_read_bool(np, "regulator-state-disabled"); +} + static void of_get_regulation_constraints(struct device_node *np, struct regulator_init_data **init_data) { const __be32 *min_uV, *max_uV, *uV_offset; const __be32 *min_uA, *max_uA, *ramp_delay; + struct device_node *state; struct regulation_constraints *constraints = &(*init_data)->constraints; constraints->name = of_get_property(np, "regulator-name", NULL); @@ -64,6 +74,33 @@ static void of_get_regulation_constraints(struct device_node *np, ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL); if (ramp_delay) constraints->ramp_delay = be32_to_cpu(*ramp_delay); + + of_property_read_u32(np, "regulator-valid-modes-mask", + &constraints->valid_modes_mask); + of_property_read_u32(np, "regulator-input-uv", + &constraints->input_uV); + of_property_read_u32(np, "regulator-initial-mode", + &constraints->initial_mode); + of_property_read_u32(np, "regulator-initial-state", + &constraints->initial_state); + + /* regulator state during low power system states */ + state = of_find_node_by_name(np, "regulator-state-mem"); + if (state) + set_regulator_state_constraints(state, + &constraints->state_mem); + + state = of_find_node_by_name(np, "regulator-state-disk"); + if (state) + set_regulator_state_constraints(state, + &constraints->state_disk); + + state = of_find_node_by_name(np, "regulator-state-standby"); + if (state) + set_regulator_state_constraints(state, + &constraints->state_standby); + + } /** -- 2.34.1