linux/arch/arm/mach-pxa/cm-x300.c
<<
>>
Prefs
   1/*
   2 * linux/arch/arm/mach-pxa/cm-x300.c
   3 *
   4 * Support for the CompuLab CM-X300 modules
   5 *
   6 * Copyright (C) 2008 CompuLab Ltd.
   7 *
   8 * Mike Rapoport <mike@compulab.co.il>
   9 *
  10 * This program is free software; you can redistribute it and/or modify
  11 * it under the terms of the GNU General Public License version 2 as
  12 * published by the Free Software Foundation.
  13 */
  14
  15#include <linux/module.h>
  16#include <linux/kernel.h>
  17#include <linux/interrupt.h>
  18#include <linux/init.h>
  19#include <linux/platform_device.h>
  20
  21#include <linux/gpio.h>
  22#include <linux/dm9000.h>
  23#include <linux/leds.h>
  24#include <linux/rtc-v3020.h>
  25
  26#include <linux/i2c.h>
  27#include <linux/i2c/pca953x.h>
  28
  29#include <asm/mach-types.h>
  30#include <asm/mach/arch.h>
  31#include <asm/setup.h>
  32
  33#include <mach/pxa300.h>
  34#include <mach/pxafb.h>
  35#include <mach/mmc.h>
  36#include <mach/ohci.h>
  37#include <plat/i2c.h>
  38#include <mach/pxa3xx_nand.h>
  39
  40#include <asm/mach/map.h>
  41
  42#include "generic.h"
  43
  44#define CM_X300_ETH_PHYS        0x08000010
  45
  46#define GPIO82_MMC_IRQ          (82)
  47#define GPIO85_MMC_WP           (85)
  48
  49#define CM_X300_MMC_IRQ         IRQ_GPIO(GPIO82_MMC_IRQ)
  50
  51#define GPIO95_RTC_CS           (95)
  52#define GPIO96_RTC_WR           (96)
  53#define GPIO97_RTC_RD           (97)
  54#define GPIO98_RTC_IO           (98)
  55
  56static mfp_cfg_t cm_x300_mfp_cfg[] __initdata = {
  57        /* LCD */
  58        GPIO54_LCD_LDD_0,
  59        GPIO55_LCD_LDD_1,
  60        GPIO56_LCD_LDD_2,
  61        GPIO57_LCD_LDD_3,
  62        GPIO58_LCD_LDD_4,
  63        GPIO59_LCD_LDD_5,
  64        GPIO60_LCD_LDD_6,
  65        GPIO61_LCD_LDD_7,
  66        GPIO62_LCD_LDD_8,
  67        GPIO63_LCD_LDD_9,
  68        GPIO64_LCD_LDD_10,
  69        GPIO65_LCD_LDD_11,
  70        GPIO66_LCD_LDD_12,
  71        GPIO67_LCD_LDD_13,
  72        GPIO68_LCD_LDD_14,
  73        GPIO69_LCD_LDD_15,
  74        GPIO72_LCD_FCLK,
  75        GPIO73_LCD_LCLK,
  76        GPIO74_LCD_PCLK,
  77        GPIO75_LCD_BIAS,
  78
  79        /* BTUART */
  80        GPIO111_UART2_RTS,
  81        GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
  82        GPIO113_UART2_TXD,
  83        GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
  84
  85        /* STUART */
  86        GPIO109_UART3_TXD,
  87        GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
  88
  89        /* AC97 */
  90        GPIO23_AC97_nACRESET,
  91        GPIO24_AC97_SYSCLK,
  92        GPIO29_AC97_BITCLK,
  93        GPIO25_AC97_SDATA_IN_0,
  94        GPIO27_AC97_SDATA_OUT,
  95        GPIO28_AC97_SYNC,
  96
  97        /* Keypad */
  98        GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
  99        GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
 100        GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
 101        GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
 102        GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
 103        GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
 104        GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
 105        GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
 106        GPIO121_KP_MKOUT_0,
 107        GPIO122_KP_MKOUT_1,
 108        GPIO123_KP_MKOUT_2,
 109        GPIO124_KP_MKOUT_3,
 110        GPIO125_KP_MKOUT_4,
 111        GPIO4_2_KP_MKOUT_5,
 112
 113        /* MMC1 */
 114        GPIO3_MMC1_DAT0,
 115        GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
 116        GPIO5_MMC1_DAT2,
 117        GPIO6_MMC1_DAT3,
 118        GPIO7_MMC1_CLK,
 119        GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
 120
 121        /* MMC2 */
 122        GPIO9_MMC2_DAT0,
 123        GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
 124        GPIO11_MMC2_DAT2,
 125        GPIO12_MMC2_DAT3,
 126        GPIO13_MMC2_CLK,
 127        GPIO14_MMC2_CMD,
 128
 129        /* FFUART */
 130        GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
 131        GPIO31_UART1_TXD,
 132        GPIO32_UART1_CTS,
 133        GPIO37_UART1_RTS,
 134        GPIO33_UART1_DCD,
 135        GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
 136        GPIO35_UART1_RI,
 137        GPIO36_UART1_DTR,
 138
 139        /* GPIOs */
 140        GPIO79_GPIO,                    /* LED */
 141        GPIO82_GPIO | MFP_PULL_HIGH,    /* MMC CD */
 142        GPIO85_GPIO,                    /* MMC WP */
 143        GPIO99_GPIO,                    /* Ethernet IRQ */
 144
 145        /* RTC GPIOs */
 146        GPIO95_GPIO,                    /* RTC CS */
 147        GPIO96_GPIO,                    /* RTC WR */
 148        GPIO97_GPIO,                    /* RTC RD */
 149        GPIO98_GPIO,                    /* RTC IO */
 150
 151        /* Standard I2C */
 152        GPIO21_I2C_SCL,
 153        GPIO22_I2C_SDA,
 154};
 155
 156#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
 157static struct resource dm9000_resources[] = {
 158        [0] = {
 159                .start  = CM_X300_ETH_PHYS,
 160                .end    = CM_X300_ETH_PHYS + 0x3,
 161                .flags  = IORESOURCE_MEM,
 162        },
 163        [1] = {
 164                .start  = CM_X300_ETH_PHYS + 0x4,
 165                .end    = CM_X300_ETH_PHYS + 0x4 + 500,
 166                .flags  = IORESOURCE_MEM,
 167        },
 168        [2] = {
 169                .start  = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
 170                .end    = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
 171                .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
 172        }
 173};
 174
 175static struct dm9000_plat_data cm_x300_dm9000_platdata = {
 176        .flags          = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
 177};
 178
 179static struct platform_device dm9000_device = {
 180        .name           = "dm9000",
 181        .id             = 0,
 182        .num_resources  = ARRAY_SIZE(dm9000_resources),
 183        .resource       = dm9000_resources,
 184        .dev            = {
 185                .platform_data = &cm_x300_dm9000_platdata,
 186        }
 187
 188};
 189
 190static void __init cm_x300_init_dm9000(void)
 191{
 192        platform_device_register(&dm9000_device);
 193}
 194#else
 195static inline void cm_x300_init_dm9000(void) {}
 196#endif
 197
 198#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
 199static struct pxafb_mode_info cm_x300_lcd_modes[] = {
 200        [0] = {
 201                .pixclock       = 38000,
 202                .bpp            = 16,
 203                .xres           = 480,
 204                .yres           = 640,
 205                .hsync_len      = 8,
 206                .vsync_len      = 2,
 207                .left_margin    = 8,
 208                .upper_margin   = 0,
 209                .right_margin   = 24,
 210                .lower_margin   = 4,
 211                .cmap_greyscale = 0,
 212        },
 213        [1] = {
 214                .pixclock       = 153800,
 215                .bpp            = 16,
 216                .xres           = 240,
 217                .yres           = 320,
 218                .hsync_len      = 8,
 219                .vsync_len      = 2,
 220                .left_margin    = 8,
 221                .upper_margin   = 2,
 222                .right_margin   = 88,
 223                .lower_margin   = 2,
 224                .cmap_greyscale = 0,
 225        },
 226};
 227
 228static struct pxafb_mach_info cm_x300_lcd = {
 229        .modes                  = cm_x300_lcd_modes,
 230        .num_modes              = 2,
 231        .lcd_conn               = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
 232};
 233
 234static void __init cm_x300_init_lcd(void)
 235{
 236        set_pxa_fb_info(&cm_x300_lcd);
 237}
 238#else
 239static inline void cm_x300_init_lcd(void) {}
 240#endif
 241
 242#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
 243static struct mtd_partition cm_x300_nand_partitions[] = {
 244        [0] = {
 245                .name        = "OBM",
 246                .offset      = 0,
 247                .size        = SZ_256K,
 248                .mask_flags  = MTD_WRITEABLE, /* force read-only */
 249        },
 250        [1] = {
 251                .name        = "U-Boot",
 252                .offset      = MTDPART_OFS_APPEND,
 253                .size        = SZ_256K,
 254                .mask_flags  = MTD_WRITEABLE, /* force read-only */
 255        },
 256        [2] = {
 257                .name        = "Environment",
 258                .offset      = MTDPART_OFS_APPEND,
 259                .size        = SZ_256K,
 260        },
 261        [3] = {
 262                .name        = "reserved",
 263                .offset      = MTDPART_OFS_APPEND,
 264                .size        = SZ_256K + SZ_1M,
 265                .mask_flags  = MTD_WRITEABLE, /* force read-only */
 266        },
 267        [4] = {
 268                .name        = "kernel",
 269                .offset      = MTDPART_OFS_APPEND,
 270                .size        = SZ_4M,
 271        },
 272        [5] = {
 273                .name        = "fs",
 274                .offset      = MTDPART_OFS_APPEND,
 275                .size        = MTDPART_SIZ_FULL,
 276        },
 277};
 278
 279static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
 280        .enable_arbiter = 1,
 281        .keep_config    = 1,
 282        .parts          = cm_x300_nand_partitions,
 283        .nr_parts       = ARRAY_SIZE(cm_x300_nand_partitions),
 284};
 285
 286static void __init cm_x300_init_nand(void)
 287{
 288        pxa3xx_set_nand_info(&cm_x300_nand_info);
 289}
 290#else
 291static inline void cm_x300_init_nand(void) {}
 292#endif
 293
 294#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
 295static struct pxamci_platform_data cm_x300_mci_platform_data = {
 296        .detect_delay           = 20,
 297        .ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
 298        .gpio_card_detect       = GPIO82_MMC_IRQ,
 299        .gpio_card_ro           = GPIO85_MMC_WP,
 300        .gpio_power             = -1,
 301};
 302
 303/* The second MMC slot of CM-X300 is hardwired to Libertas card and has
 304   no detection/ro pins */
 305static int cm_x300_mci2_init(struct device *dev,
 306                             irq_handler_t cm_x300_detect_int,
 307        void *data)
 308{
 309        return 0;
 310}
 311
 312static void cm_x300_mci2_exit(struct device *dev, void *data)
 313{
 314}
 315
 316static struct pxamci_platform_data cm_x300_mci2_platform_data = {
 317        .detect_delay           = 20,
 318        .ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
 319        .init                   = cm_x300_mci2_init,
 320        .exit                   = cm_x300_mci2_exit,
 321        .gpio_card_detect       = -1,
 322        .gpio_card_ro           = -1,
 323        .gpio_power             = -1,
 324};
 325
 326static void __init cm_x300_init_mmc(void)
 327{
 328        pxa_set_mci_info(&cm_x300_mci_platform_data);
 329        pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
 330}
 331#else
 332static inline void cm_x300_init_mmc(void) {}
 333#endif
 334
 335#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
 336static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
 337        .port_mode      = PMM_PERPORT_MODE,
 338        .flags          = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
 339};
 340
 341static void __init cm_x300_init_ohci(void)
 342{
 343        pxa_set_ohci_info(&cm_x300_ohci_platform_data);
 344}
 345#else
 346static inline void cm_x300_init_ohci(void) {}
 347#endif
 348
 349#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
 350static struct gpio_led cm_x300_leds[] = {
 351        [0] = {
 352                .name = "cm-x300:green",
 353                .default_trigger = "heartbeat",
 354                .gpio = 79,
 355                .active_low = 1,
 356        },
 357};
 358
 359static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
 360        .num_leds = ARRAY_SIZE(cm_x300_leds),
 361        .leds = cm_x300_leds,
 362};
 363
 364static struct platform_device cm_x300_led_device = {
 365        .name           = "leds-gpio",
 366        .id             = -1,
 367        .dev            = {
 368                .platform_data = &cm_x300_gpio_led_pdata,
 369        },
 370};
 371
 372static void __init cm_x300_init_leds(void)
 373{
 374        platform_device_register(&cm_x300_led_device);
 375}
 376#else
 377static inline void cm_x300_init_leds(void) {}
 378#endif
 379
 380#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 381/* PCA9555 */
 382static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
 383        .gpio_base = 128,
 384};
 385
 386static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
 387        .gpio_base = 144,
 388};
 389
 390static struct i2c_board_info cm_x300_gpio_ext_info[] = {
 391        [0] = {
 392                I2C_BOARD_INFO("pca9555", 0x24),
 393                .platform_data = &cm_x300_gpio_ext_pdata_0,
 394        },
 395        [1] = {
 396                I2C_BOARD_INFO("pca9555", 0x25),
 397                .platform_data = &cm_x300_gpio_ext_pdata_1,
 398        },
 399};
 400
 401static void __init cm_x300_init_i2c(void)
 402{
 403        pxa_set_i2c_info(NULL);
 404        i2c_register_board_info(0, cm_x300_gpio_ext_info,
 405                                ARRAY_SIZE(cm_x300_gpio_ext_info));
 406}
 407#else
 408static inline void cm_x300_init_i2c(void) {}
 409#endif
 410
 411#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
 412struct v3020_platform_data cm_x300_v3020_pdata = {
 413        .use_gpio       = 1,
 414        .gpio_cs        = GPIO95_RTC_CS,
 415        .gpio_wr        = GPIO96_RTC_WR,
 416        .gpio_rd        = GPIO97_RTC_RD,
 417        .gpio_io        = GPIO98_RTC_IO,
 418};
 419
 420static struct platform_device cm_x300_rtc_device = {
 421        .name           = "v3020",
 422        .id             = -1,
 423        .dev            = {
 424                .platform_data = &cm_x300_v3020_pdata,
 425        }
 426};
 427
 428static void __init cm_x300_init_rtc(void)
 429{
 430        platform_device_register(&cm_x300_rtc_device);
 431}
 432#else
 433static inline void cm_x300_init_rtc(void) {}
 434#endif
 435
 436static void __init cm_x300_init(void)
 437{
 438        /* board-processor specific GPIO initialization */
 439        pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_mfp_cfg));
 440
 441        cm_x300_init_dm9000();
 442        cm_x300_init_lcd();
 443        cm_x300_init_ohci();
 444        cm_x300_init_mmc();
 445        cm_x300_init_nand();
 446        cm_x300_init_leds();
 447        cm_x300_init_i2c();
 448        cm_x300_init_rtc();
 449}
 450
 451static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags,
 452                                 char **cmdline, struct meminfo *mi)
 453{
 454        mi->nr_banks = 2;
 455        mi->bank[0].start = 0xa0000000;
 456        mi->bank[0].node = 0;
 457        mi->bank[0].size = (64*1024*1024);
 458        mi->bank[1].start = 0xc0000000;
 459        mi->bank[1].node = 0;
 460        mi->bank[1].size = (64*1024*1024);
 461}
 462
 463MACHINE_START(CM_X300, "CM-X300 module")
 464        .phys_io        = 0x40000000,
 465        .boot_params    = 0xa0000100,
 466        .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
 467        .map_io         = pxa_map_io,
 468        .init_irq       = pxa3xx_init_irq,
 469        .timer          = &pxa_timer,
 470        .init_machine   = cm_x300_init,
 471        .fixup          = cm_x300_fixup,
 472MACHINE_END
 473