105 lines
3.8 KiB
Diff
105 lines
3.8 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Emil Renner Berthing <kernel@esmil.dk>
|
||
|
Date: Wed, 24 Nov 2021 01:30:54 +0100
|
||
|
Subject: reset: starfive: Use 32bit I/O on 32bit registers
|
||
|
|
||
|
The driver currently uses 64bit I/O on the 32bit registers. This works
|
||
|
because there are 4 assert registers and 4 status register, so they're
|
||
|
only ever accessed on 64bit boundaries.
|
||
|
|
||
|
There are however other reset controllers for audio and video on the SoC
|
||
|
with only one status register that isn't 64bit aligned so 64bit I/O
|
||
|
would result in an unaligned access exception.
|
||
|
|
||
|
Switch to 32bit I/O in preparation for supporting these resets too.
|
||
|
|
||
|
Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
|
||
|
---
|
||
|
drivers/reset/starfive/reset-starfive-jh7100.c | 40 +++++-----
|
||
|
1 file changed, 20 insertions(+), 20 deletions(-)
|
||
|
|
||
|
diff --git a/drivers/reset/starfive/reset-starfive-jh7100.c b/drivers/reset/starfive/reset-starfive-jh7100.c
|
||
|
index fc44b2fb3e03..7563d317f5c8 100644
|
||
|
--- a/drivers/reset/starfive/reset-starfive-jh7100.c
|
||
|
+++ b/drivers/reset/starfive/reset-starfive-jh7100.c
|
||
|
@@ -34,16 +34,16 @@
|
||
|
* lines don't though, so store the expected value of the status registers when
|
||
|
* all lines are asserted.
|
||
|
*/
|
||
|
-static const u64 jh7100_reset_asserted[2] = {
|
||
|
+static const u32 jh7100_reset_asserted[4] = {
|
||
|
/* STATUS0 */
|
||
|
- BIT_ULL_MASK(JH7100_RST_U74) |
|
||
|
- BIT_ULL_MASK(JH7100_RST_VP6_DRESET) |
|
||
|
- BIT_ULL_MASK(JH7100_RST_VP6_BRESET) |
|
||
|
+ BIT(JH7100_RST_U74 % 32) |
|
||
|
+ BIT(JH7100_RST_VP6_DRESET % 32) |
|
||
|
+ BIT(JH7100_RST_VP6_BRESET % 32),
|
||
|
/* STATUS1 */
|
||
|
- BIT_ULL_MASK(JH7100_RST_HIFI4_DRESET) |
|
||
|
- BIT_ULL_MASK(JH7100_RST_HIFI4_BRESET),
|
||
|
+ BIT(JH7100_RST_HIFI4_DRESET % 32) |
|
||
|
+ BIT(JH7100_RST_HIFI4_BRESET % 32),
|
||
|
/* STATUS2 */
|
||
|
- BIT_ULL_MASK(JH7100_RST_E24) |
|
||
|
+ BIT(JH7100_RST_E24 % 32),
|
||
|
/* STATUS3 */
|
||
|
0,
|
||
|
};
|
||
|
@@ -65,12 +65,12 @@ static int jh7100_reset_update(struct reset_controller_dev *rcdev,
|
||
|
unsigned long id, bool assert)
|
||
|
{
|
||
|
struct jh7100_reset *data = jh7100_reset_from(rcdev);
|
||
|
- unsigned long offset = BIT_ULL_WORD(id);
|
||
|
- u64 mask = BIT_ULL_MASK(id);
|
||
|
- void __iomem *reg_assert = data->base + JH7100_RESET_ASSERT0 + offset * sizeof(u64);
|
||
|
- void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u64);
|
||
|
- u64 done = jh7100_reset_asserted[offset] & mask;
|
||
|
- u64 value;
|
||
|
+ unsigned long offset = id / 32;
|
||
|
+ u32 mask = BIT(id % 32);
|
||
|
+ void __iomem *reg_assert = data->base + JH7100_RESET_ASSERT0 + offset * sizeof(u32);
|
||
|
+ void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u32);
|
||
|
+ u32 done = jh7100_reset_asserted[offset] & mask;
|
||
|
+ u32 value;
|
||
|
unsigned long flags;
|
||
|
int ret;
|
||
|
|
||
|
@@ -79,15 +79,15 @@ static int jh7100_reset_update(struct reset_controller_dev *rcdev,
|
||
|
|
||
|
spin_lock_irqsave(&data->lock, flags);
|
||
|
|
||
|
- value = readq(reg_assert);
|
||
|
+ value = readl(reg_assert);
|
||
|
if (assert)
|
||
|
value |= mask;
|
||
|
else
|
||
|
value &= ~mask;
|
||
|
- writeq(value, reg_assert);
|
||
|
+ writel(value, reg_assert);
|
||
|
|
||
|
/* if the associated clock is gated, deasserting might otherwise hang forever */
|
||
|
- ret = readq_poll_timeout_atomic(reg_status, value, (value & mask) == done, 0, 1000);
|
||
|
+ ret = readl_poll_timeout_atomic(reg_status, value, (value & mask) == done, 0, 1000);
|
||
|
|
||
|
spin_unlock_irqrestore(&data->lock, flags);
|
||
|
return ret;
|
||
|
@@ -121,10 +121,10 @@ static int jh7100_reset_status(struct reset_controller_dev *rcdev,
|
||
|
unsigned long id)
|
||
|
{
|
||
|
struct jh7100_reset *data = jh7100_reset_from(rcdev);
|
||
|
- unsigned long offset = BIT_ULL_WORD(id);
|
||
|
- u64 mask = BIT_ULL_MASK(id);
|
||
|
- void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u64);
|
||
|
- u64 value = readq(reg_status);
|
||
|
+ unsigned long offset = id / 32;
|
||
|
+ u32 mask = BIT(id % 32);
|
||
|
+ void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u32);
|
||
|
+ u32 value = readl(reg_status);
|
||
|
|
||
|
return !((value ^ jh7100_reset_asserted[offset]) & mask);
|
||
|
}
|
||
|
--
|
||
|
Armbian
|
||
|
|