From 2d3b5df8530cd5ef883750378838dea7c40259af Mon Sep 17 00:00:00 2001 From: Ye Li Date: Wed, 16 Mar 2016 13:50:54 +0800 Subject: 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. Signed-off-by: Ye Li (cherry picked from commit 1704e116f9b39aeb99201919a18bc2b1e19a980e) --- drivers/dma/apbh_dma.c | 8 ++++++++ drivers/i2c/mxc_i2c.c | 18 ++++++++++++++++++ drivers/mmc/fsl_esdhc.c | 16 ++++++++++++++++ drivers/mtd/nand/mxs_nand.c | 7 +++++++ drivers/net/fec_mxc.c | 14 ++++++++++++++ drivers/spi/fsl_qspi.c | 15 +++++++++++++++ drivers/spi/mxc_spi.c | 10 ++++++++++ drivers/usb/host/ehci-mx6.c | 15 +++++++++++++++ drivers/video/mxc_gis.c | 16 +++++++++++++++- drivers/video/mxsfb.c | 10 ++++++++++ 10 files changed, 128 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c index 1030950..6142ac5 100644 --- a/drivers/dma/apbh_dma.c +++ b/drivers/dma/apbh_dma.c @@ -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 diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index eb789f5..f1cff75 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -4,6 +4,8 @@ * (c) 2007 Pengutronix, Sascha Hauer * (c) 2011 Marek Vasut * + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * * Based on i2c-imx.c from linux kernel: * Copyright (C) 2005 Torsten Koschorrek * Copyright (C) 2005 Matthias Blaschke @@ -25,6 +27,7 @@ #include #include #include +#include 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; diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index bae3d6a..b6e8828 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -25,6 +25,7 @@ #include #include #include +#include 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; diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c index 34c0310..83c4c57 100644 --- a/drivers/mtd/nand/mxs_nand.c +++ b/drivers/mtd/nand/mxs_nand.c @@ -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) { diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 2c98227..9b9556e 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -25,6 +25,7 @@ #include #include #include +#include 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; diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index b2a0583..cdbe5d9 100644 --- a/drivers/spi/fsl_qspi.c +++ b/drivers/spi/fsl_qspi.c @@ -15,6 +15,7 @@ #include #include #include "fsl_qspi.h" +#include 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; diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c index fc2786e..a1c4ec0 100644 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -1,6 +1,8 @@ /* * Copyright (C) 2008, Guennadi Liakhovetski * + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * * SPDX-License-Identifier: GPL-2.0+ */ @@ -13,6 +15,7 @@ #include #include #include +#include #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"); diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 55ac162..db9748e 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -18,6 +18,7 @@ #include #include #include +#include #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; diff --git a/drivers/video/mxc_gis.c b/drivers/video/mxc_gis.c index 7b07198..64c1b9a 100644 --- a/drivers/video/mxc_gis.c +++ b/drivers/video/mxc_gis.c @@ -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; diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c index fe53d2e..fae9d75 100644 --- a/drivers/video/mxsfb.c +++ b/drivers/video/mxsfb.c @@ -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); -- cgit v1.1