Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/arch/arm/mach-pxa/cm-x300.c
0004  *
0005  * Support for the CompuLab CM-X300 modules
0006  *
0007  * Copyright (C) 2008,2009 CompuLab Ltd.
0008  *
0009  * Mike Rapoport <mike@compulab.co.il>
0010  * Igor Grinberg <grinberg@compulab.co.il>
0011  */
0012 #define pr_fmt(fmt) "%s: " fmt, __func__
0013 
0014 #include <linux/module.h>
0015 #include <linux/kernel.h>
0016 #include <linux/interrupt.h>
0017 #include <linux/init.h>
0018 #include <linux/delay.h>
0019 #include <linux/platform_device.h>
0020 #include <linux/clk.h>
0021 
0022 #include <linux/gpio.h>
0023 #include <linux/gpio/machine.h>
0024 #include <linux/dm9000.h>
0025 #include <linux/leds.h>
0026 #include <linux/platform_data/rtc-v3020.h>
0027 #include <linux/pwm.h>
0028 #include <linux/pwm_backlight.h>
0029 
0030 #include <linux/i2c.h>
0031 #include <linux/platform_data/pca953x.h>
0032 #include <linux/platform_data/i2c-pxa.h>
0033 
0034 #include <linux/mfd/da903x.h>
0035 #include <linux/regulator/machine.h>
0036 #include <linux/power_supply.h>
0037 #include <linux/apm-emulation.h>
0038 
0039 #include <linux/spi/spi.h>
0040 #include <linux/spi/spi_gpio.h>
0041 #include <linux/spi/tdo24m.h>
0042 
0043 #include <linux/soc/pxa/cpu.h>
0044 
0045 #include <asm/mach-types.h>
0046 #include <asm/mach/arch.h>
0047 #include <asm/setup.h>
0048 #include <asm/system_info.h>
0049 
0050 #include "pxa300.h"
0051 #include "pxa27x-udc.h"
0052 #include <linux/platform_data/video-pxafb.h>
0053 #include <linux/platform_data/mmc-pxamci.h>
0054 #include <linux/platform_data/usb-ohci-pxa27x.h>
0055 #include <linux/platform_data/mtd-nand-pxa3xx.h>
0056 #include <linux/platform_data/asoc-pxa.h>
0057 #include <linux/platform_data/usb-pxa3xx-ulpi.h>
0058 
0059 #include <asm/mach/map.h>
0060 
0061 #include "generic.h"
0062 #include "devices.h"
0063 
0064 #define CM_X300_ETH_PHYS    0x08000010
0065 
0066 #define GPIO82_MMC_IRQ      (82)
0067 #define GPIO85_MMC_WP       (85)
0068 
0069 #define CM_X300_MMC_IRQ     PXA_GPIO_TO_IRQ(GPIO82_MMC_IRQ)
0070 
0071 #define GPIO95_RTC_CS       (95)
0072 #define GPIO96_RTC_WR       (96)
0073 #define GPIO97_RTC_RD       (97)
0074 #define GPIO98_RTC_IO       (98)
0075 
0076 #define GPIO_ULPI_PHY_RST   (127)
0077 
0078 static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
0079     /* LCD */
0080     GPIO54_LCD_LDD_0,
0081     GPIO55_LCD_LDD_1,
0082     GPIO56_LCD_LDD_2,
0083     GPIO57_LCD_LDD_3,
0084     GPIO58_LCD_LDD_4,
0085     GPIO59_LCD_LDD_5,
0086     GPIO60_LCD_LDD_6,
0087     GPIO61_LCD_LDD_7,
0088     GPIO62_LCD_LDD_8,
0089     GPIO63_LCD_LDD_9,
0090     GPIO64_LCD_LDD_10,
0091     GPIO65_LCD_LDD_11,
0092     GPIO66_LCD_LDD_12,
0093     GPIO67_LCD_LDD_13,
0094     GPIO68_LCD_LDD_14,
0095     GPIO69_LCD_LDD_15,
0096     GPIO72_LCD_FCLK,
0097     GPIO73_LCD_LCLK,
0098     GPIO74_LCD_PCLK,
0099     GPIO75_LCD_BIAS,
0100 
0101     /* BTUART */
0102     GPIO111_UART2_RTS,
0103     GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
0104     GPIO113_UART2_TXD,
0105     GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
0106 
0107     /* STUART */
0108     GPIO109_UART3_TXD,
0109     GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
0110 
0111     /* AC97 */
0112     GPIO23_AC97_nACRESET,
0113     GPIO24_AC97_SYSCLK,
0114     GPIO29_AC97_BITCLK,
0115     GPIO25_AC97_SDATA_IN_0,
0116     GPIO27_AC97_SDATA_OUT,
0117     GPIO28_AC97_SYNC,
0118 
0119     /* Keypad */
0120     GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
0121     GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
0122     GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
0123     GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
0124     GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
0125     GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
0126     GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
0127     GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
0128     GPIO121_KP_MKOUT_0,
0129     GPIO122_KP_MKOUT_1,
0130     GPIO123_KP_MKOUT_2,
0131     GPIO124_KP_MKOUT_3,
0132     GPIO125_KP_MKOUT_4,
0133     GPIO4_2_KP_MKOUT_5,
0134 
0135     /* MMC1 */
0136     GPIO3_MMC1_DAT0,
0137     GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
0138     GPIO5_MMC1_DAT2,
0139     GPIO6_MMC1_DAT3,
0140     GPIO7_MMC1_CLK,
0141     GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
0142 
0143     /* MMC2 */
0144     GPIO9_MMC2_DAT0,
0145     GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
0146     GPIO11_MMC2_DAT2,
0147     GPIO12_MMC2_DAT3,
0148     GPIO13_MMC2_CLK,
0149     GPIO14_MMC2_CMD,
0150 
0151     /* FFUART */
0152     GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
0153     GPIO31_UART1_TXD,
0154     GPIO32_UART1_CTS,
0155     GPIO37_UART1_RTS,
0156     GPIO33_UART1_DCD,
0157     GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
0158     GPIO35_UART1_RI,
0159     GPIO36_UART1_DTR,
0160 
0161     /* GPIOs */
0162     GPIO82_GPIO | MFP_PULL_HIGH,    /* MMC CD */
0163     GPIO85_GPIO,            /* MMC WP */
0164     GPIO99_GPIO,            /* Ethernet IRQ */
0165 
0166     /* RTC GPIOs */
0167     GPIO95_GPIO | MFP_LPM_DRIVE_HIGH,   /* RTC CS */
0168     GPIO96_GPIO | MFP_LPM_DRIVE_HIGH,   /* RTC WR */
0169     GPIO97_GPIO | MFP_LPM_DRIVE_HIGH,   /* RTC RD */
0170     GPIO98_GPIO,                /* RTC IO */
0171 
0172     /* Standard I2C */
0173     GPIO21_I2C_SCL,
0174     GPIO22_I2C_SDA,
0175 
0176     /* PWM Backlight */
0177     GPIO19_PWM2_OUT,
0178 };
0179 
0180 static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
0181     /* GPIOs */
0182     GPIO79_GPIO,            /* LED */
0183     GPIO77_GPIO,            /* WiFi reset */
0184     GPIO78_GPIO,            /* BT reset */
0185 };
0186 
0187 static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
0188     /* GPIOs */
0189     GPIO76_GPIO,            /* LED */
0190     GPIO71_GPIO,            /* WiFi reset */
0191     GPIO70_GPIO,            /* BT reset */
0192 };
0193 
0194 static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = {
0195     /* USB PORT 2 */
0196     ULPI_STP,
0197     ULPI_NXT,
0198     ULPI_DIR,
0199     GPIO30_ULPI_DATA_OUT_0,
0200     GPIO31_ULPI_DATA_OUT_1,
0201     GPIO32_ULPI_DATA_OUT_2,
0202     GPIO33_ULPI_DATA_OUT_3,
0203     GPIO34_ULPI_DATA_OUT_4,
0204     GPIO35_ULPI_DATA_OUT_5,
0205     GPIO36_ULPI_DATA_OUT_6,
0206     GPIO37_ULPI_DATA_OUT_7,
0207     GPIO38_ULPI_CLK,
0208     /* external PHY reset pin */
0209     GPIO127_GPIO,
0210 
0211     /* USB PORT 3 */
0212     GPIO77_USB_P3_1,
0213     GPIO78_USB_P3_2,
0214     GPIO79_USB_P3_3,
0215     GPIO80_USB_P3_4,
0216     GPIO81_USB_P3_5,
0217     GPIO82_USB_P3_6,
0218     GPIO0_2_USBH_PEN,
0219 };
0220 
0221 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
0222 static struct resource dm9000_resources[] = {
0223     [0] = {
0224         .start  = CM_X300_ETH_PHYS,
0225         .end    = CM_X300_ETH_PHYS + 0x3,
0226         .flags  = IORESOURCE_MEM,
0227     },
0228     [1] = {
0229         .start  = CM_X300_ETH_PHYS + 0x4,
0230         .end    = CM_X300_ETH_PHYS + 0x4 + 500,
0231         .flags  = IORESOURCE_MEM,
0232     },
0233     [2] = {
0234         .start  = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)),
0235         .end    = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)),
0236         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
0237     }
0238 };
0239 
0240 static struct dm9000_plat_data cm_x300_dm9000_platdata = {
0241     .flags      = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
0242 };
0243 
0244 static struct platform_device dm9000_device = {
0245     .name       = "dm9000",
0246     .id     = 0,
0247     .num_resources  = ARRAY_SIZE(dm9000_resources),
0248     .resource   = dm9000_resources,
0249     .dev        = {
0250         .platform_data = &cm_x300_dm9000_platdata,
0251     }
0252 
0253 };
0254 
0255 static void __init cm_x300_init_dm9000(void)
0256 {
0257     platform_device_register(&dm9000_device);
0258 }
0259 #else
0260 static inline void cm_x300_init_dm9000(void) {}
0261 #endif
0262 
0263 /* LCD */
0264 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
0265 static struct pxafb_mode_info cm_x300_lcd_modes[] = {
0266     [0] = {
0267         .pixclock   = 38250,
0268         .bpp        = 16,
0269         .xres       = 480,
0270         .yres       = 640,
0271         .hsync_len  = 8,
0272         .vsync_len  = 2,
0273         .left_margin    = 8,
0274         .upper_margin   = 2,
0275         .right_margin   = 24,
0276         .lower_margin   = 4,
0277         .cmap_greyscale = 0,
0278     },
0279     [1] = {
0280         .pixclock   = 153800,
0281         .bpp        = 16,
0282         .xres       = 240,
0283         .yres       = 320,
0284         .hsync_len  = 8,
0285         .vsync_len  = 2,
0286         .left_margin    = 8,
0287         .upper_margin   = 2,
0288         .right_margin   = 88,
0289         .lower_margin   = 2,
0290         .cmap_greyscale = 0,
0291     },
0292 };
0293 
0294 static struct pxafb_mach_info cm_x300_lcd = {
0295     .modes          = cm_x300_lcd_modes,
0296     .num_modes      = ARRAY_SIZE(cm_x300_lcd_modes),
0297     .lcd_conn       = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
0298 };
0299 
0300 static void __init cm_x300_init_lcd(void)
0301 {
0302     pxa_set_fb_info(NULL, &cm_x300_lcd);
0303 }
0304 #else
0305 static inline void cm_x300_init_lcd(void) {}
0306 #endif
0307 
0308 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
0309 static struct pwm_lookup cm_x300_pwm_lookup[] = {
0310     PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.0", NULL, 10000,
0311            PWM_POLARITY_NORMAL),
0312 };
0313 
0314 static struct platform_pwm_backlight_data cm_x300_backlight_data = {
0315     .max_brightness = 100,
0316     .dft_brightness = 100,
0317 };
0318 
0319 static struct platform_device cm_x300_backlight_device = {
0320     .name       = "pwm-backlight",
0321     .dev        = {
0322         .parent = &pxa27x_device_pwm0.dev,
0323         .platform_data  = &cm_x300_backlight_data,
0324     },
0325 };
0326 
0327 static void cm_x300_init_bl(void)
0328 {
0329     pwm_add_table(cm_x300_pwm_lookup, ARRAY_SIZE(cm_x300_pwm_lookup));
0330     platform_device_register(&cm_x300_backlight_device);
0331 }
0332 #else
0333 static inline void cm_x300_init_bl(void) {}
0334 #endif
0335 
0336 #if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
0337 #define GPIO_LCD_BASE   (144)
0338 #define GPIO_LCD_DIN    (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
0339 #define GPIO_LCD_DOUT   (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
0340 #define GPIO_LCD_SCL    (GPIO_LCD_BASE + 10)    /* aux_gpio3_2 */
0341 #define GPIO_LCD_CS (GPIO_LCD_BASE + 11)    /* aux_gpio3_3 */
0342 #define LCD_SPI_BUS_NUM (1)
0343 
0344 static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
0345     .num_chipselect = 1,
0346 };
0347 
0348 static struct platform_device cm_x300_spi_gpio = {
0349     .name       = "spi_gpio",
0350     .id     = LCD_SPI_BUS_NUM,
0351     .dev        = {
0352         .platform_data  = &cm_x300_spi_gpio_pdata,
0353     },
0354 };
0355 
0356 static struct gpiod_lookup_table cm_x300_spi_gpiod_table = {
0357     .dev_id         = "spi_gpio",
0358     .table          = {
0359         GPIO_LOOKUP("pca9555.1", GPIO_LCD_SCL - GPIO_LCD_BASE,
0360                 "sck", GPIO_ACTIVE_HIGH),
0361         GPIO_LOOKUP("pca9555.1", GPIO_LCD_DIN - GPIO_LCD_BASE,
0362                 "mosi", GPIO_ACTIVE_HIGH),
0363         GPIO_LOOKUP("pca9555.1", GPIO_LCD_DOUT - GPIO_LCD_BASE,
0364                 "miso", GPIO_ACTIVE_HIGH),
0365         GPIO_LOOKUP("pca9555.1", GPIO_LCD_CS - GPIO_LCD_BASE,
0366                 "cs", GPIO_ACTIVE_HIGH),
0367         { },
0368     },
0369 };
0370 
0371 static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
0372     .model = TDO35S,
0373 };
0374 
0375 static struct spi_board_info cm_x300_spi_devices[] __initdata = {
0376     {
0377         .modalias       = "tdo24m",
0378         .max_speed_hz       = 1000000,
0379         .bus_num        = LCD_SPI_BUS_NUM,
0380         .chip_select        = 0,
0381         .platform_data      = &cm_x300_tdo24m_pdata,
0382     },
0383 };
0384 
0385 static void __init cm_x300_init_spi(void)
0386 {
0387     spi_register_board_info(cm_x300_spi_devices,
0388                 ARRAY_SIZE(cm_x300_spi_devices));
0389     gpiod_add_lookup_table(&cm_x300_spi_gpiod_table);
0390     platform_device_register(&cm_x300_spi_gpio);
0391 }
0392 #else
0393 static inline void cm_x300_init_spi(void) {}
0394 #endif
0395 
0396 #if defined(CONFIG_SND_PXA2XX_LIB_AC97)
0397 static void __init cm_x300_init_ac97(void)
0398 {
0399     pxa_set_ac97_info(NULL);
0400 }
0401 #else
0402 static inline void cm_x300_init_ac97(void) {}
0403 #endif
0404 
0405 #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
0406 static struct mtd_partition cm_x300_nand_partitions[] = {
0407     [0] = {
0408         .name        = "OBM",
0409         .offset      = 0,
0410         .size        = SZ_256K,
0411         .mask_flags  = MTD_WRITEABLE, /* force read-only */
0412     },
0413     [1] = {
0414         .name        = "U-Boot",
0415         .offset      = MTDPART_OFS_APPEND,
0416         .size        = SZ_256K,
0417         .mask_flags  = MTD_WRITEABLE, /* force read-only */
0418     },
0419     [2] = {
0420         .name        = "Environment",
0421         .offset      = MTDPART_OFS_APPEND,
0422         .size        = SZ_256K,
0423     },
0424     [3] = {
0425         .name        = "reserved",
0426         .offset      = MTDPART_OFS_APPEND,
0427         .size        = SZ_256K + SZ_1M,
0428         .mask_flags  = MTD_WRITEABLE, /* force read-only */
0429     },
0430     [4] = {
0431         .name        = "kernel",
0432         .offset      = MTDPART_OFS_APPEND,
0433         .size        = SZ_4M,
0434     },
0435     [5] = {
0436         .name        = "fs",
0437         .offset      = MTDPART_OFS_APPEND,
0438         .size        = MTDPART_SIZ_FULL,
0439     },
0440 };
0441 
0442 static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
0443     .keep_config    = 1,
0444     .parts      = cm_x300_nand_partitions,
0445     .nr_parts   = ARRAY_SIZE(cm_x300_nand_partitions),
0446 };
0447 
0448 static void __init cm_x300_init_nand(void)
0449 {
0450     pxa3xx_set_nand_info(&cm_x300_nand_info);
0451 }
0452 #else
0453 static inline void cm_x300_init_nand(void) {}
0454 #endif
0455 
0456 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
0457 static struct pxamci_platform_data cm_x300_mci_platform_data = {
0458     .detect_delay_ms    = 200,
0459     .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
0460 };
0461 
0462 static struct gpiod_lookup_table cm_x300_mci_gpio_table = {
0463     .dev_id = "pxa2xx-mci.0",
0464     .table = {
0465         /* Card detect on GPIO 82 */
0466         GPIO_LOOKUP("gpio-pxa", GPIO82_MMC_IRQ, "cd", GPIO_ACTIVE_LOW),
0467         /* Write protect on GPIO 85 */
0468         GPIO_LOOKUP("gpio-pxa", GPIO85_MMC_WP, "wp", GPIO_ACTIVE_LOW),
0469         { },
0470     },
0471 };
0472 
0473 /* The second MMC slot of CM-X300 is hardwired to Libertas card and has
0474    no detection/ro pins */
0475 static int cm_x300_mci2_init(struct device *dev,
0476                  irq_handler_t cm_x300_detect_int,
0477     void *data)
0478 {
0479     return 0;
0480 }
0481 
0482 static void cm_x300_mci2_exit(struct device *dev, void *data)
0483 {
0484 }
0485 
0486 static struct pxamci_platform_data cm_x300_mci2_platform_data = {
0487     .detect_delay_ms    = 200,
0488     .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
0489     .init           = cm_x300_mci2_init,
0490     .exit           = cm_x300_mci2_exit,
0491 };
0492 
0493 static void __init cm_x300_init_mmc(void)
0494 {
0495     gpiod_add_lookup_table(&cm_x300_mci_gpio_table);
0496     pxa_set_mci_info(&cm_x300_mci_platform_data);
0497     pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
0498 }
0499 #else
0500 static inline void cm_x300_init_mmc(void) {}
0501 #endif
0502 
0503 #if defined(CONFIG_PXA310_ULPI)
0504 static struct clk *pout_clk;
0505 
0506 static int cm_x300_ulpi_phy_reset(void)
0507 {
0508     int err;
0509 
0510     /* reset the PHY */
0511     err = gpio_request_one(GPIO_ULPI_PHY_RST, GPIOF_OUT_INIT_LOW,
0512                    "ulpi reset");
0513     if (err) {
0514         pr_err("failed to request ULPI reset GPIO: %d\n", err);
0515         return err;
0516     }
0517 
0518     msleep(10);
0519     gpio_set_value(GPIO_ULPI_PHY_RST, 1);
0520     msleep(10);
0521 
0522     gpio_free(GPIO_ULPI_PHY_RST);
0523 
0524     return 0;
0525 }
0526 
0527 static int cm_x300_u2d_init(struct device *dev)
0528 {
0529     int err = 0;
0530 
0531     if (cpu_is_pxa310()) {
0532         /* CLK_POUT is connected to the ULPI PHY */
0533         pout_clk = clk_get(NULL, "CLK_POUT");
0534         if (IS_ERR(pout_clk)) {
0535             err = PTR_ERR(pout_clk);
0536             pr_err("failed to get CLK_POUT: %d\n", err);
0537             return err;
0538         }
0539         clk_prepare_enable(pout_clk);
0540 
0541         err = cm_x300_ulpi_phy_reset();
0542         if (err) {
0543             clk_disable(pout_clk);
0544             clk_put(pout_clk);
0545         }
0546     }
0547 
0548     return err;
0549 }
0550 
0551 static void cm_x300_u2d_exit(struct device *dev)
0552 {
0553     if (cpu_is_pxa310()) {
0554         clk_disable_unprepare(pout_clk);
0555         clk_put(pout_clk);
0556     }
0557 }
0558 
0559 static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = {
0560     .ulpi_mode  = ULPI_SER_6PIN,
0561     .init       = cm_x300_u2d_init,
0562     .exit       = cm_x300_u2d_exit,
0563 };
0564 
0565 static void __init cm_x300_init_u2d(void)
0566 {
0567     pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data);
0568 }
0569 #else
0570 static inline void cm_x300_init_u2d(void) {}
0571 #endif
0572 
0573 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
0574 static int cm_x300_ohci_init(struct device *dev)
0575 {
0576     if (cpu_is_pxa300())
0577         UP2OCR = UP2OCR_HXS
0578             | UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE;
0579 
0580     return 0;
0581 }
0582 
0583 static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
0584     .port_mode  = PMM_PERPORT_MODE,
0585     .flags      = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
0586     .init       = cm_x300_ohci_init,
0587 };
0588 
0589 static void __init cm_x300_init_ohci(void)
0590 {
0591     pxa_set_ohci_info(&cm_x300_ohci_platform_data);
0592 }
0593 #else
0594 static inline void cm_x300_init_ohci(void) {}
0595 #endif
0596 
0597 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
0598 static struct gpio_led cm_x300_leds[] = {
0599     [0] = {
0600         .name = "cm-x300:green",
0601         .default_trigger = "heartbeat",
0602         .active_low = 1,
0603     },
0604 };
0605 
0606 static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
0607     .num_leds = ARRAY_SIZE(cm_x300_leds),
0608     .leds = cm_x300_leds,
0609 };
0610 
0611 static struct platform_device cm_x300_led_device = {
0612     .name       = "leds-gpio",
0613     .id     = -1,
0614     .dev        = {
0615         .platform_data = &cm_x300_gpio_led_pdata,
0616     },
0617 };
0618 
0619 static void __init cm_x300_init_leds(void)
0620 {
0621     if (system_rev < 130)
0622         cm_x300_leds[0].gpio = 79;
0623     else
0624         cm_x300_leds[0].gpio = 76;
0625 
0626     platform_device_register(&cm_x300_led_device);
0627 }
0628 #else
0629 static inline void cm_x300_init_leds(void) {}
0630 #endif
0631 
0632 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
0633 /* PCA9555 */
0634 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
0635     .gpio_base = 128,
0636 };
0637 
0638 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
0639     .gpio_base = 144,
0640 };
0641 
0642 static struct i2c_board_info cm_x300_gpio_ext_info[] = {
0643     [0] = {
0644         I2C_BOARD_INFO("pca9555", 0x24),
0645         .platform_data = &cm_x300_gpio_ext_pdata_0,
0646     },
0647     [1] = {
0648         I2C_BOARD_INFO("pca9555", 0x25),
0649         .platform_data = &cm_x300_gpio_ext_pdata_1,
0650     },
0651 };
0652 
0653 static void __init cm_x300_init_i2c(void)
0654 {
0655     pxa_set_i2c_info(NULL);
0656     i2c_register_board_info(0, cm_x300_gpio_ext_info,
0657                 ARRAY_SIZE(cm_x300_gpio_ext_info));
0658 }
0659 #else
0660 static inline void cm_x300_init_i2c(void) {}
0661 #endif
0662 
0663 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
0664 struct v3020_platform_data cm_x300_v3020_pdata = {
0665     .use_gpio   = 1,
0666     .gpio_cs    = GPIO95_RTC_CS,
0667     .gpio_wr    = GPIO96_RTC_WR,
0668     .gpio_rd    = GPIO97_RTC_RD,
0669     .gpio_io    = GPIO98_RTC_IO,
0670 };
0671 
0672 static struct platform_device cm_x300_rtc_device = {
0673     .name       = "v3020",
0674     .id     = -1,
0675     .dev        = {
0676         .platform_data = &cm_x300_v3020_pdata,
0677     }
0678 };
0679 
0680 static void __init cm_x300_init_rtc(void)
0681 {
0682     platform_device_register(&cm_x300_rtc_device);
0683 }
0684 #else
0685 static inline void cm_x300_init_rtc(void) {}
0686 #endif
0687 
0688 /* Battery */
0689 struct power_supply_info cm_x300_psy_info = {
0690     .name = "battery",
0691     .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
0692     .voltage_max_design = 4200000,
0693     .voltage_min_design = 3000000,
0694     .use_for_apm = 1,
0695 };
0696 
0697 static void cm_x300_battery_low(void)
0698 {
0699 #if defined(CONFIG_APM_EMULATION)
0700     apm_queue_event(APM_LOW_BATTERY);
0701 #endif
0702 }
0703 
0704 static void cm_x300_battery_critical(void)
0705 {
0706 #if defined(CONFIG_APM_EMULATION)
0707     apm_queue_event(APM_CRITICAL_SUSPEND);
0708 #endif
0709 }
0710 
0711 struct da9030_battery_info cm_x300_battery_info = {
0712     .battery_info = &cm_x300_psy_info,
0713 
0714     .charge_milliamp = 1000,
0715     .charge_millivolt = 4200,
0716 
0717     .vbat_low = 3600,
0718     .vbat_crit = 3400,
0719     .vbat_charge_start = 4100,
0720     .vbat_charge_stop = 4200,
0721     .vbat_charge_restart = 4000,
0722 
0723     .vcharge_min = 3200,
0724     .vcharge_max = 5500,
0725 
0726     .tbat_low = 197,
0727     .tbat_high = 78,
0728     .tbat_restart = 100,
0729 
0730     .batmon_interval = 0,
0731 
0732     .battery_low = cm_x300_battery_low,
0733     .battery_critical = cm_x300_battery_critical,
0734 };
0735 
0736 static struct regulator_consumer_supply buck2_consumers[] = {
0737     REGULATOR_SUPPLY("vcc_core", NULL),
0738 };
0739 
0740 static struct regulator_init_data buck2_data = {
0741     .constraints = {
0742         .min_uV = 1375000,
0743         .max_uV = 1375000,
0744         .state_mem = {
0745             .enabled = 0,
0746         },
0747         .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
0748         .apply_uV = 1,
0749     },
0750     .num_consumer_supplies = ARRAY_SIZE(buck2_consumers),
0751     .consumer_supplies = buck2_consumers,
0752 };
0753 
0754 /* DA9030 */
0755 struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
0756     {
0757         .name = "da903x-battery",
0758         .id = DA9030_ID_BAT,
0759         .platform_data = &cm_x300_battery_info,
0760     },
0761     {
0762         .name = "da903x-regulator",
0763         .id = DA9030_ID_BUCK2,
0764         .platform_data = &buck2_data,
0765     },
0766 };
0767 
0768 static struct da903x_platform_data cm_x300_da9030_info = {
0769     .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs),
0770     .subdevs = cm_x300_da9030_subdevs,
0771 };
0772 
0773 static struct i2c_board_info cm_x300_pmic_info = {
0774     I2C_BOARD_INFO("da9030", 0x49),
0775     .irq = IRQ_WAKEUP0,
0776     .platform_data = &cm_x300_da9030_info,
0777 };
0778 
0779 static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = {
0780     .use_pio = 1,
0781 };
0782 
0783 static void __init cm_x300_init_da9030(void)
0784 {
0785     pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info);
0786     i2c_register_board_info(1, &cm_x300_pmic_info, 1);
0787     irq_set_irq_wake(IRQ_WAKEUP0, 1);
0788 }
0789 
0790 /* wi2wi gpio setting for system_rev >= 130 */
0791 static struct gpio cm_x300_wi2wi_gpios[] __initdata = {
0792     { 71, GPIOF_OUT_INIT_HIGH, "wlan en" },
0793     { 70, GPIOF_OUT_INIT_HIGH, "bt reset" },
0794 };
0795 
0796 static void __init cm_x300_init_wi2wi(void)
0797 {
0798     int err;
0799 
0800     if (system_rev < 130) {
0801         cm_x300_wi2wi_gpios[0].gpio = 77;   /* wlan en */
0802         cm_x300_wi2wi_gpios[1].gpio = 78;   /* bt reset */
0803     }
0804 
0805     /* Libertas and CSR reset */
0806     err = gpio_request_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
0807     if (err) {
0808         pr_err("failed to request wifi/bt gpios: %d\n", err);
0809         return;
0810     }
0811 
0812     udelay(10);
0813     gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 0);
0814     udelay(10);
0815     gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 1);
0816 
0817     gpio_free_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
0818 }
0819 
0820 /* MFP */
0821 static void __init cm_x300_init_mfp(void)
0822 {
0823     /* board-processor specific GPIO initialization */
0824     pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
0825 
0826     if (system_rev < 130)
0827         pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
0828     else
0829         pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));
0830 
0831     if (cpu_is_pxa310())
0832         pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
0833 }
0834 
0835 static void __init cm_x300_init(void)
0836 {
0837     cm_x300_init_mfp();
0838 
0839     pxa_set_btuart_info(NULL);
0840     pxa_set_stuart_info(NULL);
0841     if (cpu_is_pxa300())
0842         pxa_set_ffuart_info(NULL);
0843 
0844     cm_x300_init_da9030();
0845     cm_x300_init_dm9000();
0846     cm_x300_init_lcd();
0847     cm_x300_init_u2d();
0848     cm_x300_init_ohci();
0849     cm_x300_init_mmc();
0850     cm_x300_init_nand();
0851     cm_x300_init_leds();
0852     cm_x300_init_i2c();
0853     cm_x300_init_spi();
0854     cm_x300_init_rtc();
0855     cm_x300_init_ac97();
0856     cm_x300_init_wi2wi();
0857     cm_x300_init_bl();
0858 
0859     regulator_has_full_constraints();
0860 }
0861 
0862 static void __init cm_x300_fixup(struct tag *tags, char **cmdline)
0863 {
0864     /* Make sure that mi->bank[0].start = PHYS_ADDR */
0865     for (; tags->hdr.size; tags = tag_next(tags))
0866         if (tags->hdr.tag == ATAG_MEM &&
0867             tags->u.mem.start == 0x80000000) {
0868             tags->u.mem.start = 0xa0000000;
0869             break;
0870         }
0871 }
0872 
0873 MACHINE_START(CM_X300, "CM-X300 module")
0874     .atag_offset    = 0x100,
0875     .map_io     = pxa3xx_map_io,
0876     .nr_irqs    = PXA_NR_IRQS,
0877     .init_irq   = pxa3xx_init_irq,
0878     .handle_irq = pxa3xx_handle_irq,
0879     .init_time  = pxa_timer_init,
0880     .init_machine   = cm_x300_init,
0881     .fixup      = cm_x300_fixup,
0882     .restart    = pxa_restart,
0883 MACHINE_END