From: Charlie Paul <cpaul.windri...@gmail.com>

These files add the usb host funtionality to the
LSI axxia 5500 board.

Signed-off-by: Charlie Paul <cpaul.windri...@gmail.com>
---
 drivers/usb/host/Kconfig        |   19 ++
 drivers/usb/host/ehci-ci13612.c |  384 +++++++++++++++++++++++++++++++++++++++
 drivers/usb/host/ehci-ci13612.h |   48 +++++
 drivers/usb/host/ehci-hcd.c     |  176 ++++++++++--------
 4 files changed, 548 insertions(+), 79 deletions(-)
 create mode 100644 drivers/usb/host/ehci-ci13612.c
 create mode 100644 drivers/usb/host/ehci-ci13612.h

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index fafc628..9b5bd84 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -3,6 +3,12 @@
 #
 comment "USB Host Controller Drivers"
 
+config LSI_USB_SW_WORKAROUND
+       bool "LSI USB SW Workaround for ACP34xx devices"
+       default n
+       help
+         LSI USB SW Workaround for ACP34xx devices
+
 config USB_C67X00_HCD
        tristate "Cypress C67x00 HCD support"
        help
@@ -355,6 +361,19 @@ config USB_ISP1362_HCD
          To compile this driver as a module, choose M here: the
          module will be called isp1362-hcd.
 
+config USB_CI13612_HCD
+       tristate "CI13612A HCD support"
+       depends on USB
+       ---help---
+         The CI13612A is an USB host/OTG/device controller. Enable this
+         option if your board has this chip. If unsure, say N.
+
+         This driver does not support isochronous transfers and doesn't
+         implement OTG nor USB device controllers.
+
+         To compile this driver as a module, choose M here: the
+         module will be called CI13612-hcd.
+
 config USB_FUSBH200_HCD
        tristate "FUSBH200 HCD support"
        depends on USB
diff --git a/drivers/usb/host/ehci-ci13612.c b/drivers/usb/host/ehci-ci13612.c
new file mode 100644
index 0000000..81d954f
--- /dev/null
+++ b/drivers/usb/host/ehci-ci13612.c
@@ -0,0 +1,384 @@
+ /*
+  * drivers/usb/host/ehci-ci13612.c
+  *
+  * USB Host Controller Driver for LSI's ACP
+  *
+  * Copyright (C) 2010 LSI Inc.
+  *
+  * This program is free software; you can redistribute it and/or modify
+  * it under the terms of the GNU General Public License as published by
+  * the Free Software Foundation; either version 2 of the License, or
+  * (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program; if not, write to the Free Software
+  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+  *
+  */
+
+#include <linux/platform_device.h>
+#include <linux/irq.h>
+#include <linux/of_platform.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/uaccess.h>
+#include <linux/io.h>
+#include "ehci-ci13612.h"
+
+
+static int ci13612_ehci_halt(struct ehci_hcd *ehci);
+
+#ifdef CONFIG_LSI_USB_SW_WORKAROUND
+static void ci13612_usb_setup(struct usb_hcd *hcd)
+{
+       int USB_TXFIFOTHRES, VUSB_HS_TX_BURST;
+       u32 devicemode;
+       struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+       u32 txfulltuning = 0;
+
+       if ((of_find_compatible_node(NULL, NULL, "lsi,acp3500")
+               != NULL)
+               || (of_find_compatible_node(NULL, NULL, "lsi,axxia35xx")
+               != NULL)) {
+               writel(3, USB_SBUSCFG);
+               return;
+       }
+
+       /* Fix for HW errata 0002832: Settings of VUSB_HS_TX_BURST and
+        * TXFILLTUNING.
+        * TXFIFOTHRES should satisfy
+        * TXFIFOTHRES * VUSB_HS_TX_BURST >= MAXIMUM PACKET SIZE of packet
+        * relationship.
+        */
+       VUSB_HS_TX_BURST = readl(USB_HWTXBUF) & 0x0f;
+       USB_TXFIFOTHRES = (32 << 16);
+       txfulltuning = (txfulltuning  & 0xffc0ffff) | USB_TXFIFOTHRES;
+       writel(txfulltuning, (void __iomem *)USB_TXFILLTUNING);
+
+       /* Fix for HW errata 9000556154: When operating in device mode Use
+        * Unspecified Length Bursts by setting SBUSCFG to 0x0, or use stream
+        * disable mode by setting USBMODE.SDIS to 0x1.
+        */
+       devicemode = ehci_readl(ehci, hcd->regs + 0x1A8);
+
+       if ((devicemode & 0x3) == 0x2) {
+               /* device mode */
+               writel(0x0, hcd->regs + 0x90);
+       } else if ((devicemode & 0x3) == 0x3) {
+               /* host mode */
+               writel(0x6, hcd->regs + 0x90);
+       }
+
+       pr_err("ehci-ci13612 (ci13612_usb_setup): VUSB_HS_TX_BURST = 
0x%x,USB_TXFIFOTHRES = 0x%x\n",
+                       VUSB_HS_TX_BURST, USB_TXFIFOTHRES);
+}
+#endif
+
+/* called after powerup, by probe or system-pm "wakeup" */
+static int ehci_ci13612_reinit(struct ehci_hcd *ehci)
+{
+
+#ifdef CONFIG_LSI_USB_SW_WORKAROUND
+       /* S/W workarounds are not needed in AXM55xx */
+       ci13612_usb_setup(ehci_to_hcd(ehci));
+#endif
+       return 0;
+}
+
+
+static int ci13612_ehci_init(struct usb_hcd *hcd)
+{
+       struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+       int retval = 0;
+       int len;
+
+       /* EHCI registers start at offset 0x100 */
+       ehci->caps = hcd->regs + 0x100;
+       ehci->regs = hcd->regs + 0x100
+               + HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
+       len = HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
+
+       /* configure other settings */
+       ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
+       hcd->has_tt = 1;
+
+       ehci->sbrn = 0x20;
+
+       /* Reset is only allowed on a stopped controller */
+       ci13612_ehci_halt(ehci);
+
+       /* reset controller */
+       ehci_reset(ehci);
+
+       /* data structure init */
+       retval = ehci_init(hcd);
+       if (retval)
+               return retval;
+       hcd->self.sg_tablesize = 0;
+
+       retval = ehci_ci13612_reinit(ehci);
+
+       return retval;
+}
+
+#ifdef CONFIG_LSI_USB_SW_WORKAROUND
+/*
+ * ci13612_fixup_usbcmd_rs
+ *
+ * Fix HW errata 0003256: Do not enable USBCMD.RS for some time after the USB
+ * reset has been completed (PORTSCx.PR=0). This ensures that the host does not
+ * send the SOF until the ULPI post reset processing has been completed. Note:
+ * This workaround reduces the likelihood of this problem occuring, but it may
+ * not entirely eliminate it.
+ */
+static int
+ci13612_fixup_usbcmd_rs(struct ehci_hcd *ehci)
+{
+       u32 port_status;
+       /* This workaround is not applicable to 3500 */
+       if ((of_find_compatible_node(NULL, NULL, "lsi,acp3500")
+               != NULL)
+               || (of_find_compatible_node(NULL, NULL, "lsi,axxia35xx")
+               != NULL)) {
+               return 0;
+       }
+
+       port_status = ehci_readl(ehci, &ehci->regs->port_status[0]);
+       pr_info("ehci-ci13612: port_status = 0x%x\n", port_status);
+       if (port_status & 0x100) {
+               pr_err("ehci-ci13612: USB port is in reset status, not able to 
change HC status to run\n");
+               return -EFAULT;
+       }
+       return 0;
+}
+#else
+#define ci13612_fixup_usbcmd_rs(_ehci) (0)
+#endif
+
+
+#ifdef CONFIG_LSI_USB_SW_WORKAROUND
+/*
+ * ci13612_fixup_txpburst
+ *
+ * Fix for HW errata 9000373951: You can adjust the burst size and fill the
+ * level to minimize under-run possibilities. In the failing case, the transfer
+ * size was 96 bytes, the burst size was 16, and the fill threshold level was
+ * set to 2. Because of this, the Host core issued the Out token when it
+ * requested the second burst of data. If the burst size had been changed to 8,
+ * and the fill level set to 3, then the core would have pre-fetched the 96
+ * bytes before issuing the OUT token.
+ */
+static void
+ci13612_fixup_txpburst(struct ehci_hcd *ehci)
+{
+       unsigned burst_size;
+
+       /* This workaround is not applicable to 3500 */
+       if ((of_find_compatible_node(NULL, NULL, "lsi,acp3500")
+               != NULL)
+               || (of_find_compatible_node(NULL, NULL, "lsi,axxia35xx")
+               != NULL)) {
+               return;
+       }
+
+       burst_size = ehci_readl(ehci, &ehci->regs->reserved1[1]);
+       burst_size = (burst_size & 0xffff00ff) | 0x4000;        /* TXPBURST */
+       ehci_writel(ehci, burst_size, &ehci->regs->reserved1[1]);
+}
+#else
+#define ci13612_fixup_txpburst(ehci) do { (void)ehci; } while (0)
+#endif
+
+static int ci13612_ehci_run(struct usb_hcd *hcd)
+{
+       struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+       int retval;
+       u32 tmp;
+
+       retval = ci13612_fixup_usbcmd_rs(ehci);
+       if (retval)
+               return retval;
+
+
+#ifndef CONFIG_LSI_USB_SW_WORKAROUND
+       /* Setup AMBA interface to force INCR16 busts when possible */
+       writel(3, USB_SBUSCFG);
+#endif
+
+       retval = ehci_run(hcd);
+       if (retval)
+               return retval;
+
+       ci13612_fixup_txpburst(ehci);
+
+#ifndef CONFIG_LSI_USB_SW_WORKAROUND
+       /* Set ITC (bits [23:16]) to zero for interrupt on every micro-frame */
+       tmp = ehci_readl(ehci, &ehci->regs->command);
+       tmp &= 0xFFFF;
+       ehci_writel(ehci, tmp & 0xFFFF, &ehci->regs->command);
+#endif
+
+       return retval;
+}
+
+static const struct hc_driver ci13612_hc_driver = {
+       .description            = "ci13612_hcd",
+       .product_desc           = "CI13612A EHCI USB Host Controller",
+       .hcd_priv_size          = sizeof(struct ehci_hcd),
+       .irq                    = ehci_irq,
+       .flags                  = HCD_MEMORY | HCD_USB2,
+       .reset                  = ci13612_ehci_init,
+       .start                  = ci13612_ehci_run,
+       .stop                   = ehci_stop,
+       .shutdown               = ehci_shutdown,
+       .urb_enqueue            = ehci_urb_enqueue,
+       .urb_dequeue            = ehci_urb_dequeue,
+       .endpoint_disable       = ehci_endpoint_disable,
+       .get_frame_number       = ehci_get_frame,
+       .hub_status_data        = ehci_hub_status_data,
+       .hub_control            = ehci_hub_control,
+#if defined(CONFIG_PM)
+       .bus_suspend            = ehci_bus_suspend,
+       .bus_resume             = ehci_bus_resume,
+#endif
+       .relinquish_port        = ehci_relinquish_port,
+       .port_handed_over       = ehci_port_handed_over,
+};
+
+static int ci13612_ehci_probe(struct platform_device *pdev)
+{
+       struct device_node *np = pdev->dev.of_node;
+       struct usb_hcd *hcd;
+       void __iomem *gpreg_base;
+       int irq;
+       int retval;
+       struct resource *res;
+
+       if (usb_disabled())
+               return -ENODEV;
+
+       irq = platform_get_irq(pdev, 0);
+       if (irq < 0) {
+               dev_dbg(&pdev->dev, "error getting irq number\n");
+               retval = irq;
+               goto fail_create_hcd;
+       }
+
+       if (0 != irq_set_irq_type(irq, IRQ_TYPE_LEVEL_HIGH)) {
+               dev_dbg(&pdev->dev, "set_irq_type() failed\n");
+               retval = -EBUSY;
+               goto fail_create_hcd;
+       }
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res) {
+               dev_err(&pdev->dev, "Error: resource addr %s setup!\n",
+                       dev_name(&pdev->dev));
+               return -ENODEV;
+       }
+
+
+#ifndef CONFIG_LSI_USB_SW_WORKAROUND
+       /* Device using 32-bit addressing */
+       pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+       pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
+#endif
+
+       hcd = usb_create_hcd(&ci13612_hc_driver,
+                       &pdev->dev, dev_name(&pdev->dev));
+       if (!hcd) {
+               retval = -ENOMEM;
+               goto fail_create_hcd;
+       }
+
+       hcd->rsrc_start = res->start;
+       hcd->rsrc_len = resource_size(res);
+
+       hcd->regs = of_iomap(np, 0);
+       if (!hcd->regs) {
+               dev_err(&pdev->dev, "of_iomap error\n");
+               retval = -ENOMEM;
+               goto fail_put_hcd;
+       }
+
+       gpreg_base = of_iomap(np, 1);
+       if (!gpreg_base) {
+               dev_warn(&pdev->dev, "of_iomap error can't map region 1\n");
+               retval = -ENOMEM;
+               goto fail_put_hcd;
+       } else {
+               /* Set address bits [39:32] to zero */
+               writel(0x0, gpreg_base + 0x8);
+#ifndef CONFIG_LSI_USB_SW_WORKAROUND
+               /* hprot cachable and bufferable */
+               writel(0xc, gpreg_base + 0x74);
+#endif
+               iounmap(gpreg_base);
+       }
+
+       retval = usb_add_hcd(hcd, irq, 0);
+       if (retval == 0) {
+               platform_set_drvdata(pdev, hcd);
+               return retval;
+       }
+
+fail_put_hcd:
+       usb_put_hcd(hcd);
+fail_create_hcd:
+       dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), retval);
+       return retval;
+}
+
+static int ci13612_ehci_remove(struct platform_device *pdev)
+{
+       struct usb_hcd *hcd = platform_get_drvdata(pdev);
+
+       usb_remove_hcd(hcd);
+       iounmap(hcd->regs);
+       usb_put_hcd(hcd);
+       platform_set_drvdata(pdev, NULL);
+
+       return 0;
+}
+
+static int ci13612_ehci_halt(struct ehci_hcd *ehci)
+{
+       u32     temp;
+
+       temp = ehci_readl(ehci, &ehci->regs->command);
+       temp &= ~CMD_RUN;
+       ehci_writel(ehci, temp, &ehci->regs->command);
+
+       return ehci_handshake(ehci, &ehci->regs->status,
+               STS_HALT, STS_HALT, 16 * 125);
+}
+
+MODULE_ALIAS("platform:ci13612-ehci");
+
+static struct of_device_id ci13612_match[] = {
+       {
+               .type   = "usb",
+               .compatible = "lsi,acp-usb",
+       },
+       {
+               .type   = "usb",
+               .compatible = "acp-usb",
+       },
+       {},
+};
+
+static struct platform_driver ci13612_ehci_driver = {
+       .probe = ci13612_ehci_probe,
+       .remove = ci13612_ehci_remove,
+       .driver = {
+               .name = "ci13612-ehci",
+               .of_match_table = ci13612_match,
+       },
+
+};
diff --git a/drivers/usb/host/ehci-ci13612.h b/drivers/usb/host/ehci-ci13612.h
new file mode 100644
index 0000000..7785bdd
--- /dev/null
+++ b/drivers/usb/host/ehci-ci13612.h
@@ -0,0 +1,48 @@
+/*
+ * Host interface registers
+ */
+
+/* define CI13612 USB registers here */
+#define CI13612_USB_BASE       (hcd->regs)
+
+#define USB_ID                 (CI13612_USB_BASE + 0x0000)
+#define USB_HWGENERAL          (CI13612_USB_BASE + 0x0004)
+#define USB_HWHOST             (CI13612_USB_BASE + 0x0008)
+#define USB_HWDEVICE           (CI13612_USB_BASE + 0x000C)
+#define USB_HWTXBUF            (CI13612_USB_BASE + 0x0010)
+#define USB_HWRXBUF            (CI13612_USB_BASE + 0x0014)
+#define USB_GPTIMER0LD         (CI13612_USB_BASE + 0x0080)
+#define USB_GPTIMER0CTRL       (CI13612_USB_BASE + 0x0084)
+#define USB_GPTIMER1LD         (CI13612_USB_BASE + 0x0088)
+#define USB_GPTIMER1CTRL       (CI13612_USB_BASE + 0x008c)
+#define USB_SBUSCFG            (CI13612_USB_BASE + 0x0090)
+
+#define USB_CAPLENGTH          (CI13612_USB_BASE + 0x0100) /* 8 bit */
+#define USB_HCIVERSION         (CI13612_USB_BASE + 0x0102) /* 16 bit */
+#define USB_HCSPARAMS          (CI13612_USB_BASE + 0x0104)
+#define USB_HCCPARAMS          (CI13612_USB_BASE + 0x0108)
+#define USB_DCIVERSION         (CI13612_USB_BASE + 0x0120) /* 16 bit */
+#define USB_DCCPARAMS          (CI13612_USB_BASE + 0x0124)
+#define USB_USBCMD             (CI13612_USB_BASE + 0x0140)
+#define USB_USBSTS             (CI13612_USB_BASE + 0x0144)
+#define USB_USBINTR            (CI13612_USB_BASE + 0x0148)
+#define USB_FRINDEX            (CI13612_USB_BASE + 0x014C)
+#define USB_DEVICEADDR         (CI13612_USB_BASE + 0x0154)
+#define USB_ENDPOINTLISTADDR   (CI13612_USB_BASE + 0x0158)
+#define USB_TTCTRL             (CI13612_USB_BASE + 0x015C)
+#define USB_BURSTSIZE          (CI13612_USB_BASE + 0x0160)
+#define USB_TXFILLTUNING       (CI13612_USB_BASE + 0x0164)
+#define USB_ICUSB              (CI13612_USB_BASE + 0x016C)
+#define USB_ULPI_VIEWPORT      (CI13612_USB_BASE + 0x0170)
+#define USB_ENDPTNAK           (CI13612_USB_BASE + 0x0178)
+#define USB_ENDPTNAKEN         (CI13612_USB_BASE + 0x017C)
+#define USB_CONFIGFLAG         (CI13612_USB_BASE + 0x0180)
+#define USB_PORTSC             (CI13612_USB_BASE + 0x0184)
+#define USB_OTGSC              (CI13612_USB_BASE + 0x01A4)
+#define USB_USBMODE            (CI13612_USB_BASE + 0x01A8)
+#define USB_ENDPTSETUPSTAT     (CI13612_USB_BASE + 0x01AC)
+#define USB_ENDPTPRIME         (CI13612_USB_BASE + 0x01B0)
+#define USB_ENDPTFLUSH         (CI13612_USB_BASE + 0x01B4)
+#define USB_ENDPTSTAT          (CI13612_USB_BASE + 0x01B8)
+#define USB_ENDPTCOMPLETE      (CI13612_USB_BASE + 0x01BC)
+#define USB_ENDPTCTRL(n)       (CI13612_USB_BASE + 0x01C0 + (4 * (n)))
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 38bfeed..211d951 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -68,7 +68,7 @@
 #define DRIVER_AUTHOR "David Brownell"
 #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver"
 
-static const char      hcd_name [] = "ehci_hcd";
+static const char      hcd_name[] = "ehci_hcd";
 
 
 #undef EHCI_URB_TRACE
@@ -88,19 +88,19 @@ static const char   hcd_name [] = "ehci_hcd";
 #define        EHCI_TUNE_FLS           1       /* (medium) 512-frame schedule 
*/
 
 /* Initial IRQ latency:  faster than hw default */
-static int log2_irq_thresh = 0;                // 0 to 6
-module_param (log2_irq_thresh, int, S_IRUGO);
-MODULE_PARM_DESC (log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");
+static int log2_irq_thresh;            /* 0 to 6 */
+module_param(log2_irq_thresh, int, S_IRUGO);
+MODULE_PARM_DESC(log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");
 
 /* initial park setting:  slower than hw default */
-static unsigned park = 0;
-module_param (park, uint, S_IRUGO);
-MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets");
+static unsigned park;
+module_param(park, uint, S_IRUGO);
+MODULE_PARM_DESC(park, "park setting; 1-3 back-to-back async packets");
 
 /* for flakey hardware, ignore overcurrent indicators */
-static bool ignore_oc = 0;
-module_param (ignore_oc, bool, S_IRUGO);
-MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
+static bool ignore_oc;
+module_param(ignore_oc, bool, S_IRUGO);
+MODULE_PARM_DESC(ignore_oc, "ignore bogus hardware overcurrent indications");
 
 #define        INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
 
@@ -169,7 +169,7 @@ int ehci_handshake(struct ehci_hcd *ehci, void __iomem *ptr,
                result &= mask;
                if (result == done)
                        return 0;
-               udelay (1);
+               udelay(1);
                usec--;
        } while (usec > 0);
        return -ETIMEDOUT;
@@ -177,7 +177,7 @@ int ehci_handshake(struct ehci_hcd *ehci, void __iomem *ptr,
 EXPORT_SYMBOL_GPL(ehci_handshake);
 
 /* check TDI/ARC silicon is in host mode */
-static int tdi_in_host_mode (struct ehci_hcd *ehci)
+static int tdi_in_host_mode(struct ehci_hcd *ehci)
 {
        u32             tmp;
 
@@ -189,7 +189,7 @@ static int tdi_in_host_mode (struct ehci_hcd *ehci)
  * Force HC to halt state from unknown (EHCI spec section 2.3).
  * Must be called with interrupts enabled and the lock not held.
  */
-static int ehci_halt (struct ehci_hcd *ehci)
+static int ehci_halt(struct ehci_hcd *ehci)
 {
        u32     temp;
 
@@ -220,7 +220,7 @@ static int ehci_halt (struct ehci_hcd *ehci)
 }
 
 /* put TDI/ARC silicon into EHCI mode */
-static void tdi_reset (struct ehci_hcd *ehci)
+static void tdi_reset(struct ehci_hcd *ehci)
 {
        u32             tmp;
 
@@ -239,7 +239,7 @@ static void tdi_reset (struct ehci_hcd *ehci)
  * Reset a non-running (STS_HALT == 1) controller.
  * Must be called with interrupts enabled and the lock not held.
  */
-static int ehci_reset (struct ehci_hcd *ehci)
+static int ehci_reset(struct ehci_hcd *ehci)
 {
        int     retval;
        u32     command = ehci_readl(ehci, &ehci->regs->command);
@@ -250,7 +250,7 @@ static int ehci_reset (struct ehci_hcd *ehci)
                ehci->debug = NULL;
 
        command |= CMD_RESET;
-       dbg_cmd (ehci, "reset", command);
+       dbg_cmd(ehci, "reset", command);
        ehci_writel(ehci, command, &ehci->regs->command);
        ehci->rh_state = EHCI_RH_HALTED;
        ehci->next_statechange = jiffies;
@@ -266,7 +266,7 @@ static int ehci_reset (struct ehci_hcd *ehci)
                return retval;
 
        if (ehci_is_TDI(ehci))
-               tdi_reset (ehci);
+               tdi_reset(ehci);
 
        if (ehci->debug)
                dbgp_external_startup(ehci_to_hcd(ehci));
@@ -280,7 +280,7 @@ static int ehci_reset (struct ehci_hcd *ehci)
  * Idle the controller (turn off the schedules).
  * Must be called with interrupts enabled and the lock not held.
  */
-static void ehci_quiesce (struct ehci_hcd *ehci)
+static void ehci_quiesce(struct ehci_hcd *ehci)
 {
        u32     temp;
 
@@ -384,7 +384,7 @@ static void ehci_shutdown(struct usb_hcd *hcd)
  * ehci_work is called from some interrupts, timers, and so on.
  * it calls driver completion functions, after dropping ehci->lock.
  */
-static void ehci_work (struct ehci_hcd *ehci)
+static void ehci_work(struct ehci_hcd *ehci)
 {
        /* another CPU may drop ehci->lock during a schedule scan while
         * it reports urb completions.  this flag guards against bogus
@@ -418,11 +418,11 @@ static void ehci_work (struct ehci_hcd *ehci)
 /*
  * Called when the ehci_hcd module is removed.
  */
-static void ehci_stop (struct usb_hcd *hcd)
+static void ehci_stop(struct usb_hcd *hcd)
 {
-       struct ehci_hcd         *ehci = hcd_to_ehci (hcd);
+       struct ehci_hcd         *ehci = hcd_to_ehci(hcd);
 
-       ehci_dbg (ehci, "stop\n");
+       ehci_dbg(ehci, "stop\n");
 
        /* no more interrupts ... */
 
@@ -432,22 +432,22 @@ static void ehci_stop (struct usb_hcd *hcd)
 
        ehci_quiesce(ehci);
        ehci_silence_controller(ehci);
-       ehci_reset (ehci);
+       ehci_reset(ehci);
 
        hrtimer_cancel(&ehci->hrtimer);
        remove_sysfs_files(ehci);
-       remove_debug_files (ehci);
+       remove_debug_files(ehci);
 
        /* root hub is shut down separately (first, when possible) */
-       spin_lock_irq (&ehci->lock);
+       spin_lock_irq(&ehci->lock);
        end_free_itds(ehci);
-       spin_unlock_irq (&ehci->lock);
-       ehci_mem_cleanup (ehci);
+       spin_unlock_irq(&ehci->lock);
+       ehci_mem_cleanup(ehci);
 
        if (ehci->amd_pll_fix == 1)
                usb_amd_dev_put();
 
-       dbg_status (ehci, "ehci_stop completed",
+       dbg_status(ehci, "ehci_stop completed",
                    ehci_readl(ehci, &ehci->regs->status));
 }
 
@@ -496,19 +496,27 @@ static int ehci_init(struct usb_hcd *hcd)
        if (HCC_PGM_FRAMELISTLEN(hcc_params)) {
                /* periodic schedule size can be smaller than default */
                switch (EHCI_TUNE_FLS) {
-               case 0: ehci->periodic_size = 1024; break;
-               case 1: ehci->periodic_size = 512; break;
-               case 2: ehci->periodic_size = 256; break;
-               default:        BUG();
+               case 0:
+                       ehci->periodic_size = 1024;
+                       break;
+               case 1:
+                       ehci->periodic_size = 512;
+                       break;
+               case 2:
+                       ehci->periodic_size = 256;
+                       break;
+               default:
+                       BUG();
                }
        }
-       if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0)
+       retval = ehci_mem_init(ehci, GFP_KERNEL);
+       if (retval < 0)
                return retval;
 
        /* controllers may cache some of the periodic schedule ... */
-       if (HCC_ISOC_CACHE(hcc_params))         // full frame cache
+       if (HCC_ISOC_CACHE(hcc_params))         /* full frame cache */
                ehci->i_thresh = 0;
-       else                                    // N microframes cached
+       else                                    /* N microframes cached */
                ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
 
        /*
@@ -568,9 +576,9 @@ static int ehci_init(struct usb_hcd *hcd)
 }
 
 /* start HC running; it's halted, ehci_init() has been run (once) */
-static int ehci_run (struct usb_hcd *hcd)
+static int ehci_run(struct usb_hcd *hcd)
 {
-       struct ehci_hcd         *ehci = hcd_to_ehci (hcd);
+       struct ehci_hcd         *ehci = hcd_to_ehci(hcd);
        u32                     temp;
        u32                     hcc_params;
 
@@ -597,19 +605,21 @@ static int ehci_run (struct usb_hcd *hcd)
        if (HCC_64BIT_ADDR(hcc_params)) {
                ehci_writel(ehci, 0, &ehci->regs->segment);
 #if 0
-// this is deeply broken on almost all architectures
+/* this is deeply broken on almost all architectures */
                if (!dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64)))
                        ehci_info(ehci, "enabled 64bit DMA\n");
 #endif
        }
 
 
-       // Philips, Intel, and maybe others need CMD_RUN before the
-       // root hub will detect new devices (why?); NEC doesn't
+       /*
+        * Philips, Intel, and maybe others need CMD_RUN before the
+        * root hub will detect new devices (why?); NEC doesn't
+        */
        ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
        ehci->command |= CMD_RUN;
        ehci_writel(ehci, ehci->command, &ehci->regs->command);
-       dbg_cmd (ehci, "init", ehci->command);
+       dbg_cmd(ehci, "init", ehci->command);
 
        /*
         * Start, enabling full USB 2.0 functionality ... usb 1.1 devices
@@ -634,7 +644,7 @@ static int ehci_run (struct usb_hcd *hcd)
        ehci->last_periodic_enable = ktime_get_real();
 
        temp = HC_VERSION(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
-       ehci_info (ehci,
+       ehci_info(ehci,
                "USB %x.%x started, EHCI %x.%02x%s\n",
                ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
                temp >> 8, temp & 0xff,
@@ -685,9 +695,9 @@ EXPORT_SYMBOL_GPL(ehci_setup);
 
 /*-------------------------------------------------------------------------*/
 
-static irqreturn_t ehci_irq (struct usb_hcd *hcd)
+static irqreturn_t ehci_irq(struct usb_hcd *hcd)
 {
-       struct ehci_hcd         *ehci = hcd_to_ehci (hcd);
+       struct ehci_hcd         *ehci = hcd_to_ehci(hcd);
        u32                     status, masked_status, pcd_status = 0, cmd;
        int                     bh;
        unsigned long           flags;
@@ -704,7 +714,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
 
        /* e.g. cardbus physical eject */
        if (status == ~(u32) 0) {
-               ehci_dbg (ehci, "device removed\n");
+               ehci_dbg(ehci, "device removed\n");
                goto dead;
        }
 
@@ -726,11 +736,11 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
        bh = 0;
 
        /* normal [4.15.1.2] or error [4.15.1.1] completion */
-       if (likely ((status & (STS_INT|STS_ERR)) != 0)) {
-               if (likely ((status & STS_ERR) == 0))
-                       COUNT (ehci->stats.normal);
+       if (likely((status & (STS_INT|STS_ERR)) != 0)) {
+               if (likely((status & STS_ERR) == 0))
+                       COUNT(ehci->stats.normal);
                else
-                       COUNT (ehci->stats.error);
+                       COUNT(ehci->stats.error);
                bh = 1;
        }
 
@@ -760,7 +770,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
 
        /* remote wakeup [4.3.1] */
        if (status & STS_PCD) {
-               unsigned        i = HCS_N_PORTS (ehci->hcs_params);
+               unsigned        i = HCS_N_PORTS(ehci->hcs_params);
                u32             ppcd = ~0;
 
                /* kick root hub later */
@@ -799,14 +809,14 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
                         */
                        ehci->reset_done[i] = jiffies + msecs_to_jiffies(25);
                        set_bit(i, &ehci->resuming_ports);
-                       ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
+                       ehci_dbg(ehci, "port %d remote wakeup\n", i + 1);
                        usb_hcd_start_port_resume(&hcd->self, i);
                        mod_timer(&hcd->rh_timer, ehci->reset_done[i]);
                }
        }
 
        /* PCI errors [4.15.2.4] */
-       if (unlikely ((status & STS_FATAL) != 0)) {
+       if (unlikely((status & STS_FATAL) != 0)) {
                ehci_err(ehci, "fatal error\n");
                dbg_cmd(ehci, "fatal", cmd);
                dbg_status(ehci, "fatal", status);
@@ -826,7 +836,7 @@ dead:
        }
 
        if (bh)
-               ehci_work (ehci);
+               ehci_work(ehci);
        spin_unlock_irqrestore(&ehci->lock, flags);
        if (pcd_status)
                usb_hcd_poll_rh_status(hcd);
@@ -847,17 +857,17 @@ dead:
  * NOTE:  control, bulk, and interrupt share the same code to append TDs
  * to a (possibly active) QH, and the same QH scanning code.
  */
-static int ehci_urb_enqueue (
+static int ehci_urb_enqueue(
        struct usb_hcd  *hcd,
        struct urb      *urb,
        gfp_t           mem_flags
 ) {
-       struct ehci_hcd         *ehci = hcd_to_ehci (hcd);
+       struct ehci_hcd         *ehci = hcd_to_ehci(hcd);
        struct list_head        qtd_list;
 
-       INIT_LIST_HEAD (&qtd_list);
+       INIT_LIST_HEAD(&qtd_list);
 
-       switch (usb_pipetype (urb->pipe)) {
+       switch (usb_pipetype(urb->pipe)) {
        case PIPE_CONTROL:
                /* qh_completions() code doesn't handle all the fault cases
                 * in multi-TD control transfers.  Even 1KB is rare anyway.
@@ -867,20 +877,20 @@ static int ehci_urb_enqueue (
                /* FALLTHROUGH */
        /* case PIPE_BULK: */
        default:
-               if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
+               if (!qh_urb_transaction(ehci, urb, &qtd_list, mem_flags))
                        return -ENOMEM;
                return submit_async(ehci, urb, &qtd_list, mem_flags);
 
        case PIPE_INTERRUPT:
-               if (!qh_urb_transaction (ehci, urb, &qtd_list, mem_flags))
+               if (!qh_urb_transaction(ehci, urb, &qtd_list, mem_flags))
                        return -ENOMEM;
                return intr_submit(ehci, urb, &qtd_list, mem_flags);
 
        case PIPE_ISOCHRONOUS:
                if (urb->dev->speed == USB_SPEED_HIGH)
-                       return itd_submit (ehci, urb, mem_flags);
+                       return itd_submit(ehci, urb, mem_flags);
                else
-                       return sitd_submit (ehci, urb, mem_flags);
+                       return sitd_submit(ehci, urb, mem_flags);
        }
 }
 
@@ -890,12 +900,12 @@ static int ehci_urb_enqueue (
 
 static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 {
-       struct ehci_hcd         *ehci = hcd_to_ehci (hcd);
+       struct ehci_hcd         *ehci = hcd_to_ehci(hcd);
        struct ehci_qh          *qh;
        unsigned long           flags;
        int                     rc;
 
-       spin_lock_irqsave (&ehci->lock, flags);
+       spin_lock_irqsave(&ehci->lock, flags);
        rc = usb_hcd_check_unlink_urb(hcd, urb, status);
        if (rc)
                goto done;
@@ -930,18 +940,18 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
                }
        }
 done:
-       spin_unlock_irqrestore (&ehci->lock, flags);
+       spin_unlock_irqrestore(&ehci->lock, flags);
        return rc;
 }
 
 /*-------------------------------------------------------------------------*/
 
-// bulk qh holds the data toggle
+/* bulk qh holds the data toggle */
 
 static void
-ehci_endpoint_disable (struct usb_hcd *hcd, struct usb_host_endpoint *ep)
+ehci_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
 {
-       struct ehci_hcd         *ehci = hcd_to_ehci (hcd);
+       struct ehci_hcd         *ehci = hcd_to_ehci(hcd);
        unsigned long           flags;
        struct ehci_qh          *qh;
 
@@ -949,7 +959,7 @@ ehci_endpoint_disable (struct usb_hcd *hcd, struct 
usb_host_endpoint *ep)
        /* ASSERT:  nobody can be submitting urbs for this any more */
 
 rescan:
-       spin_lock_irqsave (&ehci->lock, flags);
+       spin_lock_irqsave(&ehci->lock, flags);
        qh = ep->hcpriv;
        if (!qh)
                goto done;
@@ -982,13 +992,13 @@ rescan:
        case QH_STATE_UNLINK:           /* wait for hw to finish? */
        case QH_STATE_UNLINK_WAIT:
 idle_timeout:
-               spin_unlock_irqrestore (&ehci->lock, flags);
+               spin_unlock_irqrestore(&ehci->lock, flags);
                schedule_timeout_uninterruptible(1);
                goto rescan;
        case QH_STATE_IDLE:             /* fully unlinked */
                if (qh->clearing_tt)
                        goto idle_timeout;
-               if (list_empty (&qh->qtd_list)) {
+               if (list_empty(&qh->qtd_list)) {
                        if (qh->ps.bw_uperiod)
                                reserve_release_intr_bandwidth(ehci, qh, -1);
                        qh_destroy(ehci, qh);
@@ -999,14 +1009,14 @@ idle_timeout:
                /* caller was supposed to have unlinked any requests;
                 * that's not our job.  just leak this memory.
                 */
-               ehci_err (ehci, "qh %p (#%02x) state %d%s\n",
+               ehci_err(ehci, "qh %p (#%02x) state %d%s\n",
                        qh, ep->desc.bEndpointAddress, qh->qh_state,
-                       list_empty (&qh->qtd_list) ? "" : "(has tds)");
+                       list_empty(&qh->qtd_list) ? "" : "(has tds)");
                break;
        }
  done:
        ep->hcpriv = NULL;
-       spin_unlock_irqrestore (&ehci->lock, flags);
+       spin_unlock_irqrestore(&ehci->lock, flags);
 }
 
 static void
@@ -1049,9 +1059,10 @@ ehci_endpoint_reset(struct usb_hcd *hcd, struct 
usb_host_endpoint *ep)
        spin_unlock_irqrestore(&ehci->lock, flags);
 }
 
-static int ehci_get_frame (struct usb_hcd *hcd)
+static int ehci_get_frame(struct usb_hcd *hcd)
 {
-       struct ehci_hcd         *ehci = hcd_to_ehci (hcd);
+       struct ehci_hcd         *ehci = hcd_to_ehci(hcd);
+
        return (ehci_read_frame_index(ehci) >> 3) % ehci->periodic_size;
 }
 
@@ -1247,8 +1258,8 @@ EXPORT_SYMBOL_GPL(ehci_init_driver);
 /*-------------------------------------------------------------------------*/
 
 MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_AUTHOR (DRIVER_AUTHOR);
-MODULE_LICENSE ("GPL");
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_LICENSE("GPL");
 
 #ifdef CONFIG_USB_EHCI_FSL
 #include "ehci-fsl.c"
@@ -1300,6 +1311,11 @@ MODULE_LICENSE ("GPL");
 #define        PLATFORM_DRIVER         ehci_hcd_sead3_driver
 #endif
 
+#ifdef CONFIG_USB_CI13612_HCD
+#include "ehci-ci13612.c"
+#define PLATFORM_DRIVER        ci13612_ehci_driver
+#endif
+
 static int __init ehci_hcd_init(void)
 {
        int retval = 0;
@@ -1307,11 +1323,11 @@ static int __init ehci_hcd_init(void)
        if (usb_disabled())
                return -ENODEV;
 
-       printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name);
+       pr_info("%s: " DRIVER_DESC "\n", hcd_name);
        set_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
        if (test_bit(USB_UHCI_LOADED, &usb_hcds_loaded) ||
                        test_bit(USB_OHCI_LOADED, &usb_hcds_loaded))
-               printk(KERN_WARNING "Warning! ehci_hcd should always be loaded"
+               pr_warn("Warning! ehci_hcd should always be loaded"
                                " before uhci_hcd and ohci_hcd, not after\n");
 
        pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
@@ -1330,7 +1346,9 @@ static int __init ehci_hcd_init(void)
 #ifdef PLATFORM_DRIVER
        retval = platform_driver_register(&PLATFORM_DRIVER);
        if (retval < 0)
+       {
                goto clean0;
+       }
 #endif
 
 #ifdef PS3_SYSTEM_BUS_DRIVER
-- 
1.7.9.5

-- 
_______________________________________________
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to