rk:move pmic_type to board.h
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk30 / board-rk3066b-m701.c
index cfdc6fc68ec329564b589bc6c0770c41d0b30325..7735e9e08860ac9d17c53f4ab44ed409161af513 100755 (executable)
@@ -286,6 +286,7 @@ static struct rk29_bl_info rk29_bl_info = {
        .io_init = rk29_backlight_io_init,
        .io_deinit = rk29_backlight_io_deinit,
        .min_brightness = 48,
+       .delay_ms = 0,
        .pwm_suspend = rk29_backlight_pwm_suspend,
        .pwm_resume = rk29_backlight_pwm_resume,
 };
@@ -604,6 +605,22 @@ static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
 {
        int ret = 0;
 
+       if(LCD_STB_PIN !=INVALID_GPIO)
+        {
+                ret = gpio_request(LCD_STB_PIN, NULL);
+                if (ret != 0)
+                {
+                        gpio_free(LCD_STB_PIN);
+                        printk(KERN_ERR "request lcd en pin fail!\n");
+                        return -1;
+                }
+                else
+                {
+                        gpio_direction_output(LCD_STB_PIN, LCD_STB_VALUE);
+                }
+        }
+
+       msleep(100);
        if(LCD_CS_PIN !=INVALID_GPIO)
        {
                ret = gpio_request(LCD_CS_PIN, NULL);
@@ -634,25 +651,16 @@ static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
                }
        }
 
-       if(LCD_STB_PIN !=INVALID_GPIO)
-        {
-                ret = gpio_request(LCD_STB_PIN, NULL);
-                if (ret != 0)
-                {
-                        gpio_free(LCD_STB_PIN);
-                        printk(KERN_ERR "request lcd en pin fail!\n");
-                        return -1;
-                }
-                else
-                {
-                        gpio_direction_output(LCD_STB_PIN, LCD_STB_VALUE);
-                }
-        }
 
        return 0;
 }
 static int rk_fb_io_disable(void)
 {
+       if(LCD_STB_PIN !=INVALID_GPIO)
+       {
+               gpio_set_value(LCD_STB_PIN, !LCD_STB_VALUE);
+       }
+       msleep(50);
        if(LCD_CS_PIN !=INVALID_GPIO)
        {
                gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
@@ -661,10 +669,16 @@ static int rk_fb_io_disable(void)
        {
                gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
        }
+
        return 0;
 }
 static int rk_fb_io_enable(void)
 {
+       if(LCD_STB_PIN !=INVALID_GPIO)
+       {
+               gpio_set_value(LCD_STB_PIN, LCD_STB_VALUE);
+       }
+       msleep(50);
        if(LCD_CS_PIN !=INVALID_GPIO)
        {
                gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
@@ -1098,10 +1112,11 @@ struct rk29_sdmmc_platform_data default_sdmmc1_data = {
 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
         .dc_det_pin      = RK30_PIN0_PB2,
         .batt_low_pin    = RK30_PIN0_PB1, 
-        .charge_set_pin  = INVALID_GPIO,
+        .charge_set_pin  = RK30_PIN2_PA7,
         .charge_ok_pin   = RK30_PIN0_PA6,
         .dc_det_level    = GPIO_LOW,
         .charge_ok_level = GPIO_HIGH,
+               .charge_set_level = GPIO_HIGH,
 };
 
 static struct platform_device rk30_device_adc_battery = {
@@ -1394,8 +1409,6 @@ static struct i2c_board_info __initdata i2c0_info[] = {
 };
 #endif
 
-#define PMIC_TYPE_WM8326       1
-#define PMIC_TYPE_TPS65910     2
 int __sramdata g_pmic_type =  0;
 #ifdef CONFIG_I2C1_RK30
 #ifdef CONFIG_MFD_WM831X_I2C
@@ -1431,11 +1444,11 @@ static struct i2c_board_info __initdata i2c1_info[] = {
 void __sramfunc board_pmu_suspend(void)
 {      
        #if defined (CONFIG_MFD_WM831X_I2C)
-       if(g_pmic_type == PMIC_TYPE_WM8326)
+       if(pmic_is_wm8326())
        board_pmu_wm8326_suspend();
        #endif
        #if defined (CONFIG_MFD_TPS65910)
-       if(g_pmic_type == PMIC_TYPE_TPS65910)
+       if(pmic_is_tps65910())
        board_pmu_tps65910_suspend(); 
     #endif   
 }
@@ -1443,11 +1456,11 @@ void __sramfunc board_pmu_suspend(void)
 void __sramfunc board_pmu_resume(void)
 {      
        #if defined (CONFIG_MFD_WM831X_I2C)
-       if(g_pmic_type == PMIC_TYPE_WM8326)
+       if(pmic_is_wm8326())
        board_pmu_wm8326_resume();
        #endif
        #if defined (CONFIG_MFD_TPS65910)
-       if(g_pmic_type == PMIC_TYPE_TPS65910)
+       if(pmic_is_tps65910())
        board_pmu_tps65910_resume(); 
        #endif
 }
@@ -1586,10 +1599,34 @@ static void __init rk30_i2c_register_board_info(void)
 }
 //end of i2c
 
+#define POWEROFF_CHARGING_ANIMATION            (1)
 #define POWER_ON_PIN RK30_PIN0_PA0   //power_hold
 static void rk30_pm_power_off(void)
 {
-       printk(KERN_ERR "rk30_pm_power_off start...\n");
+#if POWEROFF_CHARGING_ANIMATION
+       int pwr_cnt = 0;
+       struct rk30_adc_battery_platform_data *batt_plat_data = &rk30_adc_battery_platdata;
+       if (gpio_get_value (batt_plat_data->dc_det_pin)  ==
+               batt_plat_data->dc_det_level) {
+               printk("AC Charging, try to restart...\n");
+               while (1) {
+                        if (gpio_get_value (batt_plat_data->dc_det_pin) !=
+                               batt_plat_data->dc_det_level ) {
+                               pwr_cnt = 0;
+                               break;
+                        }
+                        if (pwr_cnt++ > 40)
+                               break;
+                        mdelay(50);
+               }
+               if (pwr_cnt > 40)  {
+                       printk("AC Charging, will restart system...\n");
+                       arm_pm_restart(0, NULL);
+               }
+       }
+#endif
+
+       printk("rk30_pm_power_off start...\n");
        gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
 #if defined(CONFIG_MFD_WM831X)
        wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
@@ -1650,17 +1687,17 @@ static void __init rk30_reserve(void)
  */
 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
 #if 0
-       {.frequency = 252 * 1000,       .cpu_volt = 1075 * 1000,        .logic_volt = 1125 * 1000},//0.975V/1.000V
+       {.frequency = 252 * 1000,       .cpu_volt = 1075 * 1000,        .logic_volt = 1125 * 1000},
 #endif
-       {.frequency = 504 * 1000,       .cpu_volt = 1100 * 1000,                .logic_volt = 1100 * 1000},//0.975V/1.000V
-       {.frequency = 816 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1100 * 1000},//1.000V/1.025V
-       {.frequency = 1200 * 1000,      .cpu_volt = 1100 * 1000,        .logic_volt = 1100 * 1000},//1.100V/1.050V
+       {.frequency = 504 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1100 * 1000},
+       {.frequency = 816 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1100 * 1000},
+       {.frequency = 1200 * 1000,      .cpu_volt = 1100 * 1000,        .logic_volt = 1100 * 1000},
 #if 0
-       {.frequency = 1008 * 1000,      .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},//1.025V/1.050V
-       {.frequency = 1272 * 1000,      .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
-       {.frequency = 1416 * 1000,      .cpu_volt = 1300 * 1000,        .logic_volt = 1200 * 1000},//1.225V/1.100V
-       {.frequency = 1512 * 1000,      .cpu_volt = 1350 * 1000,        .logic_volt = 1250 * 1000},//1.300V/1.150V
-       {.frequency = 1608 * 1000,      .cpu_volt = 1425 * 1000,        .logic_volt = 1300 * 1000},//1.325V/1.175V
+       {.frequency = 1008 * 1000,      .cpu_volt = 1125 * 1000,        .logic_volt = 1150 * 1000},
+       {.frequency = 1272 * 1000,      .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 1416 * 1000,      .cpu_volt = 1300 * 1000,        .logic_volt = 1200 * 1000},
+       {.frequency = 1512 * 1000,      .cpu_volt = 1350 * 1000,        .logic_volt = 1250 * 1000},
+       {.frequency = 1608 * 1000,      .cpu_volt = 1425 * 1000,        .logic_volt = 1300 * 1000},
 #endif
        {.frequency = CPUFREQ_TABLE_END},
 };
@@ -1668,6 +1705,7 @@ static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
        {.frequency = 266 * 1000,       .index = 1000 * 1000},
        {.frequency = 400 * 1000,       .index = 1000 * 1000},
+       {.frequency = 600 * 1000,       .index = 1200 * 1000},
        {.frequency = CPUFREQ_TABLE_END},
 };