Skip to content

Commit

Permalink
linux-iot2050: Add support for PVU-based DMA isolation on AM654
Browse files Browse the repository at this point in the history
Signed-off-by: Li Hua Qian <[email protected]>
  • Loading branch information
huaqianli committed Nov 26, 2024
1 parent 9b7cead commit b2e33f6
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jan Kiszka <[email protected]>
Date: Mon, 24 Jun 2024 13:40:26 +0200
Subject: [PATCH] dt-bindings: soc: ti: Add AM65 peripheral virtualization unit

The PVU allows to define a limited set of mappings for incoming DMA
requests to the system memory. It is not a real IOMMU, thus hooked up
under the TI SoC bindings.

Signed-off-by: Jan Kiszka <[email protected]>
---
.../bindings/soc/ti/ti,am654-pvu.yaml | 51 +++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 Documentation/devicetree/bindings/soc/ti/ti,am654-pvu.yaml

diff --git a/Documentation/devicetree/bindings/soc/ti/ti,am654-pvu.yaml b/Documentation/devicetree/bindings/soc/ti/ti,am654-pvu.yaml
new file mode 100644
index 000000000000..fd0f86fa27b0
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/ti/ti,am654-pvu.yaml
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (c) Siemens AG, 2024
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/ti/ti,am654-pvu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI AM654 Peripheral Virtualization Unit
+
+maintainers:
+ - Jan Kiszka <[email protected]>
+
+properties:
+ compatible:
+ enum:
+ - ti,am654-pvu
+
+ reg:
+ minItems: 2
+
+ reg-names:
+ items:
+ - const: cfg
+ - const: tlbif
+
+ interrupts:
+ items:
+ - description: fault interrupt
+
+ interrupt-names:
+ items:
+ - const: pvu
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - interrupt-names
+
+additionalProperties: false
+
+examples:
+ - |
+ ti-pvu@30f80000 {
+ compatible = "ti,am654-pvu";
+ reg = <0x30f80000 0x1000>,
+ <0x36000000 0x100000>;
+ reg-names = "cfg", "tlbif";
+ interrupts-extended = <&intr_main_navss 390>;
+ interrupt-names = "pvu";
+ };
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Signed-off-by: Jan Kiszka <[email protected]>
drivers/soc/ti/Kconfig | 4 +
drivers/soc/ti/Makefile | 1 +
drivers/soc/ti/ti-pvu.c | 487 ++++++++++++++++++++++++++++++++++++++++
include/linux/ti-pvu.h | 11 +
4 files changed, 503 insertions(+)
include/linux/ti-pvu.h | 16 ++
4 files changed, 508 insertions(+)
create mode 100644 drivers/soc/ti/ti-pvu.c
create mode 100644 include/linux/ti-pvu.h

Expand Down Expand Up @@ -57,7 +57,7 @@ index cc3c972fad2e..15a0d598ac60 100644
+obj-$(CONFIG_TI_PVU) += ti-pvu.o
diff --git a/drivers/soc/ti/ti-pvu.c b/drivers/soc/ti/ti-pvu.c
new file mode 100644
index 000000000000..af1cadc2f4bc
index 000000000000..5b71d503051f
--- /dev/null
+++ b/drivers/soc/ti/ti-pvu.c
@@ -0,0 +1,487 @@
Expand Down Expand Up @@ -446,7 +446,7 @@ index 000000000000..af1cadc2f4bc
+ u32 val;
+ int ret;
+
+ pvu = devm_kzalloc(dev, sizeof(struct ti_pvu), GFP_KERNEL);
+ pvu = devm_kzalloc(dev, sizeof(*pvu), GFP_KERNEL);
+ if (!pvu)
+ return -ENOMEM;
+
Expand Down Expand Up @@ -550,18 +550,23 @@ index 000000000000..af1cadc2f4bc
+module_platform_driver(ti_pvu_driver);
diff --git a/include/linux/ti-pvu.h b/include/linux/ti-pvu.h
new file mode 100644
index 000000000000..d40642522cf0
index 000000000000..acd4d9e0dc86
--- /dev/null
+++ b/include/linux/ti-pvu.h
@@ -0,0 +1,11 @@
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * TI Peripheral Virtualization Unit driver for static DMA isolation
+ *
+ * Copyright (c) 2024, Siemens AG
+ */
+
+#ifndef _LINUX_TI_PVU_H
+#define _LINUX_TI_PVU_H
+
+#include <linux/ioport.h>
+
+int ti_pvu_create_region(unsigned int virt_id, const struct resource *region);
+int ti_pvu_remove_region(unsigned int virt_id, const struct resource *region);
+
+#endif /* _LINUX_TI_PVU_H */
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jan Kiszka <[email protected]>
Date: Mon, 26 Aug 2024 22:53:40 +0200
Subject: [PATCH] dt-bindings: PCI: ti,am65: Extend for use with PVU

Describe also the VMAP registers which are needed in order to make use
of the PVU with this PCI host. Furthermore, permit to specify a
restricted DMA pool by phandle.

Signed-off-by: Jan Kiszka <[email protected]>
---
.../devicetree/bindings/pci/ti,am65-pci-host.yaml | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/pci/ti,am65-pci-host.yaml b/Documentation/devicetree/bindings/pci/ti,am65-pci-host.yaml
index a20dccbafd94..8cd2c327da48 100644
--- a/Documentation/devicetree/bindings/pci/ti,am65-pci-host.yaml
+++ b/Documentation/devicetree/bindings/pci/ti,am65-pci-host.yaml
@@ -20,7 +20,7 @@ properties:
- ti,keystone-pcie

reg:
- maxItems: 4
+ maxItems: 6

reg-names:
items:
@@ -28,6 +28,8 @@ properties:
- const: dbics
- const: config
- const: atu
+ - const: vmap_lp
+ - const: vmap_hp

interrupts:
maxItems: 1
@@ -55,6 +57,9 @@ properties:

dma-coherent: true

+ memory-region:
+ description: phandle to restricted DMA pool to be used for all devices behind this controller
+
required:
- compatible
- reg
@@ -88,8 +93,10 @@ examples:
reg = <0x5500000 0x1000>,
<0x5501000 0x1000>,
<0x10000000 0x2000>,
- <0x5506000 0x1000>;
- reg-names = "app", "dbics", "config", "atu";
+ <0x5506000 0x1000>,
+ <0x2900000 0x1000>,
+ <0x2908000 0x1000>;
+ reg-names = "app", "dbics", "config", "atu", "vmap_lp", "vmap_hp";
power-domains = <&k3_pds 120 TI_SCI_PD_EXCLUSIVE>;
#address-cells = <3>;
#size-cells = <2>;
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ Signed-off-by: Jan Kiszka <[email protected]>
1 file changed, 101 insertions(+)

diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
index 623aafc0303a..f8fe663e6e75 100644
index 623aafc0303a..06f634f600bd 100644
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -19,6 +19,7 @@
#include <linux/mfd/syscon.h>
@@ -20,6 +20,7 @@
#include <linux/msi.h>
#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/of_device.h>
+#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_pci.h>
#include <linux/phy/phy.h>
@@ -27,6 +28,7 @@
#include <linux/regmap.h>
#include <linux/resource.h>
Expand Down

0 comments on commit b2e33f6

Please sign in to comment.