diff options
author | Romain Izard <romain.izard.pro@gmail.com> | 2017-12-11 11:55:33 -0500 |
---|---|---|
committer | Stephen Boyd <sboyd@codeaurora.org> | 2017-12-21 19:34:03 -0500 |
commit | 960e1c4d93be86d3b118fe22d4edc69e401b28b5 (patch) | |
tree | 5c6ec5df809fc52f291c93394b8fd899868997ea | |
parent | 4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323 (diff) |
clk: at91: pmc: Wait for clocks when resuming
Wait for the syncronization of all clocks when resuming, not only the
UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG()
when interrupts are masked, which is the case in here.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r-- | drivers/clk/at91/pmc.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 775af473fe11..5c2b26de303e 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c | |||
@@ -107,10 +107,20 @@ static int pmc_suspend(void) | |||
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | static bool pmc_ready(unsigned int mask) | ||
111 | { | ||
112 | unsigned int status; | ||
113 | |||
114 | regmap_read(pmcreg, AT91_PMC_SR, &status); | ||
115 | |||
116 | return ((status & mask) == mask) ? 1 : 0; | ||
117 | } | ||
118 | |||
110 | static void pmc_resume(void) | 119 | static void pmc_resume(void) |
111 | { | 120 | { |
112 | int i, ret = 0; | 121 | int i; |
113 | u32 tmp; | 122 | u32 tmp; |
123 | u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA; | ||
114 | 124 | ||
115 | regmap_read(pmcreg, AT91_PMC_MCKR, &tmp); | 125 | regmap_read(pmcreg, AT91_PMC_MCKR, &tmp); |
116 | if (pmc_cache.mckr != tmp) | 126 | if (pmc_cache.mckr != tmp) |
@@ -134,13 +144,11 @@ static void pmc_resume(void) | |||
134 | AT91_PMC_PCR_CMD); | 144 | AT91_PMC_PCR_CMD); |
135 | } | 145 | } |
136 | 146 | ||
137 | if (pmc_cache.uckr & AT91_PMC_UPLLEN) { | 147 | if (pmc_cache.uckr & AT91_PMC_UPLLEN) |
138 | ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp, | 148 | mask |= AT91_PMC_LOCKU; |
139 | !(tmp & AT91_PMC_LOCKU), | 149 | |
140 | 10, 5000); | 150 | while (!pmc_ready(mask)) |
141 | if (ret) | 151 | cpu_relax(); |
142 | pr_crit("USB PLL didn't lock when resuming\n"); | ||
143 | } | ||
144 | } | 152 | } |
145 | 153 | ||
146 | static struct syscore_ops pmc_syscore_ops = { | 154 | static struct syscore_ops pmc_syscore_ops = { |