Commit | Line | Data |
---|---|---|
5d783a2d MV |
1 | /* |
2 | * linux/arch/arm/mach-pxa/palmtc.c | |
3 | * | |
4 | * Support for the Palm Tungsten|C | |
5 | * | |
6 | * Author: Marek Vasut <marek.vasut@gmail.com> | |
7 | * | |
8 | * Based on work of: | |
9 | * Petr Blaha <p3t3@centrum.cz> | |
10 | * Chetan S. Kumar <shivakumar.chetan@gmail.com> | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU General Public License version 2 as | |
14 | * published by the Free Software Foundation. | |
15 | */ | |
16 | ||
17 | #include <linux/platform_device.h> | |
18 | #include <linux/delay.h> | |
19 | #include <linux/irq.h> | |
20 | #include <linux/input.h> | |
21 | #include <linux/pwm_backlight.h> | |
22 | #include <linux/gpio.h> | |
23 | #include <linux/input/matrix_keypad.h> | |
24 | #include <linux/ucb1400.h> | |
25 | #include <linux/power_supply.h> | |
26 | #include <linux/gpio_keys.h> | |
27 | #include <linux/mtd/physmap.h> | |
28 | ||
29 | #include <asm/mach-types.h> | |
30 | #include <asm/mach/arch.h> | |
31 | #include <asm/mach/map.h> | |
32 | ||
33 | #include <mach/audio.h> | |
34 | #include <mach/palmtc.h> | |
35 | #include <mach/mmc.h> | |
36 | #include <mach/pxafb.h> | |
37 | #include <mach/mfp-pxa25x.h> | |
38 | #include <mach/irda.h> | |
39 | #include <mach/udc.h> | |
40 | #include <mach/pxa2xx-regs.h> | |
41 | ||
42 | #include "generic.h" | |
43 | #include "devices.h" | |
44 | ||
45 | /****************************************************************************** | |
46 | * Pin configuration | |
47 | ******************************************************************************/ | |
48 | static unsigned long palmtc_pin_config[] __initdata = { | |
49 | /* MMC */ | |
50 | GPIO6_MMC_CLK, | |
51 | GPIO8_MMC_CS0, | |
52 | GPIO12_GPIO, /* detect */ | |
53 | GPIO32_GPIO, /* power */ | |
54 | GPIO54_GPIO, /* r/o switch */ | |
55 | ||
56 | /* PCMCIA */ | |
57 | GPIO52_nPCE_1, | |
58 | GPIO53_nPCE_2, | |
59 | GPIO50_nPIOR, | |
60 | GPIO51_nPIOW, | |
61 | GPIO49_nPWE, | |
62 | GPIO48_nPOE, | |
63 | GPIO52_nPCE_1, | |
64 | GPIO53_nPCE_2, | |
65 | GPIO57_nIOIS16, | |
66 | GPIO56_nPWAIT, | |
67 | ||
68 | /* AC97 */ | |
69 | GPIO28_AC97_BITCLK, | |
70 | GPIO29_AC97_SDATA_IN_0, | |
71 | GPIO30_AC97_SDATA_OUT, | |
72 | GPIO31_AC97_SYNC, | |
73 | ||
74 | /* IrDA */ | |
75 | GPIO45_GPIO, /* ir disable */ | |
76 | GPIO46_FICP_RXD, | |
77 | GPIO47_FICP_TXD, | |
78 | ||
79 | /* PWM */ | |
80 | GPIO17_PWM1_OUT, | |
81 | ||
82 | /* USB */ | |
83 | GPIO4_GPIO, /* detect */ | |
84 | GPIO36_GPIO, /* pullup */ | |
85 | ||
86 | /* LCD */ | |
87 | GPIO58_LCD_LDD_0, | |
88 | GPIO59_LCD_LDD_1, | |
89 | GPIO60_LCD_LDD_2, | |
90 | GPIO61_LCD_LDD_3, | |
91 | GPIO62_LCD_LDD_4, | |
92 | GPIO63_LCD_LDD_5, | |
93 | GPIO64_LCD_LDD_6, | |
94 | GPIO65_LCD_LDD_7, | |
95 | GPIO66_LCD_LDD_8, | |
96 | GPIO67_LCD_LDD_9, | |
97 | GPIO68_LCD_LDD_10, | |
98 | GPIO69_LCD_LDD_11, | |
99 | GPIO70_LCD_LDD_12, | |
100 | GPIO71_LCD_LDD_13, | |
101 | GPIO72_LCD_LDD_14, | |
102 | GPIO73_LCD_LDD_15, | |
103 | GPIO74_LCD_FCLK, | |
104 | GPIO75_LCD_LCLK, | |
105 | GPIO76_LCD_PCLK, | |
106 | GPIO77_LCD_BIAS, | |
107 | ||
108 | /* MATRIX KEYPAD */ | |
109 | GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 0 */ | |
110 | GPIO9_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 1 */ | |
111 | GPIO10_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 2 */ | |
112 | GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 3 */ | |
113 | GPIO18_GPIO | MFP_LPM_DRIVE_LOW, /* out 0 */ | |
114 | GPIO19_GPIO | MFP_LPM_DRIVE_LOW, /* out 1 */ | |
115 | GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* out 2 */ | |
116 | GPIO21_GPIO | MFP_LPM_DRIVE_LOW, /* out 3 */ | |
117 | GPIO22_GPIO | MFP_LPM_DRIVE_LOW, /* out 4 */ | |
118 | GPIO23_GPIO | MFP_LPM_DRIVE_LOW, /* out 5 */ | |
119 | GPIO24_GPIO | MFP_LPM_DRIVE_LOW, /* out 6 */ | |
120 | GPIO25_GPIO | MFP_LPM_DRIVE_LOW, /* out 7 */ | |
121 | GPIO26_GPIO | MFP_LPM_DRIVE_LOW, /* out 8 */ | |
122 | GPIO27_GPIO | MFP_LPM_DRIVE_LOW, /* out 9 */ | |
123 | GPIO79_GPIO | MFP_LPM_DRIVE_LOW, /* out 10 */ | |
124 | GPIO80_GPIO | MFP_LPM_DRIVE_LOW, /* out 11 */ | |
125 | ||
126 | /* PXA GPIO KEYS */ | |
127 | GPIO7_GPIO | WAKEUP_ON_EDGE_BOTH, /* hotsync button on cradle */ | |
128 | ||
129 | /* MISC */ | |
130 | GPIO1_RST, /* reset */ | |
131 | GPIO2_GPIO, /* earphone detect */ | |
132 | GPIO16_GPIO, /* backlight switch */ | |
133 | }; | |
134 | ||
135 | /****************************************************************************** | |
136 | * SD/MMC card controller | |
137 | ******************************************************************************/ | |
138 | static struct pxamci_platform_data palmtc_mci_platform_data = { | |
139 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, | |
140 | .gpio_power = GPIO_NR_PALMTC_SD_POWER, | |
141 | .gpio_card_ro = GPIO_NR_PALMTC_SD_READONLY, | |
142 | .gpio_card_detect = GPIO_NR_PALMTC_SD_DETECT_N, | |
143 | .detect_delay = 20, | |
144 | }; | |
145 | ||
146 | /****************************************************************************** | |
147 | * GPIO keys | |
148 | ******************************************************************************/ | |
149 | static struct gpio_keys_button palmtc_pxa_buttons[] = { | |
150 | {KEY_F8, GPIO_NR_PALMTC_HOTSYNC_BUTTON, 1, "HotSync Button", EV_KEY, 1}, | |
151 | }; | |
152 | ||
153 | static struct gpio_keys_platform_data palmtc_pxa_keys_data = { | |
154 | .buttons = palmtc_pxa_buttons, | |
155 | .nbuttons = ARRAY_SIZE(palmtc_pxa_buttons), | |
156 | }; | |
157 | ||
158 | static struct platform_device palmtc_pxa_keys = { | |
159 | .name = "gpio-keys", | |
160 | .id = -1, | |
161 | .dev = { | |
162 | .platform_data = &palmtc_pxa_keys_data, | |
163 | }, | |
164 | }; | |
165 | ||
166 | /****************************************************************************** | |
167 | * Backlight | |
168 | ******************************************************************************/ | |
169 | static int palmtc_backlight_init(struct device *dev) | |
170 | { | |
171 | int ret; | |
172 | ||
173 | ret = gpio_request(GPIO_NR_PALMTC_BL_POWER, "BL POWER"); | |
174 | if (ret) | |
175 | goto err; | |
176 | ret = gpio_direction_output(GPIO_NR_PALMTC_BL_POWER, 1); | |
177 | if (ret) | |
178 | goto err2; | |
179 | ||
180 | return 0; | |
181 | ||
182 | err2: | |
183 | gpio_free(GPIO_NR_PALMTC_BL_POWER); | |
184 | err: | |
185 | return ret; | |
186 | } | |
187 | ||
188 | static int palmtc_backlight_notify(int brightness) | |
189 | { | |
190 | /* backlight is on when GPIO16 AF0 is high */ | |
191 | gpio_set_value(GPIO_NR_PALMTC_BL_POWER, brightness); | |
192 | return brightness; | |
193 | } | |
194 | ||
195 | static void palmtc_backlight_exit(struct device *dev) | |
196 | { | |
197 | gpio_free(GPIO_NR_PALMTC_BL_POWER); | |
198 | } | |
199 | ||
200 | static struct platform_pwm_backlight_data palmtc_backlight_data = { | |
201 | .pwm_id = 1, | |
202 | .max_brightness = PALMTC_MAX_INTENSITY, | |
203 | .dft_brightness = PALMTC_MAX_INTENSITY, | |
204 | .pwm_period_ns = PALMTC_PERIOD_NS, | |
205 | .init = palmtc_backlight_init, | |
206 | .notify = palmtc_backlight_notify, | |
207 | .exit = palmtc_backlight_exit, | |
208 | }; | |
209 | ||
210 | static struct platform_device palmtc_backlight = { | |
211 | .name = "pwm-backlight", | |
212 | .dev = { | |
213 | .parent = &pxa25x_device_pwm1.dev, | |
214 | .platform_data = &palmtc_backlight_data, | |
215 | }, | |
216 | }; | |
217 | ||
218 | /****************************************************************************** | |
219 | * IrDA | |
220 | ******************************************************************************/ | |
221 | static int palmtc_irda_startup(struct device *dev) | |
222 | { | |
223 | int err; | |
224 | err = gpio_request(GPIO_NR_PALMTC_IR_DISABLE, "IR DISABLE"); | |
225 | if (err) | |
226 | goto err; | |
227 | err = gpio_direction_output(GPIO_NR_PALMTC_IR_DISABLE, 1); | |
228 | if (err) | |
229 | gpio_free(GPIO_NR_PALMTC_IR_DISABLE); | |
230 | err: | |
231 | return err; | |
232 | } | |
233 | ||
234 | static void palmtc_irda_shutdown(struct device *dev) | |
235 | { | |
236 | gpio_free(GPIO_NR_PALMTC_IR_DISABLE); | |
237 | } | |
238 | ||
239 | static void palmtc_irda_transceiver_mode(struct device *dev, int mode) | |
240 | { | |
241 | gpio_set_value(GPIO_NR_PALMTC_IR_DISABLE, mode & IR_OFF); | |
242 | pxa2xx_transceiver_mode(dev, mode); | |
243 | } | |
244 | ||
245 | static struct pxaficp_platform_data palmtc_ficp_platform_data = { | |
246 | .startup = palmtc_irda_startup, | |
247 | .shutdown = palmtc_irda_shutdown, | |
248 | .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF, | |
249 | .transceiver_mode = palmtc_irda_transceiver_mode, | |
250 | }; | |
251 | ||
252 | /****************************************************************************** | |
253 | * Keyboard | |
254 | ******************************************************************************/ | |
255 | static const uint32_t palmtc_matrix_keys[] = { | |
256 | KEY(0, 0, KEY_F1), | |
257 | KEY(0, 1, KEY_X), | |
258 | KEY(0, 2, KEY_POWER), | |
259 | KEY(0, 3, KEY_TAB), | |
260 | KEY(0, 4, KEY_A), | |
261 | KEY(0, 5, KEY_Q), | |
262 | KEY(0, 6, KEY_LEFTSHIFT), | |
263 | KEY(0, 7, KEY_Z), | |
264 | KEY(0, 8, KEY_S), | |
265 | KEY(0, 9, KEY_W), | |
266 | KEY(0, 10, KEY_E), | |
267 | KEY(0, 11, KEY_UP), | |
268 | ||
269 | KEY(1, 0, KEY_F2), | |
270 | KEY(1, 1, KEY_DOWN), | |
271 | KEY(1, 3, KEY_D), | |
272 | KEY(1, 4, KEY_C), | |
273 | KEY(1, 5, KEY_F), | |
274 | KEY(1, 6, KEY_R), | |
275 | KEY(1, 7, KEY_SPACE), | |
276 | KEY(1, 8, KEY_V), | |
277 | KEY(1, 9, KEY_G), | |
278 | KEY(1, 10, KEY_T), | |
279 | KEY(1, 11, KEY_LEFT), | |
280 | ||
281 | KEY(2, 0, KEY_F3), | |
282 | KEY(2, 1, KEY_LEFTCTRL), | |
283 | KEY(2, 3, KEY_H), | |
284 | KEY(2, 4, KEY_Y), | |
285 | KEY(2, 5, KEY_N), | |
286 | KEY(2, 6, KEY_J), | |
287 | KEY(2, 7, KEY_U), | |
288 | KEY(2, 8, KEY_M), | |
289 | KEY(2, 9, KEY_K), | |
290 | KEY(2, 10, KEY_I), | |
291 | KEY(2, 11, KEY_RIGHT), | |
292 | ||
293 | KEY(3, 0, KEY_F4), | |
294 | KEY(3, 1, KEY_ENTER), | |
295 | KEY(3, 3, KEY_DOT), | |
296 | KEY(3, 4, KEY_L), | |
297 | KEY(3, 5, KEY_O), | |
298 | KEY(3, 6, KEY_LEFTALT), | |
299 | KEY(3, 7, KEY_ENTER), | |
300 | KEY(3, 8, KEY_BACKSPACE), | |
301 | KEY(3, 9, KEY_P), | |
302 | KEY(3, 10, KEY_B), | |
303 | KEY(3, 11, KEY_FN), | |
304 | }; | |
305 | ||
306 | const struct matrix_keymap_data palmtc_keymap_data = { | |
307 | .keymap = palmtc_matrix_keys, | |
308 | .keymap_size = ARRAY_SIZE(palmtc_matrix_keys), | |
309 | }; | |
310 | ||
311 | const static unsigned int palmtc_keypad_row_gpios[] = { | |
312 | 0, 9, 10, 11 | |
313 | }; | |
314 | ||
315 | const static unsigned int palmtc_keypad_col_gpios[] = { | |
316 | 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80 | |
317 | }; | |
318 | ||
319 | static struct matrix_keypad_platform_data palmtc_keypad_platform_data = { | |
320 | .keymap_data = &palmtc_keymap_data, | |
321 | .col_gpios = palmtc_keypad_row_gpios, | |
322 | .num_col_gpios = 12, | |
323 | .row_gpios = palmtc_keypad_col_gpios, | |
324 | .num_row_gpios = 4, | |
325 | .active_low = 1, | |
326 | ||
327 | .debounce_ms = 20, | |
328 | .col_scan_delay_us = 5, | |
329 | }; | |
330 | ||
331 | static struct platform_device palmtc_keyboard = { | |
332 | .name = "matrix-keypad", | |
333 | .id = -1, | |
334 | .dev = { | |
335 | .platform_data = &palmtc_keypad_platform_data, | |
336 | }, | |
337 | }; | |
338 | ||
339 | /****************************************************************************** | |
340 | * UDC | |
341 | ******************************************************************************/ | |
342 | static struct pxa2xx_udc_mach_info palmtc_udc_info __initdata = { | |
343 | .gpio_vbus = GPIO_NR_PALMTC_USB_DETECT_N, | |
344 | .gpio_vbus_inverted = 1, | |
345 | .gpio_pullup = GPIO_NR_PALMTC_USB_POWER, | |
346 | }; | |
347 | ||
348 | /****************************************************************************** | |
349 | * Touchscreen / Battery / GPIO-extender | |
350 | ******************************************************************************/ | |
351 | static struct platform_device palmtc_ucb1400_core = { | |
352 | .name = "ucb1400_core", | |
353 | .id = -1, | |
354 | }; | |
355 | ||
356 | /****************************************************************************** | |
357 | * NOR Flash | |
358 | ******************************************************************************/ | |
359 | static struct resource palmtc_flash_resource = { | |
360 | .start = PXA_CS0_PHYS, | |
361 | .end = PXA_CS0_PHYS + SZ_16M - 1, | |
362 | .flags = IORESOURCE_MEM, | |
363 | }; | |
364 | ||
365 | static struct mtd_partition palmtc_flash_parts[] = { | |
366 | { | |
367 | .name = "U-Boot Bootloader", | |
368 | .offset = 0x0, | |
369 | .size = 0x40000, | |
370 | }, | |
371 | { | |
372 | .name = "Linux Kernel", | |
373 | .offset = 0x40000, | |
374 | .size = 0x2c0000, | |
375 | }, | |
376 | { | |
377 | .name = "Filesystem", | |
378 | .offset = 0x300000, | |
379 | .size = 0xcc0000, | |
380 | }, | |
381 | { | |
382 | .name = "U-Boot Environment", | |
383 | .offset = 0xfc0000, | |
384 | .size = MTDPART_SIZ_FULL, | |
385 | }, | |
386 | }; | |
387 | ||
388 | static struct physmap_flash_data palmtc_flash_data = { | |
389 | .width = 4, | |
390 | .parts = palmtc_flash_parts, | |
391 | .nr_parts = ARRAY_SIZE(palmtc_flash_parts), | |
392 | }; | |
393 | ||
394 | static struct platform_device palmtc_flash = { | |
395 | .name = "physmap-flash", | |
396 | .id = -1, | |
397 | .resource = &palmtc_flash_resource, | |
398 | .num_resources = 1, | |
399 | .dev = { | |
400 | .platform_data = &palmtc_flash_data, | |
401 | }, | |
402 | }; | |
403 | ||
404 | /****************************************************************************** | |
405 | * Framebuffer | |
406 | ******************************************************************************/ | |
407 | static struct pxafb_mode_info palmtc_lcd_modes[] = { | |
408 | { | |
409 | .pixclock = 115384, | |
410 | .xres = 320, | |
411 | .yres = 320, | |
412 | .bpp = 16, | |
413 | ||
414 | .left_margin = 27, | |
415 | .right_margin = 7, | |
416 | .upper_margin = 7, | |
417 | .lower_margin = 8, | |
418 | ||
419 | .hsync_len = 6, | |
420 | .vsync_len = 1, | |
421 | }, | |
422 | }; | |
423 | ||
424 | static struct pxafb_mach_info palmtc_lcd_screen = { | |
425 | .modes = palmtc_lcd_modes, | |
426 | .num_modes = ARRAY_SIZE(palmtc_lcd_modes), | |
427 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, | |
428 | }; | |
429 | ||
430 | /****************************************************************************** | |
431 | * Machine init | |
432 | ******************************************************************************/ | |
433 | static struct platform_device *devices[] __initdata = { | |
434 | &palmtc_backlight, | |
435 | &palmtc_ucb1400_core, | |
436 | &palmtc_keyboard, | |
437 | &palmtc_pxa_keys, | |
438 | &palmtc_flash, | |
439 | }; | |
440 | ||
441 | static void __init palmtc_init(void) | |
442 | { | |
443 | pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config)); | |
444 | ||
445 | set_pxa_fb_info(&palmtc_lcd_screen); | |
446 | pxa_set_mci_info(&palmtc_mci_platform_data); | |
447 | pxa_set_udc_info(&palmtc_udc_info); | |
448 | pxa_set_ac97_info(NULL); | |
449 | pxa_set_ficp_info(&palmtc_ficp_platform_data); | |
450 | ||
451 | platform_add_devices(devices, ARRAY_SIZE(devices)); | |
452 | }; | |
453 | ||
454 | MACHINE_START(PALMTC, "Palm Tungsten|C") | |
455 | .phys_io = 0x40000000, | |
456 | .boot_params = 0xa0000100, | |
457 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
458 | .map_io = pxa_map_io, | |
459 | .init_irq = pxa25x_init_irq, | |
460 | .timer = &pxa_timer, | |
461 | .init_machine = palmtc_init | |
462 | MACHINE_END |