rk2928: tps65910: irq_base use IRQ_BOARD_BASE
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2928 / board-rk2928-sdk-tps65910.c
index 7215da55b8b73345a5279a6ee4ef7242324041cf..253c11c967a54c3cc7c8f1ab5b0e4eae65c00a08 100755 (executable)
@@ -7,22 +7,8 @@
 #include <mach/gpio.h>
 #include <mach/iomux.h>
 
-#define gpio_readl(offset)     readl_relaxed(RK2928_GPIO1_BASE + offset)
-#define gpio_writel(v, offset) do { writel_relaxed(v, RK2928_GPIO1_BASE + offset); dsb(); } while (0)
-
-#define GPIO_SWPORTA_DR  0x0000
-#define GPIO_SWPORTA_DDR 0x0004
-
-#define GPIO1_A1_OUTPUT  (1<<1)
-#define GPIO1_A1_OUTPUT_HIGH  (1<<1)
-#define GPIO1_A1_OUTPUT_LOW  (~(1<<1))
-
 #ifdef CONFIG_MFD_TPS65910
-#if defined(CONFIG_MACH_RK2928_SDK)
-#define PMU_POWER_SLEEP RK2928_PIN0_PD0        
-#else
-#define PMU_POWER_SLEEP RK2928_PIN1_PA1        
-#endif
+
 extern int platform_device_register(struct platform_device *pdev);
 
 int tps65910_pre_init(struct tps65910 *tps65910){
@@ -32,8 +18,24 @@ int tps65910_pre_init(struct tps65910 *tps65910){
        int err = -1;
                
        printk("%s,line=%d\n", __func__,__LINE__);      
+#ifdef CONFIG_RK_CONFIG
+        if(sram_gpio_init(get_port_config(pmic_slp).gpio, &pmic_sleep) < 0){
+                printk(KERN_ERR "sram_gpio_init failed\n");
+                return -EINVAL;
+        }
+        if(port_output_init(pmic_slp, 0, "pmic_slp") < 0){
+                printk(KERN_ERR "port_output_init failed\n");
+                return -EINVAL;
+        }
+#else
+        if(sram_gpio_init(PMU_POWER_SLEEP, &pmic_sleep) < 0){
+                printk(KERN_ERR "sram_gpio_init failed\n");
+                return -EINVAL;
+        }
+
        gpio_request(PMU_POWER_SLEEP, "NULL");
        gpio_direction_output(PMU_POWER_SLEEP, GPIO_LOW);
+#endif
 
        val = tps65910_reg_read(tps65910, TPS65910_DEVCTRL2);
        if (val<0) {
@@ -186,6 +188,7 @@ int tps65910_pre_init(struct tps65910 *tps65910){
         }
        
        val  |= 0xff;
+       val  &= ~(0x07);   //set vdd1 vdd2 vio in pfm mode when in sleep
        err = tps65910_reg_write(tps65910, TPS65910_SLEEP_KEEP_RES_ON, val);
        if (err) {
                printk(KERN_ERR "Unable to read TPS65910 Reg at offset 0x%x= \
@@ -223,6 +226,22 @@ int tps65910_pre_init(struct tps65910 *tps65910){
        }
        #endif
        #endif
+
+       /**********************set arm in pwm ****************/
+         val = tps65910_reg_read(tps65910, TPS65910_DCDCCTRL);
+        if (val<0) {
+                printk(KERN_ERR "Unable to read TPS65910_DCDCCTRL reg\n");
+                return val;
+        }
+       
+       val &= ~(1<<4);
+       err = tps65910_reg_write(tps65910, TPS65910_DCDCCTRL, val);
+       if (err) {
+               printk(KERN_ERR "Unable to read TPS65910 Reg at offset 0x%x= \
+                               \n", TPS65910_VDIG1);
+               return err;
+       }       
+       /************************************************/
        
        printk("%s,line=%d\n", __func__,__LINE__);
        return 0;
@@ -233,92 +252,40 @@ int tps65910_post_init(struct tps65910 *tps65910)
 {
        struct regulator *dcdc;
        struct regulator *ldo;
+       int i = 0;
        printk("%s,line=%d\n", __func__,__LINE__);
 
+#ifndef CONFIG_RK_CONFIG
        g_pmic_type = PMIC_TYPE_TPS65910;
+#endif
        printk("%s:g_pmic_type=%d\n",__func__,g_pmic_type);
 
        #ifdef CONFIG_RK30_PWM_REGULATOR
        platform_device_register(&pwm_regulator_device[0]);
        #endif
+
+       for(i = 0; i < ARRAY_SIZE(tps65910_dcdc_info); i++)
+       {
+                if(tps65910_dcdc_info[i].min_uv == 0 && tps65910_dcdc_info[i].max_uv == 0)
+                        continue;
+               dcdc =regulator_get(NULL, tps65910_dcdc_info[i].name);
+               regulator_set_voltage(dcdc, tps65910_dcdc_info[i].min_uv, tps65910_dcdc_info[i].max_uv);
+               regulator_enable(dcdc);
+               printk("%s  %s =%dmV end\n", __func__,tps65910_dcdc_info[i].name, regulator_get_voltage(dcdc));
+               regulator_put(dcdc);
+               udelay(100);
+       }
        
-       dcdc = regulator_get(NULL, "vio");      //vcc_io
-       regulator_set_voltage(dcdc, 3300000, 3300000);
-       regulator_enable(dcdc);
-       printk("%s set vio vcc_io=%dmV end\n", __func__, regulator_get_voltage(dcdc));
-       regulator_put(dcdc);
-       udelay(100);
-        /*
-       ldo = regulator_get(NULL, "vpll");      // vcc25
-       regulator_set_voltage(ldo, 2500000, 2500000);
-       regulator_enable(ldo);
-       printk("%s set vpll vcc25=%dmV end\n", __func__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
-       udelay(100);
-        */
-       ldo = regulator_get(NULL, "vdig2");     // vdd12
-       regulator_set_voltage(ldo, 1200000, 1200000);
-       regulator_enable(ldo);
-       printk("%s set vdig2 vdd12=%dmV end\n", __func__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
-       udelay(100);
-
-       ldo = regulator_get(NULL, "vaux33");     //vcc_tp
-       regulator_set_voltage(ldo, 3300000, 3300000);
-       regulator_enable(ldo);
-       printk("%s set vaux33 vcc_tp=%dmV end\n", __func__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
-       udelay(100);
-       
-       dcdc = regulator_get(NULL, "vdd_cpu");  //vdd_cpu
-       regulator_set_voltage(dcdc, 1200000, 1200000);
-       regulator_enable(dcdc);
-       printk("%s set vdd1 vdd_cpu=%dmV end\n", __func__, regulator_get_voltage(dcdc));
-       regulator_put(dcdc);
-       udelay(100);
-       
-       dcdc = regulator_get(NULL, "vdd2");     //vcc_ddr 
-       regulator_set_voltage(dcdc, 1200000, 1200000);  // 1.5*4/5 = 1.2 and Vout=1.5v
-       regulator_enable(dcdc);
-       printk("%s set vdd2 vcc_ddr=%dmV end\n", __func__, regulator_get_voltage(dcdc));
-       regulator_put(dcdc);
-       udelay(100);
-       
-       ldo = regulator_get(NULL, "vdig1");     //vcc18_cif
-       regulator_set_voltage(ldo, 1500000, 1500000);
-       regulator_enable(ldo);
-       printk("%s set vdig1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
-       udelay(100);
-       
-       dcdc = regulator_get(NULL, "vaux1"); //vcc28_cif
-       regulator_set_voltage(dcdc,2800000,2800000);
-       regulator_enable(dcdc); 
-       printk("%s set vaux1 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(dcdc));
-       regulator_put(dcdc);
-       udelay(100);
-
-       ldo = regulator_get(NULL, "vaux2");     //vcca33
-       regulator_set_voltage(ldo, 3300000, 3300000);
-       regulator_enable(ldo);
-       printk("%s set vaux2 vcca33=%dmV end\n", __func__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
-       udelay(100);
-        /*
-       ldo = regulator_get(NULL, "vdac"); // vccio_wl
-       regulator_set_voltage(ldo,1800000,1800000);
-       regulator_enable(ldo); 
-       printk("%s set vdac vccio_wl=%dmV end\n", __func__, regulator_get_voltage(ldo));
-       regulator_put(ldo);
-       udelay(100);
-        */
-       ldo = regulator_get(NULL, "vmmc");  //vccio_wl
-       regulator_set_voltage(ldo,3300000,3300000);
-       regulator_enable(ldo); 
-       printk("%s set vmmc vccio_wl=%dmV end\n", __func__, regulator_get_voltage(ldo));
-       regulator_disable(ldo); 
-       regulator_put(ldo);
-       udelay(100);
+       for(i = 0; i < ARRAY_SIZE(tps65910_ldo_info); i++)
+       {
+                if(tps65910_ldo_info[i].min_uv == 0 && tps65910_ldo_info[i].max_uv == 0)
+                        continue;
+               ldo =regulator_get(NULL, tps65910_ldo_info[i].name);
+               regulator_set_voltage(ldo, tps65910_ldo_info[i].min_uv, tps65910_ldo_info[i].max_uv);
+               regulator_enable(ldo);
+               printk("%s  %s =%dmV end\n", __func__,tps65910_ldo_info[i].name, regulator_get_voltage(ldo));
+               regulator_put(ldo);
+       }
 
        printk("%s,line=%d END\n", __func__,__LINE__);
        
@@ -336,6 +303,11 @@ static struct regulator_consumer_supply tps65910_smps2_supply[] = {
        {
                .supply = "vdd2",
        },
+       #if defined(CONFIG_MACH_RK2926_V86)
+       {
+               .supply = "vdd_core",
+       },
+      #endif
        
 };
 static struct regulator_consumer_supply tps65910_smps3_supply[] = {
@@ -580,24 +552,16 @@ static struct regulator_init_data tps65910_ldo8 = {
 };
 void __sramfunc board_pmu_tps65910_suspend(void)
 {      
-       int ret;
-       ret = gpio_readl(GPIO_SWPORTA_DDR);
-       gpio_writel(ret | GPIO1_A1_OUTPUT, GPIO_SWPORTA_DDR);
-       ret = gpio_readl(GPIO_SWPORTA_DR);
-       gpio_writel(ret | GPIO1_A1_OUTPUT_HIGH, GPIO_SWPORTA_DR);  //set pmu_sleep output high
+        sram_gpio_set_value(pmic_sleep, GPIO_HIGH);  
 }
 void __sramfunc board_pmu_tps65910_resume(void)
 {
-       int ret;
-       ret = gpio_readl(GPIO_SWPORTA_DDR);
-       gpio_writel(ret | GPIO1_A1_OUTPUT, GPIO_SWPORTA_DDR);
-       ret = gpio_readl(GPIO_SWPORTA_DR);
-       gpio_writel(ret & GPIO1_A1_OUTPUT_LOW, GPIO_SWPORTA_DR);   //set pmu_sleep output low
+       sram_gpio_set_value(pmic_sleep, GPIO_LOW);  
        sram_udelay(2000);
 }
 static struct tps65910_board tps65910_data = {
        .irq    = (unsigned)TPS65910_HOST_IRQ,          
-       .irq_base = NR_GIC_IRQS + NR_GPIO_IRQS,
+       .irq_base = IRQ_BOARD_BASE,
        .gpio_base = TPS65910_GPIO_EXPANDER_BASE,
        
        .pre_init = tps65910_pre_init,