Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: sunxi: Support I/O bias voltage setting on H6

H6 SoC has a "pio group withstand voltage mode" register (datasheet
description), that needs to be used to select either 1.8V or 3.3V I/O mode,
based on what voltage is powering the respective pin banks and is thus used
for I/O signals.

Add support for configuring this register according to the voltage of the
pin bank regulator (if enabled).

This is similar to the support for I/O bias voltage setting patch for A80
and the same concerns apply. See:

commit 402bfb3c1352 ("Support I/O bias voltage setting on A80")

Signed-off-by: Ondrej Jirman <megous@megous.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Ondrej Jirman and committed by
Linus Walleij
cc62383f f7275345

+19
+1
drivers/pinctrl/sunxi/pinctrl-sun50i-h6.c
··· 591 591 .irq_banks = 4, 592 592 .irq_bank_map = h6_irq_bank_map, 593 593 .irq_read_needs_mux = true, 594 + .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL, 594 595 }; 595 596 596 597 static int h6_pinctrl_probe(struct platform_device *pdev)
+11
drivers/pinctrl/sunxi/pinctrl-sunxi.c
··· 614 614 unsigned pin, 615 615 struct regulator *supply) 616 616 { 617 + unsigned short bank = pin / PINS_PER_BANK; 618 + unsigned long flags; 617 619 u32 val, reg; 618 620 int uV; 619 621 ··· 652 650 reg = readl(pctl->membase + sunxi_grp_config_reg(pin)); 653 651 reg &= ~IO_BIAS_MASK; 654 652 writel(reg | val, pctl->membase + sunxi_grp_config_reg(pin)); 653 + return 0; 654 + case BIAS_VOLTAGE_PIO_POW_MODE_SEL: 655 + val = uV <= 1800000 ? 1 : 0; 656 + 657 + raw_spin_lock_irqsave(&pctl->lock, flags); 658 + reg = readl(pctl->membase + PIO_POW_MOD_SEL_REG); 659 + reg &= ~(1 << bank); 660 + writel(reg | val << bank, pctl->membase + PIO_POW_MOD_SEL_REG); 661 + raw_spin_unlock_irqrestore(&pctl->lock, flags); 655 662 return 0; 656 663 default: 657 664 return -EINVAL;
+7
drivers/pinctrl/sunxi/pinctrl-sunxi.h
··· 95 95 #define PINCTRL_SUN7I_A20 BIT(7) 96 96 #define PINCTRL_SUN8I_R40 BIT(8) 97 97 98 + #define PIO_POW_MOD_SEL_REG 0x340 99 + 98 100 enum sunxi_desc_bias_voltage { 99 101 BIAS_VOLTAGE_NONE, 100 102 /* ··· 104 102 * Pn_GRP_CONFIG registers, as seen on A80 SoC. 105 103 */ 106 104 BIAS_VOLTAGE_GRP_CONFIG, 105 + /* 106 + * Bias voltage is set through PIO_POW_MOD_SEL_REG 107 + * register, as seen on H6 SoC, for example. 108 + */ 109 + BIAS_VOLTAGE_PIO_POW_MODE_SEL, 107 110 }; 108 111 109 112 struct sunxi_desc_function {