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/sysdev.h>
14 #include <linux/irq.h>
15 #include <linux/gpio.h>
16 #include <linux/delay.h>
18 #include <linux/rtc-v3020.h>
19 #include <video/mbxfb.h>
21 #include <linux/spi/spi.h>
22 #include <linux/spi/libertas_spi.h>
24 #include <mach/pxa27x.h>
25 #include <mach/ohci.h>
27 #include <mach/pxa2xx_spi.h>
31 /* physical address if local-bus attached devices */
32 #define RTC_PHYS_BASE (PXA_CS1_PHYS + (5 << 22))
35 #define GPIO83_MMC_IRQ (83)
37 #define CMX270_MMC_IRQ IRQ_GPIO(GPIO83_MMC_IRQ)
39 /* MMC power enable */
40 #define GPIO105_MMC_POWER (105)
43 #define GPIO19_WLAN_STRAP (19)
44 #define GPIO102_WLAN_RST (102)
46 static unsigned long cmx270_pin_config[] = {
49 GPIO29_AC97_SDATA_IN_0,
50 GPIO30_AC97_SDATA_OUT,
106 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
122 /* SDRAM and local bus */
132 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH,
133 GPIO105_GPIO | MFP_LPM_DRIVE_HIGH, /* MMC/SD power */
134 GPIO53_GPIO, /* PC card reset */
135 GPIO102_GPIO, /* WLAN reset */
138 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
139 GPIO89_GPIO, /* NAND Ready/Busy */
142 GPIO10_GPIO, /* DM9000 interrupt */
143 GPIO83_GPIO, /* MMC card detect */
144 GPIO95_GPIO, /* WLAN interrupt */
148 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
149 static struct resource cmx270_v3020_resource[] = {
151 .start = RTC_PHYS_BASE,
152 .end = RTC_PHYS_BASE + 4,
153 .flags = IORESOURCE_MEM,
157 struct v3020_platform_data cmx270_v3020_pdata = {
161 static struct platform_device cmx270_rtc_device = {
163 .num_resources = ARRAY_SIZE(cmx270_v3020_resource),
164 .resource = cmx270_v3020_resource,
167 .platform_data = &cmx270_v3020_pdata,
171 static void __init cmx270_init_rtc(void)
173 platform_device_register(&cmx270_rtc_device);
176 static inline void cmx270_init_rtc(void) {}
180 #if defined(CONFIG_FB_MBX) || defined(CONFIG_FB_MBX_MODULE)
181 static u64 fb_dma_mask = ~(u64)0;
183 static struct resource cmx270_2700G_resource[] = {
184 /* frame buffer memory including ODFB and External SDRAM */
186 .start = PXA_CS2_PHYS,
187 .end = PXA_CS2_PHYS + 0x01ffffff,
188 .flags = IORESOURCE_MEM,
190 /* Marathon registers */
192 .start = PXA_CS2_PHYS + 0x03fe0000,
193 .end = PXA_CS2_PHYS + 0x03ffffff,
194 .flags = IORESOURCE_MEM,
198 static unsigned long save_lcd_regs[10];
200 static int cmx270_marathon_probe(struct fb_info *fb)
202 /* save PXA-270 pin settings before enabling 2700G */
203 save_lcd_regs[0] = GPDR1;
204 save_lcd_regs[1] = GPDR2;
205 save_lcd_regs[2] = GAFR1_U;
206 save_lcd_regs[3] = GAFR2_L;
207 save_lcd_regs[4] = GAFR2_U;
209 /* Disable PXA-270 on-chip controller driving pins */
210 GPDR1 &= ~(0xfc000000);
211 GPDR2 &= ~(0x00c03fff);
212 GAFR1_U &= ~(0xfff00000);
213 GAFR2_L &= ~(0x0fffffff);
214 GAFR2_U &= ~(0x0000f000);
218 static int cmx270_marathon_remove(struct fb_info *fb)
220 GPDR1 = save_lcd_regs[0];
221 GPDR2 = save_lcd_regs[1];
222 GAFR1_U = save_lcd_regs[2];
223 GAFR2_L = save_lcd_regs[3];
224 GAFR2_U = save_lcd_regs[4];
228 static struct mbxfb_platform_data cmx270_2700G_data = {
244 .memsize = 8*1024*1024,
245 .probe = cmx270_marathon_probe,
246 .remove = cmx270_marathon_remove,
249 static struct platform_device cmx270_2700G = {
252 .platform_data = &cmx270_2700G_data,
253 .dma_mask = &fb_dma_mask,
254 .coherent_dma_mask = 0xffffffff,
256 .num_resources = ARRAY_SIZE(cmx270_2700G_resource),
257 .resource = cmx270_2700G_resource,
261 static void __init cmx270_init_2700G(void)
263 platform_device_register(&cmx270_2700G);
266 static inline void cmx270_init_2700G(void) {}
269 /* PXA27x OHCI controller setup */
270 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
271 static struct pxaohci_platform_data cmx270_ohci_platform_data = {
272 .port_mode = PMM_PERPORT_MODE,
273 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
276 static void __init cmx270_init_ohci(void)
278 pxa_set_ohci_info(&cmx270_ohci_platform_data);
281 static inline void cmx270_init_ohci(void) {}
284 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
285 static struct pxamci_platform_data cmx270_mci_platform_data = {
286 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
287 .gpio_card_detect = GPIO83_MMC_IRQ,
289 .gpio_power = GPIO105_MMC_POWER,
290 .gpio_power_invert = 1,
293 static void __init cmx270_init_mmc(void)
295 pxa_set_mci_info(&cmx270_mci_platform_data);
298 static inline void cmx270_init_mmc(void) {}
301 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
302 static struct pxa2xx_spi_master cm_x270_spi_info = {
307 static struct pxa2xx_spi_chip cm_x270_libertas_chip = {
314 static unsigned long cm_x270_libertas_pin_config[] = {
323 static int cm_x270_libertas_setup(struct spi_device *spi)
325 int err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
329 err = gpio_request(GPIO102_WLAN_RST, "WLAN RST");
333 err = gpio_direction_output(GPIO102_WLAN_RST, 0);
338 err = gpio_direction_output(GPIO19_WLAN_STRAP, 1);
343 pxa2xx_mfp_config(ARRAY_AND_SIZE(cm_x270_libertas_pin_config));
345 gpio_set_value(GPIO102_WLAN_RST, 1);
348 spi->bits_per_word = 16;
354 gpio_free(GPIO19_WLAN_STRAP);
359 static int cm_x270_libertas_teardown(struct spi_device *spi)
361 gpio_set_value(GPIO102_WLAN_RST, 0);
362 gpio_free(GPIO102_WLAN_RST);
363 gpio_free(GPIO19_WLAN_STRAP);
368 struct libertas_spi_platform_data cm_x270_libertas_pdata = {
369 .use_dummy_writes = 1,
370 .setup = cm_x270_libertas_setup,
371 .teardown = cm_x270_libertas_teardown,
374 static struct spi_board_info cm_x270_spi_devices[] __initdata = {
376 .modalias = "libertas_spi",
377 .max_speed_hz = 13000000,
379 .irq = gpio_to_irq(95),
381 .controller_data = &cm_x270_libertas_chip,
382 .platform_data = &cm_x270_libertas_pdata,
386 static void __init cmx270_init_spi(void)
388 pxa2xx_set_spi_info(2, &cm_x270_spi_info);
389 spi_register_board_info(ARRAY_AND_SIZE(cm_x270_spi_devices));
392 static inline void cmx270_init_spi(void) {}
395 void __init cmx270_init(void)
397 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config));
400 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);