usb: mx6: add fuse check
[oweals/u-boot.git] / drivers / usb / host / ehci-fsl.c
index 17d1fae3829d4d51dd1f9767800d810763933798..ced295ef0fa40166228b1360f6f4b8364fb3352e 100644 (file)
@@ -1,14 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2009, 2011, 2016 Freescale Semiconductor, Inc.
  *
  * (C) Copyright 2008, Excito Elektronik i Sk=E5ne AB
  *
  * Author: Tor Krill tor@excito.com
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <env.h>
 #include <pci.h>
 #include <usb.h>
 #include <asm/io.h>
@@ -26,7 +26,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
 #endif
 
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
 struct ehci_fsl_priv {
        struct ehci_ctrl ehci;
        fdt_addr_t hcd_base;
@@ -35,7 +35,7 @@ struct ehci_fsl_priv {
 #endif
 
 static void set_txfifothresh(struct usb_ehci *, u32);
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
 static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci,
                  struct ehci_hccr *hccr, struct ehci_hcor *hcor);
 #else
@@ -55,7 +55,7 @@ static int usb_phy_clk_valid(struct usb_ehci *ehci)
        }
 }
 
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
 static int ehci_fsl_ofdata_to_platdata(struct udevice *dev)
 {
        struct ehci_fsl_priv *priv = dev_get_priv(dev);
@@ -76,8 +76,12 @@ static int ehci_fsl_init_after_reset(struct ehci_ctrl *ctrl)
        struct usb_ehci *ehci = NULL;
        struct ehci_fsl_priv *priv = container_of(ctrl, struct ehci_fsl_priv,
                                                   ehci);
-
+#ifdef CONFIG_PPC
+       ehci = (struct usb_ehci *)lower_32_bits(priv->hcd_base);
+#else
        ehci = (struct usb_ehci *)priv->hcd_base;
+#endif
+
        if (ehci_fsl_init(priv, ehci, priv->ehci.hccr, priv->ehci.hcor) < 0)
                return -ENXIO;
 
@@ -94,6 +98,7 @@ static int ehci_fsl_probe(struct udevice *dev)
        struct usb_ehci *ehci = NULL;
        struct ehci_hccr *hccr;
        struct ehci_hcor *hcor;
+       struct ehci_ctrl *ehci_ctrl = &priv->ehci;
 
        /*
         * Get the base address for EHCI controller from the device node
@@ -103,11 +108,17 @@ static int ehci_fsl_probe(struct udevice *dev)
                debug("Can't get the EHCI register base address\n");
                return -ENXIO;
        }
+#ifdef CONFIG_PPC
+       ehci = (struct usb_ehci *)lower_32_bits(priv->hcd_base);
+#else
        ehci = (struct usb_ehci *)priv->hcd_base;
+#endif
        hccr = (struct ehci_hccr *)(&ehci->caplength);
        hcor = (struct ehci_hcor *)
                ((void *)hccr + HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
 
+       ehci_ctrl->has_fsl_erratum_a005275 = has_erratum_a005275();
+
        if (ehci_fsl_init(priv, ehci, hccr, hcor) < 0)
                return -ENXIO;
 
@@ -146,6 +157,8 @@ U_BOOT_DRIVER(ehci_fsl) = {
 int ehci_hcd_init(int index, enum usb_init_type init,
                struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
+       struct ehci_ctrl *ehci_ctrl = container_of(hccr,
+                                       struct ehci_ctrl, hccr);
        struct usb_ehci *ehci = NULL;
 
        switch (index) {
@@ -164,6 +177,8 @@ int ehci_hcd_init(int index, enum usb_init_type init,
        *hcor = (struct ehci_hcor *)((uint32_t) *hccr +
                        HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
 
+       ehci_ctrl->has_fsl_erratum_a005275 = has_erratum_a005275();
+
        return ehci_fsl_init(index, ehci, *hccr, *hcor);
 }
 
@@ -177,7 +192,7 @@ int ehci_hcd_stop(int index)
 }
 #endif
 
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
 static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci,
                  struct ehci_hccr *hccr, struct ehci_hcor *hcor)
 #else
@@ -186,7 +201,7 @@ static int ehci_fsl_init(int index, struct usb_ehci *ehci,
 #endif
 {
        const char *phy_type = NULL;
-#ifndef CONFIG_DM_USB
+#if !CONFIG_IS_ENABLED(DM_USB)
        size_t len;
        char current_usb_controller[5];
 #endif
@@ -212,7 +227,7 @@ static int ehci_fsl_init(int index, struct usb_ehci *ehci,
        out_be32(&ehci->snoop2, 0x80000000 | SNOOP_SIZE_2GB);
 
        /* Init phy */
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
        if (priv->phy_type)
                phy_type = priv->phy_type;
 #else