Skip to content

Commit 6d079d9

Browse files
Andre-ARMlinusw
authored andcommitted
pinctrl: sunxi: support moved power configuration registers
The Allwinner pincontroller IP features some registers to control the withstand voltage of each pin group. So far those registers were always located at the same offset, but the A523 SoC has moved them (probably to accommodate all eleven pin banks). Add a flag to note this feature, and use that to program the registers either at offset 0x340 or 0x380. So far no pincontroller driver uses this flag, but we need it for the upcoming A523 support. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent c6c4dc7 commit 6d079d9

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

drivers/pinctrl/sunxi/pinctrl-sunxi.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,19 +736,22 @@ static int sunxi_pinctrl_set_io_bias_cfg(struct sunxi_pinctrl *pctl,
736736
val = uV > 1800000 && uV <= 2500000 ? BIT(bank) : 0;
737737

738738
raw_spin_lock_irqsave(&pctl->lock, flags);
739-
reg = readl(pctl->membase + PIO_POW_MOD_CTL_REG);
739+
reg = readl(pctl->membase + pctl->pow_mod_sel_offset +
740+
PIO_POW_MOD_CTL_OFS);
740741
reg &= ~BIT(bank);
741-
writel(reg | val, pctl->membase + PIO_POW_MOD_CTL_REG);
742+
writel(reg | val, pctl->membase + pctl->pow_mod_sel_offset +
743+
PIO_POW_MOD_CTL_OFS);
742744
raw_spin_unlock_irqrestore(&pctl->lock, flags);
743745

744746
fallthrough;
745747
case BIAS_VOLTAGE_PIO_POW_MODE_SEL:
746748
val = uV <= 1800000 ? 1 : 0;
747749

748750
raw_spin_lock_irqsave(&pctl->lock, flags);
749-
reg = readl(pctl->membase + PIO_POW_MOD_SEL_REG);
751+
reg = readl(pctl->membase + pctl->pow_mod_sel_offset);
750752
reg &= ~(1 << bank);
751-
writel(reg | val << bank, pctl->membase + PIO_POW_MOD_SEL_REG);
753+
writel(reg | val << bank,
754+
pctl->membase + pctl->pow_mod_sel_offset);
752755
raw_spin_unlock_irqrestore(&pctl->lock, flags);
753756
return 0;
754757
default:
@@ -1520,6 +1523,10 @@ int sunxi_pinctrl_init_with_flags(struct platform_device *pdev,
15201523
pctl->pull_regs_offset = PULL_REGS_OFFSET;
15211524
pctl->dlevel_field_width = DLEVEL_FIELD_WIDTH;
15221525
}
1526+
if (flags & SUNXI_PINCTRL_ELEVEN_BANKS)
1527+
pctl->pow_mod_sel_offset = PIO_11B_POW_MOD_SEL_REG;
1528+
else
1529+
pctl->pow_mod_sel_offset = PIO_POW_MOD_SEL_REG;
15231530

15241531
pctl->irq_array = devm_kcalloc(&pdev->dev,
15251532
IRQ_PER_BANK * pctl->desc->irq_banks,

drivers/pinctrl/sunxi/pinctrl-sunxi.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@
8787
#define SUNXI_PINCTRL_VARIANT_MASK GENMASK(7, 0)
8888
#define SUNXI_PINCTRL_NEW_REG_LAYOUT BIT(8)
8989
#define SUNXI_PINCTRL_PORTF_SWITCH BIT(9)
90+
#define SUNXI_PINCTRL_ELEVEN_BANKS BIT(10)
9091

91-
#define PIO_POW_MOD_SEL_REG 0x340
92-
#define PIO_POW_MOD_CTL_REG 0x344
92+
#define PIO_POW_MOD_SEL_REG 0x340
93+
#define PIO_11B_POW_MOD_SEL_REG 0x380
94+
#define PIO_POW_MOD_CTL_OFS 0x004
9395

9496
#define PIO_BANK_K_OFFSET 0x500
9597

@@ -173,6 +175,7 @@ struct sunxi_pinctrl {
173175
u32 bank_mem_size;
174176
u32 pull_regs_offset;
175177
u32 dlevel_field_width;
178+
u32 pow_mod_sel_offset;
176179
};
177180

178181
#define SUNXI_PIN(_pin, ...) \

0 commit comments

Comments
 (0)