Add linux-next specific files for 20110831
[linux-2.6/next.git] / arch / arm / mach-pxa / cm-x270.c
blob13518a7053994dbfe6c4ce422ee994a88d3e21f4
1 /*
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>
26 #include <mach/mmc.h>
28 #include "generic.h"
30 /* physical address if local-bus attached devices */
31 #define RTC_PHYS_BASE (PXA_CS1_PHYS + (5 << 22))
33 /* GPIO IRQ usage */
34 #define GPIO83_MMC_IRQ (83)
36 #define CMX270_MMC_IRQ IRQ_GPIO(GPIO83_MMC_IRQ)
38 /* MMC power enable */
39 #define GPIO105_MMC_POWER (105)
41 /* WLAN GPIOS */
42 #define GPIO19_WLAN_STRAP (19)
43 #define GPIO102_WLAN_RST (102)
45 static unsigned long cmx270_pin_config[] = {
46 /* AC'97 */
47 GPIO28_AC97_BITCLK,
48 GPIO29_AC97_SDATA_IN_0,
49 GPIO30_AC97_SDATA_OUT,
50 GPIO31_AC97_SYNC,
51 GPIO98_AC97_SYSCLK,
52 GPIO113_AC97_nRESET,
54 /* BTUART */
55 GPIO42_BTUART_RXD,
56 GPIO43_BTUART_TXD,
57 GPIO44_BTUART_CTS,
58 GPIO45_BTUART_RTS,
60 /* STUART */
61 GPIO46_STUART_RXD,
62 GPIO47_STUART_TXD,
64 /* MCI controller */
65 GPIO32_MMC_CLK,
66 GPIO112_MMC_CMD,
67 GPIO92_MMC_DAT_0,
68 GPIO109_MMC_DAT_1,
69 GPIO110_MMC_DAT_2,
70 GPIO111_MMC_DAT_3,
72 /* LCD */
73 GPIOxx_LCD_TFT_16BPP,
75 /* I2C */
76 GPIO117_I2C_SCL,
77 GPIO118_I2C_SDA,
79 /* SSP1 */
80 GPIO23_SSP1_SCLK,
81 GPIO24_SSP1_SFRM,
82 GPIO25_SSP1_TXD,
83 GPIO26_SSP1_RXD,
85 /* SSP2 */
86 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
87 GPIO14_GPIO,
88 GPIO87_SSP2_TXD,
89 GPIO88_SSP2_RXD,
91 /* PC Card */
92 GPIO48_nPOE,
93 GPIO49_nPWE,
94 GPIO50_nPIOR,
95 GPIO51_nPIOW,
96 GPIO85_nPCE_1,
97 GPIO54_nPCE_2,
98 GPIO55_nPREG,
99 GPIO56_nPWAIT,
100 GPIO57_nIOIS16,
102 /* SDRAM and local bus */
103 GPIO15_nCS_1,
104 GPIO78_nCS_2,
105 GPIO79_nCS_3,
106 GPIO80_nCS_4,
107 GPIO33_nCS_5,
108 GPIO49_nPWE,
109 GPIO18_RDY,
111 /* GPIO */
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 */
117 /* NAND controls */
118 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
119 GPIO89_GPIO, /* NAND Ready/Busy */
121 /* interrupts */
122 GPIO10_GPIO, /* DM9000 interrupt */
123 GPIO83_GPIO, /* MMC card detect */
124 GPIO95_GPIO, /* WLAN interrupt */
127 /* V3020 RTC */
128 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
129 static struct resource cmx270_v3020_resource[] = {
130 [0] = {
131 .start = RTC_PHYS_BASE,
132 .end = RTC_PHYS_BASE + 4,
133 .flags = IORESOURCE_MEM,
137 struct v3020_platform_data cmx270_v3020_pdata = {
138 .leftshift = 16,
141 static struct platform_device cmx270_rtc_device = {
142 .name = "v3020",
143 .num_resources = ARRAY_SIZE(cmx270_v3020_resource),
144 .resource = cmx270_v3020_resource,
145 .id = -1,
146 .dev = {
147 .platform_data = &cmx270_v3020_pdata,
151 static void __init cmx270_init_rtc(void)
153 platform_device_register(&cmx270_rtc_device);
155 #else
156 static inline void cmx270_init_rtc(void) {}
157 #endif
159 /* 2700G graphics */
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 */
165 [0] = {
166 .start = PXA_CS2_PHYS,
167 .end = PXA_CS2_PHYS + 0x01ffffff,
168 .flags = IORESOURCE_MEM,
170 /* Marathon registers */
171 [1] = {
172 .start = PXA_CS2_PHYS + 0x03fe0000,
173 .end = PXA_CS2_PHYS + 0x03ffffff,
174 .flags = IORESOURCE_MEM,
178 static unsigned long cmx270_marathon_on[] = {
179 GPIO58_GPIO,
180 GPIO59_GPIO,
181 GPIO60_GPIO,
182 GPIO61_GPIO,
183 GPIO62_GPIO,
184 GPIO63_GPIO,
185 GPIO64_GPIO,
186 GPIO65_GPIO,
187 GPIO66_GPIO,
188 GPIO67_GPIO,
189 GPIO68_GPIO,
190 GPIO69_GPIO,
191 GPIO70_GPIO,
192 GPIO71_GPIO,
193 GPIO72_GPIO,
194 GPIO73_GPIO,
195 GPIO74_GPIO,
196 GPIO75_GPIO,
197 GPIO76_GPIO,
198 GPIO77_GPIO,
201 static unsigned long cmx270_marathon_off[] = {
202 GPIOxx_LCD_TFT_16BPP,
205 static int cmx270_marathon_probe(struct fb_info *fb)
207 int gpio, err;
209 for (gpio = 58; gpio <= 77; gpio++) {
210 err = gpio_request(gpio, "LCD");
211 if (err)
212 return err;
213 gpio_direction_input(gpio);
216 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_on));
217 return 0;
220 static int cmx270_marathon_remove(struct fb_info *fb)
222 int gpio;
224 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_off));
226 for (gpio = 58; gpio <= 77; gpio++)
227 gpio_free(gpio);
229 return 0;
232 static struct mbxfb_platform_data cmx270_2700G_data = {
233 .xres = {
234 .min = 240,
235 .max = 1200,
236 .defval = 640,
238 .yres = {
239 .min = 240,
240 .max = 1200,
241 .defval = 480,
243 .bpp = {
244 .min = 16,
245 .max = 32,
246 .defval = 16,
248 .memsize = 8*1024*1024,
249 .probe = cmx270_marathon_probe,
250 .remove = cmx270_marathon_remove,
253 static struct platform_device cmx270_2700G = {
254 .name = "mbx-fb",
255 .dev = {
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,
262 .id = -1,
265 static void __init cmx270_init_2700G(void)
267 platform_device_register(&cmx270_2700G);
269 #else
270 static inline void cmx270_init_2700G(void) {}
271 #endif
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);
284 #else
285 static inline void cmx270_init_ohci(void) {}
286 #endif
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,
292 .gpio_card_ro = -1,
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);
301 #else
302 static inline void cmx270_init_mmc(void) {}
303 #endif
305 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
306 static struct pxa2xx_spi_master cm_x270_spi_info = {
307 .num_chipselect = 1,
308 .enable_dma = 1,
311 static struct pxa2xx_spi_chip cm_x270_libertas_chip = {
312 .rx_threshold = 1,
313 .tx_threshold = 1,
314 .timeout = 1000,
315 .gpio_cs = 14,
318 static unsigned long cm_x270_libertas_pin_config[] = {
319 /* SSP2 */
320 GPIO19_SSP2_SCLK,
321 GPIO14_GPIO,
322 GPIO87_SSP2_TXD,
323 GPIO88_SSP2_RXD,
327 static int cm_x270_libertas_setup(struct spi_device *spi)
329 int err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
330 if (err)
331 return err;
333 err = gpio_request(GPIO102_WLAN_RST, "WLAN RST");
334 if (err)
335 goto err_free_strap;
337 err = gpio_direction_output(GPIO102_WLAN_RST, 0);
338 if (err)
339 goto err_free_strap;
340 msleep(100);
342 err = gpio_direction_output(GPIO19_WLAN_STRAP, 1);
343 if (err)
344 goto err_free_strap;
345 msleep(100);
347 pxa2xx_mfp_config(ARRAY_AND_SIZE(cm_x270_libertas_pin_config));
349 gpio_set_value(GPIO102_WLAN_RST, 1);
350 msleep(100);
352 spi->bits_per_word = 16;
353 spi_setup(spi);
355 return 0;
357 err_free_strap:
358 gpio_free(GPIO19_WLAN_STRAP);
360 return err;
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);
369 return 0;
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,
382 .bus_num = 2,
383 .irq = gpio_to_irq(95),
384 .chip_select = 0,
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));
395 #else
396 static inline void cmx270_init_spi(void) {}
397 #endif
399 void __init cmx270_init(void)
401 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config));
403 #ifdef CONFIG_PM
404 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
405 #endif
407 cmx270_init_rtc();
408 cmx270_init_mmc();
409 cmx270_init_ohci();
410 cmx270_init_2700G();
411 cmx270_init_spi();