summaryrefslogtreecommitdiff
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2026-03-09 15:26:34 -0600
committerTom Rini <trini@konsulko.com>2026-03-09 15:26:34 -0600
commit1e240f7206fccde4ec73ea432ab8360d321c5fe5 (patch)
tree931d5985e8a237b5604999922f5662fc464a8817 /drivers/pinctrl
parent36add050eea439f0b2a15e4ea0d3a8e21216f159 (diff)
parentba7bf918dafcd093ad733b07ba490baeb20cf5da (diff)
Merge tag 'v2026.04-rc4' into next
Prepare v2026.04-rc4
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-adi-adsp.c3
-rw-r--r--drivers/pinctrl/pinctrl_stm32.c83
2 files changed, 72 insertions, 14 deletions
diff --git a/drivers/pinctrl/pinctrl-adi-adsp.c b/drivers/pinctrl/pinctrl-adi-adsp.c
index debf434212d..e39f88c8b26 100644
--- a/drivers/pinctrl/pinctrl-adi-adsp.c
+++ b/drivers/pinctrl/pinctrl-adi-adsp.c
@@ -2,10 +2,9 @@
/*
* (C) Copyright 2022 - Analog Devices, Inc.
*
- * Written and/or maintained by Timesys Corporation
+ * Written by Timesys Corporation
*
* Author: Greg Malysa <greg.malysa@timesys.com>
- * Additional Contact: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
*
* dm pinctrl implementation for ADI ADSP SoCs
*
diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
index fbf0271f08a..1758f9a909c 100644
--- a/drivers/pinctrl/pinctrl_stm32.c
+++ b/drivers/pinctrl/pinctrl_stm32.c
@@ -11,6 +11,7 @@
#include <malloc.h>
#include <asm/gpio.h>
#include <asm/io.h>
+#include <dm/device-internal.h>
#include <dm/device_compat.h>
#include <dm/lists.h>
#include <dm/pinctrl.h>
@@ -27,6 +28,7 @@
#define PUPD_MASK 3
#define OTYPE_MSK 1
#define AFR_MASK 0xF
+#define SECCFG_MSK 1
struct stm32_pinctrl_priv {
struct hwspinlock hws;
@@ -39,7 +41,12 @@ struct stm32_gpio_bank {
struct list_head list;
};
+struct stm32_pinctrl_data {
+ bool secure_control;
+};
+
#ifndef CONFIG_XPL_BUILD
+static int stm32_pinctrl_get_access(struct udevice *gpio_dev, unsigned int gpio_idx);
static char pin_name[PINNAME_SIZE];
static const char * const pinmux_mode[GPIOF_COUNT] = {
@@ -216,6 +223,12 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
if (!gpio_dev)
return -ENODEV;
+ /* Check access protection */
+ if (stm32_pinctrl_get_access(gpio_dev, gpio_idx)) {
+ snprintf(buf, size, "NO ACCESS");
+ return 0;
+ }
+
mode = gpio_get_raw_function(gpio_dev, gpio_idx, &label);
dev_dbg(dev, "selector = %d gpio_idx = %d mode = %d\n",
selector, gpio_idx, mode);
@@ -252,6 +265,20 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
#endif
+static int stm32_pinctrl_get_access(struct udevice *gpio_dev, unsigned int gpio_idx)
+{
+ struct stm32_gpio_priv *priv = dev_get_priv(gpio_dev);
+ struct stm32_gpio_regs *regs = priv->regs;
+ ulong drv_data = dev_get_driver_data(gpio_dev);
+
+ /* Deny request access if IO is secured */
+ if ((drv_data & STM32_GPIO_FLAG_SEC_CTRL) &&
+ ((readl(&regs->seccfgr) >> gpio_idx) & SECCFG_MSK))
+ return -EACCES;
+
+ return 0;
+}
+
static int stm32_pinctrl_probe(struct udevice *dev)
{
struct stm32_pinctrl_priv *priv = dev_get_priv(dev);
@@ -279,6 +306,14 @@ static int stm32_gpio_config(ofnode node,
int ret;
u32 index;
+ /* Check access protection */
+ ret = stm32_pinctrl_get_access(desc->dev, desc->offset);
+ if (ret) {
+ dev_err(desc->dev, "Failed to get secure IO %s %d @ %p\n",
+ uc_priv->bank_name, desc->offset, regs);
+ return ret;
+ }
+
if (!ctl || ctl->af > 15 || ctl->mode > 3 || ctl->otype > 1 ||
ctl->pupd > 2 || ctl->speed > 3)
return -EINVAL;
@@ -414,8 +449,25 @@ static int stm32_pinctrl_bind(struct udevice *dev)
{
ofnode node;
const char *name;
+ struct driver *drv;
+ const struct stm32_pinctrl_data *drv_data;
+ ulong gpio_data = 0;
int ret;
+ drv = lists_driver_lookup_name("gpio_stm32");
+ if (!drv) {
+ debug("Cannot find driver 'gpio_stm32'\n");
+ return -ENOENT;
+ }
+
+ drv_data = (const struct stm32_pinctrl_data *)dev_get_driver_data(dev);
+ if (!drv_data) {
+ debug("Cannot find driver data\n");
+ return -EINVAL;
+ }
+ if (drv_data->secure_control)
+ gpio_data = STM32_GPIO_FLAG_SEC_CTRL;
+
dev_for_each_subnode(node, dev) {
dev_dbg(dev, "bind %s\n", ofnode_get_name(node));
@@ -431,8 +483,7 @@ static int stm32_pinctrl_bind(struct udevice *dev)
return -EINVAL;
/* Bind each gpio node */
- ret = device_bind_driver_to_node(dev, "gpio_stm32",
- name, node, NULL);
+ ret = device_bind_with_driver_data(dev, drv, name, gpio_data, node, NULL);
if (ret)
return ret;
@@ -495,17 +546,25 @@ static struct pinctrl_ops stm32_pinctrl_ops = {
#endif
};
+static const struct stm32_pinctrl_data stm32_pinctrl_no_sec = {
+ .secure_control = false,
+};
+
+static const struct stm32_pinctrl_data stm32_pinctrl_with_sec = {
+ .secure_control = true,
+};
+
static const struct udevice_id stm32_pinctrl_ids[] = {
- { .compatible = "st,stm32f429-pinctrl" },
- { .compatible = "st,stm32f469-pinctrl" },
- { .compatible = "st,stm32f746-pinctrl" },
- { .compatible = "st,stm32f769-pinctrl" },
- { .compatible = "st,stm32h743-pinctrl" },
- { .compatible = "st,stm32mp157-pinctrl" },
- { .compatible = "st,stm32mp157-z-pinctrl" },
- { .compatible = "st,stm32mp135-pinctrl" },
- { .compatible = "st,stm32mp257-pinctrl" },
- { .compatible = "st,stm32mp257-z-pinctrl" },
+ { .compatible = "st,stm32f429-pinctrl", .data = (ulong)&stm32_pinctrl_no_sec },
+ { .compatible = "st,stm32f469-pinctrl", .data = (ulong)&stm32_pinctrl_no_sec },
+ { .compatible = "st,stm32f746-pinctrl", .data = (ulong)&stm32_pinctrl_no_sec },
+ { .compatible = "st,stm32f769-pinctrl", .data = (ulong)&stm32_pinctrl_no_sec },
+ { .compatible = "st,stm32h743-pinctrl", .data = (ulong)&stm32_pinctrl_no_sec },
+ { .compatible = "st,stm32mp157-pinctrl", .data = (ulong)&stm32_pinctrl_no_sec },
+ { .compatible = "st,stm32mp157-z-pinctrl", .data = (ulong)&stm32_pinctrl_no_sec },
+ { .compatible = "st,stm32mp135-pinctrl", .data = (ulong)&stm32_pinctrl_with_sec },
+ { .compatible = "st,stm32mp257-pinctrl", .data = (ulong)&stm32_pinctrl_with_sec },
+ { .compatible = "st,stm32mp257-z-pinctrl", .data = (ulong)&stm32_pinctrl_with_sec },
{ }
};