rk:move pmic_type to board.h
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2928 / board-rk2928-a720.c
index 550da6c0d50adf42659b02b0c0a76790f7e4022d..41803c13fdababcc575ad25d5a8e0123765e0dbf 100755 (executable)
 #include "board-rk2928-a720-camera.c" 
 #include "board-rk2928-a720-key.c"
 
-int __sramdata g_pmic_type =  0;
-#define PMIC_TYPE_TPS65910     2
-#define PMIC_TYPE_ACT8931      3
-
 #ifdef  CONFIG_THREE_FB_BUFFER
 #define RK30_FB0_MEM_SIZE 12*SZ_1M
 #else
 #define RK30_FB0_MEM_SIZE 8*SZ_1M
 #endif
 
+int __sramdata g_pmic_type =  0;
+
 static struct spi_board_info board_spi_devices[] = {
 };
 
@@ -131,13 +129,13 @@ static int rk29_backlight_pwm_suspend(void)
                return -1;
        }
        #if defined(CONFIG_MFD_TPS65910)        
-       if(g_pmic_type == PMIC_TYPE_TPS65910)
+       if(pmic_is_tps65910())
        {
                gpio_direction_output(PWM_GPIO, GPIO_LOW);
        }
        #endif
        #if defined(CONFIG_REGULATOR_ACT8931)
-       if(g_pmic_type == PMIC_TYPE_ACT8931)
+       if(pmic_is_act8931())
        {
                gpio_direction_output(PWM_GPIO, GPIO_HIGH);
        }
@@ -217,7 +215,7 @@ static int rk_fb_io_disable(void)
 {
 
        #if 0//defined(CONFIG_REGULATOR_ACT8931)
-       if(g_pmic_type == PMIC_TYPE_ACT8931)
+       if(pmic_is_act8931())
        {
                struct regulator *ldo;
                ldo = regulator_get(NULL, "act_ldo4");   //vcc_lcd
@@ -232,7 +230,7 @@ static int rk_fb_io_disable(void)
 static int rk_fb_io_enable(void)
 {
        #if 0//defined(CONFIG_REGULATOR_ACT8931)
-       if(g_pmic_type == PMIC_TYPE_ACT8931)
+       if(pmic_is_act8931())
        {
                struct regulator *ldo;
                ldo = regulator_get(NULL, "act_ldo4");   //vcc_lcd
@@ -480,12 +478,12 @@ static void rkusb_wifi_power(int on) {
        struct regulator *ldo = NULL;
        
 #if defined(CONFIG_MFD_TPS65910)       
-       if(g_pmic_type == PMIC_TYPE_TPS65910) {
+       if(pmic_is_tps65910()) {
                ldo = regulator_get(NULL, "vmmc");  //vccio_wl
        }
 #endif
 #if defined(CONFIG_REGULATOR_ACT8931)
-       if(g_pmic_type == PMIC_TYPE_ACT8931) {
+       if(pmic_is_act8931()) {
                ldo = regulator_get(NULL, "act_ldo4");  //vccio_wl
        }
 #endif 
@@ -607,6 +605,23 @@ static struct platform_device device_acodec = {
 };
 #endif
 
+#ifdef CONFIG_BATTERY_RK30_ADC_FAC
+static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
+        .dc_det_pin      = INVALID_GPIO,
+        .batt_low_pin    = INVALID_GPIO,
+        .charge_set_pin  = INVALID_GPIO,
+        .charge_ok_pin   = INVALID_GPIO,
+};
+
+static struct platform_device rk30_device_adc_battery = {
+        .name   = "rk30-battery",
+        .id     = -1,
+        .dev = {
+                .platform_data = &rk30_adc_battery_platdata,
+        },
+};
+#endif
+
 static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_FB_ROCKCHIP
        &device_fb,
@@ -623,6 +638,9 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_SND_SOC_RK2928
        &device_acodec,
 #endif
+#ifdef CONFIG_BATTERY_RK30_ADC_FAC
+       &rk30_device_adc_battery,
+#endif
 };
 //i2c
 #ifdef CONFIG_I2C0_RK30
@@ -712,13 +730,13 @@ void __sramfunc rk30_pwm_logic_resume_voltage(void)
 #ifdef CONFIG_RK30_PWM_REGULATOR
 #ifdef CONFIG_MACH_RK2926_M713
        writel_relaxed((1<<22)|gpio0d3_iomux, GRF_GPIO0D_IOMUX);
-       gpio_writel(gpio0d3_dir, GPIO_SWPORTA_DDR);
-       gpio_writel(gpio0d3_do, GPIO_SWPORTA_DR);
+       gpio0_writel(gpio0d3_dir, GPIO_SWPORTA_DDR);
+       gpio0_writel(gpio0d3_do, GPIO_SWPORTA_DR);
        sram_udelay(10000);
 #else
        writel_relaxed((1<<24)|gpio0d4_iomux, GRF_GPIO0D_IOMUX);
-       gpio_writel(gpio0d4_dir, GPIO_SWPORTA_DDR);
-       gpio_writel(gpio0d4_do, GPIO_SWPORTA_DR);
+       gpio0_writel(gpio0d4_dir, GPIO_SWPORTA_DDR);
+       gpio0_writel(gpio0d4_do, GPIO_SWPORTA_DR);
        sram_udelay(10000);
 #endif
 
@@ -740,6 +758,21 @@ void  rk30_pwm_resume_voltage_set(void)
 #endif
 }
 
+void __sramfunc board_pmu_suspend(void)
+{      
+       #if defined (CONFIG_MFD_TPS65910)
+       if(pmic_is_tps65910())
+       board_pmu_tps65910_suspend(); 
+       #endif   
+}
+void __sramfunc board_pmu_resume(void)
+{      
+       #if defined (CONFIG_MFD_TPS65910)
+       if(pmic_is_tps65910())
+       board_pmu_tps65910_resume(); 
+       #endif
+}
+
 #ifdef CONFIG_I2C1_RK30
 static struct i2c_board_info __initdata i2c1_info[] = {
 #if defined (CONFIG_GS_MMA7660)
@@ -824,7 +857,7 @@ static void rk2928_pm_power_off(void)
        printk(KERN_ERR "rk2928_pm_power_off start...\n");
         
         #if defined(CONFIG_REGULATOR_ACT8931)
-        if(g_pmic_type == PMIC_TYPE_ACT8931)
+        if(pmic_is_act8931())
         {
               if(act8931_charge_det)
                    arm_pm_restart(0, NULL);
@@ -832,7 +865,7 @@ static void rk2928_pm_power_off(void)
         #endif
        
        #if defined(CONFIG_MFD_TPS65910)        
-       if(g_pmic_type == PMIC_TYPE_TPS65910)
+       if(pmic_is_tps65910())
        {
                tps65910_device_shutdown();//tps65910 shutdown
        }
@@ -876,22 +909,33 @@ static void __init rk2928_reserve(void)
  * comments    : min arm/logic voltage
  */
 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
-       {.frequency = 216 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//0.975V/1.000V
-       {.frequency = 312 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//0.975V/1.000V
-       {.frequency = 408 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//1.000V/1.025V
-       {.frequency = 504 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//1.000V/1.025V
-       {.frequency = 600 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//1.025V/1.050V
-       {.frequency = 696 * 1000,       .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.000V/1.025V
-       {.frequency = 816 * 1000,       .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
-       {.frequency = 912 * 1000,       .cpu_volt = 1450 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
-       {.frequency = 1008 * 1000,      .cpu_volt = 1500 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
+#if defined(CONFIG_MACH_RK2926_M713)
+       {.frequency = 216 * 1000,       .cpu_volt =  850 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 312 * 1000,       .cpu_volt =  900 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 408 * 1000,       .cpu_volt =  950 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 504 * 1000,       .cpu_volt = 1000 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 600 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 696 * 1000,       .cpu_volt = 1175 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 816 * 1000,       .cpu_volt = 1250 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 912 * 1000,       .cpu_volt = 1350 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 1008 * 1000,      .cpu_volt = 1450 * 1000,        .logic_volt = 1200 * 1000},
+#else
+       {.frequency = 216 * 1000,       .cpu_volt =  850 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 312 * 1000,       .cpu_volt =  900 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 408 * 1000,       .cpu_volt =  975 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 504 * 1000,       .cpu_volt = 1050 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 600 * 1000,       .cpu_volt = 1150 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 696 * 1000,       .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 816 * 1000,       .cpu_volt = 1325 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 912 * 1000,       .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 1008 * 1000,      .cpu_volt = 1475 * 1000,        .logic_volt = 1200 * 1000},
+#endif
 #if 0
-       {.frequency = 1104 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
-       {.frequency = 1200 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
-       {.frequency = 1104 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
-       {.frequency = 1248 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
+       {.frequency = 1104 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 1200 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 1104 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 1248 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},
 #endif
-       //{.frequency = 1000 * 1000,    .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
        {.frequency = CPUFREQ_TABLE_END},
 };