mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 8/8] ARM: tqma6ul: use upstream device trees
Date: Wed, 21 Feb 2024 17:42:49 +0100	[thread overview]
Message-ID: <a27b45a4-2e4c-4ad0-8f81-85ed7638d79b@pengutronix.de> (raw)
In-Reply-To: <20240221150323.2715164-9-s.hauer@pengutronix.de>

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@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 |




  reply	other threads:[~2024-02-21 16:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 15:03 [PATCH 0/8] Update TQMa6UL Sascha Hauer
2024-02-21 15:03 ` [PATCH 1/8] board: tq: add missing select Sascha Hauer
2024-02-21 15:03 ` [PATCH 2/8] board: tq: fix format specifier Sascha Hauer
2024-02-21 15:03 ` [PATCH 3/8] board: tq: add support for 16bit eeprom Sascha Hauer
2024-02-21 15:03 ` [PATCH 4/8] ARM: i.MX6: add i2c4 base address Sascha Hauer
2024-02-21 15:03 ` [PATCH 5/8] ARM: tqma6ul: add pr_fmt string Sascha Hauer
2024-02-21 15:03 ` [PATCH 6/8] ARM: tqma6ul: enable enet_ref_125m clk Sascha Hauer
2024-02-21 15:03 ` [PATCH 7/8] net: phy: fix miibus parent device of_node not matching phy node Sascha Hauer
2024-02-21 15:03 ` [PATCH 8/8] ARM: tqma6ul: use upstream device trees Sascha Hauer
2024-02-21 16:42   ` Ahmad Fatoum [this message]
2024-02-23  7:37     ` Sascha Hauer
2024-02-23  7:32 ` [PATCH 0/8] Update TQMa6UL Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a27b45a4-2e4c-4ad0-8f81-85ed7638d79b@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox