devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 05/10] iommu/ipmmu-vmsa: Add device tree bindings documentation
       [not found] <1418737457-22042-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>
@ 2014-12-16 13:44 ` Laurent Pinchart
  2014-12-16 13:52   ` Geert Uytterhoeven
  2014-12-16 13:44 ` [PATCH v2 06/10] iommu/ipmmu-vmsa: Add device tree support Laurent Pinchart
  1 sibling, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2014-12-16 13:44 UTC (permalink / raw)
  To: iommu; +Cc: linux-sh, devicetree

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 .../bindings/iommu/renesas,ipmmu-vmsa.txt          | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt

Cc: devicetree@vger.kernel.org

Changes compared to v1:

- Extend the register range over both the base registers bank and the
  non-secure aliases
- Specify both the secure and non-secure interrupt, when applicable

diff --git a/Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt b/Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt
new file mode 100644
index 000000000000..ba225a091dcf
--- /dev/null
+++ b/Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt
@@ -0,0 +1,41 @@
+* Renesas VMSA-Compatible IOMMU
+
+The IPMMU is an IOMMU implementation compatible with the ARM VMSA page tables.
+It provides address translation for bus masters outside of the CPU, each
+connected to the IPMMU through a port called micro-TLB.
+
+
+Required Properties:
+
+  - compatible: Must contain "renesas,ipmmu-vmsa".
+  - reg: Base address and size of the IPMMU registers.
+  - interrupts: Specifiers for the MMU fault interrupts. For instances that
+    support secure mode two interrupts must be specified, for non-secure and
+    secure mode, in that order. For instances that don't support secure mode a
+    single interrupt must be specified.
+
+  - #iommu-cells: Must be 1.
+
+Each bus master connected to an IPMMU must reference the IPMMU in its device
+node with the following property:
+
+  - iommus: A reference to the IPMMU in two cells. The first cell is a phandle
+    to the IPMMU and the second cell the number of the micro-TLB that the
+    device is connected to.
+
+
+Example: R8A7791 IPMMU-MX and VSP1-D0 bus master
+
+	ipmmu_mx: mmu@fe951800 {
+		compatible = "renasas,ipmmu-vmsa";
+		reg = <0 0xfe951000 0 0x1000>;
+		interrupts = <0 222 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 221 IRQ_TYPE_LEVEL_HIGH>;
+		#iommu-cells = <1>;
+	};
+
+	vsp1@fe928000 {
+		...
+		iommus = <&ipmmu_mx 13>;
+		...
+	};
-- 
2.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 06/10] iommu/ipmmu-vmsa: Add device tree support
       [not found] <1418737457-22042-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>
  2014-12-16 13:44 ` [PATCH v2 05/10] iommu/ipmmu-vmsa: Add device tree bindings documentation Laurent Pinchart
@ 2014-12-16 13:44 ` Laurent Pinchart
  1 sibling, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2014-12-16 13:44 UTC (permalink / raw)
  To: iommu; +Cc: linux-sh, devicetree

Make platform data optional when the device is instantiated from DT and
look up the micro-TLB number in the bus master DT node.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/iommu/ipmmu-vmsa.c | 55 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 47 insertions(+), 8 deletions(-)

Cc: devicetree@vger.kernel.org

Changes compared to v1:

- Update to the v2 DT bindings

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 70bb5ba2aa51..8d9b3e79f05c 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -16,6 +16,7 @@
 #include <linux/io.h>
 #include <linux/iommu.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_data/ipmmu-vmsa.h>
 #include <linux/platform_device.h>
 #include <linux/sizes.h>
@@ -58,6 +59,8 @@ static LIST_HEAD(ipmmu_devices);
  * Registers Definition
  */
 
+#define IM_NS_ALIAS_OFFSET		0x800
+
 #define IM_CTX_SIZE			0x40
 
 #define IMCTR				0x0000
@@ -1002,16 +1005,33 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,
 
 static int ipmmu_find_utlb(struct ipmmu_vmsa_device *mmu, struct device *dev)
 {
-	const struct ipmmu_vmsa_master *master = mmu->pdata->masters;
-	const char *devname = dev_name(dev);
-	unsigned int i;
+	struct of_phandle_args args;
+	int ret;
+
+	if (mmu->pdata) {
+		const struct ipmmu_vmsa_master *master = mmu->pdata->masters;
+		const char *devname = dev_name(dev);
+		unsigned int i;
 
-	for (i = 0; i < mmu->pdata->num_masters; ++i, ++master) {
-		if (strcmp(master->name, devname) == 0)
-			return master->utlb;
+		for (i = 0; i < mmu->pdata->num_masters; ++i, ++master) {
+			if (strcmp(master->name, devname) == 0)
+				return master->utlb;
+		}
+
+		return -1;
 	}
 
-	return -1;
+	ret = of_parse_phandle_with_args(dev->of_node, "iommus",
+					 "#iommu-cells", 0, &args);
+	if (ret < 0)
+		return -1;
+
+	of_node_put(args.np);
+
+	if (args.np != mmu->dev->of_node || args.args_count != 1)
+		return -1;
+
+	return args.args[0];
 }
 
 static int ipmmu_add_device(struct device *dev)
@@ -1156,7 +1176,7 @@ static int ipmmu_probe(struct platform_device *pdev)
 	int irq;
 	int ret;
 
-	if (!pdev->dev.platform_data) {
+	if (!IS_ENABLED(CONFIG_OF) && !pdev->dev.platform_data) {
 		dev_err(&pdev->dev, "missing platform data\n");
 		return -EINVAL;
 	}
@@ -1177,6 +1197,20 @@ static int ipmmu_probe(struct platform_device *pdev)
 	if (IS_ERR(mmu->base))
 		return PTR_ERR(mmu->base);
 
+	/*
+	 * The IPMMU has two register banks, for secure and non-secure modes.
+	 * The bank mapped at the beginning of the IPMMU address space
+	 * corresponds to the running mode of the CPU. When running in secure
+	 * mode the non-secure register bank is also available at an offset.
+	 *
+	 * Secure mode operation isn't clearly documented and is thus currently
+	 * not implemented in the driver. Furthermore, preliminary tests of
+	 * non-secure operation with the main register bank were not successful.
+	 * Offset the registers base unconditionally to point to the non-secure
+	 * alias space for now.
+	 */
+	mmu->base += IM_NS_ALIAS_OFFSET;
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "no IRQ found\n");
@@ -1222,10 +1256,15 @@ static int ipmmu_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id ipmmu_of_ids[] = {
+	{ .compatible = "renesas,ipmmu-vmsa", },
+};
+
 static struct platform_driver ipmmu_driver = {
 	.driver = {
 		.owner = THIS_MODULE,
 		.name = "ipmmu-vmsa",
+		.of_match_table = of_match_ptr(ipmmu_of_ids),
 	},
 	.probe = ipmmu_probe,
 	.remove	= ipmmu_remove,
-- 
2.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 05/10] iommu/ipmmu-vmsa: Add device tree bindings documentation
  2014-12-16 13:44 ` [PATCH v2 05/10] iommu/ipmmu-vmsa: Add device tree bindings documentation Laurent Pinchart
@ 2014-12-16 13:52   ` Geert Uytterhoeven
  2014-12-16 15:19     ` Laurent Pinchart
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2014-12-16 13:52 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: iommu, Linux-sh list, devicetree@vger.kernel.org

Hi Laurent,

On Tue, Dec 16, 2014 at 2:44 PM, Laurent Pinchart
<laurent.pinchart+renesas@ideasonboard.com> wrote:
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Thanks!

Apart from the minor nit below:
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>

> +       ipmmu_mx: mmu@fe951800 {

fe951000

(yes, having to put the same information in two places will cause discrepancies)

> +               compatible = "renasas,ipmmu-vmsa";
> +               reg = <0 0xfe951000 0 0x1000>;
> +               interrupts = <0 222 IRQ_TYPE_LEVEL_HIGH>,
> +                            <0 221 IRQ_TYPE_LEVEL_HIGH>;
> +               #iommu-cells = <1>;
> +       };

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 05/10] iommu/ipmmu-vmsa: Add device tree bindings documentation
  2014-12-16 13:52   ` Geert Uytterhoeven
@ 2014-12-16 15:19     ` Laurent Pinchart
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2014-12-16 15:19 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Laurent Pinchart, iommu, Linux-sh list,
	devicetree@vger.kernel.org

Hi Geert,

On Tuesday 16 December 2014 14:52:39 Geert Uytterhoeven wrote:
> On Tue, Dec 16, 2014 at 2:44 PM, Laurent Pinchart wrote:
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> 
> Thanks!
> 
> Apart from the minor nit below:
> Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> > +       ipmmu_mx: mmu@fe951800 {
> 
> fe951000

Oops :-) Fixed, and applied your ack. Thank you.

> (yes, having to put the same information in two places will cause
> discrepancies)
>
> > +               compatible = "renasas,ipmmu-vmsa";
> > +               reg = <0 0xfe951000 0 0x1000>;
> > +               interrupts = <0 222 IRQ_TYPE_LEVEL_HIGH>,
> > +                            <0 221 IRQ_TYPE_LEVEL_HIGH>;
> > +               #iommu-cells = <1>;
> > +       };

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-16 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1418737457-22042-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>
2014-12-16 13:44 ` [PATCH v2 05/10] iommu/ipmmu-vmsa: Add device tree bindings documentation Laurent Pinchart
2014-12-16 13:52   ` Geert Uytterhoeven
2014-12-16 15:19     ` Laurent Pinchart
2014-12-16 13:44 ` [PATCH v2 06/10] iommu/ipmmu-vmsa: Add device tree support Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).