From 87db50252a2c1f96e84ca8f9f7216c7731c7dc27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=B5=B5=E5=AD=90=E5=88=9D?= Date: Thu, 25 Oct 2012 20:31:29 +0800 Subject: [PATCH] rk2928phonepad: sc6610:add resume and suspend --- arch/arm/mach-rk2928/board-rk2928-phonepad.c | 4 +- drivers/misc/3g_module/sc6610.c | 93 +++++++++----------- include/linux/mu509.h | 2 +- include/linux/sc6610.h | 27 ++++++ 4 files changed, 71 insertions(+), 55 deletions(-) create mode 100755 include/linux/sc6610.h diff --git a/arch/arm/mach-rk2928/board-rk2928-phonepad.c b/arch/arm/mach-rk2928/board-rk2928-phonepad.c index 381135b4e417..014cb7068680 100755 --- a/arch/arm/mach-rk2928/board-rk2928-phonepad.c +++ b/arch/arm/mach-rk2928/board-rk2928-phonepad.c @@ -59,7 +59,7 @@ #endif #if defined(CONFIG_SC6610) -#include +#include #endif #include "board-rk2928-phonepad-camera.c" @@ -728,7 +728,7 @@ static int sc6610_io_deinit(void) return 0; } -struct rk29_mu509_data rk29_sc6610_info = { +struct rk29_sc6610_data rk29_sc6610_info = { .io_init = sc6610_io_init, .io_deinit = sc6610_io_deinit, .bp_power = RK2928_PIN3_PC2,//RK29_PIN0_PB4, diff --git a/drivers/misc/3g_module/sc6610.c b/drivers/misc/3g_module/sc6610.c index ec84c0d1c4b6..25953b611089 100755 --- a/drivers/misc/3g_module/sc6610.c +++ b/drivers/misc/3g_module/sc6610.c @@ -19,7 +19,8 @@ #include #include #include -#include +#include + #include #include @@ -31,24 +32,24 @@ MODULE_LICENSE("GPL"); #else #define MODEMDBG(fmt,argss...) #endif -#define MODEM_RESET 2 +#define MODEM_RESET 2 #define MODEM_ON 1 #define MODEM_OFF 0 -struct rk29_mu509_data *s_gpdata = NULL; +struct rk29_sc6610_data *s_gpdata = NULL; + struct class *modem_class = NULL; static int do_wakeup_irq = 0; static struct wake_lock modem_wakelock; -#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_FALLING +//#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_FALLING +#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING int modem_poweron_off(int on_off) { - struct rk29_mu509_data *pdata = s_gpdata; + struct rk29_sc6610_data *pdata = s_gpdata; if(on_off){ - MODEMDBG("------------modem_poweron usb\n"); gpio_set_value(pdata->bp_power, GPIO_HIGH); }else{ - MODEMDBG("------------modem_poweroff usb\n"); - //gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_set_value(pdata->bp_power, GPIO_LOW); } return 0; } @@ -59,31 +60,23 @@ static irqreturn_t detect_irq_handler(int irq, void *dev_id) { 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; } static int sc6610_open(struct inode *inode, struct file *file) { - //MODEMDBG("------sc6610_open-------%s\n",__FUNCTION__); - struct rk29_mu509_data *pdata = s_gpdata; - //device_init_wakeup(pdata->dev, 1); - modem_poweron_off(MODEM_ON); return 0; } static int sc6610_release(struct inode *inode, struct file *file) { - //MODEMDBG("-------------%s\n",__FUNCTION__); - modem_poweron_off(MODEM_OFF); return 0; } static long sc6610_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct rk29_mu509_data *pdata = s_gpdata; + struct rk29_sc6610_data *pdata = s_gpdata; switch(cmd) { case MODEM_RESET: @@ -118,42 +111,38 @@ static struct miscdevice sc6610_misc = { static int sc6610_probe(struct platform_device *pdev) { - struct rk29_mu509_data *pdata = s_gpdata = pdev->dev.platform_data; + struct rk29_sc6610_data *pdata = s_gpdata = pdev->dev.platform_data; struct modem_dev *sc6610_data = NULL; int result; int irq; pdata->dev = &pdev->dev; - printk("%s, sc6610 new \n", __FUNCTION__); - //rk30_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_GPIO1C1); if(pdata->io_init) pdata->io_init(); - result = gpio_request(pdata->ap_wakeup_bp, "sc6610"); + result = gpio_request(pdata->ap_wakeup_bp, "ap_wakeup_bp"); if (result) { - printk("failed to request AP_BP_WAKEUP gpio\n"); - goto err; + printk("failed to request ap_wakeup_bp gpio\n"); + goto err0; } - result = gpio_request(pdata->bp_power, "sc6610"); + result = gpio_request(pdata->bp_power, "bp_power"); if (result) { printk("failed to request bp_power gpio\n"); goto err1; } - result = gpio_request(pdata->bp_wakeup_ap, "sc6610"); + result = gpio_request(pdata->bp_wakeup_ap, "bp_wakeup_ap"); if (result) { - printk("failed to request modem_power_en gpio\n"); + printk("failed to request bp_wakeup_ap gpio\n"); goto err2; } - - - gpio_set_value(pdata->ap_wakeup_bp, 0); + + gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); irq = gpio_to_irq(pdata->bp_wakeup_ap); 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 err4; + goto err2; } enable_irq_wake(irq); wake_lock_init(&modem_wakelock, WAKE_LOCK_SUSPEND, "bp_wakeup_ap"); @@ -161,7 +150,7 @@ static int sc6610_probe(struct platform_device *pdev) if(sc6610_data == NULL) { printk("failed to request sc6610_data\n"); - goto err; + goto err3; } platform_set_drvdata(pdev, sc6610_data); result = misc_register(&sc6610_misc); @@ -170,45 +159,45 @@ static int sc6610_probe(struct platform_device *pdev) printk("misc_register err\n"); } modem_poweron_off(MODEM_ON); - printk("<----sc6610 prope ok----->\n"); return result; -err4: - gpio_free(pdata->bp_wakeup_ap); -err2: - gpio_free(pdata->bp_power); -err1: +err0: gpio_free(pdata->ap_wakeup_bp); -err: +err1: + gpio_free(pdata->bp_power); +err2: + gpio_free(pdata->bp_wakeup_ap); +err3: kfree(sc6610_data); return 0; } -int c6310_suspend(struct platform_device *pdev, pm_message_t state) +int c6610_suspend(struct platform_device *pdev, pm_message_t state) { - //struct rk29_mu509_data *pdata = pdev->dev.platform_data; + struct rk29_sc6610_data *pdata = s_gpdata = pdev->dev.platform_data; + pdata->dev = &pdev->dev; do_wakeup_irq = 1; - //gpio_set_value(pdata->ap_statue, GPIO_HIGH); + gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); return 0; } -int c6310_resume(struct platform_device *pdev) +int c6610_resume(struct platform_device *pdev) { - //struct rk29_mu509_data *pdata = pdev->dev.platform_data; - //gpio_set_value(pdata->ap_statue, GPIO_LOW); + struct rk29_sc6610_data *pdata = s_gpdata = pdev->dev.platform_data; + pdata->dev = &pdev->dev; + gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); return 0; } -void c6310_shutdown(struct platform_device *pdev) +void c6610_shutdown(struct platform_device *pdev) { - struct rk29_mu509_data *pdata = pdev->dev.platform_data; + struct rk29_sc6610_data *pdata = pdev->dev.platform_data; struct modem_dev *sc6610_data = platform_get_drvdata(pdev); - modem_poweron_off(0); + modem_poweron_off(MODEM_OFF); if(pdata->io_deinit) pdata->io_deinit(); cancel_work_sync(&sc6610_data->work); gpio_free(pdata->bp_power); - gpio_free(pdata->bp_reset); gpio_free(pdata->ap_wakeup_bp); gpio_free(pdata->bp_wakeup_ap); kfree(sc6610_data); @@ -216,9 +205,9 @@ void c6310_shutdown(struct platform_device *pdev) static struct platform_driver sc6610_driver = { .probe = sc6610_probe, - .shutdown = c6310_shutdown, - .suspend = c6310_suspend, - .resume = c6310_resume, + .shutdown = c6610_shutdown, + .suspend = c6610_suspend, + .resume = c6610_resume, .driver = { .name = "SC6610", .owner = THIS_MODULE, diff --git a/include/linux/mu509.h b/include/linux/mu509.h index 3d40aa26438d..65f237f98c81 100755 --- a/include/linux/mu509.h +++ b/include/linux/mu509.h @@ -24,4 +24,4 @@ struct rk29_mu509_data { unsigned int modem_assert; }; -#define MODEM_NAME "SC6610" +#define MODEM_NAME "mu509" diff --git a/include/linux/sc6610.h b/include/linux/sc6610.h new file mode 100755 index 000000000000..66414dc203a6 --- /dev/null +++ b/include/linux/sc6610.h @@ -0,0 +1,27 @@ +#include +#include +#include + +struct modem_dev +{ + const char *name; + struct miscdevice miscdev; + struct work_struct work; +}; + +/* 耳机数据结构ä½?*/ +struct rk29_sc6610_data { + struct device *dev; + int (*io_init)(void); + int (*io_deinit)(void); + 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; + unsigned int modem_power_en; + unsigned int modem_assert; +}; + +#define MODEM_NAME "SC6610" -- 2.34.1