1 #include <linux/module.h>
\r
2 #include <linux/kernel.h>
\r
3 #include <linux/i2c.h>
\r
4 #include <linux/irq.h>
\r
5 #include <linux/gpio.h>
\r
6 #include <linux/input.h>
\r
7 #include <linux/platform_device.h>
\r
8 #include <linux/fs.h>
\r
9 #include <linux/uaccess.h>
\r
10 #include <linux/miscdevice.h>
\r
11 #include <linux/circ_buf.h>
\r
12 #include <linux/interrupt.h>
\r
13 #include <linux/miscdevice.h>
\r
14 #include <mach/iomux.h>
\r
15 #include <mach/gpio.h>
\r
16 #include <linux/delay.h>
\r
17 #include <linux/poll.h>
\r
18 #include <linux/wait.h>
\r
19 #include <linux/wakelock.h>
\r
20 #include <linux/workqueue.h>
\r
21 #include <mach/iomux.h>
\r
22 #include<linux/ioctl.h>
\r
24 #include <linux/slab.h>
\r
26 MODULE_LICENSE("GPL");
\r
28 struct rk29_audio_switch_data {
\r
30 unsigned int gpio_switch_fm_ap;
\r
31 unsigned int gpio_switch_bb_ap;
\r
35 struct rk29_audio_switch_data *gpdata = NULL;
\r
37 #define AUDIO_SWTICH_IO 0XA2
\r
38 #define AS_IOCTL_AP _IO(AUDIO_SWTICH_IO,0X01)
\r
39 #define AS_IOCTL_BP _IO(AUDIO_SWTICH_IO,0X02)
\r
40 #define AS_IOCTL_FM _IO(AUDIO_SWTICH_IO,0X03)
\r
43 static int as_open(struct inode *inode, struct file *file)
\r
48 static int as_release(struct inode *inode, struct file *file)
\r
53 static long as_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
\r
59 gpio_set_value(gpdata->gpio_switch_fm_ap, GPIO_LOW);
\r
64 gpio_set_value(gpdata->gpio_switch_fm_ap, GPIO_HIGH);
\r
72 static struct file_operations as_fops = {
\r
73 .owner = THIS_MODULE,
\r
75 .release = as_release,
\r
76 .unlocked_ioctl = as_ioctl
\r
79 static struct miscdevice as_misc = {
\r
80 .minor = MISC_DYNAMIC_MINOR,
\r
81 .name = "audio_switch",
\r
85 static int as_probe(struct platform_device *pdev)
\r
88 gpdata = kzalloc(sizeof(struct rk29_audio_switch_data), GFP_KERNEL);
\r
90 rk30_mux_api_set(GPIO1B0_SPI_CLK_UART1_CTSN_NAME, GPIO1B_GPIO1B0);
\r
91 gpdata->gpio_switch_fm_ap = gpio_request(RK2928_PIN1_PB0,"switch_bb_ap");
\r
92 gpio_direction_output(gpdata->gpio_switch_fm_ap,GPIO_LOW);
\r
94 platform_set_drvdata(pdev, gpdata);
\r
96 result = misc_register(&as_misc);
\r
98 gpio_free(gpdata->gpio_switch_fm_ap);
\r
104 int as_suspend(struct platform_device *pdev, pm_message_t state)
\r
109 int as_resume(struct platform_device *pdev)
\r
114 void as_shutdown(struct platform_device *pdev)
\r
116 gpio_free(gpdata->gpio_switch_fm_ap);
\r
120 static struct platform_driver as_driver = {
\r
122 .shutdown = as_shutdown,
\r
123 .suspend = as_suspend,
\r
124 .resume = as_resume,
\r
126 .name = "audio_switch",
\r
127 .owner = THIS_MODULE,
\r
131 static int __init audio_switch_init(void)
\r
133 return platform_driver_register(&as_driver);
\r
136 static void __exit audio_switch_exit(void)
\r
138 platform_driver_unregister(&as_driver);
\r
141 module_init(audio_switch_init);
\r
143 module_exit(audio_switch_exit);
\r