[PATCH v4 20/21] pinctrl: starfive: Add StarFive JHB100 per3 controller driver
Changhuang Liang <[email protected]> Sat, 1 Aug 2026 00:27:10 -0700
| Newsgroups | org.kernel.vger.linux-gpio,org.infradead.lists.linux-riscv,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Add pinctrl driver for StarFive JHB100 SoC Peripheral-3(per3) pinctrl controller. Co-developed-by: Lianfeng Ouyang <[email protected]> Signed-off-by: Lianfeng Ouyang <[email protected]> Signed-off-by: Alex Soo <[email protected]> Signed-off-by: Changhuang Liang <[email protected]> --- drivers/pinctrl/starfive/Kconfig | 11 ++ drivers/pinctrl/starfive/Makefile | 1 + .../starfive/pinctrl-starfive-jhb100-per3.c | 118 ++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jhb100-per3.c diff --git a/drivers/pinctrl/starfive/Kconfig b/drivers/pinctrl/starfive/Kconfig index cbbd6f1fc338..b67640cf0d26 100644 --- a/drivers/pinctrl/starfive/Kconfig +++ b/drivers/pinctrl/starfive/Kconfig @@ -101,6 +101,17 @@ config PINCTRL_STARFIVE_JHB100_PER2POK peripherals supporting inputs, outputs, configuring pull-up/pull-down and interrupts on input changes. +config PINCTRL_STARFIVE_JHB100_PER3 + tristate "StarFive JHB100 SoC Peripheral-3 pinctrl and GPIO driver" + depends on ARCH_STARFIVE || COMPILE_TEST + select PINCTRL_STARFIVE_JHB100 + default ARCH_STARFIVE + help + Say yes here to support Peripheral-3 pin control on the StarFive JHB100 SoC. + This also provides an interface to the GPIO pins not used by other + peripherals supporting inputs, outputs, configuring pull-up/pull-down + and interrupts on input changes. + config PINCTRL_STARFIVE_JHB100_SYS0 tristate "StarFive JHB100 SoC System-0 pinctrl and GPIO driver" depends on ARCH_STARFIVE || COMPILE_TEST diff --git a/drivers/pinctrl/starfive/Makefile b/drivers/pinctrl/starfive/Makefile index 213002da9cdd..351fce524fec 100644 --- a/drivers/pinctrl/starfive/Makefile +++ b/drivers/pinctrl/starfive/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_PINCTRL_STARFIVE_JHB100_PER0) += pinctrl-starfive-jhb100-per0.o obj-$(CONFIG_PINCTRL_STARFIVE_JHB100_PER1) += pinctrl-starfive-jhb100-per1.o obj-$(CONFIG_PINCTRL_STARFIVE_JHB100_PER2) += pinctrl-starfive-jhb100-per2.o obj-$(CONFIG_PINCTRL_STARFIVE_JHB100_PER2POK) += pinctrl-starfive-jhb100-per2pok.o +obj-$(CONFIG_PINCTRL_STARFIVE_JHB100_PER3) += pinctrl-starfive-jhb100-per3.o obj-$(CONFIG_PINCTRL_STARFIVE_JHB100_SYS0) += pinctrl-starfive-jhb100-sys0.o obj-$(CONFIG_PINCTRL_STARFIVE_JHB100_SYS0H) += pinctrl-starfive-jhb100-sys0h.o obj-$(CONFIG_PINCTRL_STARFIVE_JHB100_SYS1) += pinctrl-starfive-jhb100-sys1.o diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jhb100-per3.c b/drivers/pinctrl/starfive/pinctrl-starfive-jhb100-per3.c new file mode 100644 index 000000000000..e0765450cd78 --- /dev/null +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jhb100-per3.c @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Pinctrl / GPIO driver for StarFive JHB100 SoC Peripheral-3 domain + * + * Copyright (C) 2024 StarFive Technology Co., Ltd. + * Author: Alex Soo <[email protected]> + * + */ + +#include <dt-bindings/pinctrl/starfive,jhb100-pinctrl.h> +#include <linux/mod_devicetable.h> +#include <linux/platform_device.h> + +#include "pinctrl-starfive-jhb100.h" + +static const struct jhb100_pin_layout_desc jhb100_per3_pl_desc[] = { + { .pin_start = 0, .pin_cnt = 11, .name = "gpio", .gpio_func_sel = 0 }, + { 0xff }, +}; + +static const struct config_reg_layout_desc jhb100_per3_pinctrl_rl_desc[] = { + { + .pin_start = 0, + .pin_cnt = 2, + .fields[PAD_CFG_DRIVE_STRENGTH_2BIT] = { .shift = 0, .width = 2 }, + .fields[PAD_CFG_INPUT_ENABLE] = { .shift = 2, .width = 1 }, + .fields[PAD_CFG_PULL_DOWN] = { .shift = 3, .width = 1 }, + .fields[PAD_CFG_PULL_UP] = { .shift = 4, .width = 1 }, + .fields[PAD_CFG_SLEW_RATE] = { .shift = 5, .width = 1 }, + .fields[PAD_CFG_SCHMITT_TRIGGER_SELECT] = { .shift = 6, .width = 1 }, + .fields[PAD_CFG_DEBOUNCE_WIDTH] = { .shift = 15, .width = 17 }, + }, + { + .pin_start = 2, + .pin_cnt = 9, + .fields[PAD_CFG_INPUT_ENABLE] = { .shift = 0, .width = 1 }, + .fields[PAD_CFG_SLEW_RATE] = { .shift = 1, .width = 1 }, + .fields[PAD_CFG_VSEL] = { .shift = 2, .width = 2 }, + .fields[PAD_CFG_DEBOUNCE_WIDTH] = { .shift = 15, .width = 17 }, + }, + { 0xff }, +}; + +static const struct pinvref_desc pinvref_desc_per3[] = { + { + /* gpios */ + .pin_grp = { + PADNUM_PER3_GPIO_E0, + PADNUM_PER3_GPIO_E1, + PADNUM_PER3_GPIO_E2, + PADNUM_PER3_GPIO_E3, + PADNUM_PER3_GPIO_E4, + PADNUM_PER3_GPIO_E5, + PADNUM_PER3_GPIO_E6, + PADNUM_PER3_GPIO_E7, + PADNUM_PER3_GPIO_E8, + PADNUM_PER3_GPIO_E9, + PADNUM_PER3_GPIO_E10 + }, + .num_pins = 11, + .range = BIT(JHB100_PINVREF_1_8V) | BIT(JHB100_PINVREF_2_5V) | + BIT(JHB100_PINVREF_3_3V) + }, +}; + +static const struct starfive_pinctrl_regs jhb100_per3_pinctrl_regs = { + .vref = { .reg = 0x00, .pv_desc = pinvref_desc_per3, + .num_pv = ARRAY_SIZE(pinvref_desc_per3) }, + .func_sel = { .reg = 0x3c, .width_per_pin = 2 }, + .config = 0x04, + .output = 0x30, + .output_en = 0x34, + .gpio_status = 0x38, + .irq_en = 0x40, + .irq_status = 0x44, + .irq_clr = 0x48, + .irq_trigger = 0x4c, + .irq_level = 0x50, + .irq_both_edge = 0x54, + .irq_edge = 0x58, +}; + +static const struct jhb100_pinctrl_func_maps jhb100_func_maps_per3[] = { + { .func = "gmac_mdio", .val = 1 }, + { .func = "gmac_rmii", .val = 1 }, + { .func = "gpio", .val = 0 }, +}; + +static const struct jhb100_pinctrl_domain_info jhb100_per3_pinctrl_info = { + .name = "jhb100-per3", + .pl_desc = jhb100_per3_pl_desc, + .crl_desc = jhb100_per3_pinctrl_rl_desc, + .regs = &jhb100_per3_pinctrl_regs, + .fmaps = jhb100_func_maps_per3, + .num_maps = ARRAY_SIZE(jhb100_func_maps_per3), +}; + +static const struct of_device_id jhb100_per3_pinctrl_of_match[] = { + { + .compatible = "starfive,jhb100-per3-pinctrl", + .data = &jhb100_per3_pinctrl_info, + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, jhb100_per3_pinctrl_of_match); + +static struct platform_driver jhb100_per3_pinctrl_driver = { + .probe = jhb100_pinctrl_probe, + .driver = { + .name = "starfive-jhb100-per3-pinctrl", + .of_match_table = jhb100_per3_pinctrl_of_match, + }, +}; +module_platform_driver(jhb100_per3_pinctrl_driver); + +MODULE_DESCRIPTION("Pinctrl driver for StarFive JHB100 SoC Peripheral-3 domain"); +MODULE_AUTHOR("Alex Soo <[email protected]>"); +MODULE_LICENSE("GPL"); -- 2.25.1