From: wlq Date: Fri, 11 Oct 2013 12:32:40 +0000 (+0800) Subject: ac: add for display key control X-Git-Tag: firefly_0821_release~6572 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=06028a94a91fd1ea3561d143e932fb4433347092;p=firefly-linux-kernel-4.4.55.git ac: add for display key control --- diff --git a/arch/arm/configs/rk3188_ac_defconfig b/arch/arm/configs/rk3188_ac_defconfig old mode 100644 new mode 100755 index e4571af47494..f20af96aee6c --- a/arch/arm/configs/rk3188_ac_defconfig +++ b/arch/arm/configs/rk3188_ac_defconfig @@ -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 diff --git a/arch/arm/mach-rk3188/board-rk3188-ac.c b/arch/arm/mach-rk3188/board-rk3188-ac.c index 999ce00d9bbb..5feb14a990ca 100755 --- a/arch/arm/mach-rk3188/board-rk3188-ac.c +++ b/arch/arm/mach-rk3188/board-rk3188-ac.c @@ -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 }; diff --git a/arch/arm/plat-rk/include/plat/board.h b/arch/arm/plat-rk/include/plat/board.h index c71fa0455358..89fc19aa1733 100755 --- a/arch/arm/plat-rk/include/plat/board.h +++ b/arch/arm/plat-rk/include/plat/board.h @@ -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; diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 4e90a6d47c23..49fb1da17e77 100755 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -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" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile old mode 100644 new mode 100755 index ff2e22c7a33d..04e973cd3e78 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -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 index 000000000000..a72bcd4663a0 --- /dev/null +++ b/drivers/misc/ac_usb_switch.c @@ -0,0 +1,217 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if 1 +#define DBG(x...) printk(KERN_INFO x) +#else +#define DBG(x...) +#endif +#define PC_DISPLAY_MODE 1 +#define ANDROID_DISPLAY_MODE 2 + +#define USB_SWITCH_IOCTL_BASE 'u' +#define USB_SWITCH_IOCTL_SET_USB_SWITCH_MODE _IOW(USB_SWITCH_IOCTL_BASE, 0x01, int) +#define USB_SWITCH_IOCTL_GET_PC_STATE _IOR(USB_SWITCH_IOCTL_BASE, 0x02, int) + +static struct ac_usb_switch_platform_data *ac_usb_switch; + + +static int setUsbSwitchMode(int mode){ + struct ac_usb_switch_platform_data *pdata = ac_usb_switch; + if(pdata->usb_switch_pin == INVALID_GPIO){ + DBG(" error ac_usb_switch_pin is null !!!\n"); + return -1; + } + switch(mode){ + case PC_DISPLAY_MODE: + gpio_set_value(pdata->usb_switch_pin,GPIO_LOW); + break; + case ANDROID_DISPLAY_MODE: + gpio_set_value(pdata->usb_switch_pin,GPIO_HIGH); + break; + default: + break; + } + return 0; +} +static int getPCstate(){ + return 1; +} + +static int ac_usb_switch_open(struct inode *inode, struct file *filp) +{ + DBG("ac_usb_switch_open\n"); + + return 0; +} + +static ssize_t ac_usb_switch_read(struct file *filp, char __user *ptr, size_t size, loff_t *pos) +{ + if (ptr == NULL) + printk("%s: user space address is NULL\n", __func__); + return sizeof(int); +} + +static long ac_usb_switch_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + long ret = 0; + int mode; + struct ac_usb_switch_platform_data *pdata = ac_usb_switch; + + DBG("ac_usb_switch_ioctl: cmd = %d arg = %ld\n",cmd, arg); + + switch (cmd){ + case USB_SWITCH_IOCTL_SET_USB_SWITCH_MODE: + DBG("ac_usb_switch_ioctl: USB_SWITCH_IOCTL_SET_USB_SWITCH_MODE\n"); + mode = arg; + setUsbSwitchMode(mode); + break; + case USB_SWITCH_IOCTL_GET_PC_STATE: + DBG("ac_usb_switch_ioctl: USB_SWITCH_IOCTL_GET_PC_STATE\n"); + return getPCstate(); + + default: + printk("unknown ioctl cmd!\n"); + ret = -EINVAL; + break; + } + return ret; +} + +static int ac_usb_switch_release(struct inode *inode, struct file *filp) +{ + DBG("ac_usb_switch_release\n"); + + return 0; +} + +static struct file_operations ac_usb_switch_fops = { + .owner = THIS_MODULE, + .open = ac_usb_switch_open, + .read = ac_usb_switch_read, + .unlocked_ioctl = ac_usb_switch_ioctl, + .release = ac_usb_switch_release, +}; + +static struct miscdevice ac_usb_switch_dev = +{ + .minor = MISC_DYNAMIC_MINOR, + .name = "ac_usb_switch", + .fops = &ac_usb_switch_fops, +}; + +static int ac_usb_switch_probe(struct platform_device *pdev) +{ + int ret = 0; + int result; + struct ac_usb_switch_platform_data *pdata = pdev->dev.platform_data; + if(!pdata) + return -1; + ac_usb_switch = pdata; + ret = misc_register(&ac_usb_switch_dev); + if (ret < 0){ + printk("ac_usb_switch register err!\n"); + return ret; + } + + if(pdata->usb_switch_pin != INVALID_GPIO){ + result = gpio_request(pdata->usb_switch_pin, "ac_usb_switch"); + if(result) + { + printk("%s:fail to request gpio %d\n",__func__, pdata->usb_switch_pin); + //return -1; + }else{ + gpio_direction_output(pdata->usb_switch_pin,GPIO_HIGH); + } + } + + if(pdata->pc_state_pin != INVALID_GPIO){ + result = gpio_request(pdata->pc_state_pin, "ac_usb_switch"); + if(result) + { + printk("%s:fail to request gpio %d\n",__func__, pdata->pc_state_pin); + //return -1; + }else{ + gpio_direction_input(pdata->pc_state_pin); + } + } + printk("%s: ok ...... \n", __func__); + + return ret; +} + +static int ac_usb_switch_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct ac_usb_switch_platform_data *pdata = pdev->dev.platform_data; + + if(!pdata) { + printk("%s: pdata = NULL ...... \n", __func__); + return -1; + } + printk("%s\n",__FUNCTION__); + return 0; +} + +static int ac_usb_switch_resume(struct platform_device *pdev) +{ + struct ac_usb_switch_platform_data *pdata = pdev->dev.platform_data; + + if(!pdata) { + printk("%s: pdata = NULL ...... \n", __func__); + return -1; + } + printk("%s\n",__FUNCTION__); + return 0; +} + +static int ac_usb_switch_remove(struct platform_device *pdev) +{ + struct ac_usb_switch_platform_data *pdata = pdev->dev.platform_data; + if(!pdata) + return -1; + + misc_deregister(&ac_usb_switch_dev); + + return 0; +} + +static struct platform_driver ac_usb_switch_driver = { + .probe = ac_usb_switch_probe, + .remove = ac_usb_switch_remove, + .suspend = ac_usb_switch_suspend, + .resume = ac_usb_switch_resume, + .driver = { + .name = "ac_usb_switch", + .owner = THIS_MODULE, + }, +}; + +static int __init ac_usb_switch_init(void) +{ + return platform_driver_register(&ac_usb_switch_driver); +} + +static void __exit ac_usb_switch_exit(void) +{ + platform_driver_unregister(&ac_usb_switch_driver); +} + +module_init(ac_usb_switch_init); +module_exit(ac_usb_switch_exit); +MODULE_DESCRIPTION ("ac usb switch driver"); +MODULE_LICENSE("GPL"); + diff --git a/include/linux/input.h b/include/linux/input.h old mode 100644 new mode 100755 index a207923f3612..97a7d17a4279 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -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 */