add u5501 modem
authorllj <llj@rock-chips.com>
Mon, 3 Jun 2013 06:49:36 +0000 (14:49 +0800)
committerllj <llj@rock-chips.com>
Mon, 3 Jun 2013 06:49:36 +0000 (14:49 +0800)
drivers/misc/bp/chips/Kconfig
drivers/misc/bp/chips/Makefile
drivers/misc/bp/chips/u5501.c [new file with mode: 0755]

index ba45f960ebefffaccd1c45c6316821ca5a6f7c0e..bf2367482d4e2c1cbcd8a607b9f536ee54166b2a 100755 (executable)
@@ -22,3 +22,6 @@ bool "modem sew290"
 config BP_AUTO_U7501\r
 bool "modem u7501"\r
         default n\r
+config BP_AUTO_U5501\r
+bool "modem u5501"\r
+        default n
\ No newline at end of file
index 1015c0bd7be90a8d648c18f60624b205765226dc..56bc1b54c3aff75e42780481e9bda8849ae37665 100755 (executable)
@@ -9,3 +9,4 @@ obj-$(CONFIG_BP_AUTO)                           += c66a.o
 obj-$(CONFIG_BP_AUTO)                           += sew290.o\r
 obj-$(CONFIG_BP_AUTO)                           += u7501.o\r
 obj-$(CONFIG_BP_AUTO)                           += a85xx.o\r
+obj-$(CONFIG_BP_AUTO)                           += u5501.o\r
diff --git a/drivers/misc/bp/chips/u5501.c b/drivers/misc/bp/chips/u5501.c
new file mode 100755 (executable)
index 0000000..c5fa41a
--- /dev/null
@@ -0,0 +1,349 @@
+/* drivers/misc/bp/chips/u5501.c\r
+ *\r
+ * Copyright (C) 2012-2015 ROCKCHIP.\r
+ * Author: luowei <lw@rock-chips.com>\r
+ *\r
+ * This software is licensed under the terms of the GNU General Public\r
+ * License version 2, as published by the Free Software Foundation, and\r
+ * may be copied, distributed, and modified under those terms.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ */\r
+#include <linux/module.h>\r
+#include <linux/kernel.h>\r
+#include <linux/i2c.h>\r
+#include <linux/irq.h>\r
+#include <linux/gpio.h>\r
+#include <linux/input.h>\r
+#include <linux/platform_device.h>\r
+#include <linux/fs.h>\r
+#include <linux/uaccess.h>\r
+#include <linux/miscdevice.h>\r
+#include <linux/circ_buf.h>\r
+#include <linux/interrupt.h>\r
+#include <linux/miscdevice.h>\r
+#include <mach/iomux.h>\r
+#include <mach/gpio.h>\r
+#include <asm/gpio.h>\r
+#include <linux/delay.h>\r
+#include <linux/poll.h>\r
+#include <linux/wait.h>\r
+#include <linux/wakelock.h>\r
+#include <linux/workqueue.h>\r
+#include <linux/slab.h>\r
+#include <linux/earlysuspend.h>\r
+\r
+#include <linux/bp-auto.h>\r
+        \r
+\r
+#if 0\r
+#define DBG(x...)  printk(x)\r
+#else\r
+#define DBG(x...)\r
+#endif\r
+\r
+\r
+/****************operate according to bp chip:start************/\r
+static int bp_active(struct bp_private_data *bp, int enable)\r
+{      \r
+       int result = 0;\r
+       if(enable)\r
+       {\r
+//             gpio_direction_output(bp->ops->bp_power, GPIO_HIGH);\r
+//             msleep(500);\r
+               gpio_set_value(bp->ops->bp_reset, GPIO_HIGH);\r
+               msleep(100);\r
+               gpio_set_value(bp->ops->bp_reset, GPIO_LOW);\r
+               gpio_set_value(bp->ops->bp_en, GPIO_LOW);\r
+               msleep(1000);\r
+               gpio_set_value(bp->ops->bp_en, GPIO_HIGH);\r
+               msleep(700);\r
+               gpio_set_value(bp->ops->bp_en, GPIO_LOW);\r
+               gpio_set_value(bp->ops->ap_wakeup_bp, GPIO_LOW);\r
+       }\r
+       else\r
+       {\r
+//             gpio_direction_output(bp->ops->bp_power, GPIO_LOW);\r
+               gpio_set_value(bp->ops->bp_en, GPIO_LOW);\r
+               gpio_set_value(bp->ops->bp_en, GPIO_HIGH);\r
+               msleep(2500);\r
+               gpio_set_value(bp->ops->bp_en, GPIO_LOW);\r
+       }\r
+       \r
+       return result;\r
+}\r
+\r
+static int ap_wake_bp(struct bp_private_data *bp, int wake)\r
+{\r
+       int result = 0;\r
+       \r
+       gpio_set_value(bp->ops->ap_wakeup_bp, wake);  \r
+       \r
+       return result;\r
+\r
+}\r
+\r
+static void  ap_wake_bp_work(struct work_struct *work)\r
+{\r
+       struct delayed_work *wakeup_work = container_of(work, struct delayed_work, work);\r
+       struct bp_private_data *bp = container_of(wakeup_work, struct bp_private_data, wakeup_work);\r
+\r
+       if(bp->suspend_status)\r
+       {\r
+               if(bp->ops->ap_wake_bp)\r
+               bp->ops->ap_wake_bp(bp, 0);\r
+               bp->suspend_status = 0;\r
+       }\r
+       else    \r
+       {\r
+               if(bp->ops->ap_wake_bp)\r
+               bp->ops->ap_wake_bp(bp, 1);\r
+       }\r
+}\r
+\r
+\r
+static int bp_init(struct bp_private_data *bp)\r
+{\r
+       int result = 0;\r
+       gpio_direction_output(bp->ops->bp_power, GPIO_HIGH);\r
+       gpio_set_value(bp->ops->bp_power, GPIO_HIGH);\r
+       msleep(500);\r
+       //if(bp->ops->active)\r
+       //      bp->ops->active(bp, 1);\r
+       gpio_direction_input(bp->ops->bp_wakeup_ap);\r
+       gpio_pull_updown(bp->ops->bp_wakeup_ap, 1);     \r
+       gpio_direction_output(bp->ops->bp_reset, GPIO_LOW);\r
+       gpio_direction_output(bp->ops->bp_en, GPIO_LOW);\r
+       gpio_direction_output(bp->ops->ap_wakeup_bp, GPIO_LOW);\r
+       INIT_DELAYED_WORK(&bp->wakeup_work, ap_wake_bp_work);\r
+       return result;\r
+}\r
+\r
+static int bp_reset(struct bp_private_data *bp)\r
+{\r
+//     gpio_direction_output(bp->ops->bp_power, GPIO_HIGH);\r
+//     msleep(500);\r
+       gpio_set_value(bp->ops->bp_reset, GPIO_HIGH);\r
+       msleep(100);\r
+       gpio_set_value(bp->ops->bp_reset, GPIO_LOW);\r
+       gpio_set_value(bp->ops->bp_en, GPIO_LOW);\r
+       msleep(1000);\r
+       gpio_set_value(bp->ops->bp_en, GPIO_HIGH);\r
+       msleep(700);\r
+       gpio_set_value(bp->ops->bp_en, GPIO_LOW);\r
+       gpio_set_value(bp->ops->ap_wakeup_bp, GPIO_LOW);\r
+\r
+       return 0;\r
+}\r
+\r
+static int bp_wake_ap(struct bp_private_data *bp)\r
+{\r
+       int result = 0;\r
+       \r
+       bp->suspend_status = 0;\r
+       wake_lock_timeout(&bp->bp_wakelock, 10 * HZ);\r
+       \r
+       return result;\r
+}\r
+\r
+\r
+static int bp_shutdown(struct bp_private_data *bp)\r
+{\r
+       int result = 0;\r
+       \r
+       if(bp->ops->active)\r
+               bp->ops->active(bp, 0);\r
+       gpio_set_value(bp->ops->bp_power, GPIO_LOW);\r
+       cancel_delayed_work_sync(&bp->wakeup_work);     \r
+\r
+       return result;\r
+}\r
+\r
+\r
+\r
+static int bp_suspend(struct bp_private_data *bp)\r
+{      \r
+       int result = 0;\r
+       printk("<-----u5501 bp_suspend-------->\n");\r
+       #if defined(CONFIG_ARCH_RK29)\r
+               rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_GPIO1C1);\r
+       #elif defined(CONFIG_ARCH_RK30)\r
+               rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0TXD_NAME, GPIO1A_GPIO1A7);\r
+       #endif\r
+       \r
+       if(!bp->suspend_status)\r
+       {\r
+               bp->suspend_status = 1; \r
+               gpio_set_value(bp->ops->ap_wakeup_bp, GPIO_HIGH);       \r
+       }\r
+       #if defined(CONFIG_ARCH_RK2928)\r
+       rk29_mux_api_set(GPIO1B1_SPI_TXD_UART1_SOUT_NAME, GPIO1B_GPIO1B1);\r
+       gpio_set_value(RK2928_PIN1_PB1, GPIO_LOW);\r
+       #elif defined(CONFIG_ARCH_RK30)\r
+       rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0CLK_NAME, GPIO1A_GPIO1A5);\r
+       gpio_set_value(RK30_PIN1_PA5, GPIO_LOW);\r
+       #endif\r
+       return result;\r
+}\r
+\r
+\r
+\r
+\r
+static int bp_resume(struct bp_private_data *bp)\r
+{      \r
+       #if defined(CONFIG_ARCH_RK29)\r
+               rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_UART0_RTS_N);\r
+       #elif defined(CONFIG_ARCH_RK30)\r
+               rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0TXD_NAME, GPIO1A_UART1_RTS_N);\r
+       #endif\r
+       \r
+       #if defined(CONFIG_ARCH_RK2928)\r
+       rk29_mux_api_set(GPIO1B1_SPI_TXD_UART1_SOUT_NAME, GPIO1B_UART1_SOUT);\r
+       #elif defined(CONFIG_ARCH_RK30)\r
+       rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0CLK_NAME, GPIO1A_UART1_SOUT);\r
+       #endif\r
+       //bp->suspend_status = 0;       \r
+       //gpio_set_value(bp->ops->ap_wakeup_bp, GPIO_LOW);      \r
+       schedule_delayed_work(&bp->wakeup_work, 4*HZ);\r
+       \r
+       \r
+       return 0;\r
+}\r
+\r
+\r
+struct bp_operate bp_u5501_ops = {\r
+#if defined(CONFIG_ARCH_RK2928)\r
+       .name                   = "u5501",\r
+       .bp_id                  = BP_ID_U5501,\r
+       .bp_bus                 = BP_BUS_TYPE_USB_UART,         \r
+       .bp_pid                 = 0,    \r
+       .bp_vid                 = 0,    \r
+       .bp_power               = RK2928_PIN3_PC2,      // 3g_power\r
+       .bp_en                  = BP_UNKNOW_DATA,       // 3g_en\r
+       .bp_reset                       = RK2928_PIN1_PA3,\r
+       .ap_ready               = BP_UNKNOW_DATA,       //\r
+       .bp_ready               = BP_UNKNOW_DATA,\r
+       .ap_wakeup_bp           = RK2928_PIN3_PC4,\r
+       .bp_wakeup_ap           = RK2928_PIN3_PC3,      //\r
+       .bp_uart_en             = BP_UNKNOW_DATA,       //EINT9\r
+       .bp_usb_en              = BP_UNKNOW_DATA,       //W_disable\r
+       .trig                   = IRQF_TRIGGER_FALLING,\r
+\r
+       .active                 = bp_active,\r
+       .init                   = bp_init,\r
+       .reset                  = bp_reset,\r
+       .ap_wake_bp             = ap_wake_bp,\r
+       .bp_wake_ap             = bp_wake_ap,\r
+       .shutdown               = bp_shutdown,\r
+       .read_status            = NULL,\r
+       .write_status           = NULL,\r
+       .suspend                = bp_suspend,\r
+       .resume                 = bp_resume,\r
+       .misc_name              = NULL,\r
+       .private_miscdev        = NULL,\r
+#elif defined(CONFIG_ARCH_RK30)\r
+       .name                   = "u5501",\r
+       .bp_id                  = BP_ID_U5501,\r
+       .bp_bus                 = BP_BUS_TYPE_USB_UART,         \r
+       .bp_pid                 = 0,    \r
+       .bp_vid                 = 0,    \r
+       .bp_power               = BP_UNKNOW_DATA,//RK2928_PIN3_PC2,     // 3g_power\r
+       .bp_en                  = BP_UNKNOW_DATA,       // 3g_en\r
+       .bp_reset                       = BP_UNKNOW_DATA,//RK2928_PIN1_PA3,\r
+       .ap_ready               = BP_UNKNOW_DATA,       //\r
+       .bp_ready               = BP_UNKNOW_DATA,\r
+       .ap_wakeup_bp           = BP_UNKNOW_DATA,//RK2928_PIN3_PC4,\r
+       .bp_wakeup_ap           = BP_UNKNOW_DATA,//RK2928_PIN3_PC3,     //\r
+       .bp_uart_en             = BP_UNKNOW_DATA,       //EINT9\r
+       .bp_usb_en              = BP_UNKNOW_DATA,       //W_disable\r
+       .trig                   = IRQF_TRIGGER_FALLING,\r
+\r
+       .active                 = bp_active,\r
+       .init                   = bp_init,\r
+       .reset                  = bp_reset,\r
+       .ap_wake_bp             = ap_wake_bp,\r
+       .bp_wake_ap             = bp_wake_ap,\r
+       .shutdown               = bp_shutdown,\r
+       .read_status            = NULL,\r
+       .write_status           = NULL,\r
+       .suspend                = bp_suspend,\r
+       .resume                 = bp_resume,\r
+       .misc_name              = NULL,\r
+       .private_miscdev        = NULL,\r
+#else\r
+       .name                   = "u5501",\r
+       .bp_id                  = BP_ID_U5501,\r
+       .bp_bus                 = BP_BUS_TYPE_USB_UART,         \r
+       .bp_pid                 = 0,    \r
+       .bp_vid                 = 0,    \r
+       .bp_power               = BP_UNKNOW_DATA,//RK2928_PIN3_PC2,     // 3g_power\r
+       .bp_en                  = BP_UNKNOW_DATA,       // 3g_en\r
+       .bp_reset                       = BP_UNKNOW_DATA,//RK2928_PIN1_PA3,\r
+       .ap_ready               = BP_UNKNOW_DATA,       //\r
+       .bp_ready               = BP_UNKNOW_DATA,\r
+       .ap_wakeup_bp           = BP_UNKNOW_DATA,//RK2928_PIN3_PC4,\r
+       .bp_wakeup_ap           = BP_UNKNOW_DATA,//RK2928_PIN3_PC3,     //\r
+       .bp_uart_en             = BP_UNKNOW_DATA,       //EINT9\r
+       .bp_usb_en              = BP_UNKNOW_DATA,       //W_disable\r
+       .trig                   = IRQF_TRIGGER_FALLING,\r
+\r
+       .active                 = bp_active,\r
+       .init                   = bp_init,\r
+       .reset                  = bp_reset,\r
+       .ap_wake_bp             = ap_wake_bp,\r
+       .bp_wake_ap             = bp_wake_ap,\r
+       .shutdown               = bp_shutdown,\r
+       .read_status            = NULL,\r
+       .write_status           = NULL,\r
+       .suspend                = bp_suspend,\r
+       .resume                 = bp_resume,\r
+       .misc_name              = NULL,\r
+       .private_miscdev        = NULL,\r
+#endif\r
+};\r
+\r
+/****************operate according to bp chip:end************/\r
+\r
+//function name should not be changed\r
+static struct bp_operate *bp_get_ops(void)\r
+{\r
+       return &bp_u5501_ops;\r
+}\r
+\r
+static int __init bp_u5501_init(void)\r
+{\r
+       struct bp_operate *ops = bp_get_ops();\r
+       int result = 0;\r
+       result = bp_register_slave(NULL, NULL, bp_get_ops);\r
+       if(result)\r
+       {       \r
+               return result;\r
+       }\r
+       \r
+       if(ops->private_miscdev)\r
+       {\r
+               result = misc_register(ops->private_miscdev);\r
+               if (result < 0) {\r
+                       printk("%s:misc_register err\n",__func__);\r
+                       return result;\r
+               }\r
+       }\r
+       \r
+       DBG("%s\n",__func__);\r
+       return result;\r
+}\r
+\r
+static void __exit bp_u5501_exit(void)\r
+{\r
+       //struct bp_operate *ops = bp_get_ops();\r
+       bp_unregister_slave(NULL, NULL, bp_get_ops);\r
+}\r
+\r
+\r
+subsys_initcall(bp_u5501_init);\r
+module_exit(bp_u5501_exit);\r
+\r