Commit 11282a49 authored by Andre Przywara's avatar Andre Przywara Committed by Philipp Zabel

reset: sunxi: fix for 64-bit compilation

The Allwinner reset controller has 32-bit registers, so translating
the reset cell number into a register and bit offset should not use
any architecture dependent data size. Otherwise this breaks for 64-bit
architectures like arm64.
Fix this by making it clear that it's the hardware register width which
matters here in the calculation.
Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
Acked-by: default avatarChen-Yu Tsai <wens@csie.org>
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent 62700682
...@@ -34,15 +34,16 @@ static int sunxi_reset_assert(struct reset_controller_dev *rcdev, ...@@ -34,15 +34,16 @@ static int sunxi_reset_assert(struct reset_controller_dev *rcdev,
struct sunxi_reset_data *data = container_of(rcdev, struct sunxi_reset_data *data = container_of(rcdev,
struct sunxi_reset_data, struct sunxi_reset_data,
rcdev); rcdev);
int bank = id / BITS_PER_LONG; int reg_width = sizeof(u32);
int offset = id % BITS_PER_LONG; int bank = id / (reg_width * BITS_PER_BYTE);
int offset = id % (reg_width * BITS_PER_BYTE);
unsigned long flags; unsigned long flags;
u32 reg; u32 reg;
spin_lock_irqsave(&data->lock, flags); spin_lock_irqsave(&data->lock, flags);
reg = readl(data->membase + (bank * 4)); reg = readl(data->membase + (bank * reg_width));
writel(reg & ~BIT(offset), data->membase + (bank * 4)); writel(reg & ~BIT(offset), data->membase + (bank * reg_width));
spin_unlock_irqrestore(&data->lock, flags); spin_unlock_irqrestore(&data->lock, flags);
...@@ -55,15 +56,16 @@ static int sunxi_reset_deassert(struct reset_controller_dev *rcdev, ...@@ -55,15 +56,16 @@ static int sunxi_reset_deassert(struct reset_controller_dev *rcdev,
struct sunxi_reset_data *data = container_of(rcdev, struct sunxi_reset_data *data = container_of(rcdev,
struct sunxi_reset_data, struct sunxi_reset_data,
rcdev); rcdev);
int bank = id / BITS_PER_LONG; int reg_width = sizeof(u32);
int offset = id % BITS_PER_LONG; int bank = id / (reg_width * BITS_PER_BYTE);
int offset = id % (reg_width * BITS_PER_BYTE);
unsigned long flags; unsigned long flags;
u32 reg; u32 reg;
spin_lock_irqsave(&data->lock, flags); spin_lock_irqsave(&data->lock, flags);
reg = readl(data->membase + (bank * 4)); reg = readl(data->membase + (bank * reg_width));
writel(reg | BIT(offset), data->membase + (bank * 4)); writel(reg | BIT(offset), data->membase + (bank * reg_width));
spin_unlock_irqrestore(&data->lock, flags); spin_unlock_irqrestore(&data->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment