ac: add for display key control
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk3188 / board-rk3188-ac.c
old mode 100644 (file)
new mode 100755 (executable)
index 705c9ee..5feb14a
@@ -75,6 +75,7 @@
 
 #include "../mach-rk30/board-rk3168-ds1006h-camera.c"
 #include <plat/key.h>
+#include <linux/scaler-core.h>
 
 static struct rk29_keys_button key_button[] = {
        {
@@ -84,6 +85,7 @@ static struct rk29_keys_button key_button[] = {
                .active_low = PRESS_LEV_LOW,
                .wakeup = 1,
        },
+/*     
        {
                .desc   = "esc",
                .code   = KEY_BACK,
@@ -91,6 +93,19 @@ static struct rk29_keys_button key_button[] = {
                .gpio = INVALID_GPIO,
                .active_low = PRESS_LEV_LOW,
        },
+       */
+       {
+                .desc   = "mode_switch",
+                .code   = KEY_MODE_SWITCH,
+                //.desc   = "vol+",
+                //.code   = KEY_VOLUMEUP,
+                
+                .adc_value      = 1,
+                .gpio = INVALID_GPIO,
+                .active_low = PRESS_LEV_LOW,
+               .wakeup = 1
+        },
+       
 };
 struct rk29_keys_platform_data rk29_keys_pdata = {
        .buttons        = key_button,
@@ -505,8 +520,8 @@ static int rk_fb_io_enable(void)
        return 0;
 }
 
-#if defined(CONFIG_LCDC0_RK3188)
-struct rk29fb_info lcdc0_screen_info = {
+#if defined(CONFIG_LCDC1_RK3188)
+struct rk29fb_info lcdc1_screen_info = {
        .prop           = EXTEND,       //extend display device
        .lcd_info  = NULL,
        .set_screen_info = hdmi_init_lcdc,
@@ -514,8 +529,8 @@ struct rk29fb_info lcdc0_screen_info = {
 };
 #endif
 
-#if defined(CONFIG_LCDC1_RK3188)
-struct rk29fb_info lcdc1_screen_info = {
+#if defined(CONFIG_LCDC0_RK3188)
+struct rk29fb_info lcdc0_screen_info = {
        .prop      = PRMRY,             //primary display device
        .io_init   = rk_fb_io_init,
        .io_disable = rk_fb_io_disable,
@@ -725,7 +740,7 @@ static struct platform_device device_ion = {
  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
 **************************************************************************************************/
 #ifdef CONFIG_SDMMC_RK29
-#include "board-rk3188-ds1006h-sdmmc-config.c"
+#include "board-rk3188-ac-sdmmc-config.c"
 #include "../plat-rk/rk-sdmmc-ops.c"
 #include "../plat-rk/rk-sdmmc-wifi.c"
 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
@@ -794,7 +809,7 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = {
        .use_dma = 0,
 #endif
 
-#if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
+#if defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
     .status = rk29sdk_wifi_mmc0_status,
     .register_status_notify = rk29sdk_wifi_mmc0_status_register,
 #endif
@@ -940,6 +955,81 @@ struct rk29_sdmmc_platform_data default_sdmmc1_data = {
 **************************************************************************************************/
 
 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
+static int ac_current = -1;
+#define CHARING_CURRENT_500MA 0
+#define CHARING_CURRENT_1000MA 1
+
+#define   DC_CUR_SET_PIN RK30_PIN0_PB0
+#define   CHARGE_OK_PIN  RK30_PIN0_PA6
+#define   DC_DET_PIN     RK30_PIN0_PB2
+static int rk30_battery_adc_io_init(void)
+{
+        int ret = 0;
+        printk("charging:  set charging current 500ma \n");
+        ac_current = CHARING_CURRENT_500MA;
+        //dc charge detect pin
+        ret = gpio_request(DC_DET_PIN, NULL);
+        if (ret) {
+             printk("failed to request dc_det gpio\n");
+             return ret ;
+        }
+
+        gpio_pull_updown(DC_DET_PIN, 1);//important
+        ret = gpio_direction_input(DC_DET_PIN);
+        if (ret) {
+                printk("failed to set gpio dc_det input\n");
+                return ret ;
+        }
+
+        //charge ok pin
+        ret = gpio_request(CHARGE_OK_PIN, NULL);
+        if (ret) {
+                printk("failed to request charge_ok gpio\n");
+                return ret ;
+        }
+
+        gpio_pull_updown(CHARGE_OK_PIN, 1);//important
+        ret = gpio_direction_input(CHARGE_OK_PIN);
+        if (ret) {
+                printk("failed to set gpio charge_ok input\n");
+                return ret ;
+        }
+        //charge current set pin
+        ret = gpio_request(DC_CUR_SET_PIN, NULL);
+        if (ret) {
+                printk("failed to request DC_CUR_SET_PIN gpio\n");
+                return ret ;
+        }
+
+        ret = gpio_direction_output(DC_CUR_SET_PIN, GPIO_LOW);//500ma
+        if (ret) {
+                printk("failed to set gpio DC_CUR_SET_PIN output\n");
+                return ret ;
+        }
+
+        return 0;
+
+}
+
+static int set_usb_charging_current(int mode)
+{
+#if 0
+    if ( (ac_current==CHARING_CURRENT_1000MA) && (mode == PC_MODE) ) {
+                gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
+                ac_current = CHARING_CURRENT_500MA;
+     }
+     else if ((mode == ADAPT_MODE) && (ac_current==CHARING_CURRENT_500MA))
+     {
+                gpio_set_value(DC_CUR_SET_PIN, GPIO_HIGH);
+               ac_current = CHARING_CURRENT_1000MA;
+
+      }
+#endif
+       gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW);
+       ac_current = CHARING_CURRENT_500MA;
+}
+
+
 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
         .dc_det_pin      = RK30_PIN0_PB2,
         .batt_low_pin    = INVALID_GPIO, 
@@ -955,7 +1045,9 @@ static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
 
        .is_reboot_charging = 1,
         .save_capacity   = 1 ,
-        .low_voltage_protection = 3600,    
+        .low_voltage_protection = 3600,   
+       .io_init = rk30_battery_adc_io_init,
+       .control_usb_charging= set_usb_charging_current, 
 };
 
 static struct platform_device rk30_device_adc_battery = {
@@ -1019,6 +1111,13 @@ struct platform_device pwm_regulator_device[1] = {
 };
 #endif
 
+#ifdef CONFIG_RK29_VMAC
+#define PHY_PWR_EN_GPIO  INVALID_GPIO
+#define PHY_PWR_EN_IOMUX GPIO3_D2 
+#define PHY_PWR_EN_VALUE GPIO_HIGH
+#include "../mach-rk30/board-rk31-sdk-vmac.c"
+#endif
+
 #ifdef CONFIG_RFKILL_RK
 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
@@ -1034,26 +1133,26 @@ static struct rfkill_rk_platform_data rfkill_rk_platdata = {
     },
 
     .reset_gpio         = { // BT_RST
-        .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
+        .io             = RK30_PIN3_PA0, // set io to INVALID_GPIO for disable it
         .enable         = GPIO_LOW,
         .iomux          = {
             .name       = "bt_reset",
-            .fgpio      = GPIO3_D1,
+            .fgpio      = GPIO3_A0,
        },
    }, 
 
     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
-        .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
+        .io             = RK30_PIN3_PB0, // set io to INVALID_GPIO for disable it
         .enable         = GPIO_HIGH,
         .iomux          = {
             .name       = "bt_wake",
-            .fgpio      = GPIO3_C6,
+            .fgpio      = GPIO3_B0,
         },
     },
 
     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
         .gpio           = {
-            .io         = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
+            .io         = RK30_PIN3_PB1, // set io to INVALID_GPIO for disable it
             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
             .iomux      = {
                 .name   = NULL,
@@ -1244,6 +1343,19 @@ static struct platform_device device_tcc_bt = {
 };
 #endif
 
+#if defined(CONFIG_AC_USB_SWITCH)
+static struct ac_usb_switch_platform_data  ac_usb_switch_platdata= {
+       .usb_switch_pin = RK30_PIN3_PB2,
+       .pc_state_pin = INVALID_GPIO,
+};
+static struct platform_device device_ac_usb_switch = {
+       .name   = "ac_usb_switch",
+       .id     = -1,
+       .dev    = {
+               .platform_data = &ac_usb_switch_platdata,
+       },
+};
+#endif
 
 static struct platform_device *devices[] __initdata = {
 
@@ -1280,6 +1392,9 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_TCC_BT_DEV
         &device_tcc_bt,
 #endif
+#if defined(CONFIG_AC_USB_SWITCH)
+       &device_ac_usb_switch,
+#endif
 };
 
 
@@ -1384,6 +1499,13 @@ static struct i2c_board_info __initdata i2c0_info[] = {
                .flags         = 0,
        },
 #endif
+#if defined (CONFIG_SND_SOC_CX2070X)
+        {
+                .type                   = "cx2070x",
+                .addr                   = 0x14,
+                .flags                  = 0,
+        },
+#endif
 };
 #endif
 
@@ -1657,7 +1779,50 @@ static  struct pmu_info  tps65910_ldo_info[] = {
 #include "../mach-rk30/board-pmu-tps65910.c"
 #endif
 
+#if defined(CONFIG_SCALER_TEST) 
+//the fisrt port is default 
+struct scaler_output_port tst_oports[] ={
+       {
+               .led_gpio = INVALID_GPIO,
+               .type = SCALER_OUT_VGA,
+       },
+};
+
+//the fisrt port is default 
+struct scaler_input_port tst_iports[] = {
+       {
+               //RK
+               .led_gpio = RK30_PIN0_PD4,
+               .type = SCALER_IN_VGA,
+       },
+       {
+               //pc
+               .led_gpio = RK30_PIN0_PD5,
+               .type = SCALER_IN_VGA,
+       },
+};
+
+struct scaler_platform_data test_data = {
+       .func_type = SCALER_FUNC_SWITCH,
+
+       .iports = tst_iports,
+       .iport_size = ARRAY_SIZE(tst_iports),
+       .oports = tst_oports,
+       .oport_size = ARRAY_SIZE(tst_oports),
+
+       .power_gpio = RK30_PIN2_PD7,
+};
+#endif
+
 static struct i2c_board_info __initdata i2c1_info[] = {
+#if defined(CONFIG_SCALER_TEST) 
+       {
+               .type           = "aswitch",
+               .addr           = 0x57,
+               .flags          = 0,
+               .platform_data = &test_data,
+       },
+#endif
 #if defined (CONFIG_REGULATOR_ACT8846)
        {
                .type                   = "act8846",
@@ -1780,6 +1945,13 @@ void  rk30_pwm_resume_voltage_set(void)
 
 #ifdef CONFIG_I2C2_RK30
 static struct i2c_board_info __initdata i2c2_info[] = {
+#if defined(CONFIG_SCALER_DEVICE) 
+       {
+               .type           = "vga_i2c",
+               .addr           = 0x50,
+               .flags          = 0,
+       },
+#endif
 #if defined (CONFIG_CT36X_TS)
        {
                .type          = CT36X_NAME,