Skip to content

Commit 82c3539

Browse files
youssefz24arnopo
authored andcommitted
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 <[email protected]>
1 parent e8589f6 commit 82c3539

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

drivers/gpio/Kconfig.stm32

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# STM32 GPIO configuration
22

33
# Copyright (c) 2016 Open-RnD Sp. z o.o.
4+
# Copyright (C) 2025 Savoir-faire Linux, Inc.
45
# SPDX-License-Identifier: Apache-2.0
56

67
config GPIO_STM32
78
bool "GPIO Driver for STM32 family of MCUs"
89
default y
9-
depends on DT_HAS_ST_STM32_GPIO_ENABLED
10+
depends on DT_HAS_ST_STM32_GPIO_ENABLED || DT_HAS_ST_STM32MP2_GPIO_ENABLED
1011
help
1112
Enable GPIO driver for STM32 line of MCUs

drivers/gpio/gpio_stm32.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2016 Open-RnD Sp. z o.o.
3+
* Copyright (C) 2025 Savoir-faire Linux, Inc.
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
@@ -708,7 +709,7 @@ static int gpio_stm32_pm_action(const struct device *dev,
708709
*
709710
* @return 0
710711
*/
711-
static int gpio_stm32_init(const struct device *dev)
712+
__maybe_unused static int gpio_stm32_init(const struct device *dev)
712713
{
713714
struct gpio_stm32_data *data = dev->data;
714715

@@ -737,12 +738,16 @@ static int gpio_stm32_init(const struct device *dev)
737738
}, \
738739
.base = (uint32_t *)__base_addr, \
739740
.port = __port, \
740-
.pclken = { .bus = __bus, .enr = __cenr } \
741+
COND_CODE_1(DT_NODE_HAS_PROP(__node, clocks), \
742+
(.pclken = { .bus = __bus, .enr = __cenr },), \
743+
(/* Nothing if clocks not present */)) \
741744
}; \
742745
static struct gpio_stm32_data gpio_stm32_data_## __suffix; \
743746
PM_DEVICE_DT_DEFINE(__node, gpio_stm32_pm_action); \
744747
DEVICE_DT_DEFINE(__node, \
745-
gpio_stm32_init, \
748+
COND_CODE_1(DT_NODE_HAS_PROP(__node, clocks), \
749+
(gpio_stm32_init), \
750+
(NULL)), \
746751
PM_DEVICE_DT_GET(__node), \
747752
&gpio_stm32_data_## __suffix, \
748753
&gpio_stm32_cfg_## __suffix, \
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (C) 2025 Savoir-faire Linux, Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: STM32MP2 GPIO Controller
5+
6+
compatible: "st,stm32mp2-gpio"
7+
8+
include:
9+
- name: st,stm32-gpio.yaml
10+
property-blocklist:
11+
- clocks
12+
13+
properties:
14+
clocks:
15+
type: phandle-array
16+
description: |
17+
The clocks property is optional for STM32MP2 GPIO controllers.
18+
This property is not required when the Cortex-A core is responsible for
19+
GPIO initialization and acts as the resource manager, as defined by the
20+
RIF (Resource Isolation Framework) peripheral. Adding the GPIO clocks
21+
in that case would only trigger an IAC event.
22+
If the Cortex-M core is designated as the resource manager, then the
23+
clocks property must be defined and added to the device tree.

0 commit comments

Comments
 (0)