root/arch/arm/mach-pxa/palmtc.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. palmtc_mmc_init
  2. palmtc_mmc_init
  3. palmtc_keys_init
  4. palmtc_keys_init
  5. palmtc_pwm_init
  6. palmtc_pwm_init
  7. palmtc_irda_init
  8. palmtc_irda_init
  9. palmtc_mkp_init
  10. palmtc_mkp_init
  11. palmtc_udc_init
  12. palmtc_udc_init
  13. palmtc_ts_init
  14. palmtc_ts_init
  15. palmtc_leds_init
  16. palmtc_leds_init
  17. palmtc_nor_init
  18. palmtc_nor_init
  19. palmtc_lcd_init
  20. palmtc_lcd_init
  21. palmtc_init

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * linux/arch/arm/mach-pxa/palmtc.c
   4  *
   5  * Support for the Palm Tungsten|C
   6  *
   7  * Author:      Marek Vasut <marek.vasut@gmail.com>
   8  *
   9  * Based on work of:
  10  *              Petr Blaha <p3t3@centrum.cz>
  11  *              Chetan S. Kumar <shivakumar.chetan@gmail.com>
  12  */
  13 
  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>
  27 
  28 #include <asm/mach-types.h>
  29 #include <asm/mach/arch.h>
  30 #include <asm/mach/map.h>
  31 
  32 #include "pxa25x.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>
  38 #include "udc.h"
  39 
  40 #include "generic.h"
  41 #include "devices.h"
  42 
  43 /******************************************************************************
  44  * Pin configuration
  45  ******************************************************************************/
  46 static unsigned long palmtc_pin_config[] __initdata = {
  47         /* MMC */
  48         GPIO6_MMC_CLK,
  49         GPIO8_MMC_CS0,
  50         GPIO12_GPIO,    /* detect */
  51         GPIO32_GPIO,    /* power */
  52         GPIO54_GPIO,    /* r/o switch */
  53 
  54         /* PCMCIA */
  55         GPIO52_nPCE_1,
  56         GPIO53_nPCE_2,
  57         GPIO50_nPIOR,
  58         GPIO51_nPIOW,
  59         GPIO49_nPWE,
  60         GPIO48_nPOE,
  61         GPIO52_nPCE_1,
  62         GPIO53_nPCE_2,
  63         GPIO57_nIOIS16,
  64         GPIO56_nPWAIT,
  65 
  66         /* AC97 */
  67         GPIO28_AC97_BITCLK,
  68         GPIO29_AC97_SDATA_IN_0,
  69         GPIO30_AC97_SDATA_OUT,
  70         GPIO31_AC97_SYNC,
  71 
  72         /* IrDA */
  73         GPIO45_GPIO,    /* ir disable */
  74         GPIO46_FICP_RXD,
  75         GPIO47_FICP_TXD,
  76 
  77         /* PWM */
  78         GPIO17_PWM1_OUT,
  79 
  80         /* USB */
  81         GPIO4_GPIO,     /* detect */
  82         GPIO36_GPIO,    /* pullup */
  83 
  84         /* LCD */
  85         GPIOxx_LCD_TFT_16BPP,
  86 
  87         /* MATRIX KEYPAD */
  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 */
 104 
 105         /* PXA GPIO KEYS */
 106         GPIO7_GPIO | WAKEUP_ON_EDGE_BOTH,       /* hotsync button on cradle */
 107 
 108         /* MISC */
 109         GPIO1_RST,      /* reset */
 110         GPIO2_GPIO,     /* earphone detect */
 111         GPIO16_GPIO,    /* backlight switch */
 112 };
 113 
 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,
 121 };
 122 
 123 static struct gpiod_lookup_table palmtc_mci_gpio_table = {
 124         .dev_id = "pxa2xx-mci.0",
 125         .table = {
 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),
 132                 { },
 133         },
 134 };
 135 
 136 static void __init palmtc_mmc_init(void)
 137 {
 138         gpiod_add_lookup_table(&palmtc_mci_gpio_table);
 139         pxa_set_mci_info(&palmtc_mci_platform_data);
 140 }
 141 #else
 142 static inline void palmtc_mmc_init(void) {}
 143 #endif
 144 
 145 /******************************************************************************
 146  * GPIO keys
 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},
 151 };
 152 
 153 static struct gpio_keys_platform_data palmtc_pxa_keys_data = {
 154         .buttons        = palmtc_pxa_buttons,
 155         .nbuttons       = ARRAY_SIZE(palmtc_pxa_buttons),
 156 };
 157 
 158 static struct platform_device palmtc_pxa_keys = {
 159         .name   = "gpio-keys",
 160         .id     = -1,
 161         .dev    = {
 162                 .platform_data = &palmtc_pxa_keys_data,
 163         },
 164 };
 165 
 166 static void __init palmtc_keys_init(void)
 167 {
 168         platform_device_register(&palmtc_pxa_keys);
 169 }
 170 #else
 171 static inline void palmtc_keys_init(void) {}
 172 #endif
 173 
 174 /******************************************************************************
 175  * Backlight
 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),
 181 };
 182 
 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,
 187 };
 188 
 189 static struct platform_device palmtc_backlight = {
 190         .name   = "pwm-backlight",
 191         .dev    = {
 192                 .parent         = &pxa25x_device_pwm1.dev,
 193                 .platform_data  = &palmtc_backlight_data,
 194         },
 195 };
 196 
 197 static void __init palmtc_pwm_init(void)
 198 {
 199         pwm_add_table(palmtc_pwm_lookup, ARRAY_SIZE(palmtc_pwm_lookup));
 200         platform_device_register(&palmtc_backlight);
 201 }
 202 #else
 203 static inline void palmtc_pwm_init(void) {}
 204 #endif
 205 
 206 /******************************************************************************
 207  * IrDA
 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,
 213 };
 214 
 215 static void __init palmtc_irda_init(void)
 216 {
 217         pxa_set_ficp_info(&palmtc_ficp_platform_data);
 218 }
 219 #else
 220 static inline void palmtc_irda_init(void) {}
 221 #endif
 222 
 223 /******************************************************************************
 224  * Keyboard
 225  ******************************************************************************/
 226 #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
 227 static const uint32_t palmtc_matrix_keys[] = {
 228         KEY(0, 0, KEY_F1),
 229         KEY(0, 1, KEY_X),
 230         KEY(0, 2, KEY_POWER),
 231         KEY(0, 3, KEY_TAB),
 232         KEY(0, 4, KEY_A),
 233         KEY(0, 5, KEY_Q),
 234         KEY(0, 6, KEY_LEFTSHIFT),
 235         KEY(0, 7, KEY_Z),
 236         KEY(0, 8, KEY_S),
 237         KEY(0, 9, KEY_W),
 238         KEY(0, 10, KEY_E),
 239         KEY(0, 11, KEY_UP),
 240 
 241         KEY(1, 0, KEY_F2),
 242         KEY(1, 1, KEY_DOWN),
 243         KEY(1, 3, KEY_D),
 244         KEY(1, 4, KEY_C),
 245         KEY(1, 5, KEY_F),
 246         KEY(1, 6, KEY_R),
 247         KEY(1, 7, KEY_SPACE),
 248         KEY(1, 8, KEY_V),
 249         KEY(1, 9, KEY_G),
 250         KEY(1, 10, KEY_T),
 251         KEY(1, 11, KEY_LEFT),
 252 
 253         KEY(2, 0, KEY_F3),
 254         KEY(2, 1, KEY_LEFTCTRL),
 255         KEY(2, 3, KEY_H),
 256         KEY(2, 4, KEY_Y),
 257         KEY(2, 5, KEY_N),
 258         KEY(2, 6, KEY_J),
 259         KEY(2, 7, KEY_U),
 260         KEY(2, 8, KEY_M),
 261         KEY(2, 9, KEY_K),
 262         KEY(2, 10, KEY_I),
 263         KEY(2, 11, KEY_RIGHT),
 264 
 265         KEY(3, 0, KEY_F4),
 266         KEY(3, 1, KEY_ENTER),
 267         KEY(3, 3, KEY_DOT),
 268         KEY(3, 4, KEY_L),
 269         KEY(3, 5, KEY_O),
 270         KEY(3, 6, KEY_LEFTALT),
 271         KEY(3, 7, KEY_ENTER),
 272         KEY(3, 8, KEY_BACKSPACE),
 273         KEY(3, 9, KEY_P),
 274         KEY(3, 10, KEY_B),
 275         KEY(3, 11, KEY_FN),
 276 };
 277 
 278 const struct matrix_keymap_data palmtc_keymap_data = {
 279         .keymap                 = palmtc_matrix_keys,
 280         .keymap_size            = ARRAY_SIZE(palmtc_matrix_keys),
 281 };
 282 
 283 static const unsigned int palmtc_keypad_row_gpios[] = {
 284         0, 9, 10, 11
 285 };
 286 
 287 static const unsigned int palmtc_keypad_col_gpios[] = {
 288         18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
 289 };
 290 
 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),
 297         .active_low     = 1,
 298 
 299         .debounce_ms            = 20,
 300         .col_scan_delay_us      = 5,
 301 };
 302 
 303 static struct platform_device palmtc_keyboard = {
 304         .name   = "matrix-keypad",
 305         .id     = -1,
 306         .dev    = {
 307                 .platform_data = &palmtc_keypad_platform_data,
 308         },
 309 };
 310 static void __init palmtc_mkp_init(void)
 311 {
 312         platform_device_register(&palmtc_keyboard);
 313 }
 314 #else
 315 static inline void palmtc_mkp_init(void) {}
 316 #endif
 317 
 318 /******************************************************************************
 319  * UDC
 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,
 326 };
 327 
 328 static struct platform_device palmtc_gpio_vbus = {
 329         .name   = "gpio-vbus",
 330         .id     = -1,
 331         .dev    = {
 332                 .platform_data  = &palmtc_udc_info,
 333         },
 334 };
 335 
 336 static void __init palmtc_udc_init(void)
 337 {
 338         platform_device_register(&palmtc_gpio_vbus);
 339 };
 340 #else
 341 static inline void palmtc_udc_init(void) {}
 342 #endif
 343 
 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",
 351         .id     = -1,
 352 };
 353 
 354 static void __init palmtc_ts_init(void)
 355 {
 356         pxa_set_ac97_info(NULL);
 357         platform_device_register(&palmtc_ucb1400_device);
 358 }
 359 #else
 360 static inline void palmtc_ts_init(void) {}
 361 #endif
 362 
 363 /******************************************************************************
 364  * LEDs
 365  ******************************************************************************/
 366 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
 367 struct gpio_led palmtc_gpio_leds[] = {
 368 {
 369         .name                   = "palmtc:green:user",
 370         .default_trigger        = "none",
 371         .gpio                   = GPIO_NR_PALMTC_LED_POWER,
 372         .active_low             = 1,
 373 }, {
 374         .name                   = "palmtc:vibra:vibra",
 375         .default_trigger        = "none",
 376         .gpio                   = GPIO_NR_PALMTC_VIBRA_POWER,
 377         .active_low             = 1,
 378 }
 379 
 380 };
 381 
 382 static struct gpio_led_platform_data palmtc_gpio_led_info = {
 383         .leds           = palmtc_gpio_leds,
 384         .num_leds       = ARRAY_SIZE(palmtc_gpio_leds),
 385 };
 386 
 387 static struct platform_device palmtc_leds = {
 388         .name   = "leds-gpio",
 389         .id     = -1,
 390         .dev    = {
 391                 .platform_data  = &palmtc_gpio_led_info,
 392         }
 393 };
 394 
 395 static void __init palmtc_leds_init(void)
 396 {
 397         platform_device_register(&palmtc_leds);
 398 }
 399 #else
 400 static inline void palmtc_leds_init(void) {}
 401 #endif
 402 
 403 /******************************************************************************
 404  * NOR Flash
 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,
 411 };
 412 
 413 static struct mtd_partition palmtc_flash_parts[] = {
 414         {
 415                 .name   = "U-Boot Bootloader",
 416                 .offset = 0x0,
 417                 .size   = 0x40000,
 418         },
 419         {
 420                 .name   = "Linux Kernel",
 421                 .offset = 0x40000,
 422                 .size   = 0x2c0000,
 423         },
 424         {
 425                 .name   = "Filesystem",
 426                 .offset = 0x300000,
 427                 .size   = 0xcc0000,
 428         },
 429         {
 430                 .name   = "U-Boot Environment",
 431                 .offset = 0xfc0000,
 432                 .size   = MTDPART_SIZ_FULL,
 433         },
 434 };
 435 
 436 static struct physmap_flash_data palmtc_flash_data = {
 437         .width          = 4,
 438         .parts          = palmtc_flash_parts,
 439         .nr_parts       = ARRAY_SIZE(palmtc_flash_parts),
 440 };
 441 
 442 static struct platform_device palmtc_flash = {
 443         .name           = "physmap-flash",
 444         .id             = -1,
 445         .resource       = &palmtc_flash_resource,
 446         .num_resources  = 1,
 447         .dev = {
 448                 .platform_data  = &palmtc_flash_data,
 449         },
 450 };
 451 
 452 static void __init palmtc_nor_init(void)
 453 {
 454         platform_device_register(&palmtc_flash);
 455 }
 456 #else
 457 static inline void palmtc_nor_init(void) {}
 458 #endif
 459 
 460 /******************************************************************************
 461  * Framebuffer
 462  ******************************************************************************/
 463 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
 464 static struct pxafb_mode_info palmtc_lcd_modes[] = {
 465         {
 466                 .pixclock       = 115384,
 467                 .xres           = 320,
 468                 .yres           = 320,
 469                 .bpp            = 16,
 470 
 471                 .left_margin    = 27,
 472                 .right_margin   = 7,
 473                 .upper_margin   = 7,
 474                 .lower_margin   = 8,
 475 
 476                 .hsync_len      = 6,
 477                 .vsync_len      = 1,
 478         },
 479 };
 480 
 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,
 485 };
 486 
 487 static void __init palmtc_lcd_init(void)
 488 {
 489         pxa_set_fb_info(NULL, &palmtc_lcd_screen);
 490 }
 491 #else
 492 static inline void palmtc_lcd_init(void) {}
 493 #endif
 494 
 495 /******************************************************************************
 496  * Machine init
 497  ******************************************************************************/
 498 static void __init palmtc_init(void)
 499 {
 500         pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config));
 501 
 502         pxa_set_ffuart_info(NULL);
 503         pxa_set_btuart_info(NULL);
 504         pxa_set_stuart_info(NULL);
 505         pxa_set_hwuart_info(NULL);
 506 
 507         palmtc_mmc_init();
 508         palmtc_keys_init();
 509         palmtc_pwm_init();
 510         palmtc_irda_init();
 511         palmtc_mkp_init();
 512         palmtc_udc_init();
 513         palmtc_ts_init();
 514         palmtc_nor_init();
 515         palmtc_lcd_init();
 516         palmtc_leds_init();
 517 };
 518 
 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,
 528 MACHINE_END

/* [<][>][^][v][top][bottom][index][help] */