Skip to content

Commit b6d7406

Browse files
esmilConchuOD
authored andcommitted
reset: starfive: jh71x0: Use 32bit I/O on 32bit registers
We currently use 64bit I/O on the 32bit registers. This works because there are an even number of assert and status registers, so they're only ever accessed in pairs on 64bit boundaries. There are however other reset controllers for audio and video on the JH7100 SoC with only one status register that isn't 64bit aligned so 64bit I/O results in an unaligned access exception. Switch to 32bit I/O in preparation for supporting these resets too. Tested-by: Tommaso Merciai <tomm.merciai@gmail.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> Signed-off-by: Emil Renner Berthing <kernel@esmil.dk> Signed-off-by: Hal Feng <hal.feng@starfivetech.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
1 parent 0333103 commit b6d7406

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
* lines don't though, so store the expected value of the status registers when
3131
* all lines are asserted.
3232
*/
33-
static const u64 jh7100_reset_asserted[2] = {
33+
static const u32 jh7100_reset_asserted[4] = {
3434
/* STATUS0 */
35-
BIT_ULL_MASK(JH7100_RST_U74) |
36-
BIT_ULL_MASK(JH7100_RST_VP6_DRESET) |
37-
BIT_ULL_MASK(JH7100_RST_VP6_BRESET) |
35+
BIT(JH7100_RST_U74 % 32) |
36+
BIT(JH7100_RST_VP6_DRESET % 32) |
37+
BIT(JH7100_RST_VP6_BRESET % 32),
3838
/* STATUS1 */
39-
BIT_ULL_MASK(JH7100_RST_HIFI4_DRESET) |
40-
BIT_ULL_MASK(JH7100_RST_HIFI4_BRESET),
39+
BIT(JH7100_RST_HIFI4_DRESET % 32) |
40+
BIT(JH7100_RST_HIFI4_BRESET % 32),
4141
/* STATUS2 */
42-
BIT_ULL_MASK(JH7100_RST_E24) |
42+
BIT(JH7100_RST_E24 % 32),
4343
/* STATUS3 */
4444
0,
4545
};

drivers/reset/starfive/reset-starfive-jh71x0.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <linux/bitmap.h>
99
#include <linux/device.h>
1010
#include <linux/io.h>
11-
#include <linux/io-64-nonatomic-lo-hi.h>
1211
#include <linux/iopoll.h>
1312
#include <linux/reset-controller.h>
1413
#include <linux/spinlock.h>
@@ -21,7 +20,7 @@ struct jh71x0_reset {
2120
spinlock_t lock;
2221
void __iomem *assert;
2322
void __iomem *status;
24-
const u64 *asserted;
23+
const u32 *asserted;
2524
};
2625

2726
static inline struct jh71x0_reset *
@@ -34,12 +33,12 @@ static int jh71x0_reset_update(struct reset_controller_dev *rcdev,
3433
unsigned long id, bool assert)
3534
{
3635
struct jh71x0_reset *data = jh71x0_reset_from(rcdev);
37-
unsigned long offset = BIT_ULL_WORD(id);
38-
u64 mask = BIT_ULL_MASK(id);
39-
void __iomem *reg_assert = data->assert + offset * sizeof(u64);
40-
void __iomem *reg_status = data->status + offset * sizeof(u64);
41-
u64 done = data->asserted ? data->asserted[offset] & mask : 0;
42-
u64 value;
36+
unsigned long offset = id / 32;
37+
u32 mask = BIT(id % 32);
38+
void __iomem *reg_assert = data->assert + offset * sizeof(u32);
39+
void __iomem *reg_status = data->status + offset * sizeof(u32);
40+
u32 done = data->asserted ? data->asserted[offset] & mask : 0;
41+
u32 value;
4342
unsigned long flags;
4443
int ret;
4544

@@ -48,15 +47,15 @@ static int jh71x0_reset_update(struct reset_controller_dev *rcdev,
4847

4948
spin_lock_irqsave(&data->lock, flags);
5049

51-
value = readq(reg_assert);
50+
value = readl(reg_assert);
5251
if (assert)
5352
value |= mask;
5453
else
5554
value &= ~mask;
56-
writeq(value, reg_assert);
55+
writel(value, reg_assert);
5756

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

6160
spin_unlock_irqrestore(&data->lock, flags);
6261
return ret;
@@ -90,10 +89,10 @@ static int jh71x0_reset_status(struct reset_controller_dev *rcdev,
9089
unsigned long id)
9190
{
9291
struct jh71x0_reset *data = jh71x0_reset_from(rcdev);
93-
unsigned long offset = BIT_ULL_WORD(id);
94-
u64 mask = BIT_ULL_MASK(id);
95-
void __iomem *reg_status = data->status + offset * sizeof(u64);
96-
u64 value = readq(reg_status);
92+
unsigned long offset = id / 32;
93+
u32 mask = BIT(id % 32);
94+
void __iomem *reg_status = data->status + offset * sizeof(u32);
95+
u32 value = readl(reg_status);
9796

9897
return !((value ^ data->asserted[offset]) & mask);
9998
}
@@ -107,7 +106,7 @@ static const struct reset_control_ops jh71x0_reset_ops = {
107106

108107
int reset_starfive_jh71x0_register(struct device *dev, struct device_node *of_node,
109108
void __iomem *assert, void __iomem *status,
110-
const u64 *asserted, unsigned int nr_resets,
109+
const u32 *asserted, unsigned int nr_resets,
111110
struct module *owner)
112111
{
113112
struct jh71x0_reset *data;

drivers/reset/starfive/reset-starfive-jh71x0.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
int reset_starfive_jh71x0_register(struct device *dev, struct device_node *of_node,
1010
void __iomem *assert, void __iomem *status,
11-
const u64 *asserted, unsigned int nr_resets,
11+
const u32 *asserted, unsigned int nr_resets,
1212
struct module *owner);
1313

1414
#endif /* __RESET_STARFIVE_JH71X0_H */

0 commit comments

Comments
 (0)