aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/em-x270.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/em-x270.c')
-rw-r--r--arch/arm/mach-pxa/em-x270.c381
1 files changed, 295 insertions, 86 deletions
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index 9c57700ee5c2..e5cc6ca63c75 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Support for CompuLab EM-x270 platform 2 * Support for CompuLab EM-X270 platform
3 * 3 *
4 * Copyright (C) 2007 CompuLab, Ltd. 4 * Copyright (C) 2007, 2008 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il> 5 * Author: Mike Rapoport <mike@compulab.co.il>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -14,29 +14,159 @@
14 14
15#include <linux/dm9000.h> 15#include <linux/dm9000.h>
16#include <linux/rtc-v3020.h> 16#include <linux/rtc-v3020.h>
17
18#include <linux/mtd/nand.h> 17#include <linux/mtd/nand.h>
19#include <linux/mtd/partitions.h> 18#include <linux/mtd/partitions.h>
19#include <linux/input.h>
20#include <linux/gpio_keys.h>
21#include <linux/gpio.h>
20 22
21#include <asm/mach-types.h> 23#include <asm/mach-types.h>
22
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
24 25
26#include <asm/arch/mfp-pxa27x.h>
25#include <asm/arch/pxa-regs.h> 27#include <asm/arch/pxa-regs.h>
26#include <asm/arch/pxa2xx-gpio.h> 28#include <asm/arch/pxa27x-udc.h>
29#include <asm/arch/audio.h>
27#include <asm/arch/pxafb.h> 30#include <asm/arch/pxafb.h>
28#include <asm/arch/ohci.h> 31#include <asm/arch/ohci.h>
29#include <asm/arch/mmc.h> 32#include <asm/arch/mmc.h>
30#include <asm/arch/bitfield.h> 33#include <asm/arch/pxa27x_keypad.h>
31 34
32#include "generic.h" 35#include "generic.h"
33 36
34/* GPIO IRQ usage */ 37/* GPIO IRQ usage */
35#define EM_X270_MMC_PD (105) 38#define GPIO41_ETHIRQ (41)
36#define EM_X270_ETHIRQ IRQ_GPIO(41) 39#define GPIO13_MMC_CD (13)
37#define EM_X270_MMC_IRQ IRQ_GPIO(13) 40#define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
41#define EM_X270_MMC_CD IRQ_GPIO(GPIO13_MMC_CD)
42
43/* NAND control GPIOs */
44#define GPIO11_NAND_CS (11)
45#define GPIO56_NAND_RB (56)
46
47static unsigned long em_x270_pin_config[] = {
48 /* AC'97 */
49 GPIO28_AC97_BITCLK,
50 GPIO29_AC97_SDATA_IN_0,
51 GPIO30_AC97_SDATA_OUT,
52 GPIO31_AC97_SYNC,
53 GPIO98_AC97_SYSCLK,
54 GPIO113_AC97_nRESET,
55
56 /* BTUART */
57 GPIO42_BTUART_RXD,
58 GPIO43_BTUART_TXD,
59 GPIO44_BTUART_CTS,
60 GPIO45_BTUART_RTS,
61
62 /* STUART */
63 GPIO46_STUART_RXD,
64 GPIO47_STUART_TXD,
65
66 /* MCI controller */
67 GPIO32_MMC_CLK,
68 GPIO112_MMC_CMD,
69 GPIO92_MMC_DAT_0,
70 GPIO109_MMC_DAT_1,
71 GPIO110_MMC_DAT_2,
72 GPIO111_MMC_DAT_3,
73
74 /* LCD */
75 GPIO58_LCD_LDD_0,
76 GPIO59_LCD_LDD_1,
77 GPIO60_LCD_LDD_2,
78 GPIO61_LCD_LDD_3,
79 GPIO62_LCD_LDD_4,
80 GPIO63_LCD_LDD_5,
81 GPIO64_LCD_LDD_6,
82 GPIO65_LCD_LDD_7,
83 GPIO66_LCD_LDD_8,
84 GPIO67_LCD_LDD_9,
85 GPIO68_LCD_LDD_10,
86 GPIO69_LCD_LDD_11,
87 GPIO70_LCD_LDD_12,
88 GPIO71_LCD_LDD_13,
89 GPIO72_LCD_LDD_14,
90 GPIO73_LCD_LDD_15,
91 GPIO74_LCD_FCLK,
92 GPIO75_LCD_LCLK,
93 GPIO76_LCD_PCLK,
94 GPIO77_LCD_BIAS,
95
96 /* QCI */
97 GPIO84_CIF_FV,
98 GPIO25_CIF_LV,
99 GPIO53_CIF_MCLK,
100 GPIO54_CIF_PCLK,
101 GPIO81_CIF_DD_0,
102 GPIO55_CIF_DD_1,
103 GPIO51_CIF_DD_2,
104 GPIO50_CIF_DD_3,
105 GPIO52_CIF_DD_4,
106 GPIO48_CIF_DD_5,
107 GPIO17_CIF_DD_6,
108 GPIO12_CIF_DD_7,
109
110 /* I2C */
111 GPIO117_I2C_SCL,
112 GPIO118_I2C_SDA,
113
114 /* Keypad */
115 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
116 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
117 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
118 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
119 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
120 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
121 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
122 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
123 GPIO103_KP_MKOUT_0,
124 GPIO104_KP_MKOUT_1,
125 GPIO105_KP_MKOUT_2,
126 GPIO106_KP_MKOUT_3,
127 GPIO107_KP_MKOUT_4,
128 GPIO108_KP_MKOUT_5,
129 GPIO96_KP_MKOUT_6,
130 GPIO22_KP_MKOUT_7,
131
132 /* SSP1 */
133 GPIO26_SSP1_RXD,
134 GPIO23_SSP1_SCLK,
135 GPIO24_SSP1_SFRM,
136 GPIO57_SSP1_TXD,
137
138 /* SSP2 */
139 GPIO19_SSP2_SCLK,
140 GPIO14_SSP2_SFRM,
141 GPIO89_SSP2_TXD,
142 GPIO88_SSP2_RXD,
143
144 /* SDRAM and local bus */
145 GPIO15_nCS_1,
146 GPIO78_nCS_2,
147 GPIO79_nCS_3,
148 GPIO80_nCS_4,
149 GPIO49_nPWE,
150 GPIO18_RDY,
151
152 /* GPIO */
153 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
154
155 /* power controls */
156 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
157 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
158
159 /* NAND controls */
160 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
161 GPIO56_GPIO, /* NAND Ready/Busy */
162
163 /* interrupts */
164 GPIO13_GPIO, /* MMC card detect */
165 GPIO41_GPIO, /* DM9000 interrupt */
166};
38 167
39static struct resource em_x270_dm9k_resource[] = { 168#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
169static struct resource em_x270_dm9000_resource[] = {
40 [0] = { 170 [0] = {
41 .start = PXA_CS2_PHYS, 171 .start = PXA_CS2_PHYS,
42 .end = PXA_CS2_PHYS + 3, 172 .end = PXA_CS2_PHYS + 3,
@@ -54,38 +184,30 @@ static struct resource em_x270_dm9k_resource[] = {
54 } 184 }
55}; 185};
56 186
57/* for the moment we limit ourselves to 32bit IO until some 187static struct dm9000_plat_data em_x270_dm9000_platdata = {
58 * better IO routines can be written and tested
59 */
60static struct dm9000_plat_data em_x270_dm9k_platdata = {
61 .flags = DM9000_PLATF_32BITONLY, 188 .flags = DM9000_PLATF_32BITONLY,
62}; 189};
63 190
64/* Ethernet device */ 191static struct platform_device em_x270_dm9000 = {
65static struct platform_device em_x270_dm9k = {
66 .name = "dm9000", 192 .name = "dm9000",
67 .id = 0, 193 .id = 0,
68 .num_resources = ARRAY_SIZE(em_x270_dm9k_resource), 194 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
69 .resource = em_x270_dm9k_resource, 195 .resource = em_x270_dm9000_resource,
70 .dev = { 196 .dev = {
71 .platform_data = &em_x270_dm9k_platdata, 197 .platform_data = &em_x270_dm9000_platdata,
72 } 198 }
73}; 199};
74 200
75/* audio device */ 201static void __init em_x270_init_dm9000(void)
76static struct platform_device em_x270_audio = { 202{
77 .name = "pxa2xx-ac97", 203 platform_device_register(&em_x270_dm9000);
78 .id = -1, 204}
79}; 205#else
80 206static inline void em_x270_init_dm9000(void) {}
81/* WM9712 touchscreen controller. Hopefully the driver will make it to 207#endif
82 * the mainstream sometime */
83static struct platform_device em_x270_ts = {
84 .name = "wm97xx-ts",
85 .id = -1,
86};
87 208
88/* RTC */ 209/* V3020 RTC */
210#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
89static struct resource em_x270_v3020_resource[] = { 211static struct resource em_x270_v3020_resource[] = {
90 [0] = { 212 [0] = {
91 .start = PXA_CS4_PHYS, 213 .start = PXA_CS4_PHYS,
@@ -108,20 +230,26 @@ static struct platform_device em_x270_rtc = {
108 } 230 }
109}; 231};
110 232
111/* NAND flash */ 233static void __init em_x270_init_rtc(void)
112#define GPIO_NAND_CS (11) 234{
113#define GPIO_NAND_RB (56) 235 platform_device_register(&em_x270_rtc);
236}
237#else
238static inline void em_x270_init_rtc(void) {}
239#endif
114 240
241/* NAND flash */
242#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
115static inline void nand_cs_on(void) 243static inline void nand_cs_on(void)
116{ 244{
117 GPCR(GPIO_NAND_CS) = GPIO_bit(GPIO_NAND_CS); 245 gpio_set_value(GPIO11_NAND_CS, 0);
118} 246}
119 247
120static void nand_cs_off(void) 248static void nand_cs_off(void)
121{ 249{
122 dsb(); 250 dsb();
123 251
124 GPSR(GPIO_NAND_CS) = GPIO_bit(GPIO_NAND_CS); 252 gpio_set_value(GPIO11_NAND_CS, 1);
125} 253}
126 254
127/* hardware specific access to control-lines */ 255/* hardware specific access to control-lines */
@@ -161,7 +289,7 @@ static int em_x270_nand_device_ready(struct mtd_info *mtd)
161{ 289{
162 dsb(); 290 dsb();
163 291
164 return GPLR(GPIO_NAND_RB) & GPIO_bit(GPIO_NAND_RB); 292 return gpio_get_value(GPIO56_NAND_RB);
165} 293}
166 294
167static struct mtd_partition em_x270_partition_info[] = { 295static struct mtd_partition em_x270_partition_info[] = {
@@ -214,17 +342,35 @@ static struct platform_device em_x270_nand = {
214 } 342 }
215}; 343};
216 344
217/* platform devices */ 345static void __init em_x270_init_nand(void)
218static struct platform_device *platform_devices[] __initdata = { 346{
219 &em_x270_dm9k, 347 int err;
220 &em_x270_audio, 348
221 &em_x270_ts, 349 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
222 &em_x270_rtc, 350 if (err) {
223 &em_x270_nand, 351 pr_warning("EM-X270: failed to request NAND CS gpio\n");
224}; 352 return;
353 }
354
355 gpio_direction_output(GPIO11_NAND_CS, 1);
356
357 err = gpio_request(GPIO56_NAND_RB, "NAND R/B");
358 if (err) {
359 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
360 gpio_free(GPIO11_NAND_CS);
361 return;
362 }
363
364 gpio_direction_input(GPIO56_NAND_RB);
225 365
366 platform_device_register(&em_x270_nand);
367}
368#else
369static inline void em_x270_init_nand(void) {}
370#endif
226 371
227/* PXA27x OHCI controller setup */ 372/* PXA27x OHCI controller setup */
373#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
228static int em_x270_ohci_init(struct device *dev) 374static int em_x270_ohci_init(struct device *dev)
229{ 375{
230 /* Set the Power Control Polarity Low */ 376 /* Set the Power Control Polarity Low */
@@ -242,27 +388,23 @@ static struct pxaohci_platform_data em_x270_ohci_platform_data = {
242 .init = em_x270_ohci_init, 388 .init = em_x270_ohci_init,
243}; 389};
244 390
391static void __init em_x270_init_ohci(void)
392{
393 pxa_set_ohci_info(&em_x270_ohci_platform_data);
394}
395#else
396static inline void em_x270_init_ohci(void) {}
397#endif
245 398
399/* MCI controller setup */
400#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
246static int em_x270_mci_init(struct device *dev, 401static int em_x270_mci_init(struct device *dev,
247 irq_handler_t em_x270_detect_int, 402 irq_handler_t em_x270_detect_int,
248 void *data) 403 void *data)
249{ 404{
250 int err; 405 int err = request_irq(EM_X270_MMC_CD, em_x270_detect_int,
251 406 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
252 /* setup GPIO for PXA27x MMC controller */ 407 "MMC card detect", data);
253 pxa_gpio_mode(GPIO32_MMCCLK_MD);
254 pxa_gpio_mode(GPIO112_MMCCMD_MD);
255 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
256 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
257 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
258 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
259
260 /* EM-X270 uses GPIO13 as SD power enable */
261 pxa_gpio_mode(EM_X270_MMC_PD | GPIO_OUT);
262
263 err = request_irq(EM_X270_MMC_IRQ, em_x270_detect_int,
264 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
265 "MMC card detect", data);
266 if (err) { 408 if (err) {
267 printk(KERN_ERR "%s: can't request MMC card detect IRQ: %d\n", 409 printk(KERN_ERR "%s: can't request MMC card detect IRQ: %d\n",
268 __func__, err); 410 __func__, err);
@@ -284,7 +426,8 @@ static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
284 426
285static void em_x270_mci_exit(struct device *dev, void *data) 427static void em_x270_mci_exit(struct device *dev, void *data)
286{ 428{
287 free_irq(EM_X270_MMC_IRQ, data); 429 int irq = gpio_to_irq(GPIO13_MMC_CD);
430 free_irq(irq, data);
288} 431}
289 432
290static struct pxamci_platform_data em_x270_mci_platform_data = { 433static struct pxamci_platform_data em_x270_mci_platform_data = {
@@ -294,7 +437,16 @@ static struct pxamci_platform_data em_x270_mci_platform_data = {
294 .exit = em_x270_mci_exit, 437 .exit = em_x270_mci_exit,
295}; 438};
296 439
440static void __init em_x270_init_mmc(void)
441{
442 pxa_set_mci_info(&em_x270_mci_platform_data);
443}
444#else
445static inline void em_x270_init_mmc(void) {}
446#endif
447
297/* LCD 480x640 */ 448/* LCD 480x640 */
449#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
298static struct pxafb_mode_info em_x270_lcd_mode = { 450static struct pxafb_mode_info em_x270_lcd_mode = {
299 .pixclock = 50000, 451 .pixclock = 50000,
300 .bpp = 16, 452 .bpp = 16,
@@ -312,39 +464,96 @@ static struct pxafb_mode_info em_x270_lcd_mode = {
312static struct pxafb_mach_info em_x270_lcd = { 464static struct pxafb_mach_info em_x270_lcd = {
313 .modes = &em_x270_lcd_mode, 465 .modes = &em_x270_lcd_mode,
314 .num_modes = 1, 466 .num_modes = 1,
315 .cmap_inverse = 0, 467 .lcd_conn = LCD_COLOR_TFT_16BPP,
316 .cmap_static = 0,
317 .lccr0 = LCCR0_PAS,
318 .lccr3 = LCCR3_PixClkDiv(0x01) | LCCR3_Acb(0xff),
319}; 468};
320 469static void __init em_x270_init_lcd(void)
321static void __init em_x270_init(void)
322{ 470{
323 /* setup LCD */
324 set_pxa_fb_info(&em_x270_lcd); 471 set_pxa_fb_info(&em_x270_lcd);
472}
473#else
474static inline void em_x270_init_lcd(void) {}
475#endif
476
477#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
478static void __init em_x270_init_ac97(void)
479{
480 pxa_set_ac97_info(NULL);
481}
482#else
483static inline void em_x270_init_ac97(void) {}
484#endif
485
486#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
487static unsigned int em_x270_matrix_keys[] = {
488 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
489 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
490 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
491};
325 492
326 /* register EM-X270 platform devices */ 493struct pxa27x_keypad_platform_data em_x270_keypad_info = {
327 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 494 /* code map for the matrix keys */
495 .matrix_key_rows = 3,
496 .matrix_key_cols = 3,
497 .matrix_key_map = em_x270_matrix_keys,
498 .matrix_key_map_size = ARRAY_SIZE(em_x270_matrix_keys),
499};
328 500
329 /* set MCI and OHCI platform parameters */ 501static void __init em_x270_init_keypad(void)
330 pxa_set_mci_info(&em_x270_mci_platform_data); 502{
331 pxa_set_ohci_info(&em_x270_ohci_platform_data); 503 pxa_set_keypad_info(&em_x270_keypad_info);
504}
505#else
506static inline void em_x270_init_keypad(void) {}
507#endif
508
509#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
510static struct gpio_keys_button gpio_keys_button[] = {
511 [0] = {
512 .desc = "sleep/wakeup",
513 .code = KEY_SUSPEND,
514 .type = EV_PWR,
515 .gpio = 1,
516 .wakeup = 1,
517 },
518};
519
520static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
521 .buttons = gpio_keys_button,
522 .nbuttons = 1,
523};
332 524
333 /* setup STUART GPIOs */ 525static struct platform_device em_x270_gpio_keys = {
334 pxa_gpio_mode(GPIO46_STRXD_MD); 526 .name = "gpio-keys",
335 pxa_gpio_mode(GPIO47_STTXD_MD); 527 .id = -1,
528 .dev = {
529 .platform_data = &em_x270_gpio_keys_data,
530 },
531};
336 532
337 /* setup BTUART GPIOs */ 533static void __init em_x270_init_gpio_keys(void)
338 pxa_gpio_mode(GPIO42_BTRXD_MD); 534{
339 pxa_gpio_mode(GPIO43_BTTXD_MD); 535 platform_device_register(&em_x270_gpio_keys);
340 pxa_gpio_mode(GPIO44_BTCTS_MD); 536}
341 pxa_gpio_mode(GPIO45_BTRTS_MD); 537#else
538static inline void em_x270_init_gpio_keys(void) {}
539#endif
342 540
343 /* Setup interrupt for dm9000 */ 541static void __init em_x270_init(void)
344 set_irq_type(EM_X270_ETHIRQ, IRQT_RISING); 542{
543 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
544
545 em_x270_init_dm9000();
546 em_x270_init_rtc();
547 em_x270_init_nand();
548 em_x270_init_lcd();
549 em_x270_init_mmc();
550 em_x270_init_ohci();
551 em_x270_init_keypad();
552 em_x270_init_gpio_keys();
553 em_x270_init_ac97();
345} 554}
346 555
347MACHINE_START(EM_X270, "Compulab EM-x270") 556MACHINE_START(EM_X270, "Compulab EM-X270")
348 .boot_params = 0xa0000100, 557 .boot_params = 0xa0000100,
349 .phys_io = 0x40000000, 558 .phys_io = 0x40000000,
350 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, 559 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,