summaryrefslogtreecommitdiff
path: root/packages/linux/linux/simpad/linux-2.6.21-SIMpad-serial-and-gpio_keys.patch
blob: 90ce4cb00979d18253f592d56ddc3b826e8cdbf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
diff -uNr linux-2.6.21.vanilla/arch/arm/mach-sa1100/simpad.c linux-2.6.21/arch/arm/mach-sa1100/simpad.c
--- linux-2.6.21.vanilla/arch/arm/mach-sa1100/simpad.c	2007-05-01 16:40:44.000000000 +0200
+++ linux-2.6.21/arch/arm/mach-sa1100/simpad.c	2007-05-01 19:23:29.000000000 +0200
@@ -1,5 +1,14 @@
 /*
  * linux/arch/arm/mach-sa1100/simpad.c
+ *
+ * 2007/04/11 mrdata:
+ *            - insert simpad_uart_set_mctrl()
+ *                     simpad_uart_get_mctrl()
+ *            - internal RS232/DECT/Bluetooth
+ *              works again (based on 2.4 simpad-serial.patch)
+ *
+ * 2007/04/12 Bernhard Guillon: 
+ *            -added gpio_keys (based on h3000.c from hh.org)
  */
 
 #include <linux/module.h>
@@ -27,6 +36,8 @@
 
 #include <linux/serial_core.h>
 #include <linux/ioport.h>
+#include <linux/input.h>
+#include <linux/gpio_keys.h>
 #include <asm/io.h>
 
 #include "generic.h"
@@ -55,6 +66,7 @@
 	*(CS3BUSTYPE *)(CS3_BASE) = cs3_shadow;
 }
 
+EXPORT_SYMBOL(get_cs3_shadow);
 EXPORT_SYMBOL(set_cs3_bit);
 EXPORT_SYMBOL(clear_cs3_bit);
 
@@ -73,23 +85,71 @@
 };
 
 
+static void simpad_uart_set_mctrl(struct uart_port *port, u_int mctrl)
+{
+        if (port->mapbase == _Ser1UTCR0) {
+                /* internal serial port (ttySA1, DECT/Bluetooth) */
+                if (mctrl & TIOCM_RTS)  GPCR = GPIO_UART1_RTS;
+                else                    GPSR = GPIO_UART1_RTS;
+
+                if (mctrl & TIOCM_DTR)  GPCR = GPIO_UART1_DTR;
+                else                    GPSR = GPIO_UART1_DTR;
+        }
+
+        else if (port->mapbase == _Ser3UTCR0) {
+                /* external serial port (ttySA0, RS232) */
+                if (mctrl & TIOCM_RTS)  GPCR = GPIO_UART3_RTS;
+                else                    GPSR = GPIO_UART3_RTS;
+
+                if (mctrl & TIOCM_DTR)  GPCR = GPIO_UART3_DTR;
+                else                    GPSR = GPIO_UART3_DTR;
+        }              
+}
+
+
+static u_int simpad_uart_get_mctrl(struct uart_port *port)
+{
+        u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
+       
+        if (port->mapbase == _Ser1UTCR0) {
+                /* internal serial port (ttySA1, DECT/Bluetooth) */
+                int gplr = GPLR;
+                if (gplr & GPIO_UART1_DCD) ret &= ~TIOCM_CD;
+                if (gplr & GPIO_UART1_CTS) ret &= ~TIOCM_CTS;
+                if (gplr & GPIO_UART1_DSR) ret &= ~TIOCM_DSR;
+        }
+       
+        else if (port->mapbase == _Ser3UTCR0) {
+                /* external serial port (ttySA0, RS232) */
+                int gplr = GPLR;
+                if (gplr & GPIO_UART3_DCD) ret &= ~TIOCM_CD;
+                if (gplr & GPIO_UART3_CTS) ret &= ~TIOCM_CTS;
+                if (gplr & GPIO_UART3_DSR) ret &= ~TIOCM_DSR;
+        }
+        return ret;
+}
+
+
 static void simpad_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
 {
-	if (port->mapbase == (u_int)&Ser1UTCR0) {
-		if (state)
-		{
-			clear_cs3_bit(RS232_ON);
-			clear_cs3_bit(DECT_POWER_ON);
-		}else
-		{
-			set_cs3_bit(RS232_ON);
-			set_cs3_bit(DECT_POWER_ON);
-		}
-	}
+        if (port->mapbase == (u_int)&Ser3UTCR0) {
+                if (state)
+                {
+                        clear_cs3_bit(RS232_ON);
+                        /* clear_cs3_bit(DECT_POWER_ON); */
+                }else
+                {
+                        set_cs3_bit(RS232_ON);
+                        /* set_cs3_bit(DECT_POWER_ON); */
+                }
+        }
 }
 
+
 static struct sa1100_port_fns simpad_port_fns __initdata = {
-	.pm	   = simpad_uart_pm,
+        .set_mctrl = simpad_uart_set_mctrl,
+        .get_mctrl = simpad_uart_get_mctrl,
+        .pm        = simpad_uart_pm,
 };
 
 
@@ -150,7 +210,7 @@
 	sa1100_register_uart(0, 3);  /* serial interface */
 	sa1100_register_uart(1, 1);  /* DECT             */
 
-	// Reassign UART 1 pins
+	/* Reassign UART 1 pins */
 	GAFR |= GPIO_UART_TXD | GPIO_UART_RXD;
 	GPDR |= GPIO_UART_TXD | GPIO_LDD13 | GPIO_LDD15;
 	GPDR &= ~GPIO_UART_RXD;
@@ -173,7 +233,7 @@
 
 static void simpad_power_off(void)
 {
-	local_irq_disable(); // was cli
+	local_irq_disable(); /* was cli */
 	set_cs3(0x800);        /* only SD_MEDIAQ */
 
 	/* disable internal oscillator, float CS lines */
@@ -197,19 +257,42 @@
 
 
 /*
+ * gpio_keys
+*/
+
+static struct gpio_keys_button simpad_button_table[] = {
+	{ KEY_POWER, IRQ_GPIO_POWER_BUTTON, 0, "power button" },
+};
+
+static struct gpio_keys_platform_data simpad_keys_data = {
+	.buttons = simpad_button_table,
+	.nbuttons = ARRAY_SIZE(simpad_button_table),
+};
+
+static struct platform_device simpad_keys = {
+	.name = "gpio-keys",
+	.dev = {
+		.platform_data = &simpad_keys_data,
+	},
+};
+
+
+/*
  * MediaQ Video Device
  */
+
 static struct platform_device simpad_mq200fb = {
 	.name = "simpad-mq200",
 	.id   = 0,
 };
 
+
 static struct platform_device *devices[] __initdata = {
-	&simpad_mq200fb
+	&simpad_keys,
+    &simpad_mq200fb,
 };
 
 
-
 static int __init simpad_init(void)
 {
 	int ret;
diff -uNr linux-2.6.21.vanilla/include/asm-arm/arch-sa1100/simpad.h linux-2.6.21/include/asm-arm/arch-sa1100/simpad.h
--- linux-2.6.21.vanilla/include/asm-arm/arch-sa1100/simpad.h	2007-05-01 16:40:51.000000000 +0200
+++ linux-2.6.21/include/asm-arm/arch-sa1100/simpad.h	2007-05-01 19:22:45.000000000 +0200
@@ -12,7 +12,7 @@
 #define __ASM_ARCH_SIMPAD_H
 
 
-#define GPIO_UART1_RTS	GPIO_GPIO14
+#define GPIO_UART1_RTS	GPIO_GPIO9
 #define GPIO_UART1_DTR	GPIO_GPIO7
 #define GPIO_UART1_CTS	GPIO_GPIO8
 #define GPIO_UART1_DCD	GPIO_GPIO23