]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-omap2/board-h4.c
ARM: OMAP: USB peripheral support on H4
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-h4.c
index 996aeda1285d058e6abe2b39df36bfb5bbcf75b1..b1cebddccacfc6e697d00d95e3210cdda35638b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/arch/arm/mach-omap/omap2/board-h4.c
+ * linux/arch/arm/mach-omap2/board-h4.c
  *
  * Copyright (C) 2005 Nokia Corporation
  * Author: Paul Mundt <paul.mundt@nokia.com>
@@ -39,7 +39,6 @@
 #include "prcm-regs.h"
 
 #include <asm/io.h>
-#include <asm/delay.h>
 
 static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
 static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
@@ -132,26 +131,6 @@ static struct platform_device h4_flash_device = {
        .resource       = &h4_flash_resource,
 };
 
-static struct resource h4_smc91x_resources[] = {
-       [0] = {
-               .start  = OMAP24XX_ETHR_START,          /* Physical */
-               .end    = OMAP24XX_ETHR_START + 0xf,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
-               .end    = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device h4_smc91x_device = {
-       .name           = "smc91x",
-       .id             = -1,
-       .num_resources  = ARRAY_SIZE(h4_smc91x_resources),
-       .resource       = h4_smc91x_resources,
-};
-
 /* Select between the IrDA and aGPS module
  */
 static int h4_select_irda(struct device *dev, int state)
@@ -179,9 +158,11 @@ static int h4_select_irda(struct device *dev, int state)
        return err;
 }
 
-static void set_trans_mode(void *data)
+static void set_trans_mode(struct work_struct *work)
 {
-       int *mode = data;
+       struct omap_irda_config *irda_config =
+               container_of(work, struct omap_irda_config, gpio_expa.work);
+       int mode = irda_config->mode;
        unsigned char expa;
        int err = 0;
 
@@ -191,7 +172,7 @@ static void set_trans_mode(void *data)
 
        expa &= ~0x01;
 
-       if (!(*mode & IR_SIRMODE)) { /* MIR/FIR */
+       if (!(mode & IR_SIRMODE)) { /* MIR/FIR */
                expa |= 0x01;
        }
 
@@ -204,9 +185,10 @@ static int h4_transceiver_mode(struct device *dev, int mode)
 {
        struct omap_irda_config *irda_config = dev->platform_data;
 
+       irda_config->mode = mode;
        cancel_delayed_work(&irda_config->gpio_expa);
-       PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
-       schedule_work(&irda_config->gpio_expa);
+       PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode);
+       schedule_delayed_work(&irda_config->gpio_expa, 0);
 
        return 0;
 }
@@ -265,14 +247,13 @@ static struct platform_device h4_lcd_device = {
 };
 
 static struct platform_device *h4_devices[] __initdata = {
-       &h4_smc91x_device,
        &h4_flash_device,
        &h4_irda_device,
        &h4_kp_device,
        &h4_lcd_device,
 };
 
-static inline void __init h4_init_smc91x(void)
+static inline void __init h4_init_debug(void)
 {
        /* Make sure CS1 timings are correct */
        GPMC_CONFIG1_1 = 0x00011200;
@@ -285,12 +266,8 @@ static inline void __init h4_init_smc91x(void)
        udelay(100);
 
        omap_cfg_reg(M15_24XX_GPIO92);
-       if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
-               printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
-                       OMAP24XX_ETHR_GPIO_IRQ);
-               return;
-       }
-       omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
+       if (debug_card_init(cs_mem_base, OMAP24XX_ETHR_GPIO_IRQ) < 0)
+               gpmc_cs_free(eth_cs);
 }
 
 static void __init omap_h4_init_irq(void)
@@ -298,11 +275,14 @@ static void __init omap_h4_init_irq(void)
        omap2_init_common_hw();
        omap_init_irq();
        omap_gpio_init();
-       h4_init_smc91x();
 }
 
 static struct omap_uart_config h4_uart_config __initdata = {
+#ifdef CONFIG_MACH_OMAP2_H4_USB1
+       .enabled_uarts = ((1 << 0) | (1 << 1)),
+#else
        .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
+#endif
 };
 
 static struct omap_mmc_config h4_mmc_config __initdata = {
@@ -319,10 +299,44 @@ static struct omap_lcd_config h4_lcd_config __initdata = {
        .ctrl_name      = "internal",
 };
 
+static struct omap_usb_config h4_usb_config __initdata = {
+#ifdef CONFIG_MACH_OMAP2_H4_USB1
+       /* NOTE:  usb1 could also be used with 3 wire signaling */
+       .pins[1]        = 4,
+#endif
+
+#ifdef CONFIG_MACH_OMAP_H4_OTG
+       /* S1.10 ON -- USB OTG port
+        * usb0 switched to Mini-AB port and isp1301 transceiver;
+        * S2.POS3 = OFF, S2.POS4 = ON ... to allow battery charging
+        */
+       .otg            = 1,
+       .pins[0]        = 4,
+#ifdef CONFIG_USB_GADGET_OMAP
+       /* use OTG cable, or standard A-to-MiniB */
+       .hmc_mode       = 0x14, /* 0:dev/otg 1:host 2:disable */
+#elif  defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
+       /* use OTG cable, or NONSTANDARD (B-to-MiniB) */
+       .hmc_mode       = 0x11, /* 0:host 1:host 2:disable */
+#endif /* XX */
+
+#else
+       /* S1.10 OFF -- usb "download port"
+        * usb0 switched to Mini-B port and isp1105 transceiver;
+        * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
+        */
+       .register_dev   = 1,
+       .pins[0]        = 3,
+//     .hmc_mode       = 0x14, /* 0:dev 1:host 2:disable */
+       .hmc_mode       = 0x00, /* 0:dev|otg 1:disable 2:disable */
+#endif
+};
+
 static struct omap_board_config_kernel h4_config[] = {
        { OMAP_TAG_UART,        &h4_uart_config },
        { OMAP_TAG_MMC,         &h4_mmc_config },
        { OMAP_TAG_LCD,         &h4_lcd_config },
+       { OMAP_TAG_USB, &h4_usb_config },
 };
 
 static void __init omap_h4_init(void)
@@ -345,6 +359,14 @@ static void __init omap_h4_init(void)
        }
 #endif
 
+#ifdef CONFIG_MACH_OMAP2_H4_USB1
+       /* S3.3 controls whether these pins are for UART2 or USB1 */
+       omap_cfg_reg(N14_24XX_USB1_SE0);
+       omap_cfg_reg(P15_24XX_USB1_DAT);
+       omap_cfg_reg(W20_24XX_USB1_TXEN);
+       omap_cfg_reg(V19_24XX_USB1_RCV);
+#endif
+
        platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
        omap_board_config = h4_config;
        omap_board_config_size = ARRAY_SIZE(h4_config);