1 #include <linux/module.h>
2 #include <linux/kernel.h>
5 #include <linux/gpio.h>
6 #include <linux/input.h>
7 #include <linux/platform_device.h>
9 #include <linux/uaccess.h>
10 #include <linux/miscdevice.h>
11 #include <linux/circ_buf.h>
12 #include <linux/interrupt.h>
13 #include <linux/miscdevice.h>
14 #include <mach/iomux.h>
15 #include <mach/gpio.h>
16 #include <linux/delay.h>
17 #include <linux/poll.h>
18 #include <linux/wait.h>
19 #include <linux/slab.h>
21 #include <linux/workqueue.h>
22 #include <linux/mtk23d.h>
25 MODULE_LICENSE("GPL");
29 #define MODEMDBG(x...) printk(x)
31 #define MODEMDBG(fmt,argss...)
37 struct rk2818_23d_data *gpdata = NULL;
40 int modem_poweron_off(int on_off)
42 struct rk2818_23d_data *pdata = gpdata;
46 printk("tdsc8800_poweron\n");
47 gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_HIGH:GPIO_LOW); // power on enable
52 printk("tdsc8800_poweroff\n");
53 gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_LOW:GPIO_HIGH);
57 static int tdsc8800_open(struct inode *inode, struct file *file)
60 device_init_wakeup(gpdata->dev, 1);
65 static int tdsc8800_release(struct inode *inode, struct file *file)
67 MODEMDBG("tdsc8800_release\n");
72 static long tdsc8800_ioctl(struct file *file, unsigned int a, unsigned long b)
81 MODEMDBG("cmd error !!!\n");
87 static struct file_operations tdsc8800_fops = {
90 .release =tdsc8800_release,
91 .unlocked_ioctl = tdsc8800_ioctl
94 static struct miscdevice tdsc8800_misc = {
95 .minor = MISC_DYNAMIC_MINOR,
97 .fops = &tdsc8800_fops
100 static int tdsc8800_probe(struct platform_device *pdev)
102 struct rk2818_23d_data *pdata = gpdata = pdev->dev.platform_data;
103 struct modem_dev *tdsc8800_data = NULL;
106 MODEMDBG("tdsc8800_probe\n");
110 pdata->dev = &pdev->dev;
111 tdsc8800_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL);
112 if(NULL == tdsc8800_data)
114 printk("failed to request tdsc8800_data\n");
117 platform_set_drvdata(pdev, tdsc8800_data);
119 result = gpio_request(pdata->bp_power, "tdsc8800");
121 printk("failed to request BP_POW_EN gpio\n");
126 gpio_direction_output(pdata->bp_power, GPIO_LOW);
128 gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_LOW:GPIO_HIGH);
129 result = misc_register(&tdsc8800_misc);
132 MODEMDBG("misc_register err\n");
134 MODEMDBG("mtk23d_probe ok\n");
138 gpio_free(pdata->bp_power);
140 kfree(tdsc8800_data);
144 int tdsc8800_suspend(struct platform_device *pdev)
149 int tdsc8800_resume(struct platform_device *pdev)
154 void tdsc8800_shutdown(struct platform_device *pdev, pm_message_t state)
156 struct rk2818_23d_data *pdata = pdev->dev.platform_data;
157 struct modem_dev *mt6223d_data = platform_get_drvdata(pdev);
159 MODEMDBG("%s \n", __FUNCTION__);
161 modem_poweron_off(0); // power down
162 gpio_free(pdata->bp_power);
166 static struct platform_driver tdsc8800_driver = {
167 .probe = tdsc8800_probe,
168 .shutdown = tdsc8800_shutdown,
169 .suspend = tdsc8800_suspend,
170 .resume = tdsc8800_resume,
173 .owner = THIS_MODULE,
177 static int __init tdsc8800_init(void)
179 int ret = platform_driver_register(&tdsc8800_driver);
180 MODEMDBG("tdsc8800_init ret=%d\n",ret);
184 static void __exit tdsc8800_exit(void)
186 MODEMDBG("tdsc8800_exit\n");
187 platform_driver_unregister(&tdsc8800_driver);
190 module_init(tdsc8800_init);
191 module_exit(tdsc8800_exit);