From: 赵子初 Date: Tue, 17 Jul 2012 08:34:04 +0000 (+0800) Subject: phonepad:fix 3g driver X-Git-Tag: firefly_0821_release~8997 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a7ebd62b93a938042e11401d7afc66b1a6aacd8e;p=firefly-linux-kernel-4.4.55.git phonepad:fix 3g driver --- 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/3g_module/mt6229.c b/drivers/misc/3g_module/mt6229.c new file mode 100755 index 000000000000..2fad22a2815e --- /dev/null +++ b/drivers/misc/3g_module/mt6229.c @@ -0,0 +1,311 @@ +#include +#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 +static struct wake_lock modem_wakelock; +//#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_FALLING +#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING +#define MT6229_RESET 0x01 +struct rk29_mt6229_data *gpdata = NULL; +struct class *modem_class = NULL; +static int do_wakeup_irq = 0; +static int modem_status; +int suspend_int =0; +static void ap_wakeup_bp(struct platform_device *pdev, int wake) +{ + struct rk29_mt6229_data *pdata = pdev->dev.platform_data; + + gpio_set_value(pdata->ap_wakeup_bp, wake); + +} +extern void rk28_send_wakeup_key(void); + +static void do_wakeup(struct work_struct *work) +{ + if(suspend_int) + { + gpio_set_value(gpdata->ap_wakeup_bp, 0); + suspend_int = 0; + } + +} + +static DECLARE_DELAYED_WORK(wakeup_work, do_wakeup); +static irqreturn_t detect_irq_handler(int irq, void *dev_id) +{ + if(do_wakeup_irq) + { + do_wakeup_irq = 0; + wake_lock_timeout(&modem_wakelock, 10 * HZ); + schedule_delayed_work(&wakeup_work, 2*HZ); + } + return IRQ_HANDLED; +} +int modem_poweron_off(int on_off) +{ + struct rk29_mt6229_data *pdata = gpdata; + if(on_off) + { + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_set_value(pdata->bp_power, GPIO_HIGH); + msleep(10); + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); + } + else + { + gpio_set_value(pdata->bp_power, GPIO_HIGH); + gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); + } + return 0; +} +static int mt6229_open(struct inode *inode, struct file *file) +{ + struct rk29_mt6229_data *pdata = gpdata; + device_init_wakeup(pdata->dev, 1); + return 0; +} + +static int mt6229_release(struct inode *inode, struct file *file) +{ + return 0; +} + +static long mt6229_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct rk29_mt6229_data *pdata = gpdata; + switch(cmd) + { + case MT6229_RESET: + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_set_value(pdata->bp_power, GPIO_HIGH); + msleep(10); + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); + break; + default: + break; + } + return 0; +} + +static struct file_operations mt6229_fops = { + .owner = THIS_MODULE, + .open = mt6229_open, + .release = mt6229_release, + .unlocked_ioctl = mt6229_ioctl +}; + +static struct miscdevice mt6229_misc = { + .minor = MISC_DYNAMIC_MINOR, + .name = MODEM_NAME, + .fops = &mt6229_fops +}; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) +static ssize_t modem_status_read(struct class *cls, struct class_attribute *attr, char *_buf) +#else +static ssize_t modem_status_read(struct class *cls, char *_buf) +#endif +{ + + return sprintf(_buf, "%d\n", modem_status); + +} +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) +static ssize_t modem_status_write(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count) +#else +static ssize_t modem_status_write(struct class *cls, const char *_buf, size_t _count) +#endif +{ + int new_state = simple_strtoul(_buf, NULL, 16); + if(new_state == modem_status) return _count; + if (new_state == 1){ + printk("%s, c(%d), open modem \n", __FUNCTION__, new_state); + modem_poweron_off(1); + }else if(new_state == 0){ + printk("%s, c(%d), close modem \n", __FUNCTION__, new_state); + modem_poweron_off(0); + }else{ + printk("%s, invalid parameter \n", __FUNCTION__); + } + modem_status = new_state; + return _count; +} +static CLASS_ATTR(modem_status, 0777, modem_status_read, modem_status_write); +static void rk29_early_suspend(struct early_suspend *h) +{ + +} +static void rk29_early_resume(struct early_suspend *h) +{ + if(suspend_int) + { + gpio_set_value(gpdata->ap_wakeup_bp, 0); + suspend_int = 0; + } +} + +static struct early_suspend mt6229_early_suspend = { + .suspend = rk29_early_suspend, + .resume = rk29_early_resume, + .level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1, + }; +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; + pdata->dev = &pdev->dev; + if(pdata->io_init) + pdata->io_init(); + gpio_set_value(pdata->modem_power_en, GPIO_HIGH); + msleep(1000); + modem_poweron_off(1); + modem_status = 1; + + register_early_suspend(&mt6229_early_suspend); + mt6229_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL); + if(mt6229_data == NULL) + { + printk("failed to request mt6229_data\n"); + goto err2; + } + platform_set_drvdata(pdev, mt6229_data); + result = gpio_request(pdata->ap_wakeup_bp, "mt6229"); + if (result) { + printk("failed to request AP_BP_WAKEUP gpio\n"); + goto err1; + } + irq = gpio_to_irq(pdata->bp_wakeup_ap); + enable_irq_wake(irq); + if(irq < 0) + { + gpio_free(pdata->bp_wakeup_ap); + printk("failed to request bp_wakeup_ap\n"); + } + result = gpio_request(pdata->bp_wakeup_ap, "bp_wakeup_ap"); + if (result < 0) { + printk("%s: gpio_request(%d) failed\n", __func__, pdata->bp_wakeup_ap); + } + 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); + 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(&mt6229_misc); + if(result) + { + printk("misc_register err\n"); + } + return result; +err0: + cancel_work_sync(&mt6229_data->work); + gpio_free(pdata->bp_wakeup_ap); +err1: + gpio_free(pdata->ap_wakeup_bp); +err2: + kfree(mt6229_data); + return 0; +} + +int mt6229_suspend(struct platform_device *pdev, pm_message_t state) +{ + suspend_int = 1; + do_wakeup_irq = 1; + ap_wakeup_bp(pdev, 1); + return 0; +} + +int mt6229_resume(struct platform_device *pdev) +{ + ap_wakeup_bp(pdev, 0); + return 0; +} + +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); + + modem_poweron_off(0); + + if(pdata->io_deinit) + pdata->io_deinit(); + cancel_work_sync(&mt6229_data->work); + gpio_free(pdata->modem_power_en); + gpio_free(pdata->bp_power); + gpio_free(pdata->bp_reset); + gpio_free(pdata->ap_wakeup_bp); + gpio_free(pdata->bp_wakeup_ap); + kfree(mt6229_data); +} + +static struct platform_driver mt6229_driver = { + .probe = mt6229_probe, + .shutdown = mt6229_shutdown, + .suspend = mt6229_suspend, + .resume = mt6229_resume, + .driver = { + .name = "mt6229", + .owner = THIS_MODULE, + }, +}; + +static int __init mt6229_init(void) +{ + int ret ; + modem_class = class_create(THIS_MODULE, "rk291x_modem"); + ret = class_create_file(modem_class, &class_attr_modem_status); + if (ret) + { + printk("Fail to class rk291x_modem.\n"); + } + return platform_driver_register(&mt6229_driver); +} + +static void __exit mt6229_exit(void) +{ + platform_driver_unregister(&mt6229_driver); + class_remove_file(modem_class, &class_attr_modem_status); +} + +module_init(mt6229_init); + +module_exit(mt6229_exit); diff --git a/drivers/misc/3g_module/mu509.c b/drivers/misc/3g_module/mu509.c new file mode 100755 index 000000000000..d6ce5b46f722 --- /dev/null +++ b/drivers/misc/3g_module/mu509.c @@ -0,0 +1,339 @@ +#include +#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 +static struct wake_lock modem_wakelock; +#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_FALLING +//#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING +#define MU509_RESET 0x01 +struct rk29_mu509_data *gpdata = NULL; +struct class *modem_class = NULL; +static int do_wakeup_irq = 0; +static int modem_status; +int suspend_int =0; +static void ap_wakeup_bp(struct platform_device *pdev, int wake) +{ + struct rk29_mu509_data *pdata = pdev->dev.platform_data; + + gpio_set_value(pdata->ap_wakeup_bp, wake); + +} +extern void rk28_send_wakeup_key(void); + +static void do_wakeup(struct work_struct *work) +{ + if(suspend_int) + { + gpio_set_value(gpdata->ap_wakeup_bp, 0); + suspend_int = 0; + } + +} + +static DECLARE_DELAYED_WORK(wakeup_work, do_wakeup); +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); + } + return IRQ_HANDLED; +} +int modem_poweron_off(int on_off) +{ + struct rk29_mu509_data *pdata = gpdata; + if(on_off) + { + 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); + msleep(1000); + gpio_set_value(pdata->bp_power, GPIO_HIGH); + msleep(700); + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); + } + else + { + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_set_value(pdata->bp_power, GPIO_HIGH); + msleep(2500); + gpio_set_value(pdata->bp_power, GPIO_LOW); + } + return 0; +} +static int mu509_open(struct inode *inode, struct file *file) +{ + struct rk29_mu509_data *pdata = gpdata; + device_init_wakeup(pdata->dev, 1); + return 0; +} + +static int mu509_release(struct inode *inode, struct file *file) +{ + return 0; +} + +static long mu509_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct rk29_mu509_data *pdata = gpdata; + switch(cmd) + { + case MU509_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); + msleep(1000); + gpio_set_value(pdata->bp_power, GPIO_HIGH); + msleep(700); + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); + break; + default: + break; + } + return 0; +} + +static struct file_operations mu509_fops = { + .owner = THIS_MODULE, + .open = mu509_open, + .release = mu509_release, + .unlocked_ioctl = mu509_ioctl +}; + +static struct miscdevice mu509_misc = { + .minor = MISC_DYNAMIC_MINOR, + .name = MODEM_NAME, + .fops = &mu509_fops +}; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) +static ssize_t modem_status_read(struct class *cls, struct class_attribute *attr, char *_buf) +#else +static ssize_t modem_status_read(struct class *cls, char *_buf) +#endif +{ + + return sprintf(_buf, "%d\n", modem_status); + +} +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) +static ssize_t modem_status_write(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count) +#else +static ssize_t modem_status_write(struct class *cls, const char *_buf, size_t _count) +#endif +{ + int new_state = simple_strtoul(_buf, NULL, 16); + if(new_state == modem_status) return _count; + if (new_state == 1){ + printk("%s, c(%d), open modem \n", __FUNCTION__, new_state); + modem_poweron_off(1); + }else if(new_state == 0){ + printk("%s, c(%d), close modem \n", __FUNCTION__, new_state); + modem_poweron_off(0); + }else{ + printk("%s, invalid parameter \n", __FUNCTION__); + } + modem_status = new_state; + return _count; +} +static CLASS_ATTR(modem_status, 0777, modem_status_read, modem_status_write); +static void rk29_early_suspend(struct early_suspend *h) +{ + +} +static void rk29_early_resume(struct early_suspend *h) +{ + if(suspend_int) + { + gpio_set_value(gpdata->ap_wakeup_bp, 0); + suspend_int = 0; + } +} + +static struct early_suspend mu509_early_suspend = { + .suspend = rk29_early_suspend, + .resume = rk29_early_resume, + .level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1, + }; +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; + + pdata->dev = &pdev->dev; + if(pdata->io_init) + pdata->io_init(); + gpio_set_value(pdata->modem_power_en, GPIO_HIGH); + msleep(1000); + modem_poweron_off(1); + modem_status = 1; + + register_early_suspend(&mu509_early_suspend); + mu509_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL); + if(mu509_data == NULL) + { + printk("failed to request mu509_data\n"); + goto err2; + } + platform_set_drvdata(pdev, mu509_data); + result = gpio_request(pdata->ap_wakeup_bp, "mu509"); + if (result) { + printk("failed to request AP_BP_WAKEUP gpio\n"); + goto err1; + } + irq = gpio_to_irq(pdata->bp_wakeup_ap); + enable_irq_wake(irq); + if(irq < 0) + { + gpio_free(pdata->bp_wakeup_ap); + printk("failed to request bp_wakeup_ap\n"); + } + result = gpio_request(pdata->bp_wakeup_ap, "bp_wakeup_ap"); + if (result < 0) { + printk("%s: gpio_request(%d) failed\n", __func__, pdata->bp_wakeup_ap); + } + 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); + 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(&mu509_misc); + if(result) + { + printk("misc_register err\n"); + } + return result; +err0: + cancel_work_sync(&mu509_data->work); + gpio_free(pdata->bp_wakeup_ap); +err1: + gpio_free(pdata->ap_wakeup_bp); +err2: + kfree(mu509_data); + return 0; +} + +int mu509_suspend(struct platform_device *pdev, pm_message_t state) +{ + suspend_int = 1; + do_wakeup_irq = 1; + ap_wakeup_bp(pdev, 1); +#if defined(CONFIG_ARCH_RK29) + rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_GPIO1C1); +#endif +#if defined(CONFIG_ARCH_RK30) + rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0TXD_NAME, GPIO1A_GPIO1A7); +#endif + return 0; +} + +int mu509_resume(struct platform_device *pdev) +{ +#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); + } + return 0; +} + +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); + + modem_poweron_off(0); + + if(pdata->io_deinit) + pdata->io_deinit(); + cancel_work_sync(&mu509_data->work); + gpio_free(pdata->modem_power_en); + gpio_free(pdata->bp_power); + gpio_free(pdata->bp_reset); + gpio_free(pdata->ap_wakeup_bp); + gpio_free(pdata->bp_wakeup_ap); + kfree(mu509_data); +} + +static struct platform_driver mu509_driver = { + .probe = mu509_probe, + .shutdown = mu509_shutdown, + .suspend = mu509_suspend, + .resume = mu509_resume, + .driver = { + .name = "mu509", + .owner = THIS_MODULE, + }, +}; + +static int __init mu509_init(void) +{ + int ret ; + modem_class = class_create(THIS_MODULE, "rk291x_modem"); + ret = class_create_file(modem_class, &class_attr_modem_status); + if (ret) + { + printk("Fail to class rk291x_modem.\n"); + } + return platform_driver_register(&mu509_driver); +} + +static void __exit mu509_exit(void) +{ + platform_driver_unregister(&mu509_driver); + class_remove_file(modem_class, &class_attr_modem_status); +} + +module_init(mu509_init); + +module_exit(mu509_exit); diff --git a/drivers/misc/3g_module/mw100.c b/drivers/misc/3g_module/mw100.c new file mode 100644 index 000000000000..ca75f039c24d --- /dev/null +++ b/drivers/misc/3g_module/mw100.c @@ -0,0 +1,235 @@ +#include +#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"); + +#ifdef DEBUG +#define MODEMDBG(x...) printk(x) +#else +#define MODEMDBG(fmt,argss...) +#endif + +#define MW100IO 0XA1 +#define MW_IOCTL_RESET _IO(MW100IO,0X01) + +#define SLEEP 1 +#define READY 0 +#define MW100_RESET 0x01 +#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING +//#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING +struct rk29_mw100_data *gpdata = NULL; +static int bp_wakeup_ap_irq = 0; + +static struct wake_lock bp_wakelock; +static bool bpstatus_irq_enable = false; + +static void do_wakeup(struct work_struct *work) +{ + 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) +{ + wake_lock_timeout(&bp_wakelock, 10 * HZ); + + return IRQ_HANDLED; +} + +static int mw100_open(struct inode *inode, struct file *file) +{ + return 0; +} + +static int mw100_release(struct inode *inode, struct file *file) +{ + return 0; +} + +static long mw100_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct rk29_mw100_data *pdata = gpdata; + switch(cmd) + { + case MW_IOCTL_RESET: + gpio_direction_output(pdata->bp_reset,GPIO_LOW); + mdelay(120); + gpio_set_value(pdata->bp_reset, GPIO_HIGH); + + break; + default: + break; + } + return 0; +} + +static struct file_operations mw100_fops = { + .owner = THIS_MODULE, + .open = mw100_open, + .release = mw100_release, + .unlocked_ioctl = mw100_ioctl +}; + +static struct miscdevice mw100_misc = { + .minor = MISC_DYNAMIC_MINOR, + .name = "mw100", + .fops = &mw100_fops +}; + +static int mw100_probe(struct platform_device *pdev) +{ + struct rk29_mw100_data *pdata = gpdata = pdev->dev.platform_data; + struct modem_dev *mw100_data = NULL; + int result, irq = 0; + + gpio_request(pdata->bp_power,"bp_power"); + gpio_request(pdata->bp_reset,"bp_reset"); + gpio_request(pdata->bp_wakeup_ap,"bp_wakeup_ap"); + gpio_request(pdata->ap_wakeup_bp,"ap_wakeup_bp"); + gpio_set_value(pdata->modem_power_en, GPIO_HIGH); + msleep(1000); + gpio_direction_output(pdata->bp_reset,GPIO_LOW); + mdelay(120); + gpio_set_value(pdata->bp_reset, GPIO_HIGH); + + gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); + gpio_direction_output(pdata->ap_wakeup_bp,GPIO_HIGH); + + gpio_set_value(pdata->bp_power, GPIO_HIGH); + gpio_direction_output(pdata->bp_power,GPIO_HIGH); + mdelay(120); + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_direction_output(pdata->bp_power,GPIO_LOW); + + mw100_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL); + if(mw100_data == NULL){ + printk("failed to request mw100_data\n"); + goto err2; + } + platform_set_drvdata(pdev, mw100_data); + + gpio_direction_input(pdata->bp_wakeup_ap); + 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"); + } + + bp_wakeup_ap_irq = irq; + + 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(bp_wakeup_ap_irq); + + wake_lock_init(&bp_wakelock, WAKE_LOCK_SUSPEND, "bp_resume"); + + result = misc_register(&mw100_misc); + if(result){ + MODEMDBG("misc_register err\n"); + } + return result; +err0: + gpio_free(pdata->bp_wakeup_ap); +err2: + kfree(mw100_data); + return 0; +} + +int mw100_suspend(struct platform_device *pdev, pm_message_t state) +{ + + struct rk29_mw100_data *pdata = pdev->dev.platform_data; + int irq; + gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); + irq = gpio_to_irq(pdata->bp_wakeup_ap); + if (irq < 0) { + printk("can't get pdata->bp_statue irq \n"); + } + else + { + bpstatus_irq_enable = true; + enable_irq_wake(irq); + } + return 0; +} + +int mw100_resume(struct platform_device *pdev) +{ + struct rk29_mw100_data *pdata = pdev->dev.platform_data; + int irq; + gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); + irq = gpio_to_irq(pdata->bp_wakeup_ap); + if (irq ) { + disable_irq_wake(irq); + bpstatus_irq_enable = false; + } + return 0; +} + +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); + + gpio_set_value(pdata->bp_power, GPIO_HIGH); + mdelay(2010); + gpio_free(pdata->modem_power_en); + gpio_free(pdata->bp_power); + gpio_free(pdata->bp_reset); + gpio_free(pdata->ap_wakeup_bp); + gpio_free(pdata->bp_wakeup_ap); + kfree(mw100_data); +} + +static struct platform_driver mw100_driver = { + .probe = mw100_probe, + .shutdown = mw100_shutdown, + .suspend = mw100_suspend, + .resume = mw100_resume, + .driver = { + .name = "mw100", + .owner = THIS_MODULE, + }, +}; + +static int __init mw100_init(void) +{ + return platform_driver_register(&mw100_driver); +} + +static void __exit mw100_exit(void) +{ + platform_driver_unregister(&mw100_driver); +} + +module_init(mw100_init); + +module_exit(mw100_exit); 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/mt6229.c b/drivers/misc/mt6229.c deleted file mode 100755 index 164012bacaaa..000000000000 --- a/drivers/misc/mt6229.c +++ /dev/null @@ -1,353 +0,0 @@ -#include -#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 -static struct wake_lock modem_wakelock; -//#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_FALLING -#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING -#define MT6229_RESET 0x01 -struct rk29_mt6229_data *gpdata = NULL; -struct class *modem_class = NULL; -static int do_wakeup_irq = 0; -static int modem_status; -int suspend_int =0; -static void ap_wakeup_bp(struct platform_device *pdev, int wake) -{ - struct rk29_mt6229_data *pdata = pdev->dev.platform_data; - - gpio_set_value(pdata->ap_wakeup_bp, wake); - -} -extern void rk28_send_wakeup_key(void); - -static void do_wakeup(struct work_struct *work) -{ - if(suspend_int) - { - gpio_set_value(gpdata->ap_wakeup_bp, 0); - suspend_int = 0; - } - -} - -static DECLARE_DELAYED_WORK(wakeup_work, do_wakeup); -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); - } - return IRQ_HANDLED; -} -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); - gpio_set_value(pdata->bp_power, GPIO_LOW); - gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); - } - else - { - MODEMDBG("------------modem_poweroff\n"); - gpio_set_value(pdata->bp_power, GPIO_HIGH); - gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); - } - return 0; -} -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); - gpio_set_value(pdata->bp_power, GPIO_LOW); - gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); - break; - default: - break; - } - return 0; -} - -static struct file_operations mt6229_fops = { - .owner = THIS_MODULE, - .open = mt6229_open, - .release = mt6229_release, - .unlocked_ioctl = mt6229_ioctl -}; - -static struct miscdevice mt6229_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = MODEM_NAME, - .fops = &mt6229_fops -}; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) -static ssize_t modem_status_read(struct class *cls, struct class_attribute *attr, char *_buf) -#else -static ssize_t modem_status_read(struct class *cls, char *_buf) -#endif -{ - - return sprintf(_buf, "%d\n", modem_status); - -} -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) -static ssize_t modem_status_write(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count) -#else -static ssize_t modem_status_write(struct class *cls, const char *_buf, size_t _count) -#endif -{ - int new_state = simple_strtoul(_buf, NULL, 16); - if(new_state == modem_status) return _count; - if (new_state == 1){ - printk("%s, c(%d), open modem \n", __FUNCTION__, new_state); - modem_poweron_off(1); - }else if(new_state == 0){ - printk("%s, c(%d), close modem \n", __FUNCTION__, new_state); - modem_poweron_off(0); - }else{ - printk("%s, invalid parameter \n", __FUNCTION__); - } - modem_status = new_state; - return _count; -} -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; - } -} - -static struct early_suspend mt6229_early_suspend = { - .suspend = rk29_early_suspend, - .resume = rk29_early_resume, - .level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1, - }; -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(); - gpio_set_value(pdata->modem_power_en, GPIO_HIGH); - msleep(1000); - modem_poweron_off(1); - modem_status = 1; - - register_early_suspend(&mt6229_early_suspend); - mt6229_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL); - if(mt6229_data == NULL) - { - printk("failed to request mt6229_data\n"); - goto err2; - } - platform_set_drvdata(pdev, mt6229_data); - result = gpio_request(pdata->ap_wakeup_bp, "mt6229"); - if (result) { - printk("failed to request AP_BP_WAKEUP gpio\n"); - goto err1; - } - irq = gpio_to_irq(pdata->bp_wakeup_ap); - enable_irq_wake(irq); - if(irq < 0) - { - gpio_free(pdata->bp_wakeup_ap); - printk("failed to request bp_wakeup_ap\n"); - } - result = gpio_request(pdata->bp_wakeup_ap, "bp_wakeup_ap"); - if (result < 0) { - printk("%s: gpio_request(%d) failed\n", __func__, pdata->bp_wakeup_ap); - } - 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); - 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(&mt6229_misc); - if(result) - { - printk("misc_register err\n"); - } - return result; -err0: - cancel_work_sync(&mt6229_data->work); - gpio_free(pdata->bp_wakeup_ap); -err1: - gpio_free(pdata->ap_wakeup_bp); -err2: - kfree(mt6229_data); - return 0; -} - -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); - } - return 0; -} - -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) - pdata->io_deinit(); - cancel_work_sync(&mt6229_data->work); - gpio_free(pdata->modem_power_en); - gpio_free(pdata->bp_power); - gpio_free(pdata->bp_reset); - gpio_free(pdata->ap_wakeup_bp); - gpio_free(pdata->bp_wakeup_ap); - kfree(mt6229_data); -} - -static struct platform_driver mt6229_driver = { - .probe = mt6229_probe, - .shutdown = mt6229_shutdown, - .suspend = mt6229_suspend, - .resume = mt6229_resume, - .driver = { - .name = "mt6229", - .owner = THIS_MODULE, - }, -}; - -static int __init mt6229_init(void) -{ - //MODEMDBG("-------------%s\n",__FUNCTION__); - int ret ; - - - modem_class = class_create(THIS_MODULE, "rk291x_modem"); - ret = class_create_file(modem_class, &class_attr_modem_status); - if (ret) - { - printk("Fail to class rk291x_modem.\n"); - } - return platform_driver_register(&mt6229_driver); -} - -static void __exit mt6229_exit(void) -{ - //MODEMDBG("-------------%s\n",__FUNCTION__); - platform_driver_unregister(&mt6229_driver); - class_remove_file(modem_class, &class_attr_modem_status); -} - -module_init(mt6229_init); - -module_exit(mt6229_exit); diff --git a/drivers/misc/mu509.c b/drivers/misc/mu509.c deleted file mode 100755 index 6c951b069bd3..000000000000 --- a/drivers/misc/mu509.c +++ /dev/null @@ -1,398 +0,0 @@ -#include -#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 -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) -{ - struct rk29_mu509_data *pdata = pdev->dev.platform_data; - - gpio_set_value(pdata->ap_wakeup_bp, wake); - -} -extern void rk28_send_wakeup_key(void); - -static void do_wakeup(struct work_struct *work) -{ - if(suspend_int) - { - gpio_set_value(gpdata->ap_wakeup_bp, 0); - suspend_int = 0; - } - -} - -static DECLARE_DELAYED_WORK(wakeup_work, do_wakeup); -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); - } - return IRQ_HANDLED; -} -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); - gpio_set_value(pdata->bp_power, GPIO_LOW); - msleep(1000); - gpio_set_value(pdata->bp_power, GPIO_HIGH); - 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); - gpio_set_value(pdata->bp_power, GPIO_LOW); - } - return 0; -} -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: - 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); - msleep(1000); - gpio_set_value(pdata->bp_power, GPIO_HIGH); - 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; - } - return 0; -} - -static struct file_operations mu509_fops = { - .owner = THIS_MODULE, - .open = mu509_open, - .release = mu509_release, - .unlocked_ioctl = mu509_ioctl -}; - -static struct miscdevice mu509_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = MODEM_NAME, - .fops = &mu509_fops -}; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) -static ssize_t modem_status_read(struct class *cls, struct class_attribute *attr, char *_buf) -#else -static ssize_t modem_status_read(struct class *cls, char *_buf) -#endif -{ - - return sprintf(_buf, "%d\n", modem_status); - -} -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) -static ssize_t modem_status_write(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count) -#else -static ssize_t modem_status_write(struct class *cls, const char *_buf, size_t _count) -#endif -{ - int new_state = simple_strtoul(_buf, NULL, 16); - if(new_state == modem_status) return _count; - if (new_state == 1){ - printk("%s, c(%d), open modem \n", __FUNCTION__, new_state); - modem_poweron_off(1); - }else if(new_state == 0){ - printk("%s, c(%d), close modem \n", __FUNCTION__, new_state); - modem_poweron_off(0); - }else{ - printk("%s, invalid parameter \n", __FUNCTION__); - } - modem_status = new_state; - 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; - } -} - -static struct early_suspend mu509_early_suspend = { - .suspend = rk29_early_suspend, - .resume = rk29_early_resume, - .level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1, - }; -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) - pdata->io_init(); - gpio_set_value(pdata->modem_power_en, GPIO_HIGH); - msleep(1000); - modem_poweron_off(1); - modem_status = 1; - - register_early_suspend(&mu509_early_suspend); - mu509_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL); - if(mu509_data == NULL) - { - printk("failed to request mu509_data\n"); - goto err2; - } - platform_set_drvdata(pdev, mu509_data); - result = gpio_request(pdata->ap_wakeup_bp, "mu509"); - if (result) { - printk("failed to request AP_BP_WAKEUP gpio\n"); - goto err1; - } - irq = gpio_to_irq(pdata->bp_wakeup_ap); - enable_irq_wake(irq); - if(irq < 0) - { - gpio_free(pdata->bp_wakeup_ap); - printk("failed to request bp_wakeup_ap\n"); - } - result = gpio_request(pdata->bp_wakeup_ap, "bp_wakeup_ap"); - if (result < 0) { - printk("%s: gpio_request(%d) failed\n", __func__, pdata->bp_wakeup_ap); - } - 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); - 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(&mu509_misc); - if(result) - { - printk("misc_register err\n"); - } - return result; -err0: - cancel_work_sync(&mu509_data->work); - gpio_free(pdata->bp_wakeup_ap); -err1: - gpio_free(pdata->ap_wakeup_bp); -err2: - kfree(mu509_data); - return 0; -} - -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); -#endif - return 0; -} - -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 -#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); - } - return 0; -} - -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) - pdata->io_deinit(); - cancel_work_sync(&mu509_data->work); - gpio_free(pdata->modem_power_en); - gpio_free(pdata->bp_power); - gpio_free(pdata->bp_reset); - gpio_free(pdata->ap_wakeup_bp); - gpio_free(pdata->bp_wakeup_ap); - kfree(mu509_data); -} - -static struct platform_driver mu509_driver = { - .probe = mu509_probe, - .shutdown = mu509_shutdown, - .suspend = mu509_suspend, - .resume = mu509_resume, - .driver = { - .name = "mu509", - .owner = THIS_MODULE, - }, -}; - -static int __init mu509_init(void) -{ - //MODEMDBG("-------------%s\n",__FUNCTION__); - 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"); - } - return platform_driver_register(&mu509_driver); -} - -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); - -module_exit(mu509_exit); diff --git a/drivers/misc/mw100.c b/drivers/misc/mw100.c deleted file mode 100644 index 484cd977b47d..000000000000 --- a/drivers/misc/mw100.c +++ /dev/null @@ -1,283 +0,0 @@ -#include -#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 MW100IO 0XA1 -#define MW_IOCTL_RESET _IO(MW100IO,0X01) - -#define SLEEP 1 -#define READY 0 -#define MW100_RESET 0x01 -#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING -//#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING -struct rk29_mw100_data *gpdata = NULL; -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; -} - -static long mw100_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - struct rk29_mw100_data *pdata = gpdata; - 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); - - break; - default: - break; - } - return 0; -} - -static struct file_operations mw100_fops = { - .owner = THIS_MODULE, - .open = mw100_open, - .release = mw100_release, - .unlocked_ioctl = mw100_ioctl -}; - -static struct miscdevice mw100_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = "mw100", - .fops = &mw100_fops -}; - -static int mw100_probe(struct platform_device *pdev) -{ - struct rk29_mw100_data *pdata = gpdata = pdev->dev.platform_data; - struct modem_dev *mw100_data = NULL; - int result, irq = 0; - - gpio_request(pdata->bp_power,"bp_power"); - gpio_request(pdata->bp_reset,"bp_reset"); - gpio_request(pdata->bp_wakeup_ap,"bp_wakeup_ap"); - 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); - - gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); - gpio_direction_output(pdata->ap_wakeup_bp,GPIO_HIGH); - - gpio_set_value(pdata->bp_power, GPIO_HIGH); - gpio_direction_output(pdata->bp_power,GPIO_HIGH); - mdelay(120); - 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"); - goto err2; - } - platform_set_drvdata(pdev, mw100_data); - - gpio_direction_input(pdata->bp_wakeup_ap); - 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"); - } - - bp_wakeup_ap_irq = irq; - - 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(bp_wakeup_ap_irq); - - wake_lock_init(&bp_wakelock, WAKE_LOCK_SUSPEND, "bp_resume"); - - result = misc_register(&mw100_misc); - if(result){ - MODEMDBG("misc_register err\n"); - } - return result; -err0: - gpio_free(pdata->bp_wakeup_ap); -err2: - kfree(mw100_data); - return 0; -} - -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) { - printk("can't get pdata->bp_statue irq \n"); - } - else - { - printk("enable pdata->bp_statue irq_wake!! \n"); - bpstatus_irq_enable = true; - enable_irq_wake(irq); - } - return 0; -} - -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; - } - return 0; -} - -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); - gpio_free(pdata->bp_power); - gpio_free(pdata->bp_reset); - gpio_free(pdata->ap_wakeup_bp); - gpio_free(pdata->bp_wakeup_ap); - kfree(mw100_data); -} - -static struct platform_driver mw100_driver = { - .probe = mw100_probe, - .shutdown = mw100_shutdown, - .suspend = mw100_suspend, - .resume = mw100_resume, - .driver = { - .name = "mw100", - .owner = THIS_MODULE, - }, -}; - -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); -} - -module_init(mw100_init); - -module_exit(mw100_exit); 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"