Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Hardware definitions for Palm Treo smartphones
0004  *
0005  * currently supported:
0006  *     Palm Treo 680 (GSM)
0007  *     Palm Centro 685 (GSM)
0008  *
0009  * Author:     Tomas Cech <sleep_walker@suse.cz>
0010  *
0011  * (find more info at www.hackndev.com)
0012  */
0013 
0014 #include <linux/platform_device.h>
0015 #include <linux/delay.h>
0016 #include <linux/irq.h>
0017 #include <linux/gpio_keys.h>
0018 #include <linux/input.h>
0019 #include <linux/memblock.h>
0020 #include <linux/pda_power.h>
0021 #include <linux/pwm_backlight.h>
0022 #include <linux/gpio.h>
0023 #include <linux/power_supply.h>
0024 #include <linux/w1-gpio.h>
0025 
0026 #include <asm/mach-types.h>
0027 #include <asm/mach/arch.h>
0028 #include <asm/mach/map.h>
0029 
0030 #include "pxa27x.h"
0031 #include "pxa27x-udc.h"
0032 #include <linux/platform_data/asoc-pxa.h>
0033 #include "palmtreo.h"
0034 #include <linux/platform_data/mmc-pxamci.h>
0035 #include <linux/platform_data/video-pxafb.h>
0036 #include <linux/platform_data/irda-pxaficp.h>
0037 #include <linux/platform_data/keypad-pxa27x.h>
0038 #include "udc.h"
0039 #include <linux/platform_data/usb-ohci-pxa27x.h>
0040 #include "pxa2xx-regs.h"
0041 #include <linux/platform_data/asoc-palm27x.h>
0042 #include <linux/platform_data/media/camera-pxa.h>
0043 #include "palm27x.h"
0044 
0045 #include <sound/pxa2xx-lib.h>
0046 
0047 #include "generic.h"
0048 #include "devices.h"
0049 
0050 /******************************************************************************
0051  * Pin configuration
0052  ******************************************************************************/
0053 static unsigned long treo_pin_config[] __initdata = {
0054     /* MMC */
0055     GPIO32_MMC_CLK,
0056     GPIO92_MMC_DAT_0,
0057     GPIO109_MMC_DAT_1,
0058     GPIO110_MMC_DAT_2,
0059     GPIO111_MMC_DAT_3,
0060     GPIO112_MMC_CMD,
0061     GPIO113_GPIO,               /* SD detect */
0062 
0063     /* AC97 */
0064     GPIO28_AC97_BITCLK,
0065     GPIO29_AC97_SDATA_IN_0,
0066     GPIO30_AC97_SDATA_OUT,
0067     GPIO31_AC97_SYNC,
0068     GPIO89_AC97_SYSCLK,
0069     GPIO95_AC97_nRESET,
0070 
0071     /* IrDA */
0072     GPIO46_FICP_RXD,
0073     GPIO47_FICP_TXD,
0074 
0075     /* PWM */
0076     GPIO16_PWM0_OUT,
0077 
0078     /* USB */
0079     GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,   /* usb detect */
0080 
0081     /* MATRIX KEYPAD */
0082     GPIO101_KP_MKIN_1,
0083     GPIO102_KP_MKIN_2,
0084     GPIO97_KP_MKIN_3,
0085     GPIO98_KP_MKIN_4,
0086     GPIO91_KP_MKIN_6,
0087     GPIO13_KP_MKIN_7,
0088     GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH,
0089     GPIO104_KP_MKOUT_1,
0090     GPIO105_KP_MKOUT_2,
0091     GPIO106_KP_MKOUT_3,
0092     GPIO107_KP_MKOUT_4,
0093     GPIO108_KP_MKOUT_5,
0094     GPIO96_KP_MKOUT_6,
0095     GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH,    /* Hotsync button */
0096 
0097     /* Quick Capture Interface */
0098     GPIO84_CIF_FV,
0099     GPIO85_CIF_LV,
0100     GPIO53_CIF_MCLK,
0101     GPIO54_CIF_PCLK,
0102     GPIO81_CIF_DD_0,
0103     GPIO55_CIF_DD_1,
0104     GPIO51_CIF_DD_2,
0105     GPIO50_CIF_DD_3,
0106     GPIO52_CIF_DD_4,
0107     GPIO48_CIF_DD_5,
0108     GPIO17_CIF_DD_6,
0109     GPIO12_CIF_DD_7,
0110 
0111     /* I2C */
0112     GPIO117_I2C_SCL,
0113     GPIO118_I2C_SDA,
0114 
0115     /* GSM */
0116     GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH,  /* GSM host wake up */
0117     GPIO34_FFUART_RXD,
0118     GPIO35_FFUART_CTS,
0119     GPIO39_FFUART_TXD,
0120     GPIO41_FFUART_RTS,
0121 
0122     /* MISC. */
0123     GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH,   /* external power detect */
0124     GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH,  /* silent switch */
0125     GPIO116_GPIO,               /* headphone detect */
0126     GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH,  /* bluetooth host wake up */
0127 };
0128 
0129 #ifdef CONFIG_MACH_TREO680
0130 static unsigned long treo680_pin_config[] __initdata = {
0131     GPIO33_GPIO,    /* SD read only */
0132 
0133     /* MATRIX KEYPAD - different wake up source */
0134     GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
0135     GPIO99_KP_MKIN_5,
0136 
0137     /* LCD... L_BIAS alt fn not configured on Treo680; is GPIO instead */
0138     GPIOxx_LCD_16BPP,
0139     GPIO74_LCD_FCLK,
0140     GPIO75_LCD_LCLK,
0141     GPIO76_LCD_PCLK,
0142 };
0143 #endif /* CONFIG_MACH_TREO680 */
0144 
0145 #ifdef CONFIG_MACH_CENTRO
0146 static unsigned long centro685_pin_config[] __initdata = {
0147     /* Bluetooth attached to BT UART*/
0148     MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW),    /* power: LOW = off */
0149     GPIO42_BTUART_RXD,
0150     GPIO43_BTUART_TXD,
0151     GPIO44_BTUART_CTS,
0152     GPIO45_BTUART_RTS,
0153 
0154     /* MATRIX KEYPAD - different wake up source */
0155     GPIO100_KP_MKIN_0,
0156     GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
0157 
0158     /* LCD */
0159     GPIOxx_LCD_TFT_16BPP,
0160 };
0161 #endif /* CONFIG_MACH_CENTRO */
0162 
0163 /******************************************************************************
0164  * GPIO keyboard
0165  ******************************************************************************/
0166 #if IS_ENABLED(CONFIG_KEYBOARD_PXA27x)
0167 static const unsigned int treo680_matrix_keys[] = {
0168     KEY(0, 0, KEY_F8),      /* Red/Off/Power */
0169     KEY(0, 1, KEY_LEFT),
0170     KEY(0, 2, KEY_LEFTCTRL),    /* Alternate */
0171     KEY(0, 3, KEY_L),
0172     KEY(0, 4, KEY_A),
0173     KEY(0, 5, KEY_Q),
0174     KEY(0, 6, KEY_P),
0175 
0176     KEY(1, 0, KEY_RIGHTCTRL),   /* Menu */
0177     KEY(1, 1, KEY_RIGHT),
0178     KEY(1, 2, KEY_LEFTSHIFT),   /* Left shift */
0179     KEY(1, 3, KEY_Z),
0180     KEY(1, 4, KEY_S),
0181     KEY(1, 5, KEY_W),
0182 
0183     KEY(2, 0, KEY_F1),      /* Phone */
0184     KEY(2, 1, KEY_UP),
0185     KEY(2, 2, KEY_0),
0186     KEY(2, 3, KEY_X),
0187     KEY(2, 4, KEY_D),
0188     KEY(2, 5, KEY_E),
0189 
0190     KEY(3, 0, KEY_F10),     /* Calendar */
0191     KEY(3, 1, KEY_DOWN),
0192     KEY(3, 2, KEY_SPACE),
0193     KEY(3, 3, KEY_C),
0194     KEY(3, 4, KEY_F),
0195     KEY(3, 5, KEY_R),
0196 
0197     KEY(4, 0, KEY_F12),     /* Mail */
0198     KEY(4, 1, KEY_KPENTER),
0199     KEY(4, 2, KEY_RIGHTALT),    /* Alt */
0200     KEY(4, 3, KEY_V),
0201     KEY(4, 4, KEY_G),
0202     KEY(4, 5, KEY_T),
0203 
0204     KEY(5, 0, KEY_F9),      /* Home */
0205     KEY(5, 1, KEY_PAGEUP),      /* Side up */
0206     KEY(5, 2, KEY_DOT),
0207     KEY(5, 3, KEY_B),
0208     KEY(5, 4, KEY_H),
0209     KEY(5, 5, KEY_Y),
0210 
0211     KEY(6, 0, KEY_TAB),     /* Side Activate */
0212     KEY(6, 1, KEY_PAGEDOWN),    /* Side down */
0213     KEY(6, 2, KEY_ENTER),
0214     KEY(6, 3, KEY_N),
0215     KEY(6, 4, KEY_J),
0216     KEY(6, 5, KEY_U),
0217 
0218     KEY(7, 0, KEY_F6),      /* Green/Call */
0219     KEY(7, 1, KEY_O),
0220     KEY(7, 2, KEY_BACKSPACE),
0221     KEY(7, 3, KEY_M),
0222     KEY(7, 4, KEY_K),
0223     KEY(7, 5, KEY_I),
0224 };
0225 
0226 static const unsigned int centro_matrix_keys[] = {
0227     KEY(0, 0, KEY_F9),      /* Home */
0228     KEY(0, 1, KEY_LEFT),
0229     KEY(0, 2, KEY_LEFTCTRL),    /* Alternate */
0230     KEY(0, 3, KEY_L),
0231     KEY(0, 4, KEY_A),
0232     KEY(0, 5, KEY_Q),
0233     KEY(0, 6, KEY_P),
0234 
0235     KEY(1, 0, KEY_RIGHTCTRL),   /* Menu */
0236     KEY(1, 1, KEY_RIGHT),
0237     KEY(1, 2, KEY_LEFTSHIFT),   /* Left shift */
0238     KEY(1, 3, KEY_Z),
0239     KEY(1, 4, KEY_S),
0240     KEY(1, 5, KEY_W),
0241 
0242     KEY(2, 0, KEY_F1),      /* Phone */
0243     KEY(2, 1, KEY_UP),
0244     KEY(2, 2, KEY_0),
0245     KEY(2, 3, KEY_X),
0246     KEY(2, 4, KEY_D),
0247     KEY(2, 5, KEY_E),
0248 
0249     KEY(3, 0, KEY_F10),     /* Calendar */
0250     KEY(3, 1, KEY_DOWN),
0251     KEY(3, 2, KEY_SPACE),
0252     KEY(3, 3, KEY_C),
0253     KEY(3, 4, KEY_F),
0254     KEY(3, 5, KEY_R),
0255 
0256     KEY(4, 0, KEY_F12),     /* Mail */
0257     KEY(4, 1, KEY_KPENTER),
0258     KEY(4, 2, KEY_RIGHTALT),    /* Alt */
0259     KEY(4, 3, KEY_V),
0260     KEY(4, 4, KEY_G),
0261     KEY(4, 5, KEY_T),
0262 
0263     KEY(5, 0, KEY_F8),      /* Red/Off/Power */
0264     KEY(5, 1, KEY_PAGEUP),      /* Side up */
0265     KEY(5, 2, KEY_DOT),
0266     KEY(5, 3, KEY_B),
0267     KEY(5, 4, KEY_H),
0268     KEY(5, 5, KEY_Y),
0269 
0270     KEY(6, 0, KEY_TAB),     /* Side Activate */
0271     KEY(6, 1, KEY_PAGEDOWN),    /* Side down */
0272     KEY(6, 2, KEY_ENTER),
0273     KEY(6, 3, KEY_N),
0274     KEY(6, 4, KEY_J),
0275     KEY(6, 5, KEY_U),
0276 
0277     KEY(7, 0, KEY_F6),      /* Green/Call */
0278     KEY(7, 1, KEY_O),
0279     KEY(7, 2, KEY_BACKSPACE),
0280     KEY(7, 3, KEY_M),
0281     KEY(7, 4, KEY_K),
0282     KEY(7, 5, KEY_I),
0283 };
0284 
0285 static struct matrix_keymap_data treo680_matrix_keymap_data = {
0286     .keymap         = treo680_matrix_keys,
0287     .keymap_size        = ARRAY_SIZE(treo680_matrix_keys),
0288 };
0289 
0290 static struct matrix_keymap_data centro_matrix_keymap_data = {
0291     .keymap         = centro_matrix_keys,
0292     .keymap_size        = ARRAY_SIZE(centro_matrix_keys),
0293 };
0294 
0295 static struct pxa27x_keypad_platform_data treo680_keypad_pdata = {
0296     .matrix_key_rows    = 8,
0297     .matrix_key_cols    = 7,
0298     .matrix_keymap_data = &treo680_matrix_keymap_data,
0299     .direct_key_map     = { KEY_CONNECT },
0300     .direct_key_num     = 1,
0301 
0302     .debounce_interval  = 30,
0303 };
0304 
0305 static void __init palmtreo_kpc_init(void)
0306 {
0307     static struct pxa27x_keypad_platform_data *data = &treo680_keypad_pdata;
0308 
0309     if (machine_is_centro())
0310         data->matrix_keymap_data = &centro_matrix_keymap_data;
0311 
0312     pxa_set_keypad_info(&treo680_keypad_pdata);
0313 }
0314 #else
0315 static inline void palmtreo_kpc_init(void) {}
0316 #endif
0317 
0318 /******************************************************************************
0319  * USB host
0320  ******************************************************************************/
0321 #if IS_ENABLED(CONFIG_USB_OHCI_HCD)
0322 static struct pxaohci_platform_data treo680_ohci_info = {
0323     .port_mode    = PMM_PERPORT_MODE,
0324     .flags        = ENABLE_PORT1 | ENABLE_PORT3,
0325     .power_budget = 0,
0326 };
0327 
0328 static void __init palmtreo_uhc_init(void)
0329 {
0330     if (machine_is_treo680())
0331         pxa_set_ohci_info(&treo680_ohci_info);
0332 }
0333 #else
0334 static inline void palmtreo_uhc_init(void) {}
0335 #endif
0336 
0337 /******************************************************************************
0338  * Vibra and LEDs
0339  ******************************************************************************/
0340 static struct gpio_led treo680_gpio_leds[] = {
0341     {
0342         .name           = "treo680:vibra:vibra",
0343         .default_trigger    = "none",
0344         .gpio           = GPIO_NR_TREO680_VIBRATE_EN,
0345     },
0346     {
0347         .name           = "treo680:green:led",
0348         .default_trigger    = "mmc0",
0349         .gpio           = GPIO_NR_TREO_GREEN_LED,
0350     },
0351     {
0352         .name           = "treo680:white:keybbl",
0353         .default_trigger    = "none",
0354         .gpio           = GPIO_NR_TREO680_KEYB_BL,
0355     },
0356 };
0357 
0358 static struct gpio_led_platform_data treo680_gpio_led_info = {
0359     .leds       = treo680_gpio_leds,
0360     .num_leds   = ARRAY_SIZE(treo680_gpio_leds),
0361 };
0362 
0363 static struct gpio_led centro_gpio_leds[] = {
0364     {
0365         .name           = "centro:vibra:vibra",
0366         .default_trigger    = "none",
0367         .gpio           = GPIO_NR_CENTRO_VIBRATE_EN,
0368     },
0369     {
0370         .name           = "centro:green:led",
0371         .default_trigger    = "mmc0",
0372         .gpio           = GPIO_NR_TREO_GREEN_LED,
0373     },
0374     {
0375         .name           = "centro:white:keybbl",
0376         .default_trigger    = "none",
0377         .active_low     = 1,
0378         .gpio           = GPIO_NR_CENTRO_KEYB_BL,
0379     },
0380 };
0381 
0382 static struct gpio_led_platform_data centro_gpio_led_info = {
0383     .leds       = centro_gpio_leds,
0384     .num_leds   = ARRAY_SIZE(centro_gpio_leds),
0385 };
0386 
0387 static struct platform_device palmtreo_leds = {
0388     .name   = "leds-gpio",
0389     .id     = -1,
0390 };
0391 
0392 static void __init palmtreo_leds_init(void)
0393 {
0394     if (machine_is_centro())
0395         palmtreo_leds.dev.platform_data = &centro_gpio_led_info;
0396     else if (machine_is_treo680())
0397         palmtreo_leds.dev.platform_data = &treo680_gpio_led_info;
0398 
0399     platform_device_register(&palmtreo_leds);
0400 }
0401 
0402 /******************************************************************************
0403  * Machine init
0404  ******************************************************************************/
0405 static void __init treo_reserve(void)
0406 {
0407     memblock_reserve(0xa0000000, 0x1000);
0408     memblock_reserve(0xa2000000, 0x1000);
0409 }
0410 
0411 static void __init palmphone_common_init(void)
0412 {
0413     pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
0414     pxa_set_ffuart_info(NULL);
0415     pxa_set_btuart_info(NULL);
0416     pxa_set_stuart_info(NULL);
0417     palm27x_pm_init(TREO_STR_BASE);
0418     palm27x_lcd_init(GPIO_NR_TREO_BL_POWER, &palm_320x320_new_lcd_mode);
0419     palm27x_udc_init(GPIO_NR_TREO_USB_DETECT, GPIO_NR_TREO_USB_PULLUP, 1);
0420     palm27x_irda_init(GPIO_NR_TREO_IR_EN);
0421     palm27x_ac97_init(-1, -1, -1, 95);
0422     palm27x_pwm_init(GPIO_NR_TREO_BL_POWER, -1);
0423     palm27x_power_init(GPIO_NR_TREO_POWER_DETECT, -1);
0424     palm27x_pmic_init();
0425     palmtreo_kpc_init();
0426     palmtreo_uhc_init();
0427     palmtreo_leds_init();
0428 }
0429 
0430 #ifdef CONFIG_MACH_TREO680
0431 void __init treo680_gpio_init(void)
0432 {
0433     unsigned int gpio;
0434 
0435     /* drive all three lcd gpios high initially */
0436     const unsigned long lcd_flags = GPIOF_INIT_HIGH | GPIOF_DIR_OUT;
0437 
0438     /*
0439      * LCD GPIO initialization...
0440      */
0441 
0442     /*
0443      * This is likely the power to the lcd.  Toggling it low/high appears to
0444      * turn the lcd off/on.  Can be toggled after lcd is initialized without
0445      * any apparent adverse effects to the lcd operation.  Note that this
0446      * gpio line is used by the lcd controller as the L_BIAS signal, but
0447      * treo680 configures it as gpio.
0448      */
0449     gpio = GPIO_NR_TREO680_LCD_POWER;
0450     if (gpio_request_one(gpio, lcd_flags, "LCD power") < 0)
0451         goto fail;
0452 
0453     /*
0454      * These two are called "enables", for lack of a better understanding.
0455      * If either of these are toggled after the lcd is initialized, the
0456      * image becomes degraded.  N.B. The IPL shipped with the treo
0457      * configures GPIO_NR_TREO680_LCD_EN_N as output and drives it high.  If
0458      * the IPL is ever reprogrammed, this initialization may be need to be
0459      * revisited.
0460      */
0461     gpio = GPIO_NR_TREO680_LCD_EN;
0462     if (gpio_request_one(gpio, lcd_flags, "LCD enable") < 0)
0463         goto fail;
0464     gpio = GPIO_NR_TREO680_LCD_EN_N;
0465     if (gpio_request_one(gpio, lcd_flags, "LCD enable_n") < 0)
0466         goto fail;
0467 
0468     /* driving this low turns LCD on */
0469     gpio_set_value(GPIO_NR_TREO680_LCD_EN_N, 0);
0470 
0471     return;
0472  fail:
0473     pr_err("gpio %d initialization failed\n", gpio);
0474     gpio_free(GPIO_NR_TREO680_LCD_POWER);
0475     gpio_free(GPIO_NR_TREO680_LCD_EN);
0476     gpio_free(GPIO_NR_TREO680_LCD_EN_N);
0477 }
0478 
0479 static struct gpiod_lookup_table treo680_mci_gpio_table = {
0480     .dev_id = "pxa2xx-mci.0",
0481     .table = {
0482         GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N,
0483                 "cd", GPIO_ACTIVE_LOW),
0484         GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_READONLY,
0485                 "wp", GPIO_ACTIVE_LOW),
0486         GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_POWER,
0487                 "power", GPIO_ACTIVE_HIGH),
0488         { },
0489     },
0490 };
0491 
0492 static void __init treo680_init(void)
0493 {
0494     pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
0495     palmphone_common_init();
0496     treo680_gpio_init();
0497     palm27x_mmc_init(&treo680_mci_gpio_table);
0498 }
0499 #endif
0500 
0501 #ifdef CONFIG_MACH_CENTRO
0502 
0503 static struct gpiod_lookup_table centro685_mci_gpio_table = {
0504     .dev_id = "pxa2xx-mci.0",
0505     .table = {
0506         GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N,
0507                 "cd", GPIO_ACTIVE_LOW),
0508         GPIO_LOOKUP("gpio-pxa", GPIO_NR_CENTRO_SD_POWER,
0509                 "power", GPIO_ACTIVE_LOW),
0510         { },
0511     },
0512 };
0513 
0514 static void __init centro_init(void)
0515 {
0516     pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
0517     palmphone_common_init();
0518     palm27x_mmc_init(&centro685_mci_gpio_table);
0519 }
0520 #endif
0521 
0522 #ifdef CONFIG_MACH_TREO680
0523 MACHINE_START(TREO680, "Palm Treo 680")
0524     .atag_offset    = 0x100,
0525     .map_io         = pxa27x_map_io,
0526     .reserve    = treo_reserve,
0527     .nr_irqs    = PXA_NR_IRQS,
0528     .init_irq       = pxa27x_init_irq,
0529     .handle_irq       = pxa27x_handle_irq,
0530     .init_time  = pxa_timer_init,
0531     .init_machine   = treo680_init,
0532     .restart    = pxa_restart,
0533 MACHINE_END
0534 #endif
0535 
0536 #ifdef CONFIG_MACH_CENTRO
0537 MACHINE_START(CENTRO, "Palm Centro 685")
0538     .atag_offset    = 0x100,
0539     .map_io         = pxa27x_map_io,
0540     .reserve    = treo_reserve,
0541     .nr_irqs    = PXA_NR_IRQS,
0542     .init_irq       = pxa27x_init_irq,
0543     .handle_irq       = pxa27x_handle_irq,
0544     .init_time  = pxa_timer_init,
0545     .init_machine   = centro_init,
0546     .restart    = pxa_restart,
0547 MACHINE_END
0548 #endif