[PATCH 8/8] ARM: imx6: Adapt device tree selection in DH board file

Marek Vasut marex at denx.de
Thu May 19 14:57:36 CEST 2022


On 5/19/22 13:08, Philip Oberfichtner wrote:
> Before this commit device tree selection could rely solely on
> differentiating the iMX6 processor variant Q and DL. After adding two new
> carrier boards, the DRC02 and the picoITX, the interchangeability of SoMs
> makes this approach infeasible.
> 
> It is now required to specify the carrier board (dhcom-drc02,
> dhcom-picoitx or dhcom-pdk2) at compile time using
> CONFIG_DEFAULT_DEVICETREE. The SoM is determined at runtime as before.
> 
> Signed-off-by: Philip Oberfichtner <pro at denx.de>
> ---
> 
>   board/dhelectronics/dh_imx6/dh_imx6.c | 22 ++++++++++++++--------
>   1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c
> index 6059f96e80..c63fc1dd8a 100644
> --- a/board/dhelectronics/dh_imx6/dh_imx6.c
> +++ b/board/dhelectronics/dh_imx6/dh_imx6.c
> @@ -227,14 +227,20 @@ int checkboard(void)
>   #ifdef CONFIG_MULTI_DTB_FIT
>   int board_fit_config_name_match(const char *name)
>   {
> -	if (is_mx6dq()) {
> -		if (!strcmp(name, "imx6q-dhcom-pdk2"))
> -			return 0;
> -	} else if (is_mx6sdl()) {

Careful here ^ is_mx6sdl() matches on Solo and DualLite.

> -		if (!strcmp(name, "imx6dl-dhcom-pdk2"))
> -			return 0;
> -	}
> +	/* Determine carrier board at compile time and SoM at runtime */
> +	const size_t size = 32;
> +	char *car, *som, dt[size];
> +
> +	car = strchr(CONFIG_DEFAULT_DEVICE_TREE, '-'); /* i.e. -dhcom-drc02 */
> +
> +	som = is_mx6dq()   ? "imx6q"  :
> +	      is_mx6dl()   ? "imx6dl" :
> +	      is_mx6solo() ? "imx6s"  : NULL;
> +
> +	if (!(car && som))
> +		return -1;
>   
> -	return -1;
> +	snprintf(dt, size, "%s%s", som, car);
> +	return strcmp(name, dt);

This will break imx6s-dhcom-pdk2 , which used the imx6dl-dhcom-pdk2 DT 
which was fine, because U-Boot is single core anyway.

Try something like this:

/* Test SoC prefix */
if (is_mx6dq()) {
	if (strncmp(name, "imx6q-"))
		return -1;
} else if (is_mx6sdl()) {
	if (strncmp(name, "imx6s-") && strncmp(name, "imx6dl-"))
		return -1;
}

/* Test board suffix */
a = strchr(CONFIG_DEFAULT_DEVICE_TREE, '-'); /* i.e. -dhcom-drc02 */
b = strchr(name, '-'); /* i.e. -dhcom-drc02 */

return strcmp(a, b) ? -1 : 0;

I _think_ that should work and cover all combinations. (and of course, 
pick better variable names than a,b)


More information about the U-Boot mailing list