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

pinctrl: aspeed: Use masks to describe pinconf bitfields

Since some of the AST2600 pinconf setting are not just single bit, modified
aspeed_pin_config @bit to @mask and add @mask to aspeed_pin_config_map to
support configuring multiple bits.

Signed-off-by: Johnny Huang <johnny_huang@aspeedtech.com>
[AJ: Tweak commit message]
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Link: https://lore.kernel.org/r/20191202061432.3996-7-andrew@aj.id.au
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Johnny Huang and committed by
Linus Walleij
5f52c853 5b854f28

+20 -19
+5 -5
drivers/pinctrl/aspeed/pinctrl-aspeed-g4.c
··· 2595 2595 } 2596 2596 2597 2597 static const struct aspeed_pin_config_map aspeed_g4_pin_config_map[] = { 2598 - { PIN_CONFIG_BIAS_PULL_DOWN, 0, 1}, 2599 - { PIN_CONFIG_BIAS_PULL_DOWN, -1, 0}, 2600 - { PIN_CONFIG_BIAS_DISABLE, -1, 1}, 2601 - { PIN_CONFIG_DRIVE_STRENGTH, 8, 0}, 2602 - { PIN_CONFIG_DRIVE_STRENGTH, 16, 1}, 2598 + { PIN_CONFIG_BIAS_PULL_DOWN, 0, 1, BIT_MASK(0)}, 2599 + { PIN_CONFIG_BIAS_PULL_DOWN, -1, 0, BIT_MASK(0)}, 2600 + { PIN_CONFIG_BIAS_DISABLE, -1, 1, BIT_MASK(0)}, 2601 + { PIN_CONFIG_DRIVE_STRENGTH, 8, 0, BIT_MASK(0)}, 2602 + { PIN_CONFIG_DRIVE_STRENGTH, 16, 1, BIT_MASK(0)}, 2603 2603 }; 2604 2604 2605 2605 static const struct aspeed_pinmux_ops aspeed_g4_ops = {
+5 -5
drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
··· 2781 2781 } 2782 2782 2783 2783 static const struct aspeed_pin_config_map aspeed_g5_pin_config_map[] = { 2784 - { PIN_CONFIG_BIAS_PULL_DOWN, 0, 1}, 2785 - { PIN_CONFIG_BIAS_PULL_DOWN, -1, 0}, 2786 - { PIN_CONFIG_BIAS_DISABLE, -1, 1}, 2787 - { PIN_CONFIG_DRIVE_STRENGTH, 8, 0}, 2788 - { PIN_CONFIG_DRIVE_STRENGTH, 16, 1}, 2784 + { PIN_CONFIG_BIAS_PULL_DOWN, 0, 1, BIT_MASK(0)}, 2785 + { PIN_CONFIG_BIAS_PULL_DOWN, -1, 0, BIT_MASK(0)}, 2786 + { PIN_CONFIG_BIAS_DISABLE, -1, 1, BIT_MASK(0)}, 2787 + { PIN_CONFIG_DRIVE_STRENGTH, 8, 0, BIT_MASK(0)}, 2788 + { PIN_CONFIG_DRIVE_STRENGTH, 16, 1, BIT_MASK(0)}, 2789 2789 }; 2790 2790 2791 2791 static const struct aspeed_pinmux_ops aspeed_g5_ops = {
+6 -6
drivers/pinctrl/aspeed/pinctrl-aspeed.c
··· 464 464 return rc; 465 465 466 466 pmap = find_pinconf_map(pdata, param, MAP_TYPE_VAL, 467 - (val & BIT(pconf->bit)) >> pconf->bit); 467 + (val & pconf->mask) >> __ffs(pconf->mask)); 468 468 469 469 if (!pmap) 470 470 return -EINVAL; ··· 512 512 if (WARN_ON(!pmap)) 513 513 return -EINVAL; 514 514 515 - val = pmap->val << pconf->bit; 515 + val = pmap->val << __ffs(pconf->mask); 516 516 517 517 rc = regmap_update_bits(pdata->scu, pconf->reg, 518 - BIT(pconf->bit), val); 518 + pmap->mask, val); 519 519 520 520 if (rc < 0) 521 521 return rc; 522 522 523 - pr_debug("%s: Set SCU%02X[%d]=%d for param %d(=%d) on pin %d\n", 524 - __func__, pconf->reg, pconf->bit, pmap->val, 525 - param, arg, offset); 523 + pr_debug("%s: Set SCU%02X[%lu]=%d for param %d(=%d) on pin %d\n", 524 + __func__, pconf->reg, __ffs(pconf->mask), 525 + pmap->val, param, arg, offset); 526 526 } 527 527 528 528 return 0;
+4 -3
drivers/pinctrl/aspeed/pinctrl-aspeed.h
··· 24 24 enum pin_config_param param; 25 25 unsigned int pins[2]; 26 26 unsigned int reg; 27 - u8 bit; 28 - u8 value; 27 + u32 mask; 29 28 }; 30 29 31 30 #define ASPEED_PINCTRL_PIN(name_) \ ··· 38 39 .param = param_, \ 39 40 .pins = {pin0_, pin1_}, \ 40 41 .reg = reg_, \ 41 - .bit = bit_ \ 42 + .mask = BIT_MASK(bit_) \ 42 43 } 43 44 44 45 /* ··· 47 48 * @param: pinconf configuration parameter 48 49 * @arg: The supported argument for @param, or -1 if any value is supported 49 50 * @val: The register value to write to configure @arg for @param 51 + * @mask: The bitfield mask for @val 50 52 * 51 53 * The map is to be used in conjunction with the configuration array supplied 52 54 * by the driver implementation. ··· 56 56 enum pin_config_param param; 57 57 s32 arg; 58 58 u32 val; 59 + u32 mask; 59 60 }; 60 61 61 62 struct aspeed_pinctrl_data {