Skip to content

Commit 796cba2

Browse files
LaurentiuM1234Shawn Guo
authored andcommitted
bus: add driver for IMX AIPSTZ bridge
The secure AHB to IP Slave (AIPSTZ) bus bridge provides access control configurations meant to restrict access to certain peripherals. Some of the configurations include: 1) Marking masters as trusted for R/W. Based on this (and the configuration of the accessed peripheral), the bridge may choose to abort the R/W transactions issued by certain masters. 2) Allowing/disallowing write accesses to peripherals. Add driver for this IP. Since there's currently no framework for access controllers (and since there's currently no need for having flexibility w.r.t the configurations) all this driver does is it applies a relaxed, "default" configuration, in which all masters are trusted for R/W. Note that some instances of this IP (e.g: AIPSTZ5 on i.MX8MP) may be tied to a power domain and may lose their configuration when the domain is powered off. This is why the configuration has to be restored when the domain is powered on. Co-developed-by: Daniel Baluta <[email protected]> Signed-off-by: Daniel Baluta <[email protected]> Signed-off-by: Laurentiu Mihalcea <[email protected]> Signed-off-by: Shawn Guo <[email protected]>
1 parent 37ccad0 commit 796cba2

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

drivers/bus/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ config HISILICON_LPC
8787
Driver to enable I/O access to devices attached to the Low Pin
8888
Count bus on the HiSilicon Hip06/7 SoC.
8989

90+
config IMX_AIPSTZ
91+
tristate "Support for IMX Secure AHB to IP Slave bus (AIPSTZ) bridge"
92+
depends on ARCH_MXC
93+
help
94+
Enable support for IMX AIPSTZ bridge.
95+
9096
config IMX_WEIM
9197
bool "Freescale EIM DRIVER"
9298
depends on ARCH_MXC || COMPILE_TEST

drivers/bus/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/
1515

1616
obj-$(CONFIG_BT1_APB) += bt1-apb.o
1717
obj-$(CONFIG_BT1_AXI) += bt1-axi.o
18+
obj-$(CONFIG_IMX_AIPSTZ) += imx-aipstz.o
1819
obj-$(CONFIG_IMX_WEIM) += imx-weim.o
1920
obj-$(CONFIG_INTEL_IXP4XX_EB) += intel-ixp4xx-eb.o
2021
obj-$(CONFIG_MIPS_CDMM) += mips_cdmm.o

drivers/bus/imx-aipstz.c

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright 2025 NXP
4+
*/
5+
6+
#include <linux/module.h>
7+
#include <linux/of.h>
8+
#include <linux/of_platform.h>
9+
#include <linux/platform_device.h>
10+
#include <linux/pm_runtime.h>
11+
#include <linux/regmap.h>
12+
13+
#define IMX_AIPSTZ_MPR0 0x0
14+
15+
struct imx_aipstz_config {
16+
u32 mpr0;
17+
};
18+
19+
struct imx_aipstz_data {
20+
void __iomem *base;
21+
const struct imx_aipstz_config *default_cfg;
22+
};
23+
24+
static void imx_aipstz_apply_default(struct imx_aipstz_data *data)
25+
{
26+
writel(data->default_cfg->mpr0, data->base + IMX_AIPSTZ_MPR0);
27+
}
28+
29+
static int imx_aipstz_probe(struct platform_device *pdev)
30+
{
31+
struct imx_aipstz_data *data;
32+
33+
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
34+
if (!data)
35+
return dev_err_probe(&pdev->dev, -ENOMEM,
36+
"failed to allocate data memory\n");
37+
38+
data->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
39+
if (IS_ERR(data->base))
40+
return dev_err_probe(&pdev->dev, -ENOMEM,
41+
"failed to get/ioremap AC memory\n");
42+
43+
data->default_cfg = of_device_get_match_data(&pdev->dev);
44+
45+
imx_aipstz_apply_default(data);
46+
47+
dev_set_drvdata(&pdev->dev, data);
48+
49+
pm_runtime_set_active(&pdev->dev);
50+
devm_pm_runtime_enable(&pdev->dev);
51+
52+
return devm_of_platform_populate(&pdev->dev);
53+
}
54+
55+
static int imx_aipstz_runtime_resume(struct device *dev)
56+
{
57+
struct imx_aipstz_data *data = dev_get_drvdata(dev);
58+
59+
/* restore potentially lost configuration during domain power-off */
60+
imx_aipstz_apply_default(data);
61+
62+
return 0;
63+
}
64+
65+
static const struct dev_pm_ops imx_aipstz_pm_ops = {
66+
RUNTIME_PM_OPS(NULL, imx_aipstz_runtime_resume, NULL)
67+
SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
68+
};
69+
70+
/*
71+
* following configuration is equivalent to:
72+
* masters 0-7 => trusted for R/W + use AHB's HPROT[1] to det. privilege
73+
*/
74+
static const struct imx_aipstz_config imx8mp_aipstz_default_cfg = {
75+
.mpr0 = 0x77777777,
76+
};
77+
78+
static const struct of_device_id imx_aipstz_of_ids[] = {
79+
{ .compatible = "fsl,imx8mp-aipstz", .data = &imx8mp_aipstz_default_cfg },
80+
{ }
81+
};
82+
MODULE_DEVICE_TABLE(of, imx_aipstz_of_ids);
83+
84+
static struct platform_driver imx_aipstz_of_driver = {
85+
.probe = imx_aipstz_probe,
86+
.driver = {
87+
.name = "imx-aipstz",
88+
.of_match_table = imx_aipstz_of_ids,
89+
.pm = pm_ptr(&imx_aipstz_pm_ops),
90+
},
91+
};
92+
module_platform_driver(imx_aipstz_of_driver);
93+
94+
MODULE_LICENSE("GPL");
95+
MODULE_DESCRIPTION("IMX secure AHB to IP Slave bus (AIPSTZ) bridge driver");
96+
MODULE_AUTHOR("Laurentiu Mihalcea <[email protected]>");

0 commit comments

Comments
 (0)