mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 06:31:58 +02:00
Renesas driver updates for v6.5 (take two)
- Convert the R-Mobile SYSC driver to readl_poll_timeout_atomic(). -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQ9qaHoIs/1I4cXmEiKwlD9ZEnxcAUCZIL1sgAKCRCKwlD9ZEnx cEyOAP9s0vZ+GG/BAEiONvu+/QTO0v92XQyptEDaTZlbNz4bqQEAoSmm1w1RzZcP BwFQzHfnFHjArdp9+3iiSXhjDlhuqQA= =26KV -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEiK/NIGsWEZVxh/FrYKtH/8kJUicFAmSDHisACgkQYKtH/8kJ Uie0AQ/+JWCY05otLeEzJaxsKkZPDb83aiHxOXA5qBgWnm01ou12PQc2ylUW+kql LvHn56g2kfsUyw2S3ZbHP6fzGinbZ1LcwawI2aKGCxEicSlNgxsQkV5w+nE7Yrv/ Bx/9YJL/aMq13FtfDJ8GC+vysZzjLTU/5/w1AF55oBOccplqI0zBdWCf2TrgfyBp +1lXj3W5KMJKKnz05gbVnZN2XGLoTJN//dA2W+Szb090IOtnvJnut1VuloHALxt7 JtSPxtBe/jBAX40kxLIxoUGNAP2aXKEccBdexxsHVRTbS7XN3mMRodbh4UDPGemd IvJqsbqCEsV0p/CTpgdIO1l/9T9ojEmKt+Ci5ehpCQDGgu19VeplSFjAAt9nJ1Kd rp3JiAnCDiBeB8fv6jbRYSiGyPMT1e+9QKHamBJgsfhCs00oefYm82PWyChN+AvL Y6FIs4z7OB9NKY1HWMz+WKUYWdVpS2RX5jU3NCdlNrXCrVSQ1rHfUYNaQvL5viGh QW7wuwG7XXW+9Sj1fax0ySJYEnVOSHd4XlFMeOJxn/PUnYBWWjuV4Ud2QTMUk1fm y1TNX51lN0MX1YfYsCec3vAHdvhcJUZZsUZyDmpsk7w3yx6OvaMC7ZCwIn/A3m1T V+AHdVAKOxOEMwt8Ih0ccY6j0nUm2wjXdqhplIunTn/8FYC0jH0= =cOe+ -----END PGP SIGNATURE----- Merge tag 'renesas-drivers-for-v6.5-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-devel into soc/drivers Renesas driver updates for v6.5 (take two) - Convert the R-Mobile SYSC driver to readl_poll_timeout_atomic(). * tag 'renesas-drivers-for-v6.5-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-devel: soc: renesas: rmobile-sysc: Convert to readl_poll_timeout_atomic() iopoll: Do not use timekeeping in read_poll_timeout_atomic() iopoll: Call cpu_relax() in busy loops Link: https://lore.kernel.org/r/cover.1686304612.git.geert+renesas@glider.be Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
commit
c6a5181263
|
|
@ -12,6 +12,8 @@
|
|||
#include <linux/clk/renesas.h>
|
||||
#include <linux/console.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/pm.h>
|
||||
|
|
@ -19,8 +21,6 @@
|
|||
#include <linux/pm_domain.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <asm/io.h>
|
||||
|
||||
/* SYSC */
|
||||
#define SPDCR 0x08 /* SYS Power Down Control Register */
|
||||
#define SWUCR 0x14 /* SYS Wakeup Control Register */
|
||||
|
|
@ -47,6 +47,7 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
|
|||
{
|
||||
struct rmobile_pm_domain *rmobile_pd = to_rmobile_pd(genpd);
|
||||
unsigned int mask = BIT(rmobile_pd->bit_shift);
|
||||
u32 val;
|
||||
|
||||
if (rmobile_pd->suspend) {
|
||||
int ret = rmobile_pd->suspend();
|
||||
|
|
@ -56,14 +57,10 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
|
|||
}
|
||||
|
||||
if (readl(rmobile_pd->base + PSTR) & mask) {
|
||||
unsigned int retry_count;
|
||||
writel(mask, rmobile_pd->base + SPDCR);
|
||||
|
||||
for (retry_count = PSTR_RETRIES; retry_count; retry_count--) {
|
||||
if (!(readl(rmobile_pd->base + SPDCR) & mask))
|
||||
break;
|
||||
cpu_relax();
|
||||
}
|
||||
readl_poll_timeout_atomic(rmobile_pd->base + SPDCR, val,
|
||||
!(val & mask), 0, PSTR_RETRIES);
|
||||
}
|
||||
|
||||
pr_debug("%s: Power off, 0x%08x -> PSTR = 0x%08x\n", genpd->name, mask,
|
||||
|
|
@ -74,8 +71,7 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
|
|||
|
||||
static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd)
|
||||
{
|
||||
unsigned int mask = BIT(rmobile_pd->bit_shift);
|
||||
unsigned int retry_count;
|
||||
unsigned int val, mask = BIT(rmobile_pd->bit_shift);
|
||||
int ret = 0;
|
||||
|
||||
if (readl(rmobile_pd->base + PSTR) & mask)
|
||||
|
|
@ -83,16 +79,9 @@ static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd)
|
|||
|
||||
writel(mask, rmobile_pd->base + SWUCR);
|
||||
|
||||
for (retry_count = 2 * PSTR_RETRIES; retry_count; retry_count--) {
|
||||
if (!(readl(rmobile_pd->base + SWUCR) & mask))
|
||||
break;
|
||||
if (retry_count > PSTR_RETRIES)
|
||||
udelay(PSTR_DELAY_US);
|
||||
else
|
||||
cpu_relax();
|
||||
}
|
||||
if (!retry_count)
|
||||
ret = -EIO;
|
||||
ret = readl_poll_timeout_atomic(rmobile_pd->base + SWUCR, val,
|
||||
(val & mask), PSTR_DELAY_US,
|
||||
PSTR_RETRIES * PSTR_DELAY_US);
|
||||
|
||||
pr_debug("%s: Power on, 0x%08x -> PSTR = 0x%08x\n",
|
||||
rmobile_pd->genpd.name, mask,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
} \
|
||||
if (__sleep_us) \
|
||||
usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
|
||||
cpu_relax(); \
|
||||
} \
|
||||
(cond) ? 0 : -ETIMEDOUT; \
|
||||
})
|
||||
|
|
@ -73,6 +74,10 @@
|
|||
* Returns 0 on success and -ETIMEDOUT upon a timeout. In either
|
||||
* case, the last read value at @args is stored in @val.
|
||||
*
|
||||
* This macro does not rely on timekeeping. Hence it is safe to call even when
|
||||
* timekeeping is suspended, at the expense of an underestimation of wall clock
|
||||
* time, which is rather minimal with a non-zero delay_us.
|
||||
*
|
||||
* When available, you'll probably want to use one of the specialized
|
||||
* macros defined below rather than this macro directly.
|
||||
*/
|
||||
|
|
@ -80,21 +85,30 @@
|
|||
delay_before_read, args...) \
|
||||
({ \
|
||||
u64 __timeout_us = (timeout_us); \
|
||||
s64 __left_ns = __timeout_us * NSEC_PER_USEC; \
|
||||
unsigned long __delay_us = (delay_us); \
|
||||
ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
|
||||
if (delay_before_read && __delay_us) \
|
||||
u64 __delay_ns = __delay_us * NSEC_PER_USEC; \
|
||||
if (delay_before_read && __delay_us) { \
|
||||
udelay(__delay_us); \
|
||||
if (__timeout_us) \
|
||||
__left_ns -= __delay_ns; \
|
||||
} \
|
||||
for (;;) { \
|
||||
(val) = op(args); \
|
||||
if (cond) \
|
||||
break; \
|
||||
if (__timeout_us && \
|
||||
ktime_compare(ktime_get(), __timeout) > 0) { \
|
||||
if (__timeout_us && __left_ns < 0) { \
|
||||
(val) = op(args); \
|
||||
break; \
|
||||
} \
|
||||
if (__delay_us) \
|
||||
if (__delay_us) { \
|
||||
udelay(__delay_us); \
|
||||
if (__timeout_us) \
|
||||
__left_ns -= __delay_ns; \
|
||||
} \
|
||||
cpu_relax(); \
|
||||
if (__timeout_us) \
|
||||
__left_ns--; \
|
||||
} \
|
||||
(cond) ? 0 : -ETIMEDOUT; \
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user