2 * linux/arch/arm/mach-pxa/cm-x270.c
4 * Copyright (C) 2007, 2008 CompuLab, Ltd.
5 * Mike Rapoport <mike@compulab.co.il>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/platform_device.h>
13 #include <linux/irq.h>
14 #include <linux/gpio.h>
15 #include <linux/delay.h>
17 #include <linux/rtc-v3020.h>
18 #include <video/mbxfb.h>
20 #include <linux/spi/spi.h>
21 #include <linux/spi/pxa2xx_spi.h>
22 #include <linux/spi/libertas_spi.h>
24 #include <mach/pxa27x.h>
25 #include <mach/ohci.h>
30 /* physical address if local-bus attached devices */
31 #define RTC_PHYS_BASE (PXA_CS1_PHYS + (5 << 22))
34 #define GPIO83_MMC_IRQ (83)
36 #define CMX270_MMC_IRQ PXA_GPIO_TO_IRQ(GPIO83_MMC_IRQ)
38 /* MMC power enable */
39 #define GPIO105_MMC_POWER (105)
42 #define GPIO19_WLAN_STRAP (19)
43 #define GPIO102_WLAN_RST (102)
45 static unsigned long cmx270_pin_config[] = {
48 GPIO29_AC97_SDATA_IN_0,
49 GPIO30_AC97_SDATA_OUT,
86 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
102 /* SDRAM and local bus */
112 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH,
113 GPIO105_GPIO | MFP_LPM_DRIVE_HIGH, /* MMC/SD power */
114 GPIO53_GPIO, /* PC card reset */
115 GPIO102_GPIO, /* WLAN reset */
118 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
119 GPIO89_GPIO, /* NAND Ready/Busy */
122 GPIO10_GPIO, /* DM9000 interrupt */
123 GPIO83_GPIO, /* MMC card detect */
124 GPIO95_GPIO, /* WLAN interrupt */
128 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
129 static struct resource cmx270_v3020_resource[] = {
131 .start = RTC_PHYS_BASE,
132 .end = RTC_PHYS_BASE + 4,
133 .flags = IORESOURCE_MEM,
137 struct v3020_platform_data cmx270_v3020_pdata = {
141 static struct platform_device cmx270_rtc_device = {
143 .num_resources = ARRAY_SIZE(cmx270_v3020_resource),
144 .resource = cmx270_v3020_resource,
147 .platform_data = &cmx270_v3020_pdata,
151 static void __init cmx270_init_rtc(void)
153 platform_device_register(&cmx270_rtc_device);
156 static inline void cmx270_init_rtc(void) {}
160 #if defined(CONFIG_FB_MBX) || defined(CONFIG_FB_MBX_MODULE)
161 static u64 fb_dma_mask = ~(u64)0;
163 static struct resource cmx270_2700G_resource[] = {
164 /* frame buffer memory including ODFB and External SDRAM */
166 .start = PXA_CS2_PHYS,
167 .end = PXA_CS2_PHYS + 0x01ffffff,
168 .flags = IORESOURCE_MEM,
170 /* Marathon registers */
172 .start = PXA_CS2_PHYS + 0x03fe0000,
173 .end = PXA_CS2_PHYS + 0x03ffffff,
174 .flags = IORESOURCE_MEM,
178 static unsigned long cmx270_marathon_on[] = {
201 static unsigned long cmx270_marathon_off[] = {
202 GPIOxx_LCD_TFT_16BPP,
205 static int cmx270_marathon_probe(struct fb_info *fb)
209 for (gpio = 58; gpio <= 77; gpio++) {
210 err = gpio_request(gpio, "LCD");
213 gpio_direction_input(gpio);
216 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_on));
220 static int cmx270_marathon_remove(struct fb_info *fb)
224 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_off));
226 for (gpio = 58; gpio <= 77; gpio++)
232 static struct mbxfb_platform_data cmx270_2700G_data = {
248 .memsize = 8*1024*1024,
249 .probe = cmx270_marathon_probe,
250 .remove = cmx270_marathon_remove,
253 static struct platform_device cmx270_2700G = {
256 .platform_data = &cmx270_2700G_data,
257 .dma_mask = &fb_dma_mask,
258 .coherent_dma_mask = 0xffffffff,
260 .num_resources = ARRAY_SIZE(cmx270_2700G_resource),
261 .resource = cmx270_2700G_resource,
265 static void __init cmx270_init_2700G(void)
267 platform_device_register(&cmx270_2700G);
270 static inline void cmx270_init_2700G(void) {}
273 /* PXA27x OHCI controller setup */
274 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
275 static struct pxaohci_platform_data cmx270_ohci_platform_data = {
276 .port_mode = PMM_PERPORT_MODE,
277 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
280 static void __init cmx270_init_ohci(void)
282 pxa_set_ohci_info(&cmx270_ohci_platform_data);
285 static inline void cmx270_init_ohci(void) {}
288 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
289 static struct pxamci_platform_data cmx270_mci_platform_data = {
290 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
291 .gpio_card_detect = GPIO83_MMC_IRQ,
293 .gpio_power = GPIO105_MMC_POWER,
294 .gpio_power_invert = 1,
297 static void __init cmx270_init_mmc(void)
299 pxa_set_mci_info(&cmx270_mci_platform_data);
302 static inline void cmx270_init_mmc(void) {}
305 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
306 static struct pxa2xx_spi_master cm_x270_spi_info = {
311 static struct pxa2xx_spi_chip cm_x270_libertas_chip = {
318 static unsigned long cm_x270_libertas_pin_config[] = {
327 static int cm_x270_libertas_setup(struct spi_device *spi)
329 int err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
333 err = gpio_request(GPIO102_WLAN_RST, "WLAN RST");
337 err = gpio_direction_output(GPIO102_WLAN_RST, 0);
342 err = gpio_direction_output(GPIO19_WLAN_STRAP, 1);
347 pxa2xx_mfp_config(ARRAY_AND_SIZE(cm_x270_libertas_pin_config));
349 gpio_set_value(GPIO102_WLAN_RST, 1);
352 spi->bits_per_word = 16;
358 gpio_free(GPIO19_WLAN_STRAP);
363 static int cm_x270_libertas_teardown(struct spi_device *spi)
365 gpio_set_value(GPIO102_WLAN_RST, 0);
366 gpio_free(GPIO102_WLAN_RST);
367 gpio_free(GPIO19_WLAN_STRAP);
372 struct libertas_spi_platform_data cm_x270_libertas_pdata = {
373 .use_dummy_writes = 1,
374 .setup = cm_x270_libertas_setup,
375 .teardown = cm_x270_libertas_teardown,
378 static struct spi_board_info cm_x270_spi_devices[] __initdata = {
380 .modalias = "libertas_spi",
381 .max_speed_hz = 13000000,
383 .irq = PXA_GPIO_TO_IRQ(95),
385 .controller_data = &cm_x270_libertas_chip,
386 .platform_data = &cm_x270_libertas_pdata,
390 static void __init cmx270_init_spi(void)
392 pxa2xx_set_spi_info(2, &cm_x270_spi_info);
393 spi_register_board_info(ARRAY_AND_SIZE(cm_x270_spi_devices));
396 static inline void cmx270_init_spi(void) {}
399 void __init cmx270_init(void)
401 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config));
404 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);