From a7ebd62b93a938042e11401d7afc66b1a6aacd8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=B5=B5=E5=AD=90=E5=88=9D?= Date: Tue, 17 Jul 2012 16:34:04 +0800 Subject: [PATCH] phonepad:fix 3g driver --- arch/arm/mach-rk30/board-rk30-sdk.c | 40 ++++- drivers/misc/3g_module/Kconfig | 28 ++++ drivers/misc/3g_module/Makefile | 5 + drivers/misc/{ => 3g_module}/mt6229.c | 48 +----- drivers/misc/{ => 3g_module}/mu509.c | 61 +------ drivers/misc/{ => 3g_module}/mw100.c | 48 ------ drivers/misc/3g_module/sew868.c | 228 ++++++++++++++++++++++++++ drivers/misc/Kconfig | 12 +- drivers/misc/Makefile | 5 +- drivers/misc/ste.c | 203 ----------------------- drivers/usb/serial/usb-serial.c | 14 ++ include/linux/sew868.h | 25 +++ 12 files changed, 345 insertions(+), 372 deletions(-) create mode 100644 drivers/misc/3g_module/Kconfig create mode 100644 drivers/misc/3g_module/Makefile rename drivers/misc/{ => 3g_module}/mt6229.c (82%) rename drivers/misc/{ => 3g_module}/mu509.c (80%) rename drivers/misc/{ => 3g_module}/mw100.c (79%) create mode 100755 drivers/misc/3g_module/sew868.c delete mode 100644 drivers/misc/ste.c create mode 100755 include/linux/sew868.h diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index e500d0ac0438..0b27edc772dd 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -60,6 +60,9 @@ #if defined(CONFIG_MT6229) #include #endif +#if defined(CONFIG_SEW868) +#include +#endif #if defined(CONFIG_ANDROID_TIMED_GPIO) #include "../../../drivers/staging/android/timed_gpio.h" #endif @@ -780,7 +783,7 @@ struct rk29_mt6229_data rk29_mt6229_info = { .io_init = mt6229_io_init, .io_deinit = mt6229_io_deinit, .modem_power_en = RK30_PIN6_PB2, - .bp_power = RK30_PIN2_PB7,//RK30_PIN2_PB6, + .bp_power = RK30_PIN2_PB7, .bp_reset = RK30_PIN4_PD2, .ap_wakeup_bp = RK30_PIN2_PC0, .bp_wakeup_ap = RK30_PIN6_PA0, @@ -793,6 +796,38 @@ struct platform_device rk29_device_mt6229 = { } }; #endif +#if defined(CONFIG_SEW868) +static int sew868_io_init(void) +{ + rk30_mux_api_set(GPIO2B6_LCDC1DATA14_SMCADDR18_TSSYNC_NAME, GPIO2B_GPIO2B6); + rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2); + rk30_mux_api_set(GPIO4D4_SMCDATA12_TRACEDATA12_NAME, GPIO4D_GPIO4D4); + return 0; +} +static int sew868_io_deinit(void) +{ + return 0; +} +struct rk30_sew868_data rk30_sew868_info = { + .io_init = sew868_io_init, + .io_deinit = sew868_io_deinit, + .bp_power = RK30_PIN6_PB2, + .bp_power_active_low = 1, + .bp_sys = RK30_PIN2_PB6, + .bp_reset = RK30_PIN4_PD2, + .bp_reset_active_low = 1, + .bp_wakeup_ap = RK30_PIN4_PD4, + .ap_wakeup_bp = NULL, +}; + +struct platform_device rk30_device_sew868 = { + .name = "sew868", + .id = -1, + .dev = { + .platform_data = &rk30_sew868_info, + } + }; +#endif /*MMA8452 gsensor*/ #if defined (CONFIG_GS_MMA8452) @@ -1401,6 +1436,9 @@ static struct platform_device *devices[] __initdata = { #if defined(CONFIG_MT6229) &rk29_device_mt6229, #endif +#if defined(CONFIG_SEW868) + &rk30_device_sew868, +#endif #ifdef CONFIG_BATTERY_RK30_ADC &rk30_device_adc_battery, #endif diff --git a/drivers/misc/3g_module/Kconfig b/drivers/misc/3g_module/Kconfig new file mode 100644 index 000000000000..2074779c92f4 --- /dev/null +++ b/drivers/misc/3g_module/Kconfig @@ -0,0 +1,28 @@ +# +# 3G device configuration +# + +menuconfig 3G_MODULE + tristate "3G module for phonepad" + ---help--- + Say Y here if you have a support modem + +choice + depends on 3G_MODULE + prompt "Select 3G Module" + + config MU509 + bool "MU509" + + config MT6229 + bool "MT6229" + + config MW100 + bool "MW100" + + config SEW868 + bool "SEW868" + + +endchoice + diff --git a/drivers/misc/3g_module/Makefile b/drivers/misc/3g_module/Makefile new file mode 100644 index 000000000000..33af3f5a603f --- /dev/null +++ b/drivers/misc/3g_module/Makefile @@ -0,0 +1,5 @@ +obj-$(CONFIG_MU509) += mu509.o +obj-$(CONFIG_MW100) += mw100.o +obj-$(CONFIG_MT6229) += mt6229.o +obj-$(CONFIG_SEW868) += sew868.o + diff --git a/drivers/misc/mt6229.c b/drivers/misc/3g_module/mt6229.c similarity index 82% rename from drivers/misc/mt6229.c rename to drivers/misc/3g_module/mt6229.c index 164012bacaaa..2fad22a2815e 100755 --- a/drivers/misc/mt6229.c +++ b/drivers/misc/3g_module/mt6229.c @@ -67,7 +67,6 @@ static irqreturn_t detect_irq_handler(int irq, void *dev_id) if(do_wakeup_irq) { do_wakeup_irq = 0; - // MODEMDBG("%s[%d]: %s\n", __FILE__, __LINE__, __FUNCTION__); wake_lock_timeout(&modem_wakelock, 10 * HZ); schedule_delayed_work(&wakeup_work, 2*HZ); } @@ -78,10 +77,6 @@ int modem_poweron_off(int on_off) struct rk29_mt6229_data *pdata = gpdata; if(on_off) { - MODEMDBG("------------modem_poweron\n"); - //gpio_set_value(pdata->bp_reset, GPIO_HIGH); - //msleep(100); - //gpio_set_value(pdata->bp_reset, GPIO_LOW); gpio_set_value(pdata->bp_power, GPIO_LOW); gpio_set_value(pdata->bp_power, GPIO_HIGH); msleep(10); @@ -90,7 +85,6 @@ int modem_poweron_off(int on_off) } else { - MODEMDBG("------------modem_poweroff\n"); gpio_set_value(pdata->bp_power, GPIO_HIGH); gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); } @@ -98,30 +92,22 @@ int modem_poweron_off(int on_off) } static int mt6229_open(struct inode *inode, struct file *file) { - //MODEMDBG("-------------%s\n",__FUNCTION__); struct rk29_mt6229_data *pdata = gpdata; -// struct platform_data *pdev = container_of(pdata, struct device, platform_data); device_init_wakeup(pdata->dev, 1); return 0; } static int mt6229_release(struct inode *inode, struct file *file) { - //MODEMDBG("-------------%s\n",__FUNCTION__); return 0; } static long mt6229_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct rk29_mt6229_data *pdata = gpdata; - //MODEMDBG("-------------%s\n",__FUNCTION__); switch(cmd) { case MT6229_RESET: - //gpio_set_value(pdata->bp_reset, GPIO_HIGH); - //msleep(100); - //gpio_set_value(pdata->bp_reset, GPIO_LOW); - //msleep(100); gpio_set_value(pdata->bp_power, GPIO_LOW); gpio_set_value(pdata->bp_power, GPIO_HIGH); msleep(10); @@ -179,14 +165,12 @@ static ssize_t modem_status_write(struct class *cls, const char *_buf, size_t _c static CLASS_ATTR(modem_status, 0777, modem_status_read, modem_status_write); static void rk29_early_suspend(struct early_suspend *h) { - printk("*********************mt6229____suspend\n"); } static void rk29_early_resume(struct early_suspend *h) { if(suspend_int) { - printk("***************mt6229____resume\n"); gpio_set_value(gpdata->ap_wakeup_bp, 0); suspend_int = 0; } @@ -202,8 +186,6 @@ static int mt6229_probe(struct platform_device *pdev) struct rk29_mt6229_data *pdata = gpdata = pdev->dev.platform_data; struct modem_dev *mt6229_data = NULL; int result, irq = 0; - //MODEMDBG("-------------%s\n",__FUNCTION__); - pdata->dev = &pdev->dev; if(pdata->io_init) pdata->io_init(); @@ -238,7 +220,7 @@ static int mt6229_probe(struct platform_device *pdev) } wake_lock_init(&modem_wakelock, WAKE_LOCK_SUSPEND, "bp_wakeup_ap"); gpio_direction_input(pdata->bp_wakeup_ap); - gpio_pull_updown(pdata->bp_wakeup_ap, 1); + gpio_pull_updown(pdata->bp_wakeup_ap, 1); result = request_irq(irq, detect_irq_handler, IRQ_BB_WAKEUP_AP_TRIGGER, "bp_wakeup_ap", NULL); if (result < 0) { printk("%s: request_irq(%d) failed\n", __func__, irq); @@ -267,32 +249,13 @@ int mt6229_suspend(struct platform_device *pdev, pm_message_t state) { suspend_int = 1; do_wakeup_irq = 1; - //MODEMDBG("-------------%s\n",__FUNCTION__); ap_wakeup_bp(pdev, 1); -#if defined(CONFIG_ARCH_RK29) - rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_GPIO1C1); - //gpio_direction_output(RK29_PIN1_PC1, 1); -#endif -#if defined(CONFIG_ARCH_RK30) - rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0TXD_NAME, GPIO1A_GPIO1A7); -#endif return 0; } int mt6229_resume(struct platform_device *pdev) { - //MODEMDBG("-------------%s\n",__FUNCTION__); - //ap_wakeup_bp(pdev, 0); -#if defined(CONFIG_ARCH_RK29) - rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N); -#endif -#if defined(CONFIG_ARCH_RK30) - rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0TXD_NAME, GPIO1A_UART1_RTS_N); -#endif - if(gpio_get_value(gpdata->bp_wakeup_ap)) - { - schedule_delayed_work(&wakeup_work, 2*HZ); - } + ap_wakeup_bp(pdev, 0); return 0; } @@ -301,7 +264,6 @@ void mt6229_shutdown(struct platform_device *pdev) struct rk29_mt6229_data *pdata = pdev->dev.platform_data; struct modem_dev *mt6229_data = platform_get_drvdata(pdev); - //MODEMDBG("-------------%s\n",__FUNCTION__); modem_poweron_off(0); if(pdata->io_deinit) @@ -328,10 +290,7 @@ static struct platform_driver mt6229_driver = { static int __init mt6229_init(void) { - //MODEMDBG("-------------%s\n",__FUNCTION__); - int ret ; - - + int ret ; modem_class = class_create(THIS_MODULE, "rk291x_modem"); ret = class_create_file(modem_class, &class_attr_modem_status); if (ret) @@ -343,7 +302,6 @@ static int __init mt6229_init(void) static void __exit mt6229_exit(void) { - //MODEMDBG("-------------%s\n",__FUNCTION__); platform_driver_unregister(&mt6229_driver); class_remove_file(modem_class, &class_attr_modem_status); } diff --git a/drivers/misc/mu509.c b/drivers/misc/3g_module/mu509.c similarity index 80% rename from drivers/misc/mu509.c rename to drivers/misc/3g_module/mu509.c index 6c951b069bd3..d6ce5b46f722 100755 --- a/drivers/misc/mu509.c +++ b/drivers/misc/3g_module/mu509.c @@ -36,20 +36,11 @@ MODULE_LICENSE("GPL"); static struct wake_lock modem_wakelock; #define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_FALLING //#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING -#if defined(CONFIG_ARCH_RK29) -#define airplane_mode RK29_PIN6_PC1 -#endif -#if defined(CONFIG_ARCH_RK30) -#define airplane_mode RK30_PIN2_PC0 -#endif #define MU509_RESET 0x01 -#define AIRPLANE_MODE_OFF 0x03 -#define AIRPLANE_MODE_ON 0x00 struct rk29_mu509_data *gpdata = NULL; struct class *modem_class = NULL; static int do_wakeup_irq = 0; static int modem_status; -static int online = 0; int suspend_int =0; static void ap_wakeup_bp(struct platform_device *pdev, int wake) { @@ -87,7 +78,6 @@ int modem_poweron_off(int on_off) struct rk29_mu509_data *pdata = gpdata; if(on_off) { - MODEMDBG("------------modem_poweron\n"); gpio_set_value(pdata->bp_reset, GPIO_HIGH); msleep(100); gpio_set_value(pdata->bp_reset, GPIO_LOW); @@ -97,11 +87,9 @@ int modem_poweron_off(int on_off) msleep(700); gpio_set_value(pdata->bp_power, GPIO_LOW); gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); - gpio_set_value(airplane_mode, GPIO_HIGH); } else { - MODEMDBG("------------modem_poweroff\n"); gpio_set_value(pdata->bp_power, GPIO_LOW); gpio_set_value(pdata->bp_power, GPIO_HIGH); msleep(2500); @@ -111,23 +99,19 @@ int modem_poweron_off(int on_off) } static int mu509_open(struct inode *inode, struct file *file) { - //MODEMDBG("-------------%s\n",__FUNCTION__); struct rk29_mu509_data *pdata = gpdata; -// struct platform_data *pdev = container_of(pdata, struct device, platform_data); device_init_wakeup(pdata->dev, 1); return 0; } static int mu509_release(struct inode *inode, struct file *file) { - //MODEMDBG("-------------%s\n",__FUNCTION__); return 0; } static long mu509_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct rk29_mu509_data *pdata = gpdata; - //MODEMDBG("-------------%s\n",__FUNCTION__); switch(cmd) { case MU509_RESET: @@ -141,13 +125,6 @@ static long mu509_ioctl(struct file *file, unsigned int cmd, unsigned long arg) msleep(700); gpio_set_value(pdata->bp_power, GPIO_LOW); gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); - gpio_set_value(airplane_mode, GPIO_HIGH); - break; - case AIRPLANE_MODE_ON: - gpio_set_value(airplane_mode, GPIO_LOW); - break; - case AIRPLANE_MODE_OFF: - gpio_set_value(airplane_mode, GPIO_HIGH); break; default: break; @@ -198,37 +175,14 @@ static ssize_t modem_status_write(struct class *cls, const char *_buf, size_t _c return _count; } static CLASS_ATTR(modem_status, 0777, modem_status_read, modem_status_write); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) -static ssize_t online_read(struct class *cls, struct class_attribute *attr, char *_buf) -#else -static ssize_t online_read(struct class *cls, char *_buf) -#endif -{ - return sprintf(_buf, "%d\n", online); - -} -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) -static ssize_t online_write(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count) -#else -static ssize_t online_write(struct class *cls, const char *_buf, size_t _count) -#endif -{ - int new_value = simple_strtoul(_buf, NULL, 16); - if(new_value == online) return _count; - online = new_value; - return _count; -} -static CLASS_ATTR(online, 0777, online_read, online_write); static void rk29_early_suspend(struct early_suspend *h) { - printk("*********************509____suspend\n"); } static void rk29_early_resume(struct early_suspend *h) { if(suspend_int) { - printk("***************509____resume\n"); gpio_set_value(gpdata->ap_wakeup_bp, 0); suspend_int = 0; } @@ -244,7 +198,6 @@ static int mu509_probe(struct platform_device *pdev) struct rk29_mu509_data *pdata = gpdata = pdev->dev.platform_data; struct modem_dev *mu509_data = NULL; int result, irq = 0; - //MODEMDBG("-------------%s\n",__FUNCTION__); pdata->dev = &pdev->dev; if(pdata->io_init) @@ -309,12 +262,9 @@ int mu509_suspend(struct platform_device *pdev, pm_message_t state) { suspend_int = 1; do_wakeup_irq = 1; - //MODEMDBG("-------------%s\n",__FUNCTION__); - if(!online) ap_wakeup_bp(pdev, 1); #if defined(CONFIG_ARCH_RK29) rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_GPIO1C1); - //gpio_direction_output(RK29_PIN1_PC1, 1); #endif #if defined(CONFIG_ARCH_RK30) rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0TXD_NAME, GPIO1A_GPIO1A7); @@ -324,8 +274,6 @@ int mu509_suspend(struct platform_device *pdev, pm_message_t state) int mu509_resume(struct platform_device *pdev) { - //MODEMDBG("-------------%s\n",__FUNCTION__); - //ap_wakeup_bp(pdev, 0); #if defined(CONFIG_ARCH_RK29) rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N); #endif @@ -344,7 +292,6 @@ void mu509_shutdown(struct platform_device *pdev) struct rk29_mu509_data *pdata = pdev->dev.platform_data; struct modem_dev *mu509_data = platform_get_drvdata(pdev); - //MODEMDBG("-------------%s\n",__FUNCTION__); modem_poweron_off(0); if(pdata->io_deinit) @@ -371,13 +318,9 @@ static struct platform_driver mu509_driver = { static int __init mu509_init(void) { - //MODEMDBG("-------------%s\n",__FUNCTION__); - int ret ; - - + int ret ; modem_class = class_create(THIS_MODULE, "rk291x_modem"); ret = class_create_file(modem_class, &class_attr_modem_status); - ret = class_create_file(modem_class, &class_attr_online); if (ret) { printk("Fail to class rk291x_modem.\n"); @@ -387,10 +330,8 @@ static int __init mu509_init(void) static void __exit mu509_exit(void) { - //MODEMDBG("-------------%s\n",__FUNCTION__); platform_driver_unregister(&mu509_driver); class_remove_file(modem_class, &class_attr_modem_status); - class_remove_file(modem_class, &class_attr_online); } module_init(mu509_init); diff --git a/drivers/misc/mw100.c b/drivers/misc/3g_module/mw100.c similarity index 79% rename from drivers/misc/mw100.c rename to drivers/misc/3g_module/mw100.c index 484cd977b47d..ca75f039c24d 100644 --- a/drivers/misc/mw100.c +++ b/drivers/misc/3g_module/mw100.c @@ -26,7 +26,6 @@ MODULE_LICENSE("GPL"); -//#define DEBUG #ifdef DEBUG #define MODEMDBG(x...) printk(x) #else @@ -47,54 +46,26 @@ static int bp_wakeup_ap_irq = 0; static struct wake_lock bp_wakelock; static bool bpstatus_irq_enable = false; -#if 0 -static void ap_wakeup_bp(struct platform_device *pdev, int wake) -{ - struct rk29_mw100_data *pdata = pdev->dev.platform_data; - MODEMDBG("ap_wakeup_bp\n"); - - gpio_set_value(pdata->ap_wakeup_bp, wake); -} -#endif - static void do_wakeup(struct work_struct *work) { - MODEMDBG("%s[%d]: %s\n", __FILE__, __LINE__, __FUNCTION__); enable_irq(bp_wakeup_ap_irq); } static DECLARE_DELAYED_WORK(wakeup_work, do_wakeup); static irqreturn_t detect_irq_handler(int irq, void *dev_id) { - printk("%s[%d]: %s\n", __FILE__, __LINE__, __FUNCTION__); wake_lock_timeout(&bp_wakelock, 10 * HZ); return IRQ_HANDLED; } -int modem_poweron_off(int on_off) -{ - if(on_off) - { - MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); - } - else - { - MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); - } - return 0; -} static int mw100_open(struct inode *inode, struct file *file) { - MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); - //modem_poweron_off(1); return 0; } static int mw100_release(struct inode *inode, struct file *file) { - MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); - //modem_poweron_off(0); return 0; } @@ -104,7 +75,6 @@ static long mw100_ioctl(struct file *file, unsigned int cmd, unsigned long arg) switch(cmd) { case MW_IOCTL_RESET: - printk("%s::%d--bruins--ioctl mw100 reset\n",__func__,__LINE__); gpio_direction_output(pdata->bp_reset,GPIO_LOW); mdelay(120); gpio_set_value(pdata->bp_reset, GPIO_HIGH); @@ -141,9 +111,6 @@ static int mw100_probe(struct platform_device *pdev) gpio_request(pdata->ap_wakeup_bp,"ap_wakeup_bp"); gpio_set_value(pdata->modem_power_en, GPIO_HIGH); msleep(1000); -#if defined(CONFIG_ARCH_RK29) - rk29_mux_api_set(GPIO6C76_CPUTRACEDATA76_NAME, GPIO4H_GPIO6C76); -#endif gpio_direction_output(pdata->bp_reset,GPIO_LOW); mdelay(120); gpio_set_value(pdata->bp_reset, GPIO_HIGH); @@ -157,14 +124,6 @@ static int mw100_probe(struct platform_device *pdev) gpio_set_value(pdata->bp_power, GPIO_LOW); gpio_direction_output(pdata->bp_power,GPIO_LOW); - - //±£Áô -/* gpio_set_value(pdata->bp_reset, GPIO_LOW); - gpio_direction_output(pdata->bp_reset,GPIO_LOW); - mdelay(120); - gpio_set_value(pdata->bp_reset, GPIO_HIGH); - gpio_direction_output(pdata->bp_reset,GPIO_HIGH); -*/ mw100_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL); if(mw100_data == NULL){ printk("failed to request mw100_data\n"); @@ -209,7 +168,6 @@ int mw100_suspend(struct platform_device *pdev, pm_message_t state) struct rk29_mw100_data *pdata = pdev->dev.platform_data; int irq; - MODEMDBG("%s::%d--\n",__func__,__LINE__); gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); irq = gpio_to_irq(pdata->bp_wakeup_ap); if (irq < 0) { @@ -217,7 +175,6 @@ int mw100_suspend(struct platform_device *pdev, pm_message_t state) } else { - printk("enable pdata->bp_statue irq_wake!! \n"); bpstatus_irq_enable = true; enable_irq_wake(irq); } @@ -228,11 +185,9 @@ int mw100_resume(struct platform_device *pdev) { struct rk29_mw100_data *pdata = pdev->dev.platform_data; int irq; - MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); irq = gpio_to_irq(pdata->bp_wakeup_ap); if (irq ) { - printk("enable pdata->bp_statue irq_wake!! \n"); disable_irq_wake(irq); bpstatus_irq_enable = false; } @@ -244,7 +199,6 @@ void mw100_shutdown(struct platform_device *pdev) struct rk29_mw100_data *pdata = pdev->dev.platform_data; struct modem_dev *mw100_data = platform_get_drvdata(pdev); - MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); gpio_set_value(pdata->bp_power, GPIO_HIGH); mdelay(2010); gpio_free(pdata->modem_power_en); @@ -268,13 +222,11 @@ static struct platform_driver mw100_driver = { static int __init mw100_init(void) { - MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); return platform_driver_register(&mw100_driver); } static void __exit mw100_exit(void) { - MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); platform_driver_unregister(&mw100_driver); } diff --git a/drivers/misc/3g_module/sew868.c b/drivers/misc/3g_module/sew868.c new file mode 100755 index 000000000000..ae786be7e6d7 --- /dev/null +++ b/drivers/misc/3g_module/sew868.c @@ -0,0 +1,228 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MODULE_LICENSE("GPL"); + +#define DEBUG +#ifdef DEBUG +#define MODEMDBG(x...) printk(x) +#else +#define MODEMDBG(fmt,argss...) +#endif +#define SLEEP 1 +#define READY 0 +#define SEW868_RESET 0x01 +#define SEW868_POWON 0x02 +#define SEW868_POWOFF 0x03 +static struct wake_lock modem_wakelock; +#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_FALLING +//#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING +struct rk30_sew868_data *gpdata = NULL; +static int do_wakeup_irq = 0; + +extern void rk28_send_wakeup_key(void); + +static void do_wakeup(struct work_struct *work) +{ + rk28_send_wakeup_key(); +} + +static DECLARE_DELAYED_WORK(wakeup_work, do_wakeup); +static irqreturn_t detect_irq_handler(int irq, void *dev_id) +{ + printk("%s\n", __FUNCTION__); + if(do_wakeup_irq) + { + do_wakeup_irq = 0; + wake_lock_timeout(&modem_wakelock, 10 * HZ); + schedule_delayed_work(&wakeup_work, HZ / 10); + } + return IRQ_HANDLED; +} +int modem_poweron_off(int on_off) +{ + struct rk30_sew868_data *pdata = gpdata; + if(on_off) + { + gpio_direction_output(pdata->bp_sys, GPIO_HIGH); + gpio_set_value(pdata->bp_power, GPIO_LOW); + msleep(200);//for charge + gpio_set_value(pdata->bp_power, GPIO_HIGH); + msleep(4000); + gpio_set_value(pdata->bp_power, GPIO_LOW); + msleep(200); + } + else + { + gpio_set_value(pdata->bp_power, GPIO_HIGH); + msleep(4000); + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_set_value(pdata->bp_sys, GPIO_LOW); + msleep(50); + gpio_set_value(pdata->bp_power, GPIO_LOW); + } + return 0; +} +static int sew868_open(struct inode *inode, struct file *file) +{ + return 0; +} + +static int sew868_release(struct inode *inode, struct file *file) +{ + return 0; +} + +static long sew868_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct rk30_sew868_data *pdata = gpdata; + switch(cmd) + { + case SEW868_RESET: + gpio_set_value(pdata->bp_reset, GPIO_HIGH); + mdelay(100); + gpio_set_value(pdata->bp_reset, GPIO_LOW); + mdelay(200); + modem_poweron_off(1); + break; + case SEW868_POWON: + modem_poweron_off(1); + break; + case SEW868_POWOFF: + modem_poweron_off(0); + break; + default: + break; + } + return 0; +} + +static struct file_operations sew868_fops = { + .owner = THIS_MODULE, + .open = sew868_open, + .release = sew868_release, + .unlocked_ioctl = sew868_ioctl +}; + +static struct miscdevice sew868_misc = { + .minor = MISC_DYNAMIC_MINOR, + .name = MODEM_NAME, + .fops = &sew868_fops +}; + +static int sew868_probe(struct platform_device *pdev) +{ + struct rk30_sew868_data *pdata = gpdata = pdev->dev.platform_data; + struct modem_dev *sew868_data = NULL; + int result, irq = 0; + + if(pdata->io_init) + pdata->io_init(); + + modem_poweron_off(1); + sew868_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL); + if(sew868_data == NULL) + { + printk("failed to request sew868_data\n"); + goto err1; + } + platform_set_drvdata(pdev, sew868_data); + + irq = gpio_to_irq(pdata->bp_wakeup_ap); + if(irq < 0) + { + gpio_free(pdata->bp_wakeup_ap); + printk("failed to request bp_wakeup_ap\n"); + } + + wake_lock_init(&modem_wakelock, WAKE_LOCK_SUSPEND, "bp_wakeup_ap"); + gpio_direction_input(pdata->bp_wakeup_ap); + gpio_pull_updown(pdata->bp_wakeup_ap, GPIONormal); + result = request_irq(irq, detect_irq_handler, IRQ_BB_WAKEUP_AP_TRIGGER, "bp_wakeup_ap", NULL); + if (result < 0) { + printk("%s: request_irq(%d) failed\n", __func__, irq); + gpio_free(pdata->bp_wakeup_ap); + goto err0; + } + enable_irq_wake(gpio_to_irq(pdata->bp_wakeup_ap)); + result = misc_register(&sew868_misc); + if(result) + { + MODEMDBG("misc_register err\n"); + } + + return result; +err0: + cancel_work_sync(&sew868_data->work); +err1: + kfree(sew868_data); + return 0; +} + +int sew868_suspend(struct platform_device *pdev, pm_message_t state) +{ + do_wakeup_irq = 1; + return 0; +} + +int sew868_resume(struct platform_device *pdev) +{ + return 0; +} + +void sew868_shutdown(struct platform_device *pdev) +{ + struct rk30_sew868_data *pdata = pdev->dev.platform_data; + struct modem_dev *sew868_data = platform_get_drvdata(pdev); + modem_poweron_off(0); + if(pdata->io_deinit) + pdata->io_deinit(); + cancel_work_sync(&sew868_data->work); + kfree(sew868_data); +} + +static struct platform_driver sew868_driver = { + .probe = sew868_probe, + .shutdown = sew868_shutdown, + .suspend = sew868_suspend, + .resume = sew868_resume, + .driver = { + .name = "sew868", + .owner = THIS_MODULE, + }, +}; + +static int __init sew868_init(void) +{ + return platform_driver_register(&sew868_driver); +} + +static void __exit sew868_exit(void) +{ + platform_driver_unregister(&sew868_driver); +} + +module_init(sew868_init); + +module_exit(sew868_exit); diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 626ff9a81d53..fc68cb288615 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -528,9 +528,6 @@ config APANIC_PLABEL If your platform uses a different flash partition label for storing crashdumps, enter it here. -config STE - bool "STE modem control driver" - config MTK23D bool "MTK6223D modem control driver" default n @@ -538,14 +535,6 @@ config MTK23D config FM580X bool "FM rda580x driver" -config MU509 - bool "MU509 modem control driver" - -config MW100 - bool "MW100 modem control driver" - -config MT6229 - bool "MT6229 modem control driver" config RK29_NEWTON bool "RK29_NEWTON misc driver" @@ -569,5 +558,6 @@ source "drivers/misc/iwmc3200top/Kconfig" source "drivers/misc/ti-st/Kconfig" source "drivers/misc/lis3lv02d/Kconfig" source "drivers/misc/carma/Kconfig" +source "drivers/misc/3g_module/Kconfig" endif # MISC_DEVICES diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index e5b97a33c724..47fa292d9a7b 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -53,11 +53,8 @@ obj-$(CONFIG_APANIC) += apanic.o obj-$(CONFIG_SENSORS_AK8975) += akm8975.o obj-$(CONFIG_MTK23D) += mtk23d.o obj-$(CONFIG_FM580X) += fm580x.o -obj-$(CONFIG_MU509) += mu509.o -obj-$(CONFIG_MW100) += mw100.o -obj-$(CONFIG_MT6229) += mt6229.o -obj-$(CONFIG_STE) += ste.o obj-$(CONFIG_RK29_SUPPORT_MODEM) += rk29_modem/ +obj-$(CONFIG_3G_MODULE) += 3g_module/ obj-$(CONFIG_GPS_GNS7560) += gps/ obj-y += inv_mpu/ obj-$(CONFIG_RK29_NEWTON) += newton.o diff --git a/drivers/misc/ste.c b/drivers/misc/ste.c deleted file mode 100644 index c0d29ef39bd8..000000000000 --- a/drivers/misc/ste.c +++ /dev/null @@ -1,203 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if 1 -#define D(x...) printk(x) -#else -#define D(x...) -#endif - -static int misc_opened; - -#define AP_TD_UNDEFINED_GBIN5 FPGA_PIO2_02 -#define AP_RESET_TD FPGA_PIO2_04 -#define AP_SHUTDOWN_TD_PMU FPGA_PIO2_05 -#define AP_PW_EN_TD FPGA_PIO2_03 - -#define PIN_BPSEND_ACK RK2818_PIN_PE0 -#define PIN_APSEND_ACK RK2818_PIN_PF7 - -static int bp_power_on(void) -{ - int ret=0; - - ret = gpio_request(AP_TD_UNDEFINED_GBIN5, NULL); - if (ret) { - printk("%s:failed to request fpga s %d\n",__FUNCTION__,__LINE__); - goto err; - } - ret = gpio_request(AP_RESET_TD, NULL); - if (ret) { - printk("%s:failed to request fpga s %d\n",__FUNCTION__,__LINE__); - goto err0; - } - - - ret = gpio_request(AP_SHUTDOWN_TD_PMU, NULL); - if (ret) { - printk("%s:failed to request fpga %d\n",__FUNCTION__,__LINE__); - goto err1; - } - - ret = gpio_request(AP_PW_EN_TD, NULL); - if (ret) { - printk("%s:failed to request fpga %d\n",__FUNCTION__,__LINE__); - goto err2; - } - - gpio_set_value(AP_TD_UNDEFINED_GBIN5, 1); - gpio_direction_output(AP_TD_UNDEFINED_GBIN5, 1); - gpio_direction_input(AP_RESET_TD); - - gpio_set_value(AP_SHUTDOWN_TD_PMU, 0); - gpio_direction_output(AP_SHUTDOWN_TD_PMU, 0); - - gpio_set_value(AP_PW_EN_TD, 0); - gpio_direction_output(AP_PW_EN_TD, 0); - mdelay(1); - gpio_set_value(AP_PW_EN_TD, 1); - mdelay(1200); - gpio_set_value(AP_PW_EN_TD, 0); - - return true; -err2: - gpio_free(AP_SHUTDOWN_TD_PMU); -err1: - gpio_free(AP_RESET_TD); -err0: - gpio_free(AP_TD_UNDEFINED_GBIN5); -err: - return false; -} - - - -static int bp_power_off(void) -{ - D("+++--++++++%s_________ \r\n",__FUNCTION__); - - gpio_set_value(AP_TD_UNDEFINED_GBIN5, 0); - - gpio_set_value(AP_PW_EN_TD, 0); - //gpio_direction_output(AP_PW_EN_TD, 0); - mdelay(1); - gpio_set_value(AP_PW_EN_TD, 1); - mdelay(1200); - gpio_set_value(AP_PW_EN_TD, 0); - - mdelay(5000); - gpio_set_value(AP_SHUTDOWN_TD_PMU, 1); - mdelay(1200); - // gpio_free(AP_PW_EN_TD); - D("++++--+++++%s ok_________\r\n",__FUNCTION__); - return 0; -} -//add end - -static int ste_open(struct inode *inode, struct file *file) -{ - D("%s\n", __func__); - if (misc_opened) - return -EBUSY; - misc_opened = 1; - return 0; -} - -static int ste_release(struct inode *inode, struct file *file) -{ - D("%s\n", __func__); - misc_opened = 0; - return 0; -} - -static int ste_ioctl(struct inode *inode,struct file *file, unsigned int cmd, unsigned long arg) -{ - int val; - D("%s cmd %d\n", __func__, _IOC_NR(cmd)); - switch (cmd) { - case STE_IOCTL_EN_APSEND_ACK: - D("%s:STE_IOCTL_EN_APSEND_ACK\n"); - gpio_direction_output(PIN_APSEND_ACK,GPIO_LOW); - msleep(50); - gpio_direction_output(PIN_APSEND_ACK,GPIO_HIGH); - msleep(50); - break; - case STE_IOCTL_GET_ACK: - val = gpio_get_value(PIN_BPSEND_ACK); - D("%s:STE_IOCTL_GET_ACK pin status is %d\n",__func__,val); - return put_user(val, (unsigned long __user *)arg); - break; - case STE_IOCTL_POWER_ON: - D("%s:STE_IOCTL_POWER_ON\n",__func__); - bp_power_on(); - break; - case STE_IOCTL_POWER_OFF: - D("%s:STE_IOCTL_POWER_OFF\n",__func__); - bp_power_off(); - break; - default: - pr_err("%s: invalid cmd %d\n", __func__, _IOC_NR(cmd)); - return -EINVAL; - } - return 0; -} - -static struct file_operations ste_fops = { - .owner = THIS_MODULE, - .open = ste_open, - .release = ste_release, - .ioctl = ste_ioctl -}; - -static struct miscdevice ste_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = STE_NAME, - .fops = &ste_fops -}; - -static int ste_probe(struct platform_device *pdev) -{ - int rc = -EIO; - D("%s-----------\n",__FUNCTION__); - - rc = misc_register(&ste_misc); - if (rc < 0) { - pr_err("%s: could not register misc device\n", __func__); - // goto err_unregister_input_device; - } - return rc; -} - -static struct platform_driver ste_driver = { - .probe = ste_probe, - .driver = { - .name = "ste", - .owner = THIS_MODULE - }, -}; - -static int __init ste_init(void) -{ - return platform_driver_register(&ste_driver); -} - -static void __exit ste_exit(void) -{ - platform_driver_unregister(&ste_driver); -} - -module_init(ste_init); -module_exit(ste_exit); diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index bf8a940a353a..49d860078b93 100755 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -65,6 +65,10 @@ static int MW100_USB = 0; static int MT6229_USB = 0; #define MT6229_USB_PORT (SERIAL_TTY_MINORS - 10) #endif +#ifdef CONFIG_SEW868 +static int SEW868_USB = 0; +#define SEW868_USB_PORT (SERIAL_TTY_MINORS - 10) +#endif /* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead the MODULE_DEVICE_TABLE declarations in each serial driver @@ -126,6 +130,10 @@ static struct usb_serial *get_free_serial(struct usb_serial *serial, #ifdef CONFIG_MT6229 if (MT6229_USB) a= MT6229_USB_PORT; +#endif +#ifdef CONFIG_SEW868 + if (SEW868_USB) + a= SEW868_USB_PORT; #endif for (i = a; i < SERIAL_TTY_MINORS; ++i) { if (serial_table[i]) @@ -1101,6 +1109,12 @@ int usb_serial_probe(struct usb_interface *interface, else MT6229_USB = 0; #endif +#ifdef CONFIG_SEW868 + if ((le16_to_cpu(dev->descriptor.idVendor) == 0x19d2) && (le16_to_cpu(dev->descriptor.idProduct) == 0xffeb)) + SEW868_USB =1; + else + SEW868_USB = 0; +#endif if (get_free_serial(serial, num_ports, &minor) == NULL) { dev_err(&interface->dev, "No more free serial devices\n"); diff --git a/include/linux/sew868.h b/include/linux/sew868.h new file mode 100755 index 000000000000..3d09ccbdd03e --- /dev/null +++ b/include/linux/sew868.h @@ -0,0 +1,25 @@ +#include +#include +#include + +struct modem_dev +{ + const char *name; + struct miscdevice miscdev; + struct work_struct work; +}; + +/* 耳机数据结构体 */ +struct rk30_sew868_data { + int (*io_init)(void); + int (*io_deinit)(void); + unsigned int bp_sys; + unsigned int bp_power; + unsigned int bp_power_active_low; + unsigned int bp_reset; + unsigned int bp_reset_active_low; + unsigned int bp_wakeup_ap; + unsigned int ap_wakeup_bp; +}; + +#define MODEM_NAME "sew868" -- 2.34.1