diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/mips/au1000/db1x00 |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/mips/au1000/db1x00')
-rw-r--r-- | arch/mips/au1000/db1x00/Makefile | 9 | ||||
-rw-r--r-- | arch/mips/au1000/db1x00/board_setup.c | 127 | ||||
-rw-r--r-- | arch/mips/au1000/db1x00/init.c | 74 | ||||
-rw-r--r-- | arch/mips/au1000/db1x00/irqmap.c | 72 | ||||
-rw-r--r-- | arch/mips/au1000/db1x00/mirage_ts.c | 261 |
5 files changed, 543 insertions, 0 deletions
diff --git a/arch/mips/au1000/db1x00/Makefile b/arch/mips/au1000/db1x00/Makefile new file mode 100644 index 000000000000..4c7d763f2113 --- /dev/null +++ b/arch/mips/au1000/db1x00/Makefile | |||
@@ -0,0 +1,9 @@ | |||
1 | # | ||
2 | # Copyright 2000 MontaVista Software Inc. | ||
3 | # Author: MontaVista Software, Inc. | ||
4 | # ppopov@mvista.com or source@mvista.com | ||
5 | # | ||
6 | # Makefile for the Alchemy Semiconductor Db1x00 board. | ||
7 | |||
8 | lib-y := init.o board_setup.o irqmap.o | ||
9 | obj-$(CONFIG_WM97XX_COMODULE) += mirage_ts.o | ||
diff --git a/arch/mips/au1000/db1x00/board_setup.c b/arch/mips/au1000/db1x00/board_setup.c new file mode 100644 index 000000000000..ac05ba0ff63f --- /dev/null +++ b/arch/mips/au1000/db1x00/board_setup.c | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | * | ||
3 | * BRIEF MODULE DESCRIPTION | ||
4 | * Alchemy Db1x00 board setup. | ||
5 | * | ||
6 | * Copyright 2000 MontaVista Software Inc. | ||
7 | * Author: MontaVista Software, Inc. | ||
8 | * ppopov@mvista.com or source@mvista.com | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
17 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
18 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
21 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License along | ||
27 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
28 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
29 | */ | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/sched.h> | ||
33 | #include <linux/ioport.h> | ||
34 | #include <linux/mm.h> | ||
35 | #include <linux/console.h> | ||
36 | #include <linux/mc146818rtc.h> | ||
37 | #include <linux/delay.h> | ||
38 | |||
39 | #include <asm/cpu.h> | ||
40 | #include <asm/bootinfo.h> | ||
41 | #include <asm/irq.h> | ||
42 | #include <asm/mipsregs.h> | ||
43 | #include <asm/reboot.h> | ||
44 | #include <asm/pgtable.h> | ||
45 | #include <asm/mach-au1x00/au1000.h> | ||
46 | #include <asm/mach-db1x00/db1x00.h> | ||
47 | |||
48 | /* not correct for db1550 */ | ||
49 | static BCSR * const bcsr = (BCSR *)0xAE000000; | ||
50 | |||
51 | void board_reset (void) | ||
52 | { | ||
53 | /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */ | ||
54 | au_writel(0x00000000, 0xAE00001C); | ||
55 | } | ||
56 | |||
57 | void __init board_setup(void) | ||
58 | { | ||
59 | u32 pin_func; | ||
60 | |||
61 | pin_func = 0; | ||
62 | /* not valid for 1550 */ | ||
63 | #ifdef CONFIG_AU1X00_USB_DEVICE | ||
64 | // 2nd USB port is USB device | ||
65 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8000); | ||
66 | au_writel(pin_func, SYS_PINFUNC); | ||
67 | #endif | ||
68 | |||
69 | #if defined(CONFIG_IRDA) && (defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100)) | ||
70 | /* set IRFIRSEL instead of GPIO15 */ | ||
71 | pin_func = au_readl(SYS_PINFUNC) | (u32)((1<<8)); | ||
72 | au_writel(pin_func, SYS_PINFUNC); | ||
73 | /* power off until the driver is in use */ | ||
74 | bcsr->resets &= ~BCSR_RESETS_IRDA_MODE_MASK; | ||
75 | bcsr->resets |= BCSR_RESETS_IRDA_MODE_OFF; | ||
76 | au_sync(); | ||
77 | #endif | ||
78 | au_writel(0, 0xAE000010); /* turn off pcmcia power */ | ||
79 | |||
80 | #ifdef CONFIG_MIPS_MIRAGE | ||
81 | /* enable GPIO[31:0] inputs */ | ||
82 | au_writel(0, SYS_PININPUTEN); | ||
83 | |||
84 | /* GPIO[20] is output, tristate the other input primary GPIO's */ | ||
85 | au_writel((u32)(~(1<<20)), SYS_TRIOUTCLR); | ||
86 | |||
87 | /* set GPIO[210:208] instead of SSI_0 */ | ||
88 | pin_func = au_readl(SYS_PINFUNC) | (u32)(1); | ||
89 | |||
90 | /* set GPIO[215:211] for LED's */ | ||
91 | pin_func |= (u32)((5<<2)); | ||
92 | |||
93 | /* set GPIO[214:213] for more LED's */ | ||
94 | pin_func |= (u32)((5<<12)); | ||
95 | |||
96 | /* set GPIO[207:200] instead of PCMCIA/LCD */ | ||
97 | pin_func |= (u32)((3<<17)); | ||
98 | au_writel(pin_func, SYS_PINFUNC); | ||
99 | |||
100 | /* Enable speaker amplifier. This should | ||
101 | * be part of the audio driver. | ||
102 | */ | ||
103 | au_writel(au_readl(GPIO2_DIR) | 0x200, GPIO2_DIR); | ||
104 | au_writel(0x02000200, GPIO2_OUTPUT); | ||
105 | #endif | ||
106 | |||
107 | au_sync(); | ||
108 | |||
109 | #ifdef CONFIG_MIPS_DB1000 | ||
110 | printk("AMD Alchemy Au1000/Db1000 Board\n"); | ||
111 | #endif | ||
112 | #ifdef CONFIG_MIPS_DB1500 | ||
113 | printk("AMD Alchemy Au1500/Db1500 Board\n"); | ||
114 | #endif | ||
115 | #ifdef CONFIG_MIPS_DB1100 | ||
116 | printk("AMD Alchemy Au1100/Db1100 Board\n"); | ||
117 | #endif | ||
118 | #ifdef CONFIG_MIPS_BOSPORUS | ||
119 | printk("AMD Alchemy Bosporus Board\n"); | ||
120 | #endif | ||
121 | #ifdef CONFIG_MIPS_MIRAGE | ||
122 | printk("AMD Alchemy Mirage Board\n"); | ||
123 | #endif | ||
124 | #ifdef CONFIG_MIPS_DB1550 | ||
125 | printk("AMD Alchemy Au1550/Db1550 Board\n"); | ||
126 | #endif | ||
127 | } | ||
diff --git a/arch/mips/au1000/db1x00/init.c b/arch/mips/au1000/db1x00/init.c new file mode 100644 index 000000000000..51eee94a5e82 --- /dev/null +++ b/arch/mips/au1000/db1x00/init.c | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * BRIEF MODULE DESCRIPTION | ||
3 | * PB1000 board setup | ||
4 | * | ||
5 | * Copyright 2001 MontaVista Software Inc. | ||
6 | * Author: MontaVista Software, Inc. | ||
7 | * ppopov@mvista.com or source@mvista.com | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
15 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
17 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
20 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License along | ||
26 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
27 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 | */ | ||
29 | |||
30 | #include <linux/init.h> | ||
31 | #include <linux/mm.h> | ||
32 | #include <linux/sched.h> | ||
33 | #include <linux/bootmem.h> | ||
34 | #include <asm/addrspace.h> | ||
35 | #include <asm/bootinfo.h> | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/string.h> | ||
38 | #include <linux/kernel.h> | ||
39 | |||
40 | int prom_argc; | ||
41 | char **prom_argv, **prom_envp; | ||
42 | extern void __init prom_init_cmdline(void); | ||
43 | extern char *prom_getenv(char *envname); | ||
44 | |||
45 | const char *get_system_type(void) | ||
46 | { | ||
47 | #ifdef CONFIG_MIPS_BOSPORUS | ||
48 | return "Alchemy Bosporus Gateway Reference"; | ||
49 | #else | ||
50 | return "Alchemy Db1x00"; | ||
51 | #endif | ||
52 | } | ||
53 | |||
54 | void __init prom_init(void) | ||
55 | { | ||
56 | unsigned char *memsize_str; | ||
57 | unsigned long memsize; | ||
58 | |||
59 | prom_argc = fw_arg0; | ||
60 | prom_argv = (char **) fw_arg1; | ||
61 | prom_envp = (char **) fw_arg2; | ||
62 | |||
63 | mips_machgroup = MACH_GROUP_ALCHEMY; | ||
64 | mips_machtype = MACH_DB1000; /* set the platform # */ | ||
65 | |||
66 | prom_init_cmdline(); | ||
67 | |||
68 | memsize_str = prom_getenv("memsize"); | ||
69 | if (!memsize_str) | ||
70 | memsize = 0x04000000; | ||
71 | else | ||
72 | memsize = simple_strtol(memsize_str, NULL, 0); | ||
73 | add_memory_region(0, memsize, BOOT_MEM_RAM); | ||
74 | } | ||
diff --git a/arch/mips/au1000/db1x00/irqmap.c b/arch/mips/au1000/db1x00/irqmap.c new file mode 100644 index 000000000000..8f6ef0dbe1f8 --- /dev/null +++ b/arch/mips/au1000/db1x00/irqmap.c | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * BRIEF MODULE DESCRIPTION | ||
3 | * Au1xxx irq map table | ||
4 | * | ||
5 | * Copyright 2003 Embedded Edge, LLC | ||
6 | * dan@embeddededge.com | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
16 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
19 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
20 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License along | ||
25 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
26 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
27 | */ | ||
28 | #include <linux/config.h> | ||
29 | #include <linux/errno.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/irq.h> | ||
32 | #include <linux/kernel_stat.h> | ||
33 | #include <linux/module.h> | ||
34 | #include <linux/signal.h> | ||
35 | #include <linux/sched.h> | ||
36 | #include <linux/types.h> | ||
37 | #include <linux/interrupt.h> | ||
38 | #include <linux/ioport.h> | ||
39 | #include <linux/timex.h> | ||
40 | #include <linux/slab.h> | ||
41 | #include <linux/random.h> | ||
42 | #include <linux/delay.h> | ||
43 | #include <linux/bitops.h> | ||
44 | |||
45 | #include <asm/bootinfo.h> | ||
46 | #include <asm/io.h> | ||
47 | #include <asm/mipsregs.h> | ||
48 | #include <asm/system.h> | ||
49 | #include <asm/mach-au1x00/au1000.h> | ||
50 | |||
51 | au1xxx_irq_map_t au1xxx_irq_map[] = { | ||
52 | |||
53 | #ifndef CONFIG_MIPS_MIRAGE | ||
54 | #ifdef CONFIG_MIPS_DB1550 | ||
55 | { AU1000_GPIO_3, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card 0 IRQ# */ | ||
56 | { AU1000_GPIO_5, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card 1 IRQ# */ | ||
57 | #else | ||
58 | { AU1000_GPIO_0, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card 0 Fully_Interted# */ | ||
59 | { AU1000_GPIO_1, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card 0 STSCHG# */ | ||
60 | { AU1000_GPIO_2, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card 0 IRQ# */ | ||
61 | |||
62 | { AU1000_GPIO_3, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card 1 Fully_Interted# */ | ||
63 | { AU1000_GPIO_4, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card 1 STSCHG# */ | ||
64 | { AU1000_GPIO_5, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card 1 IRQ# */ | ||
65 | #endif | ||
66 | #else | ||
67 | { AU1000_GPIO_7, INTC_INT_RISE_EDGE, 0 }, /* touchscreen pen down */ | ||
68 | #endif | ||
69 | |||
70 | }; | ||
71 | |||
72 | int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); | ||
diff --git a/arch/mips/au1000/db1x00/mirage_ts.c b/arch/mips/au1000/db1x00/mirage_ts.c new file mode 100644 index 000000000000..ade35e432004 --- /dev/null +++ b/arch/mips/au1000/db1x00/mirage_ts.c | |||
@@ -0,0 +1,261 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/au1000/db1x00/mirage_ts.c | ||
3 | * | ||
4 | * BRIEF MODULE DESCRIPTION | ||
5 | * Glue between Mirage board-specific touchscreen pieces | ||
6 | * and generic Wolfson Codec touchscreen support. | ||
7 | * | ||
8 | * Based on pb1100_ts.c used in Hydrogen II. | ||
9 | * | ||
10 | * Copyright (c) 2003 Embedded Edge, LLC | ||
11 | * dan@embeddededge.com | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify it | ||
14 | * under the terms of the GNU General Public License as published by the | ||
15 | * Free Software Foundation; either version 2 of the License, or (at your | ||
16 | * option) any later version. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
21 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
24 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | * | ||
29 | * You should have received a copy of the GNU General Public License along | ||
30 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
31 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
32 | */ | ||
33 | |||
34 | #include <linux/config.h> | ||
35 | #include <linux/types.h> | ||
36 | #include <linux/module.h> | ||
37 | #include <linux/sched.h> | ||
38 | #include <linux/kernel.h> | ||
39 | #include <linux/init.h> | ||
40 | #include <linux/fs.h> | ||
41 | #include <linux/poll.h> | ||
42 | #include <linux/proc_fs.h> | ||
43 | #include <linux/smp.h> | ||
44 | #include <linux/smp_lock.h> | ||
45 | #include <linux/wait.h> | ||
46 | |||
47 | #include <asm/segment.h> | ||
48 | #include <asm/irq.h> | ||
49 | #include <asm/uaccess.h> | ||
50 | #include <asm/delay.h> | ||
51 | #include <asm/au1000.h> | ||
52 | |||
53 | /* | ||
54 | * Imported interface to Wolfson Codec driver. | ||
55 | */ | ||
56 | extern void *wm97xx_ts_get_handle(int which); | ||
57 | extern int wm97xx_ts_ready(void* ts_handle); | ||
58 | extern void wm97xx_ts_set_cal(void* ts_handle, int xscale, int xtrans, int yscale, int ytrans); | ||
59 | extern u16 wm97xx_ts_get_ac97(void* ts_handle, u8 reg); | ||
60 | extern void wm97xx_ts_set_ac97(void* ts_handle, u8 reg, u16 val); | ||
61 | extern int wm97xx_ts_read_data(void* ts_handle, long* x, long* y, long* pressure); | ||
62 | extern void wm97xx_ts_send_data(void* ts_handle, long x, long y, long z); | ||
63 | |||
64 | int wm97xx_comodule_present = 1; | ||
65 | |||
66 | |||
67 | #define TS_NAME "mirage_ts" | ||
68 | |||
69 | #define err(format, arg...) printk(KERN_ERR TS_NAME ": " format "\n" , ## arg) | ||
70 | #define info(format, arg...) printk(KERN_INFO TS_NAME ": " format "\n" , ## arg) | ||
71 | #define warn(format, arg...) printk(KERN_WARNING TS_NAME ": " format "\n" , ## arg) | ||
72 | #define DPRINTK(format, arg...) printk("%s: " format "\n", __FUNCTION__ , ## arg) | ||
73 | |||
74 | |||
75 | #define PEN_DOWN_IRQ AU1000_GPIO_7 | ||
76 | |||
77 | static struct task_struct *ts_task = 0; | ||
78 | static DECLARE_COMPLETION(ts_complete); | ||
79 | static DECLARE_WAIT_QUEUE_HEAD(pendown_wait); | ||
80 | |||
81 | #ifdef CONFIG_WM97XX_FIVEWIRETS | ||
82 | static int release_pressure = 1; | ||
83 | #else | ||
84 | static int release_pressure = 50; | ||
85 | #endif | ||
86 | |||
87 | typedef struct { | ||
88 | long x; | ||
89 | long y; | ||
90 | } DOWN_EVENT; | ||
91 | |||
92 | #define SAMPLE_RATE 50 /* samples per second */ | ||
93 | #define PEN_DEBOUNCE 5 /* samples for settling - fn of SAMPLE_RATE */ | ||
94 | #define PEN_UP_TIMEOUT 10 /* in seconds */ | ||
95 | #define PEN_UP_SETTLE 5 /* samples per second */ | ||
96 | |||
97 | static struct { | ||
98 | int xscale; | ||
99 | int xtrans; | ||
100 | int yscale; | ||
101 | int ytrans; | ||
102 | } mirage_ts_cal = | ||
103 | { | ||
104 | #if 0 | ||
105 | xscale: 84, | ||
106 | xtrans: -157, | ||
107 | yscale: 66, | ||
108 | ytrans: -150, | ||
109 | #else | ||
110 | xscale: 84, | ||
111 | xtrans: -150, | ||
112 | yscale: 66, | ||
113 | ytrans: -146, | ||
114 | #endif | ||
115 | }; | ||
116 | |||
117 | |||
118 | static void pendown_irq(int irqnr, void *devid, struct pt_regs *regs) | ||
119 | { | ||
120 | //DPRINTK("got one 0x%x", au_readl(SYS_PINSTATERD)); | ||
121 | wake_up(&pendown_wait); | ||
122 | } | ||
123 | |||
124 | static int ts_thread(void *id) | ||
125 | { | ||
126 | static int pen_was_down = 0; | ||
127 | static DOWN_EVENT pen_xy; | ||
128 | long x, y, z; | ||
129 | void *ts; /* handle */ | ||
130 | struct task_struct *tsk = current; | ||
131 | int timeout = HZ / SAMPLE_RATE; | ||
132 | |||
133 | ts_task = tsk; | ||
134 | |||
135 | daemonize(); | ||
136 | tsk->tty = NULL; | ||
137 | tsk->policy = SCHED_FIFO; | ||
138 | tsk->rt_priority = 1; | ||
139 | strcpy(tsk->comm, "touchscreen"); | ||
140 | |||
141 | /* only want to receive SIGKILL */ | ||
142 | spin_lock_irq(&tsk->sigmask_lock); | ||
143 | siginitsetinv(&tsk->blocked, sigmask(SIGKILL)); | ||
144 | recalc_sigpending(tsk); | ||
145 | spin_unlock_irq(&tsk->sigmask_lock); | ||
146 | |||
147 | /* get handle for codec */ | ||
148 | ts = wm97xx_ts_get_handle(0); | ||
149 | |||
150 | /* proceed only after everybody is ready */ | ||
151 | wait_event_timeout(pendown_wait, wm97xx_ts_ready(ts), HZ/4); | ||
152 | |||
153 | /* board-specific calibration */ | ||
154 | wm97xx_ts_set_cal(ts, | ||
155 | mirage_ts_cal.xscale, | ||
156 | mirage_ts_cal.xtrans, | ||
157 | mirage_ts_cal.yscale, | ||
158 | mirage_ts_cal.ytrans); | ||
159 | |||
160 | /* route Wolfson pendown interrupts to our GPIO */ | ||
161 | au_sync(); | ||
162 | wm97xx_ts_set_ac97(ts, 0x4c, wm97xx_ts_get_ac97(ts, 0x4c) & ~0x0008); | ||
163 | au_sync(); | ||
164 | wm97xx_ts_set_ac97(ts, 0x56, wm97xx_ts_get_ac97(ts, 0x56) & ~0x0008); | ||
165 | au_sync(); | ||
166 | wm97xx_ts_set_ac97(ts, 0x52, wm97xx_ts_get_ac97(ts, 0x52) | 0x2008); | ||
167 | au_sync(); | ||
168 | |||
169 | for (;;) { | ||
170 | interruptible_sleep_on_timeout(&pendown_wait, timeout); | ||
171 | disable_irq(PEN_DOWN_IRQ); | ||
172 | if (signal_pending(tsk)) { | ||
173 | break; | ||
174 | } | ||
175 | |||
176 | /* read codec */ | ||
177 | if (!wm97xx_ts_read_data(ts, &x, &y, &z)) | ||
178 | z = 0; /* treat no-data and pen-up the same */ | ||
179 | |||
180 | if (signal_pending(tsk)) { | ||
181 | break; | ||
182 | } | ||
183 | |||
184 | if (z >= release_pressure) { | ||
185 | y = ~y; /* top to bottom */ | ||
186 | if (pen_was_down > 1 /*&& pen_was_down < PEN_DEBOUNCE*/) {//THXXX | ||
187 | /* bounce ? */ | ||
188 | x = pen_xy.x; | ||
189 | y = pen_xy.y; | ||
190 | --pen_was_down; | ||
191 | } else if (pen_was_down <= 1) { | ||
192 | pen_xy.x = x; | ||
193 | pen_xy.y = y; | ||
194 | if (pen_was_down) | ||
195 | wm97xx_ts_send_data(ts, x, y, z); | ||
196 | pen_was_down = PEN_DEBOUNCE; | ||
197 | } | ||
198 | //wm97xx_ts_send_data(ts, x, y, z); | ||
199 | timeout = HZ / SAMPLE_RATE; | ||
200 | } else { | ||
201 | if (pen_was_down) { | ||
202 | if (--pen_was_down) | ||
203 | z = release_pressure; | ||
204 | else //THXXX | ||
205 | wm97xx_ts_send_data(ts, pen_xy.x, pen_xy.y, z); | ||
206 | } | ||
207 | /* The pendown signal takes some time to settle after | ||
208 | * reading the pen pressure so wait a little | ||
209 | * before enabling the pen. | ||
210 | */ | ||
211 | if (! pen_was_down) { | ||
212 | // interruptible_sleep_on_timeout(&pendown_wait, HZ / PEN_UP_SETTLE); | ||
213 | timeout = HZ * PEN_UP_TIMEOUT; | ||
214 | } | ||
215 | } | ||
216 | enable_irq(PEN_DOWN_IRQ); | ||
217 | } | ||
218 | enable_irq(PEN_DOWN_IRQ); | ||
219 | ts_task = NULL; | ||
220 | complete(&ts_complete); | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int __init ts_mirage_init(void) | ||
225 | { | ||
226 | int ret; | ||
227 | |||
228 | /* pen down signal is connected to GPIO 7 */ | ||
229 | |||
230 | ret = request_irq(PEN_DOWN_IRQ, pendown_irq, 0, "ts-pendown", NULL); | ||
231 | if (ret) { | ||
232 | err("unable to get pendown irq%d: [%d]", PEN_DOWN_IRQ, ret); | ||
233 | return ret; | ||
234 | } | ||
235 | |||
236 | lock_kernel(); | ||
237 | ret = kernel_thread(ts_thread, NULL, CLONE_FS | CLONE_FILES); | ||
238 | if (ret < 0) { | ||
239 | unlock_kernel(); | ||
240 | return ret; | ||
241 | } | ||
242 | unlock_kernel(); | ||
243 | |||
244 | info("Mirage touchscreen IRQ initialized."); | ||
245 | |||
246 | return 0; | ||
247 | } | ||
248 | |||
249 | static void __exit ts_mirage_exit(void) | ||
250 | { | ||
251 | if (ts_task) { | ||
252 | send_sig(SIGKILL, ts_task, 1); | ||
253 | wait_for_completion(&ts_complete); | ||
254 | } | ||
255 | |||
256 | free_irq(PEN_DOWN_IRQ, NULL); | ||
257 | } | ||
258 | |||
259 | module_init(ts_mirage_init); | ||
260 | module_exit(ts_mirage_exit); | ||
261 | |||