[RFC][PATCH] ARM: imx: verdin-imx8mm: Set CAN oscillator frequency based on model

Francesco Dolcini francesco at dolcini.it
Mon Jan 15 16:44:20 CET 2024


On Sat, Jan 13, 2024 at 07:33:17PM +0100, Marek Vasut wrote:
> The older i.MX8M Mini Verdin SoMs before rev. 1.1C came with 20 MHz SPI CAN
> controller oscillator, the newer SoMs use 40 MHz oscillator. Handle both by
> overriding the oscillator frequency just before booting the kernel.
> 
> Signed-off-by: Marek Vasut <marex at denx.de>
> ---
> Cc: "NXP i.MX U-Boot Team" <uboot-imx at nxp.com>
> Cc: Fabio Estevam <festevam at gmail.com>
> Cc: Francesco Dolcini <francesco.dolcini at toradex.com>
> Cc: Marcel Ziswiler <marcel.ziswiler at toradex.com>
> Cc: Philippe Schenker <philippe.schenker at toradex.com>

Philippe is no longer in toradex, removed from cc list.

> Cc: Stefano Babic <sbabic at denx.de>
> ---
>  board/toradex/verdin-imx8mm/verdin-imx8mm.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/board/toradex/verdin-imx8mm/verdin-imx8mm.c b/board/toradex/verdin-imx8mm/verdin-imx8mm.c
> index b2781b51d6a..8bc1a51eeb1 100644
> --- a/board/toradex/verdin-imx8mm/verdin-imx8mm.c
> +++ b/board/toradex/verdin-imx8mm/verdin-imx8mm.c
> @@ -142,6 +142,25 @@ int board_phys_sdram_size(phys_size_t *size)
>  #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
>  int ft_board_setup(void *blob, struct bd_info *bd)
>  {
> +	const char *canoscpath = "/oscillator";
> +	int canoscoff, freq, ret;
> +
> +	canoscoff = fdt_path_offset(blob, canoscpath);
> +	if (canoscoff < 0)	/* No CAN oscillator found. */
> +		goto exit;
> +
> +	if (tdx_hw_tag.ver_assembly < 2)        /* rev. A or B */
> +		freq = 20000000;
> +	else					/* rev. C or newer */
> +		freq = 40000000;

So, the situation is more complex than what I thought initially.

The actual frequency of the oscillator depends on the whole
`struct toradex_hw`, you would need to check prodid, ver_major,
ver_minor and ver_assembly.
	
In addition to that code should not expect `ver_assembly` to be an
increasing number, this is just a number that is matching the BOM.

The actual `prodid` (PID4 in Toradex naming) that have the CAN
functionality are 0055 and 0059.

0059, V1.1A and V1.1B, use a 20MHz oscillator
0055, V1.1A, V1.1B, V1.1C and V1.1D, use a 20Mhz oscillator

Verdin iMX8MM V1.0* is something I would not consider, from what I know
they were all scrapped (not even myself has any of those anymore).

With that said what I would do is something like

if ((tdx_hw_tag.ver_major == 1 && tdx_hw_tag.ver_minor == 1) &&
    ((tdx_hw_tag.prodid == VERDIN_IMX8MMQ_IT && ver_assembly <= 1) ||
    (tdx_hw_tag.prodid == VERDIN_IMX8MMQ_WIFI_BT_IT &&. ....))

    ft_fixup_can_oscillator_freq();

or any other more readable variant of your choice ;-)

And I would not have the code guess anything apart this, just setting
20MHz for the well known configuration.

If you are interested the details on the versions they are public, see
https://www.toradex.com/computer-on-modules/verdin-arm-family/nxp-imx-8m-mini-nano
and
https://developer.toradex.com/hardware/verdin-som-family/modules/verdin-imx8m-mini/#revision-history

Francesco



More information about the U-Boot mailing list