From: 张晴 Date: Mon, 31 Mar 2014 02:56:37 +0000 (+0800) Subject: rk3288;rk808:support two switch as ldo & enable rk808 irq to wakeup X-Git-Tag: firefly_0821_release~5705 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5351b7e59fda1a597fe8f21a8d80c0baade6bdc4;p=firefly-linux-kernel-4.4.55.git rk3288;rk808:support two switch as ldo & enable rk808 irq to wakeup --- diff --git a/arch/arm/boot/dts/rk3288-tb.dts b/arch/arm/boot/dts/rk3288-tb.dts index 382b899193cc..a35f10ecbb35 100755 --- a/arch/arm/boot/dts/rk3288-tb.dts +++ b/arch/arm/boot/dts/rk3288-tb.dts @@ -713,5 +713,17 @@ rockchip,power_type = ; regulator-always-on; regulator-boot-on; }; + + rk808_ldo9_reg: regulator@12 { + regulator-name= "rk_ldo9"; + regulator-always-on; + regulator-boot-on; + }; + + rk808_ldo10_reg: regulator@13 { + regulator-name= "rk_ldo10"; + regulator-always-on; + regulator-boot-on; + }; }; }; diff --git a/arch/arm/boot/dts/rk808.dtsi b/arch/arm/boot/dts/rk808.dtsi old mode 100755 new mode 100644 index 2983ac7001ab..eecf5355ad17 --- a/arch/arm/boot/dts/rk808.dtsi +++ b/arch/arm/boot/dts/rk808.dtsi @@ -114,7 +114,7 @@ regulator-initial-state = <3>; regulator-state-mem { regulator-state-enabled; - regulator-state-uv = <1200000>; + regulator-state-uv = <1000000>; }; }; @@ -137,6 +137,24 @@ regulator-state-uv = <1800000>; }; }; + + rk808_ldo9_reg: regulator@12{ + reg = <12>; + regulator-compatible = "rk_ldo9"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; + + rk808_ldo10_reg: regulator@13{ + reg = <13>; + regulator-compatible = "rk_ldo10"; + regulator-initial-state = <3>; + regulator-state-mem { + regulator-state-enabled; + }; + }; }; }; diff --git a/drivers/mfd/rk808-irq.c b/drivers/mfd/rk808-irq.c index dbae25e4dccf..cfaf297b15ae 100755 --- a/drivers/mfd/rk808-irq.c +++ b/drivers/mfd/rk808-irq.c @@ -221,6 +221,7 @@ int rk808_irq_init(struct rk808 *rk808, int irq,struct rk808_board *pdata) ret = request_threaded_irq(rk808->chip_irq, NULL, rk808_irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "rk808", rk808); irq_set_irq_type(rk808->chip_irq, IRQ_TYPE_LEVEL_LOW); + enable_irq_wake(rk808->chip_irq); if (ret != 0) dev_err(rk808->dev, "Failed to request IRQ: %d\n", ret); diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index 87691a6df99d..788feb5610f7 100755 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -186,8 +186,13 @@ static int rk808_ldo_suspend_enable(struct regulator_dev *dev) { struct rk808 *rk808 = rdev_get_drvdata(dev); int ldo= rdev_get_id(dev) - RK808_LDO1; - - return rk808_set_bits(rk808, RK808_SLEEP_SET_OFF_REG2, 1 << ldo, 0); + + if(ldo == 8) + return rk808_set_bits(rk808, RK808_SLEEP_SET_OFF_REG1, 1 << 5, 0); + else if(ldo ==9) + return rk808_set_bits(rk808, RK808_SLEEP_SET_OFF_REG1, 1 << 6, 0); + else + return rk808_set_bits(rk808, RK808_SLEEP_SET_OFF_REG2, 1 << ldo, 0); } static int rk808_ldo_suspend_disable(struct regulator_dev *dev) @@ -195,6 +200,11 @@ static int rk808_ldo_suspend_disable(struct regulator_dev *dev) struct rk808 *rk808 = rdev_get_drvdata(dev); int ldo= rdev_get_id(dev) - RK808_LDO1; + if(ldo == 8) + return rk808_set_bits(rk808, RK808_SLEEP_SET_OFF_REG1, 1 << 5, 1 << 5); + else if(ldo ==9) + return rk808_set_bits(rk808, RK808_SLEEP_SET_OFF_REG1, 1 << 6, 1 << 6); + else return rk808_set_bits(rk808, RK808_SLEEP_SET_OFF_REG2, 1 << ldo, 1 << ldo); } @@ -204,16 +214,24 @@ static int rk808_ldo_get_voltage(struct regulator_dev *dev) int ldo= rdev_get_id(dev) - RK808_LDO1; u16 reg = 0; int val; - reg = rk808_reg_read(rk808,rk808_LDO_SET_VOL_REG(ldo)); - reg &= LDO_VOL_MASK; - if (ldo ==2){ - val = 1000 * ldo3_voltage_map[reg]; - } - else if (ldo == 5 || ldo ==6){ - val = 1000 * ldo6_voltage_map[reg]; + + if ((ldo ==8 ) || (ldo ==9)){ + reg = rk808_reg_read(rk808,rk808_BUCK_SET_VOL_REG(3)); + reg &= BUCK_VOL_MASK; + val = 1000 * buck4_voltage_map[reg]; } else{ - val = 1000 * ldo_voltage_map[reg]; + reg = rk808_reg_read(rk808,rk808_LDO_SET_VOL_REG(ldo)); + reg &= LDO_VOL_MASK; + if (ldo ==2){ + val = 1000 * ldo3_voltage_map[reg]; + } + else if (ldo == 5 || ldo ==6){ + val = 1000 * ldo6_voltage_map[reg]; + } + else{ + val = 1000 * ldo_voltage_map[reg]; + } } return val; } @@ -687,6 +705,22 @@ static struct regulator_desc regulators[] = { .type = REGULATOR_VOLTAGE, .owner = THIS_MODULE, }, + { + .name = "RK_LDO9", + .id = 12, + .ops = &rk808_ldo_ops, + .n_voltages = ARRAY_SIZE(buck4_voltage_map), + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + }, + { + .name = "RK_LDO10", + .id = 13, + .ops = &rk808_ldo_ops, + .n_voltages = ARRAY_SIZE(buck4_voltage_map), + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + }, }; @@ -1004,6 +1038,8 @@ static struct of_regulator_match rk808_reg_matches[] = { { .name = "rk_ldo6", .driver_data = (void *)9 }, { .name = "rk_ldo7", .driver_data = (void *)10 }, { .name = "rk_ldo8", .driver_data = (void *)11 }, + { .name = "rk_ldo9", .driver_data = (void *)12 }, + { .name = "rk_ldo10", .driver_data = (void *)13 }, }; static struct rk808_board *rk808_parse_dt(struct rk808 *rk808) diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h index b79b7f5b2250..04bd5c4a82ce 100755 --- a/include/linux/mfd/rk808.h +++ b/include/linux/mfd/rk808.h @@ -104,7 +104,7 @@ #define RK808_NUM_IRQ 9 -#define rk808_NUM_REGULATORS 12 +#define rk808_NUM_REGULATORS 14 #define RK808_VBAT_LOW_2V8 0x00 #define RK808_VBAT_LOW_2V9 0x01