Skip to content

Commit c09463c

Browse files
committed
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>
1 parent 93fdad1 commit c09463c

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

drivers/reset/starfive/reset-starfive-jh7100.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
* lines don't though, so store the expected value of the status registers when
3434
* all lines are asserted.
3535
*/
36-
static const u64 jh7100_reset_asserted[2] = {
36+
static const u32 jh7100_reset_asserted[4] = {
3737
/* STATUS0 */
38-
BIT_ULL_MASK(JH7100_RST_U74) |
39-
BIT_ULL_MASK(JH7100_RST_VP6_DRESET) |
40-
BIT_ULL_MASK(JH7100_RST_VP6_BRESET) |
38+
BIT(JH7100_RST_U74 % 32) |
39+
BIT(JH7100_RST_VP6_DRESET % 32) |
40+
BIT(JH7100_RST_VP6_BRESET % 32),
4141
/* STATUS1 */
42-
BIT_ULL_MASK(JH7100_RST_HIFI4_DRESET) |
43-
BIT_ULL_MASK(JH7100_RST_HIFI4_BRESET),
42+
BIT(JH7100_RST_HIFI4_DRESET % 32) |
43+
BIT(JH7100_RST_HIFI4_BRESET % 32),
4444
/* STATUS2 */
45-
BIT_ULL_MASK(JH7100_RST_E24) |
45+
BIT(JH7100_RST_E24 % 32),
4646
/* STATUS3 */
4747
0,
4848
};
@@ -64,12 +64,12 @@ static int jh7100_reset_update(struct reset_controller_dev *rcdev,
6464
unsigned long id, bool assert)
6565
{
6666
struct jh7100_reset *data = jh7100_reset_from(rcdev);
67-
unsigned long offset = BIT_ULL_WORD(id);
68-
u64 mask = BIT_ULL_MASK(id);
69-
void __iomem *reg_assert = data->base + JH7100_RESET_ASSERT0 + offset * sizeof(u64);
70-
void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u64);
71-
u64 done = jh7100_reset_asserted[offset] & mask;
72-
u64 value;
67+
unsigned long offset = id / 32;
68+
u32 mask = BIT(id % 32);
69+
void __iomem *reg_assert = data->base + JH7100_RESET_ASSERT0 + offset * sizeof(u32);
70+
void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u32);
71+
u32 done = jh7100_reset_asserted[offset] & mask;
72+
u32 value;
7373
unsigned long flags;
7474
int ret;
7575

@@ -78,15 +78,15 @@ static int jh7100_reset_update(struct reset_controller_dev *rcdev,
7878

7979
spin_lock_irqsave(&data->lock, flags);
8080

81-
value = readq(reg_assert);
81+
value = readl(reg_assert);
8282
if (assert)
8383
value |= mask;
8484
else
8585
value &= ~mask;
86-
writeq(value, reg_assert);
86+
writel(value, reg_assert);
8787

8888
/* if the associated clock is gated, deasserting might otherwise hang forever */
89-
ret = readq_poll_timeout_atomic(reg_status, value, (value & mask) == done, 0, 1000);
89+
ret = readl_poll_timeout_atomic(reg_status, value, (value & mask) == done, 0, 1000);
9090

9191
spin_unlock_irqrestore(&data->lock, flags);
9292
return ret;
@@ -120,10 +120,10 @@ static int jh7100_reset_status(struct reset_controller_dev *rcdev,
120120
unsigned long id)
121121
{
122122
struct jh7100_reset *data = jh7100_reset_from(rcdev);
123-
unsigned long offset = BIT_ULL_WORD(id);
124-
u64 mask = BIT_ULL_MASK(id);
125-
void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u64);
126-
u64 value = readq(reg_status);
123+
unsigned long offset = id / 32;
124+
u32 mask = BIT(id % 32);
125+
void __iomem *reg_status = data->base + JH7100_RESET_STATUS0 + offset * sizeof(u32);
126+
u32 value = readl(reg_status);
127127

128128
return !((value ^ jh7100_reset_asserted[offset]) & mask);
129129
}

0 commit comments

Comments
 (0)