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...)
34 static bool wakelock_inited;
37 struct rk2818_23d_data *gpdata = NULL;
40 int modem_poweron_off(int on_off)
42 struct rk2818_23d_data *pdata = gpdata;
43 int result, error = 0, irq = 0;
47 printk("tdsc8800_poweron\n");
48 gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_HIGH:GPIO_LOW); // power on enable
53 printk("tdsc8800_poweroff\n");
54 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)
59 struct rk2818_23d_data *pdata = gpdata;
60 //struct rk2818_23d_data *pdata = gpdata = pdev->dev.platform_data;
61 struct platform_data *pdev = container_of(pdata, struct device, platform_data);
63 MODEMDBG("tdsc8800_open\n");
67 device_init_wakeup(&pdev, 1);
72 static int tdsc8800_release(struct inode *inode, struct file *file)
74 MODEMDBG("tdsc8800_release\n");
78 static int tdsc8800_ioctl(struct inode *inode,struct file *file, unsigned int cmd, unsigned long arg)
83 static struct file_operations tdsc8800_fops = {
86 .release =tdsc8800_release,
87 .unlocked_ioctl = tdsc8800_ioctl
90 static struct miscdevice tdsc8800_misc = {
91 .minor = MISC_DYNAMIC_MINOR,
93 .fops = &tdsc8800_fops
96 static int tdsc8800_probe(struct platform_device *pdev)
98 struct rk2818_23d_data *pdata = gpdata = pdev->dev.platform_data;
99 struct modem_dev *tdsc8800_data = NULL;
100 int result, error = 0, irq = 0;
102 MODEMDBG("tdsc8800_probe\n");
106 tdsc8800_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL);
107 if(NULL == tdsc8800_data)
109 printk("failed to request tdsc8800_data\n");
112 platform_set_drvdata(pdev, tdsc8800_data);
114 result = gpio_request(pdata->bp_power, "tdsc8800");
116 printk("failed to request BP_POW_EN gpio\n");
121 gpio_direction_output(pdata->bp_power, GPIO_LOW);
123 gpio_set_value(pdata->bp_power, pdata->bp_reset_active_low? GPIO_LOW:GPIO_HIGH);
124 result = misc_register(&tdsc8800_misc);
127 MODEMDBG("misc_register err\n");
129 MODEMDBG("mtk23d_probe ok\n");
133 gpio_free(pdata->bp_power);
135 kfree(tdsc8800_data);
140 int tdsc8800_suspend(struct platform_device *pdev)
145 int tdsc8800_resume(struct platform_device *pdev)
150 void tdsc8800_shutdown(struct platform_device *pdev, pm_message_t state)
152 struct rk2818_23d_data *pdata = pdev->dev.platform_data;
153 struct modem_dev *mt6223d_data = platform_get_drvdata(pdev);
155 MODEMDBG("%s \n", __FUNCTION__);
157 modem_poweron_off(0); // power down
158 gpio_free(pdata->bp_power);
162 static struct platform_driver tdsc8800_driver = {
163 .probe = tdsc8800_probe,
164 .shutdown = tdsc8800_shutdown,
165 .suspend = tdsc8800_suspend,
166 .resume = tdsc8800_resume,
169 .owner = THIS_MODULE,
173 static int __init tdsc8800_init(void)
175 MODEMDBG("tdsc8800_init ret=%d\n");
176 return platform_driver_register(&tdsc8800_driver);
179 static void __exit tdsc8800_exit(void)
181 MODEMDBG("tdsc8800_exit\n");
182 platform_driver_unregister(&tdsc8800_driver);
185 module_init(tdsc8800_init);
186 module_exit(tdsc8800_exit);