pinctrl: sunxi: Refactor register/offset calculation
authorSamuel Holland <samuel@sholland.org>
Wed, 13 Jul 2022 02:52:31 +0000 (21:52 -0500)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 18 Jul 2022 09:39:33 +0000 (11:39 +0200)
commit0bb95ae2672f9e00f471598a515bf4e9c2005046
treeea4e8e1c825b7fbf9eaf0cb2ceba12e4470b56e3
parent88df36f2e6aa171a674715f8079d3b6ee4165ac3
pinctrl: sunxi: Refactor register/offset calculation

Starting with the D1/D1s/T113 SoC, Allwinner changed the layout of the
pinctrl registers. This new layout widens the drive level field, which
affects the pull register offset and the overall bank size.

As a first step to support this, combine the register and offset
calculation functions, and refactor the math to depend on one constant
for field widths instead of three. This minimizes the code size impact
of making some of the factors dynamic.

While rewriting these functions, move them to the implementation file,
since that is the only file where they are used. And make the comment
more generic, without mentioning specific offsets/sizes.

The callers are updated to expect a shifted mask, and to use consistent
terminology (reg/shift/mask/val).

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20220713025233.27248-5-samuel@sholland.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/sunxi/pinctrl-sunxi.c
drivers/pinctrl/sunxi/pinctrl-sunxi.h