diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/busses/Kconfig | 2 | ||||
-rw-r--r-- | drivers/input/keyboard/Kconfig | 48 | ||||
-rw-r--r-- | drivers/input/keyboard/Makefile | 3 | ||||
-rw-r--r-- | drivers/input/keyboard/corgikbd.c | 414 | ||||
-rw-r--r-- | drivers/input/keyboard/spitzkbd.c | 496 | ||||
-rw-r--r-- | drivers/input/keyboard/tosakbd.c | 431 | ||||
-rw-r--r-- | drivers/input/touchscreen/Kconfig | 16 | ||||
-rw-r--r-- | drivers/input/touchscreen/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/touchscreen/corgi_ts.c | 385 | ||||
-rw-r--r-- | drivers/mmc/host/mmci.c | 19 | ||||
-rw-r--r-- | drivers/mmc/host/mmci.h | 6 | ||||
-rw-r--r-- | drivers/mmc/host/pxamci.c | 2 | ||||
-rw-r--r-- | drivers/pcmcia/Kconfig | 3 | ||||
-rw-r--r-- | drivers/pcmcia/Makefile | 1 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_vpac270.c | 229 | ||||
-rw-r--r-- | drivers/serial/Kconfig | 7 | ||||
-rw-r--r-- | drivers/serial/atmel_serial.c | 207 | ||||
-rw-r--r-- | drivers/spi/pxa2xx_spi.c | 25 | ||||
-rw-r--r-- | drivers/usb/gadget/at91_udc.c | 7 |
19 files changed, 450 insertions, 1852 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 9c6170cd9aa..87ab0568bb0 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -564,7 +564,7 @@ config I2C_STU300 | |||
564 | 564 | ||
565 | config I2C_VERSATILE | 565 | config I2C_VERSATILE |
566 | tristate "ARM Versatile/Realview I2C bus support" | 566 | tristate "ARM Versatile/Realview I2C bus support" |
567 | depends on ARCH_VERSATILE || ARCH_REALVIEW | 567 | depends on ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS |
568 | select I2C_ALGOBIT | 568 | select I2C_ALGOBIT |
569 | help | 569 | help |
570 | Say yes if you want to support the I2C serial bus on ARMs Versatile | 570 | Say yes if you want to support the I2C serial bus on ARMs Versatile |
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 64c102355f5..a8293388d01 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -143,19 +143,6 @@ config KEYBOARD_BFIN | |||
143 | To compile this driver as a module, choose M here: the | 143 | To compile this driver as a module, choose M here: the |
144 | module will be called bf54x-keys. | 144 | module will be called bf54x-keys. |
145 | 145 | ||
146 | config KEYBOARD_CORGI | ||
147 | tristate "Corgi keyboard (deprecated)" | ||
148 | depends on PXA_SHARPSL | ||
149 | help | ||
150 | Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx | ||
151 | series of PDAs. | ||
152 | |||
153 | This driver is now deprecated, use generic GPIO based matrix | ||
154 | keyboard driver instead. | ||
155 | |||
156 | To compile this driver as a module, choose M here: the | ||
157 | module will be called corgikbd. | ||
158 | |||
159 | config KEYBOARD_LKKBD | 146 | config KEYBOARD_LKKBD |
160 | tristate "DECstation/VAXstation LK201/LK401 keyboard" | 147 | tristate "DECstation/VAXstation LK201/LK401 keyboard" |
161 | select SERIO | 148 | select SERIO |
@@ -339,19 +326,6 @@ config KEYBOARD_PXA930_ROTARY | |||
339 | To compile this driver as a module, choose M here: the | 326 | To compile this driver as a module, choose M here: the |
340 | module will be called pxa930_rotary. | 327 | module will be called pxa930_rotary. |
341 | 328 | ||
342 | config KEYBOARD_SPITZ | ||
343 | tristate "Spitz keyboard (deprecated)" | ||
344 | depends on PXA_SHARPSL | ||
345 | help | ||
346 | Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000, | ||
347 | SL-C3000 and Sl-C3100 series of PDAs. | ||
348 | |||
349 | This driver is now deprecated, use generic GPIO based matrix | ||
350 | keyboard driver instead. | ||
351 | |||
352 | To compile this driver as a module, choose M here: the | ||
353 | module will be called spitzkbd. | ||
354 | |||
355 | config KEYBOARD_STOWAWAY | 329 | config KEYBOARD_STOWAWAY |
356 | tristate "Stowaway keyboard" | 330 | tristate "Stowaway keyboard" |
357 | select SERIO | 331 | select SERIO |
@@ -414,28 +388,6 @@ config KEYBOARD_TWL4030 | |||
414 | To compile this driver as a module, choose M here: the | 388 | To compile this driver as a module, choose M here: the |
415 | module will be called twl4030_keypad. | 389 | module will be called twl4030_keypad. |
416 | 390 | ||
417 | config KEYBOARD_TOSA | ||
418 | tristate "Tosa keyboard (deprecated)" | ||
419 | depends on MACH_TOSA | ||
420 | help | ||
421 | Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa) | ||
422 | |||
423 | This driver is now deprecated, use generic GPIO based matrix | ||
424 | keyboard driver instead. | ||
425 | |||
426 | To compile this driver as a module, choose M here: the | ||
427 | module will be called tosakbd. | ||
428 | |||
429 | config KEYBOARD_TOSA_USE_EXT_KEYCODES | ||
430 | bool "Tosa keyboard: use extended keycodes" | ||
431 | depends on KEYBOARD_TOSA | ||
432 | help | ||
433 | Say Y here to enable the tosa keyboard driver to generate extended | ||
434 | (>= 127) keycodes. Be aware, that they can't be correctly interpreted | ||
435 | by either console keyboard driver or by Kdrive keybd driver. | ||
436 | |||
437 | Say Y only if you know, what you are doing! | ||
438 | |||
439 | config KEYBOARD_XTKBD | 391 | config KEYBOARD_XTKBD |
440 | tristate "XT keyboard" | 392 | tristate "XT keyboard" |
441 | select SERIO | 393 | select SERIO |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 706c6b5ed5f..9a74127e4d1 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -11,7 +11,6 @@ obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o | |||
11 | obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o | 11 | obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o |
12 | obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o | 12 | obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o |
13 | obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o | 13 | obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o |
14 | obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o | ||
15 | obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o | 14 | obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o |
16 | obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o | 15 | obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o |
17 | obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o | 16 | obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o |
@@ -33,10 +32,8 @@ obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o | |||
33 | obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o | 32 | obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o |
34 | obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o | 33 | obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o |
35 | obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o | 34 | obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o |
36 | obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o | ||
37 | obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o | 35 | obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o |
38 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o | 36 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o |
39 | obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o | ||
40 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o | 37 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o |
41 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o | 38 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o |
42 | obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o | 39 | obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o |
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c deleted file mode 100644 index 634af6a8e6b..00000000000 --- a/drivers/input/keyboard/corgikbd.c +++ /dev/null | |||
@@ -1,414 +0,0 @@ | |||
1 | /* | ||
2 | * Keyboard driver for Sharp Corgi models (SL-C7xx) | ||
3 | * | ||
4 | * Copyright (c) 2004-2005 Richard Purdie | ||
5 | * | ||
6 | * Based on xtkbd.c/locomkbd.c | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/delay.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/input.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/jiffies.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | #include <mach/corgi.h> | ||
24 | #include <mach/pxa2xx-gpio.h> | ||
25 | #include <asm/hardware/scoop.h> | ||
26 | |||
27 | #define KB_ROWS 8 | ||
28 | #define KB_COLS 12 | ||
29 | #define KB_ROWMASK(r) (1 << (r)) | ||
30 | #define SCANCODE(r,c) ( ((r)<<4) + (c) + 1 ) | ||
31 | /* zero code, 124 scancodes */ | ||
32 | #define NR_SCANCODES ( SCANCODE(KB_ROWS-1,KB_COLS-1) +1 +1 ) | ||
33 | |||
34 | #define SCAN_INTERVAL (50) /* ms */ | ||
35 | #define HINGE_SCAN_INTERVAL (250) /* ms */ | ||
36 | |||
37 | #define CORGI_KEY_CALENDER KEY_F1 | ||
38 | #define CORGI_KEY_ADDRESS KEY_F2 | ||
39 | #define CORGI_KEY_FN KEY_F3 | ||
40 | #define CORGI_KEY_CANCEL KEY_F4 | ||
41 | #define CORGI_KEY_OFF KEY_SUSPEND | ||
42 | #define CORGI_KEY_EXOK KEY_F5 | ||
43 | #define CORGI_KEY_EXCANCEL KEY_F6 | ||
44 | #define CORGI_KEY_EXJOGDOWN KEY_F7 | ||
45 | #define CORGI_KEY_EXJOGUP KEY_F8 | ||
46 | #define CORGI_KEY_JAP1 KEY_LEFTCTRL | ||
47 | #define CORGI_KEY_JAP2 KEY_LEFTALT | ||
48 | #define CORGI_KEY_MAIL KEY_F10 | ||
49 | #define CORGI_KEY_OK KEY_F11 | ||
50 | #define CORGI_KEY_MENU KEY_F12 | ||
51 | |||
52 | static unsigned char corgikbd_keycode[NR_SCANCODES] = { | ||
53 | 0, /* 0 */ | ||
54 | 0, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, 0, 0, 0, 0, 0, 0, 0, /* 1-16 */ | ||
55 | 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, 0, 0, 0, 0, 0, 0, 0, /* 17-32 */ | ||
56 | KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ | ||
57 | CORGI_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */ | ||
58 | CORGI_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, 0, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, /* 65-80 */ | ||
59 | CORGI_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */ | ||
60 | KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, CORGI_KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */ | ||
61 | CORGI_KEY_OFF, CORGI_KEY_EXOK, CORGI_KEY_EXCANCEL, CORGI_KEY_EXJOGDOWN, CORGI_KEY_EXJOGUP, 0, 0, 0, 0, 0, 0, 0, /* 113-124 */ | ||
62 | }; | ||
63 | |||
64 | |||
65 | struct corgikbd { | ||
66 | unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)]; | ||
67 | struct input_dev *input; | ||
68 | |||
69 | spinlock_t lock; | ||
70 | struct timer_list timer; | ||
71 | struct timer_list htimer; | ||
72 | |||
73 | unsigned int suspended; | ||
74 | unsigned long suspend_jiffies; | ||
75 | }; | ||
76 | |||
77 | #define KB_DISCHARGE_DELAY 10 | ||
78 | #define KB_ACTIVATE_DELAY 10 | ||
79 | |||
80 | /* Helper functions for reading the keyboard matrix | ||
81 | * Note: We should really be using the generic gpio functions to alter | ||
82 | * GPDR but it requires a function call per GPIO bit which is | ||
83 | * excessive when we need to access 12 bits at once, multiple times. | ||
84 | * These functions must be called within local_irq_save()/local_irq_restore() | ||
85 | * or similar. | ||
86 | */ | ||
87 | static inline void corgikbd_discharge_all(void) | ||
88 | { | ||
89 | /* STROBE All HiZ */ | ||
90 | GPCR2 = CORGI_GPIO_ALL_STROBE_BIT; | ||
91 | GPDR2 &= ~CORGI_GPIO_ALL_STROBE_BIT; | ||
92 | } | ||
93 | |||
94 | static inline void corgikbd_activate_all(void) | ||
95 | { | ||
96 | /* STROBE ALL -> High */ | ||
97 | GPSR2 = CORGI_GPIO_ALL_STROBE_BIT; | ||
98 | GPDR2 |= CORGI_GPIO_ALL_STROBE_BIT; | ||
99 | |||
100 | udelay(KB_DISCHARGE_DELAY); | ||
101 | |||
102 | /* Clear any interrupts we may have triggered when altering the GPIO lines */ | ||
103 | GEDR1 = CORGI_GPIO_HIGH_SENSE_BIT; | ||
104 | GEDR2 = CORGI_GPIO_LOW_SENSE_BIT; | ||
105 | } | ||
106 | |||
107 | static inline void corgikbd_activate_col(int col) | ||
108 | { | ||
109 | /* STROBE col -> High, not col -> HiZ */ | ||
110 | GPSR2 = CORGI_GPIO_STROBE_BIT(col); | ||
111 | GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col); | ||
112 | } | ||
113 | |||
114 | static inline void corgikbd_reset_col(int col) | ||
115 | { | ||
116 | /* STROBE col -> Low */ | ||
117 | GPCR2 = CORGI_GPIO_STROBE_BIT(col); | ||
118 | /* STROBE col -> out, not col -> HiZ */ | ||
119 | GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col); | ||
120 | } | ||
121 | |||
122 | #define GET_ROWS_STATUS(c) (((GPLR1 & CORGI_GPIO_HIGH_SENSE_BIT) >> CORGI_GPIO_HIGH_SENSE_RSHIFT) | ((GPLR2 & CORGI_GPIO_LOW_SENSE_BIT) << CORGI_GPIO_LOW_SENSE_LSHIFT)) | ||
123 | |||
124 | /* | ||
125 | * The corgi keyboard only generates interrupts when a key is pressed. | ||
126 | * When a key is pressed, we enable a timer which then scans the | ||
127 | * keyboard to detect when the key is released. | ||
128 | */ | ||
129 | |||
130 | /* Scan the hardware keyboard and push any changes up through the input layer */ | ||
131 | static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data) | ||
132 | { | ||
133 | unsigned int row, col, rowd; | ||
134 | unsigned long flags; | ||
135 | unsigned int num_pressed; | ||
136 | |||
137 | if (corgikbd_data->suspended) | ||
138 | return; | ||
139 | |||
140 | spin_lock_irqsave(&corgikbd_data->lock, flags); | ||
141 | |||
142 | num_pressed = 0; | ||
143 | for (col = 0; col < KB_COLS; col++) { | ||
144 | /* | ||
145 | * Discharge the output driver capacitatance | ||
146 | * in the keyboard matrix. (Yes it is significant..) | ||
147 | */ | ||
148 | |||
149 | corgikbd_discharge_all(); | ||
150 | udelay(KB_DISCHARGE_DELAY); | ||
151 | |||
152 | corgikbd_activate_col(col); | ||
153 | udelay(KB_ACTIVATE_DELAY); | ||
154 | |||
155 | rowd = GET_ROWS_STATUS(col); | ||
156 | for (row = 0; row < KB_ROWS; row++) { | ||
157 | unsigned int scancode, pressed; | ||
158 | |||
159 | scancode = SCANCODE(row, col); | ||
160 | pressed = rowd & KB_ROWMASK(row); | ||
161 | |||
162 | input_report_key(corgikbd_data->input, corgikbd_data->keycode[scancode], pressed); | ||
163 | |||
164 | if (pressed) | ||
165 | num_pressed++; | ||
166 | |||
167 | if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) | ||
168 | && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { | ||
169 | input_event(corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); | ||
170 | corgikbd_data->suspend_jiffies=jiffies; | ||
171 | } | ||
172 | } | ||
173 | corgikbd_reset_col(col); | ||
174 | } | ||
175 | |||
176 | corgikbd_activate_all(); | ||
177 | |||
178 | input_sync(corgikbd_data->input); | ||
179 | |||
180 | /* if any keys are pressed, enable the timer */ | ||
181 | if (num_pressed) | ||
182 | mod_timer(&corgikbd_data->timer, jiffies + msecs_to_jiffies(SCAN_INTERVAL)); | ||
183 | |||
184 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); | ||
185 | } | ||
186 | |||
187 | /* | ||
188 | * corgi keyboard interrupt handler. | ||
189 | */ | ||
190 | static irqreturn_t corgikbd_interrupt(int irq, void *dev_id) | ||
191 | { | ||
192 | struct corgikbd *corgikbd_data = dev_id; | ||
193 | |||
194 | if (!timer_pending(&corgikbd_data->timer)) { | ||
195 | /** wait chattering delay **/ | ||
196 | udelay(20); | ||
197 | corgikbd_scankeyboard(corgikbd_data); | ||
198 | } | ||
199 | |||
200 | return IRQ_HANDLED; | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * corgi timer checking for released keys | ||
205 | */ | ||
206 | static void corgikbd_timer_callback(unsigned long data) | ||
207 | { | ||
208 | struct corgikbd *corgikbd_data = (struct corgikbd *) data; | ||
209 | corgikbd_scankeyboard(corgikbd_data); | ||
210 | } | ||
211 | |||
212 | /* | ||
213 | * The hinge switches generate no interrupt so they need to be | ||
214 | * monitored by a timer. | ||
215 | * | ||
216 | * We debounce the switches and pass them to the input system. | ||
217 | * | ||
218 | * gprr == 0x00 - Keyboard with Landscape Screen | ||
219 | * 0x08 - No Keyboard with Portrait Screen | ||
220 | * 0x0c - Keyboard and Screen Closed | ||
221 | */ | ||
222 | |||
223 | #define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x)) | ||
224 | #define HINGE_STABLE_COUNT 2 | ||
225 | static int sharpsl_hinge_state; | ||
226 | static int hinge_count; | ||
227 | |||
228 | static void corgikbd_hinge_timer(unsigned long data) | ||
229 | { | ||
230 | struct corgikbd *corgikbd_data = (struct corgikbd *) data; | ||
231 | unsigned long gprr; | ||
232 | unsigned long flags; | ||
233 | |||
234 | gprr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_GPRR) & (CORGI_SCP_SWA | CORGI_SCP_SWB); | ||
235 | gprr |= (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0); | ||
236 | if (gprr != sharpsl_hinge_state) { | ||
237 | hinge_count = 0; | ||
238 | sharpsl_hinge_state = gprr; | ||
239 | } else if (hinge_count < HINGE_STABLE_COUNT) { | ||
240 | hinge_count++; | ||
241 | if (hinge_count >= HINGE_STABLE_COUNT) { | ||
242 | spin_lock_irqsave(&corgikbd_data->lock, flags); | ||
243 | |||
244 | input_report_switch(corgikbd_data->input, SW_LID, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); | ||
245 | input_report_switch(corgikbd_data->input, SW_TABLET_MODE, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); | ||
246 | input_report_switch(corgikbd_data->input, SW_HEADPHONE_INSERT, (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0)); | ||
247 | input_sync(corgikbd_data->input); | ||
248 | |||
249 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); | ||
250 | } | ||
251 | } | ||
252 | mod_timer(&corgikbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
253 | } | ||
254 | |||
255 | #ifdef CONFIG_PM | ||
256 | static int corgikbd_suspend(struct platform_device *dev, pm_message_t state) | ||
257 | { | ||
258 | int i; | ||
259 | struct corgikbd *corgikbd = platform_get_drvdata(dev); | ||
260 | |||
261 | corgikbd->suspended = 1; | ||
262 | /* strobe 0 is the power key so this can't be made an input for | ||
263 | powersaving therefore i = 1 */ | ||
264 | for (i = 1; i < CORGI_KEY_STROBE_NUM; i++) | ||
265 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_IN); | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | static int corgikbd_resume(struct platform_device *dev) | ||
271 | { | ||
272 | int i; | ||
273 | struct corgikbd *corgikbd = platform_get_drvdata(dev); | ||
274 | |||
275 | for (i = 1; i < CORGI_KEY_STROBE_NUM; i++) | ||
276 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); | ||
277 | |||
278 | /* Upon resume, ignore the suspend key for a short while */ | ||
279 | corgikbd->suspend_jiffies=jiffies; | ||
280 | corgikbd->suspended = 0; | ||
281 | |||
282 | return 0; | ||
283 | } | ||
284 | #else | ||
285 | #define corgikbd_suspend NULL | ||
286 | #define corgikbd_resume NULL | ||
287 | #endif | ||
288 | |||
289 | static int __devinit corgikbd_probe(struct platform_device *pdev) | ||
290 | { | ||
291 | struct corgikbd *corgikbd; | ||
292 | struct input_dev *input_dev; | ||
293 | int i, err = -ENOMEM; | ||
294 | |||
295 | corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); | ||
296 | input_dev = input_allocate_device(); | ||
297 | if (!corgikbd || !input_dev) | ||
298 | goto fail; | ||
299 | |||
300 | platform_set_drvdata(pdev, corgikbd); | ||
301 | |||
302 | corgikbd->input = input_dev; | ||
303 | spin_lock_init(&corgikbd->lock); | ||
304 | |||
305 | /* Init Keyboard rescan timer */ | ||
306 | init_timer(&corgikbd->timer); | ||
307 | corgikbd->timer.function = corgikbd_timer_callback; | ||
308 | corgikbd->timer.data = (unsigned long) corgikbd; | ||
309 | |||
310 | /* Init Hinge Timer */ | ||
311 | init_timer(&corgikbd->htimer); | ||
312 | corgikbd->htimer.function = corgikbd_hinge_timer; | ||
313 | corgikbd->htimer.data = (unsigned long) corgikbd; | ||
314 | |||
315 | corgikbd->suspend_jiffies=jiffies; | ||
316 | |||
317 | memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode)); | ||
318 | |||
319 | input_dev->name = "Corgi Keyboard"; | ||
320 | input_dev->phys = "corgikbd/input0"; | ||
321 | input_dev->id.bustype = BUS_HOST; | ||
322 | input_dev->id.vendor = 0x0001; | ||
323 | input_dev->id.product = 0x0001; | ||
324 | input_dev->id.version = 0x0100; | ||
325 | input_dev->dev.parent = &pdev->dev; | ||
326 | |||
327 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | | ||
328 | BIT_MASK(EV_PWR) | BIT_MASK(EV_SW); | ||
329 | input_dev->keycode = corgikbd->keycode; | ||
330 | input_dev->keycodesize = sizeof(unsigned char); | ||
331 | input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode); | ||
332 | |||
333 | for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) | ||
334 | set_bit(corgikbd->keycode[i], input_dev->keybit); | ||
335 | clear_bit(0, input_dev->keybit); | ||
336 | set_bit(SW_LID, input_dev->swbit); | ||
337 | set_bit(SW_TABLET_MODE, input_dev->swbit); | ||
338 | set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); | ||
339 | |||
340 | err = input_register_device(corgikbd->input); | ||
341 | if (err) | ||
342 | goto fail; | ||
343 | |||
344 | mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
345 | |||
346 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | ||
347 | for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) { | ||
348 | pxa_gpio_mode(CORGI_GPIO_KEY_SENSE(i) | GPIO_IN); | ||
349 | if (request_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd_interrupt, | ||
350 | IRQF_DISABLED | IRQF_TRIGGER_RISING, | ||
351 | "corgikbd", corgikbd)) | ||
352 | printk(KERN_WARNING "corgikbd: Can't get IRQ: %d!\n", i); | ||
353 | } | ||
354 | |||
355 | /* Set Strobe lines as outputs - set high */ | ||
356 | for (i = 0; i < CORGI_KEY_STROBE_NUM; i++) | ||
357 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); | ||
358 | |||
359 | /* Setup the headphone jack as an input */ | ||
360 | pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN); | ||
361 | |||
362 | return 0; | ||
363 | |||
364 | fail: input_free_device(input_dev); | ||
365 | kfree(corgikbd); | ||
366 | return err; | ||
367 | } | ||
368 | |||
369 | static int __devexit corgikbd_remove(struct platform_device *pdev) | ||
370 | { | ||
371 | int i; | ||
372 | struct corgikbd *corgikbd = platform_get_drvdata(pdev); | ||
373 | |||
374 | for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) | ||
375 | free_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd); | ||
376 | |||
377 | del_timer_sync(&corgikbd->htimer); | ||
378 | del_timer_sync(&corgikbd->timer); | ||
379 | |||
380 | input_unregister_device(corgikbd->input); | ||
381 | |||
382 | kfree(corgikbd); | ||
383 | |||
384 | return 0; | ||
385 | } | ||
386 | |||
387 | static struct platform_driver corgikbd_driver = { | ||
388 | .probe = corgikbd_probe, | ||
389 | .remove = __devexit_p(corgikbd_remove), | ||
390 | .suspend = corgikbd_suspend, | ||
391 | .resume = corgikbd_resume, | ||
392 | .driver = { | ||
393 | .name = "corgi-keyboard", | ||
394 | .owner = THIS_MODULE, | ||
395 | }, | ||
396 | }; | ||
397 | |||
398 | static int __init corgikbd_init(void) | ||
399 | { | ||
400 | return platform_driver_register(&corgikbd_driver); | ||
401 | } | ||
402 | |||
403 | static void __exit corgikbd_exit(void) | ||
404 | { | ||
405 | platform_driver_unregister(&corgikbd_driver); | ||
406 | } | ||
407 | |||
408 | module_init(corgikbd_init); | ||
409 | module_exit(corgikbd_exit); | ||
410 | |||
411 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | ||
412 | MODULE_DESCRIPTION("Corgi Keyboard Driver"); | ||
413 | MODULE_LICENSE("GPL v2"); | ||
414 | MODULE_ALIAS("platform:corgi-keyboard"); | ||
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c deleted file mode 100644 index 13967422658..00000000000 --- a/drivers/input/keyboard/spitzkbd.c +++ /dev/null | |||
@@ -1,496 +0,0 @@ | |||
1 | /* | ||
2 | * Keyboard driver for Sharp Spitz, Borzoi and Akita (SL-Cxx00 series) | ||
3 | * | ||
4 | * Copyright (c) 2005 Richard Purdie | ||
5 | * | ||
6 | * Based on corgikbd.c | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/delay.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/input.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/jiffies.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | #include <mach/spitz.h> | ||
24 | #include <mach/pxa2xx-gpio.h> | ||
25 | |||
26 | #define KB_ROWS 7 | ||
27 | #define KB_COLS 11 | ||
28 | #define KB_ROWMASK(r) (1 << (r)) | ||
29 | #define SCANCODE(r,c) (((r)<<4) + (c) + 1) | ||
30 | #define NR_SCANCODES ((KB_ROWS<<4) + 1) | ||
31 | |||
32 | #define SCAN_INTERVAL (50) /* ms */ | ||
33 | #define HINGE_SCAN_INTERVAL (150) /* ms */ | ||
34 | |||
35 | #define SPITZ_KEY_CALENDER KEY_F1 | ||
36 | #define SPITZ_KEY_ADDRESS KEY_F2 | ||
37 | #define SPITZ_KEY_FN KEY_F3 | ||
38 | #define SPITZ_KEY_CANCEL KEY_F4 | ||
39 | #define SPITZ_KEY_EXOK KEY_F5 | ||
40 | #define SPITZ_KEY_EXCANCEL KEY_F6 | ||
41 | #define SPITZ_KEY_EXJOGDOWN KEY_F7 | ||
42 | #define SPITZ_KEY_EXJOGUP KEY_F8 | ||
43 | #define SPITZ_KEY_JAP1 KEY_LEFTALT | ||
44 | #define SPITZ_KEY_JAP2 KEY_RIGHTCTRL | ||
45 | #define SPITZ_KEY_SYNC KEY_F9 | ||
46 | #define SPITZ_KEY_MAIL KEY_F10 | ||
47 | #define SPITZ_KEY_OK KEY_F11 | ||
48 | #define SPITZ_KEY_MENU KEY_F12 | ||
49 | |||
50 | static unsigned char spitzkbd_keycode[NR_SCANCODES] = { | ||
51 | 0, /* 0 */ | ||
52 | KEY_LEFTCTRL, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, SPITZ_KEY_EXOK, SPITZ_KEY_EXCANCEL, 0, 0, 0, 0, 0, /* 1-16 */ | ||
53 | 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, SPITZ_KEY_EXJOGDOWN, SPITZ_KEY_EXJOGUP, 0, 0, 0, 0, 0, /* 17-32 */ | ||
54 | KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ | ||
55 | SPITZ_KEY_ADDRESS, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */ | ||
56 | SPITZ_KEY_CALENDER, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, /* 65-80 */ | ||
57 | SPITZ_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, SPITZ_KEY_FN, 0, 0, 0, 0, 0, /* 81-96 */ | ||
58 | KEY_SYSRQ, SPITZ_KEY_JAP1, SPITZ_KEY_JAP2, SPITZ_KEY_CANCEL, SPITZ_KEY_OK, SPITZ_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0 /* 97-112 */ | ||
59 | }; | ||
60 | |||
61 | static int spitz_strobes[] = { | ||
62 | SPITZ_GPIO_KEY_STROBE0, | ||
63 | SPITZ_GPIO_KEY_STROBE1, | ||
64 | SPITZ_GPIO_KEY_STROBE2, | ||
65 | SPITZ_GPIO_KEY_STROBE3, | ||
66 | SPITZ_GPIO_KEY_STROBE4, | ||
67 | SPITZ_GPIO_KEY_STROBE5, | ||
68 | SPITZ_GPIO_KEY_STROBE6, | ||
69 | SPITZ_GPIO_KEY_STROBE7, | ||
70 | SPITZ_GPIO_KEY_STROBE8, | ||
71 | SPITZ_GPIO_KEY_STROBE9, | ||
72 | SPITZ_GPIO_KEY_STROBE10, | ||
73 | }; | ||
74 | |||
75 | static int spitz_senses[] = { | ||
76 | SPITZ_GPIO_KEY_SENSE0, | ||
77 | SPITZ_GPIO_KEY_SENSE1, | ||
78 | SPITZ_GPIO_KEY_SENSE2, | ||
79 | SPITZ_GPIO_KEY_SENSE3, | ||
80 | SPITZ_GPIO_KEY_SENSE4, | ||
81 | SPITZ_GPIO_KEY_SENSE5, | ||
82 | SPITZ_GPIO_KEY_SENSE6, | ||
83 | }; | ||
84 | |||
85 | struct spitzkbd { | ||
86 | unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)]; | ||
87 | struct input_dev *input; | ||
88 | char phys[32]; | ||
89 | |||
90 | spinlock_t lock; | ||
91 | struct timer_list timer; | ||
92 | struct timer_list htimer; | ||
93 | |||
94 | unsigned int suspended; | ||
95 | unsigned long suspend_jiffies; | ||
96 | }; | ||
97 | |||
98 | #define KB_DISCHARGE_DELAY 10 | ||
99 | #define KB_ACTIVATE_DELAY 10 | ||
100 | |||
101 | /* Helper functions for reading the keyboard matrix | ||
102 | * Note: We should really be using the generic gpio functions to alter | ||
103 | * GPDR but it requires a function call per GPIO bit which is | ||
104 | * excessive when we need to access 11 bits at once, multiple times. | ||
105 | * These functions must be called within local_irq_save()/local_irq_restore() | ||
106 | * or similar. | ||
107 | */ | ||
108 | static inline void spitzkbd_discharge_all(void) | ||
109 | { | ||
110 | /* STROBE All HiZ */ | ||
111 | GPCR0 = SPITZ_GPIO_G0_STROBE_BIT; | ||
112 | GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT; | ||
113 | GPCR1 = SPITZ_GPIO_G1_STROBE_BIT; | ||
114 | GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT; | ||
115 | GPCR2 = SPITZ_GPIO_G2_STROBE_BIT; | ||
116 | GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT; | ||
117 | GPCR3 = SPITZ_GPIO_G3_STROBE_BIT; | ||
118 | GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT; | ||
119 | } | ||
120 | |||
121 | static inline void spitzkbd_activate_all(void) | ||
122 | { | ||
123 | /* STROBE ALL -> High */ | ||
124 | GPSR0 = SPITZ_GPIO_G0_STROBE_BIT; | ||
125 | GPDR0 |= SPITZ_GPIO_G0_STROBE_BIT; | ||
126 | GPSR1 = SPITZ_GPIO_G1_STROBE_BIT; | ||
127 | GPDR1 |= SPITZ_GPIO_G1_STROBE_BIT; | ||
128 | GPSR2 = SPITZ_GPIO_G2_STROBE_BIT; | ||
129 | GPDR2 |= SPITZ_GPIO_G2_STROBE_BIT; | ||
130 | GPSR3 = SPITZ_GPIO_G3_STROBE_BIT; | ||
131 | GPDR3 |= SPITZ_GPIO_G3_STROBE_BIT; | ||
132 | |||
133 | udelay(KB_DISCHARGE_DELAY); | ||
134 | |||
135 | /* Clear any interrupts we may have triggered when altering the GPIO lines */ | ||
136 | GEDR0 = SPITZ_GPIO_G0_SENSE_BIT; | ||
137 | GEDR1 = SPITZ_GPIO_G1_SENSE_BIT; | ||
138 | GEDR2 = SPITZ_GPIO_G2_SENSE_BIT; | ||
139 | GEDR3 = SPITZ_GPIO_G3_SENSE_BIT; | ||
140 | } | ||
141 | |||
142 | static inline void spitzkbd_activate_col(int col) | ||
143 | { | ||
144 | int gpio = spitz_strobes[col]; | ||
145 | GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT; | ||
146 | GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT; | ||
147 | GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT; | ||
148 | GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT; | ||
149 | GPSR(gpio) = GPIO_bit(gpio); | ||
150 | GPDR(gpio) |= GPIO_bit(gpio); | ||
151 | } | ||
152 | |||
153 | static inline void spitzkbd_reset_col(int col) | ||
154 | { | ||
155 | int gpio = spitz_strobes[col]; | ||
156 | GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT; | ||
157 | GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT; | ||
158 | GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT; | ||
159 | GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT; | ||
160 | GPCR(gpio) = GPIO_bit(gpio); | ||
161 | GPDR(gpio) |= GPIO_bit(gpio); | ||
162 | } | ||
163 | |||
164 | static inline int spitzkbd_get_row_status(int col) | ||
165 | { | ||
166 | return ((GPLR0 >> 12) & 0x01) | ((GPLR0 >> 16) & 0x02) | ||
167 | | ((GPLR2 >> 25) & 0x04) | ((GPLR1 << 1) & 0x08) | ||
168 | | ((GPLR1 >> 0) & 0x10) | ((GPLR1 >> 1) & 0x60); | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * The spitz keyboard only generates interrupts when a key is pressed. | ||
173 | * When a key is pressed, we enable a timer which then scans the | ||
174 | * keyboard to detect when the key is released. | ||
175 | */ | ||
176 | |||
177 | /* Scan the hardware keyboard and push any changes up through the input layer */ | ||
178 | static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data) | ||
179 | { | ||
180 | unsigned int row, col, rowd; | ||
181 | unsigned long flags; | ||
182 | unsigned int num_pressed, pwrkey = ((GPLR(SPITZ_GPIO_ON_KEY) & GPIO_bit(SPITZ_GPIO_ON_KEY)) != 0); | ||
183 | |||
184 | if (spitzkbd_data->suspended) | ||
185 | return; | ||
186 | |||
187 | spin_lock_irqsave(&spitzkbd_data->lock, flags); | ||
188 | |||
189 | num_pressed = 0; | ||
190 | for (col = 0; col < KB_COLS; col++) { | ||
191 | /* | ||
192 | * Discharge the output driver capacitatance | ||
193 | * in the keyboard matrix. (Yes it is significant..) | ||
194 | */ | ||
195 | |||
196 | spitzkbd_discharge_all(); | ||
197 | udelay(KB_DISCHARGE_DELAY); | ||
198 | |||
199 | spitzkbd_activate_col(col); | ||
200 | udelay(KB_ACTIVATE_DELAY); | ||
201 | |||
202 | rowd = spitzkbd_get_row_status(col); | ||
203 | for (row = 0; row < KB_ROWS; row++) { | ||
204 | unsigned int scancode, pressed; | ||
205 | |||
206 | scancode = SCANCODE(row, col); | ||
207 | pressed = rowd & KB_ROWMASK(row); | ||
208 | |||
209 | input_report_key(spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed); | ||
210 | |||
211 | if (pressed) | ||
212 | num_pressed++; | ||
213 | } | ||
214 | spitzkbd_reset_col(col); | ||
215 | } | ||
216 | |||
217 | spitzkbd_activate_all(); | ||
218 | |||
219 | input_report_key(spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 ); | ||
220 | input_report_key(spitzkbd_data->input, KEY_SUSPEND, pwrkey); | ||
221 | |||
222 | if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) { | ||
223 | input_event(spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1); | ||
224 | spitzkbd_data->suspend_jiffies = jiffies; | ||
225 | } | ||
226 | |||
227 | input_sync(spitzkbd_data->input); | ||
228 | |||
229 | /* if any keys are pressed, enable the timer */ | ||
230 | if (num_pressed) | ||
231 | mod_timer(&spitzkbd_data->timer, jiffies + msecs_to_jiffies(SCAN_INTERVAL)); | ||
232 | |||
233 | spin_unlock_irqrestore(&spitzkbd_data->lock, flags); | ||
234 | } | ||
235 | |||
236 | /* | ||
237 | * spitz keyboard interrupt handler. | ||
238 | */ | ||
239 | static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id) | ||
240 | { | ||
241 | struct spitzkbd *spitzkbd_data = dev_id; | ||
242 | |||
243 | if (!timer_pending(&spitzkbd_data->timer)) { | ||
244 | /** wait chattering delay **/ | ||
245 | udelay(20); | ||
246 | spitzkbd_scankeyboard(spitzkbd_data); | ||
247 | } | ||
248 | |||
249 | return IRQ_HANDLED; | ||
250 | } | ||
251 | |||
252 | /* | ||
253 | * spitz timer checking for released keys | ||
254 | */ | ||
255 | static void spitzkbd_timer_callback(unsigned long data) | ||
256 | { | ||
257 | struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; | ||
258 | |||
259 | spitzkbd_scankeyboard(spitzkbd_data); | ||
260 | } | ||
261 | |||
262 | /* | ||
263 | * The hinge switches generate an interrupt. | ||
264 | * We debounce the switches and pass them to the input system. | ||
265 | */ | ||
266 | |||
267 | static irqreturn_t spitzkbd_hinge_isr(int irq, void *dev_id) | ||
268 | { | ||
269 | struct spitzkbd *spitzkbd_data = dev_id; | ||
270 | |||
271 | if (!timer_pending(&spitzkbd_data->htimer)) | ||
272 | mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
273 | |||
274 | return IRQ_HANDLED; | ||
275 | } | ||
276 | |||
277 | #define HINGE_STABLE_COUNT 2 | ||
278 | static int sharpsl_hinge_state; | ||
279 | static int hinge_count; | ||
280 | |||
281 | static void spitzkbd_hinge_timer(unsigned long data) | ||
282 | { | ||
283 | struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; | ||
284 | unsigned long state; | ||
285 | unsigned long flags; | ||
286 | |||
287 | state = GPLR(SPITZ_GPIO_SWA) & (GPIO_bit(SPITZ_GPIO_SWA)|GPIO_bit(SPITZ_GPIO_SWB)); | ||
288 | state |= (GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT)); | ||
289 | if (state != sharpsl_hinge_state) { | ||
290 | hinge_count = 0; | ||
291 | sharpsl_hinge_state = state; | ||
292 | } else if (hinge_count < HINGE_STABLE_COUNT) { | ||
293 | hinge_count++; | ||
294 | } | ||
295 | |||
296 | if (hinge_count >= HINGE_STABLE_COUNT) { | ||
297 | spin_lock_irqsave(&spitzkbd_data->lock, flags); | ||
298 | |||
299 | input_report_switch(spitzkbd_data->input, SW_LID, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); | ||
300 | input_report_switch(spitzkbd_data->input, SW_TABLET_MODE, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); | ||
301 | input_report_switch(spitzkbd_data->input, SW_HEADPHONE_INSERT, ((GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT)) != 0)); | ||
302 | input_sync(spitzkbd_data->input); | ||
303 | |||
304 | spin_unlock_irqrestore(&spitzkbd_data->lock, flags); | ||
305 | } else { | ||
306 | mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | #ifdef CONFIG_PM | ||
311 | static int spitzkbd_suspend(struct platform_device *dev, pm_message_t state) | ||
312 | { | ||
313 | int i; | ||
314 | struct spitzkbd *spitzkbd = platform_get_drvdata(dev); | ||
315 | spitzkbd->suspended = 1; | ||
316 | |||
317 | /* Set Strobe lines as inputs - *except* strobe line 0 leave this | ||
318 | enabled so we can detect a power button press for resume */ | ||
319 | for (i = 1; i < SPITZ_KEY_STROBE_NUM; i++) | ||
320 | pxa_gpio_mode(spitz_strobes[i] | GPIO_IN); | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | static int spitzkbd_resume(struct platform_device *dev) | ||
326 | { | ||
327 | int i; | ||
328 | struct spitzkbd *spitzkbd = platform_get_drvdata(dev); | ||
329 | |||
330 | for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) | ||
331 | pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); | ||
332 | |||
333 | /* Upon resume, ignore the suspend key for a short while */ | ||
334 | spitzkbd->suspend_jiffies = jiffies; | ||
335 | spitzkbd->suspended = 0; | ||
336 | |||
337 | return 0; | ||
338 | } | ||
339 | #else | ||
340 | #define spitzkbd_suspend NULL | ||
341 | #define spitzkbd_resume NULL | ||
342 | #endif | ||
343 | |||
344 | static int __devinit spitzkbd_probe(struct platform_device *dev) | ||
345 | { | ||
346 | struct spitzkbd *spitzkbd; | ||
347 | struct input_dev *input_dev; | ||
348 | int i, err = -ENOMEM; | ||
349 | |||
350 | spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); | ||
351 | input_dev = input_allocate_device(); | ||
352 | if (!spitzkbd || !input_dev) | ||
353 | goto fail; | ||
354 | |||
355 | platform_set_drvdata(dev, spitzkbd); | ||
356 | strcpy(spitzkbd->phys, "spitzkbd/input0"); | ||
357 | |||
358 | spin_lock_init(&spitzkbd->lock); | ||
359 | |||
360 | /* Init Keyboard rescan timer */ | ||
361 | init_timer(&spitzkbd->timer); | ||
362 | spitzkbd->timer.function = spitzkbd_timer_callback; | ||
363 | spitzkbd->timer.data = (unsigned long) spitzkbd; | ||
364 | |||
365 | /* Init Hinge Timer */ | ||
366 | init_timer(&spitzkbd->htimer); | ||
367 | spitzkbd->htimer.function = spitzkbd_hinge_timer; | ||
368 | spitzkbd->htimer.data = (unsigned long) spitzkbd; | ||
369 | |||
370 | spitzkbd->suspend_jiffies = jiffies; | ||
371 | |||
372 | spitzkbd->input = input_dev; | ||
373 | |||
374 | input_dev->name = "Spitz Keyboard"; | ||
375 | input_dev->phys = spitzkbd->phys; | ||
376 | input_dev->dev.parent = &dev->dev; | ||
377 | |||
378 | input_dev->id.bustype = BUS_HOST; | ||
379 | input_dev->id.vendor = 0x0001; | ||
380 | input_dev->id.product = 0x0001; | ||
381 | input_dev->id.version = 0x0100; | ||
382 | |||
383 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | | ||
384 | BIT_MASK(EV_PWR) | BIT_MASK(EV_SW); | ||
385 | input_dev->keycode = spitzkbd->keycode; | ||
386 | input_dev->keycodesize = sizeof(unsigned char); | ||
387 | input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode); | ||
388 | |||
389 | memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode)); | ||
390 | for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++) | ||
391 | set_bit(spitzkbd->keycode[i], input_dev->keybit); | ||
392 | clear_bit(0, input_dev->keybit); | ||
393 | set_bit(KEY_SUSPEND, input_dev->keybit); | ||
394 | set_bit(SW_LID, input_dev->swbit); | ||
395 | set_bit(SW_TABLET_MODE, input_dev->swbit); | ||
396 | set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); | ||
397 | |||
398 | err = input_register_device(input_dev); | ||
399 | if (err) | ||
400 | goto fail; | ||
401 | |||
402 | mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
403 | |||
404 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | ||
405 | for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) { | ||
406 | pxa_gpio_mode(spitz_senses[i] | GPIO_IN); | ||
407 | if (request_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd_interrupt, | ||
408 | IRQF_DISABLED|IRQF_TRIGGER_RISING, | ||
409 | "Spitzkbd Sense", spitzkbd)) | ||
410 | printk(KERN_WARNING "spitzkbd: Can't get Sense IRQ: %d!\n", i); | ||
411 | } | ||
412 | |||
413 | /* Set Strobe lines as outputs - set high */ | ||
414 | for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) | ||
415 | pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); | ||
416 | |||
417 | pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN); | ||
418 | pxa_gpio_mode(SPITZ_GPIO_ON_KEY | GPIO_IN); | ||
419 | pxa_gpio_mode(SPITZ_GPIO_SWA | GPIO_IN); | ||
420 | pxa_gpio_mode(SPITZ_GPIO_SWB | GPIO_IN); | ||
421 | |||
422 | request_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd_interrupt, | ||
423 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
424 | "Spitzkbd Sync", spitzkbd); | ||
425 | request_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd_interrupt, | ||
426 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
427 | "Spitzkbd PwrOn", spitzkbd); | ||
428 | request_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd_hinge_isr, | ||
429 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
430 | "Spitzkbd SWA", spitzkbd); | ||
431 | request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr, | ||
432 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
433 | "Spitzkbd SWB", spitzkbd); | ||
434 | request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr, | ||
435 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
436 | "Spitzkbd HP", spitzkbd); | ||
437 | |||
438 | return 0; | ||
439 | |||
440 | fail: input_free_device(input_dev); | ||
441 | kfree(spitzkbd); | ||
442 | return err; | ||
443 | } | ||
444 | |||
445 | static int __devexit spitzkbd_remove(struct platform_device *dev) | ||
446 | { | ||
447 | int i; | ||
448 | struct spitzkbd *spitzkbd = platform_get_drvdata(dev); | ||
449 | |||
450 | for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) | ||
451 | free_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd); | ||
452 | |||
453 | free_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd); | ||
454 | free_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd); | ||
455 | free_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd); | ||
456 | free_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd); | ||
457 | free_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd); | ||
458 | |||
459 | del_timer_sync(&spitzkbd->htimer); | ||
460 | del_timer_sync(&spitzkbd->timer); | ||
461 | |||
462 | input_unregister_device(spitzkbd->input); | ||
463 | |||
464 | kfree(spitzkbd); | ||
465 | |||
466 | return 0; | ||
467 | } | ||
468 | |||
469 | static struct platform_driver spitzkbd_driver = { | ||
470 | .probe = spitzkbd_probe, | ||
471 | .remove = __devexit_p(spitzkbd_remove), | ||
472 | .suspend = spitzkbd_suspend, | ||
473 | .resume = spitzkbd_resume, | ||
474 | .driver = { | ||
475 | .name = "spitz-keyboard", | ||
476 | .owner = THIS_MODULE, | ||
477 | }, | ||
478 | }; | ||
479 | |||
480 | static int __init spitzkbd_init(void) | ||
481 | { | ||
482 | return platform_driver_register(&spitzkbd_driver); | ||
483 | } | ||
484 | |||
485 | static void __exit spitzkbd_exit(void) | ||
486 | { | ||
487 | platform_driver_unregister(&spitzkbd_driver); | ||
488 | } | ||
489 | |||
490 | module_init(spitzkbd_init); | ||
491 | module_exit(spitzkbd_exit); | ||
492 | |||
493 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | ||
494 | MODULE_DESCRIPTION("Spitz Keyboard Driver"); | ||
495 | MODULE_LICENSE("GPL v2"); | ||
496 | MODULE_ALIAS("platform:spitz-keyboard"); | ||
diff --git a/drivers/input/keyboard/tosakbd.c b/drivers/input/keyboard/tosakbd.c deleted file mode 100644 index 3910f269cfc..00000000000 --- a/drivers/input/keyboard/tosakbd.c +++ /dev/null | |||
@@ -1,431 +0,0 @@ | |||
1 | /* | ||
2 | * Keyboard driver for Sharp Tosa models (SL-6000x) | ||
3 | * | ||
4 | * Copyright (c) 2005 Dirk Opfer | ||
5 | * Copyright (c) 2007 Dmitry Baryshkov | ||
6 | * | ||
7 | * Based on xtkbd.c/locomkbd.c/corgikbd.c | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/input.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | #include <mach/gpio.h> | ||
24 | #include <mach/tosa.h> | ||
25 | |||
26 | #define KB_ROWMASK(r) (1 << (r)) | ||
27 | #define SCANCODE(r, c) (((r)<<4) + (c) + 1) | ||
28 | #define NR_SCANCODES SCANCODE(TOSA_KEY_SENSE_NUM - 1, TOSA_KEY_STROBE_NUM - 1) + 1 | ||
29 | |||
30 | #define SCAN_INTERVAL (HZ/10) | ||
31 | |||
32 | #define KB_DISCHARGE_DELAY 10 | ||
33 | #define KB_ACTIVATE_DELAY 10 | ||
34 | |||
35 | static unsigned short tosakbd_keycode[NR_SCANCODES] = { | ||
36 | 0, | ||
37 | 0, KEY_W, 0, 0, 0, KEY_K, KEY_BACKSPACE, KEY_P, | ||
38 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
39 | KEY_Q, KEY_E, KEY_T, KEY_Y, 0, KEY_O, KEY_I, KEY_COMMA, | ||
40 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
41 | KEY_A, KEY_D, KEY_G, KEY_U, 0, KEY_L, KEY_ENTER, KEY_DOT, | ||
42 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
43 | KEY_Z, KEY_C, KEY_V, KEY_J, TOSA_KEY_ADDRESSBOOK, TOSA_KEY_CANCEL, TOSA_KEY_CENTER, TOSA_KEY_OK, | ||
44 | KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, 0, | ||
45 | KEY_S, KEY_R, KEY_B, KEY_N, TOSA_KEY_CALENDAR, TOSA_KEY_HOMEPAGE, KEY_LEFTCTRL, TOSA_KEY_LIGHT, | ||
46 | 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, | ||
47 | KEY_TAB, KEY_SLASH, KEY_H, KEY_M, TOSA_KEY_MENU, 0, KEY_UP, 0, | ||
48 | 0, 0, TOSA_KEY_FN, 0, 0, 0, 0, 0, | ||
49 | KEY_X, KEY_F, KEY_SPACE, KEY_APOSTROPHE, TOSA_KEY_MAIL, KEY_LEFT, KEY_DOWN, KEY_RIGHT, | ||
50 | 0, 0, 0, | ||
51 | }; | ||
52 | |||
53 | struct tosakbd { | ||
54 | unsigned short keycode[ARRAY_SIZE(tosakbd_keycode)]; | ||
55 | struct input_dev *input; | ||
56 | bool suspended; | ||
57 | spinlock_t lock; /* protect kbd scanning */ | ||
58 | struct timer_list timer; | ||
59 | }; | ||
60 | |||
61 | |||
62 | /* Helper functions for reading the keyboard matrix | ||
63 | * Note: We should really be using the generic gpio functions to alter | ||
64 | * GPDR but it requires a function call per GPIO bit which is | ||
65 | * excessive when we need to access 12 bits at once, multiple times. | ||
66 | * These functions must be called within local_irq_save()/local_irq_restore() | ||
67 | * or similar. | ||
68 | */ | ||
69 | #define GET_ROWS_STATUS(c) ((GPLR2 & TOSA_GPIO_ALL_SENSE_BIT) >> TOSA_GPIO_ALL_SENSE_RSHIFT) | ||
70 | |||
71 | static inline void tosakbd_discharge_all(void) | ||
72 | { | ||
73 | /* STROBE All HiZ */ | ||
74 | GPCR1 = TOSA_GPIO_HIGH_STROBE_BIT; | ||
75 | GPDR1 &= ~TOSA_GPIO_HIGH_STROBE_BIT; | ||
76 | GPCR2 = TOSA_GPIO_LOW_STROBE_BIT; | ||
77 | GPDR2 &= ~TOSA_GPIO_LOW_STROBE_BIT; | ||
78 | } | ||
79 | |||
80 | static inline void tosakbd_activate_all(void) | ||
81 | { | ||
82 | /* STROBE ALL -> High */ | ||
83 | GPSR1 = TOSA_GPIO_HIGH_STROBE_BIT; | ||
84 | GPDR1 |= TOSA_GPIO_HIGH_STROBE_BIT; | ||
85 | GPSR2 = TOSA_GPIO_LOW_STROBE_BIT; | ||
86 | GPDR2 |= TOSA_GPIO_LOW_STROBE_BIT; | ||
87 | |||
88 | udelay(KB_DISCHARGE_DELAY); | ||
89 | |||
90 | /* STATE CLEAR */ | ||
91 | GEDR2 |= TOSA_GPIO_ALL_SENSE_BIT; | ||
92 | } | ||
93 | |||
94 | static inline void tosakbd_activate_col(int col) | ||
95 | { | ||
96 | if (col <= 5) { | ||
97 | /* STROBE col -> High, not col -> HiZ */ | ||
98 | GPSR1 = TOSA_GPIO_STROBE_BIT(col); | ||
99 | GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col); | ||
100 | } else { | ||
101 | /* STROBE col -> High, not col -> HiZ */ | ||
102 | GPSR2 = TOSA_GPIO_STROBE_BIT(col); | ||
103 | GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | static inline void tosakbd_reset_col(int col) | ||
108 | { | ||
109 | if (col <= 5) { | ||
110 | /* STROBE col -> Low */ | ||
111 | GPCR1 = TOSA_GPIO_STROBE_BIT(col); | ||
112 | /* STROBE col -> out, not col -> HiZ */ | ||
113 | GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col); | ||
114 | } else { | ||
115 | /* STROBE col -> Low */ | ||
116 | GPCR2 = TOSA_GPIO_STROBE_BIT(col); | ||
117 | /* STROBE col -> out, not col -> HiZ */ | ||
118 | GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col); | ||
119 | } | ||
120 | } | ||
121 | /* | ||
122 | * The tosa keyboard only generates interrupts when a key is pressed. | ||
123 | * So when a key is pressed, we enable a timer. This timer scans the | ||
124 | * keyboard, and this is how we detect when the key is released. | ||
125 | */ | ||
126 | |||
127 | /* Scan the hardware keyboard and push any changes up through the input layer */ | ||
128 | static void tosakbd_scankeyboard(struct platform_device *dev) | ||
129 | { | ||
130 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
131 | unsigned int row, col, rowd; | ||
132 | unsigned long flags; | ||
133 | unsigned int num_pressed = 0; | ||
134 | |||
135 | spin_lock_irqsave(&tosakbd->lock, flags); | ||
136 | |||
137 | if (tosakbd->suspended) | ||
138 | goto out; | ||
139 | |||
140 | for (col = 0; col < TOSA_KEY_STROBE_NUM; col++) { | ||
141 | /* | ||
142 | * Discharge the output driver capacitatance | ||
143 | * in the keyboard matrix. (Yes it is significant..) | ||
144 | */ | ||
145 | tosakbd_discharge_all(); | ||
146 | udelay(KB_DISCHARGE_DELAY); | ||
147 | |||
148 | tosakbd_activate_col(col); | ||
149 | udelay(KB_ACTIVATE_DELAY); | ||
150 | |||
151 | rowd = GET_ROWS_STATUS(col); | ||
152 | |||
153 | for (row = 0; row < TOSA_KEY_SENSE_NUM; row++) { | ||
154 | unsigned int scancode, pressed; | ||
155 | scancode = SCANCODE(row, col); | ||
156 | pressed = rowd & KB_ROWMASK(row); | ||
157 | |||
158 | if (pressed && !tosakbd->keycode[scancode]) | ||
159 | dev_warn(&dev->dev, | ||
160 | "unhandled scancode: 0x%02x\n", | ||
161 | scancode); | ||
162 | |||
163 | input_report_key(tosakbd->input, | ||
164 | tosakbd->keycode[scancode], | ||
165 | pressed); | ||
166 | if (pressed) | ||
167 | num_pressed++; | ||
168 | } | ||
169 | |||
170 | tosakbd_reset_col(col); | ||
171 | } | ||
172 | |||
173 | tosakbd_activate_all(); | ||
174 | |||
175 | input_sync(tosakbd->input); | ||
176 | |||
177 | /* if any keys are pressed, enable the timer */ | ||
178 | if (num_pressed) | ||
179 | mod_timer(&tosakbd->timer, jiffies + SCAN_INTERVAL); | ||
180 | |||
181 | out: | ||
182 | spin_unlock_irqrestore(&tosakbd->lock, flags); | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | * tosa keyboard interrupt handler. | ||
187 | */ | ||
188 | static irqreturn_t tosakbd_interrupt(int irq, void *__dev) | ||
189 | { | ||
190 | struct platform_device *dev = __dev; | ||
191 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
192 | |||
193 | if (!timer_pending(&tosakbd->timer)) { | ||
194 | /** wait chattering delay **/ | ||
195 | udelay(20); | ||
196 | tosakbd_scankeyboard(dev); | ||
197 | } | ||
198 | |||
199 | return IRQ_HANDLED; | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * tosa timer checking for released keys | ||
204 | */ | ||
205 | static void tosakbd_timer_callback(unsigned long __dev) | ||
206 | { | ||
207 | struct platform_device *dev = (struct platform_device *)__dev; | ||
208 | |||
209 | tosakbd_scankeyboard(dev); | ||
210 | } | ||
211 | |||
212 | #ifdef CONFIG_PM | ||
213 | static int tosakbd_suspend(struct platform_device *dev, pm_message_t state) | ||
214 | { | ||
215 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
216 | unsigned long flags; | ||
217 | |||
218 | spin_lock_irqsave(&tosakbd->lock, flags); | ||
219 | tosakbd->suspended = true; | ||
220 | spin_unlock_irqrestore(&tosakbd->lock, flags); | ||
221 | |||
222 | del_timer_sync(&tosakbd->timer); | ||
223 | |||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | static int tosakbd_resume(struct platform_device *dev) | ||
228 | { | ||
229 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
230 | |||
231 | tosakbd->suspended = false; | ||
232 | tosakbd_scankeyboard(dev); | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | #else | ||
237 | #define tosakbd_suspend NULL | ||
238 | #define tosakbd_resume NULL | ||
239 | #endif | ||
240 | |||
241 | static int __devinit tosakbd_probe(struct platform_device *pdev) { | ||
242 | |||
243 | int i; | ||
244 | struct tosakbd *tosakbd; | ||
245 | struct input_dev *input_dev; | ||
246 | int error; | ||
247 | |||
248 | tosakbd = kzalloc(sizeof(struct tosakbd), GFP_KERNEL); | ||
249 | if (!tosakbd) | ||
250 | return -ENOMEM; | ||
251 | |||
252 | input_dev = input_allocate_device(); | ||
253 | if (!input_dev) { | ||
254 | kfree(tosakbd); | ||
255 | return -ENOMEM; | ||
256 | } | ||
257 | |||
258 | platform_set_drvdata(pdev, tosakbd); | ||
259 | |||
260 | spin_lock_init(&tosakbd->lock); | ||
261 | |||
262 | /* Init Keyboard rescan timer */ | ||
263 | init_timer(&tosakbd->timer); | ||
264 | tosakbd->timer.function = tosakbd_timer_callback; | ||
265 | tosakbd->timer.data = (unsigned long) pdev; | ||
266 | |||
267 | tosakbd->input = input_dev; | ||
268 | |||
269 | input_set_drvdata(input_dev, tosakbd); | ||
270 | input_dev->name = "Tosa Keyboard"; | ||
271 | input_dev->phys = "tosakbd/input0"; | ||
272 | input_dev->dev.parent = &pdev->dev; | ||
273 | |||
274 | input_dev->id.bustype = BUS_HOST; | ||
275 | input_dev->id.vendor = 0x0001; | ||
276 | input_dev->id.product = 0x0001; | ||
277 | input_dev->id.version = 0x0100; | ||
278 | |||
279 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
280 | input_dev->keycode = tosakbd->keycode; | ||
281 | input_dev->keycodesize = sizeof(tosakbd->keycode[0]); | ||
282 | input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode); | ||
283 | |||
284 | memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode)); | ||
285 | |||
286 | for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++) | ||
287 | __set_bit(tosakbd->keycode[i], input_dev->keybit); | ||
288 | __clear_bit(KEY_RESERVED, input_dev->keybit); | ||
289 | |||
290 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | ||
291 | for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) { | ||
292 | int gpio = TOSA_GPIO_KEY_SENSE(i); | ||
293 | int irq; | ||
294 | error = gpio_request(gpio, "tosakbd"); | ||
295 | if (error < 0) { | ||
296 | printk(KERN_ERR "tosakbd: failed to request GPIO %d, " | ||
297 | " error %d\n", gpio, error); | ||
298 | goto fail; | ||
299 | } | ||
300 | |||
301 | error = gpio_direction_input(TOSA_GPIO_KEY_SENSE(i)); | ||
302 | if (error < 0) { | ||
303 | printk(KERN_ERR "tosakbd: failed to configure input" | ||
304 | " direction for GPIO %d, error %d\n", | ||
305 | gpio, error); | ||
306 | gpio_free(gpio); | ||
307 | goto fail; | ||
308 | } | ||
309 | |||
310 | irq = gpio_to_irq(gpio); | ||
311 | if (irq < 0) { | ||
312 | error = irq; | ||
313 | printk(KERN_ERR "gpio-keys: Unable to get irq number" | ||
314 | " for GPIO %d, error %d\n", | ||
315 | gpio, error); | ||
316 | gpio_free(gpio); | ||
317 | goto fail; | ||
318 | } | ||
319 | |||
320 | error = request_irq(irq, tosakbd_interrupt, | ||
321 | IRQF_DISABLED | IRQF_TRIGGER_RISING, | ||
322 | "tosakbd", pdev); | ||
323 | |||
324 | if (error) { | ||
325 | printk("tosakbd: Can't get IRQ: %d: error %d!\n", | ||
326 | irq, error); | ||
327 | gpio_free(gpio); | ||
328 | goto fail; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | /* Set Strobe lines as outputs - set high */ | ||
333 | for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) { | ||
334 | int gpio = TOSA_GPIO_KEY_STROBE(i); | ||
335 | error = gpio_request(gpio, "tosakbd"); | ||
336 | if (error < 0) { | ||
337 | printk(KERN_ERR "tosakbd: failed to request GPIO %d, " | ||
338 | " error %d\n", gpio, error); | ||
339 | goto fail2; | ||
340 | } | ||
341 | |||
342 | error = gpio_direction_output(gpio, 1); | ||
343 | if (error < 0) { | ||
344 | printk(KERN_ERR "tosakbd: failed to configure input" | ||
345 | " direction for GPIO %d, error %d\n", | ||
346 | gpio, error); | ||
347 | gpio_free(gpio); | ||
348 | goto fail2; | ||
349 | } | ||
350 | |||
351 | } | ||
352 | |||
353 | error = input_register_device(input_dev); | ||
354 | if (error) { | ||
355 | printk(KERN_ERR "tosakbd: Unable to register input device, " | ||
356 | "error: %d\n", error); | ||
357 | goto fail2; | ||
358 | } | ||
359 | |||
360 | printk(KERN_INFO "input: Tosa Keyboard Registered\n"); | ||
361 | |||
362 | return 0; | ||
363 | |||
364 | fail2: | ||
365 | while (--i >= 0) | ||
366 | gpio_free(TOSA_GPIO_KEY_STROBE(i)); | ||
367 | |||
368 | i = TOSA_KEY_SENSE_NUM; | ||
369 | fail: | ||
370 | while (--i >= 0) { | ||
371 | free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), pdev); | ||
372 | gpio_free(TOSA_GPIO_KEY_SENSE(i)); | ||
373 | } | ||
374 | |||
375 | platform_set_drvdata(pdev, NULL); | ||
376 | input_free_device(input_dev); | ||
377 | kfree(tosakbd); | ||
378 | |||
379 | return error; | ||
380 | } | ||
381 | |||
382 | static int __devexit tosakbd_remove(struct platform_device *dev) | ||
383 | { | ||
384 | int i; | ||
385 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
386 | |||
387 | for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) | ||
388 | gpio_free(TOSA_GPIO_KEY_STROBE(i)); | ||
389 | |||
390 | for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) { | ||
391 | free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), dev); | ||
392 | gpio_free(TOSA_GPIO_KEY_SENSE(i)); | ||
393 | } | ||
394 | |||
395 | del_timer_sync(&tosakbd->timer); | ||
396 | |||
397 | input_unregister_device(tosakbd->input); | ||
398 | |||
399 | kfree(tosakbd); | ||
400 | |||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | static struct platform_driver tosakbd_driver = { | ||
405 | .probe = tosakbd_probe, | ||
406 | .remove = __devexit_p(tosakbd_remove), | ||
407 | .suspend = tosakbd_suspend, | ||
408 | .resume = tosakbd_resume, | ||
409 | .driver = { | ||
410 | .name = "tosa-keyboard", | ||
411 | .owner = THIS_MODULE, | ||
412 | }, | ||
413 | }; | ||
414 | |||
415 | static int __devinit tosakbd_init(void) | ||
416 | { | ||
417 | return platform_driver_register(&tosakbd_driver); | ||
418 | } | ||
419 | |||
420 | static void __exit tosakbd_exit(void) | ||
421 | { | ||
422 | platform_driver_unregister(&tosakbd_driver); | ||
423 | } | ||
424 | |||
425 | module_init(tosakbd_init); | ||
426 | module_exit(tosakbd_exit); | ||
427 | |||
428 | MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>"); | ||
429 | MODULE_DESCRIPTION("Tosa Keyboard Driver"); | ||
430 | MODULE_LICENSE("GPL v2"); | ||
431 | MODULE_ALIAS("platform:tosa-keyboard"); | ||
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 8a8fa4d2d6a..3d1ade2e519 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -99,22 +99,6 @@ config TOUCHSCREEN_BITSY | |||
99 | To compile this driver as a module, choose M here: the | 99 | To compile this driver as a module, choose M here: the |
100 | module will be called h3600_ts_input. | 100 | module will be called h3600_ts_input. |
101 | 101 | ||
102 | config TOUCHSCREEN_CORGI | ||
103 | tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)" | ||
104 | depends on PXA_SHARPSL | ||
105 | select CORGI_SSP_DEPRECATED | ||
106 | help | ||
107 | Say Y here to enable the driver for the touchscreen on the | ||
108 | Sharp SL-C7xx and SL-Cxx00 series of PDAs. | ||
109 | |||
110 | If unsure, say N. | ||
111 | |||
112 | To compile this driver as a module, choose M here: the | ||
113 | module will be called corgi_ts. | ||
114 | |||
115 | NOTE: this driver is deprecated, try enable SPI and generic | ||
116 | ADS7846-based touchscreen driver. | ||
117 | |||
118 | config TOUCHSCREEN_DA9034 | 102 | config TOUCHSCREEN_DA9034 |
119 | tristate "Touchscreen support for Dialog Semiconductor DA9034" | 103 | tristate "Touchscreen support for Dialog Semiconductor DA9034" |
120 | depends on PMIC_DA903X | 104 | depends on PMIC_DA903X |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 7fef7d5cca2..41145d074de 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -12,7 +12,6 @@ obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o | |||
12 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o | 12 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o |
13 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o | 13 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o |
14 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o | 14 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o |
15 | obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o | ||
16 | obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o | 15 | obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o |
17 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o | 16 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o |
18 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o | 17 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o |
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c deleted file mode 100644 index 94a1919d439..00000000000 --- a/drivers/input/touchscreen/corgi_ts.c +++ /dev/null | |||
@@ -1,385 +0,0 @@ | |||
1 | /* | ||
2 | * Touchscreen driver for Sharp SL-C7xx and SL-Cxx00 models | ||
3 | * | ||
4 | * Copyright (c) 2004-2005 Richard Purdie | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | |||
13 | #include <linux/delay.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/input.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/irq.h> | ||
21 | |||
22 | #include <mach/sharpsl.h> | ||
23 | #include <mach/hardware.h> | ||
24 | #include <mach/pxa2xx-gpio.h> | ||
25 | |||
26 | |||
27 | #define PWR_MODE_ACTIVE 0 | ||
28 | #define PWR_MODE_SUSPEND 1 | ||
29 | |||
30 | #define X_AXIS_MAX 3830 | ||
31 | #define X_AXIS_MIN 150 | ||
32 | #define Y_AXIS_MAX 3830 | ||
33 | #define Y_AXIS_MIN 190 | ||
34 | #define PRESSURE_MIN 0 | ||
35 | #define PRESSURE_MAX 15000 | ||
36 | |||
37 | struct ts_event { | ||
38 | short pressure; | ||
39 | short x; | ||
40 | short y; | ||
41 | }; | ||
42 | |||
43 | struct corgi_ts { | ||
44 | struct input_dev *input; | ||
45 | struct timer_list timer; | ||
46 | struct ts_event tc; | ||
47 | int pendown; | ||
48 | int power_mode; | ||
49 | int irq_gpio; | ||
50 | struct corgits_machinfo *machinfo; | ||
51 | }; | ||
52 | |||
53 | #ifdef CONFIG_PXA25x | ||
54 | #define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a)) | ||
55 | #define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x)) | ||
56 | #define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x)) | ||
57 | #endif | ||
58 | #ifdef CONFIG_PXA27x | ||
59 | #define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a)) | ||
60 | #define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C1, 0" : "=r"(x)) | ||
61 | #define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C1, 0" : : "r"(x)) | ||
62 | #endif | ||
63 | |||
64 | /* ADS7846 Touch Screen Controller bit definitions */ | ||
65 | #define ADSCTRL_PD0 (1u << 0) /* PD0 */ | ||
66 | #define ADSCTRL_PD1 (1u << 1) /* PD1 */ | ||
67 | #define ADSCTRL_DFR (1u << 2) /* SER/DFR */ | ||
68 | #define ADSCTRL_MOD (1u << 3) /* Mode */ | ||
69 | #define ADSCTRL_ADR_SH 4 /* Address setting */ | ||
70 | #define ADSCTRL_STS (1u << 7) /* Start Bit */ | ||
71 | |||
72 | /* External Functions */ | ||
73 | extern unsigned int get_clk_frequency_khz(int info); | ||
74 | |||
75 | static unsigned long calc_waittime(struct corgi_ts *corgi_ts) | ||
76 | { | ||
77 | unsigned long hsync_invperiod = corgi_ts->machinfo->get_hsync_invperiod(); | ||
78 | |||
79 | if (hsync_invperiod) | ||
80 | return get_clk_frequency_khz(0)*1000/hsync_invperiod; | ||
81 | else | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static int sync_receive_data_send_cmd(struct corgi_ts *corgi_ts, int doRecive, int doSend, | ||
86 | unsigned int address, unsigned long wait_time) | ||
87 | { | ||
88 | unsigned long timer1 = 0, timer2, pmnc = 0; | ||
89 | int pos = 0; | ||
90 | |||
91 | if (wait_time && doSend) { | ||
92 | PMNC_GET(pmnc); | ||
93 | if (!(pmnc & 0x01)) | ||
94 | PMNC_SET(0x01); | ||
95 | |||
96 | /* polling HSync */ | ||
97 | corgi_ts->machinfo->wait_hsync(); | ||
98 | /* get CCNT */ | ||
99 | CCNT(timer1); | ||
100 | } | ||
101 | |||
102 | if (doRecive) | ||
103 | pos = corgi_ssp_ads7846_get(); | ||
104 | |||
105 | if (doSend) { | ||
106 | int cmd = ADSCTRL_PD0 | ADSCTRL_PD1 | (address << ADSCTRL_ADR_SH) | ADSCTRL_STS; | ||
107 | /* dummy command */ | ||
108 | corgi_ssp_ads7846_put(cmd); | ||
109 | corgi_ssp_ads7846_get(); | ||
110 | |||
111 | if (wait_time) { | ||
112 | /* Wait after HSync */ | ||
113 | CCNT(timer2); | ||
114 | if (timer2-timer1 > wait_time) { | ||
115 | /* too slow - timeout, try again */ | ||
116 | corgi_ts->machinfo->wait_hsync(); | ||
117 | /* get CCNT */ | ||
118 | CCNT(timer1); | ||
119 | /* Wait after HSync */ | ||
120 | CCNT(timer2); | ||
121 | } | ||
122 | while (timer2 - timer1 < wait_time) | ||
123 | CCNT(timer2); | ||
124 | } | ||
125 | corgi_ssp_ads7846_put(cmd); | ||
126 | if (wait_time && !(pmnc & 0x01)) | ||
127 | PMNC_SET(pmnc); | ||
128 | } | ||
129 | return pos; | ||
130 | } | ||
131 | |||
132 | static int read_xydata(struct corgi_ts *corgi_ts) | ||
133 | { | ||
134 | unsigned int x, y, z1, z2; | ||
135 | unsigned long flags, wait_time; | ||
136 | |||
137 | /* critical section */ | ||
138 | local_irq_save(flags); | ||
139 | corgi_ssp_ads7846_lock(); | ||
140 | wait_time = calc_waittime(corgi_ts); | ||
141 | |||
142 | /* Y-axis */ | ||
143 | sync_receive_data_send_cmd(corgi_ts, 0, 1, 1u, wait_time); | ||
144 | |||
145 | /* Y-axis */ | ||
146 | sync_receive_data_send_cmd(corgi_ts, 1, 1, 1u, wait_time); | ||
147 | |||
148 | /* X-axis */ | ||
149 | y = sync_receive_data_send_cmd(corgi_ts, 1, 1, 5u, wait_time); | ||
150 | |||
151 | /* Z1 */ | ||
152 | x = sync_receive_data_send_cmd(corgi_ts, 1, 1, 3u, wait_time); | ||
153 | |||
154 | /* Z2 */ | ||
155 | z1 = sync_receive_data_send_cmd(corgi_ts, 1, 1, 4u, wait_time); | ||
156 | z2 = sync_receive_data_send_cmd(corgi_ts, 1, 0, 4u, wait_time); | ||
157 | |||
158 | /* Power-Down Enable */ | ||
159 | corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
160 | corgi_ssp_ads7846_get(); | ||
161 | |||
162 | corgi_ssp_ads7846_unlock(); | ||
163 | local_irq_restore(flags); | ||
164 | |||
165 | if (x== 0 || y == 0 || z1 == 0 || (x * (z2 - z1) / z1) >= 15000) { | ||
166 | corgi_ts->tc.pressure = 0; | ||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | corgi_ts->tc.x = x; | ||
171 | corgi_ts->tc.y = y; | ||
172 | corgi_ts->tc.pressure = (x * (z2 - z1)) / z1; | ||
173 | return 1; | ||
174 | } | ||
175 | |||
176 | static void new_data(struct corgi_ts *corgi_ts) | ||
177 | { | ||
178 | struct input_dev *dev = corgi_ts->input; | ||
179 | |||
180 | if (corgi_ts->power_mode != PWR_MODE_ACTIVE) | ||
181 | return; | ||
182 | |||
183 | if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0) | ||
184 | return; | ||
185 | |||
186 | input_report_abs(dev, ABS_X, corgi_ts->tc.x); | ||
187 | input_report_abs(dev, ABS_Y, corgi_ts->tc.y); | ||
188 | input_report_abs(dev, ABS_PRESSURE, corgi_ts->tc.pressure); | ||
189 | input_report_key(dev, BTN_TOUCH, corgi_ts->pendown); | ||
190 | input_sync(dev); | ||
191 | } | ||
192 | |||
193 | static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer) | ||
194 | { | ||
195 | if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) { | ||
196 | /* Disable Interrupt */ | ||
197 | set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_NONE); | ||
198 | if (read_xydata(corgi_ts)) { | ||
199 | corgi_ts->pendown = 1; | ||
200 | new_data(corgi_ts); | ||
201 | } | ||
202 | mod_timer(&corgi_ts->timer, jiffies + HZ / 100); | ||
203 | } else { | ||
204 | if (corgi_ts->pendown == 1 || corgi_ts->pendown == 2) { | ||
205 | mod_timer(&corgi_ts->timer, jiffies + HZ / 100); | ||
206 | corgi_ts->pendown++; | ||
207 | return; | ||
208 | } | ||
209 | |||
210 | if (corgi_ts->pendown) { | ||
211 | corgi_ts->tc.pressure = 0; | ||
212 | new_data(corgi_ts); | ||
213 | } | ||
214 | |||
215 | /* Enable Falling Edge */ | ||
216 | set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING); | ||
217 | corgi_ts->pendown = 0; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | static void corgi_ts_timer(unsigned long data) | ||
222 | { | ||
223 | struct corgi_ts *corgits_data = (struct corgi_ts *) data; | ||
224 | |||
225 | ts_interrupt_main(corgits_data, 1); | ||
226 | } | ||
227 | |||
228 | static irqreturn_t ts_interrupt(int irq, void *dev_id) | ||
229 | { | ||
230 | struct corgi_ts *corgits_data = dev_id; | ||
231 | |||
232 | ts_interrupt_main(corgits_data, 0); | ||
233 | return IRQ_HANDLED; | ||
234 | } | ||
235 | |||
236 | #ifdef CONFIG_PM | ||
237 | static int corgits_suspend(struct platform_device *dev, pm_message_t state) | ||
238 | { | ||
239 | struct corgi_ts *corgi_ts = platform_get_drvdata(dev); | ||
240 | |||
241 | if (corgi_ts->pendown) { | ||
242 | del_timer_sync(&corgi_ts->timer); | ||
243 | corgi_ts->tc.pressure = 0; | ||
244 | new_data(corgi_ts); | ||
245 | corgi_ts->pendown = 0; | ||
246 | } | ||
247 | corgi_ts->power_mode = PWR_MODE_SUSPEND; | ||
248 | |||
249 | corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
250 | |||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | static int corgits_resume(struct platform_device *dev) | ||
255 | { | ||
256 | struct corgi_ts *corgi_ts = platform_get_drvdata(dev); | ||
257 | |||
258 | corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
259 | /* Enable Falling Edge */ | ||
260 | set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING); | ||
261 | corgi_ts->power_mode = PWR_MODE_ACTIVE; | ||
262 | |||
263 | return 0; | ||
264 | } | ||
265 | #else | ||
266 | #define corgits_suspend NULL | ||
267 | #define corgits_resume NULL | ||
268 | #endif | ||
269 | |||
270 | static int __devinit corgits_probe(struct platform_device *pdev) | ||
271 | { | ||
272 | struct corgi_ts *corgi_ts; | ||
273 | struct input_dev *input_dev; | ||
274 | int err = -ENOMEM; | ||
275 | |||
276 | corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL); | ||
277 | input_dev = input_allocate_device(); | ||
278 | if (!corgi_ts || !input_dev) | ||
279 | goto fail1; | ||
280 | |||
281 | platform_set_drvdata(pdev, corgi_ts); | ||
282 | |||
283 | corgi_ts->machinfo = pdev->dev.platform_data; | ||
284 | corgi_ts->irq_gpio = platform_get_irq(pdev, 0); | ||
285 | |||
286 | if (corgi_ts->irq_gpio < 0) { | ||
287 | err = -ENODEV; | ||
288 | goto fail1; | ||
289 | } | ||
290 | |||
291 | corgi_ts->input = input_dev; | ||
292 | |||
293 | init_timer(&corgi_ts->timer); | ||
294 | corgi_ts->timer.data = (unsigned long) corgi_ts; | ||
295 | corgi_ts->timer.function = corgi_ts_timer; | ||
296 | |||
297 | input_dev->name = "Corgi Touchscreen"; | ||
298 | input_dev->phys = "corgits/input0"; | ||
299 | input_dev->id.bustype = BUS_HOST; | ||
300 | input_dev->id.vendor = 0x0001; | ||
301 | input_dev->id.product = 0x0002; | ||
302 | input_dev->id.version = 0x0100; | ||
303 | input_dev->dev.parent = &pdev->dev; | ||
304 | |||
305 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | ||
306 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
307 | input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0); | ||
308 | input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0); | ||
309 | input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0); | ||
310 | |||
311 | pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN); | ||
312 | |||
313 | /* Initiaize ADS7846 Difference Reference mode */ | ||
314 | corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
315 | mdelay(5); | ||
316 | corgi_ssp_ads7846_putget((3u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
317 | mdelay(5); | ||
318 | corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
319 | mdelay(5); | ||
320 | corgi_ssp_ads7846_putget((5u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
321 | mdelay(5); | ||
322 | |||
323 | if (request_irq(corgi_ts->irq_gpio, ts_interrupt, IRQF_DISABLED, "ts", corgi_ts)) { | ||
324 | err = -EBUSY; | ||
325 | goto fail1; | ||
326 | } | ||
327 | |||
328 | err = input_register_device(corgi_ts->input); | ||
329 | if (err) | ||
330 | goto fail2; | ||
331 | |||
332 | corgi_ts->power_mode = PWR_MODE_ACTIVE; | ||
333 | |||
334 | /* Enable Falling Edge */ | ||
335 | set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING); | ||
336 | |||
337 | return 0; | ||
338 | |||
339 | fail2: free_irq(corgi_ts->irq_gpio, corgi_ts); | ||
340 | fail1: input_free_device(input_dev); | ||
341 | kfree(corgi_ts); | ||
342 | return err; | ||
343 | } | ||
344 | |||
345 | static int __devexit corgits_remove(struct platform_device *pdev) | ||
346 | { | ||
347 | struct corgi_ts *corgi_ts = platform_get_drvdata(pdev); | ||
348 | |||
349 | free_irq(corgi_ts->irq_gpio, corgi_ts); | ||
350 | del_timer_sync(&corgi_ts->timer); | ||
351 | corgi_ts->machinfo->put_hsync(); | ||
352 | input_unregister_device(corgi_ts->input); | ||
353 | kfree(corgi_ts); | ||
354 | |||
355 | return 0; | ||
356 | } | ||
357 | |||
358 | static struct platform_driver corgits_driver = { | ||
359 | .probe = corgits_probe, | ||
360 | .remove = __devexit_p(corgits_remove), | ||
361 | .suspend = corgits_suspend, | ||
362 | .resume = corgits_resume, | ||
363 | .driver = { | ||
364 | .name = "corgi-ts", | ||
365 | .owner = THIS_MODULE, | ||
366 | }, | ||
367 | }; | ||
368 | |||
369 | static int __init corgits_init(void) | ||
370 | { | ||
371 | return platform_driver_register(&corgits_driver); | ||
372 | } | ||
373 | |||
374 | static void __exit corgits_exit(void) | ||
375 | { | ||
376 | platform_driver_unregister(&corgits_driver); | ||
377 | } | ||
378 | |||
379 | module_init(corgits_init); | ||
380 | module_exit(corgits_exit); | ||
381 | |||
382 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | ||
383 | MODULE_DESCRIPTION("Corgi TouchScreen Driver"); | ||
384 | MODULE_LICENSE("GPL"); | ||
385 | MODULE_ALIAS("platform:corgi-ts"); | ||
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 84c103a7ee1..ff115d92088 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c | |||
@@ -55,14 +55,16 @@ static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired) | |||
55 | host->cclk = host->mclk / (2 * (clk + 1)); | 55 | host->cclk = host->mclk / (2 * (clk + 1)); |
56 | } | 56 | } |
57 | if (host->hw_designer == AMBA_VENDOR_ST) | 57 | if (host->hw_designer == AMBA_VENDOR_ST) |
58 | clk |= MCI_FCEN; /* Bug fix in ST IP block */ | 58 | clk |= MCI_ST_FCEN; /* Bug fix in ST IP block */ |
59 | clk |= MCI_CLK_ENABLE; | 59 | clk |= MCI_CLK_ENABLE; |
60 | /* This hasn't proven to be worthwhile */ | 60 | /* This hasn't proven to be worthwhile */ |
61 | /* clk |= MCI_CLK_PWRSAVE; */ | 61 | /* clk |= MCI_CLK_PWRSAVE; */ |
62 | } | 62 | } |
63 | 63 | ||
64 | if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4) | 64 | if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4) |
65 | clk |= MCI_WIDE_BUS; | 65 | clk |= MCI_4BIT_BUS; |
66 | if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8) | ||
67 | clk |= MCI_ST_8BIT_BUS; | ||
66 | 68 | ||
67 | writel(clk, host->base + MMCICLOCK); | 69 | writel(clk, host->base + MMCICLOCK); |
68 | } | 70 | } |
@@ -629,7 +631,18 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id) | |||
629 | 631 | ||
630 | mmc->ops = &mmci_ops; | 632 | mmc->ops = &mmci_ops; |
631 | mmc->f_min = (host->mclk + 511) / 512; | 633 | mmc->f_min = (host->mclk + 511) / 512; |
632 | mmc->f_max = min(host->mclk, fmax); | 634 | /* |
635 | * If the platform data supplies a maximum operating | ||
636 | * frequency, this takes precedence. Else, we fall back | ||
637 | * to using the module parameter, which has a (low) | ||
638 | * default value in case it is not specified. Either | ||
639 | * value must not exceed the clock rate into the block, | ||
640 | * of course. | ||
641 | */ | ||
642 | if (plat->f_max) | ||
643 | mmc->f_max = min(host->mclk, plat->f_max); | ||
644 | else | ||
645 | mmc->f_max = min(host->mclk, fmax); | ||
633 | dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max); | 646 | dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max); |
634 | 647 | ||
635 | #ifdef CONFIG_REGULATOR | 648 | #ifdef CONFIG_REGULATOR |
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index 1ceb9a90f59..d77062e5e3a 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h | |||
@@ -25,9 +25,11 @@ | |||
25 | #define MCI_CLK_ENABLE (1 << 8) | 25 | #define MCI_CLK_ENABLE (1 << 8) |
26 | #define MCI_CLK_PWRSAVE (1 << 9) | 26 | #define MCI_CLK_PWRSAVE (1 << 9) |
27 | #define MCI_CLK_BYPASS (1 << 10) | 27 | #define MCI_CLK_BYPASS (1 << 10) |
28 | #define MCI_WIDE_BUS (1 << 11) | 28 | #define MCI_4BIT_BUS (1 << 11) |
29 | /* 8bit wide buses supported in ST Micro versions */ | ||
30 | #define MCI_ST_8BIT_BUS (1 << 12) | ||
29 | /* HW flow control on the ST Micro version */ | 31 | /* HW flow control on the ST Micro version */ |
30 | #define MCI_FCEN (1 << 13) | 32 | #define MCI_ST_FCEN (1 << 13) |
31 | 33 | ||
32 | #define MMCIARGUMENT 0x008 | 34 | #define MMCIARGUMENT 0x008 |
33 | #define MMCICOMMAND 0x00c | 35 | #define MMCICOMMAND 0x00c |
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index 0ed48959b59..e4f00e70a74 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c | |||
@@ -544,7 +544,7 @@ static irqreturn_t pxamci_detect_irq(int irq, void *devid) | |||
544 | { | 544 | { |
545 | struct pxamci_host *host = mmc_priv(devid); | 545 | struct pxamci_host *host = mmc_priv(devid); |
546 | 546 | ||
547 | mmc_detect_change(devid, host->pdata->detect_delay); | 547 | mmc_detect_change(devid, msecs_to_jiffies(host->pdata->detect_delay_ms)); |
548 | return IRQ_HANDLED; | 548 | return IRQ_HANDLED; |
549 | } | 549 | } |
550 | 550 | ||
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index d189e4743e6..a44733d44ca 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -234,7 +234,8 @@ config PCMCIA_PXA2XX | |||
234 | depends on ARM && ARCH_PXA && PCMCIA | 234 | depends on ARM && ARCH_PXA && PCMCIA |
235 | depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ | 235 | depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ |
236 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ | 236 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ |
237 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2) | 237 | || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \ |
238 | || MACH_VPAC270) | ||
238 | select PCMCIA_SOC_COMMON | 239 | select PCMCIA_SOC_COMMON |
239 | help | 240 | help |
240 | Say Y here to include support for the PXA2xx PCMCIA controller | 241 | Say Y here to include support for the PXA2xx PCMCIA controller |
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 381b031d9d7..4dae3613c45 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
@@ -66,6 +66,7 @@ pxa2xx-obj-$(CONFIG_MACH_PALMTC) += pxa2xx_palmtc.o | |||
66 | pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o | 66 | pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o |
67 | pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o | 67 | pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o |
68 | pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o | 68 | pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o |
69 | pxa2xx-obj-$(CONFIG_MACH_VPAC270) += pxa2xx_vpac270.o | ||
69 | 70 | ||
70 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) | 71 | obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) |
71 | 72 | ||
diff --git a/drivers/pcmcia/pxa2xx_vpac270.c b/drivers/pcmcia/pxa2xx_vpac270.c new file mode 100644 index 00000000000..55627eccee8 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_vpac270.c | |||
@@ -0,0 +1,229 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/pxa2xx_vpac270.c | ||
3 | * | ||
4 | * Driver for Voipac PXA270 PCMCIA and CF sockets | ||
5 | * | ||
6 | * Copyright (C) 2010 | ||
7 | * Marek Vasut <marek.vasut@gmail.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | |||
18 | #include <asm/mach-types.h> | ||
19 | |||
20 | #include <mach/gpio.h> | ||
21 | #include <mach/vpac270.h> | ||
22 | |||
23 | #include "soc_common.h" | ||
24 | |||
25 | static struct pcmcia_irqs cd_irqs[] = { | ||
26 | { | ||
27 | .sock = 0, | ||
28 | .irq = IRQ_GPIO(GPIO84_VPAC270_PCMCIA_CD), | ||
29 | .str = "PCMCIA CD" | ||
30 | }, | ||
31 | { | ||
32 | .sock = 1, | ||
33 | .irq = IRQ_GPIO(GPIO17_VPAC270_CF_CD), | ||
34 | .str = "CF CD" | ||
35 | }, | ||
36 | }; | ||
37 | |||
38 | static int vpac270_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
39 | { | ||
40 | int ret; | ||
41 | |||
42 | if (skt->nr == 0) { | ||
43 | ret = gpio_request(GPIO84_VPAC270_PCMCIA_CD, "PCMCIA CD"); | ||
44 | if (ret) | ||
45 | goto err1; | ||
46 | ret = gpio_direction_input(GPIO84_VPAC270_PCMCIA_CD); | ||
47 | if (ret) | ||
48 | goto err2; | ||
49 | |||
50 | ret = gpio_request(GPIO35_VPAC270_PCMCIA_RDY, "PCMCIA RDY"); | ||
51 | if (ret) | ||
52 | goto err2; | ||
53 | ret = gpio_direction_input(GPIO35_VPAC270_PCMCIA_RDY); | ||
54 | if (ret) | ||
55 | goto err3; | ||
56 | |||
57 | ret = gpio_request(GPIO107_VPAC270_PCMCIA_PPEN, "PCMCIA PPEN"); | ||
58 | if (ret) | ||
59 | goto err3; | ||
60 | ret = gpio_direction_output(GPIO107_VPAC270_PCMCIA_PPEN, 0); | ||
61 | if (ret) | ||
62 | goto err4; | ||
63 | |||
64 | ret = gpio_request(GPIO11_VPAC270_PCMCIA_RESET, "PCMCIA RESET"); | ||
65 | if (ret) | ||
66 | goto err4; | ||
67 | ret = gpio_direction_output(GPIO11_VPAC270_PCMCIA_RESET, 0); | ||
68 | if (ret) | ||
69 | goto err5; | ||
70 | |||
71 | skt->socket.pci_irq = gpio_to_irq(GPIO35_VPAC270_PCMCIA_RDY); | ||
72 | |||
73 | return soc_pcmcia_request_irqs(skt, &cd_irqs[0], 1); | ||
74 | |||
75 | err5: | ||
76 | gpio_free(GPIO11_VPAC270_PCMCIA_RESET); | ||
77 | err4: | ||
78 | gpio_free(GPIO107_VPAC270_PCMCIA_PPEN); | ||
79 | err3: | ||
80 | gpio_free(GPIO35_VPAC270_PCMCIA_RDY); | ||
81 | err2: | ||
82 | gpio_free(GPIO84_VPAC270_PCMCIA_CD); | ||
83 | err1: | ||
84 | return ret; | ||
85 | |||
86 | } else { | ||
87 | ret = gpio_request(GPIO17_VPAC270_CF_CD, "CF CD"); | ||
88 | if (ret) | ||
89 | goto err6; | ||
90 | ret = gpio_direction_input(GPIO17_VPAC270_CF_CD); | ||
91 | if (ret) | ||
92 | goto err7; | ||
93 | |||
94 | ret = gpio_request(GPIO12_VPAC270_CF_RDY, "CF RDY"); | ||
95 | if (ret) | ||
96 | goto err7; | ||
97 | ret = gpio_direction_input(GPIO12_VPAC270_CF_RDY); | ||
98 | if (ret) | ||
99 | goto err8; | ||
100 | |||
101 | ret = gpio_request(GPIO16_VPAC270_CF_RESET, "CF RESET"); | ||
102 | if (ret) | ||
103 | goto err8; | ||
104 | ret = gpio_direction_output(GPIO16_VPAC270_CF_RESET, 0); | ||
105 | if (ret) | ||
106 | goto err9; | ||
107 | |||
108 | skt->socket.pci_irq = gpio_to_irq(GPIO12_VPAC270_CF_RDY); | ||
109 | |||
110 | return soc_pcmcia_request_irqs(skt, &cd_irqs[1], 1); | ||
111 | |||
112 | err9: | ||
113 | gpio_free(GPIO16_VPAC270_CF_RESET); | ||
114 | err8: | ||
115 | gpio_free(GPIO12_VPAC270_CF_RDY); | ||
116 | err7: | ||
117 | gpio_free(GPIO17_VPAC270_CF_CD); | ||
118 | err6: | ||
119 | return ret; | ||
120 | |||
121 | } | ||
122 | } | ||
123 | |||
124 | static void vpac270_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
125 | { | ||
126 | gpio_free(GPIO11_VPAC270_PCMCIA_RESET); | ||
127 | gpio_free(GPIO107_VPAC270_PCMCIA_PPEN); | ||
128 | gpio_free(GPIO35_VPAC270_PCMCIA_RDY); | ||
129 | gpio_free(GPIO84_VPAC270_PCMCIA_CD); | ||
130 | gpio_free(GPIO16_VPAC270_CF_RESET); | ||
131 | gpio_free(GPIO12_VPAC270_CF_RDY); | ||
132 | gpio_free(GPIO17_VPAC270_CF_CD); | ||
133 | } | ||
134 | |||
135 | static void vpac270_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
136 | struct pcmcia_state *state) | ||
137 | { | ||
138 | if (skt->nr == 0) { | ||
139 | state->detect = !gpio_get_value(GPIO84_VPAC270_PCMCIA_CD); | ||
140 | state->ready = !!gpio_get_value(GPIO35_VPAC270_PCMCIA_RDY); | ||
141 | } else { | ||
142 | state->detect = !gpio_get_value(GPIO17_VPAC270_CF_CD); | ||
143 | state->ready = !!gpio_get_value(GPIO12_VPAC270_CF_RDY); | ||
144 | } | ||
145 | state->bvd1 = 1; | ||
146 | state->bvd2 = 1; | ||
147 | state->wrprot = 0; | ||
148 | state->vs_3v = 1; | ||
149 | state->vs_Xv = 0; | ||
150 | } | ||
151 | |||
152 | static int | ||
153 | vpac270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
154 | const socket_state_t *state) | ||
155 | { | ||
156 | if (skt->nr == 0) { | ||
157 | gpio_set_value(GPIO11_VPAC270_PCMCIA_RESET, | ||
158 | (state->flags & SS_RESET)); | ||
159 | gpio_set_value(GPIO107_VPAC270_PCMCIA_PPEN, | ||
160 | !(state->Vcc == 33 || state->Vcc == 50)); | ||
161 | } else { | ||
162 | gpio_set_value(GPIO16_VPAC270_CF_RESET, | ||
163 | (state->flags & SS_RESET)); | ||
164 | } | ||
165 | |||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | static void vpac270_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
170 | { | ||
171 | } | ||
172 | |||
173 | static void vpac270_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
174 | { | ||
175 | } | ||
176 | |||
177 | static struct pcmcia_low_level vpac270_pcmcia_ops = { | ||
178 | .owner = THIS_MODULE, | ||
179 | |||
180 | .first = 0, | ||
181 | .nr = 2, | ||
182 | |||
183 | .hw_init = vpac270_pcmcia_hw_init, | ||
184 | .hw_shutdown = vpac270_pcmcia_hw_shutdown, | ||
185 | |||
186 | .socket_state = vpac270_pcmcia_socket_state, | ||
187 | .configure_socket = vpac270_pcmcia_configure_socket, | ||
188 | |||
189 | .socket_init = vpac270_pcmcia_socket_init, | ||
190 | .socket_suspend = vpac270_pcmcia_socket_suspend, | ||
191 | }; | ||
192 | |||
193 | static struct platform_device *vpac270_pcmcia_device; | ||
194 | |||
195 | static int __init vpac270_pcmcia_init(void) | ||
196 | { | ||
197 | int ret; | ||
198 | |||
199 | if (!machine_is_vpac270()) | ||
200 | return -ENODEV; | ||
201 | |||
202 | vpac270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | ||
203 | if (!vpac270_pcmcia_device) | ||
204 | return -ENOMEM; | ||
205 | |||
206 | ret = platform_device_add_data(vpac270_pcmcia_device, | ||
207 | &vpac270_pcmcia_ops, sizeof(vpac270_pcmcia_ops)); | ||
208 | |||
209 | if (!ret) | ||
210 | ret = platform_device_add(vpac270_pcmcia_device); | ||
211 | |||
212 | if (ret) | ||
213 | platform_device_put(vpac270_pcmcia_device); | ||
214 | |||
215 | return ret; | ||
216 | } | ||
217 | |||
218 | static void __exit vpac270_pcmcia_exit(void) | ||
219 | { | ||
220 | platform_device_unregister(vpac270_pcmcia_device); | ||
221 | } | ||
222 | |||
223 | module_init(vpac270_pcmcia_init); | ||
224 | module_exit(vpac270_pcmcia_exit); | ||
225 | |||
226 | MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); | ||
227 | MODULE_DESCRIPTION("PCMCIA support for Voipac PXA270"); | ||
228 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); | ||
229 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index f55c49475a8..5f3f03df92e 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -518,12 +518,13 @@ config SERIAL_S3C2412 | |||
518 | Serial port support for the Samsung S3C2412 and S3C2413 SoC | 518 | Serial port support for the Samsung S3C2412 and S3C2413 SoC |
519 | 519 | ||
520 | config SERIAL_S3C2440 | 520 | config SERIAL_S3C2440 |
521 | tristate "Samsung S3C2440/S3C2442 Serial port support" | 521 | tristate "Samsung S3C2440/S3C2442/S3C2416 Serial port support" |
522 | depends on SERIAL_SAMSUNG && (CPU_S3C2440 || CPU_S3C2442) | 522 | depends on SERIAL_SAMSUNG && (CPU_S3C2440 || CPU_S3C2442 || CPU_S3C2416) |
523 | default y if CPU_S3C2440 | 523 | default y if CPU_S3C2440 |
524 | default y if CPU_S3C2442 | 524 | default y if CPU_S3C2442 |
525 | select SERIAL_SAMSUNG_UARTS_4 if CPU_S3C2416 | ||
525 | help | 526 | help |
526 | Serial port support for the Samsung S3C2440 and S3C2442 SoC | 527 | Serial port support for the Samsung S3C2440, S3C2416 and S3C2442 SoC |
527 | 528 | ||
528 | config SERIAL_S3C24A0 | 529 | config SERIAL_S3C24A0 |
529 | tristate "Samsung S3C24A0 Serial port support" | 530 | tristate "Samsung S3C24A0 Serial port support" |
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c index 2c9bf9b6832..eed3c2d8dd1 100644 --- a/drivers/serial/atmel_serial.c +++ b/drivers/serial/atmel_serial.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/dma-mapping.h> | 38 | #include <linux/dma-mapping.h> |
39 | #include <linux/atmel_pdc.h> | 39 | #include <linux/atmel_pdc.h> |
40 | #include <linux/atmel_serial.h> | 40 | #include <linux/atmel_serial.h> |
41 | #include <linux/uaccess.h> | ||
41 | 42 | ||
42 | #include <asm/io.h> | 43 | #include <asm/io.h> |
43 | 44 | ||
@@ -59,6 +60,9 @@ | |||
59 | 60 | ||
60 | #include <linux/serial_core.h> | 61 | #include <linux/serial_core.h> |
61 | 62 | ||
63 | static void atmel_start_rx(struct uart_port *port); | ||
64 | static void atmel_stop_rx(struct uart_port *port); | ||
65 | |||
62 | #ifdef CONFIG_SERIAL_ATMEL_TTYAT | 66 | #ifdef CONFIG_SERIAL_ATMEL_TTYAT |
63 | 67 | ||
64 | /* Use device name ttyAT, major 204 and minor 154-169. This is necessary if we | 68 | /* Use device name ttyAT, major 204 and minor 154-169. This is necessary if we |
@@ -93,6 +97,7 @@ | |||
93 | #define UART_GET_BRGR(port) __raw_readl((port)->membase + ATMEL_US_BRGR) | 97 | #define UART_GET_BRGR(port) __raw_readl((port)->membase + ATMEL_US_BRGR) |
94 | #define UART_PUT_BRGR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_BRGR) | 98 | #define UART_PUT_BRGR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_BRGR) |
95 | #define UART_PUT_RTOR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_RTOR) | 99 | #define UART_PUT_RTOR(port,v) __raw_writel(v, (port)->membase + ATMEL_US_RTOR) |
100 | #define UART_PUT_TTGR(port, v) __raw_writel(v, (port)->membase + ATMEL_US_TTGR) | ||
96 | 101 | ||
97 | /* PDC registers */ | 102 | /* PDC registers */ |
98 | #define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR) | 103 | #define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR) |
@@ -147,6 +152,9 @@ struct atmel_uart_port { | |||
147 | unsigned int irq_status_prev; | 152 | unsigned int irq_status_prev; |
148 | 153 | ||
149 | struct circ_buf rx_ring; | 154 | struct circ_buf rx_ring; |
155 | |||
156 | struct serial_rs485 rs485; /* rs485 settings */ | ||
157 | unsigned int tx_done_mask; | ||
150 | }; | 158 | }; |
151 | 159 | ||
152 | static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART]; | 160 | static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART]; |
@@ -187,6 +195,46 @@ static bool atmel_use_dma_tx(struct uart_port *port) | |||
187 | } | 195 | } |
188 | #endif | 196 | #endif |
189 | 197 | ||
198 | /* Enable or disable the rs485 support */ | ||
199 | void atmel_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf) | ||
200 | { | ||
201 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | ||
202 | unsigned int mode; | ||
203 | |||
204 | spin_lock(&port->lock); | ||
205 | |||
206 | /* Disable interrupts */ | ||
207 | UART_PUT_IDR(port, atmel_port->tx_done_mask); | ||
208 | |||
209 | mode = UART_GET_MR(port); | ||
210 | |||
211 | /* Resetting serial mode to RS232 (0x0) */ | ||
212 | mode &= ~ATMEL_US_USMODE; | ||
213 | |||
214 | atmel_port->rs485 = *rs485conf; | ||
215 | |||
216 | if (rs485conf->flags & SER_RS485_ENABLED) { | ||
217 | dev_dbg(port->dev, "Setting UART to RS485\n"); | ||
218 | atmel_port->tx_done_mask = ATMEL_US_TXEMPTY; | ||
219 | UART_PUT_TTGR(port, rs485conf->delay_rts_before_send); | ||
220 | mode |= ATMEL_US_USMODE_RS485; | ||
221 | } else { | ||
222 | dev_dbg(port->dev, "Setting UART to RS232\n"); | ||
223 | if (atmel_use_dma_tx(port)) | ||
224 | atmel_port->tx_done_mask = ATMEL_US_ENDTX | | ||
225 | ATMEL_US_TXBUFE; | ||
226 | else | ||
227 | atmel_port->tx_done_mask = ATMEL_US_TXRDY; | ||
228 | } | ||
229 | UART_PUT_MR(port, mode); | ||
230 | |||
231 | /* Enable interrupts */ | ||
232 | UART_PUT_IER(port, atmel_port->tx_done_mask); | ||
233 | |||
234 | spin_unlock(&port->lock); | ||
235 | |||
236 | } | ||
237 | |||
190 | /* | 238 | /* |
191 | * Return TIOCSER_TEMT when transmitter FIFO and Shift register is empty. | 239 | * Return TIOCSER_TEMT when transmitter FIFO and Shift register is empty. |
192 | */ | 240 | */ |
@@ -202,6 +250,7 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) | |||
202 | { | 250 | { |
203 | unsigned int control = 0; | 251 | unsigned int control = 0; |
204 | unsigned int mode; | 252 | unsigned int mode; |
253 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | ||
205 | 254 | ||
206 | #ifdef CONFIG_ARCH_AT91RM9200 | 255 | #ifdef CONFIG_ARCH_AT91RM9200 |
207 | if (cpu_is_at91rm9200()) { | 256 | if (cpu_is_at91rm9200()) { |
@@ -236,6 +285,17 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) | |||
236 | mode |= ATMEL_US_CHMODE_LOC_LOOP; | 285 | mode |= ATMEL_US_CHMODE_LOC_LOOP; |
237 | else | 286 | else |
238 | mode |= ATMEL_US_CHMODE_NORMAL; | 287 | mode |= ATMEL_US_CHMODE_NORMAL; |
288 | |||
289 | /* Resetting serial mode to RS232 (0x0) */ | ||
290 | mode &= ~ATMEL_US_USMODE; | ||
291 | |||
292 | if (atmel_port->rs485.flags & SER_RS485_ENABLED) { | ||
293 | dev_dbg(port->dev, "Setting UART to RS485\n"); | ||
294 | UART_PUT_TTGR(port, atmel_port->rs485.delay_rts_before_send); | ||
295 | mode |= ATMEL_US_USMODE_RS485; | ||
296 | } else { | ||
297 | dev_dbg(port->dev, "Setting UART to RS232\n"); | ||
298 | } | ||
239 | UART_PUT_MR(port, mode); | 299 | UART_PUT_MR(port, mode); |
240 | } | 300 | } |
241 | 301 | ||
@@ -268,12 +328,17 @@ static u_int atmel_get_mctrl(struct uart_port *port) | |||
268 | */ | 328 | */ |
269 | static void atmel_stop_tx(struct uart_port *port) | 329 | static void atmel_stop_tx(struct uart_port *port) |
270 | { | 330 | { |
331 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | ||
332 | |||
271 | if (atmel_use_dma_tx(port)) { | 333 | if (atmel_use_dma_tx(port)) { |
272 | /* disable PDC transmit */ | 334 | /* disable PDC transmit */ |
273 | UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS); | 335 | UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS); |
274 | UART_PUT_IDR(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE); | 336 | } |
275 | } else | 337 | /* Disable interrupts */ |
276 | UART_PUT_IDR(port, ATMEL_US_TXRDY); | 338 | UART_PUT_IDR(port, atmel_port->tx_done_mask); |
339 | |||
340 | if (atmel_port->rs485.flags & SER_RS485_ENABLED) | ||
341 | atmel_start_rx(port); | ||
277 | } | 342 | } |
278 | 343 | ||
279 | /* | 344 | /* |
@@ -281,17 +346,39 @@ static void atmel_stop_tx(struct uart_port *port) | |||
281 | */ | 346 | */ |
282 | static void atmel_start_tx(struct uart_port *port) | 347 | static void atmel_start_tx(struct uart_port *port) |
283 | { | 348 | { |
349 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | ||
350 | |||
284 | if (atmel_use_dma_tx(port)) { | 351 | if (atmel_use_dma_tx(port)) { |
285 | if (UART_GET_PTSR(port) & ATMEL_PDC_TXTEN) | 352 | if (UART_GET_PTSR(port) & ATMEL_PDC_TXTEN) |
286 | /* The transmitter is already running. Yes, we | 353 | /* The transmitter is already running. Yes, we |
287 | really need this.*/ | 354 | really need this.*/ |
288 | return; | 355 | return; |
289 | 356 | ||
290 | UART_PUT_IER(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE); | 357 | if (atmel_port->rs485.flags & SER_RS485_ENABLED) |
358 | atmel_stop_rx(port); | ||
359 | |||
291 | /* re-enable PDC transmit */ | 360 | /* re-enable PDC transmit */ |
292 | UART_PUT_PTCR(port, ATMEL_PDC_TXTEN); | 361 | UART_PUT_PTCR(port, ATMEL_PDC_TXTEN); |
293 | } else | 362 | } |
294 | UART_PUT_IER(port, ATMEL_US_TXRDY); | 363 | /* Enable interrupts */ |
364 | UART_PUT_IER(port, atmel_port->tx_done_mask); | ||
365 | } | ||
366 | |||
367 | /* | ||
368 | * start receiving - port is in process of being opened. | ||
369 | */ | ||
370 | static void atmel_start_rx(struct uart_port *port) | ||
371 | { | ||
372 | UART_PUT_CR(port, ATMEL_US_RSTSTA); /* reset status and receiver */ | ||
373 | |||
374 | if (atmel_use_dma_rx(port)) { | ||
375 | /* enable PDC controller */ | ||
376 | UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT | | ||
377 | port->read_status_mask); | ||
378 | UART_PUT_PTCR(port, ATMEL_PDC_RXTEN); | ||
379 | } else { | ||
380 | UART_PUT_IER(port, ATMEL_US_RXRDY); | ||
381 | } | ||
295 | } | 382 | } |
296 | 383 | ||
297 | /* | 384 | /* |
@@ -302,9 +389,11 @@ static void atmel_stop_rx(struct uart_port *port) | |||
302 | if (atmel_use_dma_rx(port)) { | 389 | if (atmel_use_dma_rx(port)) { |
303 | /* disable PDC receive */ | 390 | /* disable PDC receive */ |
304 | UART_PUT_PTCR(port, ATMEL_PDC_RXTDIS); | 391 | UART_PUT_PTCR(port, ATMEL_PDC_RXTDIS); |
305 | UART_PUT_IDR(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT); | 392 | UART_PUT_IDR(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT | |
306 | } else | 393 | port->read_status_mask); |
394 | } else { | ||
307 | UART_PUT_IDR(port, ATMEL_US_RXRDY); | 395 | UART_PUT_IDR(port, ATMEL_US_RXRDY); |
396 | } | ||
308 | } | 397 | } |
309 | 398 | ||
310 | /* | 399 | /* |
@@ -428,8 +517,9 @@ static void atmel_rx_chars(struct uart_port *port) | |||
428 | static void atmel_tx_chars(struct uart_port *port) | 517 | static void atmel_tx_chars(struct uart_port *port) |
429 | { | 518 | { |
430 | struct circ_buf *xmit = &port->state->xmit; | 519 | struct circ_buf *xmit = &port->state->xmit; |
520 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | ||
431 | 521 | ||
432 | if (port->x_char && UART_GET_CSR(port) & ATMEL_US_TXRDY) { | 522 | if (port->x_char && UART_GET_CSR(port) & atmel_port->tx_done_mask) { |
433 | UART_PUT_CHAR(port, port->x_char); | 523 | UART_PUT_CHAR(port, port->x_char); |
434 | port->icount.tx++; | 524 | port->icount.tx++; |
435 | port->x_char = 0; | 525 | port->x_char = 0; |
@@ -437,7 +527,7 @@ static void atmel_tx_chars(struct uart_port *port) | |||
437 | if (uart_circ_empty(xmit) || uart_tx_stopped(port)) | 527 | if (uart_circ_empty(xmit) || uart_tx_stopped(port)) |
438 | return; | 528 | return; |
439 | 529 | ||
440 | while (UART_GET_CSR(port) & ATMEL_US_TXRDY) { | 530 | while (UART_GET_CSR(port) & atmel_port->tx_done_mask) { |
441 | UART_PUT_CHAR(port, xmit->buf[xmit->tail]); | 531 | UART_PUT_CHAR(port, xmit->buf[xmit->tail]); |
442 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | 532 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
443 | port->icount.tx++; | 533 | port->icount.tx++; |
@@ -449,7 +539,8 @@ static void atmel_tx_chars(struct uart_port *port) | |||
449 | uart_write_wakeup(port); | 539 | uart_write_wakeup(port); |
450 | 540 | ||
451 | if (!uart_circ_empty(xmit)) | 541 | if (!uart_circ_empty(xmit)) |
452 | UART_PUT_IER(port, ATMEL_US_TXRDY); | 542 | /* Enable interrupts */ |
543 | UART_PUT_IER(port, atmel_port->tx_done_mask); | ||
453 | } | 544 | } |
454 | 545 | ||
455 | /* | 546 | /* |
@@ -501,18 +592,10 @@ atmel_handle_transmit(struct uart_port *port, unsigned int pending) | |||
501 | { | 592 | { |
502 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | 593 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); |
503 | 594 | ||
504 | if (atmel_use_dma_tx(port)) { | 595 | if (pending & atmel_port->tx_done_mask) { |
505 | /* PDC transmit */ | 596 | /* Either PDC or interrupt transmission */ |
506 | if (pending & (ATMEL_US_ENDTX | ATMEL_US_TXBUFE)) { | 597 | UART_PUT_IDR(port, atmel_port->tx_done_mask); |
507 | UART_PUT_IDR(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE); | 598 | tasklet_schedule(&atmel_port->tasklet); |
508 | tasklet_schedule(&atmel_port->tasklet); | ||
509 | } | ||
510 | } else { | ||
511 | /* Interrupt transmit */ | ||
512 | if (pending & ATMEL_US_TXRDY) { | ||
513 | UART_PUT_IDR(port, ATMEL_US_TXRDY); | ||
514 | tasklet_schedule(&atmel_port->tasklet); | ||
515 | } | ||
516 | } | 599 | } |
517 | } | 600 | } |
518 | 601 | ||
@@ -590,9 +673,15 @@ static void atmel_tx_dma(struct uart_port *port) | |||
590 | 673 | ||
591 | UART_PUT_TPR(port, pdc->dma_addr + xmit->tail); | 674 | UART_PUT_TPR(port, pdc->dma_addr + xmit->tail); |
592 | UART_PUT_TCR(port, count); | 675 | UART_PUT_TCR(port, count); |
593 | /* re-enable PDC transmit and interrupts */ | 676 | /* re-enable PDC transmit */ |
594 | UART_PUT_PTCR(port, ATMEL_PDC_TXTEN); | 677 | UART_PUT_PTCR(port, ATMEL_PDC_TXTEN); |
595 | UART_PUT_IER(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE); | 678 | /* Enable interrupts */ |
679 | UART_PUT_IER(port, atmel_port->tx_done_mask); | ||
680 | } else { | ||
681 | if (atmel_port->rs485.flags & SER_RS485_ENABLED) { | ||
682 | /* DMA done, stop TX, start RX for RS485 */ | ||
683 | atmel_start_rx(port); | ||
684 | } | ||
596 | } | 685 | } |
597 | 686 | ||
598 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 687 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
@@ -1017,6 +1106,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1017 | { | 1106 | { |
1018 | unsigned long flags; | 1107 | unsigned long flags; |
1019 | unsigned int mode, imr, quot, baud; | 1108 | unsigned int mode, imr, quot, baud; |
1109 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | ||
1020 | 1110 | ||
1021 | /* Get current mode register */ | 1111 | /* Get current mode register */ |
1022 | mode = UART_GET_MR(port) & ~(ATMEL_US_USCLKS | ATMEL_US_CHRL | 1112 | mode = UART_GET_MR(port) & ~(ATMEL_US_USCLKS | ATMEL_US_CHRL |
@@ -1115,6 +1205,17 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1115 | /* disable receiver and transmitter */ | 1205 | /* disable receiver and transmitter */ |
1116 | UART_PUT_CR(port, ATMEL_US_TXDIS | ATMEL_US_RXDIS); | 1206 | UART_PUT_CR(port, ATMEL_US_TXDIS | ATMEL_US_RXDIS); |
1117 | 1207 | ||
1208 | /* Resetting serial mode to RS232 (0x0) */ | ||
1209 | mode &= ~ATMEL_US_USMODE; | ||
1210 | |||
1211 | if (atmel_port->rs485.flags & SER_RS485_ENABLED) { | ||
1212 | dev_dbg(port->dev, "Setting UART to RS485\n"); | ||
1213 | UART_PUT_TTGR(port, atmel_port->rs485.delay_rts_before_send); | ||
1214 | mode |= ATMEL_US_USMODE_RS485; | ||
1215 | } else { | ||
1216 | dev_dbg(port->dev, "Setting UART to RS232\n"); | ||
1217 | } | ||
1218 | |||
1118 | /* set the parity, stop bits and data size */ | 1219 | /* set the parity, stop bits and data size */ |
1119 | UART_PUT_MR(port, mode); | 1220 | UART_PUT_MR(port, mode); |
1120 | 1221 | ||
@@ -1231,6 +1332,35 @@ static void atmel_poll_put_char(struct uart_port *port, unsigned char ch) | |||
1231 | } | 1332 | } |
1232 | #endif | 1333 | #endif |
1233 | 1334 | ||
1335 | static int | ||
1336 | atmel_ioctl(struct uart_port *port, unsigned int cmd, unsigned long arg) | ||
1337 | { | ||
1338 | struct serial_rs485 rs485conf; | ||
1339 | |||
1340 | switch (cmd) { | ||
1341 | case TIOCSRS485: | ||
1342 | if (copy_from_user(&rs485conf, (struct serial_rs485 *) arg, | ||
1343 | sizeof(rs485conf))) | ||
1344 | return -EFAULT; | ||
1345 | |||
1346 | atmel_config_rs485(port, &rs485conf); | ||
1347 | break; | ||
1348 | |||
1349 | case TIOCGRS485: | ||
1350 | if (copy_to_user((struct serial_rs485 *) arg, | ||
1351 | &(to_atmel_uart_port(port)->rs485), | ||
1352 | sizeof(rs485conf))) | ||
1353 | return -EFAULT; | ||
1354 | break; | ||
1355 | |||
1356 | default: | ||
1357 | return -ENOIOCTLCMD; | ||
1358 | } | ||
1359 | return 0; | ||
1360 | } | ||
1361 | |||
1362 | |||
1363 | |||
1234 | static struct uart_ops atmel_pops = { | 1364 | static struct uart_ops atmel_pops = { |
1235 | .tx_empty = atmel_tx_empty, | 1365 | .tx_empty = atmel_tx_empty, |
1236 | .set_mctrl = atmel_set_mctrl, | 1366 | .set_mctrl = atmel_set_mctrl, |
@@ -1250,6 +1380,7 @@ static struct uart_ops atmel_pops = { | |||
1250 | .config_port = atmel_config_port, | 1380 | .config_port = atmel_config_port, |
1251 | .verify_port = atmel_verify_port, | 1381 | .verify_port = atmel_verify_port, |
1252 | .pm = atmel_serial_pm, | 1382 | .pm = atmel_serial_pm, |
1383 | .ioctl = atmel_ioctl, | ||
1253 | #ifdef CONFIG_CONSOLE_POLL | 1384 | #ifdef CONFIG_CONSOLE_POLL |
1254 | .poll_get_char = atmel_poll_get_char, | 1385 | .poll_get_char = atmel_poll_get_char, |
1255 | .poll_put_char = atmel_poll_put_char, | 1386 | .poll_put_char = atmel_poll_put_char, |
@@ -1265,13 +1396,12 @@ static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port, | |||
1265 | struct uart_port *port = &atmel_port->uart; | 1396 | struct uart_port *port = &atmel_port->uart; |
1266 | struct atmel_uart_data *data = pdev->dev.platform_data; | 1397 | struct atmel_uart_data *data = pdev->dev.platform_data; |
1267 | 1398 | ||
1268 | port->iotype = UPIO_MEM; | 1399 | port->iotype = UPIO_MEM; |
1269 | port->flags = UPF_BOOT_AUTOCONF; | 1400 | port->flags = UPF_BOOT_AUTOCONF; |
1270 | port->ops = &atmel_pops; | 1401 | port->ops = &atmel_pops; |
1271 | port->fifosize = 1; | 1402 | port->fifosize = 1; |
1272 | port->line = pdev->id; | 1403 | port->line = pdev->id; |
1273 | port->dev = &pdev->dev; | 1404 | port->dev = &pdev->dev; |
1274 | |||
1275 | port->mapbase = pdev->resource[0].start; | 1405 | port->mapbase = pdev->resource[0].start; |
1276 | port->irq = pdev->resource[1].start; | 1406 | port->irq = pdev->resource[1].start; |
1277 | 1407 | ||
@@ -1299,8 +1429,16 @@ static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port, | |||
1299 | 1429 | ||
1300 | atmel_port->use_dma_rx = data->use_dma_rx; | 1430 | atmel_port->use_dma_rx = data->use_dma_rx; |
1301 | atmel_port->use_dma_tx = data->use_dma_tx; | 1431 | atmel_port->use_dma_tx = data->use_dma_tx; |
1302 | if (atmel_use_dma_tx(port)) | 1432 | atmel_port->rs485 = data->rs485; |
1433 | /* Use TXEMPTY for interrupt when rs485 else TXRDY or ENDTX|TXBUFE */ | ||
1434 | if (atmel_port->rs485.flags & SER_RS485_ENABLED) | ||
1435 | atmel_port->tx_done_mask = ATMEL_US_TXEMPTY; | ||
1436 | else if (atmel_use_dma_tx(port)) { | ||
1303 | port->fifosize = PDC_BUFFER_SIZE; | 1437 | port->fifosize = PDC_BUFFER_SIZE; |
1438 | atmel_port->tx_done_mask = ATMEL_US_ENDTX | ATMEL_US_TXBUFE; | ||
1439 | } else { | ||
1440 | atmel_port->tx_done_mask = ATMEL_US_TXRDY; | ||
1441 | } | ||
1304 | } | 1442 | } |
1305 | 1443 | ||
1306 | /* | 1444 | /* |
@@ -1334,6 +1472,7 @@ static void atmel_console_putchar(struct uart_port *port, int ch) | |||
1334 | static void atmel_console_write(struct console *co, const char *s, u_int count) | 1472 | static void atmel_console_write(struct console *co, const char *s, u_int count) |
1335 | { | 1473 | { |
1336 | struct uart_port *port = &atmel_ports[co->index].uart; | 1474 | struct uart_port *port = &atmel_ports[co->index].uart; |
1475 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | ||
1337 | unsigned int status, imr; | 1476 | unsigned int status, imr; |
1338 | unsigned int pdc_tx; | 1477 | unsigned int pdc_tx; |
1339 | 1478 | ||
@@ -1341,7 +1480,7 @@ static void atmel_console_write(struct console *co, const char *s, u_int count) | |||
1341 | * First, save IMR and then disable interrupts | 1480 | * First, save IMR and then disable interrupts |
1342 | */ | 1481 | */ |
1343 | imr = UART_GET_IMR(port); | 1482 | imr = UART_GET_IMR(port); |
1344 | UART_PUT_IDR(port, ATMEL_US_RXRDY | ATMEL_US_TXRDY); | 1483 | UART_PUT_IDR(port, ATMEL_US_RXRDY | atmel_port->tx_done_mask); |
1345 | 1484 | ||
1346 | /* Store PDC transmit status and disable it */ | 1485 | /* Store PDC transmit status and disable it */ |
1347 | pdc_tx = UART_GET_PTSR(port) & ATMEL_PDC_TXTEN; | 1486 | pdc_tx = UART_GET_PTSR(port) & ATMEL_PDC_TXTEN; |
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c index 36828358a4d..e76b1afafe0 100644 --- a/drivers/spi/pxa2xx_spi.c +++ b/drivers/spi/pxa2xx_spi.c | |||
@@ -36,8 +36,7 @@ | |||
36 | #include <asm/delay.h> | 36 | #include <asm/delay.h> |
37 | 37 | ||
38 | #include <mach/dma.h> | 38 | #include <mach/dma.h> |
39 | #include <mach/regs-ssp.h> | 39 | #include <plat/ssp.h> |
40 | #include <mach/ssp.h> | ||
41 | #include <mach/pxa2xx_spi.h> | 40 | #include <mach/pxa2xx_spi.h> |
42 | 41 | ||
43 | MODULE_AUTHOR("Stephen Street"); | 42 | MODULE_AUTHOR("Stephen Street"); |
@@ -1318,14 +1317,14 @@ static int setup(struct spi_device *spi) | |||
1318 | /* NOTE: PXA25x_SSP _could_ use external clocking ... */ | 1317 | /* NOTE: PXA25x_SSP _could_ use external clocking ... */ |
1319 | if (drv_data->ssp_type != PXA25x_SSP) | 1318 | if (drv_data->ssp_type != PXA25x_SSP) |
1320 | dev_dbg(&spi->dev, "%ld Hz actual, %s\n", | 1319 | dev_dbg(&spi->dev, "%ld Hz actual, %s\n", |
1321 | clk_get_rate(ssp->clk) | 1320 | clk_get_rate(ssp->clk) |
1322 | / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), | 1321 | / (1 + ((chip->cr0 & SSCR0_SCR(0xfff)) >> 8)), |
1323 | chip->enable_dma ? "DMA" : "PIO"); | 1322 | chip->enable_dma ? "DMA" : "PIO"); |
1324 | else | 1323 | else |
1325 | dev_dbg(&spi->dev, "%ld Hz actual, %s\n", | 1324 | dev_dbg(&spi->dev, "%ld Hz actual, %s\n", |
1326 | clk_get_rate(ssp->clk) / 2 | 1325 | clk_get_rate(ssp->clk) / 2 |
1327 | / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), | 1326 | / (1 + ((chip->cr0 & SSCR0_SCR(0x0ff)) >> 8)), |
1328 | chip->enable_dma ? "DMA" : "PIO"); | 1327 | chip->enable_dma ? "DMA" : "PIO"); |
1329 | 1328 | ||
1330 | if (spi->bits_per_word <= 8) { | 1329 | if (spi->bits_per_word <= 8) { |
1331 | chip->n_bytes = 1; | 1330 | chip->n_bytes = 1; |
@@ -1466,7 +1465,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev) | |||
1466 | 1465 | ||
1467 | platform_info = dev->platform_data; | 1466 | platform_info = dev->platform_data; |
1468 | 1467 | ||
1469 | ssp = ssp_request(pdev->id, pdev->name); | 1468 | ssp = pxa_ssp_request(pdev->id, pdev->name); |
1470 | if (ssp == NULL) { | 1469 | if (ssp == NULL) { |
1471 | dev_err(&pdev->dev, "failed to request SSP%d\n", pdev->id); | 1470 | dev_err(&pdev->dev, "failed to request SSP%d\n", pdev->id); |
1472 | return -ENODEV; | 1471 | return -ENODEV; |
@@ -1476,7 +1475,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev) | |||
1476 | master = spi_alloc_master(dev, sizeof(struct driver_data) + 16); | 1475 | master = spi_alloc_master(dev, sizeof(struct driver_data) + 16); |
1477 | if (!master) { | 1476 | if (!master) { |
1478 | dev_err(&pdev->dev, "cannot alloc spi_master\n"); | 1477 | dev_err(&pdev->dev, "cannot alloc spi_master\n"); |
1479 | ssp_free(ssp); | 1478 | pxa_ssp_free(ssp); |
1480 | return -ENOMEM; | 1479 | return -ENOMEM; |
1481 | } | 1480 | } |
1482 | drv_data = spi_master_get_devdata(master); | 1481 | drv_data = spi_master_get_devdata(master); |
@@ -1558,7 +1557,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev) | |||
1558 | write_SSCR1(SSCR1_RxTresh(RX_THRESH_DFLT) | | 1557 | write_SSCR1(SSCR1_RxTresh(RX_THRESH_DFLT) | |
1559 | SSCR1_TxTresh(TX_THRESH_DFLT), | 1558 | SSCR1_TxTresh(TX_THRESH_DFLT), |
1560 | drv_data->ioaddr); | 1559 | drv_data->ioaddr); |
1561 | write_SSCR0(SSCR0_SerClkDiv(2) | 1560 | write_SSCR0(SSCR0_SCR(2) |
1562 | | SSCR0_Motorola | 1561 | | SSCR0_Motorola |
1563 | | SSCR0_DataSize(8), | 1562 | | SSCR0_DataSize(8), |
1564 | drv_data->ioaddr); | 1563 | drv_data->ioaddr); |
@@ -1605,7 +1604,7 @@ out_error_irq_alloc: | |||
1605 | 1604 | ||
1606 | out_error_master_alloc: | 1605 | out_error_master_alloc: |
1607 | spi_master_put(master); | 1606 | spi_master_put(master); |
1608 | ssp_free(ssp); | 1607 | pxa_ssp_free(ssp); |
1609 | return status; | 1608 | return status; |
1610 | } | 1609 | } |
1611 | 1610 | ||
@@ -1649,7 +1648,7 @@ static int pxa2xx_spi_remove(struct platform_device *pdev) | |||
1649 | free_irq(ssp->irq, drv_data); | 1648 | free_irq(ssp->irq, drv_data); |
1650 | 1649 | ||
1651 | /* Release SSP */ | 1650 | /* Release SSP */ |
1652 | ssp_free(ssp); | 1651 | pxa_ssp_free(ssp); |
1653 | 1652 | ||
1654 | /* Disconnect from the SPI framework */ | 1653 | /* Disconnect from the SPI framework */ |
1655 | spi_unregister_master(drv_data->master); | 1654 | spi_unregister_master(drv_data->master); |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index df1bae9b048..eaa79c8a9b8 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -366,6 +366,13 @@ rescan: | |||
366 | if (is_done) | 366 | if (is_done) |
367 | done(ep, req, 0); | 367 | done(ep, req, 0); |
368 | else if (ep->is_pingpong) { | 368 | else if (ep->is_pingpong) { |
369 | /* | ||
370 | * One dummy read to delay the code because of a HW glitch: | ||
371 | * CSR returns bad RXCOUNT when read too soon after updating | ||
372 | * RX_DATA_BK flags. | ||
373 | */ | ||
374 | csr = __raw_readl(creg); | ||
375 | |||
369 | bufferspace -= count; | 376 | bufferspace -= count; |
370 | buf += count; | 377 | buf += count; |
371 | goto rescan; | 378 | goto rescan; |