rk3288:pmic:act8846:support pmic act8846 for new hardware
author张晴 <zhangqing@rock-chips.com>
Mon, 12 May 2014 09:48:17 +0000 (17:48 +0800)
committer张晴 <zhangqing@rock-chips.com>
Mon, 12 May 2014 09:48:17 +0000 (17:48 +0800)
arch/arm/boot/dts/act8846.dtsi
arch/arm/boot/dts/rk3188-tb.dts [changed mode: 0755->0644]
arch/arm/boot/dts/rk3288-tb.dts [changed mode: 0755->0644]
drivers/regulator/act8846.c
include/linux/regulator/act8846.h

index 33032f0c35269ac342ce4f562b1cd546993217f3..421a09a52e1418e6c0fef4c9f2827351a64d146d 100644 (file)
                 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;
                };
        };
                
old mode 100755 (executable)
new mode 100644 (file)
index 60acca2..2d8c2fc
 
                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;
+               
                };
        };
 };
old mode 100755 (executable)
new mode 100644 (file)
index 078bc6b..114645f
                };
           };
        };
+       act8846: act8846@5a {
+               reg = <0x5a>;
+               status = "okay";
+       };
 
        ricoh619: ricoh619@32 {
                reg = <0x32>;
@@ -712,6 +716,120 @@ rockchip,power_type = <GPIO>;
        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 {
index 9046baee8bba037b8ab9182729218986dcc173e3..badf442e32c2ed46a3038a5ea55793a9b6b7ed68 100755 (executable)
@@ -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
index 1e9cbaaa3d1b4a6dceff898697de5d7218926811..a2679afe25a2518fd5bb4914cf34a99d21c92001 100755 (executable)
@@ -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;