Commit 5f20cc02b0b10525843813e81603e1dc82033e76

Authored by Breno Lima
Committed by Ye Li
1 parent a49a064fba

MLK-22743 mx7ulp: Update unlock and refresh sequences in sWDOG driver

According to i.MX7ULP Reference Manual the second word write for both
UNLOCK and REFRESH operations must occur in maximum 16 bus clock.

The current code is using writel() function which has a DMB barrier to
order the memory access. The DMB between two words write may introduce
some delay in certain circumstance, causing a WDOG timeout due to 16 bus
clock window requirement.

Replace writel() function by __raw_writel() to achieve a faster memory
access and avoid such issue.

Signed-off-by: Breno Lima <breno.lima@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit 5dd8c46d68d3267e989f980598a4e3e2ed04d4f9)

Showing 1 changed file with 12 additions and 6 deletions Side-by-side Diff

drivers/watchdog/ulp_wdog.c
... ... @@ -51,8 +51,10 @@
51 51 {
52 52 struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR;
53 53  
54   - writel(REFRESH_WORD0, &wdog->cnt);
55   - writel(REFRESH_WORD1, &wdog->cnt);
  54 + dmb();
  55 + __raw_writel(REFRESH_WORD0, &wdog->cnt);
  56 + __raw_writel(REFRESH_WORD1, &wdog->cnt);
  57 + dmb();
56 58 }
57 59  
58 60 void hw_watchdog_init(void)
... ... @@ -60,8 +62,10 @@
60 62 u8 val;
61 63 struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR;
62 64  
63   - writel(UNLOCK_WORD0, &wdog->cnt);
64   - writel(UNLOCK_WORD1, &wdog->cnt);
  65 + dmb();
  66 + __raw_writel(UNLOCK_WORD0, &wdog->cnt);
  67 + __raw_writel(UNLOCK_WORD1, &wdog->cnt);
  68 + dmb();
65 69  
66 70 val = readb(&wdog->cs2);
67 71 val |= WDGCS2_FLG;
... ... @@ -80,8 +84,10 @@
80 84 {
81 85 struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR;
82 86  
83   - writel(UNLOCK_WORD0, &wdog->cnt);
84   - writel(UNLOCK_WORD1, &wdog->cnt);
  87 + dmb();
  88 + __raw_writel(UNLOCK_WORD0, &wdog->cnt);
  89 + __raw_writel(UNLOCK_WORD1, &wdog->cnt);
  90 + dmb();
85 91  
86 92 hw_watchdog_set_timeout(5); /* 5ms timeout */
87 93 writel(0, &wdog->win);