[PATCH v5 12/12] pinctrl: stm32: add firewall checks before probing the HDP driver

Gatien Chevallier posted 12 patches 2 weeks, 2 days ago
[PATCH v5 12/12] pinctrl: stm32: add firewall checks before probing the HDP driver
Posted by Gatien Chevallier 2 weeks, 2 days ago
Because the HDP peripheral both depends on debug and firewall
configuration, when CONFIG_STM32_FIREWALL is present, use the
stm32 firewall framework to be able to check these configuration against
the relevant controllers.

Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
---
 drivers/pinctrl/stm32/pinctrl-stm32-hdp.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32-hdp.c b/drivers/pinctrl/stm32/pinctrl-stm32-hdp.c
index 0b1dff01e04c..cce477e86ef9 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32-hdp.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32-hdp.c
@@ -4,6 +4,7 @@
  * Author: Clément Le Goffic <clement.legoffic@foss.st.com> for STMicroelectronics.
  */
 #include <linux/bits.h>
+#include <linux/bus/stm32_firewall_device.h>
 #include <linux/clk.h>
 #include <linux/gpio/driver.h>
 #include <linux/gpio/generic.h>
@@ -46,9 +47,11 @@ struct stm32_hdp {
 	void __iomem *base;
 	struct clk *clk;
 	struct pinctrl_dev *pctl_dev;
+	struct stm32_firewall *firewall;
 	struct gpio_generic_chip gpio_chip;
 	u32 mux_conf;
 	u32 gposet_conf;
+	int nb_firewall_entries;
 	const char * const *func_name;
 };
 
@@ -615,6 +618,13 @@ static int stm32_hdp_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	hdp->dev = dev;
 
+	if (IS_ENABLED(CONFIG_STM32_FIREWALL)) {
+		err = stm32_firewall_get_grant_all_access(dev, &hdp->firewall,
+							  &hdp->nb_firewall_entries);
+		if (err)
+			return err;
+	}
+
 	platform_set_drvdata(pdev, hdp);
 
 	hdp->base = devm_platform_ioremap_resource(pdev, 0);
@@ -670,8 +680,12 @@ static int stm32_hdp_probe(struct platform_device *pdev)
 static void stm32_hdp_remove(struct platform_device *pdev)
 {
 	struct stm32_hdp *hdp = platform_get_drvdata(pdev);
+	int i;
 
 	writel_relaxed(HDP_CTRL_DISABLE, hdp->base + HDP_CTRL);
+
+	for (i = 0; i < hdp->nb_firewall_entries; i++)
+		stm32_firewall_release_access(&hdp->firewall[i]);
 }
 
 static int stm32_hdp_suspend(struct device *dev)

-- 
2.43.0

Re: [PATCH v5 12/12] pinctrl: stm32: add firewall checks before probing the HDP driver
Posted by Linus Walleij 1 week, 5 days ago
On Fri, Jan 23, 2026 at 11:42 AM Gatien Chevallier
<gatien.chevallier@foss.st.com> wrote:

> Because the HDP peripheral both depends on debug and firewall
> configuration, when CONFIG_STM32_FIREWALL is present, use the
> stm32 firewall framework to be able to check these configuration against
> the relevant controllers.
>
> Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>

Lean and clean!
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij
Re: [PATCH v5 12/12] pinctrl: stm32: add firewall checks before probing the HDP driver
Posted by Clément Le Goffic 1 week, 6 days ago
Hi Gatien,

Thank you for the patch

On 1/23/26 11:39 AM, Gatien Chevallier wrote:
> Because the HDP peripheral both depends on debug and firewall
> configuration, when CONFIG_STM32_FIREWALL is present, use the
> stm32 firewall framework to be able to check these configuration against
> the relevant controllers.
> 
> Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
> ---
>   drivers/pinctrl/stm32/pinctrl-stm32-hdp.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/pinctrl/stm32/pinctrl-stm32-hdp.c b/drivers/pinctrl/stm32/pinctrl-stm32-hdp.c
> index 0b1dff01e04c..cce477e86ef9 100644
> --- a/drivers/pinctrl/stm32/pinctrl-stm32-hdp.c
> +++ b/drivers/pinctrl/stm32/pinctrl-stm32-hdp.c
> @@ -4,6 +4,7 @@
>    * Author: Clément Le Goffic <clement.legoffic@foss.st.com> for STMicroelectronics.
>    */
>   #include <linux/bits.h>
> +#include <linux/bus/stm32_firewall_device.h>
>   #include <linux/clk.h>
>   #include <linux/gpio/driver.h>
>   #include <linux/gpio/generic.h>
> @@ -46,9 +47,11 @@ struct stm32_hdp {
>   	void __iomem *base;
>   	struct clk *clk;
>   	struct pinctrl_dev *pctl_dev;
> +	struct stm32_firewall *firewall;
>   	struct gpio_generic_chip gpio_chip;
>   	u32 mux_conf;
>   	u32 gposet_conf;
> +	int nb_firewall_entries;
>   	const char * const *func_name;
>   };
>   
> @@ -615,6 +618,13 @@ static int stm32_hdp_probe(struct platform_device *pdev)
>   		return -ENOMEM;
>   	hdp->dev = dev;
>   
> +	if (IS_ENABLED(CONFIG_STM32_FIREWALL)) {
> +		err = stm32_firewall_get_grant_all_access(dev, &hdp->firewall,
> +							  &hdp->nb_firewall_entries);
> +		if (err)
> +			return err;
> +	}
> +
>   	platform_set_drvdata(pdev, hdp);
>   
>   	hdp->base = devm_platform_ioremap_resource(pdev, 0);
> @@ -670,8 +680,12 @@ static int stm32_hdp_probe(struct platform_device *pdev)
>   static void stm32_hdp_remove(struct platform_device *pdev)
>   {
>   	struct stm32_hdp *hdp = platform_get_drvdata(pdev);
> +	int i;
>   
>   	writel_relaxed(HDP_CTRL_DISABLE, hdp->base + HDP_CTRL);
> +
> +	for (i = 0; i < hdp->nb_firewall_entries; i++)
> +		stm32_firewall_release_access(&hdp->firewall[i]);
>   }
>   
>   static int stm32_hdp_suspend(struct device *dev)
> 

Reviewed-by: Clément Le Goffic <legoffic.clement@gmail.com>