提交 0569af48 编写于 作者: S Samuel Holland 提交者: Linus Walleij

pinctrl: sunxi: Add driver for Allwinner D1

This SoC contains a pinctrl with a new register layout. Use the variant
parameter to set the right register offsets. This pinctrl also increases
the number of functions per pin from 8 to 16, taking advantage of all 4
bits in the mux config field (so far, only functions 0-8 and 14-15 are
used). This increases the maximum possible number of functions.
Reviewed-by: NHeiko Stuebner <heiko@sntech.de>
Tested-by: NHeiko Stuebner <heiko@sntech.de>
Signed-off-by: NSamuel Holland <samuel@sholland.org>
Reviewed-by: NAndre Przywara <andre.przywara@arm.com>
Link: https://lore.kernel.org/r/20220713025233.27248-7-samuel@sholland.orgSigned-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 622b681e
...@@ -81,6 +81,11 @@ config PINCTRL_SUN9I_A80_R ...@@ -81,6 +81,11 @@ config PINCTRL_SUN9I_A80_R
default MACH_SUN9I default MACH_SUN9I
select PINCTRL_SUNXI select PINCTRL_SUNXI
config PINCTRL_SUN20I_D1
bool "Support for the Allwinner D1 PIO"
default MACH_SUN8I || (RISCV && ARCH_SUNXI)
select PINCTRL_SUNXI
config PINCTRL_SUN50I_A64 config PINCTRL_SUN50I_A64
bool "Support for the Allwinner A64 PIO" bool "Support for the Allwinner A64 PIO"
default ARM64 && ARCH_SUNXI default ARM64 && ARCH_SUNXI
......
...@@ -20,6 +20,7 @@ obj-$(CONFIG_PINCTRL_SUN8I_A83T_R) += pinctrl-sun8i-a83t-r.o ...@@ -20,6 +20,7 @@ obj-$(CONFIG_PINCTRL_SUN8I_A83T_R) += pinctrl-sun8i-a83t-r.o
obj-$(CONFIG_PINCTRL_SUN8I_H3) += pinctrl-sun8i-h3.o obj-$(CONFIG_PINCTRL_SUN8I_H3) += pinctrl-sun8i-h3.o
obj-$(CONFIG_PINCTRL_SUN8I_H3_R) += pinctrl-sun8i-h3-r.o obj-$(CONFIG_PINCTRL_SUN8I_H3_R) += pinctrl-sun8i-h3-r.o
obj-$(CONFIG_PINCTRL_SUN8I_V3S) += pinctrl-sun8i-v3s.o obj-$(CONFIG_PINCTRL_SUN8I_V3S) += pinctrl-sun8i-v3s.o
obj-$(CONFIG_PINCTRL_SUN20I_D1) += pinctrl-sun20i-d1.o
obj-$(CONFIG_PINCTRL_SUN50I_H5) += pinctrl-sun50i-h5.o obj-$(CONFIG_PINCTRL_SUN50I_H5) += pinctrl-sun50i-h5.o
obj-$(CONFIG_PINCTRL_SUN50I_H6) += pinctrl-sun50i-h6.o obj-$(CONFIG_PINCTRL_SUN50I_H6) += pinctrl-sun50i-h6.o
obj-$(CONFIG_PINCTRL_SUN50I_H6_R) += pinctrl-sun50i-h6-r.o obj-$(CONFIG_PINCTRL_SUN50I_H6_R) += pinctrl-sun50i-h6-r.o
......
此差异已折叠。
...@@ -1297,11 +1297,11 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) ...@@ -1297,11 +1297,11 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
/* /*
* Find an upper bound for the maximum number of functions: in * Find an upper bound for the maximum number of functions: in
* the worst case we have gpio_in, gpio_out, irq and up to four * the worst case we have gpio_in, gpio_out, irq and up to seven
* special functions per pin, plus one entry for the sentinel. * special functions per pin, plus one entry for the sentinel.
* We'll reallocate that later anyway. * We'll reallocate that later anyway.
*/ */
pctl->functions = kcalloc(4 * pctl->ngroups + 4, pctl->functions = kcalloc(7 * pctl->ngroups + 4,
sizeof(*pctl->functions), sizeof(*pctl->functions),
GFP_KERNEL); GFP_KERNEL);
if (!pctl->functions) if (!pctl->functions)
...@@ -1494,9 +1494,15 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev, ...@@ -1494,9 +1494,15 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev,
pctl->dev = &pdev->dev; pctl->dev = &pdev->dev;
pctl->desc = desc; pctl->desc = desc;
pctl->variant = variant; pctl->variant = variant;
pctl->bank_mem_size = BANK_MEM_SIZE; if (pctl->variant >= PINCTRL_SUN20I_D1) {
pctl->pull_regs_offset = PULL_REGS_OFFSET; pctl->bank_mem_size = D1_BANK_MEM_SIZE;
pctl->dlevel_field_width = DLEVEL_FIELD_WIDTH; pctl->pull_regs_offset = D1_PULL_REGS_OFFSET;
pctl->dlevel_field_width = D1_DLEVEL_FIELD_WIDTH;
} else {
pctl->bank_mem_size = BANK_MEM_SIZE;
pctl->pull_regs_offset = PULL_REGS_OFFSET;
pctl->dlevel_field_width = DLEVEL_FIELD_WIDTH;
}
pctl->irq_array = devm_kcalloc(&pdev->dev, pctl->irq_array = devm_kcalloc(&pdev->dev,
IRQ_PER_BANK * pctl->desc->irq_banks, IRQ_PER_BANK * pctl->desc->irq_banks,
......
...@@ -44,6 +44,10 @@ ...@@ -44,6 +44,10 @@
#define PULL_REGS_OFFSET 0x1c #define PULL_REGS_OFFSET 0x1c
#define PULL_FIELD_WIDTH 2 #define PULL_FIELD_WIDTH 2
#define D1_BANK_MEM_SIZE 0x30
#define D1_DLEVEL_FIELD_WIDTH 4
#define D1_PULL_REGS_OFFSET 0x24
#define PINS_PER_BANK 32 #define PINS_PER_BANK 32
#define IRQ_PER_BANK 32 #define IRQ_PER_BANK 32
...@@ -88,6 +92,8 @@ ...@@ -88,6 +92,8 @@
#define PINCTRL_SUN8I_R40 BIT(8) #define PINCTRL_SUN8I_R40 BIT(8)
#define PINCTRL_SUN8I_V3 BIT(9) #define PINCTRL_SUN8I_V3 BIT(9)
#define PINCTRL_SUN8I_V3S BIT(10) #define PINCTRL_SUN8I_V3S BIT(10)
/* Variants below here have an updated register layout. */
#define PINCTRL_SUN20I_D1 BIT(11)
#define PIO_POW_MOD_SEL_REG 0x340 #define PIO_POW_MOD_SEL_REG 0x340
#define PIO_POW_MOD_CTL_REG 0x344 #define PIO_POW_MOD_CTL_REG 0x344
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册