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 <mach/mfp-pxa27x.h>
27 #include <mach/pxa-regs.h>
28 #include <mach/pxa27x-udc.h>
29 #include <mach/audio.h>
30 #include <mach/pxafb.h>
31 #include <mach/ohci.h>
33 #include <mach/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 /* enable port 2 transiever */
377 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
382 static struct pxaohci_platform_data em_x270_ohci_platform_data = {
383 .port_mode = PMM_PERPORT_MODE,
384 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
385 .init = em_x270_ohci_init,
388 static void __init em_x270_init_ohci(void)
390 pxa_set_ohci_info(&em_x270_ohci_platform_data);
393 static inline void em_x270_init_ohci(void) {}
396 /* MCI controller setup */
397 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
398 static int em_x270_mci_init(struct device *dev,
399 irq_handler_t em_x270_detect_int,
402 int err = request_irq(EM_X270_MMC_CD, em_x270_detect_int,
403 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
404 "MMC card detect", data);
406 printk(KERN_ERR "%s: can't request MMC card detect IRQ: %d\n",
414 static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
417 FIXME: current hardware implementation does not allow to
418 enable/disable MMC power. This will be fixed in next HW releases,
419 and we'll need to add implmentation here.
424 static void em_x270_mci_exit(struct device *dev, void *data)
426 int irq = gpio_to_irq(GPIO13_MMC_CD);
430 static struct pxamci_platform_data em_x270_mci_platform_data = {
431 .ocr_mask = MMC_VDD_28_29|MMC_VDD_29_30|MMC_VDD_30_31,
432 .init = em_x270_mci_init,
433 .setpower = em_x270_mci_setpower,
434 .exit = em_x270_mci_exit,
437 static void __init em_x270_init_mmc(void)
439 pxa_set_mci_info(&em_x270_mci_platform_data);
442 static inline void em_x270_init_mmc(void) {}
446 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
447 static struct pxafb_mode_info em_x270_lcd_mode = {
461 static struct pxafb_mach_info em_x270_lcd = {
462 .modes = &em_x270_lcd_mode,
464 .lcd_conn = LCD_COLOR_TFT_16BPP,
466 static void __init em_x270_init_lcd(void)
468 set_pxa_fb_info(&em_x270_lcd);
471 static inline void em_x270_init_lcd(void) {}
474 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
475 static void __init em_x270_init_ac97(void)
477 pxa_set_ac97_info(NULL);
480 static inline void em_x270_init_ac97(void) {}
483 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
484 static unsigned int em_x270_matrix_keys[] = {
485 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
486 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
487 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
490 struct pxa27x_keypad_platform_data em_x270_keypad_info = {
491 /* code map for the matrix keys */
492 .matrix_key_rows = 3,
493 .matrix_key_cols = 3,
494 .matrix_key_map = em_x270_matrix_keys,
495 .matrix_key_map_size = ARRAY_SIZE(em_x270_matrix_keys),
498 static void __init em_x270_init_keypad(void)
500 pxa_set_keypad_info(&em_x270_keypad_info);
503 static inline void em_x270_init_keypad(void) {}
506 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
507 static struct gpio_keys_button gpio_keys_button[] = {
509 .desc = "sleep/wakeup",
517 static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
518 .buttons = gpio_keys_button,
522 static struct platform_device em_x270_gpio_keys = {
526 .platform_data = &em_x270_gpio_keys_data,
530 static void __init em_x270_init_gpio_keys(void)
532 platform_device_register(&em_x270_gpio_keys);
535 static inline void em_x270_init_gpio_keys(void) {}
538 static void __init em_x270_init(void)
540 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
542 em_x270_init_dm9000();
548 em_x270_init_keypad();
549 em_x270_init_gpio_keys();
553 MACHINE_START(EM_X270, "Compulab EM-X270")
554 .boot_params = 0xa0000100,
555 .phys_io = 0x40000000,
556 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
557 .map_io = pxa_map_io,
558 .init_irq = pxa27x_init_irq,
560 .init_machine = em_x270_init,