Browse Source

drivers: gpio: add mp2 gpio clock handling

Remove gpio clock management from the GPIO driver when running on the
cortex-m33 on the mp2 and gpio clocks are managed by the cortex-A, being
the resource manager, allowed by the Resource Isolation Framework (RIF).
Also add a specific binding for the mp2 gpio to make clock property
optional.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
pull/83248/merge
Youssef Zini 3 months ago committed by Benjamin Cabé
parent
commit
0972b23171
  1. 3
      drivers/gpio/Kconfig.stm32
  2. 11
      drivers/gpio/gpio_stm32.c
  3. 23
      dts/bindings/gpio/st,stm32mp2-gpio.yaml

3
drivers/gpio/Kconfig.stm32

@ -1,11 +1,12 @@ @@ -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

11
drivers/gpio/gpio_stm32.c

@ -1,5 +1,6 @@ @@ -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, @@ -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) @@ -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, \

23
dts/bindings/gpio/st,stm32mp2-gpio.yaml

@ -0,0 +1,23 @@ @@ -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.
Loading…
Cancel
Save