]> Git Repo - linux.git/blame - arch/arm/mach-pxa/palmtc.c
Merge tag 'v5.1-rc1' into spi-5.2
[linux.git] / arch / arm / mach-pxa / palmtc.c
CommitLineData
5d783a2d
MV
1/*
2 * linux/arch/arm/mach-pxa/palmtc.c
3 *
4 * Support for the Palm Tungsten|C
5 *
6 * Author: Marek Vasut <[email protected]>
7 *
8 * Based on work of:
9 * Petr Blaha <[email protected]>
10 * Chetan S. Kumar <[email protected]>
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>
bfcb3117 21#include <linux/pwm.h>
5d783a2d 22#include <linux/pwm_backlight.h>
58e2d877 23#include <linux/gpio/machine.h>
5d783a2d
MV
24#include <linux/input/matrix_keypad.h>
25#include <linux/ucb1400.h>
26#include <linux/power_supply.h>
27#include <linux/gpio_keys.h>
28#include <linux/mtd/physmap.h>
4c6a832d 29#include <linux/usb/gpio_vbus.h>
5d783a2d
MV
30
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34
4c25c5d2 35#include "pxa25x.h"
5d783a2d
MV
36#include <mach/audio.h>
37#include <mach/palmtc.h>
293b2da1
AB
38#include <linux/platform_data/mmc-pxamci.h>
39#include <linux/platform_data/video-pxafb.h>
40#include <linux/platform_data/irda-pxaficp.h>
4c25c5d2 41#include "udc.h"
5d783a2d
MV
42
43#include "generic.h"
44#include "devices.h"
45
46/******************************************************************************
47 * Pin configuration
48 ******************************************************************************/
49static unsigned long palmtc_pin_config[] __initdata = {
50 /* MMC */
51 GPIO6_MMC_CLK,
52 GPIO8_MMC_CS0,
53 GPIO12_GPIO, /* detect */
54 GPIO32_GPIO, /* power */
55 GPIO54_GPIO, /* r/o switch */
56
57 /* PCMCIA */
58 GPIO52_nPCE_1,
59 GPIO53_nPCE_2,
60 GPIO50_nPIOR,
61 GPIO51_nPIOW,
62 GPIO49_nPWE,
63 GPIO48_nPOE,
64 GPIO52_nPCE_1,
65 GPIO53_nPCE_2,
66 GPIO57_nIOIS16,
67 GPIO56_nPWAIT,
68
69 /* AC97 */
70 GPIO28_AC97_BITCLK,
71 GPIO29_AC97_SDATA_IN_0,
72 GPIO30_AC97_SDATA_OUT,
73 GPIO31_AC97_SYNC,
74
75 /* IrDA */
76 GPIO45_GPIO, /* ir disable */
77 GPIO46_FICP_RXD,
78 GPIO47_FICP_TXD,
79
80 /* PWM */
81 GPIO17_PWM1_OUT,
82
83 /* USB */
84 GPIO4_GPIO, /* detect */
85 GPIO36_GPIO, /* pullup */
86
87 /* LCD */
07bae6c3 88 GPIOxx_LCD_TFT_16BPP,
5d783a2d
MV
89
90 /* MATRIX KEYPAD */
91 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 0 */
92 GPIO9_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 1 */
93 GPIO10_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 2 */
94 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 3 */
95 GPIO18_GPIO | MFP_LPM_DRIVE_LOW, /* out 0 */
96 GPIO19_GPIO | MFP_LPM_DRIVE_LOW, /* out 1 */
97 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* out 2 */
98 GPIO21_GPIO | MFP_LPM_DRIVE_LOW, /* out 3 */
99 GPIO22_GPIO | MFP_LPM_DRIVE_LOW, /* out 4 */
100 GPIO23_GPIO | MFP_LPM_DRIVE_LOW, /* out 5 */
101 GPIO24_GPIO | MFP_LPM_DRIVE_LOW, /* out 6 */
102 GPIO25_GPIO | MFP_LPM_DRIVE_LOW, /* out 7 */
103 GPIO26_GPIO | MFP_LPM_DRIVE_LOW, /* out 8 */
104 GPIO27_GPIO | MFP_LPM_DRIVE_LOW, /* out 9 */
105 GPIO79_GPIO | MFP_LPM_DRIVE_LOW, /* out 10 */
106 GPIO80_GPIO | MFP_LPM_DRIVE_LOW, /* out 11 */
107
108 /* PXA GPIO KEYS */
109 GPIO7_GPIO | WAKEUP_ON_EDGE_BOTH, /* hotsync button on cradle */
110
111 /* MISC */
112 GPIO1_RST, /* reset */
113 GPIO2_GPIO, /* earphone detect */
114 GPIO16_GPIO, /* backlight switch */
115};
116
117/******************************************************************************
118 * SD/MMC card controller
119 ******************************************************************************/
4c6a832d 120#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
5d783a2d
MV
121static struct pxamci_platform_data palmtc_mci_platform_data = {
122 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
f97cab28 123 .detect_delay_ms = 200,
5d783a2d
MV
124};
125
32d15448
LW
126static struct gpiod_lookup_table palmtc_mci_gpio_table = {
127 .dev_id = "pxa2xx-mci.0",
128 .table = {
129 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_DETECT_N,
130 "cd", GPIO_ACTIVE_LOW),
131 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_READONLY,
132 "wp", GPIO_ACTIVE_LOW),
f54005b5
LW
133 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_POWER,
134 "power", GPIO_ACTIVE_HIGH),
32d15448
LW
135 { },
136 },
137};
138
4c6a832d
MV
139static void __init palmtc_mmc_init(void)
140{
32d15448 141 gpiod_add_lookup_table(&palmtc_mci_gpio_table);
4c6a832d
MV
142 pxa_set_mci_info(&palmtc_mci_platform_data);
143}
144#else
145static inline void palmtc_mmc_init(void) {}
146#endif
147
5d783a2d
MV
148/******************************************************************************
149 * GPIO keys
150 ******************************************************************************/
4c6a832d 151#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
5d783a2d
MV
152static struct gpio_keys_button palmtc_pxa_buttons[] = {
153 {KEY_F8, GPIO_NR_PALMTC_HOTSYNC_BUTTON, 1, "HotSync Button", EV_KEY, 1},
154};
155
156static struct gpio_keys_platform_data palmtc_pxa_keys_data = {
157 .buttons = palmtc_pxa_buttons,
158 .nbuttons = ARRAY_SIZE(palmtc_pxa_buttons),
159};
160
161static struct platform_device palmtc_pxa_keys = {
162 .name = "gpio-keys",
163 .id = -1,
164 .dev = {
165 .platform_data = &palmtc_pxa_keys_data,
166 },
167};
168
4c6a832d
MV
169static void __init palmtc_keys_init(void)
170{
171 platform_device_register(&palmtc_pxa_keys);
172}
173#else
174static inline void palmtc_keys_init(void) {}
175#endif
176
5d783a2d
MV
177/******************************************************************************
178 * Backlight
179 ******************************************************************************/
4c6a832d 180#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
bfcb3117
TR
181static struct pwm_lookup palmtc_pwm_lookup[] = {
182 PWM_LOOKUP("pxa25x-pwm.1", 0, "pwm-backlight.0", NULL, PALMTC_PERIOD_NS,
ca1ef9ce 183 PWM_POLARITY_NORMAL),
bfcb3117
TR
184};
185
5d783a2d 186static struct platform_pwm_backlight_data palmtc_backlight_data = {
5d783a2d
MV
187 .max_brightness = PALMTC_MAX_INTENSITY,
188 .dft_brightness = PALMTC_MAX_INTENSITY,
db01120c 189 .enable_gpio = GPIO_NR_PALMTC_BL_POWER,
5d783a2d
MV
190};
191
192static struct platform_device palmtc_backlight = {
193 .name = "pwm-backlight",
194 .dev = {
195 .parent = &pxa25x_device_pwm1.dev,
196 .platform_data = &palmtc_backlight_data,
197 },
198};
199
4c6a832d
MV
200static void __init palmtc_pwm_init(void)
201{
bfcb3117 202 pwm_add_table(palmtc_pwm_lookup, ARRAY_SIZE(palmtc_pwm_lookup));
4c6a832d
MV
203 platform_device_register(&palmtc_backlight);
204}
205#else
206static inline void palmtc_pwm_init(void) {}
207#endif
208
5d783a2d
MV
209/******************************************************************************
210 * IrDA
211 ******************************************************************************/
4c6a832d 212#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
5d783a2d 213static struct pxaficp_platform_data palmtc_ficp_platform_data = {
c4bd0172
MV
214 .gpio_pwdown = GPIO_NR_PALMTC_IR_DISABLE,
215 .transceiver_cap = IR_SIRMODE | IR_OFF,
5d783a2d
MV
216};
217
4c6a832d
MV
218static void __init palmtc_irda_init(void)
219{
220 pxa_set_ficp_info(&palmtc_ficp_platform_data);
221}
222#else
223static inline void palmtc_irda_init(void) {}
224#endif
225
5d783a2d
MV
226/******************************************************************************
227 * Keyboard
228 ******************************************************************************/
4c6a832d 229#if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
5d783a2d
MV
230static const uint32_t palmtc_matrix_keys[] = {
231 KEY(0, 0, KEY_F1),
232 KEY(0, 1, KEY_X),
233 KEY(0, 2, KEY_POWER),
234 KEY(0, 3, KEY_TAB),
235 KEY(0, 4, KEY_A),
236 KEY(0, 5, KEY_Q),
237 KEY(0, 6, KEY_LEFTSHIFT),
238 KEY(0, 7, KEY_Z),
239 KEY(0, 8, KEY_S),
240 KEY(0, 9, KEY_W),
241 KEY(0, 10, KEY_E),
242 KEY(0, 11, KEY_UP),
243
244 KEY(1, 0, KEY_F2),
245 KEY(1, 1, KEY_DOWN),
246 KEY(1, 3, KEY_D),
247 KEY(1, 4, KEY_C),
248 KEY(1, 5, KEY_F),
249 KEY(1, 6, KEY_R),
250 KEY(1, 7, KEY_SPACE),
251 KEY(1, 8, KEY_V),
252 KEY(1, 9, KEY_G),
253 KEY(1, 10, KEY_T),
254 KEY(1, 11, KEY_LEFT),
255
256 KEY(2, 0, KEY_F3),
257 KEY(2, 1, KEY_LEFTCTRL),
258 KEY(2, 3, KEY_H),
259 KEY(2, 4, KEY_Y),
260 KEY(2, 5, KEY_N),
261 KEY(2, 6, KEY_J),
262 KEY(2, 7, KEY_U),
263 KEY(2, 8, KEY_M),
264 KEY(2, 9, KEY_K),
265 KEY(2, 10, KEY_I),
266 KEY(2, 11, KEY_RIGHT),
267
268 KEY(3, 0, KEY_F4),
269 KEY(3, 1, KEY_ENTER),
270 KEY(3, 3, KEY_DOT),
271 KEY(3, 4, KEY_L),
272 KEY(3, 5, KEY_O),
273 KEY(3, 6, KEY_LEFTALT),
274 KEY(3, 7, KEY_ENTER),
275 KEY(3, 8, KEY_BACKSPACE),
276 KEY(3, 9, KEY_P),
277 KEY(3, 10, KEY_B),
278 KEY(3, 11, KEY_FN),
279};
280
281const struct matrix_keymap_data palmtc_keymap_data = {
282 .keymap = palmtc_matrix_keys,
283 .keymap_size = ARRAY_SIZE(palmtc_matrix_keys),
284};
285
600ae40d 286static const unsigned int palmtc_keypad_row_gpios[] = {
5d783a2d
MV
287 0, 9, 10, 11
288};
289
600ae40d 290static const unsigned int palmtc_keypad_col_gpios[] = {
5d783a2d
MV
291 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
292};
293
294static struct matrix_keypad_platform_data palmtc_keypad_platform_data = {
295 .keymap_data = &palmtc_keymap_data,
902805db
OZ
296 .row_gpios = palmtc_keypad_row_gpios,
297 .num_row_gpios = ARRAY_SIZE(palmtc_keypad_row_gpios),
298 .col_gpios = palmtc_keypad_col_gpios,
299 .num_col_gpios = ARRAY_SIZE(palmtc_keypad_col_gpios),
5d783a2d
MV
300 .active_low = 1,
301
302 .debounce_ms = 20,
303 .col_scan_delay_us = 5,
304};
305
306static struct platform_device palmtc_keyboard = {
307 .name = "matrix-keypad",
308 .id = -1,
309 .dev = {
310 .platform_data = &palmtc_keypad_platform_data,
311 },
312};
4c6a832d
MV
313static void __init palmtc_mkp_init(void)
314{
315 platform_device_register(&palmtc_keyboard);
316}
317#else
318static inline void palmtc_mkp_init(void) {}
319#endif
5d783a2d
MV
320
321/******************************************************************************
322 * UDC
323 ******************************************************************************/
c0a39151 324#if defined(CONFIG_USB_PXA25X)||defined(CONFIG_USB_PXA25X_MODULE)
4c6a832d 325static struct gpio_vbus_mach_info palmtc_udc_info = {
5d783a2d
MV
326 .gpio_vbus = GPIO_NR_PALMTC_USB_DETECT_N,
327 .gpio_vbus_inverted = 1,
328 .gpio_pullup = GPIO_NR_PALMTC_USB_POWER,
329};
330
4c6a832d
MV
331static struct platform_device palmtc_gpio_vbus = {
332 .name = "gpio-vbus",
333 .id = -1,
334 .dev = {
335 .platform_data = &palmtc_udc_info,
336 },
337};
338
339static void __init palmtc_udc_init(void)
340{
341 platform_device_register(&palmtc_gpio_vbus);
342};
343#else
344static inline void palmtc_udc_init(void) {}
345#endif
346
5d783a2d
MV
347/******************************************************************************
348 * Touchscreen / Battery / GPIO-extender
349 ******************************************************************************/
4c6a832d
MV
350#if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
351 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
352static struct platform_device palmtc_ucb1400_device = {
5d783a2d
MV
353 .name = "ucb1400_core",
354 .id = -1,
355};
356
4c6a832d
MV
357static void __init palmtc_ts_init(void)
358{
359 pxa_set_ac97_info(NULL);
360 platform_device_register(&palmtc_ucb1400_device);
361}
362#else
363static inline void palmtc_ts_init(void) {}
364#endif
365
5fe2acce
MV
366/******************************************************************************
367 * LEDs
368 ******************************************************************************/
369#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
370struct gpio_led palmtc_gpio_leds[] = {
371{
372 .name = "palmtc:green:user",
373 .default_trigger = "none",
374 .gpio = GPIO_NR_PALMTC_LED_POWER,
375 .active_low = 1,
376}, {
377 .name = "palmtc:vibra:vibra",
378 .default_trigger = "none",
379 .gpio = GPIO_NR_PALMTC_VIBRA_POWER,
380 .active_low = 1,
381}
382
383};
384
385static struct gpio_led_platform_data palmtc_gpio_led_info = {
386 .leds = palmtc_gpio_leds,
387 .num_leds = ARRAY_SIZE(palmtc_gpio_leds),
388};
389
390static struct platform_device palmtc_leds = {
391 .name = "leds-gpio",
392 .id = -1,
393 .dev = {
394 .platform_data = &palmtc_gpio_led_info,
395 }
396};
397
398static void __init palmtc_leds_init(void)
399{
400 platform_device_register(&palmtc_leds);
401}
402#else
403static inline void palmtc_leds_init(void) {}
404#endif
405
5d783a2d
MV
406/******************************************************************************
407 * NOR Flash
408 ******************************************************************************/
4c6a832d 409#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
5d783a2d
MV
410static struct resource palmtc_flash_resource = {
411 .start = PXA_CS0_PHYS,
412 .end = PXA_CS0_PHYS + SZ_16M - 1,
413 .flags = IORESOURCE_MEM,
414};
415
416static struct mtd_partition palmtc_flash_parts[] = {
417 {
418 .name = "U-Boot Bootloader",
419 .offset = 0x0,
420 .size = 0x40000,
421 },
422 {
423 .name = "Linux Kernel",
424 .offset = 0x40000,
425 .size = 0x2c0000,
426 },
427 {
428 .name = "Filesystem",
429 .offset = 0x300000,
430 .size = 0xcc0000,
431 },
432 {
433 .name = "U-Boot Environment",
434 .offset = 0xfc0000,
435 .size = MTDPART_SIZ_FULL,
436 },
437};
438
439static struct physmap_flash_data palmtc_flash_data = {
440 .width = 4,
441 .parts = palmtc_flash_parts,
442 .nr_parts = ARRAY_SIZE(palmtc_flash_parts),
443};
444
445static struct platform_device palmtc_flash = {
446 .name = "physmap-flash",
447 .id = -1,
448 .resource = &palmtc_flash_resource,
449 .num_resources = 1,
450 .dev = {
451 .platform_data = &palmtc_flash_data,
452 },
453};
454
4c6a832d
MV
455static void __init palmtc_nor_init(void)
456{
457 platform_device_register(&palmtc_flash);
458}
459#else
460static inline void palmtc_nor_init(void) {}
461#endif
462
5d783a2d
MV
463/******************************************************************************
464 * Framebuffer
465 ******************************************************************************/
4c6a832d 466#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
5d783a2d 467static struct pxafb_mode_info palmtc_lcd_modes[] = {
4c6a832d
MV
468 {
469 .pixclock = 115384,
470 .xres = 320,
471 .yres = 320,
472 .bpp = 16,
473
474 .left_margin = 27,
475 .right_margin = 7,
476 .upper_margin = 7,
477 .lower_margin = 8,
478
479 .hsync_len = 6,
480 .vsync_len = 1,
481 },
5d783a2d
MV
482};
483
484static struct pxafb_mach_info palmtc_lcd_screen = {
485 .modes = palmtc_lcd_modes,
486 .num_modes = ARRAY_SIZE(palmtc_lcd_modes),
487 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
488};
489
4c6a832d
MV
490static void __init palmtc_lcd_init(void)
491{
4321e1a1 492 pxa_set_fb_info(NULL, &palmtc_lcd_screen);
4c6a832d
MV
493}
494#else
495static inline void palmtc_lcd_init(void) {}
496#endif
497
5d783a2d
MV
498/******************************************************************************
499 * Machine init
500 ******************************************************************************/
5d783a2d
MV
501static void __init palmtc_init(void)
502{
503 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config));
504
cc155c6f
RK
505 pxa_set_ffuart_info(NULL);
506 pxa_set_btuart_info(NULL);
507 pxa_set_stuart_info(NULL);
508 pxa_set_hwuart_info(NULL);
509
4c6a832d
MV
510 palmtc_mmc_init();
511 palmtc_keys_init();
512 palmtc_pwm_init();
513 palmtc_irda_init();
514 palmtc_mkp_init();
515 palmtc_udc_init();
516 palmtc_ts_init();
517 palmtc_nor_init();
518 palmtc_lcd_init();
5fe2acce 519 palmtc_leds_init();
5d783a2d
MV
520};
521
522MACHINE_START(PALMTC, "Palm Tungsten|C")
7375aba6 523 .atag_offset = 0x100,
851982c1 524 .map_io = pxa25x_map_io,
4e611091 525 .nr_irqs = PXA_NR_IRQS,
5d783a2d 526 .init_irq = pxa25x_init_irq,
8a97ae2f 527 .handle_irq = pxa25x_handle_irq,
6bb27d73 528 .init_time = pxa_timer_init,
271a74fc
RK
529 .init_machine = palmtc_init,
530 .restart = pxa_restart,
5d783a2d 531MACHINE_END
This page took 0.879638 seconds and 4 git commands to generate.