]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/musb/musb_core.c
musb_hdrc: Fix includes to compile
[linux-2.6-omap-h63xx.git] / drivers / usb / musb / musb_core.c
index c5816a24b8b26d46719a9d2d0890fc26621552f3..c939f81e7302f275b7b4d81c3c1eb97c0c0d31fb 100644 (file)
 #include <linux/io.h>
 
 #ifdef CONFIG_ARM
-#include <asm/arch/hardware.h>
-#include <asm/arch/memory.h>
+#include <mach/hardware.h>
+#include <asm/memory.h>
 #include <asm/mach-types.h>
 #endif
 
 
 
 
-#if MUSB_DEBUG > 0
-unsigned debug = MUSB_DEBUG;
-module_param(debug, uint, 0);
-MODULE_PARM_DESC(debug, "initial debug message level");
-
-#define MUSB_VERSION_SUFFIX    "/dbg"
-#endif
+unsigned debug;
+module_param(debug, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, "Debug message level. Default = 0");
 
 #define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia"
 #define DRIVER_DESC "Inventra Dual-Role USB Controller Driver"
 
-#define MUSB_VERSION_BASE "6.0"
-
-#ifndef MUSB_VERSION_SUFFIX
-#define MUSB_VERSION_SUFFIX    ""
-#endif
-#define MUSB_VERSION   MUSB_VERSION_BASE MUSB_VERSION_SUFFIX
+#define MUSB_VERSION "6.0"
 
 #define DRIVER_INFO DRIVER_DESC ", v" MUSB_VERSION
 
-const char musb_driver_name[] = "musb_hdrc";
+#define MUSB_DRIVER_NAME "musb_hdrc"
+const char musb_driver_name[] = MUSB_DRIVER_NAME;
 
 MODULE_DESCRIPTION(DRIVER_INFO);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:" MUSB_DRIVER_NAME);
 
 
 /*-------------------------------------------------------------------------*/
@@ -441,7 +434,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                                MUSB_DEV_MODE(musb);
                                break;
                        default:
-                               WARN("bogus %s RESUME (%s)\n",
+                               WARNING("bogus %s RESUME (%s)\n",
                                        "host",
                                        otg_state_string(musb));
                        }
@@ -475,7 +468,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                                break;
 #endif
                        default:
-                               WARN("bogus %s RESUME (%s)\n",
+                               WARNING("bogus %s RESUME (%s)\n",
                                        "peripheral",
                                        otg_state_string(musb));
                        }
@@ -659,6 +652,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                        switch (musb->xceiv.state) {
 #ifdef CONFIG_USB_OTG
                        case OTG_STATE_A_SUSPEND:
+                               /* We need to ignore disconnect on suspend
+                                * otherwise tusb 2.0 won't reconnect after a
+                                * power cycle, which breaks otg compliance.
+                                */
                                musb->ignore_disconnect = 1;
                                musb_g_reset(musb);
                                /* FALLTHROUGH */
@@ -673,7 +670,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                                musb_hnp_stop(musb);
                                break;
                        case OTG_STATE_B_WAIT_ACON:
-                               DBG(1, "HNP: RESET (%s), back to b_peripheral\n",
+                               DBG(1, "HNP: RESET (%s), to b_peripheral\n",
                                        otg_state_string(musb));
                                musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
                                musb_g_reset(musb);
@@ -747,7 +744,7 @@ static irqreturn_t musb_stage2_irq(struct musb *musb, u8 int_usb,
                         */
                        if (ep->dwWaitFrame >= frame) {
                                ep->dwWaitFrame = 0;
-                               printk("SOF --> periodic TX%s on %d\n",
+                               pr_debug("SOF --> periodic TX%s on %d\n",
                                        ep->tx_channel ? " DMA" : "",
                                        epnum);
                                if (!ep->tx_channel)
@@ -793,7 +790,7 @@ static irqreturn_t musb_stage2_irq(struct musb *musb, u8 int_usb,
                        break;
 #endif /* GADGET */
                default:
-                       WARN("unhandled DISCONNECT transition (%s)\n",
+                       WARNING("unhandled DISCONNECT transition (%s)\n",
                                otg_state_string(musb));
                        break;
                }
@@ -984,12 +981,6 @@ static void musb_shutdown(struct platform_device *pdev)
  * We don't currently use dynamic fifo setup capability to do anything
  * more than selecting one of a bunch of predefined configurations.
  */
-#ifdef MUSB_C_DYNFIFO_DEF
-#define        can_dynfifo()   1
-#else
-#define        can_dynfifo()   0
-#endif
-
 #if defined(CONFIG_USB_TUSB6010) || \
        defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX)
 static ushort __initdata fifo_mode = 4;
@@ -1002,8 +993,6 @@ module_param(fifo_mode, ushort, 0);
 MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration");
 
 
-#define DYN_FIFO_SIZE (1<<(MUSB_C_RAM_BITS+2))
-
 enum fifo_style { FIFO_RXTX, FIFO_TX, FIFO_RX } __attribute__ ((packed));
 enum buf_mode { BUF_SINGLE, BUF_DOUBLE } __attribute__ ((packed));
 
@@ -1113,11 +1102,12 @@ fifo_setup(struct musb *musb, struct musb_hw_ep  *hw_ep,
 
        c_size = size - 3;
        if (cfg->mode == BUF_DOUBLE) {
-               if ((offset + (maxpacket << 1)) > DYN_FIFO_SIZE)
+               if ((offset + (maxpacket << 1)) >
+                               (1 << (musb->config->ram_bits + 2)))
                        return -EMSGSIZE;
                c_size |= MUSB_FIFOSZ_DPB;
        } else {
-               if ((offset + maxpacket) > DYN_FIFO_SIZE)
+               if ((offset + maxpacket) > (1 << (musb->config->ram_bits + 2)))
                        return -EMSGSIZE;
        }
 
@@ -1213,13 +1203,13 @@ static int __init ep_config_from_table(struct musb *musb)
        /* assert(offset > 0) */
 
        /* NOTE:  for RTL versions >= 1.400 EPINFO and RAMINFO would
-        * be better than static MUSB_C_NUM_EPS and DYN_FIFO_SIZE...
+        * be better than static musb->config->num_eps and DYN_FIFO_SIZE...
         */
 
        for (i = 0; i < n; i++) {
                u8      epn = cfg->hw_ep_num;
 
-               if (epn >= MUSB_C_NUM_EPS) {
+               if (epn >= musb->config->num_eps) {
                        pr_debug("%s: invalid ep %d\n",
                                        musb_driver_name, epn);
                        continue;
@@ -1236,8 +1226,8 @@ static int __init ep_config_from_table(struct musb *musb)
 
        printk(KERN_DEBUG "%s: %d/%d max ep, %d/%d memory\n",
                        musb_driver_name,
-                       n + 1, MUSB_C_NUM_EPS * 2 - 1,
-                       offset, DYN_FIFO_SIZE);
+                       n + 1, musb->config->num_eps * 2 - 1,
+                       offset, (1 << (musb->config->ram_bits + 2)));
 
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
        if (!musb->bulk_ep) {
@@ -1264,7 +1254,7 @@ static int __init ep_config_from_hw(struct musb *musb)
 
        /* FIXME pick up ep0 maxpacket size */
 
-       for (epnum = 1; epnum < MUSB_C_NUM_EPS; epnum++) {
+       for (epnum = 1; epnum < musb->config->num_eps; epnum++) {
                musb_ep_select(mbase, epnum);
                hw_ep = musb->endpoints + epnum;
 
@@ -1377,9 +1367,9 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
                (data >> 16) & 0xff, (data >> 24) & 0xff);
        /* FIXME ID2 and ID3 are unused */
        data = musb_readl(mbase, 0x408);
-       printk("ID2=%lx\n", (long unsigned)data);
+       printk(KERN_DEBUG "ID2=%lx\n", (long unsigned)data);
        data = musb_readl(mbase, 0x40c);
-       printk("ID3=%lx\n", (long unsigned)data);
+       printk(KERN_DEBUG "ID3=%lx\n", (long unsigned)data);
        reg = musb_readb(mbase, 0x400);
        musb_type = ('M' == reg) ? MUSB_CONTROLLER_MHDRC : MUSB_CONTROLLER_HDRC;
 #else
@@ -1418,14 +1408,14 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
        musb->epmask = 1;
 
        if (reg & MUSB_CONFIGDATA_DYNFIFO) {
-               if (can_dynfifo())
+               if (musb->config->dyn_fifo)
                        status = ep_config_from_table(musb);
                else {
                        ERR("reconfigure software for Dynamic FIFOs\n");
                        status = -ENODEV;
                }
        } else {
-               if (!can_dynfifo())
+               if (!musb->config->dyn_fifo)
                        status = ep_config_from_hw(musb);
                else {
                        ERR("reconfigure software for static FIFOs\n");
@@ -1782,7 +1772,8 @@ static void musb_irq_work(struct work_struct *data)
  */
 
 static struct musb *__init
-allocate_instance(struct device *dev, void __iomem *mbase)
+allocate_instance(struct device *dev,
+               struct musb_hdrc_config *config, void __iomem *mbase)
 {
        struct musb             *musb;
        struct musb_hw_ep       *ep;
@@ -1814,17 +1805,15 @@ allocate_instance(struct device *dev, void __iomem *mbase)
        musb->mregs = mbase;
        musb->ctrl_base = mbase;
        musb->nIrq = -ENODEV;
+       musb->config = config;
        for (epnum = 0, ep = musb->endpoints;
-                       epnum < MUSB_C_NUM_EPS;
+                       epnum < musb->config->num_eps;
                        epnum++, ep++) {
 
                ep->musb = musb;
                ep->epnum = epnum;
        }
 
-#ifdef CONFIG_USB_MUSB_OTG
-       otg_set_transceiver(&musb->xceiv);
-#endif
        musb->controller = dev;
        return musb;
 }
@@ -1926,7 +1915,7 @@ bad_config:
        }
 
        /* allocate */
-       musb = allocate_instance(dev, ctrl);
+       musb = allocate_instance(dev, plat->config, ctrl);
        if (!musb)
                return -ENOMEM;
 
@@ -1984,7 +1973,7 @@ bad_config:
        musb_generic_disable(musb);
 
        /* setup musb parts of the core (especially endpoints) */
-       status = musb_core_init(plat->multipoint
+       status = musb_core_init(plat->config->multipoint
                        ? MUSB_CONTROLLER_MHDRC
                        : MUSB_CONTROLLER_HDRC, musb);
        if (status < 0)
@@ -2039,6 +2028,8 @@ bad_config:
                musb->xceiv.state = OTG_STATE_A_IDLE;
 
                status = usb_add_hcd(musb_to_hcd(musb), -1, 0);
+               if (status)
+                       goto fail;
 
                DBG(1, "%s mode, status %d, devctl %02x %c\n",
                        "HOST", status,
@@ -2053,6 +2044,8 @@ bad_config:
                musb->xceiv.state = OTG_STATE_B_IDLE;
 
                status = musb_gadget_setup(musb);
+               if (status)
+                       goto fail;
 
                DBG(1, "%s mode, status %d, dev%02x\n",
                        is_otg_enabled(musb) ? "OTG" : "PERIPHERAL",
@@ -2061,16 +2054,14 @@ bad_config:
 
        }
 
-       if (status == 0)
-               musb_debug_create("driver/musb_hdrc", musb);
-       else {
+       return 0;
+
 fail:
-               if (musb->clock)
-                       clk_put(musb->clock);
-               device_init_wakeup(dev, 0);
-               musb_free(musb);
-               return status;
-       }
+       if (musb->clock)
+               clk_put(musb->clock);
+       device_init_wakeup(dev, 0);
+       musb_free(musb);
+       return status;
 
 #ifdef CONFIG_SYSFS
        status = device_create_file(dev, &dev_attr_mode);
@@ -2133,7 +2124,6 @@ static int __devexit musb_remove(struct platform_device *pdev)
         *  - OTG mode: both roles are deactivated (or never-activated)
         */
        musb_shutdown(pdev);
-       musb_debug_delete("driver/musb_hdrc", musb);
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
        if (musb->board_mode == MUSB_HOST)
                usb_remove_hcd(musb_to_hcd(musb));