From 8e1279fcab1d03240ed150ff5d9113828766f0f0 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Mon, 25 May 2020 20:15:56 -0700 Subject: [PATCH] MLK-24157 ulp_wdog: Fix unaligned access to cs2 reg Patch "MLK-22755 mx7ulp: wdog: Wait for WDOG unlock and reconfiguration to complete", added some flags checking to WDOG driver. But the cs2 register access is wrong, should use "readb" not "readl". This is fine for some compilers (like gcc8.2, gcc9.2) which adjusts the access to "ldrb" instruction. However for old compilers (like gcc4.9), it won't fix the instruction and cause data abort. Signed-off-by: Ye Li Reviewed-by: Peng Fan (cherry picked from commit fd1f9177abdfab23ae124b8f41583c578cfe0b2e) --- drivers/watchdog/ulp_wdog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/ulp_wdog.c b/drivers/watchdog/ulp_wdog.c index 3c8baf3..3231327 100644 --- a/drivers/watchdog/ulp_wdog.c +++ b/drivers/watchdog/ulp_wdog.c @@ -71,7 +71,7 @@ void hw_watchdog_init(void) dmb(); /* Wait WDOG Unlock */ - while (!(readl(&wdog->cs2) & WDGCS2_ULK)); + while (!(readb(&wdog->cs2) & WDGCS2_ULK)); val = readb(&wdog->cs2); val |= WDGCS2_FLG; @@ -84,7 +84,7 @@ void hw_watchdog_init(void) writeb((WDGCS1_WDGE | WDGCS1_WDGUPDATE), &wdog->cs1);/* enable counter running */ /* Wait WDOG reconfiguration */ - while (!(readl(&wdog->cs2) & WDGCS2_RCS)); + while (!(readb(&wdog->cs2) & WDGCS2_RCS)); hw_watchdog_reset(); } @@ -99,7 +99,7 @@ void reset_cpu(ulong addr) dmb(); /* Wait WDOG Unlock */ - while (!(readl(&wdog->cs2) & WDGCS2_ULK)); + while (!(readb(&wdog->cs2) & WDGCS2_ULK)); hw_watchdog_set_timeout(5); /* 5ms timeout */ writel(0, &wdog->win); @@ -108,7 +108,7 @@ void reset_cpu(ulong addr) writeb(WDGCS1_WDGE, &wdog->cs1);/* enable counter running */ /* Wait WDOG reconfiguration */ - while (!(readl(&wdog->cs2) & WDGCS2_RCS)); + while (!(readb(&wdog->cs2) & WDGCS2_RCS)); hw_watchdog_reset(); -- 1.9.1