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>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
32 #include <mach/audio.h>
33 #include <mach/palmtc.h>
34 #include <linux/platform_data/mmc-pxamci.h>
35 #include <linux/platform_data/video-pxafb.h>
36 #include <linux/platform_data/irda-pxaficp.h>
42 /******************************************************************************
44 ******************************************************************************/
45 static unsigned long palmtc_pin_config
[] __initdata
= {
49 GPIO12_GPIO
, /* detect */
50 GPIO32_GPIO
, /* power */
51 GPIO54_GPIO
, /* r/o switch */
67 GPIO29_AC97_SDATA_IN_0
,
68 GPIO30_AC97_SDATA_OUT
,
72 GPIO45_GPIO
, /* ir disable */
80 GPIO4_GPIO
, /* detect */
81 GPIO36_GPIO
, /* pullup */
87 GPIO0_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 0 */
88 GPIO9_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 1 */
89 GPIO10_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 2 */
90 GPIO11_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 3 */
91 GPIO18_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 0 */
92 GPIO19_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 1 */
93 GPIO20_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 2 */
94 GPIO21_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 3 */
95 GPIO22_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 4 */
96 GPIO23_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 5 */
97 GPIO24_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 6 */
98 GPIO25_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 7 */
99 GPIO26_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 8 */
100 GPIO27_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 9 */
101 GPIO79_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 10 */
102 GPIO80_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 11 */
105 GPIO7_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* hotsync button on cradle */
108 GPIO1_RST
, /* reset */
109 GPIO2_GPIO
, /* earphone detect */
110 GPIO16_GPIO
, /* backlight switch */
113 /******************************************************************************
114 * SD/MMC card controller
115 ******************************************************************************/
116 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
117 static struct pxamci_platform_data palmtc_mci_platform_data
= {
118 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
119 .detect_delay_ms
= 200,
122 static struct gpiod_lookup_table palmtc_mci_gpio_table
= {
123 .dev_id
= "pxa2xx-mci.0",
125 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_DETECT_N
,
126 "cd", GPIO_ACTIVE_LOW
),
127 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_READONLY
,
128 "wp", GPIO_ACTIVE_LOW
),
129 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_POWER
,
130 "power", GPIO_ACTIVE_HIGH
),
135 static void __init
palmtc_mmc_init(void)
137 gpiod_add_lookup_table(&palmtc_mci_gpio_table
);
138 pxa_set_mci_info(&palmtc_mci_platform_data
);
141 static inline void palmtc_mmc_init(void) {}
144 /******************************************************************************
146 ******************************************************************************/
147 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
148 static struct gpio_keys_button palmtc_pxa_buttons
[] = {
149 {KEY_F8
, GPIO_NR_PALMTC_HOTSYNC_BUTTON
, 1, "HotSync Button", EV_KEY
, 1},
152 static struct gpio_keys_platform_data palmtc_pxa_keys_data
= {
153 .buttons
= palmtc_pxa_buttons
,
154 .nbuttons
= ARRAY_SIZE(palmtc_pxa_buttons
),
157 static struct platform_device palmtc_pxa_keys
= {
161 .platform_data
= &palmtc_pxa_keys_data
,
165 static void __init
palmtc_keys_init(void)
167 platform_device_register(&palmtc_pxa_keys
);
170 static inline void palmtc_keys_init(void) {}
173 /******************************************************************************
175 ******************************************************************************/
176 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
178 static struct gpiod_lookup_table palmtc_pwm_bl_gpio_table
= {
179 .dev_id
= "pwm-backlight.0",
181 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_BL_POWER
,
182 "enable", GPIO_ACTIVE_HIGH
),
186 static struct pwm_lookup palmtc_pwm_lookup
[] = {
187 PWM_LOOKUP("pxa25x-pwm.1", 0, "pwm-backlight.0", NULL
, PALMTC_PERIOD_NS
,
188 PWM_POLARITY_NORMAL
),
191 static struct platform_pwm_backlight_data palmtc_backlight_data
= {
192 .max_brightness
= PALMTC_MAX_INTENSITY
,
193 .dft_brightness
= PALMTC_MAX_INTENSITY
,
196 static struct platform_device palmtc_backlight
= {
197 .name
= "pwm-backlight",
199 .parent
= &pxa25x_device_pwm1
.dev
,
200 .platform_data
= &palmtc_backlight_data
,
204 static void __init
palmtc_pwm_init(void)
206 gpiod_add_lookup_table(&palmtc_pwm_bl_gpio_table
);
207 pwm_add_table(palmtc_pwm_lookup
, ARRAY_SIZE(palmtc_pwm_lookup
));
208 platform_device_register(&palmtc_backlight
);
211 static inline void palmtc_pwm_init(void) {}
214 /******************************************************************************
216 ******************************************************************************/
217 #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
218 static struct pxaficp_platform_data palmtc_ficp_platform_data
= {
219 .gpio_pwdown
= GPIO_NR_PALMTC_IR_DISABLE
,
220 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
223 static void __init
palmtc_irda_init(void)
225 pxa_set_ficp_info(&palmtc_ficp_platform_data
);
228 static inline void palmtc_irda_init(void) {}
231 /******************************************************************************
233 ******************************************************************************/
234 #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
235 static const uint32_t palmtc_matrix_keys
[] = {
238 KEY(0, 2, KEY_POWER
),
242 KEY(0, 6, KEY_LEFTSHIFT
),
255 KEY(1, 7, KEY_SPACE
),
259 KEY(1, 11, KEY_LEFT
),
262 KEY(2, 1, KEY_LEFTCTRL
),
271 KEY(2, 11, KEY_RIGHT
),
274 KEY(3, 1, KEY_ENTER
),
278 KEY(3, 6, KEY_LEFTALT
),
279 KEY(3, 7, KEY_ENTER
),
280 KEY(3, 8, KEY_BACKSPACE
),
286 const struct matrix_keymap_data palmtc_keymap_data
= {
287 .keymap
= palmtc_matrix_keys
,
288 .keymap_size
= ARRAY_SIZE(palmtc_matrix_keys
),
291 static const unsigned int palmtc_keypad_row_gpios
[] = {
295 static const unsigned int palmtc_keypad_col_gpios
[] = {
296 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
299 static struct matrix_keypad_platform_data palmtc_keypad_platform_data
= {
300 .keymap_data
= &palmtc_keymap_data
,
301 .row_gpios
= palmtc_keypad_row_gpios
,
302 .num_row_gpios
= ARRAY_SIZE(palmtc_keypad_row_gpios
),
303 .col_gpios
= palmtc_keypad_col_gpios
,
304 .num_col_gpios
= ARRAY_SIZE(palmtc_keypad_col_gpios
),
308 .col_scan_delay_us
= 5,
311 static struct platform_device palmtc_keyboard
= {
312 .name
= "matrix-keypad",
315 .platform_data
= &palmtc_keypad_platform_data
,
318 static void __init
palmtc_mkp_init(void)
320 platform_device_register(&palmtc_keyboard
);
323 static inline void palmtc_mkp_init(void) {}
326 /******************************************************************************
328 ******************************************************************************/
329 #if defined(CONFIG_USB_PXA25X)||defined(CONFIG_USB_PXA25X_MODULE)
330 static struct gpiod_lookup_table palmtc_udc_gpiod_table
= {
331 .dev_id
= "gpio-vbus",
333 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_USB_DETECT_N
,
334 "vbus", GPIO_ACTIVE_LOW
),
335 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_USB_POWER
,
336 "pullup", GPIO_ACTIVE_HIGH
),
341 static struct platform_device palmtc_gpio_vbus
= {
346 static void __init
palmtc_udc_init(void)
348 gpiod_add_lookup_table(&palmtc_udc_gpiod_table
);
349 platform_device_register(&palmtc_gpio_vbus
);
352 static inline void palmtc_udc_init(void) {}
355 /******************************************************************************
356 * Touchscreen / Battery / GPIO-extender
357 ******************************************************************************/
358 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
359 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
360 static struct platform_device palmtc_ucb1400_device
= {
361 .name
= "ucb1400_core",
365 static void __init
palmtc_ts_init(void)
367 pxa_set_ac97_info(NULL
);
368 platform_device_register(&palmtc_ucb1400_device
);
371 static inline void palmtc_ts_init(void) {}
374 /******************************************************************************
376 ******************************************************************************/
377 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
378 struct gpio_led palmtc_gpio_leds
[] = {
380 .name
= "palmtc:green:user",
381 .default_trigger
= "none",
382 .gpio
= GPIO_NR_PALMTC_LED_POWER
,
385 .name
= "palmtc:vibra:vibra",
386 .default_trigger
= "none",
387 .gpio
= GPIO_NR_PALMTC_VIBRA_POWER
,
393 static struct gpio_led_platform_data palmtc_gpio_led_info
= {
394 .leds
= palmtc_gpio_leds
,
395 .num_leds
= ARRAY_SIZE(palmtc_gpio_leds
),
398 static struct platform_device palmtc_leds
= {
402 .platform_data
= &palmtc_gpio_led_info
,
406 static void __init
palmtc_leds_init(void)
408 platform_device_register(&palmtc_leds
);
411 static inline void palmtc_leds_init(void) {}
414 /******************************************************************************
416 ******************************************************************************/
417 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
418 static struct resource palmtc_flash_resource
= {
419 .start
= PXA_CS0_PHYS
,
420 .end
= PXA_CS0_PHYS
+ SZ_16M
- 1,
421 .flags
= IORESOURCE_MEM
,
424 static struct mtd_partition palmtc_flash_parts
[] = {
426 .name
= "U-Boot Bootloader",
431 .name
= "Linux Kernel",
436 .name
= "Filesystem",
441 .name
= "U-Boot Environment",
443 .size
= MTDPART_SIZ_FULL
,
447 static struct physmap_flash_data palmtc_flash_data
= {
449 .parts
= palmtc_flash_parts
,
450 .nr_parts
= ARRAY_SIZE(palmtc_flash_parts
),
453 static struct platform_device palmtc_flash
= {
454 .name
= "physmap-flash",
456 .resource
= &palmtc_flash_resource
,
459 .platform_data
= &palmtc_flash_data
,
463 static void __init
palmtc_nor_init(void)
465 platform_device_register(&palmtc_flash
);
468 static inline void palmtc_nor_init(void) {}
471 /******************************************************************************
473 ******************************************************************************/
474 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
475 static struct pxafb_mode_info palmtc_lcd_modes
[] = {
492 static struct pxafb_mach_info palmtc_lcd_screen
= {
493 .modes
= palmtc_lcd_modes
,
494 .num_modes
= ARRAY_SIZE(palmtc_lcd_modes
),
495 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
498 static void __init
palmtc_lcd_init(void)
500 pxa_set_fb_info(NULL
, &palmtc_lcd_screen
);
503 static inline void palmtc_lcd_init(void) {}
506 /******************************************************************************
508 ******************************************************************************/
509 static void __init
palmtc_init(void)
511 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config
));
513 pxa_set_ffuart_info(NULL
);
514 pxa_set_btuart_info(NULL
);
515 pxa_set_stuart_info(NULL
);
516 pxa_set_hwuart_info(NULL
);
530 MACHINE_START(PALMTC
, "Palm Tungsten|C")
531 .atag_offset
= 0x100,
532 .map_io
= pxa25x_map_io
,
533 .nr_irqs
= PXA_NR_IRQS
,
534 .init_irq
= pxa25x_init_irq
,
535 .handle_irq
= pxa25x_handle_irq
,
536 .init_time
= pxa_timer_init
,
537 .init_machine
= palmtc_init
,
538 .restart
= pxa_restart
,