From cde727083a6ee2ea01b8364ed78ee013e7e58a9b Mon Sep 17 00:00:00 2001 From: Ye Li Date: Wed, 16 Mar 2016 13:50:54 +0800 Subject: [PATCH] MLK-12483-4 mx6: Modify drivers to disable fused modules 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 (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 | 10 ++++------ drivers/dma/apbh_dma.c | 8 ++++++++ drivers/mmc/fsl_esdhc_imx.c | 18 ++++++++++++++++++ drivers/mtd/nand/raw/mxs_nand.c | 7 +++++++ drivers/spi/fsl_qspi.c | 10 ++++++++++ drivers/spi/mxc_spi.c | 10 ++++++++++ drivers/video/mxc_epdc_fb.c | 20 ++++++++++++++++++++ drivers/video/mxc_gis.c | 16 +++++++++++++++- drivers/video/mxsfb.c | 11 +++++++++++ 9 files changed, 103 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-imx/mx6/bee.c b/arch/arm/mach-imx/mx6/bee.c index bb88661192..a3489f79fe 100644 --- a/arch/arm/mach-imx/mx6/bee.c +++ b/arch/arm/mach-imx/mx6/bee.c @@ -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 = ¶ @@ -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; } } diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c index d02294724d..bccb501d84 100644 --- a/drivers/dma/apbh_dma.c +++ b/drivers/dma/apbh_dma.c @@ -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 diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c index f43fe4cd16..bec4bc7a3d 100644 --- a/drivers/mmc/fsl_esdhc_imx.c +++ b/drivers/mmc/fsl_esdhc_imx.c @@ -38,6 +38,9 @@ #include #include #include +#if CONFIG_IS_ENABLED(IMX_MODULE_FUSE) +#include +#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; diff --git a/drivers/mtd/nand/raw/mxs_nand.c b/drivers/mtd/nand/raw/mxs_nand.c index e6bbfac4d6..603a84395f 100644 --- a/drivers/mtd/nand/raw/mxs_nand.c +++ b/drivers/mtd/nand/raw/mxs_nand.c @@ -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) { diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index 3f97730bad..c9a92d4acc 100644 --- a/drivers/spi/fsl_qspi.c +++ b/drivers/spi/fsl_qspi.c @@ -39,6 +39,9 @@ #include #include #include +#if CONFIG_IS_ENABLED(IMX_MODULE_FUSE) +#include +#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) { diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c index f3dddbdbd7..974bb56e21 100644 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2008, Guennadi Liakhovetski + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * */ #include @@ -19,6 +21,7 @@ #include #include #include +#include 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"); diff --git a/drivers/video/mxc_epdc_fb.c b/drivers/video/mxc_epdc_fb.c index b4c91be10e..84937841f0 100644 --- a/drivers/video/mxc_epdc_fb.c +++ b/drivers/video/mxc_epdc_fb.c @@ -19,6 +19,7 @@ #include #include #include +#include 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. diff --git a/drivers/video/mxc_gis.c b/drivers/video/mxc_gis.c index 5523c5de74..eefb63ee59 100644 --- a/drivers/video/mxc_gis.c +++ b/drivers/video/mxc_gis.c @@ -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; diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c index 45255e10d3..baba8e2b01 100644 --- a/drivers/video/mxsfb.c +++ b/drivers/video/mxsfb.c @@ -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); -- 2.17.1