[PATCH v14 5/5] clocksource: dw_apb_timer: Use reset array API to handle all resets
From: dongxuyang
Date: Thu Jul 30 2026 - 07:34:05 EST
From: Xuyang Dong <dongxuyang@xxxxxxxxxxxxxxxxxx>
timer_get_base_and_rate() only fetched a single, index-0 reset control
via of_reset_control_get(np, NULL), which does not consult reset-names
and always resolves to the first entry. With the binding now allowing a
second entry (APB interface reset), a device tree that lists both lines
would leave the second entry permanently unasserted, since the driver
never touches it.
Replace it with of_reset_control_array_get_optional_exclusive() to
fetch and trigger all reset lines listed in the device tree at once,
ensuring every line is properly asserted and deasserted rather than
only the first. The exclusive references are intentionally retained
for the lifetime of the timer -- the hardware continues to operate
after initialization, and holding the references keeps the resets
deasserted, preventing other devices on the bus from re-asserting
them while the timer is running.
Signed-off-by: Xuyang Dong <dongxuyang@xxxxxxxxxxxxxxxxxx>
---
drivers/clocksource/dw_apb_timer_of.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
index 3245eb0c602d..3788b46e49ed 100644
--- a/drivers/clocksource/dw_apb_timer_of.c
+++ b/drivers/clocksource/dw_apb_timer_of.c
@@ -29,9 +29,14 @@ static int __init timer_get_base_and_rate(struct device_node *np,
/*
* Reset the timer if the reset control is available, wiping
- * out the state the firmware may have left it
+ * out the state the firmware may have left it.
+ * Use the array variant to fetch and trigger all reset lines
+ * (e.g., timer and APB interface resets) together, without
+ * ordering requirements.
+ * The exclusive references are intentionally held to keep the
+ * resets deasserted while the timer is running.
*/
- rstc = of_reset_control_get(np, NULL);
+ rstc = of_reset_control_array_get_optional_exclusive(np);
if (!IS_ERR(rstc)) {
reset_control_assert(rstc);
reset_control_deassert(rstc);
--
2.34.1