imx: add module fuse support
Subsystems (7)
PATCH v2 1/4 imx: add module fuse support
There are different parts from one SoC. Take i.MX6ULL for example, some part might not have ENET, some might have; some might not have USB, some might have. The information could be got from OCOTP, to make one image support the different parts, we need runtime disable linux kernel dts node and uboot driver probe if the corresponding module not exists in the part.
---
V2:
Fix build for aarch64
arch/arm/include/asm/mach-imx/module_fuse.h | 127 +++++++++++ arch/arm/include/asm/mach-imx/sys_proto.h | 1 + arch/arm/mach-imx/Kconfig | 7 + arch/arm/mach-imx/mx6/Makefile | 1 + arch/arm/mach-imx/mx6/module_fuse.c | 322 ++++++++++++++++++++++++++++ 5 files changed, 458 insertions(+) create mode 100644 arch/arm/include/asm/mach-imx/module_fuse.h create mode 100644 arch/arm/mach-imx/mx6/module_fuse.c
arch/arm/include/asm/mach-imx/module_fuse.h new file +127 -0
@@ -0,0 +1,127 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2019 NXP +*/ + +#ifndef __MODULE_FUSE_H__ +#define __MODULE_FUSE_H__ + +enum fuse_module_type { +MODULE_TSC , +MODULE_ADC1 , +MODULE_ADC2 , +MODULE_SIM1 , +MODULE_SIM2 , +MODULE_FLEXCAN1 , +MODULE_FLEXCAN2 , +MODULE_SPDIF , +MODULE_EIM , +MODULE_SD1 , +MODULE_SD2 , +MODULE_SD3 , +MODULE_SD4 , +MODULE_QSPI1 , +MODULE_QSPI2 , +MODULE_GPMI , +MODULE_APBHDMA , +MODULE_LCDIF , +MODULE_PXP , +MODULE_CSI , +MODULE_ENET1 , +MODULE_ENET2 , +MODULE_CAAM , +MODULE_USB_OTG1 , +MODULE_USB_OTG2 , +MODULE_SAI2 , +MODULE_SAI3 , +MODULE_BEE , +MODULE_UART1 , +MODULE_UART2 , +MODULE_UART3 , +MODULE_UART4 , +MODULE_UART5 , +MODULE_UART6 , +MODULE_UART7 , +MODULE_UART8 , +MODULE_PWM5 , +MODULE_PWM6 , +MODULE_PWM7 , +MODULE_PWM8 , +MODULE_ECSPI1 , +MODULE_ECSPI2 , +MODULE_ECSPI3 , +MODULE_ECSPI4 , +MODULE_ECSPI5 , +MODULE_I2C1 , +MODULE_I2C2 , +MODULE_I2C3 , +MODULE_I2C4 , +MODULE_GPT1 , +MODULE_GPT2 , +MODULE_EPIT1 , +MODULE_EPIT2 , +MODULE_EPDC , +MODULE_ESAI , +MODULE_DCP , +MODULE_DCP_CRYPTO , +}; + +struct fuse_entry_desc { +enum fuse_module_type module; +const char *node_path; +u32 fuse_word_offset; +u32 fuse_bit_offset; +u32 status; +}; + +#if !IS_ENABLED (CONFIG_IMX_MODULE_FUSE ) +static inline u32 check_module_fused (enum fuse_module_type module) +{ +return 0 ; +}; + +static inline u32 esdhc_fused (ulong base_addr) +{ +return 0 ; +}; + +static inline u32 ecspi_fused (ulong base_addr) +{ +return 0 ; +}; + +static inline u32 uart_fused (ulong base_addr) +{ +return 0 ; +}; + +static inline u32 usb_fused (ulong base_addr) +{ +return 0 ; +}; + +static inline u32 qspi_fused (ulong base_addr) +{ +return 0 ; +}; + +static inline u32 i2c_fused (ulong base_addr) +{ +return 0 ; +}; + +static inline u32 enet_fused (ulong base_addr) +{ +return 0 ; +}; +#else +u32 check_module_fused (enum fuse_module_type module); +u32 esdhc_fused (ulong base_addr); +u32 ecspi_fused (ulong base_addr); +u32 uart_fused (ulong base_addr); +u32 usb_fused (ulong base_addr); +u32 qspi_fused (ulong base_addr); +u32 i2c_fused (ulong base_addr); +u32 enet_fused (ulong base_addr); +#endif +#endif /* __MODULE_FUSE_H__ */
arch/arm/include/asm/mach-imx/sys_proto.h +1 -0
@@ -9,6 +9,7 @@#include <asm/io.h> #include <asm/mach-imx/regs-common.h> +#include <asm/mach-imx/module_fuse.h> #include <common.h> #include "../arch-imx/cpu.h"
arch/arm/mach-imx/Kconfig +7 -0
@@ -27,6 +27,13 @@ config IMX_BOOTAUX help bootaux [addr] to boot auxiliary core. +config IMX_MODULE_FUSE + bool "i.MX Module Fuse" + depends on ARCH_MX6 + help + i.MX module fuse to runtime disable some driver, including + Linux OS device node. + config USE_IMXIMG_PLUGIN bool "Use imximage plugin code" depends on ARCH_MX7 || ARCH_MX6 || ARCH_MX7ULP
arch/arm/mach-imx/mx6/Makefile +1 -0
@@ -6,6 +6,7 @@ # (C) Copyright 2011 Freescale Semiconductor, Inc. obj-y := soc.o clock.o +obj-$(CONFIG_IMX_MODULE_FUSE) += module_fuse.o obj-$(CONFIG_SPL_BUILD) += ddr.o obj-$(CONFIG_MP) += mp.o obj-$(CONFIG_MX6UL_LITESOM) += litesom.o
arch/arm/mach-imx/mx6/module_fuse.c new file +322 -0
322 lines not on this page · raw message
Signature · 1 line
2.16.4
PATCH v2 2/4 i2c: mxc: add fuse check
Add fuse check for I2C. If the fuse indicates the module will not work in the SoC, let's fail the initialization.
---
V2:
Fix build for aarch64
drivers/i2c/mxc_i2c.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/i2c/mxc_i2c.c +17 -0
@@ -18,6 +18,7 @@#include <asm/arch/imx-regs.h> #include <linux/errno.h> #include <asm/mach-imx/mxc_i2c.h> +#include <asm/mach-imx/sys_proto.h> #include <asm/io.h> #include <i2c.h> #include <watchdog.h>
@@ -740,6 +741,14 @@ void bus_i2c_init(int index, int speed, int unused,return ; } +if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) { +if (i2c_fused ((ulong )mxc_i2c_buses[index].base)) { +printf ("SoC fuse indicates I2C at 0x%lx is unavailable.\n" , + (ulong )mxc_i2c_buses[index].base); +return ; + } + } +/* * Warning: Be careful to allow the assignment to a static * variable here. This function could be called while U-Boot is
@@ -885,6 +894,14 @@ static int mxc_i2c_probe(struct udevice *bus)if (addr ==FDT_ADDR_T_NONE )return -EINVAL ; +if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) { +if (i2c_fused ((ulong )addr)) { +printf ("SoC fuse indicates I2C at 0x%lx is unavailable.\n" , + (ulong )addr); +return -ENODEV ; + } + } + i2c_bus->base = addr; i2c_bus->index = bus->seq; i2c_bus->bus = bus;
Signature · 1 line
2.16.4
PATCH v2 2/4 i2c: mxc: add fuse check
Hello Peng,
Am 01.08.2019 um 10:45 schrieb Peng Fan:
Quoted 46 lines
Add fuse check for I2C. If the fuse indicates the module will not work in the SoC, let's fail the initialization.
Signed-off-by Peng Fan <[email protected]>---
V2:
Fix build for aarch64drivers/i2c/mxc_i2c.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/i2c/mxc_i2c.c +10
-0@@ -18,6 +18,7 @@#include <asm/arch/imx-regs.h> #include <linux/errno.h> #include <asm/mach-imx/mxc_i2c.h> +#include <asm/mach-imx/sys_proto.h> #include <asm/io.h> #include <i2c.h> #include <watchdog.h> @@ -740,6 +741,14 @@ void bus_i2c_init(int index, int speed, int unused,return ; } +if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) { +if (i2c_fused ((ulong )mxc_i2c_buses[index].base)) { +printf ("SoC fuse indicates I2C at 0x%lx is unavailable.\n" , + (ulong )mxc_i2c_buses[index].base); +return ; + } + } +/* * Warning: Be careful to allow the assignment to a static * variable here. This function could be called while U-Boot is @@ -885,6 +894,14 @@ static int mxc_i2c_probe(struct udevice *bus)if (addr ==FDT_ADDR_T_NONE )return -EINVAL ; +if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) {
drivers/i2c/mxc_i2c.c static int mxc_i2c_probe(struct udevice *bus) · line 907
Quoted 10 lines
drivers/i2c/mxc_i2c.c +7
-0+if (i2c_fused ((ulong )addr)) { +printf ("SoC fuse indicates I2C at 0x%lx is unavailable.\n" , + (ulong )addr); +return -ENODEV ; + } + } + i2c_bus->base = addr; i2c_bus->index = bus->seq; i2c_bus->bus = bus;
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH v2 3/4 usb: mx6: add fuse check
In reply to Peng FanAdd fuse check for USB. If the fuse indicates the module will not work in the SoC, let's fail the initialization.
---
V2:
Fix build for aarch64
drivers/usb/host/ehci-mx6.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/usb/host/ehci-mx6.c +16 -0
@@ -353,6 +353,14 @@ int ehci_hcd_init(int index, enum usb_init_type init,if (index >3 )return -EINVAL ; +if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) { +if (usb_fused ((ulong )ehci)) { +printf ("SoC fuse indicates USB at 0x%lx is unavailable.\n" , + (ulong )ehci); +return -ENODEV ; + } + } + ret =ehci_mx6_common_init (ehci, index);if (ret)return ret;
@@ -549,6 +557,14 @@ static int ehci_usb_probe(struct udevice *dev)struct ehci_hcor *hcor;int ret; +if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) { +if (usb_fused ((ulong )ehci)) { +printf ("SoC fuse indicates USB at 0x%lx is unavailable.\n" , + (ulong )ehci); +return -ENODEV ; + } + } + priv->ehci = ehci; priv->portnr = dev->seq; priv->init_type = type;
Signature · 1 line
2.16.4
PATCH v2 4/4 net: fec: add fuse check
In reply to Peng FanAdd fuse check for fec. If the fuse indicates the module will not work in the SoC, let's fail the initialization.
---
V2:
Fix build for aarch64
Add ACK tag
drivers/net/fec_mxc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/fec_mxc.c +14 -0
@@ -1185,6 +1185,13 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)#endif int ret; +if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) { +if (enet_fused ((ulong )addr)) { +printf ("SoC fuse indicates Ethernet at 0x%x is unavailable.\n" , addr); +return -ENODEV ; + } + } +#ifdef CONFIG_FEC_MXC_MDIO_BASE /* * The i.MX28 has two ethernet interfaces, but they are not equal.
@@ -1323,6 +1330,13 @@ static int fecmxc_probe(struct udevice *dev)uint32_t start;int ret; +if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) { +if (enet_fused ((ulong )priv->eth)) { +printf ("SoC fuse indicates Ethernet at 0x%lx is unavailable.\n" , (ulong )priv->eth); +return -ENODEV ; + } + } +if (IS_ENABLED (CONFIG_IMX8 )) { ret =clk_get_by_name (dev,"ipg" , &priv->ipg_clk);if (ret <0 ) {
Signature · 1 line
2.16.4
PATCH v2 4/4 net: fec: add fuse check
Hi Peng,
Quoted 37 lines
Add fuse check for fec. If the fuse indicates the module will not work in the SoC, let's fail the initialization.
Signed-off-by Peng Fan <[email protected]>Acked-by Joe Hershberger <[email protected]>---
V2:
Fix build for aarch64
Add ACK tagdrivers/net/fec_mxc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)drivers/net/fec_mxc.c +7
-0@@ -1185,6 +1185,13 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)#endif int ret; +if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) { +if (enet_fused ((ulong )addr)) { +printf ("SoC fuse indicates Ethernet at 0x%x is unavailable.\n" , addr); +return -ENODEV ; + } + } +#ifdef CONFIG_FEC_MXC_MDIO_BASE /* * The i.MX28 has two ethernet interfaces, but they are not equal. @@ -1323,6 +1330,13 @@ static int fecmxc_probe(struct udevice *dev)uint32_t start;int ret;
drivers/net/fec_mxc.c static int fecmxc_probe(struct udevice *dev) · line 1342
Quoted 10 lines
drivers/net/fec_mxc.c +7
-0+if (IS_ENABLED (CONFIG_IMX_MODULE_FUSE )) { +if (enet_fused ((ulong )priv->eth)) { +printf ("SoC fuse indicates Ethernet at 0x%lx is unavailable.\n" , (ulong )priv->eth); +return -ENODEV ; + } + } +if (IS_ENABLED (CONFIG_IMX8 )) { ret =clk_get_by_name (dev,"ipg" , &priv->ipg_clk);if (ret <0 ) {
Best regards,
Ye Li