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");
71 static long tdsc8800_ioctl(struct file *file, unsigned int a, unsigned long b)
80 MODEMDBG("cmd error !!!\n");
86 static struct file_operations tdsc8800_fops = {
89 .release =tdsc8800_release,
90 .unlocked_ioctl = tdsc8800_ioctl
93 static struct miscdevice tdsc8800_misc = {
94 .minor = MISC_DYNAMIC_MINOR,
96 .fops = &tdsc8800_fops
99 static int tdsc8800_probe(struct platform_device *pdev)
101 struct rk2818_23d_data *pdata = gpdata = pdev->dev.platform_data;
102 struct modem_dev *tdsc8800_data = NULL;
105 MODEMDBG("tdsc8800_probe\n");
109 pdata->dev = &pdev->dev;
110 tdsc8800_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL);
111 if(NULL == tdsc8800_data)
113 printk("failed to request tdsc8800_data\n");
116 platform_set_drvdata(pdev, tdsc8800_data);
118 result = gpio_request(pdata->bp_power, "tdsc8800");
120 printk("failed to request BP_POW_EN gpio\n");
125 gpio_direction_output(pdata->bp_power, GPIO_LOW);
127 gpio_set_value(pdata->bp_power, pdata->bp_reset_active_low? GPIO_LOW:GPIO_HIGH);
128 result = misc_register(&tdsc8800_misc);
131 MODEMDBG("misc_register err\n");
133 MODEMDBG("mtk23d_probe ok\n");
137 gpio_free(pdata->bp_power);
139 kfree(tdsc8800_data);
143 int tdsc8800_suspend(struct platform_device *pdev)
148 int tdsc8800_resume(struct platform_device *pdev)
153 void tdsc8800_shutdown(struct platform_device *pdev, pm_message_t state)
155 struct rk2818_23d_data *pdata = pdev->dev.platform_data;
156 struct modem_dev *mt6223d_data = platform_get_drvdata(pdev);
158 MODEMDBG("%s \n", __FUNCTION__);
160 modem_poweron_off(0); // power down
161 gpio_free(pdata->bp_power);
165 static struct platform_driver tdsc8800_driver = {
166 .probe = tdsc8800_probe,
167 .shutdown = tdsc8800_shutdown,
168 .suspend = tdsc8800_suspend,
169 .resume = tdsc8800_resume,
172 .owner = THIS_MODULE,
176 static int __init tdsc8800_init(void)
178 int ret = platform_driver_register(&tdsc8800_driver);
179 MODEMDBG("tdsc8800_init ret=%d\n",ret);
183 static void __exit tdsc8800_exit(void)
185 MODEMDBG("tdsc8800_exit\n");
186 platform_driver_unregister(&tdsc8800_driver);
189 module_init(tdsc8800_init);
190 module_exit(tdsc8800_exit);