MLK-12483-4 mx6: Modify drivers to disable fused modules
authorYe Li <ye.li@nxp.com>
Wed, 16 Mar 2016 05:50:54 +0000 (13:50 +0800)
committerYe Li <ye.li@nxp.com>
Wed, 5 Apr 2017 06:04:35 +0000 (14:04 +0800)
Add the fuse checking in drivers, when the module is disabled in fuse,
the driver will not work.

Changed drivers: BEE, GPMI, APBH-DMA, ESDHC, FEC, QSPI, ECSPI, I2C,
USB-EHCI, GIS, LCDIF.

Signed-off-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit 1704e116f9b39aeb99201919a18bc2b1e19a980e)

arch/arm/cpu/armv7/mx6/bee.c
drivers/dma/apbh_dma.c
drivers/i2c/mxc_i2c.c
drivers/mmc/fsl_esdhc.c
drivers/mtd/nand/mxs_nand.c
drivers/net/fec_mxc.c
drivers/spi/fsl_qspi.c
drivers/spi/mxc_spi.c
drivers/usb/host/ehci-mx6.c
drivers/video/mxc_gis.c
drivers/video/mxsfb.c

index ccdeb28..84f6a5e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <command.h>
 #include <fuse.h>
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -266,7 +267,7 @@ static int region_valid(u32 start, u32 size)
 static int do_bee_init(cmd_tbl_t *cmdtp, int flag, int argc,
                       char * const argv[])
 {
-       u32 start, size, val;
+       u32 start, size;
        int ret;
        struct bee_parameters *p = &para;
 
@@ -279,14 +280,12 @@ static int do_bee_init(cmd_tbl_t *cmdtp, int flag, int argc,
        if (argc > 5)
                return CMD_RET_USAGE;
 
-       if (fuse_read(0, 4, &val)) {
-               puts("Can not get fuse bank 0, word 4\n");
-       } else {
-               if (val & (1 << 25)) {
-                       puts("BEE disabed in fuse!\n");
-                       return CMD_RET_FAILURE;
-               }
+#ifdef CONFIG_MX6
+       if (check_module_fused(MX6_MODULE_BEE)) {
+               printf("BEE is fused, disable it!\n");
+               return CMD_RET_FAILURE;
        }
+#endif
 
        /* Cache enabled? */
        if ((get_cr() & (CR_I | CR_C)) != (CR_I | CR_C)) {
index 1030950..6142ac5 100644 (file)
@@ -574,6 +574,14 @@ void mxs_dma_init(void)
        struct mxs_apbh_regs *apbh_regs =
                (struct mxs_apbh_regs *)MXS_APBH_BASE;
 
+#ifdef CONFIG_MX6
+       if (check_module_fused(MX6_MODULE_APBHDMA)) {
+               printf("NAND APBH-DMA@0x%x is fused, disable it\n",
+                       MXS_APBH_BASE);
+               return;
+       }
+#endif
+
        mxs_reset_block(&apbh_regs->hw_apbh_ctrl0_reg);
 
 #ifdef CONFIG_APBH_DMA_BURST8
index eb789f5..f1cff75 100644 (file)
@@ -4,6 +4,8 @@
  * (c) 2007 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
  * (c) 2011 Marek Vasut <marek.vasut@gmail.com>
  *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
  * Based on i2c-imx.c from linux kernel:
  *  Copyright (C) 2005 Torsten Koschorrek <koschorrek at synertronixx.de>
  *  Copyright (C) 2005 Matthias Blaschke <blaschke at synertronixx.de>
@@ -25,6 +27,7 @@
 #include <dm.h>
 #include <dm/pinctrl.h>
 #include <fdtdec.h>
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -647,6 +650,14 @@ void bus_i2c_init(int index, int speed, int unused,
                return;
        }
 
+#ifdef CONFIG_MX6
+       if (mx6_i2c_fused((u32)mxc_i2c_buses[index].base)) {
+               printf("I2C@0x%x is fused, disable it\n",
+                       (u32)mxc_i2c_buses[index].base);
+               return;
+       }
+#endif
+
        /*
         * Warning: Be careful to allow the assignment to a static
         * variable here. This function could be called while U-Boot is
@@ -760,6 +771,13 @@ static int mxc_i2c_probe(struct udevice *bus)
        if (addr == FDT_ADDR_T_NONE)
                return -ENODEV;
 
+#ifdef CONFIG_MX6
+       if (mx6_i2c_fused(addr)) {
+               printf("I2C@0x%lx is fused, disable it\n", addr);
+               return -ENODEV;
+       }
+#endif 
+
        i2c_bus->base = addr;
        i2c_bus->index = bus->seq;
        i2c_bus->bus = bus;
index bae3d6a..b6e8828 100644 (file)
@@ -25,6 +25,7 @@
 #include <dm.h>
 #include <asm-generic/gpio.h>
 #include <power/regulator.h>
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -858,6 +859,14 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
                return ret;
        }
 
+#ifdef CONFIG_MX6
+       if (mx6_esdhc_fused(cfg->esdhc_base)) {
+               printf("ESDHC@0x%lx is fused, disable it\n", cfg->esdhc_base);
+               free(priv);
+               return -ENODEV;
+       }
+#endif
+
        ret = fsl_esdhc_init(priv);
        if (ret) {
                debug("%s init failure\n", __func__);
@@ -970,6 +979,13 @@ static int fsl_esdhc_probe(struct udevice *dev)
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
+#ifdef CONFIG_MX6
+       if (mx6_esdhc_fused(addr)) {
+               printf("ESDHC@0x%lx is fused, disable it\n", addr);
+               return -ENODEV;
+       }
+#endif
+
        priv->esdhc_regs = (struct fsl_esdhc *)addr;
        priv->dev = dev;
 
index 34c0310..83c4c57 100644 (file)
@@ -1244,6 +1244,13 @@ int mxs_nand_init(struct mxs_nand_info *info)
                (struct mxs_bch_regs *)MXS_BCH_BASE;
        int i = 0, j, ret = 0;
 
+#ifdef CONFIG_MX6
+       if (check_module_fused(MX6_MODULE_GPMI)) {
+               printf("NAND GPMI@0x%x is fused, disable it\n", MXS_GPMI_BASE);
+               return -EPERM;
+       }
+#endif
+
        info->desc = malloc(sizeof(struct mxs_dma_desc *) *
                                MXS_NAND_DMA_DESCRIPTOR_COUNT);
        if (!info->desc) {
index 2c98227..9b9556e 100644 (file)
@@ -25,6 +25,7 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/imx-common/sys_proto.h>
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1113,6 +1114,13 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)
 #endif
        int ret;
 
+#ifdef CONFIG_MX6
+       if (mx6_enet_fused(addr)) {
+               printf("Ethernet@0x%x is fused, disable it\n", addr);
+               return -2;
+       }
+#endif
+
 #ifdef CONFIG_MX28
        /*
         * The i.MX28 has two ethernet interfaces, but they are not equal.
@@ -1217,6 +1225,12 @@ static int fecmxc_probe(struct udevice *dev)
        uint32_t start;
        int ret;
 
+#ifdef CONFIG_MX6
+       if (mx6_enet_fused((uint32_t)priv->eth)) {
+               printf("Ethernet@0x%x is fused, disable it\n", (uint32_t)priv->eth);
+               return -ENODEV;
+       }
+#endif
        ret = fec_alloc_descs(priv);
        if (ret)
                return ret;
index b2a0583..cdbe5d9 100644 (file)
@@ -15,6 +15,7 @@
 #include <errno.h>
 #include <watchdog.h>
 #include "fsl_qspi.h"
+#include <asm/arch/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -873,6 +874,13 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
        if (bus >= ARRAY_SIZE(spi_bases))
                return NULL;
 
+#ifdef CONFIG_MX6
+       if (mx6_qspi_fused(spi_bases[bus])) {
+               printf("QSPI@0x%lx is fused, disable it\n", spi_bases[bus]);
+               return NULL;
+       }
+#endif
+
        if (cs >= FSL_QSPI_FLASH_NUM)
                return NULL;
 
@@ -985,6 +993,13 @@ static int fsl_qspi_probe(struct udevice *bus)
        struct dm_spi_bus *dm_spi_bus;
        int i;
 
+#ifdef CONFIG_MX6
+       if (mx6_qspi_fused(plat->reg_base)) {
+               printf("QSPI@0x%lx is fused, disable it\n", plat->reg_base);
+               return -ENODEV;
+       }
+#endif 
+
        dm_spi_bus = bus->uclass_priv;
 
        dm_spi_bus->max_hz = plat->speed_hz;
index fc2786e..a1c4ec0 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * Copyright (C) 2008, Guennadi Liakhovetski <lg@denx.de>
  *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
@@ -13,6 +15,7 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
 #include <asm/imx-common/spi.h>
+#include <asm/arch/sys_proto.h>
 
 #ifdef CONFIG_MX27
 /* i.MX27 has a completely wrong register layout and register definitions in the
@@ -413,6 +416,13 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
                return NULL;
        }
 
+#ifdef CONFIG_MX6
+       if (mx6_ecspi_fused(spi_bases[bus])) {
+               printf("ECSPI@0x%lx is fused, disable it\n", spi_bases[bus]);
+               return NULL;
+       }
+#endif
+
        mxcs = spi_alloc_slave(struct mxc_spi_slave, bus, cs);
        if (!mxcs) {
                puts("mxc_spi: SPI Slave not allocated !\n");
index 55ac162..db9748e 100644 (file)
@@ -18,6 +18,7 @@
 #include <asm/imx-common/sys_proto.h>
 #include <dm.h>
 #include <power/regulator.h>
+#include <asm/arch/sys_proto.h>
 
 #include "ehci.h"
 
@@ -353,6 +354,13 @@ int ehci_hcd_init(int index, enum usb_init_type init,
        if (index > 3)
                return -EINVAL;
 
+#if defined(CONFIG_MX6)
+       if (mx6_usb_fused((u32)ehci)) {
+               printf("USB@0x%x is fused, disable it\n", (u32)ehci);
+               return -ENODEV;
+       }
+#endif
+
        ret = ehci_mx6_common_init(ehci, index);
        if (ret)
                return ret;
@@ -511,6 +519,13 @@ static int ehci_usb_probe(struct udevice *dev)
        struct ehci_hcor *hcor;
        int ret;
 
+#if defined(CONFIG_MX6)
+       if (mx6_usb_fused((u32)ehci)) {
+               printf("USB@0x%x is fused, disable it\n", (u32)ehci);
+               return -ENODEV;
+       }
+#endif
+
        priv->ehci = ehci;
        priv->portnr = dev->seq;
        priv->init_type = type;
index 7b07198..64c1b9a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2014-2016 Freescale Semiconductor, Inc. All Rights Reserved.
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
@@ -301,6 +301,20 @@ void mxc_enable_gis(void)
        u32 csimemsize, pxpmemsize;
        char const *gis_input = getenv("gis");
 
+#ifdef CONFIG_MX6
+       if (check_module_fused(MX6_MODULE_CSI)) {
+               printf("CSI@0x%x is fused, disable it\n", CSI1_BASE_ADDR);
+               return;
+       }
+#endif
+
+#ifdef CONFIG_MX6
+       if (check_module_fused(MX6_MODULE_PXP)) {
+               printf("PXP@0x%x is fused, disable it\n", PXP_BASE_ADDR);
+               return;
+       }
+#endif
+
        gis_regs = (struct mxs_gis_regs *)GIS_BASE_ADDR;
        pxp_regs = (struct mxs_pxp_regs *)PXP_BASE_ADDR;
        csi_regs = (struct mxs_csi_regs *)CSI1_BASE_ADDR;
index fe53d2e..fae9d75 100644 (file)
@@ -171,6 +171,10 @@ void lcdif_power_down(void)
        struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)(panel.isaBase);
        int timeout = 1000000;
 
+#ifdef CONFIG_MX6
+       if (check_module_fused(MX6_MODULE_LCDIF))
+               return;
+#endif
        if (!panel.frameAdrs)
                return;
 
@@ -221,6 +225,12 @@ void *video_hw_init(void)
                bpp = depth;
        }
 
+#ifdef CONFIG_MX6
+       if (check_module_fused(MX6_MODULE_LCDIF)) {
+               printf("LCDIF@0x%x is fused, disable it\n", MXS_LCDIF_BASE);
+               return NULL;
+       }
+#endif
        /* fill in Graphic device struct */
        sprintf(panel.modeIdent, "%dx%dx%d",
                        mode.xres, mode.yres, bpp);