rk2928phonepad: sc6610:add resume and suspend
author赵子初 <zzc@rock-chips.com>
Thu, 25 Oct 2012 12:31:29 +0000 (20:31 +0800)
committer赵子初 <zzc@rock-chips.com>
Thu, 25 Oct 2012 12:31:29 +0000 (20:31 +0800)
arch/arm/mach-rk2928/board-rk2928-phonepad.c
drivers/misc/3g_module/sc6610.c
include/linux/mu509.h
include/linux/sc6610.h [new file with mode: 0755]

index 381135b4e417bdd4c72e4029658957fc9e98ac65..014cb7068680a2ad29533ae0a2432f43f4b66807 100755 (executable)
@@ -59,7 +59,7 @@
 #endif
 
 #if defined(CONFIG_SC6610)
-#include <linux/mu509.h>
+#include <linux/sc6610.h>
 #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,
index ec84c0d1c4b6bff979426b4598cf2f3b12f2cb13..25953b611089e62dd46db29f815c5b3081f762aa 100755 (executable)
@@ -19,7 +19,8 @@
 #include <linux/wait.h>
 #include <linux/wakelock.h>
 #include <linux/workqueue.h>
-#include <linux/mu509.h>
+#include <linux/sc6610.h>
+
 #include <linux/slab.h>
 #include <linux/earlysuspend.h>
 
@@ -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,
index 3d40aa26438d725dd4bd48e859bad2c50ba49ddb..65f237f98c81a9823e80f684f05111b725fdb6d1 100755 (executable)
@@ -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 (executable)
index 0000000..66414dc
--- /dev/null
@@ -0,0 +1,27 @@
+#include <linux/types.h>\r
+#include <linux/ioctl.h>\r
+#include <linux/miscdevice.h>\r
+\r
+struct modem_dev\r
+{\r
+       const char *name;\r
+       struct miscdevice miscdev;\r
+       struct work_struct work;\r
+};\r
+\r
+/* è\80³æ\9cºæ\95°æ\8d®ç»\93æ\9e\84ä½?*/\r
+struct rk29_sc6610_data {\r
+       struct device *dev;\r
+       int (*io_init)(void);\r
+       int (*io_deinit)(void);\r
+       unsigned int bp_power;\r
+       unsigned int bp_power_active_low;\r
+       unsigned int bp_reset;\r
+       unsigned int bp_reset_active_low;\r
+       unsigned int bp_wakeup_ap;\r
+       unsigned int ap_wakeup_bp;\r
+       unsigned int modem_power_en;\r
+       unsigned int modem_assert;\r
+};\r
+\r
+#define MODEM_NAME "SC6610"\r