[PATCH 8/8] ARM: tqma6ul: use upstream device trees
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Feb 21 08:42:49 PST 2024
Hello Sascha,
On 21.02.24 16:03, Sascha Hauer wrote:
> The tqma6ul has several upstream device trees depending on the exact
> board type. This removes the downstream device tree in favour for the
> upstream device trees. The board type can be determined from an EEPROM
> on the board. This patch also adds support for reading the EEPROM and
> picking the right device tree for the board found.
Is the existing "mba6ulx" device tree not a subset of all boards?
Would it make sense to fall back to that instead of using a specific
DT that may fail on other variants?
> The EEPROM has the board described as strings. I do not know the correct
> strings for the boards I don't have, so right now only the device tree
> for the "TQMa6UL2L-AB.0202" board is picked. A warning is printed when
> an unknown board type is found, so this can be added as new board type
> when found.
>
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
> arch/arm/boards/tqma6ulx/board.c | 7 +-
> arch/arm/boards/tqma6ulx/lowlevel.c | 45 ++-
> arch/arm/dts/Makefile | 5 +-
> arch/arm/dts/imx6ul-mba6ulx.dtsi | 333 ------------------
> ...mba6ulx.dts => imx6ul-tqma6ul-common.dtsi} | 5 -
> arch/arm/dts/imx6ul-tqma6ul2-mba6ulx.dts | 4 +
> arch/arm/dts/imx6ul-tqma6ul2l-mba6ulx.dts | 4 +
> arch/arm/dts/imx6ull-tqma6ull2-mba6ulx.dts | 4 +
> arch/arm/dts/imx6ull-tqma6ull2l-mba6ulx.dts | 4 +
> arch/arm/dts/tqma6ul-common.dtsi | 191 ----------
> arch/arm/dts/tqma6ulx-common.dtsi | 28 --
> arch/arm/mach-imx/Kconfig | 3 +
> 12 files changed, 72 insertions(+), 561 deletions(-)
> delete mode 100644 arch/arm/dts/imx6ul-mba6ulx.dtsi
> rename arch/arm/dts/{imx6ul-mba6ulx.dts => imx6ul-tqma6ul-common.dtsi} (96%)
> create mode 100644 arch/arm/dts/imx6ul-tqma6ul2-mba6ulx.dts
> create mode 100644 arch/arm/dts/imx6ul-tqma6ul2l-mba6ulx.dts
> create mode 100644 arch/arm/dts/imx6ull-tqma6ull2-mba6ulx.dts
> create mode 100644 arch/arm/dts/imx6ull-tqma6ull2l-mba6ulx.dts
> delete mode 100644 arch/arm/dts/tqma6ul-common.dtsi
> delete mode 100644 arch/arm/dts/tqma6ulx-common.dtsi
>
> diff --git a/arch/arm/boards/tqma6ulx/board.c b/arch/arm/boards/tqma6ulx/board.c
> index be0abe443e..378cadc018 100644
> --- a/arch/arm/boards/tqma6ulx/board.c
> +++ b/arch/arm/boards/tqma6ulx/board.c
> @@ -40,7 +40,10 @@ static int mba6ulx_probe(struct device *dev)
> }
>
> static const struct of_device_id mba6ulx_of_match[] = {
> - { .compatible = "tq,mba6ulx" },
> + { .compatible = "tq,imx6ul-tqma6ul2l" },
> + { .compatible = "tq,imx6ul-tqma6ul2" },
> + { .compatible = "tq,imx6ull-tqma6ull2" },
> + { .compatible = "tq,imx6ull-tqma6ull2l" },
> { /* sentinel */ },
> };
> MODULE_DEVICE_TABLE(of, mba6ulx_of_match);
> @@ -51,3 +54,5 @@ static struct driver mba6ulx_board_driver = {
> .of_compatible = mba6ulx_of_match,
> };
> device_platform_driver(mba6ulx_board_driver);
> +
> +BAREBOX_DEEP_PROBE_ENABLE(mba6ulx_of_match);
> diff --git a/arch/arm/boards/tqma6ulx/lowlevel.c b/arch/arm/boards/tqma6ulx/lowlevel.c
> index 052471a99c..eff38c336a 100644
> --- a/arch/arm/boards/tqma6ulx/lowlevel.c
> +++ b/arch/arm/boards/tqma6ulx/lowlevel.c
> @@ -13,8 +13,13 @@
> #include <mach/imx/esdctl.h>
> #include <mach/imx/iomux-mx6ul.h>
> #include <asm/cache.h>
> +#include <pbl/i2c.h>
> +#include <boards/tq/tq_eeprom.h>
>
> -extern char __dtb_z_imx6ul_mba6ulx_start[];
> +extern char __dtb_z_imx6ul_tqma6ul2_mba6ulx_start[];
> +extern char __dtb_z_imx6ul_tqma6ul2l_mba6ulx_start[];
> +extern char __dtb_z_imx6ull_tqma6ull2_mba6ulx_start[];
> +extern char __dtb_z_imx6ull_tqma6ull2l_mba6ulx_start[];
>
> static void setup_uart(void)
> {
> @@ -30,11 +35,47 @@ static void setup_uart(void)
>
> }
>
> +static void *read_eeprom(void)
> +{
> + struct pbl_i2c *i2c;
> + struct tq_eeprom *eeprom;
> + void __iomem *iomux = (void *)MX6_IOMUXC_BASE_ADDR;
> + void *fdt = __dtb_z_imx6ul_tqma6ul2l_mba6ulx_start;
> +
> + writel(0x12, iomux + 0x0094);
> + writel(0x0, iomux + 0x05bc);
> + writel(0x1b8b0, iomux + 0x0320);
> + writel(0x12, iomux + 0x0098);
> + writel(0x0, iomux + 0x05c0);
> + writel(0x1b8b0, iomux + 0x0324);
Could iomux_v3_setup_pad and pinctrl macros be used here instead?
> +
> + i2c = imx6_i2c_early_init(IOMEM(MX6_I2C4_BASE_ADDR));
> +
> + eeprom = pbl_tq_read_eeprom(i2c, 0x50, I2C_ADDR_16_BIT);
> + if (!eeprom) {
> + pr_err("Cannot read EEPROM\n");
> + goto out;
> + }
> +
> + pr_info("Board: %s\n", eeprom->id);
> +
> + if (!strcmp(eeprom->id, "TQMa6UL2L-AB.0202"))
> + fdt = __dtb_z_imx6ul_tqma6ul2l_mba6ulx_start;
> + else
> + pr_err("Unknown board type\n");
> +out:
> + return fdt;
> +}
[snip]
> diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
> index f7b1d88dd6..d585aa0485 100644
> --- a/arch/arm/mach-imx/Kconfig
> +++ b/arch/arm/mach-imx/Kconfig
> @@ -500,6 +500,9 @@ config MACH_TQMA6UL
> bool "TQ tqma6ul on mba6ulx"
> select ARCH_IMX6UL
> select ARM_USE_COMPRESSED_DTB
> + select BOARD_TQ
> + select I2C
Is I2C absolutely needed in barebox proper?
> + select I2C_IMX_EARLY
>
> config MACH_VARISCITE_MX6
> bool "Variscite i.MX6 Quad SOM"
Cheers,
Ahmad
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list