ac: add for display key control
authorwlq <wlq@rock-chips.com>
Fri, 11 Oct 2013 12:32:40 +0000 (20:32 +0800)
committerwlq <wlq@rock-chips.com>
Fri, 11 Oct 2013 12:32:40 +0000 (20:32 +0800)
arch/arm/configs/rk3188_ac_defconfig [changed mode: 0644->0755]
arch/arm/mach-rk3188/board-rk3188-ac.c
arch/arm/plat-rk/include/plat/board.h
drivers/misc/Kconfig
drivers/misc/Makefile [changed mode: 0644->0755]
drivers/misc/ac_usb_switch.c [new file with mode: 0755]
include/linux/input.h [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index e4571af..f20af96
@@ -194,6 +194,7 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_MISC_DEVICES=y
 CONFIG_UID_STAT=y
 CONFIG_APANIC=y
+CONFIG_AC_USB_SWITCH=y
 CONFIG_SCALER_DEVICE=y
 CONFIG_SCALER_TEST=y
 CONFIG_SCSI=y
@@ -280,7 +281,6 @@ CONFIG_POWER_SUPPLY=y
 CONFIG_BATTERY_RK30_ADC_FAC=y
 CONFIG_BATTERY_RK30_AC_CHARGE=y
 CONFIG_BATTERY_RK30_VOL3V8=y
-CONFIG_POWER_ON_CHARGER_DISPLAY=y
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
 CONFIG_RK29_WATCHDOG=y
index 999ce00d9bbb89a7a3b50110c79cd9171f0ec091..5feb14a990cadbe88c04b98c8944168c656126a6 100755 (executable)
@@ -85,6 +85,7 @@ static struct rk29_keys_button key_button[] = {
                .active_low = PRESS_LEV_LOW,
                .wakeup = 1,
        },
+/*     
        {
                .desc   = "esc",
                .code   = KEY_BACK,
@@ -92,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,
@@ -1329,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 = {
 
@@ -1365,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
 };
 
 
index c71fa045535846b536896be5b53869342973914d..89fc19aa1733a19f15c11013f8078649e86c6491 100755 (executable)
@@ -379,7 +379,10 @@ struct codec_platform_data {
        int hp_pin ;
 };
 
-
+struct ac_usb_switch_platform_data {
+       int usb_switch_pin;
+       int pc_state_pin ;
+};
 struct ct360_platform_data {
        u16             model;
        u16             x_max;
index 4e90a6d47c23a74374f1ad1b00bf5a95cc6e35e8..49fb1da17e77646572090964177d6a9b0f0de820 100755 (executable)
@@ -562,6 +562,9 @@ config TCC_BT_DEV
        default n
        help
          If you say Y here, you can contorl the power of the BT H/W Module
+config AC_USB_SWITCH
+       bool "for androidComputer external usb devices switch"
+       default n
 
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
old mode 100644 (file)
new mode 100755 (executable)
index ff2e22c..04e973c
@@ -63,4 +63,5 @@ obj-$(CONFIG_RK29_SC8800)     +=      sc8800.o
 obj-y += rk2928_callpad_misc/
 obj-$(CONFIG_MODEM_SOUND) += modem_sound.o
 obj-$(CONFIG_TCC_BT_DEV)       += tcc_bt_dev.o
+obj-$(CONFIG_AC_USB_SWITCH) += ac_usb_switch.o
 obj-$(CONFIG_SCALER_DEVICE)            += scaler/
diff --git a/drivers/misc/ac_usb_switch.c b/drivers/misc/ac_usb_switch.c
new file mode 100755 (executable)
index 0000000..a72bcd4
--- /dev/null
@@ -0,0 +1,217 @@
+#include <linux/input.h>\r
+#include <linux/module.h>\r
+#include <linux/init.h>\r
+#include <linux/interrupt.h>\r
+#include <linux/kernel.h>\r
+#include <linux/fcntl.h>\r
+#include <linux/delay.h>\r
+#include <linux/device.h>\r
+#include <linux/miscdevice.h>\r
+#include <asm/types.h>\r
+#include <mach/gpio.h>\r
+#include <mach/iomux.h>\r
+#include <linux/platform_device.h>\r
+#include <asm/uaccess.h>\r
+#include <linux/wait.h>\r
+#include <mach/board.h>\r
+\r
+#if 1\r
+#define DBG(x...)      printk(KERN_INFO x)\r
+#else\r
+#define DBG(x...)\r
+#endif\r
+#define PC_DISPLAY_MODE 1 \r
+#define ANDROID_DISPLAY_MODE   2\r
+\r
+#define USB_SWITCH_IOCTL_BASE 'u'\r
+#define USB_SWITCH_IOCTL_SET_USB_SWITCH_MODE           _IOW(USB_SWITCH_IOCTL_BASE, 0x01, int)\r
+#define USB_SWITCH_IOCTL_GET_PC_STATE          _IOR(USB_SWITCH_IOCTL_BASE, 0x02, int)\r
+\r
+static struct ac_usb_switch_platform_data *ac_usb_switch;\r
+\r
+\r
+static int setUsbSwitchMode(int mode){\r
+       struct ac_usb_switch_platform_data *pdata = ac_usb_switch;\r
+       if(pdata->usb_switch_pin == INVALID_GPIO){\r
+               DBG(" error ac_usb_switch_pin is null !!!\n");\r
+               return -1;\r
+       }\r
+       switch(mode){\r
+               case PC_DISPLAY_MODE:\r
+                       gpio_set_value(pdata->usb_switch_pin,GPIO_LOW);                 \r
+                       break;\r
+               case ANDROID_DISPLAY_MODE:\r
+                       gpio_set_value(pdata->usb_switch_pin,GPIO_HIGH);\r
+                       break;\r
+               default:\r
+               break;\r
+       }\r
+       return 0;\r
+}\r
+static int getPCstate(){\r
+       return 1;\r
+}\r
+\r
+static int ac_usb_switch_open(struct inode *inode, struct file *filp)\r
+{\r
+    DBG("ac_usb_switch_open\n");\r
+\r
+       return 0;\r
+}\r
+\r
+static ssize_t ac_usb_switch_read(struct file *filp, char __user *ptr, size_t size, loff_t *pos)\r
+{\r
+       if (ptr == NULL)\r
+               printk("%s: user space address is NULL\n", __func__);\r
+       return sizeof(int);\r
+}\r
+\r
+static long ac_usb_switch_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)\r
+{\r
+       long ret = 0;   \r
+       int mode;\r
+       struct ac_usb_switch_platform_data *pdata = ac_usb_switch;\r
+\r
+       DBG("ac_usb_switch_ioctl: cmd = %d arg = %ld\n",cmd, arg);\r
+       \r
+       switch (cmd){\r
+               case USB_SWITCH_IOCTL_SET_USB_SWITCH_MODE:\r
+                       DBG("ac_usb_switch_ioctl: USB_SWITCH_IOCTL_SET_USB_SWITCH_MODE\n");\r
+                       mode = arg;\r
+                       setUsbSwitchMode(mode);\r
+                       break;\r
+               case USB_SWITCH_IOCTL_GET_PC_STATE:\r
+                       DBG("ac_usb_switch_ioctl: USB_SWITCH_IOCTL_GET_PC_STATE\n");\r
+                       return getPCstate();\r
+                       \r
+               default:\r
+                       printk("unknown ioctl cmd!\n");\r
+                       ret = -EINVAL;\r
+                       break;\r
+       }\r
+       return ret;\r
+}\r
+\r
+static int ac_usb_switch_release(struct inode *inode, struct file *filp)\r
+{\r
+    DBG("ac_usb_switch_release\n");\r
+    \r
+       return 0;\r
+}\r
+\r
+static struct file_operations ac_usb_switch_fops = {\r
+       .owner   = THIS_MODULE,\r
+       .open    = ac_usb_switch_open,\r
+       .read    = ac_usb_switch_read,\r
+       .unlocked_ioctl   = ac_usb_switch_ioctl,\r
+       .release = ac_usb_switch_release,\r
+};\r
+\r
+static struct miscdevice ac_usb_switch_dev = \r
+{\r
+    .minor = MISC_DYNAMIC_MINOR,\r
+    .name = "ac_usb_switch",\r
+    .fops = &ac_usb_switch_fops,\r
+};\r
+\r
+static int ac_usb_switch_probe(struct platform_device *pdev)\r
+{\r
+       int ret = 0;\r
+       int result;\r
+       struct ac_usb_switch_platform_data *pdata = pdev->dev.platform_data;\r
+       if(!pdata)\r
+               return -1;\r
+       ac_usb_switch = pdata;\r
+       ret = misc_register(&ac_usb_switch_dev);\r
+       if (ret < 0){\r
+               printk("ac_usb_switch register err!\n");\r
+               return ret;\r
+       }\r
+       \r
+       if(pdata->usb_switch_pin != INVALID_GPIO){\r
+               result = gpio_request(pdata->usb_switch_pin, "ac_usb_switch");\r
+               if(result)\r
+               {\r
+                       printk("%s:fail to request gpio %d\n",__func__, pdata->usb_switch_pin);\r
+                       //return -1;\r
+               }else{\r
+                       gpio_direction_output(pdata->usb_switch_pin,GPIO_HIGH);\r
+               }\r
+       }\r
+\r
+       if(pdata->pc_state_pin != INVALID_GPIO){\r
+               result = gpio_request(pdata->pc_state_pin, "ac_usb_switch");\r
+               if(result)\r
+               {\r
+                       printk("%s:fail to request gpio %d\n",__func__, pdata->pc_state_pin);\r
+                       //return -1;\r
+               }else{\r
+                       gpio_direction_input(pdata->pc_state_pin);\r
+               }\r
+       }\r
+       printk("%s: ok ...... \n", __func__);\r
+\r
+       return ret;\r
+}\r
+\r
+static int ac_usb_switch_suspend(struct platform_device *pdev,  pm_message_t state)\r
+{\r
+       struct ac_usb_switch_platform_data *pdata = pdev->dev.platform_data;\r
+\r
+       if(!pdata) {\r
+               printk("%s: pdata = NULL ...... \n", __func__);\r
+               return -1;\r
+       }\r
+       printk("%s\n",__FUNCTION__);\r
+       return 0;       \r
+}\r
+\r
+static int ac_usb_switch_resume(struct platform_device *pdev)\r
+{\r
+       struct ac_usb_switch_platform_data *pdata = pdev->dev.platform_data;\r
+\r
+       if(!pdata) {\r
+               printk("%s: pdata = NULL ...... \n", __func__);\r
+               return -1;\r
+       }\r
+       printk("%s\n",__FUNCTION__);\r
+       return 0;\r
+}\r
+\r
+static int ac_usb_switch_remove(struct platform_device *pdev)\r
+{\r
+       struct ac_usb_switch_platform_data *pdata = pdev->dev.platform_data;\r
+       if(!pdata)\r
+               return -1;\r
+\r
+       misc_deregister(&ac_usb_switch_dev);\r
+\r
+       return 0;\r
+}\r
+\r
+static struct platform_driver ac_usb_switch_driver = {\r
+       .probe  = ac_usb_switch_probe,\r
+       .remove = ac_usb_switch_remove,\r
+       .suspend        = ac_usb_switch_suspend,\r
+       .resume         = ac_usb_switch_resume,\r
+       .driver = {\r
+               .name   = "ac_usb_switch",\r
+               .owner  = THIS_MODULE,\r
+       },\r
+};\r
+\r
+static int __init ac_usb_switch_init(void)\r
+{\r
+       return platform_driver_register(&ac_usb_switch_driver);\r
+}\r
+\r
+static void __exit ac_usb_switch_exit(void)\r
+{\r
+       platform_driver_unregister(&ac_usb_switch_driver);\r
+}\r
+\r
+module_init(ac_usb_switch_init);\r
+module_exit(ac_usb_switch_exit);\r
+MODULE_DESCRIPTION ("ac usb switch driver");\r
+MODULE_LICENSE("GPL");\r
+\r
old mode 100644 (file)
new mode 100755 (executable)
index a207923..97a7d17
@@ -440,6 +440,7 @@ struct input_keymap_entry {
 
 #define KEY_WIMAX              246
 #define KEY_RFKILL             247     /* Key that controls all radios */
+#define KEY_MODE_SWITCH                248     /* Key that controls all radios */
 
 /* Code 255 is reserved for special needs of AT keyboard driver */