]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/usb/musb-new/musb_core.c
Merge branch 'master' of git://git.denx.de/u-boot-sunxi
[people/ms/u-boot.git] / drivers / usb / musb-new / musb_core.c
index da9357149bc6c9bb8a56fb5aba2d8de6f50de236..79e118ef856c503dcc134097153c4f9bdd5960b8 100644 (file)
@@ -5,31 +5,7 @@
  * Copyright (C) 2005-2006 by Texas Instruments
  * Copyright (C) 2006-2007 Nokia Corporation
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * 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., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ * SPDX-License-Identifier:    GPL-2.0
  */
 
 /*
@@ -89,7 +65,6 @@
  * Most of the conditional compilation will (someday) vanish.
  */
 
-#define __UBOOT__
 #ifndef __UBOOT__
 #include <linux/module.h>
 #include <linux/kernel.h>
 #else
 #include <common.h>
 #include <usb.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/musb.h>
@@ -141,12 +116,9 @@ static inline struct musb *dev_to_musb(struct device *dev)
 {
        return dev_get_drvdata(dev);
 }
-#endif
 
 /*-------------------------------------------------------------------------*/
 
-#ifndef __UBOOT__
-#ifndef CONFIG_BLACKFIN
 static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
 {
        void __iomem *addr = phy->io_priv;
@@ -228,10 +200,6 @@ out:
 
        return ret;
 }
-#else
-#define musb_ulpi_read         NULL
-#define musb_ulpi_write                NULL
-#endif
 
 static struct usb_phy_io_ops musb_ulpi_access = {
        .read = musb_ulpi_read,
@@ -241,7 +209,7 @@ static struct usb_phy_io_ops musb_ulpi_access = {
 
 /*-------------------------------------------------------------------------*/
 
-#if !defined(CONFIG_USB_MUSB_TUSB6010) && !defined(CONFIG_USB_MUSB_BLACKFIN)
+#if !defined(CONFIG_USB_MUSB_TUSB6010)
 
 /*
  * Load an endpoint's FIFO
@@ -284,7 +252,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
        }
 }
 
-#if !defined(CONFIG_USB_MUSB_AM35X)
+#if !defined(CONFIG_USB_MUSB_AM35X) && !defined(CONFIG_USB_MUSB_PIC32)
 /*
  * Unload an endpoint's FIFO
  */
@@ -927,10 +895,17 @@ b_host:
 /*
 * Program the HDRC to start (enable interrupts, dma, etc.).
 */
+#ifndef __UBOOT__
 void musb_start(struct musb *musb)
+#else
+int musb_start(struct musb *musb)
+#endif
 {
        void __iomem    *regs = musb->mregs;
        u8              devctl = musb_readb(regs, MUSB_DEVCTL);
+#ifdef __UBOOT__
+       int ret;
+#endif
 
        dev_dbg(musb->controller, "<== devctl %02x\n", devctl);
 
@@ -943,9 +918,7 @@ void musb_start(struct musb *musb)
 
        /* put into basic highspeed mode and start session */
        musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
-#ifdef CONFIG_USB_GADGET_DUALSPEED
                                                | MUSB_POWER_HSENAB
-#endif
                                                /* ENSUSPEND wedges tusb */
                                                /* | MUSB_POWER_ENSUSPEND */
                                                );
@@ -975,8 +948,21 @@ void musb_start(struct musb *musb)
                if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
                        musb->is_active = 1;
        }
+
+#ifndef __UBOOT__
        musb_platform_enable(musb);
+#else
+       ret = musb_platform_enable(musb);
+       if (ret) {
+               musb->is_active = 0;
+               return ret;
+       }
+#endif
        musb_writeb(regs, MUSB_DEVCTL, devctl);
+
+#ifdef __UBOOT__
+       return 0;
+#endif
 }
 
 
@@ -1311,9 +1297,7 @@ static int __devinit ep_config_from_table(struct musb *musb)
                break;
        }
 
-       printk(KERN_DEBUG "%s: setup fifo_mode %d\n",
-                       musb_driver_name, fifo_mode);
-
+       pr_debug("%s: setup fifo_mode %d\n", musb_driver_name, fifo_mode);
 
 done:
        offset = fifo_setup(musb, hw_ep, &ep0_cfg, 0);
@@ -1341,10 +1325,9 @@ done:
                musb->nr_endpoints = max(epn, musb->nr_endpoints);
        }
 
-       printk(KERN_DEBUG "%s: %d/%d max ep, %d/%d memory\n",
-                       musb_driver_name,
-                       n + 1, musb->config->num_eps * 2 - 1,
-                       offset, (1 << (musb->config->ram_bits + 2)));
+       pr_debug("%s: %d/%d max ep, %d/%d memory\n", musb_driver_name, n + 1,
+                musb->config->num_eps * 2 - 1, offset,
+                (1 << (musb->config->ram_bits + 2)));
 
        if (!musb->bulk_ep) {
                pr_debug("%s: missing bulk\n", musb_driver_name);
@@ -1423,7 +1406,7 @@ static int __devinit musb_core_init(u16 musb_type, struct musb *musb)
                strcat(aInfo, ", dyn FIFOs");
                musb->dyn_fifo = true;
        }
-#ifndef CONFIG_MUSB_DISABLE_BULK_COMBINE_SPLIT
+#ifndef CONFIG_USB_MUSB_DISABLE_BULK_COMBINE_SPLIT
        if (reg & MUSB_CONFIGDATA_MPRXE) {
                strcat(aInfo, ", bulk combine");
                musb->bulk_combine = true;
@@ -1447,8 +1430,7 @@ static int __devinit musb_core_init(u16 musb_type, struct musb *musb)
        if (reg & MUSB_CONFIGDATA_SOFTCONE)
                strcat(aInfo, ", SoftConn");
 
-       printk(KERN_DEBUG "%s: ConfigData=0x%02x (%s)\n",
-                       musb_driver_name, reg, aInfo);
+       pr_debug("%s:ConfigData=0x%02x (%s)\n", musb_driver_name, reg, aInfo);
 
        aDate[0] = 0;
        if (MUSB_CONTROLLER_MHDRC == musb_type) {
@@ -1469,8 +1451,8 @@ static int __devinit musb_core_init(u16 musb_type, struct musb *musb)
        snprintf(aRevision, 32, "%d.%d%s", MUSB_HWVERS_MAJOR(musb->hwvers),
                MUSB_HWVERS_MINOR(musb->hwvers),
                (musb->hwvers & MUSB_HWVERS_RC) ? "RC" : "");
-       printk(KERN_DEBUG "%s: %sHDRC RTL version %s %s\n",
-                       musb_driver_name, type, aRevision, aDate);
+       pr_debug("%s: %sHDRC RTL version %s %s\n", musb_driver_name, type,
+                aRevision, aDate);
 
        /* configure ep0 */
        musb_configure_ep0(musb);
@@ -1537,7 +1519,7 @@ static int __devinit musb_core_init(u16 musb_type, struct musb *musb)
 /*-------------------------------------------------------------------------*/
 
 #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430) || \
-       defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_ARCH_U8500)
+       defined(CONFIG_ARCH_OMAP4)
 
 static irqreturn_t generic_interrupt(int irq, void *__hci)
 {
@@ -1649,7 +1631,7 @@ irqreturn_t musb_interrupt(struct musb *musb)
 }
 EXPORT_SYMBOL_GPL(musb_interrupt);
 
-#ifndef CONFIG_MUSB_PIO_ONLY
+#ifndef CONFIG_USB_MUSB_PIO_ONLY
 static bool __devinitdata use_dma = 1;
 
 /* "modprobe ... use_dma=0" etc */
@@ -1998,7 +1980,7 @@ musb_init_controller(struct musb_hdrc_platform_data *plat, struct device *dev,
 
        pm_runtime_get_sync(musb->controller);
 
-#ifndef CONFIG_MUSB_PIO_ONLY
+#ifndef CONFIG_USB_MUSB_PIO_ONLY
        if (use_dma && dev->dma_mask) {
                struct dma_controller   *c;
 
@@ -2122,7 +2104,7 @@ musb_init_controller(struct musb_hdrc_platform_data *plat, struct device *dev,
 
        pm_runtime_put(musb->controller);
 
-       dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n",
+       pr_debug("USB %s mode controller at %p using %s, IRQ %d\n",
                        ({char *s;
                         switch (musb->board_mode) {
                         case MUSB_HOST:                s = "Host"; break;
@@ -2181,7 +2163,7 @@ fail0:
  * bridge to a platform device; this driver then suffices.
  */
 
-#ifndef CONFIG_MUSB_PIO_ONLY
+#ifndef CONFIG_USB_MUSB_PIO_ONLY
 static u64     *orig_dma_mask;
 #endif
 
@@ -2204,7 +2186,7 @@ static int __devinit musb_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-#ifndef CONFIG_MUSB_PIO_ONLY
+#ifndef CONFIG_USB_MUSB_PIO_ONLY
        /* clobbered by use_dma=n */
        orig_dma_mask = dev->dma_mask;
 #endif
@@ -2231,7 +2213,7 @@ static int __devexit musb_remove(struct platform_device *pdev)
        musb_free(musb);
        iounmap(ctrl_base);
        device_init_wakeup(&pdev->dev, 0);
-#ifndef CONFIG_MUSB_PIO_ONLY
+#ifndef CONFIG_USB_MUSB_PIO_ONLY
        pdev->dev.dma_mask = orig_dma_mask;
 #endif
        return 0;