diff --git a/drivers/gpio/Kconfig.stm32 b/drivers/gpio/Kconfig.stm32 index d414cfae4e5..d05baf9c4ce 100644 --- a/drivers/gpio/Kconfig.stm32 +++ b/drivers/gpio/Kconfig.stm32 @@ -1,11 +1,12 @@ # STM32 GPIO configuration # Copyright (c) 2016 Open-RnD Sp. z o.o. +# Copyright (C) 2025 Savoir-faire Linux, Inc. # SPDX-License-Identifier: Apache-2.0 config GPIO_STM32 bool "GPIO Driver for STM32 family of MCUs" default y - depends on DT_HAS_ST_STM32_GPIO_ENABLED + depends on DT_HAS_ST_STM32_GPIO_ENABLED || DT_HAS_ST_STM32MP2_GPIO_ENABLED help Enable GPIO driver for STM32 line of MCUs diff --git a/drivers/gpio/gpio_stm32.c b/drivers/gpio/gpio_stm32.c index 1160350874b..865f4ae48e0 100644 --- a/drivers/gpio/gpio_stm32.c +++ b/drivers/gpio/gpio_stm32.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2016 Open-RnD Sp. z o.o. + * Copyright (C) 2025 Savoir-faire Linux, Inc. * * SPDX-License-Identifier: Apache-2.0 */ @@ -708,7 +709,7 @@ static int gpio_stm32_pm_action(const struct device *dev, * * @return 0 */ -static int gpio_stm32_init(const struct device *dev) +__maybe_unused static int gpio_stm32_init(const struct device *dev) { struct gpio_stm32_data *data = dev->data; @@ -741,12 +742,16 @@ static int gpio_stm32_init(const struct device *dev) }, \ .base = (uint32_t *)__base_addr, \ .port = __port, \ - .pclken = { .bus = __bus, .enr = __cenr } \ + COND_CODE_1(DT_NODE_HAS_PROP(__node, clocks), \ + (.pclken = { .bus = __bus, .enr = __cenr },), \ + (/* Nothing if clocks not present */)) \ }; \ static struct gpio_stm32_data gpio_stm32_data_## __suffix; \ PM_DEVICE_DT_DEFINE(__node, gpio_stm32_pm_action); \ DEVICE_DT_DEFINE(__node, \ - gpio_stm32_init, \ + COND_CODE_1(DT_NODE_HAS_PROP(__node, clocks), \ + (gpio_stm32_init), \ + (NULL)), \ PM_DEVICE_DT_GET(__node), \ &gpio_stm32_data_## __suffix, \ &gpio_stm32_cfg_## __suffix, \ diff --git a/dts/bindings/gpio/st,stm32mp2-gpio.yaml b/dts/bindings/gpio/st,stm32mp2-gpio.yaml new file mode 100644 index 00000000000..09b20ce063f --- /dev/null +++ b/dts/bindings/gpio/st,stm32mp2-gpio.yaml @@ -0,0 +1,23 @@ +# Copyright (C) 2025 Savoir-faire Linux, Inc. +# SPDX-License-Identifier: Apache-2.0 + +description: STM32MP2 GPIO Controller + +compatible: "st,stm32mp2-gpio" + +include: + - name: st,stm32-gpio.yaml + property-blocklist: + - clocks + +properties: + clocks: + type: phandle-array + description: | + The clocks property is optional for STM32MP2 GPIO controllers. + This property is not required when the Cortex-A core is responsible for + GPIO initialization and acts as the resource manager, as defined by the + RIF (Resource Isolation Framework) peripheral. Adding the GPIO clocks + in that case would only trigger an IAC event. + If the Cortex-M core is designated as the resource manager, then the + clocks property must be defined and added to the device tree.