ARM: imx: verdin-imx8mm: Set CAN oscillator frequency based on model
RFC PATCH 1/1 ARM: imx: verdin-imx8mm: Set CAN oscillator frequency based on model
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.
---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Francesco Dolcini <[email protected]>
Cc: Marcel Ziswiler <[email protected]>
Cc: Philippe Schenker <[email protected]>
Cc: Stefano Babic <[email protected]>
--- board/toradex/verdin-imx8mm/verdin-imx8mm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
board/toradex/verdin-imx8mm/verdin-imx8mm.c +19 -0
@@ -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 ; + + ret =fdt_setprop_u32 (blob, canoscoff,"clock-frequency" , freq); +if (ret <0 ) { +printf ("Failed to set CAN oscillator clock-frequency, ret=%d\n" , + ret); + } + +exit:return ft_common_board_setup (blob, bd); }#endif
Signature · 1 line
2.43.0
Hi Marek
Thanks, seems like a decent idea. I guess we just did not do it as those previous revisions were just samples but with this change can still be used much easier (e.g. without requiring manual intervention).
Quoted 4 lines · Marek Vasut
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.
Quoted 8 lines
Signed-off-by Marek Vasut <[email protected]>---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Francesco Dolcini <[email protected]>
Cc: Marcel Ziswiler <[email protected]>
Cc: Philippe Schenker <[email protected]>
Cc: Stefano Babic <[email protected]>
Quoted 24 lines
---
board/toradex/verdin-imx8mm/verdin-imx8mm.c | 19 +++++++++++++++++++1 file changed, 19 insertions(+)board/toradex/verdin-imx8mm/verdin-imx8mm.c +12
-0@@ -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 ; +
board/toradex/verdin-imx8mm/verdin-imx8mm.c int board_phys_sdram_size(phys_size_t *size) · line 166
Quoted 10 lines
board/toradex/verdin-imx8mm/verdin-imx8mm.c +7
-0+ ret =fdt_setprop_u32 (blob, canoscoff,"clock-frequency" , freq); +if (ret <0 ) { +printf ("Failed to set CAN oscillator clock-frequency, ret=%d\n" , + ret); + } + +exit: return ft_common_board_setup(blob, bd); } #endif
Cheers
Marcel
Quoted 6 lines · Marek Vasut
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 <[email protected]>
Applied, thanks.
Quoted 19 lines · Marcel Ziswiler
Hi Marek
Thanks, seems like a decent idea. I guess we just did not do it as those previous revisions were just samples but with this change can still be used much easier (e.g. without requiring manual intervention).
Quoted 4 lines · Marek Vasut
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.
Quoted 8 lines
Signed-off-by Marek Vasut <[email protected]>---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Francesco Dolcini <[email protected]>
Cc: Marcel Ziswiler <[email protected]>
Cc: Philippe Schenker <[email protected]>
Cc: Stefano Babic <[email protected]>
Quoted 1 line
Acked-by Marcel Ziswiler <[email protected]>
Marcel, that patch is buggy.
The assembly version makes sense only for a specific major/minor hardware version.
So what you need to check if revision < 1.1C, while the code from Marek check just for the assembly version C.
Quoted 5 lines
Quoted 5 lines
---
board/toradex/verdin-imx8mm/verdin-imx8mm.c | 19 +++++++++++++++++++1 file changed, 19 insertions(+)
Quoted 16 lines
Quoted 6 lines
board/toradex/verdin-imx8mm/verdin-imx8mm.c +0
-0@@ -142,6 +142,25 @@ int board_phys_sdram_size(phys_size_t *size) #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)board/toradex/verdin-imx8mm/verdin-imx8mm.c int board_phys_sdram_size(phys_size_t *size) · line 152
Quoted 10 lines
board/toradex/verdin-imx8mm/verdin-imx8mm.c +8
-0int 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 */
I would suggest a slightly different approach.
First you need to check also for major/minor version. The revision restart from A every time there is a change in a version.
Second I would set the 20MHz oscillator only for older version and do nothing, not set anything, for the newer one.
Quoted 9 lines · Fabio Estevam
Quoted 6 lines · Marek Vasut
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 <[email protected]>Applied, thanks.
Fabio, you were too fast ... please revert it.
Francesco
Quoted 22 lines · Francesco Dolcini
Quoted 19 lines · Marcel Ziswiler
Hi Marek
Thanks, seems like a decent idea. I guess we just did not do it as those previous revisions were just samples but with this change can still be used much easier (e.g. without requiring manual intervention).
Quoted 4 lines · Marek Vasut
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.
Quoted 8 lines
Signed-off-by Marek Vasut <[email protected]>---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Francesco Dolcini <[email protected]>
Cc: Marcel Ziswiler <[email protected]>
Cc: Philippe Schenker <[email protected]>
Cc: Stefano Babic <[email protected]>Quoted 1 line
Acked-by Marcel Ziswiler <[email protected]>
Quoted 7 lines
Marcel, that patch is buggy.
The assembly version makes sense only for a specific major/minor hardware version.
So what you need to check if revision < 1.1C, while the code from Marek check just for the assembly version C.
And in the general case even my suggested test is not enough. We started having assembly version that are not linearly increasing since some time.
I am fine on finding a solution to dynamically handle the different oscillator frequency, but let's do it right.
I will reply Monday with some more details so we can have a working solution.
Francesco
Fabio Estevam
reviewerQuoted 1 line · Francesco Dolcini
Fabio, you were too fast ... please revert it.
I have dropped this patch from u-boot-imx master-next.
Hi Guys
Quoted 21 lines · Francesco Dolcini
Quoted 20 lines · Marcel Ziswiler
Hi Marek
Thanks, seems like a decent idea. I guess we just did not do it as those previous revisions were just samples
but with this change can still be used much easier (e.g. without requiring manual intervention).Quoted 12 lines · Marek Vasut
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 <[email protected]>---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Francesco Dolcini <[email protected]>
Cc: Marcel Ziswiler <[email protected]>
Cc: Philippe Schenker <[email protected]>
Cc: Stefano Babic <[email protected]>
Quoted 6 lines
Quoted 1 line
Acked-by Marcel Ziswiler <[email protected]>Marcel, that patch is buggy.
The assembly version makes sense only for a specific major/minor hardware version.
Yes, sorry, I did not look at it careful enough.
Quoted 26 lines
So what you need to check if revision < 1.1C, while the code from Marek check just for the assembly version C.
Quoted 5 lines
Quoted 5 lines
---
board/toradex/verdin-imx8mm/verdin-imx8mm.c | 19 +++++++++++++++++++1 file changed, 19 insertions(+)Quoted 16 lines
Quoted 6 lines
board/toradex/verdin-imx8mm/verdin-imx8mm.c +0
-0@@ -142,6 +142,25 @@ int board_phys_sdram_size(phys_size_t *size) #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)board/toradex/verdin-imx8mm/verdin-imx8mm.c int board_phys_sdram_size(phys_size_t *size) · line 152
Quoted 10 lines
board/toradex/verdin-imx8mm/verdin-imx8mm.c +8
-0int 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 */I would suggest a slightly different approach.
Quoted 5 lines
First you need to check also for major/minor version. The revision restart from A every time there is a change in a version.
Second I would set the 20MHz oscillator only for older version and do nothing, not set anything, for the newer one.
Yes, I agree. So worst case it will always use the new/fixed setting.
Quoted 7 lines · Fabio Estevam
Quoted 6 lines · Marek Vasut
Quoted 5 lines
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.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Marek Vasut <[email protected]>Applied, thanks.
Fabio, you were too fast ... please revert it.
Francesco
Cheers
Marcel
Quoted 11 lines · Marek Vasut
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 <[email protected]>---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Francesco Dolcini <[email protected]>
Cc: Marcel Ziswiler <[email protected]>
Cc: Philippe Schenker <[email protected]>
Philippe is no longer in toradex, removed from cc list.
Quoted 14 lines
Cc Stefano Babic <[email protected]>--- board/toradex/verdin-imx8mm/verdin-imx8mm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)board/toradex/verdin-imx8mm/verdin-imx8mm.c +1
-0@@ -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" ;
board/toradex/verdin-imx8mm/verdin-imx8mm.c int board_phys_sdram_size(phys_size_t *size) · line 155
Quoted 10 lines
board/toradex/verdin-imx8mm/verdin-imx8mm.c +10
-0+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
Quoted 46 lines · Francesco Dolcini
Quoted 11 lines · Marek Vasut
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 <[email protected]>---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Francesco Dolcini <[email protected]>
Cc: Marcel Ziswiler <[email protected]>
Cc: Philippe Schenker <[email protected]>Philippe is no longer in toradex, removed from cc list.
Quoted 14 lines
Cc Stefano Babic <[email protected]>--- board/toradex/verdin-imx8mm/verdin-imx8mm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)board/toradex/verdin-imx8mm/verdin-imx8mm.c +1
-0@@ -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" ;board/toradex/verdin-imx8mm/verdin-imx8mm.c int board_phys_sdram_size(phys_size_t *size) · line 155
Quoted 10 lines
board/toradex/verdin-imx8mm/verdin-imx8mm.c +10
-0+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_minorandver_assembly.
Quoted 8 lines
In addition to that code should not expect
ver_assemblyto 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
Do you happen to have a table of what was populated with which oscillator, so I can fill all the 20 MHz parts in right away ?
Quoted 7 lines · Marek Vasut
Quoted 3 lines · Francesco Dolcini
On Sat, Jan 13, 2024 at 07:33:17PM +0100, Marek Vasut wrote:
0059, V1.1A and V1.1B, use a 20MHz oscillator 0055, V1.1A, V1.1B, V1.1C and V1.1D, use a 20Mhz oscillatorDo you happen to have a table of what was populated with which oscillator, so I can fill all the 20 MHz parts in right away ?
I guess that one quoted here from my previous email is "the table", but maybe I have not understood your question.
Francesco