1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-pxa/palmtc.c
5 * Support for the Palm Tungsten|C
7 * Author: Marek Vasut <marek.vasut@gmail.com>
10 * Petr Blaha <p3t3@centrum.cz>
11 * Chetan S. Kumar <shivakumar.chetan@gmail.com>
14 #include <linux/platform_device.h>
15 #include <linux/delay.h>
16 #include <linux/irq.h>
17 #include <linux/input.h>
18 #include <linux/pwm.h>
19 #include <linux/pwm_backlight.h>
20 #include <linux/gpio/machine.h>
21 #include <linux/input/matrix_keypad.h>
22 #include <linux/ucb1400.h>
23 #include <linux/power_supply.h>
24 #include <linux/gpio_keys.h>
25 #include <linux/mtd/physmap.h>
26 #include <linux/usb/gpio_vbus.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
33 #include <mach/audio.h>
34 #include <mach/palmtc.h>
35 #include <linux/platform_data/mmc-pxamci.h>
36 #include <linux/platform_data/video-pxafb.h>
37 #include <linux/platform_data/irda-pxaficp.h>
43 /******************************************************************************
45 ******************************************************************************/
46 static unsigned long palmtc_pin_config[] __initdata = {
50 GPIO12_GPIO, /* detect */
51 GPIO32_GPIO, /* power */
52 GPIO54_GPIO, /* r/o switch */
68 GPIO29_AC97_SDATA_IN_0,
69 GPIO30_AC97_SDATA_OUT,
73 GPIO45_GPIO, /* ir disable */
81 GPIO4_GPIO, /* detect */
82 GPIO36_GPIO, /* pullup */
88 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 0 */
89 GPIO9_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 1 */
90 GPIO10_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 2 */
91 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 3 */
92 GPIO18_GPIO | MFP_LPM_DRIVE_LOW, /* out 0 */
93 GPIO19_GPIO | MFP_LPM_DRIVE_LOW, /* out 1 */
94 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* out 2 */
95 GPIO21_GPIO | MFP_LPM_DRIVE_LOW, /* out 3 */
96 GPIO22_GPIO | MFP_LPM_DRIVE_LOW, /* out 4 */
97 GPIO23_GPIO | MFP_LPM_DRIVE_LOW, /* out 5 */
98 GPIO24_GPIO | MFP_LPM_DRIVE_LOW, /* out 6 */
99 GPIO25_GPIO | MFP_LPM_DRIVE_LOW, /* out 7 */
100 GPIO26_GPIO | MFP_LPM_DRIVE_LOW, /* out 8 */
101 GPIO27_GPIO | MFP_LPM_DRIVE_LOW, /* out 9 */
102 GPIO79_GPIO | MFP_LPM_DRIVE_LOW, /* out 10 */
103 GPIO80_GPIO | MFP_LPM_DRIVE_LOW, /* out 11 */
106 GPIO7_GPIO | WAKEUP_ON_EDGE_BOTH, /* hotsync button on cradle */
109 GPIO1_RST, /* reset */
110 GPIO2_GPIO, /* earphone detect */
111 GPIO16_GPIO, /* backlight switch */
114 /******************************************************************************
115 * SD/MMC card controller
116 ******************************************************************************/
117 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
118 static struct pxamci_platform_data palmtc_mci_platform_data = {
119 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
120 .detect_delay_ms = 200,
123 static struct gpiod_lookup_table palmtc_mci_gpio_table = {
124 .dev_id = "pxa2xx-mci.0",
126 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_DETECT_N,
127 "cd", GPIO_ACTIVE_LOW),
128 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_READONLY,
129 "wp", GPIO_ACTIVE_LOW),
130 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_POWER,
131 "power", GPIO_ACTIVE_HIGH),
136 static void __init palmtc_mmc_init(void)
138 gpiod_add_lookup_table(&palmtc_mci_gpio_table);
139 pxa_set_mci_info(&palmtc_mci_platform_data);
142 static inline void palmtc_mmc_init(void) {}
145 /******************************************************************************
147 ******************************************************************************/
148 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
149 static struct gpio_keys_button palmtc_pxa_buttons[] = {
150 {KEY_F8, GPIO_NR_PALMTC_HOTSYNC_BUTTON, 1, "HotSync Button", EV_KEY, 1},
153 static struct gpio_keys_platform_data palmtc_pxa_keys_data = {
154 .buttons = palmtc_pxa_buttons,
155 .nbuttons = ARRAY_SIZE(palmtc_pxa_buttons),
158 static struct platform_device palmtc_pxa_keys = {
162 .platform_data = &palmtc_pxa_keys_data,
166 static void __init palmtc_keys_init(void)
168 platform_device_register(&palmtc_pxa_keys);
171 static inline void palmtc_keys_init(void) {}
174 /******************************************************************************
176 ******************************************************************************/
177 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
178 static struct pwm_lookup palmtc_pwm_lookup[] = {
179 PWM_LOOKUP("pxa25x-pwm.1", 0, "pwm-backlight.0", NULL, PALMTC_PERIOD_NS,
180 PWM_POLARITY_NORMAL),
183 static struct platform_pwm_backlight_data palmtc_backlight_data = {
184 .max_brightness = PALMTC_MAX_INTENSITY,
185 .dft_brightness = PALMTC_MAX_INTENSITY,
186 .enable_gpio = GPIO_NR_PALMTC_BL_POWER,
189 static struct platform_device palmtc_backlight = {
190 .name = "pwm-backlight",
192 .parent = &pxa25x_device_pwm1.dev,
193 .platform_data = &palmtc_backlight_data,
197 static void __init palmtc_pwm_init(void)
199 pwm_add_table(palmtc_pwm_lookup, ARRAY_SIZE(palmtc_pwm_lookup));
200 platform_device_register(&palmtc_backlight);
203 static inline void palmtc_pwm_init(void) {}
206 /******************************************************************************
208 ******************************************************************************/
209 #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
210 static struct pxaficp_platform_data palmtc_ficp_platform_data = {
211 .gpio_pwdown = GPIO_NR_PALMTC_IR_DISABLE,
212 .transceiver_cap = IR_SIRMODE | IR_OFF,
215 static void __init palmtc_irda_init(void)
217 pxa_set_ficp_info(&palmtc_ficp_platform_data);
220 static inline void palmtc_irda_init(void) {}
223 /******************************************************************************
225 ******************************************************************************/
226 #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
227 static const uint32_t palmtc_matrix_keys[] = {
230 KEY(0, 2, KEY_POWER),
234 KEY(0, 6, KEY_LEFTSHIFT),
247 KEY(1, 7, KEY_SPACE),
251 KEY(1, 11, KEY_LEFT),
254 KEY(2, 1, KEY_LEFTCTRL),
263 KEY(2, 11, KEY_RIGHT),
266 KEY(3, 1, KEY_ENTER),
270 KEY(3, 6, KEY_LEFTALT),
271 KEY(3, 7, KEY_ENTER),
272 KEY(3, 8, KEY_BACKSPACE),
278 const struct matrix_keymap_data palmtc_keymap_data = {
279 .keymap = palmtc_matrix_keys,
280 .keymap_size = ARRAY_SIZE(palmtc_matrix_keys),
283 static const unsigned int palmtc_keypad_row_gpios[] = {
287 static const unsigned int palmtc_keypad_col_gpios[] = {
288 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
291 static struct matrix_keypad_platform_data palmtc_keypad_platform_data = {
292 .keymap_data = &palmtc_keymap_data,
293 .row_gpios = palmtc_keypad_row_gpios,
294 .num_row_gpios = ARRAY_SIZE(palmtc_keypad_row_gpios),
295 .col_gpios = palmtc_keypad_col_gpios,
296 .num_col_gpios = ARRAY_SIZE(palmtc_keypad_col_gpios),
300 .col_scan_delay_us = 5,
303 static struct platform_device palmtc_keyboard = {
304 .name = "matrix-keypad",
307 .platform_data = &palmtc_keypad_platform_data,
310 static void __init palmtc_mkp_init(void)
312 platform_device_register(&palmtc_keyboard);
315 static inline void palmtc_mkp_init(void) {}
318 /******************************************************************************
320 ******************************************************************************/
321 #if defined(CONFIG_USB_PXA25X)||defined(CONFIG_USB_PXA25X_MODULE)
322 static struct gpio_vbus_mach_info palmtc_udc_info = {
323 .gpio_vbus = GPIO_NR_PALMTC_USB_DETECT_N,
324 .gpio_vbus_inverted = 1,
325 .gpio_pullup = GPIO_NR_PALMTC_USB_POWER,
328 static struct platform_device palmtc_gpio_vbus = {
332 .platform_data = &palmtc_udc_info,
336 static void __init palmtc_udc_init(void)
338 platform_device_register(&palmtc_gpio_vbus);
341 static inline void palmtc_udc_init(void) {}
344 /******************************************************************************
345 * Touchscreen / Battery / GPIO-extender
346 ******************************************************************************/
347 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
348 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
349 static struct platform_device palmtc_ucb1400_device = {
350 .name = "ucb1400_core",
354 static void __init palmtc_ts_init(void)
356 pxa_set_ac97_info(NULL);
357 platform_device_register(&palmtc_ucb1400_device);
360 static inline void palmtc_ts_init(void) {}
363 /******************************************************************************
365 ******************************************************************************/
366 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
367 struct gpio_led palmtc_gpio_leds[] = {
369 .name = "palmtc:green:user",
370 .default_trigger = "none",
371 .gpio = GPIO_NR_PALMTC_LED_POWER,
374 .name = "palmtc:vibra:vibra",
375 .default_trigger = "none",
376 .gpio = GPIO_NR_PALMTC_VIBRA_POWER,
382 static struct gpio_led_platform_data palmtc_gpio_led_info = {
383 .leds = palmtc_gpio_leds,
384 .num_leds = ARRAY_SIZE(palmtc_gpio_leds),
387 static struct platform_device palmtc_leds = {
391 .platform_data = &palmtc_gpio_led_info,
395 static void __init palmtc_leds_init(void)
397 platform_device_register(&palmtc_leds);
400 static inline void palmtc_leds_init(void) {}
403 /******************************************************************************
405 ******************************************************************************/
406 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
407 static struct resource palmtc_flash_resource = {
408 .start = PXA_CS0_PHYS,
409 .end = PXA_CS0_PHYS + SZ_16M - 1,
410 .flags = IORESOURCE_MEM,
413 static struct mtd_partition palmtc_flash_parts[] = {
415 .name = "U-Boot Bootloader",
420 .name = "Linux Kernel",
425 .name = "Filesystem",
430 .name = "U-Boot Environment",
432 .size = MTDPART_SIZ_FULL,
436 static struct physmap_flash_data palmtc_flash_data = {
438 .parts = palmtc_flash_parts,
439 .nr_parts = ARRAY_SIZE(palmtc_flash_parts),
442 static struct platform_device palmtc_flash = {
443 .name = "physmap-flash",
445 .resource = &palmtc_flash_resource,
448 .platform_data = &palmtc_flash_data,
452 static void __init palmtc_nor_init(void)
454 platform_device_register(&palmtc_flash);
457 static inline void palmtc_nor_init(void) {}
460 /******************************************************************************
462 ******************************************************************************/
463 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
464 static struct pxafb_mode_info palmtc_lcd_modes[] = {
481 static struct pxafb_mach_info palmtc_lcd_screen = {
482 .modes = palmtc_lcd_modes,
483 .num_modes = ARRAY_SIZE(palmtc_lcd_modes),
484 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
487 static void __init palmtc_lcd_init(void)
489 pxa_set_fb_info(NULL, &palmtc_lcd_screen);
492 static inline void palmtc_lcd_init(void) {}
495 /******************************************************************************
497 ******************************************************************************/
498 static void __init palmtc_init(void)
500 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config));
502 pxa_set_ffuart_info(NULL);
503 pxa_set_btuart_info(NULL);
504 pxa_set_stuart_info(NULL);
505 pxa_set_hwuart_info(NULL);
519 MACHINE_START(PALMTC, "Palm Tungsten|C")
520 .atag_offset = 0x100,
521 .map_io = pxa25x_map_io,
522 .nr_irqs = PXA_NR_IRQS,
523 .init_irq = pxa25x_init_irq,
524 .handle_irq = pxa25x_handle_irq,
525 .init_time = pxa_timer_init,
526 .init_machine = palmtc_init,
527 .restart = pxa_restart,