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>
Thu, 29 Apr 2021 07:56:02 +0000 (00:56 -0700)
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 and EPDC.

Signed-off-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit 1704e116f9b39aeb99201919a18bc2b1e19a980e)
(cherry picked from commit 2d3b5df8530cd5ef883750378838dea7c40259af)
(cherry picked from commit 6e8c9ae136bee8ec0121c1db4b935510caad09db)
(cherry picked from commit 99b54a6965904a879afdb6883a519de726cb4e96)
(cherry picked from commit 0633c42f9465e4484d7c9db4de1c0d3910e6a46e)

arch/arm/mach-imx/mx6/bee.c
drivers/dma/apbh_dma.c
drivers/mmc/fsl_esdhc_imx.c
drivers/mtd/nand/raw/mxs_nand.c
drivers/spi/fsl_qspi.c
drivers/spi/mxc_spi.c
drivers/video/mxc_epdc_fb.c
drivers/video/mxc_gis.c
drivers/video/mxsfb.c

index bb88661..a3489f7 100644 (file)
@@ -270,7 +270,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;
 
@@ -283,11 +283,9 @@ 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");
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_BEE)) {
+                       printf("BEE is fused, disable it!\n");
                        return CMD_RET_FAILURE;
                }
        }
index d022947..bccb501 100644 (file)
@@ -578,6 +578,14 @@ void mxs_dma_init(void)
        struct mxs_apbh_regs *apbh_regs =
                (struct mxs_apbh_regs *)MXS_APBH_BASE;
 
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_APBHDMA)) {
+                       printf("NAND APBH-DMA@0x%x is fused, disable it\n",
+                               MXS_APBH_BASE);
+                       return;
+               }
+       }
+
        mxs_reset_block(&apbh_regs->hw_apbh_ctrl0_reg);
 
 #ifdef CONFIG_APBH_DMA_BURST8
index f43fe4c..bec4bc7 100644 (file)
@@ -38,6 +38,9 @@
 #include <mapmem.h>
 #include <dm/ofnode.h>
 #include <linux/iopoll.h>
+#if CONFIG_IS_ENABLED(IMX_MODULE_FUSE)
+#include <asm/mach-imx/sys_proto.h>
+#endif
 
 #if !CONFIG_IS_ENABLED(BLK)
 #include "mmc_private.h"
@@ -1333,6 +1336,13 @@ int fsl_esdhc_initialize(struct bd_info *bis, struct fsl_esdhc_cfg *cfg)
        if (!cfg)
                return -EINVAL;
 
+#if CONFIG_IS_ENABLED(IMX_MODULE_FUSE)
+       if (esdhc_fused(cfg->esdhc_base)) {
+               printf("ESDHC@0x%lx is fused, disable it\n", cfg->esdhc_base);
+               return -ENODEV;
+       }
+#endif
+
        priv = calloc(sizeof(struct fsl_esdhc_priv), 1);
        if (!priv)
                return -ENOMEM;
@@ -1426,6 +1436,14 @@ static int fsl_esdhc_of_to_plat(struct udevice *dev)
        addr = dev_read_addr(dev);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
+
+#if CONFIG_IS_ENABLED(IMX_MODULE_FUSE)
+       if (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;
        priv->mode = -1;
index e6bbfac..603a843 100644 (file)
@@ -1254,6 +1254,13 @@ static int mxs_nand_init_dma(struct mxs_nand_info *info)
 {
        int i = 0, j, ret = 0;
 
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_GPMI)) {
+                       printf("NAND GPMI@0x%lx is fused, disable it\n", (ulong)info->gpmi_regs);
+                       return -EPERM;
+               }
+       }
+
        info->desc = malloc(sizeof(struct mxs_dma_desc *) *
                                MXS_NAND_DMA_DESCRIPTOR_COUNT);
        if (!info->desc) {
index 3f97730..c9a92d4 100644 (file)
@@ -39,6 +39,9 @@
 #include <linux/sizes.h>
 #include <linux/err.h>
 #include <asm/io.h>
+#if CONFIG_IS_ENABLED(IMX_MODULE_FUSE)
+#include <asm/mach-imx/sys_proto.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -809,6 +812,13 @@ static int fsl_qspi_probe(struct udevice *bus)
 
        q->iobase = map_physmem(res.start, res.end - res.start, MAP_NOCACHE);
 
+#if CONFIG_IS_ENABLED(IMX_MODULE_FUSE)
+       if (qspi_fused((ulong)(q->iobase))) {
+               printf("QSPI@0x%lx is fused, disable it\n", (ulong)(q->iobase));
+               return -ENODEV;
+       }
+#endif
+
        ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
                                     "QuadSPI-memory", &res);
        if (ret) {
index f3dddbd..974bb56 100644 (file)
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2008, Guennadi Liakhovetski <lg@denx.de>
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
  */
 
 #include <common.h>
@@ -19,6 +21,7 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
 #include <asm/mach-imx/spi.h>
+#include <asm/mach-imx/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -547,6 +550,13 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
                return NULL;
        }
 
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (ecspi_fused(spi_bases[bus])) {
+                       printf("ECSPI@0x%lx is fused, disable it\n", spi_bases[bus]);
+                       return NULL;
+               }
+       }
+
        mxcs = spi_alloc_slave(struct mxc_spi_slave, bus, cs);
        if (!mxcs) {
                puts("mxc_spi: SPI Slave not allocated !\n");
index b4c91be..8493784 100644 (file)
@@ -19,6 +19,7 @@
 #include <asm/cache.h>
 #include <asm/global_data.h>
 #include <linux/delay.h>
+#include <asm/mach-imx/sys_proto.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -353,6 +354,12 @@ static void draw_splash_screen(void)
 
 void lcd_enable(void)
 {
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_EPDC)) {
+                       return;
+               }
+       }
+
        if (board_setup_logo_file(lcd_base)) {
                debug("Load logo failed!\n");
                return;
@@ -370,6 +377,12 @@ void lcd_enable(void)
 
 void lcd_disable(void)
 {
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_EPDC)) {
+                       return;
+               }
+       }
+
        debug("lcd_disable\n");
 
        /* Disable clocks to EPDC */
@@ -385,6 +398,13 @@ void lcd_ctrl_init(void *lcdbase)
 {
        unsigned int val;
 
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_EPDC)) {
+                       printf("EPDC@0x%x is fused, disable it\n", EPDC_BASE_ADDR);
+                       return;
+               }
+       }
+
        /*
         * We rely on lcdbase being a physical address, i.e., either MMU off,
         * or 1-to-1 mapping. Might want to add some virt2phys here.
index 5523c5d..eefb63e 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2014 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2014-2016 Freescale Semiconductor, Inc. All Rights Reserved.
  *
  */
 
@@ -308,6 +308,20 @@ void mxc_enable_gis(void)
        u32 csimemsize, pxpmemsize;
        char const *gis_input = env_get("gis");
 
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_CSI)) {
+                       printf("CSI@0x%x is fused, disable it\n", CSI1_BASE_ADDR);
+                       return;
+               }
+       }
+
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_PXP)) {
+                       printf("PXP@0x%x is fused, disable it\n", PXP_BASE_ADDR);
+                       return;
+               }
+       }
+
        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 45255e1..baba8e2 100644 (file)
@@ -203,6 +203,11 @@ static int mxs_remove_common(phys_addr_t reg_base, u32 fb)
        struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)(reg_base);
        int timeout = 1000000;
 
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_LCDIF))
+                       return -ENODEV;
+       }
+
        if (!fb)
                return -EINVAL;
 
@@ -290,6 +295,12 @@ void *video_hw_init(void)
                bpp = depth;
        }
 
+       if (CONFIG_IS_ENABLED(IMX_MODULE_FUSE)) {
+               if (check_module_fused(MODULE_LCDIF)) {
+                       printf("LCDIF@0x%x is fused, disable it\n", MXS_LCDIF_BASE);
+                       return NULL;
+               }
+       }
        /* fill in Graphic device struct */
        sprintf(panel.modeIdent, "%dx%dx%d", mode.xres, mode.yres, bpp);