Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[pandora-kernel.git] / arch / arm / mach-omap2 / board-apollon.c
index 7993b7b..3bb49c1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/arch/arm/mach-omap/omap2/board-apollon.c
+ * linux/arch/arm/mach-omap2/board-apollon.c
  *
  * Copyright (C) 2005,2006 Samsung Electronics
  * Author: Kyungmin Park <kyungmin.park@samsung.com>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/onenand.h>
+#include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/leds.h>
+#include <linux/irq.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/mach/flash.h>
 
 #include <asm/arch/gpio.h>
+#include <asm/arch/led.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/usb.h>
 #include <asm/arch/board.h>
 #include <asm/arch/common.h>
+#include <asm/arch/gpmc.h>
 #include "prcm-regs.h"
 
 /* LED & Switch macros */
@@ -45,6 +50,9 @@
 #define SW_UP_GPIO17           17
 #define SW_DOWN_GPIO58         58
 
+#define APOLLON_FLASH_CS       0
+#define APOLLON_ETH_CS         1
+
 static struct mtd_partition apollon_partitions[] = {
        {
                .name           = "X-Loader + U-Boot",
@@ -84,10 +92,10 @@ static struct flash_platform_data apollon_flash_data = {
        .nr_parts       = ARRAY_SIZE(apollon_partitions),
 };
 
-static struct resource apollon_flash_resource = {
-       .start          = APOLLON_CS0_BASE,
-       .end            = APOLLON_CS0_BASE + SZ_128K,
-       .flags          = IORESOURCE_MEM,
+static struct resource apollon_flash_resource[] = {
+       [0] = {
+               .flags          = IORESOURCE_MEM,
+       },
 };
 
 static struct platform_device apollon_onenand_device = {
@@ -96,14 +104,24 @@ static struct platform_device apollon_onenand_device = {
        .dev            = {
                .platform_data  = &apollon_flash_data,
        },
-       .num_resources  = ARRAY_SIZE(&apollon_flash_resource),
-       .resource       = &apollon_flash_resource,
+       .num_resources  = ARRAY_SIZE(apollon_flash_resource),
+       .resource       = apollon_flash_resource,
 };
 
+static void __init apollon_flash_init(void)
+{
+       unsigned long base;
+
+       if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) {
+               printk(KERN_ERR "Cannot request OneNAND GPMC CS\n");
+               return;
+       }
+       apollon_flash_resource[0].start = base;
+       apollon_flash_resource[0].end   = base + SZ_128K - 1;
+}
+
 static struct resource apollon_smc91x_resources[] = {
        [0] = {
-               .start  = APOLLON_ETHR_START,           /* Physical */
-               .end    = APOLLON_ETHR_START + 0xf,
                .flags  = IORESOURCE_MEM,
        },
        [1] = {
@@ -125,14 +143,51 @@ static struct platform_device apollon_lcd_device = {
        .id             = -1,
 };
 
+static struct omap_led_config apollon_led_config[] = {
+       {
+               .cdev   = {
+                       .name   = "apollon:led0",
+               },
+               .gpio   = LED0_GPIO13,
+       },
+       {
+               .cdev   = {
+                       .name   = "apollon:led1",
+               },
+               .gpio   = LED1_GPIO14,
+       },
+       {
+               .cdev   = {
+                       .name   = "apollon:led2",
+               },
+               .gpio   = LED2_GPIO15,
+       },
+};
+
+static struct omap_led_platform_data apollon_led_data = {
+       .nr_leds        = ARRAY_SIZE(apollon_led_config),
+       .leds           = apollon_led_config,
+};
+
+static struct platform_device apollon_led_device = {
+       .name           = "omap-led",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &apollon_led_data,
+       },
+};
+
 static struct platform_device *apollon_devices[] __initdata = {
        &apollon_onenand_device,
        &apollon_smc91x_device,
        &apollon_lcd_device,
+       &apollon_led_device,
 };
 
 static inline void __init apollon_init_smc91x(void)
 {
+       unsigned long base;
+
        /* Make sure CS1 timings are correct */
        GPMC_CONFIG1_1 = 0x00011203;
        GPMC_CONFIG2_1 = 0x001f1f01;
@@ -140,13 +195,20 @@ static inline void __init apollon_init_smc91x(void)
        GPMC_CONFIG4_1 = 0x1c091c09;
        GPMC_CONFIG5_1 = 0x041f1f1f;
        GPMC_CONFIG6_1 = 0x000004c4;
-       GPMC_CONFIG7_1 = 0x00000f40 | (APOLLON_CS1_BASE >> 24);
+
+       if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) {
+               printk(KERN_ERR "Failed to request GPMC CS for smc91x\n");
+               return;
+       }
+       apollon_smc91x_resources[0].start = base + 0x300;
+       apollon_smc91x_resources[0].end   = base + 0x30f;
        udelay(100);
 
        omap_cfg_reg(W4__24XX_GPIO74);
        if (omap_request_gpio(APOLLON_ETHR_GPIO_IRQ) < 0) {
                printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
                        APOLLON_ETHR_GPIO_IRQ);
+               gpmc_cs_free(APOLLON_ETH_CS);
                return;
        }
        omap_set_gpio_direction(APOLLON_ETHR_GPIO_IRQ, 1);
@@ -166,14 +228,21 @@ static struct omap_uart_config apollon_uart_config __initdata = {
 
 static struct omap_mmc_config apollon_mmc_config __initdata = {
        .mmc [0] = {
-               .enabled        = 0,
-               .wire4          = 0,
+               .enabled        = 1,
+               .wire4          = 1,
                .wp_pin         = -1,
                .power_pin      = -1,
                .switch_pin     = -1,
        },
 };
 
+static struct omap_usb_config apollon_usb_config __initdata = {
+       .register_dev   = 1,
+       .hmc_mode       = 0x14, /* 0:dev 1:host1 2:disable */
+
+       .pins[0]        = 6,
+};
+
 static struct omap_lcd_config apollon_lcd_config __initdata = {
        .ctrl_name      = "internal",
 };
@@ -181,6 +250,7 @@ static struct omap_lcd_config apollon_lcd_config __initdata = {
 static struct omap_board_config_kernel apollon_config[] = {
        { OMAP_TAG_UART,        &apollon_uart_config },
        { OMAP_TAG_MMC,         &apollon_mmc_config },
+       { OMAP_TAG_USB,         &apollon_usb_config },
        { OMAP_TAG_LCD,         &apollon_lcd_config },
 };
 
@@ -203,7 +273,7 @@ static void __init apollon_led_init(void)
        omap_set_gpio_dataout(LED2_GPIO15, 0);
 }
 
-static irqreturn_t apollon_sw_interrupt(int irq, void *ignored, struct pt_regs *regs)
+static irqreturn_t apollon_sw_interrupt(int irq, void *ignored)
 {
        static unsigned int led0, led1, led2;
 
@@ -249,14 +319,29 @@ static void __init apollon_sw_init(void)
                return;
 }
 
+static void __init apollon_usb_init(void)
+{
+       /* USB device */
+       /* DEVICE_SUSPEND */
+       omap_cfg_reg(P21_242X_GPIO12);
+       omap_request_gpio(12);
+       omap_set_gpio_direction(12, 0);         /* OUT */
+       omap_set_gpio_dataout(12, 0);
+}
+
 static void __init omap_apollon_init(void)
 {
        apollon_led_init();
        apollon_sw_init();
+       apollon_flash_init();
+       apollon_usb_init();
 
        /* REVISIT: where's the correct place */
        omap_cfg_reg(W19_24XX_SYS_NIRQ);
 
+       /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */
+       CONTROL_DEVCONF |= (1 << 24);
+
        /*
         * Make sure the serial ports are muxed on at this point.
         * You have to mux them off in device drivers later on