Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: omap_wdt: raw read and write endian fix

All OMAP IP blocks expect LE data, but CPU may operate in BE mode.
Need to use endian neutral functions to read/write h/w registers.
I.e instead of __raw_read[lw] and __raw_write[lw] functions code
need to use read[lw]_relaxed and write[lw]_relaxed functions.
If the first simply reads/writes register, the second will byteswap
it if host operates in BE mode.

Changes are trivial sed like replacement of __raw_xxx functions
with xxx_relaxed variant.

Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Victor Kamensky and committed by
Wim Van Sebroeck
4a7e94a0 b0df38dd

+18 -18
+18 -18
drivers/watchdog/omap_wdt.c
··· 68 68 void __iomem *base = wdev->base; 69 69 70 70 /* wait for posted write to complete */ 71 - while ((__raw_readl(base + OMAP_WATCHDOG_WPS)) & 0x08) 71 + while ((readl_relaxed(base + OMAP_WATCHDOG_WPS)) & 0x08) 72 72 cpu_relax(); 73 73 74 74 wdev->wdt_trgr_pattern = ~wdev->wdt_trgr_pattern; 75 - __raw_writel(wdev->wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR)); 75 + writel_relaxed(wdev->wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR)); 76 76 77 77 /* wait for posted write to complete */ 78 - while ((__raw_readl(base + OMAP_WATCHDOG_WPS)) & 0x08) 78 + while ((readl_relaxed(base + OMAP_WATCHDOG_WPS)) & 0x08) 79 79 cpu_relax(); 80 80 /* reloaded WCRR from WLDR */ 81 81 } ··· 85 85 void __iomem *base = wdev->base; 86 86 87 87 /* Sequence to enable the watchdog */ 88 - __raw_writel(0xBBBB, base + OMAP_WATCHDOG_SPR); 89 - while ((__raw_readl(base + OMAP_WATCHDOG_WPS)) & 0x10) 88 + writel_relaxed(0xBBBB, base + OMAP_WATCHDOG_SPR); 89 + while ((readl_relaxed(base + OMAP_WATCHDOG_WPS)) & 0x10) 90 90 cpu_relax(); 91 91 92 - __raw_writel(0x4444, base + OMAP_WATCHDOG_SPR); 93 - while ((__raw_readl(base + OMAP_WATCHDOG_WPS)) & 0x10) 92 + writel_relaxed(0x4444, base + OMAP_WATCHDOG_SPR); 93 + while ((readl_relaxed(base + OMAP_WATCHDOG_WPS)) & 0x10) 94 94 cpu_relax(); 95 95 } 96 96 ··· 99 99 void __iomem *base = wdev->base; 100 100 101 101 /* sequence required to disable watchdog */ 102 - __raw_writel(0xAAAA, base + OMAP_WATCHDOG_SPR); /* TIMER_MODE */ 103 - while (__raw_readl(base + OMAP_WATCHDOG_WPS) & 0x10) 102 + writel_relaxed(0xAAAA, base + OMAP_WATCHDOG_SPR); /* TIMER_MODE */ 103 + while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x10) 104 104 cpu_relax(); 105 105 106 - __raw_writel(0x5555, base + OMAP_WATCHDOG_SPR); /* TIMER_MODE */ 107 - while (__raw_readl(base + OMAP_WATCHDOG_WPS) & 0x10) 106 + writel_relaxed(0x5555, base + OMAP_WATCHDOG_SPR); /* TIMER_MODE */ 107 + while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x10) 108 108 cpu_relax(); 109 109 } 110 110 ··· 115 115 void __iomem *base = wdev->base; 116 116 117 117 /* just count up at 32 KHz */ 118 - while (__raw_readl(base + OMAP_WATCHDOG_WPS) & 0x04) 118 + while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x04) 119 119 cpu_relax(); 120 120 121 - __raw_writel(pre_margin, base + OMAP_WATCHDOG_LDR); 122 - while (__raw_readl(base + OMAP_WATCHDOG_WPS) & 0x04) 121 + writel_relaxed(pre_margin, base + OMAP_WATCHDOG_LDR); 122 + while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x04) 123 123 cpu_relax(); 124 124 } 125 125 ··· 135 135 pm_runtime_get_sync(wdev->dev); 136 136 137 137 /* initialize prescaler */ 138 - while (__raw_readl(base + OMAP_WATCHDOG_WPS) & 0x01) 138 + while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x01) 139 139 cpu_relax(); 140 140 141 - __raw_writel((1 << 5) | (PTV << 2), base + OMAP_WATCHDOG_CNTRL); 142 - while (__raw_readl(base + OMAP_WATCHDOG_WPS) & 0x01) 141 + writel_relaxed((1 << 5) | (PTV << 2), base + OMAP_WATCHDOG_CNTRL); 142 + while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x01) 143 143 cpu_relax(); 144 144 145 145 omap_wdt_set_timer(wdev, wdog->timeout); ··· 275 275 } 276 276 277 277 pr_info("OMAP Watchdog Timer Rev 0x%02x: initial timeout %d sec\n", 278 - __raw_readl(wdev->base + OMAP_WATCHDOG_REV) & 0xFF, 278 + readl_relaxed(wdev->base + OMAP_WATCHDOG_REV) & 0xFF, 279 279 omap_wdt->timeout); 280 280 281 281 pm_runtime_put_sync(wdev->dev);