[PATCH 0/2] ARM: at91: sama7g5: Reset external devices at software reset

This fixes the following: => sf probe SF: Detected mx66lm1g45g with page size 256 Bytes, erase size 4 KiB, total 128 MiB => reset resetting ... RomBOOT
What happened is that in u-boot the mx66lm1g45g NOR flash enters in Octal DTR mode. The user reset calls do_reset() method which does not call any driver's remove method, but merely resets the CPU. The flash remains in Octal DTR mode and RomCode can't recognize it, thus the boot will fail. More details in the commit messages.
Tested after software reset the mx66lm1g45g NOR flash, but also GMAC0/1, all went fine.
Tudor Ambarus (2): configs: Convert AT91RESET_EXTRST to Kconfig ARM: at91: sama7g5: Reset external devices at software reset
arch/arm/mach-at91/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)

Convert AT91RESET_EXTRST to Kconfig for easier integration. The symbol is not configurable from menuconfig, it will be automatically selected by SoCs that select it explicitly via the "select" directive. AT91RESET_EXTRST sets the Reset Controller's RSTC_CR.EXTRST bit which asserts the nrst_out pin that resets external devices.
Signed-off-by: Tudor Ambarus tudor.ambarus@microchip.com --- arch/arm/mach-at91/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 00f31045d6..ecc4da3797 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -299,6 +299,9 @@ endchoice config ATMEL_SFR bool
+config AT91RESET_EXTRST + bool + config SYS_SOC default "at91"

sama7g5 and other SoCs (sama5d3, sam9x60) define in the Reset Controller a RSTC_CR.EXTRST bit that asserts the nrst_out pin which resets external devices.
This is particular useful for external devices that are configured in stateful modes which can not be undone without reconfiguring the device or without resetting the device. An example is an SPI NOR flash that is configured in octal mode. The do_reset u-boot cmd does not call any driver's remove method, but merely resets the CPU. As the code was, this left the flash in octal mode, being impossible for the first stage boot loaders to recover/identify the flash after a "software reset". RSTC_CR.EXTRST comes in handy here, as it can be set at "software reset" to assert low the nrst_out pin during a time defined by the RSTC_MR.ERSTL field and reset the external devices (including the SPI NOR flash in the example). nrst_out is always asserted at "user reset" and it resets the external devices correctly. Asserting nrst_out at "software reset" should behave in a similar way. The only difference that I could find between the two types of resets in regards to the nrst_out signal, is that at "user reset" timing diagram the "Processor and Peripherals Reset Line" rises after six MD_SLCK cycles after the nrst_out line rose, while at the "software reset" timing diagram the "Processor and Peripherals Reset Line" is active for 3 MD_SLCK cycles + 2 MCK cycles. In other words, in the "software reset" case the nrst_out signal can be active for a longer period of time than the "Processor and Peripherals Reset Line" active time, depending on the RSTC_MR.ERSTL value. Using the default value (zero) for RSTC_MR.ERSTL, worked just fine for the sama7g5 case. Tested QSPI0 and GMAC0/GMAC1 on sama7g5ek rev 4 after a software reset with RSTC_CR.EXTRST=1 and RSTC_MR.ERSTL=0.
Signed-off-by: Tudor Ambarus tudor.ambarus@microchip.com --- arch/arm/mach-at91/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index ecc4da3797..68ab02a8cc 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -50,6 +50,7 @@ config SAM9X60 config SAMA7G5 bool select CPU_V7A + select AT91RESET_EXTRST
config SAMA5D2 bool

On 2/25/22 10:13 AM, Tudor Ambarus wrote:
This fixes the following: => sf probe SF: Detected mx66lm1g45g with page size 256 Bytes, erase size 4 KiB, total 128 MiB => reset resetting ... RomBOOT
What happened is that in u-boot the mx66lm1g45g NOR flash enters in Octal DTR mode. The user reset calls do_reset() method which does not call any driver's remove method, but merely resets the CPU. The flash remains in Octal DTR mode and RomCode can't recognize it, thus the boot will fail. More details in the commit messages.
Tested after software reset the mx66lm1g45g NOR flash, but also GMAC0/1, all went fine.
Tudor Ambarus (2): configs: Convert AT91RESET_EXTRST to Kconfig ARM: at91: sama7g5: Reset external devices at software reset
arch/arm/mach-at91/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)
Applied to u-boot-at91/next , thanks !
participants (2)
-
Eugen.Hristev@microchip.com
-
Tudor Ambarus