2 * Support for CompuLab EM-X270 platform
4 * Copyright (C) 2007, 2008 CompuLab, Ltd.
5 * Author: 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/irq.h>
13 #include <linux/platform_device.h>
15 #include <linux/dm9000.h>
16 #include <linux/rtc-v3020.h>
17 #include <linux/mtd/nand.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/input.h>
20 #include <linux/gpio_keys.h>
21 #include <linux/gpio.h>
23 #include <asm/mach-types.h>
24 #include <asm/mach/arch.h>
26 #include <asm/arch/mfp-pxa27x.h>
27 #include <asm/arch/pxa-regs.h>
28 #include <asm/arch/pxa27x-udc.h>
29 #include <asm/arch/audio.h>
30 #include <asm/arch/pxafb.h>
31 #include <asm/arch/ohci.h>
32 #include <asm/arch/mmc.h>
33 #include <asm/arch/pxa27x_keypad.h>
38 #define GPIO41_ETHIRQ (41)
39 #define GPIO13_MMC_CD (13)
40 #define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
41 #define EM_X270_MMC_CD IRQ_GPIO(GPIO13_MMC_CD)
43 /* NAND control GPIOs */
44 #define GPIO11_NAND_CS (11)
45 #define GPIO56_NAND_RB (56)
47 static unsigned long em_x270_pin_config[] = {
50 GPIO29_AC97_SDATA_IN_0,
51 GPIO30_AC97_SDATA_OUT,
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,
144 /* SDRAM and local bus */
153 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
156 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
157 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
160 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
161 GPIO56_GPIO, /* NAND Ready/Busy */
164 GPIO13_GPIO, /* MMC card detect */
165 GPIO41_GPIO, /* DM9000 interrupt */
168 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
169 static struct resource em_x270_dm9000_resource[] = {
171 .start = PXA_CS2_PHYS,
172 .end = PXA_CS2_PHYS + 3,
173 .flags = IORESOURCE_MEM,
176 .start = PXA_CS2_PHYS + 8,
177 .end = PXA_CS2_PHYS + 8 + 0x3f,
178 .flags = IORESOURCE_MEM,
181 .start = EM_X270_ETHIRQ,
182 .end = EM_X270_ETHIRQ,
183 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
187 static struct dm9000_plat_data em_x270_dm9000_platdata = {
188 .flags = DM9000_PLATF_32BITONLY,
191 static struct platform_device em_x270_dm9000 = {
194 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
195 .resource = em_x270_dm9000_resource,
197 .platform_data = &em_x270_dm9000_platdata,
201 static void __init em_x270_init_dm9000(void)
203 platform_device_register(&em_x270_dm9000);
206 static inline void em_x270_init_dm9000(void) {}
210 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
211 static struct resource em_x270_v3020_resource[] = {
213 .start = PXA_CS4_PHYS,
214 .end = PXA_CS4_PHYS + 3,
215 .flags = IORESOURCE_MEM,
219 static struct v3020_platform_data em_x270_v3020_platdata = {
223 static struct platform_device em_x270_rtc = {
225 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
226 .resource = em_x270_v3020_resource,
229 .platform_data = &em_x270_v3020_platdata,
233 static void __init em_x270_init_rtc(void)
235 platform_device_register(&em_x270_rtc);
238 static inline void em_x270_init_rtc(void) {}
242 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
243 static inline void nand_cs_on(void)
245 gpio_set_value(GPIO11_NAND_CS, 0);
248 static void nand_cs_off(void)
252 gpio_set_value(GPIO11_NAND_CS, 1);
255 /* hardware specific access to control-lines */
256 static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
259 struct nand_chip *this = mtd->priv;
260 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
264 if (ctrl & NAND_CTRL_CHANGE) {
266 nandaddr |= (1 << 3);
268 nandaddr &= ~(1 << 3);
270 nandaddr |= (1 << 2);
272 nandaddr &= ~(1 << 2);
280 this->IO_ADDR_W = (void __iomem *)nandaddr;
281 if (dat != NAND_CMD_NONE)
282 writel(dat, this->IO_ADDR_W);
287 /* read device ready pin */
288 static int em_x270_nand_device_ready(struct mtd_info *mtd)
292 return gpio_get_value(GPIO56_NAND_RB);
295 static struct mtd_partition em_x270_partition_info[] = {
303 .offset = MTDPART_OFS_APPEND,
304 .size = MTDPART_SIZ_FULL
308 static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
310 struct platform_nand_data em_x270_nand_platdata = {
314 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
315 .partitions = em_x270_partition_info,
317 .part_probe_types = em_x270_part_probes,
321 .dev_ready = em_x270_nand_device_ready,
323 .cmd_ctrl = em_x270_nand_cmd_ctl,
327 static struct resource em_x270_nand_resource[] = {
329 .start = PXA_CS1_PHYS,
330 .end = PXA_CS1_PHYS + 12,
331 .flags = IORESOURCE_MEM,
335 static struct platform_device em_x270_nand = {
337 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
338 .resource = em_x270_nand_resource,
341 .platform_data = &em_x270_nand_platdata,
345 static void __init em_x270_init_nand(void)
349 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
351 pr_warning("EM-X270: failed to request NAND CS gpio\n");
355 gpio_direction_output(GPIO11_NAND_CS, 1);
357 err = gpio_request(GPIO56_NAND_RB, "NAND R/B");
359 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
360 gpio_free(GPIO11_NAND_CS);
364 gpio_direction_input(GPIO56_NAND_RB);
366 platform_device_register(&em_x270_nand);
369 static inline void em_x270_init_nand(void) {}
372 /* PXA27x OHCI controller setup */
373 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
374 static int em_x270_ohci_init(struct device *dev)
376 /* Set the Power Control Polarity Low */
377 UHCHR = (UHCHR | UHCHR_PCPL) &
378 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE);
380 /* enable port 2 transiever */
381 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
386 static struct pxaohci_platform_data em_x270_ohci_platform_data = {
387 .port_mode = PMM_PERPORT_MODE,
388 .init = em_x270_ohci_init,
391 static void __init em_x270_init_ohci(void)
393 pxa_set_ohci_info(&em_x270_ohci_platform_data);
396 static inline void em_x270_init_ohci(void) {}
399 /* MCI controller setup */
400 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
401 static int em_x270_mci_init(struct device *dev,
402 irq_handler_t em_x270_detect_int,
405 int err = request_irq(EM_X270_MMC_CD, em_x270_detect_int,
406 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
407 "MMC card detect", data);
409 printk(KERN_ERR "%s: can't request MMC card detect IRQ: %d\n",
417 static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
420 FIXME: current hardware implementation does not allow to
421 enable/disable MMC power. This will be fixed in next HW releases,
422 and we'll need to add implmentation here.
427 static void em_x270_mci_exit(struct device *dev, void *data)
429 int irq = gpio_to_irq(GPIO13_MMC_CD);
433 static struct pxamci_platform_data em_x270_mci_platform_data = {
434 .ocr_mask = MMC_VDD_28_29|MMC_VDD_29_30|MMC_VDD_30_31,
435 .init = em_x270_mci_init,
436 .setpower = em_x270_mci_setpower,
437 .exit = em_x270_mci_exit,
440 static void __init em_x270_init_mmc(void)
442 pxa_set_mci_info(&em_x270_mci_platform_data);
445 static inline void em_x270_init_mmc(void) {}
449 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
450 static struct pxafb_mode_info em_x270_lcd_mode = {
464 static struct pxafb_mach_info em_x270_lcd = {
465 .modes = &em_x270_lcd_mode,
467 .lcd_conn = LCD_COLOR_TFT_16BPP,
469 static void __init em_x270_init_lcd(void)
471 set_pxa_fb_info(&em_x270_lcd);
474 static inline void em_x270_init_lcd(void) {}
477 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
478 static void __init em_x270_init_ac97(void)
480 pxa_set_ac97_info(NULL);
483 static inline void em_x270_init_ac97(void) {}
486 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
487 static 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),
493 struct pxa27x_keypad_platform_data em_x270_keypad_info = {
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),
501 static void __init em_x270_init_keypad(void)
503 pxa_set_keypad_info(&em_x270_keypad_info);
506 static inline void em_x270_init_keypad(void) {}
509 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
510 static struct gpio_keys_button gpio_keys_button[] = {
512 .desc = "sleep/wakeup",
520 static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
521 .buttons = gpio_keys_button,
525 static struct platform_device em_x270_gpio_keys = {
529 .platform_data = &em_x270_gpio_keys_data,
533 static void __init em_x270_init_gpio_keys(void)
535 platform_device_register(&em_x270_gpio_keys);
538 static inline void em_x270_init_gpio_keys(void) {}
541 static void __init em_x270_init(void)
543 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
545 em_x270_init_dm9000();
551 em_x270_init_keypad();
552 em_x270_init_gpio_keys();
556 MACHINE_START(EM_X270, "Compulab EM-X270")
557 .boot_params = 0xa0000100,
558 .phys_io = 0x40000000,
559 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
560 .map_io = pxa_map_io,
561 .init_irq = pxa27x_init_irq,
563 .init_machine = em_x270_init,