ARM: mach-at91: arm926ejs: fix data abort in startup returning from lowlevel_init
authorMartin Townsend <martin@rufilla.com>
Fri, 26 Feb 2021 08:44:44 +0000 (08:44 +0000)
committerEugen Hristev <eugen.hristev@microchip.com>
Mon, 22 Mar 2021 08:53:52 +0000 (10:53 +0200)
commitbbfb81c1876f32b8991cf34cf0fa5525e9f28afd
tree8f271294b808f09cab89b887bf5306b92765e9bf
parent8bad34a7090fd015d9f62d4145cb2109faa7641a
ARM: mach-at91: arm926ejs: fix data abort in startup returning from lowlevel_init

The startup code in arm/cpu/arm926ejs preserves the link register across
the call to lowlevel_init by using r4:

mov r4, lr /* perserve link reg across call */
bl lowlevel_init /* go setup pll,mux,memory */
mov lr, r4 /* restore link */

The lowlevel_init function for at91 machines based on the same CPU uses r4
and hence corrupts it causing a data abort when it returns to the startup
code. This patch fixes this by using r6 instead of r4 in the lowlevel_init
function.

Discovered and the fix was tested on a AT91SAM9261 based board.

Signed-off-by: Martin Townsend <martin@rufilla.com>
Reviewed-by: Eugen Hristev <eugen.hristev@microchip.com>
arch/arm/mach-at91/arm926ejs/lowlevel_init.S