From 1278fd0c0f2d72cecfefbd3b19e632842d0e1ad4 Mon Sep 17 00:00:00 2001 From: Ioannis Karachalios Date: Thu, 12 Jun 2025 15:37:10 +0300 Subject: [PATCH] drivers: gpio: smartbond: Fix PDC GPIO port selection The GPIO block instance is based on the instance number during the device driver initialization. This is not correct as instance numbers in now way reflect any numbering scheme. Therefore, a DTS property is introduced so that the block instance numbering is indicated explicitly. Signed-off-by: Ioannis Karachalios --- drivers/gpio/gpio_smartbond.c | 9 +++++---- dts/arm/renesas/smartbond/da1469x.dtsi | 2 ++ dts/bindings/gpio/renesas,smartbond-gpio.yaml | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio_smartbond.c b/drivers/gpio/gpio_smartbond.c index 0c5d713a012..c2fc07bb551 100644 --- a/drivers/gpio/gpio_smartbond.c +++ b/drivers/gpio/gpio_smartbond.c @@ -77,11 +77,12 @@ struct gpio_smartbond_config { volatile uint32_t *mode_regs; volatile struct gpio_smartbond_latch_regs *latch_regs; volatile struct gpio_smartbond_wkup_regs *wkup_regs; - /* Value of TRIG_SELECT for PDC_CTRLx_REG entry */ - uint8_t wkup_trig_select; #if CONFIG_PM_DEVICE uint8_t ngpios; #endif +#if CONFIG_PM + uint8_t port; +#endif }; static void gpio_smartbond_wkup_init(void) @@ -226,7 +227,7 @@ static int gpio_smartbond_pin_interrupt_configure(const struct device *dev, struct gpio_smartbond_data *data = dev->data; uint32_t pin_mask = BIT(pin); #if CONFIG_PM - int trig_select_id = (config->wkup_trig_select << 5) | pin; + int trig_select_id = (config->port << 5) | pin; int pdc_ix; #endif @@ -410,7 +411,7 @@ static DEVICE_API(gpio, gpio_smartbond_drv_api_funcs) = { DT_INST_REG_ADDR_BY_NAME(id, latch), \ .wkup_regs = (volatile struct gpio_smartbond_wkup_regs *) \ DT_INST_REG_ADDR_BY_NAME(id, wkup), \ - .wkup_trig_select = id, \ + IF_ENABLED(CONFIG_PM, (.port = DT_INST_PROP(id, port),)) \ GPIO_PM_DEVICE_CFG(.ngpios, DT_INST_PROP(id, ngpios)) \ }; \ \ diff --git a/dts/arm/renesas/smartbond/da1469x.dtsi b/dts/arm/renesas/smartbond/da1469x.dtsi index bad6f3a42a5..f602f5054e5 100644 --- a/dts/arm/renesas/smartbond/da1469x.dtsi +++ b/dts/arm/renesas/smartbond/da1469x.dtsi @@ -201,6 +201,7 @@ compatible = "renesas,smartbond-gpio"; gpio-controller; #gpio-cells = <2>; + port = <0>; ngpios = <32>; reg = <0x50020a00 20 0x50020a18 128 @@ -214,6 +215,7 @@ compatible = "renesas,smartbond-gpio"; gpio-controller; #gpio-cells = <2>; + port = <1>; ngpios = <23>; reg = <0x50020a04 20 0x50020a98 92 diff --git a/dts/bindings/gpio/renesas,smartbond-gpio.yaml b/dts/bindings/gpio/renesas,smartbond-gpio.yaml index ee79e2cbd14..24561607be4 100644 --- a/dts/bindings/gpio/renesas,smartbond-gpio.yaml +++ b/dts/bindings/gpio/renesas,smartbond-gpio.yaml @@ -11,6 +11,10 @@ properties: reg: required: true + port: + type: int + required: true + "#gpio-cells": const: 2