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...)
36 struct rk2818_23d_data *gpdata = NULL;
39 int modem_poweron_off(int on_off)
41 struct rk2818_23d_data *pdata = gpdata;
45 printk("tdsc8800_poweron\n");
46 gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_HIGH:GPIO_LOW); // power on enable
51 printk("tdsc8800_poweroff\n");
52 gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_LOW:GPIO_HIGH);
56 static int tdsc8800_open(struct inode *inode, struct file *file)
59 device_init_wakeup(gpdata->dev, 1);
64 static int tdsc8800_release(struct inode *inode, struct file *file)
66 MODEMDBG("tdsc8800_release\n");
70 static long tdsc8800_ioctl(struct file *file, unsigned int a, unsigned long b)
75 static struct file_operations tdsc8800_fops = {
78 .release =tdsc8800_release,
79 .unlocked_ioctl = tdsc8800_ioctl
82 static struct miscdevice tdsc8800_misc = {
83 .minor = MISC_DYNAMIC_MINOR,
85 .fops = &tdsc8800_fops
88 static int tdsc8800_probe(struct platform_device *pdev)
90 struct rk2818_23d_data *pdata = gpdata = pdev->dev.platform_data;
91 struct modem_dev *tdsc8800_data = NULL;
94 MODEMDBG("tdsc8800_probe\n");
98 pdata->dev = &pdev->dev;
99 tdsc8800_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL);
100 if(NULL == tdsc8800_data)
102 printk("failed to request tdsc8800_data\n");
105 platform_set_drvdata(pdev, tdsc8800_data);
107 result = gpio_request(pdata->bp_power, "tdsc8800");
109 printk("failed to request BP_POW_EN gpio\n");
114 gpio_direction_output(pdata->bp_power, GPIO_LOW);
116 gpio_set_value(pdata->bp_power, pdata->bp_reset_active_low? GPIO_LOW:GPIO_HIGH);
117 result = misc_register(&tdsc8800_misc);
120 MODEMDBG("misc_register err\n");
122 MODEMDBG("mtk23d_probe ok\n");
126 gpio_free(pdata->bp_power);
128 kfree(tdsc8800_data);
132 int tdsc8800_suspend(struct platform_device *pdev)
137 int tdsc8800_resume(struct platform_device *pdev)
142 void tdsc8800_shutdown(struct platform_device *pdev, pm_message_t state)
144 struct rk2818_23d_data *pdata = pdev->dev.platform_data;
145 struct modem_dev *mt6223d_data = platform_get_drvdata(pdev);
147 MODEMDBG("%s \n", __FUNCTION__);
149 modem_poweron_off(0); // power down
150 gpio_free(pdata->bp_power);
154 static struct platform_driver tdsc8800_driver = {
155 .probe = tdsc8800_probe,
156 .shutdown = tdsc8800_shutdown,
157 .suspend = tdsc8800_suspend,
158 .resume = tdsc8800_resume,
161 .owner = THIS_MODULE,
165 static int __init tdsc8800_init(void)
167 int ret = platform_driver_register(&tdsc8800_driver);
168 MODEMDBG("tdsc8800_init ret=%d\n",ret);
172 static void __exit tdsc8800_exit(void)
174 MODEMDBG("tdsc8800_exit\n");
175 platform_driver_unregister(&tdsc8800_driver);
178 module_init(tdsc8800_init);
179 module_exit(tdsc8800_exit);