linux/arch/arm/mach-pxa/zylonite.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-only
   2/*
   3 * linux/arch/arm/mach-pxa/zylonite.c
   4 *
   5 * Support for the PXA3xx Development Platform (aka Zylonite)
   6 *
   7 * Copyright (C) 2006 Marvell International Ltd.
   8 *
   9 * 2007-09-04: eric miao <eric.miao@marvell.com>
  10 *             rewrite to align with latest kernel
  11 */
  12
  13#include <linux/module.h>
  14#include <linux/kernel.h>
  15#include <linux/interrupt.h>
  16#include <linux/leds.h>
  17#include <linux/init.h>
  18#include <linux/platform_device.h>
  19#include <linux/gpio/machine.h>
  20#include <linux/pwm.h>
  21#include <linux/pwm_backlight.h>
  22#include <linux/smc91x.h>
  23
  24#include <asm/mach-types.h>
  25#include <asm/mach/arch.h>
  26#include "pxa3xx.h"
  27#include <mach/audio.h>
  28#include <linux/platform_data/video-pxafb.h>
  29#include "zylonite.h"
  30#include <linux/platform_data/mmc-pxamci.h>
  31#include <linux/platform_data/usb-ohci-pxa27x.h>
  32#include <linux/platform_data/keypad-pxa27x.h>
  33#include <linux/platform_data/mtd-nand-pxa3xx.h>
  34
  35#include "devices.h"
  36#include "generic.h"
  37
  38int gpio_eth_irq;
  39int gpio_debug_led1;
  40int gpio_debug_led2;
  41
  42int wm9713_irq;
  43
  44int lcd_id;
  45int lcd_orientation;
  46
  47static struct resource smc91x_resources[] = {
  48        [0] = {
  49                .start  = ZYLONITE_ETH_PHYS + 0x300,
  50                .end    = ZYLONITE_ETH_PHYS + 0xfffff,
  51                .flags  = IORESOURCE_MEM,
  52        },
  53        [1] = {
  54                .start  = -1,   /* for run-time assignment */
  55                .end    = -1,
  56                .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  57        }
  58};
  59
  60static struct smc91x_platdata zylonite_smc91x_info = {
  61        .flags  = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
  62                  SMC91X_NOWAIT | SMC91X_USE_DMA,
  63};
  64
  65static struct platform_device smc91x_device = {
  66        .name           = "smc91x",
  67        .id             = 0,
  68        .num_resources  = ARRAY_SIZE(smc91x_resources),
  69        .resource       = smc91x_resources,
  70        .dev            = {
  71                .platform_data = &zylonite_smc91x_info,
  72        },
  73};
  74
  75#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  76static struct gpio_led zylonite_debug_leds[] = {
  77        [0] = {
  78                .name                   = "zylonite:yellow:1",
  79                .default_trigger        = "heartbeat",
  80        },
  81        [1] = {
  82                .name                   = "zylonite:yellow:2",
  83                .default_trigger        = "default-on",
  84        },
  85};
  86
  87static struct gpio_led_platform_data zylonite_debug_leds_info = {
  88        .leds           = zylonite_debug_leds,
  89        .num_leds       = ARRAY_SIZE(zylonite_debug_leds),
  90};
  91
  92static struct platform_device zylonite_device_leds = {
  93        .name           = "leds-gpio",
  94        .id             = -1,
  95        .dev            = {
  96                .platform_data = &zylonite_debug_leds_info,
  97        }
  98};
  99
 100static void __init zylonite_init_leds(void)
 101{
 102        zylonite_debug_leds[0].gpio = gpio_debug_led1;
 103        zylonite_debug_leds[1].gpio = gpio_debug_led2;
 104
 105        platform_device_register(&zylonite_device_leds);
 106}
 107#else
 108static inline void zylonite_init_leds(void) {}
 109#endif
 110
 111#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
 112static struct pwm_lookup zylonite_pwm_lookup[] = {
 113        PWM_LOOKUP("pxa27x-pwm.1", 1, "pwm-backlight.0", NULL, 10000,
 114                   PWM_POLARITY_NORMAL),
 115};
 116
 117static struct platform_pwm_backlight_data zylonite_backlight_data = {
 118        .max_brightness = 100,
 119        .dft_brightness = 100,
 120};
 121
 122static struct platform_device zylonite_backlight_device = {
 123        .name           = "pwm-backlight",
 124        .dev            = {
 125                .parent = &pxa27x_device_pwm1.dev,
 126                .platform_data  = &zylonite_backlight_data,
 127        },
 128};
 129
 130static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
 131        .pixclock               = 110000,
 132        .xres                   = 240,
 133        .yres                   = 320,
 134        .bpp                    = 16,
 135        .hsync_len              = 4,
 136        .left_margin            = 6,
 137        .right_margin           = 4,
 138        .vsync_len              = 2,
 139        .upper_margin           = 2,
 140        .lower_margin           = 3,
 141        .sync                   = FB_SYNC_VERT_HIGH_ACT,
 142};
 143
 144static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
 145        .pixclock               = 50000,
 146        .xres                   = 640,
 147        .yres                   = 480,
 148        .bpp                    = 16,
 149        .hsync_len              = 1,
 150        .left_margin            = 0x9f,
 151        .right_margin           = 1,
 152        .vsync_len              = 44,
 153        .upper_margin           = 0,
 154        .lower_margin           = 0,
 155        .sync                   = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
 156};
 157
 158static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
 159        .num_modes              = 1,
 160        .lcd_conn               = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
 161};
 162
 163static struct pxafb_mode_info sharp_ls037_modes[] = {
 164        [0] = {
 165                .pixclock       = 158000,
 166                .xres           = 240,
 167                .yres           = 320,
 168                .bpp            = 16,
 169                .hsync_len      = 4,
 170                .left_margin    = 39,
 171                .right_margin   = 39,
 172                .vsync_len      = 1,
 173                .upper_margin   = 2,
 174                .lower_margin   = 3,
 175                .sync           = 0,
 176        },
 177        [1] = {
 178                .pixclock       = 39700,
 179                .xres           = 480,
 180                .yres           = 640,
 181                .bpp            = 16,
 182                .hsync_len      = 8,
 183                .left_margin    = 81,
 184                .right_margin   = 81,
 185                .vsync_len      = 1,
 186                .upper_margin   = 2,
 187                .lower_margin   = 7,
 188                .sync           = 0,
 189        },
 190};
 191
 192static struct pxafb_mach_info zylonite_sharp_lcd_info = {
 193        .modes                  = sharp_ls037_modes,
 194        .num_modes              = 2,
 195        .lcd_conn               = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
 196};
 197
 198static void __init zylonite_init_lcd(void)
 199{
 200        pwm_add_table(zylonite_pwm_lookup, ARRAY_SIZE(zylonite_pwm_lookup));
 201        platform_device_register(&zylonite_backlight_device);
 202
 203        if (lcd_id & 0x20) {
 204                pxa_set_fb_info(NULL, &zylonite_sharp_lcd_info);
 205                return;
 206        }
 207
 208        /* legacy LCD panels, it would be handy here if LCD panel type can
 209         * be decided at run-time
 210         */
 211        if (1)
 212                zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
 213        else
 214                zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
 215
 216        pxa_set_fb_info(NULL, &zylonite_toshiba_lcd_info);
 217}
 218#else
 219static inline void zylonite_init_lcd(void) {}
 220#endif
 221
 222#if defined(CONFIG_MMC)
 223static struct pxamci_platform_data zylonite_mci_platform_data = {
 224        .detect_delay_ms= 200,
 225        .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
 226};
 227
 228#define PCA9539A_MCI_CD 0
 229#define PCA9539A_MCI1_CD 1
 230#define PCA9539A_MCI_WP 2
 231#define PCA9539A_MCI1_WP 3
 232#define PCA9539A_MCI3_CD 30
 233#define PCA9539A_MCI3_WP 31
 234
 235static struct gpiod_lookup_table zylonite_mci_gpio_table = {
 236        .dev_id = "pxa2xx-mci.0",
 237        .table = {
 238                GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI_CD,
 239                            "cd", GPIO_ACTIVE_LOW),
 240                GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI_WP,
 241                            "wp", GPIO_ACTIVE_LOW),
 242                { },
 243        },
 244};
 245
 246static struct pxamci_platform_data zylonite_mci2_platform_data = {
 247        .detect_delay_ms= 200,
 248        .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
 249};
 250
 251static struct gpiod_lookup_table zylonite_mci2_gpio_table = {
 252        .dev_id = "pxa2xx-mci.1",
 253        .table = {
 254                GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI1_CD,
 255                            "cd", GPIO_ACTIVE_LOW),
 256                GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI1_WP,
 257                            "wp", GPIO_ACTIVE_LOW),
 258                { },
 259        },
 260};
 261
 262static struct pxamci_platform_data zylonite_mci3_platform_data = {
 263        .detect_delay_ms= 200,
 264        .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
 265};
 266
 267static struct gpiod_lookup_table zylonite_mci3_gpio_table = {
 268        .dev_id = "pxa2xx-mci.2",
 269        .table = {
 270                GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI3_CD,
 271                            "cd", GPIO_ACTIVE_LOW),
 272                GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI3_WP,
 273                            "wp", GPIO_ACTIVE_LOW),
 274                { },
 275        },
 276};
 277
 278static void __init zylonite_init_mmc(void)
 279{
 280        gpiod_add_lookup_table(&zylonite_mci_gpio_table);
 281        pxa_set_mci_info(&zylonite_mci_platform_data);
 282        gpiod_add_lookup_table(&zylonite_mci2_gpio_table);
 283        pxa3xx_set_mci2_info(&zylonite_mci2_platform_data);
 284        if (cpu_is_pxa310()) {
 285                gpiod_add_lookup_table(&zylonite_mci3_gpio_table);
 286                pxa3xx_set_mci3_info(&zylonite_mci3_platform_data);
 287        }
 288}
 289#else
 290static inline void zylonite_init_mmc(void) {}
 291#endif
 292
 293#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
 294static const unsigned int zylonite_matrix_key_map[] = {
 295        /* KEY(row, col, key_code) */
 296        KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_C), KEY(0, 5, KEY_D),
 297        KEY(1, 0, KEY_E), KEY(1, 1, KEY_F), KEY(1, 2, KEY_G), KEY(1, 5, KEY_H),
 298        KEY(2, 0, KEY_I), KEY(2, 1, KEY_J), KEY(2, 2, KEY_K), KEY(2, 5, KEY_L),
 299        KEY(3, 0, KEY_M), KEY(3, 1, KEY_N), KEY(3, 2, KEY_O), KEY(3, 5, KEY_P),
 300        KEY(5, 0, KEY_Q), KEY(5, 1, KEY_R), KEY(5, 2, KEY_S), KEY(5, 5, KEY_T),
 301        KEY(6, 0, KEY_U), KEY(6, 1, KEY_V), KEY(6, 2, KEY_W), KEY(6, 5, KEY_X),
 302        KEY(7, 1, KEY_Y), KEY(7, 2, KEY_Z),
 303
 304        KEY(4, 4, KEY_0), KEY(1, 3, KEY_1), KEY(4, 1, KEY_2), KEY(1, 4, KEY_3),
 305        KEY(2, 3, KEY_4), KEY(4, 2, KEY_5), KEY(2, 4, KEY_6), KEY(3, 3, KEY_7),
 306        KEY(4, 3, KEY_8), KEY(3, 4, KEY_9),
 307
 308        KEY(4, 5, KEY_SPACE),
 309        KEY(5, 3, KEY_KPASTERISK),      /* * */
 310        KEY(5, 4, KEY_KPDOT),           /* #" */
 311
 312        KEY(0, 7, KEY_UP),
 313        KEY(1, 7, KEY_DOWN),
 314        KEY(2, 7, KEY_LEFT),
 315        KEY(3, 7, KEY_RIGHT),
 316        KEY(2, 6, KEY_HOME),
 317        KEY(3, 6, KEY_END),
 318        KEY(6, 4, KEY_DELETE),
 319        KEY(6, 6, KEY_BACK),
 320        KEY(6, 3, KEY_CAPSLOCK),        /* KEY_LEFTSHIFT), */
 321
 322        KEY(4, 6, KEY_ENTER),           /* scroll push */
 323        KEY(5, 7, KEY_ENTER),           /* keypad action */
 324
 325        KEY(0, 4, KEY_EMAIL),
 326        KEY(5, 6, KEY_SEND),
 327        KEY(4, 0, KEY_CALENDAR),
 328        KEY(7, 6, KEY_RECORD),
 329        KEY(6, 7, KEY_VOLUMEUP),
 330        KEY(7, 7, KEY_VOLUMEDOWN),
 331
 332        KEY(0, 6, KEY_F22),     /* soft1 */
 333        KEY(1, 6, KEY_F23),     /* soft2 */
 334        KEY(0, 3, KEY_AUX),     /* contact */
 335};
 336
 337static struct matrix_keymap_data zylonite_matrix_keymap_data = {
 338        .keymap                 = zylonite_matrix_key_map,
 339        .keymap_size            = ARRAY_SIZE(zylonite_matrix_key_map),
 340};
 341
 342static struct pxa27x_keypad_platform_data zylonite_keypad_info = {
 343        .matrix_key_rows        = 8,
 344        .matrix_key_cols        = 8,
 345        .matrix_keymap_data     = &zylonite_matrix_keymap_data,
 346
 347        .enable_rotary0         = 1,
 348        .rotary0_up_key         = KEY_UP,
 349        .rotary0_down_key       = KEY_DOWN,
 350
 351        .debounce_interval      = 30,
 352};
 353
 354static void __init zylonite_init_keypad(void)
 355{
 356        pxa_set_keypad_info(&zylonite_keypad_info);
 357}
 358#else
 359static inline void zylonite_init_keypad(void) {}
 360#endif
 361
 362#if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
 363static struct mtd_partition zylonite_nand_partitions[] = {
 364        [0] = {
 365                .name        = "Bootloader",
 366                .offset      = 0,
 367                .size        = 0x060000,
 368                .mask_flags  = MTD_WRITEABLE, /* force read-only */
 369        },
 370        [1] = {
 371                .name        = "Kernel",
 372                .offset      = 0x060000,
 373                .size        = 0x200000,
 374                .mask_flags  = MTD_WRITEABLE, /* force read-only */
 375        },
 376        [2] = {
 377                .name        = "Filesystem",
 378                .offset      = 0x0260000,
 379                .size        = 0x3000000,     /* 48M - rootfs */
 380        },
 381        [3] = {
 382                .name        = "MassStorage",
 383                .offset      = 0x3260000,
 384                .size        = 0x3d40000,
 385        },
 386        [4] = {
 387                .name        = "BBT",
 388                .offset      = 0x6FA0000,
 389                .size        = 0x80000,
 390                .mask_flags  = MTD_WRITEABLE,  /* force read-only */
 391        },
 392        /* NOTE: we reserve some blocks at the end of the NAND flash for
 393         * bad block management, and the max number of relocation blocks
 394         * differs on different platforms. Please take care with it when
 395         * defining the partition table.
 396         */
 397};
 398
 399static struct pxa3xx_nand_platform_data zylonite_nand_info = {
 400        .parts          = zylonite_nand_partitions,
 401        .nr_parts       = ARRAY_SIZE(zylonite_nand_partitions),
 402};
 403
 404static void __init zylonite_init_nand(void)
 405{
 406        pxa3xx_set_nand_info(&zylonite_nand_info);
 407}
 408#else
 409static inline void zylonite_init_nand(void) {}
 410#endif /* IS_ENABLED(CONFIG_MTD_NAND_MARVELL) */
 411
 412#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
 413static struct pxaohci_platform_data zylonite_ohci_info = {
 414        .port_mode      = PMM_PERPORT_MODE,
 415        .flags          = ENABLE_PORT1 | ENABLE_PORT2 |
 416                          POWER_CONTROL_LOW | POWER_SENSE_LOW,
 417};
 418
 419static void __init zylonite_init_ohci(void)
 420{
 421        pxa_set_ohci_info(&zylonite_ohci_info);
 422}
 423#else
 424static inline void zylonite_init_ohci(void) {}
 425#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
 426
 427static void __init zylonite_init(void)
 428{
 429        pxa_set_ffuart_info(NULL);
 430        pxa_set_btuart_info(NULL);
 431        pxa_set_stuart_info(NULL);
 432
 433        /* board-processor specific initialization */
 434        zylonite_pxa300_init();
 435        zylonite_pxa320_init();
 436
 437        /*
 438         * Note: We depend that the bootloader set
 439         * the correct value to MSC register for SMC91x.
 440         */
 441        smc91x_resources[1].start = PXA_GPIO_TO_IRQ(gpio_eth_irq);
 442        smc91x_resources[1].end   = PXA_GPIO_TO_IRQ(gpio_eth_irq);
 443        platform_device_register(&smc91x_device);
 444
 445        pxa_set_ac97_info(NULL);
 446        zylonite_init_lcd();
 447        zylonite_init_mmc();
 448        zylonite_init_keypad();
 449        zylonite_init_nand();
 450        zylonite_init_leds();
 451        zylonite_init_ohci();
 452}
 453
 454MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
 455        .atag_offset    = 0x100,
 456        .map_io         = pxa3xx_map_io,
 457        .nr_irqs        = ZYLONITE_NR_IRQS,
 458        .init_irq       = pxa3xx_init_irq,
 459        .handle_irq     = pxa3xx_handle_irq,
 460        .init_time      = pxa_timer_init,
 461        .init_machine   = zylonite_init,
 462        .restart        = pxa_restart,
 463MACHINE_END
 464