* [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1
@ 2026-03-12 8:42 Junhui Liu
2026-03-12 8:42 ` [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations Junhui Liu
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Junhui Liu @ 2026-03-12 8:42 UTC (permalink / raw)
To: Linus Walleij, Yixun Lan, Bartosz Golaszewski
Cc: linux-gpio, linux-riscv, spacemit, linux-kernel, Junhui Liu
This add GPIO pin configuration support for the Spacemit K1 SoC. Some
use cases require configuring pin attributes like pull-up/down when using
GPIO lines.
A practical example is the SD card detection pin on the Banana Pi BPI-F3
board. Since it lacks an external pull-up circuit, the pin must be
configured with an internal pull-up to function correctly. Such
configurations can be specified directly in the devicetree:
cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
To address this, add the set_config() callback to the gpio-spacemit-k1
driver to enable pin configuration through pinctrl, and modify the
pinctrl driver to return -ENOTSUPP instead of -EINVAL for unsupported
parameters, allowing the GPIO subsystem to gracefully handle them.
---
Junhui Liu (2):
pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations
gpio: spacemit-k1: Add set_config callback support
drivers/gpio/gpio-spacemit-k1.c | 1 +
drivers/pinctrl/spacemit/pinctrl-k1.c | 21 ++++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
---
base-commit: b29fb8829bff243512bb8c8908fd39406f9fd4c3
change-id: 20260312-k1-gpio-set-config-f0873e92ebac
Best regards,
--
Junhui Liu <junhui.liu@pigmoral.tech>
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations 2026-03-12 8:42 [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 Junhui Liu @ 2026-03-12 8:42 ` Junhui Liu 2026-03-13 13:37 ` Yao Zi ` (2 more replies) 2026-03-12 8:42 ` [PATCH 2/2] gpio: spacemit-k1: Add set_config callback support Junhui Liu ` (2 subsequent siblings) 3 siblings, 3 replies; 11+ messages in thread From: Junhui Liu @ 2026-03-12 8:42 UTC (permalink / raw) To: Linus Walleij, Yixun Lan, Bartosz Golaszewski Cc: linux-gpio, linux-riscv, spacemit, linux-kernel, Junhui Liu Return -ENOTSUPP instead of -EINVAL when encountering unsupported pin configuration parameters. This is more logical and allows the GPIO subsystem to gracefully handle unsupported parameters via functions like gpio_set_config_with_argument_optional(), which specifically ignores -ENOTSUPP but treats others as failure. Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> --- drivers/pinctrl/spacemit/pinctrl-k1.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/pinctrl/spacemit/pinctrl-k1.c b/drivers/pinctrl/spacemit/pinctrl-k1.c index 62cab6f6cd0a..b0be62b1c816 100644 --- a/drivers/pinctrl/spacemit/pinctrl-k1.c +++ b/drivers/pinctrl/spacemit/pinctrl-k1.c @@ -674,7 +674,7 @@ static int spacemit_pinconf_get(struct pinctrl_dev *pctldev, arg = 0; break; default: - return -EINVAL; + return -ENOTSUPP; } *config = pinconf_to_config_packed(param, arg); @@ -740,7 +740,7 @@ static int spacemit_pinconf_generate_config(struct spacemit_pinctrl *pctrl, } break; default: - return -EINVAL; + return -ENOTSUPP; } } @@ -814,10 +814,12 @@ static int spacemit_pinconf_set(struct pinctrl_dev *pctldev, struct spacemit_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); const struct spacemit_pin *spin = spacemit_get_pin(pctrl, pin); u32 value; + int ret; - if (spacemit_pinconf_generate_config(pctrl, spin, pctrl->data->dconf, - configs, num_configs, &value)) - return -EINVAL; + ret = spacemit_pinconf_generate_config(pctrl, spin, pctrl->data->dconf, + configs, num_configs, &value); + if (ret) + return ret; return spacemit_pin_set_config(pctrl, pin, value); } @@ -831,16 +833,17 @@ static int spacemit_pinconf_group_set(struct pinctrl_dev *pctldev, const struct spacemit_pin *spin; const struct group_desc *group; u32 value; - int i; + int i, ret; group = pinctrl_generic_get_group(pctldev, gsel); if (!group) return -EINVAL; spin = spacemit_get_pin(pctrl, group->grp.pins[0]); - if (spacemit_pinconf_generate_config(pctrl, spin, pctrl->data->dconf, - configs, num_configs, &value)) - return -EINVAL; + ret = spacemit_pinconf_generate_config(pctrl, spin, pctrl->data->dconf, + configs, num_configs, &value); + if (ret) + return ret; for (i = 0; i < group->grp.npins; i++) spacemit_pin_set_config(pctrl, group->grp.pins[i], value); -- 2.53.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations 2026-03-12 8:42 ` [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations Junhui Liu @ 2026-03-13 13:37 ` Yao Zi 2026-03-13 13:52 ` Bartosz Golaszewski 2026-03-14 8:20 ` Anand Moon 2 siblings, 0 replies; 11+ messages in thread From: Yao Zi @ 2026-03-13 13:37 UTC (permalink / raw) To: Junhui Liu, Linus Walleij, Yixun Lan, Bartosz Golaszewski Cc: linux-gpio, linux-riscv, spacemit, linux-kernel On Thu, Mar 12, 2026 at 04:42:42PM +0800, Junhui Liu wrote: > Return -ENOTSUPP instead of -EINVAL when encountering unsupported pin > configuration parameters. This is more logical and allows the GPIO > subsystem to gracefully handle unsupported parameters via functions like > gpio_set_config_with_argument_optional(), which specifically ignores > -ENOTSUPP but treats others as failure. This sounds like a fix and deserves Fixes tag, though I'm not sure whether backporting is appropriate since no existing system should be affected... Regards, Yao Zi ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations 2026-03-12 8:42 ` [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations Junhui Liu 2026-03-13 13:37 ` Yao Zi @ 2026-03-13 13:52 ` Bartosz Golaszewski 2026-03-14 8:20 ` Anand Moon 2 siblings, 0 replies; 11+ messages in thread From: Bartosz Golaszewski @ 2026-03-13 13:52 UTC (permalink / raw) To: Junhui Liu Cc: Linus Walleij, Yixun Lan, linux-gpio, linux-riscv, spacemit, linux-kernel On Thu, Mar 12, 2026 at 9:43 AM Junhui Liu <junhui.liu@pigmoral.tech> wrote: > > Return -ENOTSUPP instead of -EINVAL when encountering unsupported pin > configuration parameters. This is more logical and allows the GPIO > subsystem to gracefully handle unsupported parameters via functions like > gpio_set_config_with_argument_optional(), which specifically ignores > -ENOTSUPP but treats others as failure. > > Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> > --- Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations 2026-03-12 8:42 ` [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations Junhui Liu 2026-03-13 13:37 ` Yao Zi 2026-03-13 13:52 ` Bartosz Golaszewski @ 2026-03-14 8:20 ` Anand Moon 2 siblings, 0 replies; 11+ messages in thread From: Anand Moon @ 2026-03-14 8:20 UTC (permalink / raw) To: Junhui Liu Cc: Linus Walleij, Yixun Lan, Bartosz Golaszewski, linux-gpio, linux-riscv, spacemit, linux-kernel Hi Junhui, On Thu, 12 Mar 2026 at 14:14, Junhui Liu <junhui.liu@pigmoral.tech> wrote: > > Return -ENOTSUPP instead of -EINVAL when encountering unsupported pin > configuration parameters. This is more logical and allows the GPIO > subsystem to gracefully handle unsupported parameters via functions like > gpio_set_config_with_argument_optional(), which specifically ignores > -ENOTSUPP but treats others as failure. > > Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> > --- Reviewed-by: Anand Moon <linux.amoon@gmail.com> Thanks -Anand ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/2] gpio: spacemit-k1: Add set_config callback support 2026-03-12 8:42 [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 Junhui Liu 2026-03-12 8:42 ` [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations Junhui Liu @ 2026-03-12 8:42 ` Junhui Liu 2026-03-13 14:05 ` Bartosz Golaszewski 2026-03-14 8:20 ` Anand Moon 2026-03-12 11:21 ` [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 Yixun Lan 2026-03-19 12:53 ` Linus Walleij 3 siblings, 2 replies; 11+ messages in thread From: Junhui Liu @ 2026-03-12 8:42 UTC (permalink / raw) To: Linus Walleij, Yixun Lan, Bartosz Golaszewski Cc: linux-gpio, linux-riscv, spacemit, linux-kernel, Junhui Liu Assign gpiochip_generic_config() to the set_config() callback to support pin configuration through the GPIO subsystem. This allows users to configure GPIO pin attributes like pull-up/down when specifying a GPIO line in the Device Tree. Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> --- drivers/gpio/gpio-spacemit-k1.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpio-spacemit-k1.c b/drivers/gpio/gpio-spacemit-k1.c index dbd2e81094b9..5fe813b7f9bb 100644 --- a/drivers/gpio/gpio-spacemit-k1.c +++ b/drivers/gpio/gpio-spacemit-k1.c @@ -228,6 +228,7 @@ static int spacemit_gpio_add_bank(struct spacemit_gpio *sg, gc->label = dev_name(dev); gc->request = gpiochip_generic_request; gc->free = gpiochip_generic_free; + gc->set_config = gpiochip_generic_config; gc->ngpio = SPACEMIT_NR_GPIOS_PER_BANK; gc->base = -1; gc->of_gpio_n_cells = 3; -- 2.53.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] gpio: spacemit-k1: Add set_config callback support 2026-03-12 8:42 ` [PATCH 2/2] gpio: spacemit-k1: Add set_config callback support Junhui Liu @ 2026-03-13 14:05 ` Bartosz Golaszewski 2026-03-19 12:54 ` Linus Walleij 2026-03-14 8:20 ` Anand Moon 1 sibling, 1 reply; 11+ messages in thread From: Bartosz Golaszewski @ 2026-03-13 14:05 UTC (permalink / raw) To: Junhui Liu Cc: Linus Walleij, Yixun Lan, linux-gpio, linux-riscv, spacemit, linux-kernel On Thu, Mar 12, 2026 at 9:43 AM Junhui Liu <junhui.liu@pigmoral.tech> wrote: > > Assign gpiochip_generic_config() to the set_config() callback to support > pin configuration through the GPIO subsystem. This allows users to > configure GPIO pin attributes like pull-up/down when specifying a GPIO > line in the Device Tree. > > Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> > --- > drivers/gpio/gpio-spacemit-k1.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/gpio/gpio-spacemit-k1.c b/drivers/gpio/gpio-spacemit-k1.c > index dbd2e81094b9..5fe813b7f9bb 100644 > --- a/drivers/gpio/gpio-spacemit-k1.c > +++ b/drivers/gpio/gpio-spacemit-k1.c > @@ -228,6 +228,7 @@ static int spacemit_gpio_add_bank(struct spacemit_gpio *sg, > gc->label = dev_name(dev); > gc->request = gpiochip_generic_request; > gc->free = gpiochip_generic_free; > + gc->set_config = gpiochip_generic_config; > gc->ngpio = SPACEMIT_NR_GPIOS_PER_BANK; > gc->base = -1; > gc->of_gpio_n_cells = 3; > > -- > 2.53.0 > Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Linus, please take it through the pinctrl tree. Bart ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] gpio: spacemit-k1: Add set_config callback support 2026-03-13 14:05 ` Bartosz Golaszewski @ 2026-03-19 12:54 ` Linus Walleij 0 siblings, 0 replies; 11+ messages in thread From: Linus Walleij @ 2026-03-19 12:54 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Junhui Liu, Yixun Lan, linux-gpio, linux-riscv, spacemit, linux-kernel On Fri, Mar 13, 2026 at 3:05 PM Bartosz Golaszewski <brgl@kernel.org> wrote: > On Thu, Mar 12, 2026 at 9:43 AM Junhui Liu <junhui.liu@pigmoral.tech> wrote: > > > > Assign gpiochip_generic_config() to the set_config() callback to support > > pin configuration through the GPIO subsystem. This allows users to > > configure GPIO pin attributes like pull-up/down when specifying a GPIO > > line in the Device Tree. > > > > Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> > Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> > > Linus, please take it through the pinctrl tree. OK done. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] gpio: spacemit-k1: Add set_config callback support 2026-03-12 8:42 ` [PATCH 2/2] gpio: spacemit-k1: Add set_config callback support Junhui Liu 2026-03-13 14:05 ` Bartosz Golaszewski @ 2026-03-14 8:20 ` Anand Moon 1 sibling, 0 replies; 11+ messages in thread From: Anand Moon @ 2026-03-14 8:20 UTC (permalink / raw) To: Junhui Liu Cc: Linus Walleij, Yixun Lan, Bartosz Golaszewski, linux-gpio, linux-riscv, spacemit, linux-kernel Hi Junhui, On Thu, 12 Mar 2026 at 14:14, Junhui Liu <junhui.liu@pigmoral.tech> wrote: > > Assign gpiochip_generic_config() to the set_config() callback to support > pin configuration through the GPIO subsystem. This allows users to > configure GPIO pin attributes like pull-up/down when specifying a GPIO > line in the Device Tree. > > Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> > --- Reviewed-by: Anand Moon <linux.amoon@gmail.com> Thanks -Anand ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 2026-03-12 8:42 [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 Junhui Liu 2026-03-12 8:42 ` [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations Junhui Liu 2026-03-12 8:42 ` [PATCH 2/2] gpio: spacemit-k1: Add set_config callback support Junhui Liu @ 2026-03-12 11:21 ` Yixun Lan 2026-03-19 12:53 ` Linus Walleij 3 siblings, 0 replies; 11+ messages in thread From: Yixun Lan @ 2026-03-12 11:21 UTC (permalink / raw) To: Junhui Liu Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-riscv, spacemit, linux-kernel Hi Junhui, On 16:42 Thu 12 Mar , Junhui Liu wrote: > This add GPIO pin configuration support for the Spacemit K1 SoC. Some > use cases require configuring pin attributes like pull-up/down when using > GPIO lines. > > A practical example is the SD card detection pin on the Banana Pi BPI-F3 > board. Since it lacks an external pull-up circuit, the pin must be > configured with an internal pull-up to function correctly. Such > configurations can be specified directly in the devicetree: > > cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; > > To address this, add the set_config() callback to the gpio-spacemit-k1 > driver to enable pin configuration through pinctrl, and modify the > pinctrl driver to return -ENOTSUPP instead of -EINVAL for unsupported > parameters, allowing the GPIO subsystem to gracefully handle them. > Thanks for working on this, for the series Reviewed-by: Yixun Lan <dlan@kernel.org> > --- > Junhui Liu (2): > pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations > gpio: spacemit-k1: Add set_config callback support > > drivers/gpio/gpio-spacemit-k1.c | 1 + > drivers/pinctrl/spacemit/pinctrl-k1.c | 21 ++++++++++++--------- > 2 files changed, 13 insertions(+), 9 deletions(-) > --- > base-commit: b29fb8829bff243512bb8c8908fd39406f9fd4c3 > change-id: 20260312-k1-gpio-set-config-f0873e92ebac > > Best regards, > -- > Junhui Liu <junhui.liu@pigmoral.tech> > -- Yixun Lan (dlan) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 2026-03-12 8:42 [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 Junhui Liu ` (2 preceding siblings ...) 2026-03-12 11:21 ` [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 Yixun Lan @ 2026-03-19 12:53 ` Linus Walleij 3 siblings, 0 replies; 11+ messages in thread From: Linus Walleij @ 2026-03-19 12:53 UTC (permalink / raw) To: Junhui Liu Cc: Yixun Lan, Bartosz Golaszewski, linux-gpio, linux-riscv, spacemit, linux-kernel Thank Junhui, On Thu, Mar 12, 2026 at 9:43 AM Junhui Liu <junhui.liu@pigmoral.tech> wrote: > This add GPIO pin configuration support for the Spacemit K1 SoC. Some > use cases require configuring pin attributes like pull-up/down when using > GPIO lines. > > A practical example is the SD card detection pin on the Banana Pi BPI-F3 > board. Since it lacks an external pull-up circuit, the pin must be > configured with an internal pull-up to function correctly. Such > configurations can be specified directly in the devicetree: > > cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; > > To address this, add the set_config() callback to the gpio-spacemit-k1 > driver to enable pin configuration through pinctrl, and modify the > pinctrl driver to return -ENOTSUPP instead of -EINVAL for unsupported > parameters, allowing the GPIO subsystem to gracefully handle them. > > --- > Junhui Liu (2): > pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations > gpio: spacemit-k1: Add set_config callback support Both patches applied to the pinctrl tree. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-03-19 12:54 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-12 8:42 [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 Junhui Liu 2026-03-12 8:42 ` [PATCH 1/2] pinctrl: spacemit: return -ENOTSUPP for unsupported pin configurations Junhui Liu 2026-03-13 13:37 ` Yao Zi 2026-03-13 13:52 ` Bartosz Golaszewski 2026-03-14 8:20 ` Anand Moon 2026-03-12 8:42 ` [PATCH 2/2] gpio: spacemit-k1: Add set_config callback support Junhui Liu 2026-03-13 14:05 ` Bartosz Golaszewski 2026-03-19 12:54 ` Linus Walleij 2026-03-14 8:20 ` Anand Moon 2026-03-12 11:21 ` [PATCH 0/2] gpio/pinctrl: spacemit: Add GPIO pin configuration support for K1 Yixun Lan 2026-03-19 12:53 ` Linus Walleij
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox