Skip to content

Commit d669ec6

Browse files
andredkrzk
authored andcommitted
clk: samsung: clk-pll: simplify samsung_pll_lock_wait()
readl_relaxed_poll_timeout_atomic() has been updated in 2023 in commit 7349a69 ("iopoll: Do not use timekeeping in read_poll_timeout_atomic()") to avoid usage of timekeeping APIs. It also never used udelay() when no delay was given. With the implementation avoiding timekeeping APIs, and with a caller not passing a delay, the timeout argument simply becomes a loop counter. Therefore the code here can be simplified to unconditionally use readl_relaxed_poll_timeout_atomic(). The difference being the last argument, the timeout (loop counter). Simply adjust it to pass the more generous counter in all cases. This change also allows us to drop all code around the pll_early_timeout variable as it is unused now. Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Signed-off-by: André Draszik <andre.draszik@linaro.org> Link: https://patch.msgid.link/20251013-samsung-clk-pll-simplification-v2-1-b9aab610878c@linaro.org Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
1 parent 25e4766 commit d669ec6

1 file changed

Lines changed: 10 additions & 31 deletions

File tree

drivers/clk/samsung/clk-pll.c

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
#include <linux/iopoll.h>
1212
#include <linux/delay.h>
1313
#include <linux/slab.h>
14-
#include <linux/timekeeping.h>
1514
#include <linux/clk-provider.h>
1615
#include <linux/io.h>
1716
#include "clk.h"
1817
#include "clk-pll.h"
1918

20-
#define PLL_TIMEOUT_US 20000U
21-
#define PLL_TIMEOUT_LOOPS 1000000U
19+
#define PLL_TIMEOUT_LOOPS 20000U
2220

2321
struct samsung_clk_pll {
2422
struct clk_hw hw;
@@ -71,20 +69,11 @@ static int samsung_pll_determine_rate(struct clk_hw *hw,
7169
return 0;
7270
}
7371

74-
static bool pll_early_timeout = true;
75-
76-
static int __init samsung_pll_disable_early_timeout(void)
77-
{
78-
pll_early_timeout = false;
79-
return 0;
80-
}
81-
arch_initcall(samsung_pll_disable_early_timeout);
82-
8372
/* Wait until the PLL is locked */
8473
static int samsung_pll_lock_wait(struct samsung_clk_pll *pll,
8574
unsigned int reg_mask)
8675
{
87-
int i, ret;
76+
int ret;
8877
u32 val;
8978

9079
/*
@@ -93,25 +82,15 @@ static int samsung_pll_lock_wait(struct samsung_clk_pll *pll,
9382
* initialized, another when the timekeeping is suspended. udelay() also
9483
* cannot be used when the clocksource is not running on arm64, since
9584
* the current timer is used as cycle counter. So a simple busy loop
96-
* is used here in that special cases. The limit of iterations has been
97-
* derived from experimental measurements of various PLLs on multiple
98-
* Exynos SoC variants. Single register read time was usually in range
99-
* 0.4...1.5 us, never less than 0.4 us.
85+
* is used here.
86+
* The limit of iterations has been derived from experimental
87+
* measurements of various PLLs on multiple Exynos SoC variants. Single
88+
* register read time was usually in range 0.4...1.5 us, never less than
89+
* 0.4 us.
10090
*/
101-
if (pll_early_timeout || timekeeping_suspended) {
102-
i = PLL_TIMEOUT_LOOPS;
103-
while (i-- > 0) {
104-
if (readl_relaxed(pll->con_reg) & reg_mask)
105-
return 0;
106-
107-
cpu_relax();
108-
}
109-
ret = -ETIMEDOUT;
110-
} else {
111-
ret = readl_relaxed_poll_timeout_atomic(pll->con_reg, val,
112-
val & reg_mask, 0, PLL_TIMEOUT_US);
113-
}
114-
91+
ret = readl_relaxed_poll_timeout_atomic(pll->con_reg, val,
92+
val & reg_mask, 0,
93+
PLL_TIMEOUT_LOOPS);
11594
if (ret < 0)
11695
pr_err("Could not lock PLL %s\n", clk_hw_get_name(&pll->hw));
11796

0 commit comments

Comments
 (0)