1 // SPDX-License-Identifier: GPL-2.0-only
3 * Hardware definitions for Palm Treo smartphones
7 * Palm Centro 685 (GSM)
9 * Author: Tomas Cech <sleep_walker@suse.cz>
11 * (find more info at www.hackndev.com)
14 #include <linux/platform_device.h>
15 #include <linux/delay.h>
16 #include <linux/irq.h>
17 #include <linux/gpio_keys.h>
18 #include <linux/input.h>
19 #include <linux/memblock.h>
20 #include <linux/pda_power.h>
21 #include <linux/pwm_backlight.h>
22 #include <linux/gpio.h>
23 #include <linux/power_supply.h>
24 #include <linux/w1-gpio.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
31 #include "pxa27x-udc.h"
32 #include <mach/audio.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>
37 #include <linux/platform_data/keypad-pxa27x.h>
39 #include <linux/platform_data/usb-ohci-pxa27x.h>
40 #include <mach/pxa2xx-regs.h>
41 #include <linux/platform_data/asoc-palm27x.h>
42 #include <linux/platform_data/media/camera-pxa.h>
45 #include <sound/pxa2xx-lib.h>
50 /******************************************************************************
52 ******************************************************************************/
53 static unsigned long treo_pin_config
[] __initdata
= {
61 GPIO113_GPIO
, /* SD detect */
65 GPIO29_AC97_SDATA_IN_0
,
66 GPIO30_AC97_SDATA_OUT
,
79 GPIO1_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* usb detect */
88 GPIO103_KP_MKOUT_0
| MFP_LPM_DRIVE_HIGH
,
95 GPIO93_KP_DKIN_0
| WAKEUP_ON_LEVEL_HIGH
, /* Hotsync button */
97 /* Quick Capture Interface */
116 GPIO14_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* GSM host wake up */
123 GPIO0_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* external power detect */
124 GPIO15_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* silent switch */
125 GPIO116_GPIO
, /* headphone detect */
126 GPIO11_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* bluetooth host wake up */
129 #ifdef CONFIG_MACH_TREO680
130 static unsigned long treo680_pin_config
[] __initdata
= {
131 GPIO33_GPIO
, /* SD read only */
133 /* MATRIX KEYPAD - different wake up source */
134 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
137 /* LCD... L_BIAS alt fn not configured on Treo680; is GPIO instead */
143 #endif /* CONFIG_MACH_TREO680 */
145 #ifdef CONFIG_MACH_CENTRO
146 static unsigned long centro685_pin_config
[] __initdata
= {
147 /* Bluetooth attached to BT UART*/
148 MFP_CFG_OUT(GPIO80
, AF0
, DRIVE_LOW
), /* power: LOW = off */
154 /* MATRIX KEYPAD - different wake up source */
156 GPIO99_KP_MKIN_5
| WAKEUP_ON_LEVEL_HIGH
,
159 GPIOxx_LCD_TFT_16BPP
,
161 #endif /* CONFIG_MACH_CENTRO */
163 /******************************************************************************
165 ******************************************************************************/
166 #if IS_ENABLED(CONFIG_KEYBOARD_PXA27x)
167 static const unsigned int treo680_matrix_keys
[] = {
168 KEY(0, 0, KEY_F8
), /* Red/Off/Power */
170 KEY(0, 2, KEY_LEFTCTRL
), /* Alternate */
176 KEY(1, 0, KEY_RIGHTCTRL
), /* Menu */
177 KEY(1, 1, KEY_RIGHT
),
178 KEY(1, 2, KEY_LEFTSHIFT
), /* Left shift */
183 KEY(2, 0, KEY_F1
), /* Phone */
190 KEY(3, 0, KEY_F10
), /* Calendar */
192 KEY(3, 2, KEY_SPACE
),
197 KEY(4, 0, KEY_F12
), /* Mail */
198 KEY(4, 1, KEY_KPENTER
),
199 KEY(4, 2, KEY_RIGHTALT
), /* Alt */
204 KEY(5, 0, KEY_F9
), /* Home */
205 KEY(5, 1, KEY_PAGEUP
), /* Side up */
211 KEY(6, 0, KEY_TAB
), /* Side Activate */
212 KEY(6, 1, KEY_PAGEDOWN
), /* Side down */
213 KEY(6, 2, KEY_ENTER
),
218 KEY(7, 0, KEY_F6
), /* Green/Call */
220 KEY(7, 2, KEY_BACKSPACE
),
226 static const unsigned int centro_matrix_keys
[] = {
227 KEY(0, 0, KEY_F9
), /* Home */
229 KEY(0, 2, KEY_LEFTCTRL
), /* Alternate */
235 KEY(1, 0, KEY_RIGHTCTRL
), /* Menu */
236 KEY(1, 1, KEY_RIGHT
),
237 KEY(1, 2, KEY_LEFTSHIFT
), /* Left shift */
242 KEY(2, 0, KEY_F1
), /* Phone */
249 KEY(3, 0, KEY_F10
), /* Calendar */
251 KEY(3, 2, KEY_SPACE
),
256 KEY(4, 0, KEY_F12
), /* Mail */
257 KEY(4, 1, KEY_KPENTER
),
258 KEY(4, 2, KEY_RIGHTALT
), /* Alt */
263 KEY(5, 0, KEY_F8
), /* Red/Off/Power */
264 KEY(5, 1, KEY_PAGEUP
), /* Side up */
270 KEY(6, 0, KEY_TAB
), /* Side Activate */
271 KEY(6, 1, KEY_PAGEDOWN
), /* Side down */
272 KEY(6, 2, KEY_ENTER
),
277 KEY(7, 0, KEY_F6
), /* Green/Call */
279 KEY(7, 2, KEY_BACKSPACE
),
285 static struct matrix_keymap_data treo680_matrix_keymap_data
= {
286 .keymap
= treo680_matrix_keys
,
287 .keymap_size
= ARRAY_SIZE(treo680_matrix_keys
),
290 static struct matrix_keymap_data centro_matrix_keymap_data
= {
291 .keymap
= centro_matrix_keys
,
292 .keymap_size
= ARRAY_SIZE(centro_matrix_keys
),
295 static struct pxa27x_keypad_platform_data treo680_keypad_pdata
= {
296 .matrix_key_rows
= 8,
297 .matrix_key_cols
= 7,
298 .matrix_keymap_data
= &treo680_matrix_keymap_data
,
299 .direct_key_map
= { KEY_CONNECT
},
302 .debounce_interval
= 30,
305 static void __init
palmtreo_kpc_init(void)
307 static struct pxa27x_keypad_platform_data
*data
= &treo680_keypad_pdata
;
309 if (machine_is_centro())
310 data
->matrix_keymap_data
= ¢ro_matrix_keymap_data
;
312 pxa_set_keypad_info(&treo680_keypad_pdata
);
315 static inline void palmtreo_kpc_init(void) {}
318 /******************************************************************************
320 ******************************************************************************/
321 #if IS_ENABLED(CONFIG_USB_OHCI_HCD)
322 static struct pxaohci_platform_data treo680_ohci_info
= {
323 .port_mode
= PMM_PERPORT_MODE
,
324 .flags
= ENABLE_PORT1
| ENABLE_PORT3
,
328 static void __init
palmtreo_uhc_init(void)
330 if (machine_is_treo680())
331 pxa_set_ohci_info(&treo680_ohci_info
);
334 static inline void palmtreo_uhc_init(void) {}
337 /******************************************************************************
339 ******************************************************************************/
340 static struct gpio_led treo680_gpio_leds
[] = {
342 .name
= "treo680:vibra:vibra",
343 .default_trigger
= "none",
344 .gpio
= GPIO_NR_TREO680_VIBRATE_EN
,
347 .name
= "treo680:green:led",
348 .default_trigger
= "mmc0",
349 .gpio
= GPIO_NR_TREO_GREEN_LED
,
352 .name
= "treo680:white:keybbl",
353 .default_trigger
= "none",
354 .gpio
= GPIO_NR_TREO680_KEYB_BL
,
358 static struct gpio_led_platform_data treo680_gpio_led_info
= {
359 .leds
= treo680_gpio_leds
,
360 .num_leds
= ARRAY_SIZE(treo680_gpio_leds
),
363 static struct gpio_led centro_gpio_leds
[] = {
365 .name
= "centro:vibra:vibra",
366 .default_trigger
= "none",
367 .gpio
= GPIO_NR_CENTRO_VIBRATE_EN
,
370 .name
= "centro:green:led",
371 .default_trigger
= "mmc0",
372 .gpio
= GPIO_NR_TREO_GREEN_LED
,
375 .name
= "centro:white:keybbl",
376 .default_trigger
= "none",
378 .gpio
= GPIO_NR_CENTRO_KEYB_BL
,
382 static struct gpio_led_platform_data centro_gpio_led_info
= {
383 .leds
= centro_gpio_leds
,
384 .num_leds
= ARRAY_SIZE(centro_gpio_leds
),
387 static struct platform_device palmtreo_leds
= {
392 static void __init
palmtreo_leds_init(void)
394 if (machine_is_centro())
395 palmtreo_leds
.dev
.platform_data
= ¢ro_gpio_led_info
;
396 else if (machine_is_treo680())
397 palmtreo_leds
.dev
.platform_data
= &treo680_gpio_led_info
;
399 platform_device_register(&palmtreo_leds
);
402 /******************************************************************************
404 ******************************************************************************/
405 static void __init
treo_reserve(void)
407 memblock_reserve(0xa0000000, 0x1000);
408 memblock_reserve(0xa2000000, 0x1000);
411 static void __init
palmphone_common_init(void)
413 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config
));
414 pxa_set_ffuart_info(NULL
);
415 pxa_set_btuart_info(NULL
);
416 pxa_set_stuart_info(NULL
);
417 palm27x_pm_init(TREO_STR_BASE
);
418 palm27x_lcd_init(GPIO_NR_TREO_BL_POWER
, &palm_320x320_new_lcd_mode
);
419 palm27x_udc_init(GPIO_NR_TREO_USB_DETECT
, GPIO_NR_TREO_USB_PULLUP
, 1);
420 palm27x_irda_init(GPIO_NR_TREO_IR_EN
);
421 palm27x_ac97_init(-1, -1, -1, 95);
422 palm27x_pwm_init(GPIO_NR_TREO_BL_POWER
, -1);
423 palm27x_power_init(GPIO_NR_TREO_POWER_DETECT
, -1);
427 palmtreo_leds_init();
430 #ifdef CONFIG_MACH_TREO680
431 void __init
treo680_gpio_init(void)
435 /* drive all three lcd gpios high initially */
436 const unsigned long lcd_flags
= GPIOF_INIT_HIGH
| GPIOF_DIR_OUT
;
439 * LCD GPIO initialization...
443 * This is likely the power to the lcd. Toggling it low/high appears to
444 * turn the lcd off/on. Can be toggled after lcd is initialized without
445 * any apparent adverse effects to the lcd operation. Note that this
446 * gpio line is used by the lcd controller as the L_BIAS signal, but
447 * treo680 configures it as gpio.
449 gpio
= GPIO_NR_TREO680_LCD_POWER
;
450 if (gpio_request_one(gpio
, lcd_flags
, "LCD power") < 0)
454 * These two are called "enables", for lack of a better understanding.
455 * If either of these are toggled after the lcd is initialized, the
456 * image becomes degraded. N.B. The IPL shipped with the treo
457 * configures GPIO_NR_TREO680_LCD_EN_N as output and drives it high. If
458 * the IPL is ever reprogrammed, this initialization may be need to be
461 gpio
= GPIO_NR_TREO680_LCD_EN
;
462 if (gpio_request_one(gpio
, lcd_flags
, "LCD enable") < 0)
464 gpio
= GPIO_NR_TREO680_LCD_EN_N
;
465 if (gpio_request_one(gpio
, lcd_flags
, "LCD enable_n") < 0)
468 /* driving this low turns LCD on */
469 gpio_set_value(GPIO_NR_TREO680_LCD_EN_N
, 0);
473 pr_err("gpio %d initialization failed\n", gpio
);
474 gpio_free(GPIO_NR_TREO680_LCD_POWER
);
475 gpio_free(GPIO_NR_TREO680_LCD_EN
);
476 gpio_free(GPIO_NR_TREO680_LCD_EN_N
);
479 static struct gpiod_lookup_table treo680_mci_gpio_table
= {
480 .dev_id
= "pxa2xx-mci.0",
482 GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N
,
483 "cd", GPIO_ACTIVE_LOW
),
484 GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_READONLY
,
485 "wp", GPIO_ACTIVE_LOW
),
486 GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_POWER
,
487 "power", GPIO_ACTIVE_HIGH
),
492 static void __init
treo680_init(void)
494 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config
));
495 palmphone_common_init();
497 palm27x_mmc_init(&treo680_mci_gpio_table
);
501 #ifdef CONFIG_MACH_CENTRO
503 static struct gpiod_lookup_table centro685_mci_gpio_table
= {
504 .dev_id
= "pxa2xx-mci.0",
506 GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N
,
507 "cd", GPIO_ACTIVE_LOW
),
508 GPIO_LOOKUP("gpio-pxa", GPIO_NR_CENTRO_SD_POWER
,
509 "power", GPIO_ACTIVE_LOW
),
514 static void __init
centro_init(void)
516 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config
));
517 palmphone_common_init();
518 palm27x_mmc_init(¢ro685_mci_gpio_table
);
522 #ifdef CONFIG_MACH_TREO680
523 MACHINE_START(TREO680
, "Palm Treo 680")
524 .atag_offset
= 0x100,
525 .map_io
= pxa27x_map_io
,
526 .reserve
= treo_reserve
,
527 .nr_irqs
= PXA_NR_IRQS
,
528 .init_irq
= pxa27x_init_irq
,
529 .handle_irq
= pxa27x_handle_irq
,
530 .init_time
= pxa_timer_init
,
531 .init_machine
= treo680_init
,
532 .restart
= pxa_restart
,
536 #ifdef CONFIG_MACH_CENTRO
537 MACHINE_START(CENTRO
, "Palm Centro 685")
538 .atag_offset
= 0x100,
539 .map_io
= pxa27x_map_io
,
540 .reserve
= treo_reserve
,
541 .nr_irqs
= PXA_NR_IRQS
,
542 .init_irq
= pxa27x_init_irq
,
543 .handle_irq
= pxa27x_handle_irq
,
544 .init_time
= pxa_timer_init
,
545 .init_machine
= centro_init
,
546 .restart
= pxa_restart
,