Skip to content

Commit 0972b23

Browse files
youssefz24kartben
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 <youssef.zini@savoirfairelinux.com>
1 parent 9bc78cf commit 0972b23

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

@@ -741,12 +742,16 @@ static int gpio_stm32_init(const struct device *dev)
741742
}, \
742743
.base = (uint32_t *)__base_addr, \
743744
.port = __port, \
744-
.pclken = { .bus = __bus, .enr = __cenr } \
745+
COND_CODE_1(DT_NODE_HAS_PROP(__node, clocks), \
746+
(.pclken = { .bus = __bus, .enr = __cenr },), \
747+
(/* Nothing if clocks not present */)) \
745748
}; \
746749
static struct gpio_stm32_data gpio_stm32_data_## __suffix; \
747750
PM_DEVICE_DT_DEFINE(__node, gpio_stm32_pm_action); \
748751
DEVICE_DT_DEFINE(__node, \
749-
gpio_stm32_init, \
752+
COND_CODE_1(DT_NODE_HAS_PROP(__node, clocks), \
753+
(gpio_stm32_init), \
754+
(NULL)), \
750755
PM_DEVICE_DT_GET(__node), \
751756
&gpio_stm32_data_## __suffix, \
752757
&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)