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

pinctrl: sunxi: Prepare for alternative bias voltage setting methods

H6 has a different I/O voltage bias setting method than A80. Prepare
existing code for using alternative bias voltage setting methods.

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
f7275345 483d70d7

+37 -21
+1 -1
drivers/pinctrl/sunxi/pinctrl-sun9i-a80-r.c
··· 153 153 .pin_base = PL_BASE, 154 154 .irq_banks = 2, 155 155 .disable_strict_mode = true, 156 - .has_io_bias_cfg = true, 156 + .io_bias_cfg_variant = BIAS_VOLTAGE_GRP_CONFIG, 157 157 }; 158 158 159 159 static int sun9i_a80_r_pinctrl_probe(struct platform_device *pdev)
+1 -1
drivers/pinctrl/sunxi/pinctrl-sun9i-a80.c
··· 722 722 .npins = ARRAY_SIZE(sun9i_a80_pins), 723 723 .irq_banks = 5, 724 724 .disable_strict_mode = true, 725 - .has_io_bias_cfg = true, 725 + .io_bias_cfg_variant = BIAS_VOLTAGE_GRP_CONFIG, 726 726 }; 727 727 728 728 static int sun9i_a80_pinctrl_probe(struct platform_device *pdev)
+25 -18
drivers/pinctrl/sunxi/pinctrl-sunxi.c
··· 617 617 u32 val, reg; 618 618 int uV; 619 619 620 - if (!pctl->desc->has_io_bias_cfg) 620 + if (!pctl->desc->io_bias_cfg_variant) 621 621 return 0; 622 622 623 623 uV = regulator_get_voltage(supply); ··· 628 628 if (uV == 0) 629 629 return 0; 630 630 631 - /* Configured value must be equal or greater to actual voltage */ 632 - if (uV <= 1800000) 633 - val = 0x0; /* 1.8V */ 634 - else if (uV <= 2500000) 635 - val = 0x6; /* 2.5V */ 636 - else if (uV <= 2800000) 637 - val = 0x9; /* 2.8V */ 638 - else if (uV <= 3000000) 639 - val = 0xA; /* 3.0V */ 640 - else 641 - val = 0xD; /* 3.3V */ 631 + switch (pctl->desc->io_bias_cfg_variant) { 632 + case BIAS_VOLTAGE_GRP_CONFIG: 633 + /* 634 + * Configured value must be equal or greater to actual 635 + * voltage. 636 + */ 637 + if (uV <= 1800000) 638 + val = 0x0; /* 1.8V */ 639 + else if (uV <= 2500000) 640 + val = 0x6; /* 2.5V */ 641 + else if (uV <= 2800000) 642 + val = 0x9; /* 2.8V */ 643 + else if (uV <= 3000000) 644 + val = 0xA; /* 3.0V */ 645 + else 646 + val = 0xD; /* 3.3V */ 642 647 643 - pin -= pctl->desc->pin_base; 648 + pin -= pctl->desc->pin_base; 644 649 645 - reg = readl(pctl->membase + sunxi_grp_config_reg(pin)); 646 - reg &= ~IO_BIAS_MASK; 647 - writel(reg | val, pctl->membase + sunxi_grp_config_reg(pin)); 648 - 649 - return 0; 650 + reg = readl(pctl->membase + sunxi_grp_config_reg(pin)); 651 + reg &= ~IO_BIAS_MASK; 652 + writel(reg | val, pctl->membase + sunxi_grp_config_reg(pin)); 653 + return 0; 654 + default: 655 + return -EINVAL; 656 + } 650 657 } 651 658 652 659 static int sunxi_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev)
+10 -1
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 + enum sunxi_desc_bias_voltage { 99 + BIAS_VOLTAGE_NONE, 100 + /* 101 + * Bias voltage configuration is done through 102 + * Pn_GRP_CONFIG registers, as seen on A80 SoC. 103 + */ 104 + BIAS_VOLTAGE_GRP_CONFIG, 105 + }; 106 + 98 107 struct sunxi_desc_function { 99 108 unsigned long variant; 100 109 const char *name; ··· 126 117 const unsigned int *irq_bank_map; 127 118 bool irq_read_needs_mux; 128 119 bool disable_strict_mode; 129 - bool has_io_bias_cfg; 120 + enum sunxi_desc_bias_voltage io_bias_cfg_variant; 130 121 }; 131 122 132 123 struct sunxi_pinctrl_function {