Skip to contentSkip to conversation

ARM: tegra: Add AHB driver

PATCH Superseded Hiroshi DOYU 6 participants 19 messages Apr 24, 2012 – Apr 26, 2012

Subsystems (5)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 ARM: tegra: Add AHB driver

The AHB Bus conforms to the AMBA Specification (Rev 2.0) Advanced High-performance Bus (AHB) architecture.

The AHB Arbiter controls AHB bus master arbitration. This effectively forms a second level of arbitration for access to the memory controller through the AHB Slave Memory device. The AHB pre-fetch logic can be configured to enhance performance for devices doing sequential access. Each AHB master is assigned to either the high or low priority bin. Both Tegra20/30 have this AHB bus.

Cc Felipe Balbi <[email protected]>
Cc Arnd Bergmann <[email protected]>

---
Update:
- Use platform_device to get info from dt dynamically.(Felipe/Arnd)

---
 arch/arm/mach-tegra/Makefile    |    1 +
 arch/arm/mach-tegra/tegra-ahb.c |  285 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 286 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/Makefile +1 -0
index 2eb4445..f6c8237 100644
@@ -1,3 +1,4 @@
+obj-y                                   += tegra-ahb.o
 obj-y                                   += board-pinmux.o
 obj-y                                   += common.o
 obj-y                                   += devices.o
arch/arm/mach-tegra/tegra-ahb.c new file +285 -0

285 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#1 lore raw

PATCH v2 2/3 ARM: tegra: Add SMMU enabler in AHB

Add extern func, "tegra_ahb_enable_smmu()" to inform AHB that SMMU is ready.

---
 arch/arm/mach-tegra/include/mach/tegra-ahb.h |   19 +++++++++++++++++++
 arch/arm/mach-tegra/tegra-ahb.c              |   18 ++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/include/mach/tegra-ahb.h new file +19 -0
new file mode 100644
index 0000000..51a5800
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef __MACH_TEGRA_AHB_H__
+#define __MACH_TEGRA_AHB_H__
+
+extern void tegra_ahb_enable_smmu(void);
+
+#endif	/* __MACH_TEGRA_AHB_H__ */
arch/arm/mach-tegra/tegra-ahb.c +18 -0
index 71b5950..32794ef 100644
@@ -78,6 +78,9 @@
 
 #define AHB_ARBITRATION_AHB_MEM_WRQUE_MST_ID	0xf8
 
+#define AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_DONE	1
+#define AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_SHIFT	17
+
 struct __tegra_ahb {
 	void __iomem	*regs;
 	struct device	*dev;
@@ -95,6 +98,21 @@ static inline void gizmo_writel(unsigned long value, unsigned long offset)
 	writel(value, tegra_ahb->regs + offset);
 }
 
+#ifdef CONFIG_ARCH_TEGRA_3x_SOC
+
+void tegra_ahb_enable_smmu(void)
+{
+	unsigned long val;
+
+	val = gizmo_readl(AHB_ARBITRATION_XBAR_CTRL);
+	val |= AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_DONE <<
+		AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_SHIFT;
+	gizmo_writel(val, AHB_ARBITRATION_XBAR_CTRL);
+}
+EXPORT_SYMBOL(tegra_ahb_enable_smmu);
+
+#endif
+
 struct __ahb_gizmo {
 	unsigned long offset;
 	unsigned long data;
Signature · 1 line
1.7.5.4
#8 lore raw

PATCH v2 3/3 iommu/tegra: smmu: Refrain from accessing to AHB registers

In reply to Hiroshi DOYU

Use "tegra_ahb_enable_smmu()" to inform AHB that SMMU is ready, instead of directly aceessing AHB registers.

---
 drivers/iommu/tegra-smmu.c |   40 ++++++++--------------------------------
 1 files changed, 8 insertions(+), 32 deletions(-)
drivers/iommu/tegra-smmu.c +8 -32
index ecd6790..de9fafe 100644
@@ -36,6 +36,7 @@
 
 #include <mach/iomap.h>
 #include <mach/smmu.h>
+#include <mach/tegra-ahb.h>
 
 /* bitmap of the page sizes currently supported */
 #define SMMU_IOMMU_PGSIZES	(SZ_4K)
@@ -111,11 +112,6 @@
 
 #define SMMU_PDE_NEXT_SHIFT		28
 
-/* AHB Arbiter Registers */
-#define AHB_XBAR_CTRL				0xe0
-#define AHB_XBAR_CTRL_SMMU_INIT_DONE_DONE	1
-#define AHB_XBAR_CTRL_SMMU_INIT_DONE_SHIFT	17
-
 #define SMMU_NUM_ASIDS				4
 #define SMMU_TLB_FLUSH_VA_SECTION__MASK		0xffc00000
 #define SMMU_TLB_FLUSH_VA_SECTION__SHIFT	12 /* right shift */
@@ -235,7 +231,7 @@ struct smmu_as {
  * Per SMMU device - IOMMU device
  */
 struct smmu_device {
-	void __iomem	*regs, *regs_ahbarb;
+	void __iomem	*regs;
 	unsigned long	iovmm_base;	/* remappable base address */
 	unsigned long	page_count;	/* total remappable size */
 	spinlock_t	lock;
@@ -257,7 +253,7 @@ struct smmu_device {
 static struct smmu_device *smmu_handle; /* unique for a system */
 
 /*
- *	SMMU/AHB register accessors
+ *	SMMU register accessors
  */
 static inline u32 smmu_read(struct smmu_device *smmu, size_t offs)
 {
@@ -268,15 +264,6 @@ static inline void smmu_write(struct smmu_device *smmu, u32 val, size_t offs)
 	writel(val, smmu->regs + offs);
 }
 
-static inline u32 ahb_read(struct smmu_device *smmu, size_t offs)
-{
-	return readl(smmu->regs_ahbarb + offs);
-}
-static inline void ahb_write(struct smmu_device *smmu, u32 val, size_t offs)
-{
-	writel(val, smmu->regs_ahbarb + offs);
-}
-
 #define VA_PAGE_TO_PA(va, page)	\
 	(page_to_phys(page) + ((unsigned long)(va) & ~PAGE_MASK))
 
@@ -397,11 +384,7 @@ static void smmu_setup_regs(struct smmu_device *smmu)
 	smmu_write(smmu, SMMU_PTC_CONFIG_RESET_VAL, SMMU_PTC_CONFIG);
 
 	smmu_flush_regs(smmu, 1);
-
-	val = ahb_read(smmu, AHB_XBAR_CTRL);
-	val |= AHB_XBAR_CTRL_SMMU_INIT_DONE_DONE <<
-		AHB_XBAR_CTRL_SMMU_INIT_DONE_SHIFT;
-	ahb_write(smmu, val, AHB_XBAR_CTRL);
+	tegra_ahb_enable_smmu();
 }
 
 static void flush_ptc_and_tlb(struct smmu_device *smmu,
@@ -883,7 +866,7 @@ static int tegra_smmu_resume(struct device *dev)
 static int tegra_smmu_probe(struct platform_device *pdev)
 {
 	struct smmu_device *smmu;
-	struct resource *regs, *regs2, *window;
+	struct resource *regs, *window;
 	struct device *dev = &pdev->dev;
 	int i, err = 0;
 
@@ -893,9 +876,8 @@ static int tegra_smmu_probe(struct platform_device *pdev)
 	BUILD_BUG_ON(PAGE_SHIFT != SMMU_PAGE_SHIFT);
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	regs2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	window = platform_get_resource(pdev, IORESOURCE_MEM, 2);
-	if (!regs || !regs2 || !window) {
+	window = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (!regs || !window) {
 		dev_err(dev, "No SMMU resources\n");
 		return -ENODEV;
 	}
@@ -911,9 +893,7 @@ static int tegra_smmu_probe(struct platform_device *pdev)
 	smmu->iovmm_base = (unsigned long)window->start;
 	smmu->page_count = resource_size(window) >> SMMU_PAGE_SHIFT;
 	smmu->regs = devm_ioremap(dev, regs->start, resource_size(regs));
-	smmu->regs_ahbarb = devm_ioremap(dev, regs2->start,
-					 resource_size(regs2));
-	if (!smmu->regs || !smmu->regs_ahbarb) {
+	if (!smmu->regs) {
 		dev_err(dev, "failed to remap SMMU registers\n");
 		err = -ENXIO;
 		goto fail;
@@ -960,8 +940,6 @@ fail:
 		__free_page(smmu->avp_vector_page);
 	if (smmu->regs)
 		devm_iounmap(dev, smmu->regs);
-	if (smmu->regs_ahbarb)
-		devm_iounmap(dev, smmu->regs_ahbarb);
 	if (smmu && smmu->as) {
 		for (i = 0; i < smmu->num_as; i++) {
 			if (smmu->as[i].pdir_page) {
@@ -993,8 +971,6 @@ static int tegra_smmu_remove(struct platform_device *pdev)
 		__free_page(smmu->avp_vector_page);
 	if (smmu->regs)
 		devm_iounmap(dev, smmu->regs);
-	if (smmu->regs_ahbarb)
-		devm_iounmap(dev, smmu->regs_ahbarb);
 	devm_kfree(dev, smmu);
 	smmu_handle = NULL;
 	return 0;
Signature · 1 line
1.7.5.4
#9 lore raw
In reply to Hiroshi DOYU
Quoted 114 lines · Hiroshi DOYU

The AHB Bus conforms to the AMBA Specification (Rev 2.0) Advanced High-performance Bus (AHB) architecture.

The AHB Arbiter controls AHB bus master arbitration. This effectively forms a second level of arbitration for access to the memory controller through the AHB Slave Memory device. The AHB pre-fetch logic can be configured to enhance performance for devices doing sequential access. Each AHB master is assigned to either the high or low priority bin. Both Tegra20/30 have this AHB bus.

Cc Felipe Balbi <[email protected]>
Cc Arnd Bergmann <[email protected]>

---
Update:
- Use platform_device to get info from dt dynamically.(Felipe/Arnd)

---
 arch/arm/mach-tegra/Makefile    |    1 +
 arch/arm/mach-tegra/tegra-ahb.c |  285 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 286 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/Makefile +1 -0
index 2eb4445..f6c8237 100644
@@ -1,3 +1,4 @@
+obj-y                                   += tegra-ahb.o
 obj-y                                   += board-pinmux.o
 obj-y                                   += common.o
 obj-y                                   += devices.o
arch/arm/mach-tegra/tegra-ahb.c new file +78 -0
new file mode 100644
index 0000000..71b5950
@@ -0,0 +1,285 @@
+/*
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * Author:
+ *	Jay Cheng <[email protected]>
+ *	James Wylder <[email protected]>
+ *	Benoit Goby <[email protected]>
+ *	Colin Cross <[email protected]>
+ *	Hiroshi DOYU <[email protected]>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+
+#include <mach/iomap.h>
+
+#define DRV_NAME "tegra-ahb"
+
+#define AHB_ARBITRATION_DISABLE		0x00
+#define AHB_ARBITRATION_PRIORITY_CTRL	0x04
+#define   AHB_PRIORITY_WEIGHT(x)	(((x) & 0x7) << 29)
+#define   PRIORITY_SELECT_USB BIT(6)
+#define   PRIORITY_SELECT_USB2 BIT(18)
+#define   PRIORITY_SELECT_USB3 BIT(17)
+
+#define AHB_GIZMO_AHB_MEM		0x0c
+#define   ENB_FAST_REARBITRATE BIT(2)
+#define   DONT_SPLIT_AHB_WR     BIT(7)
+
+#define AHB_GIZMO_APB_DMA		0x10
+#define AHB_GIZMO_IDE			0x18
+#define AHB_GIZMO_USB			0x1c
+#define AHB_GIZMO_AHB_XBAR_BRIDGE	0x20
+#define AHB_GIZMO_CPU_AHB_BRIDGE	0x24
+#define AHB_GIZMO_COP_AHB_BRIDGE	0x28
+#define AHB_GIZMO_XBAR_APB_CTLR		0x2c
+#define AHB_GIZMO_VCP_AHB_BRIDGE	0x30
+#define AHB_GIZMO_NAND			0x3c
+#define AHB_GIZMO_SDMMC4		0x44
+#define AHB_GIZMO_XIO			0x48
+#define AHB_GIZMO_BSEV			0x60
+#define AHB_GIZMO_BSEA			0x70
+#define AHB_GIZMO_NOR			0x74
+#define AHB_GIZMO_USB2			0x78
+#define AHB_GIZMO_USB3			0x7c
+#define   IMMEDIATE	BIT(18)
+
+#define AHB_GIZMO_SDMMC1		0x80
+#define AHB_GIZMO_SDMMC2		0x84
+#define AHB_GIZMO_SDMMC3		0x88
+#define AHB_MEM_PREFETCH_CFG_X		0xd8
+#define AHB_ARBITRATION_XBAR_CTRL	0xdc
+#define AHB_MEM_PREFETCH_CFG3		0xe0
+#define AHB_MEM_PREFETCH_CFG4		0xe4
+#define AHB_MEM_PREFETCH_CFG1		0xec
+#define AHB_MEM_PREFETCH_CFG2		0xf0
+#define   PREFETCH_ENB	BIT(31)
+#define   MST_ID(x)	(((x) & 0x1f) << 26)
+#define   AHBDMA_MST_ID	MST_ID(5)
+#define   USB_MST_ID	MST_ID(6)
+#define   USB2_MST_ID	MST_ID(18)
+#define   USB3_MST_ID	MST_ID(17)
+#define   ADDR_BNDRY(x)	(((x) & 0xf) << 21)
+#define   INACTIVITY_TIMEOUT(x)	(((x) & 0xffff) << 0)
+

arch/arm/mach-tegra/tegra-ahb.c line 88

Quoted 10 lines
arch/arm/mach-tegra/tegra-ahb.c new file +10 -0
+#define AHB_ARBITRATION_AHB_MEM_WRQUE_MST_ID	0xf8
+
+struct __tegra_ahb {
+	void __iomem	*regs;
+	struct device	*dev;
+};
+
+static struct __tegra_ahb *tegra_ahb;
+
+static inline unsigned long gizmo_readl(unsigned long offset)

pass void __iomem *base as argument here

arch/arm/mach-tegra/tegra-ahb.c line 90

Quoted 2 lines
arch/arm/mach-tegra/tegra-ahb.c new file +2 -0
+{
+	return readl(tegra_ahb->regs + offset);

this should become readl(base + offset);

arch/arm/mach-tegra/tegra-ahb.c line 93

Quoted 3 lines
arch/arm/mach-tegra/tegra-ahb.c new file +3 -0
+}
+
+static inline void gizmo_writel(unsigned long value, unsigned long offset)

ditto for void __iomem *base

Quoted 30 lines
arch/arm/mach-tegra/tegra-ahb.c new file +30 -0
+struct __ahb_gizmo {
+	unsigned long offset;
+	unsigned long data;
+};
+
+static struct __ahb_gizmo ahb_gizmo[] = {
+	{ .offset = AHB_ARBITRATION_DISABLE, },
+	{ .offset = AHB_ARBITRATION_PRIORITY_CTRL, },
+	{ .offset = AHB_GIZMO_AHB_MEM, },
+	{ .offset = AHB_GIZMO_APB_DMA, },
+	{ .offset = AHB_GIZMO_IDE, },
+	{ .offset = AHB_GIZMO_USB, },
+	{ .offset = AHB_GIZMO_AHB_XBAR_BRIDGE, },
+	{ .offset = AHB_GIZMO_CPU_AHB_BRIDGE, },
+	{ .offset = AHB_GIZMO_COP_AHB_BRIDGE, },
+	{ .offset = AHB_GIZMO_XBAR_APB_CTLR, },
+	{ .offset = AHB_GIZMO_VCP_AHB_BRIDGE, },
+	{ .offset = AHB_GIZMO_NAND, },
+	{ .offset = AHB_GIZMO_SDMMC4, },
+	{ .offset = AHB_GIZMO_XIO, },
+	{ .offset = AHB_GIZMO_BSEV, },
+	{ .offset = AHB_GIZMO_BSEA, },
+	{ .offset = AHB_GIZMO_NOR, },
+	{ .offset = AHB_GIZMO_USB2, },
+	{ .offset = AHB_GIZMO_USB3, },
+	{ .offset = AHB_GIZMO_SDMMC1, },
+	{ .offset = AHB_GIZMO_SDMMC2, },
+	{ .offset = AHB_GIZMO_SDMMC3, },
+	{ .offset = AHB_MEM_PREFETCH_CFG_X, },
+	{ .offset = AHB_ARBITRATION_XBAR_CTRL, },

arch/arm/mach-tegra/tegra-ahb.c line 137

Quoted 10 lines
arch/arm/mach-tegra/tegra-ahb.c new file +10 -0
+	{ .offset = AHB_MEM_PREFETCH_CFG3, },
+	{ .offset = AHB_MEM_PREFETCH_CFG4, },
+	{ .offset = AHB_MEM_PREFETCH_CFG1, },
+	{ .offset = AHB_MEM_PREFETCH_CFG2, },
+	{ .offset = AHB_ARBITRATION_AHB_MEM_WRQUE_MST_ID, },
+};
+
+static int tegra_ahb_suspend(struct device *dev)
+{
+	int i;

struct tegra_ahb *ahb = dev_get_drvdata(dev);

arch/arm/mach-tegra/tegra-ahb.c line 139

Quoted 2 lines
arch/arm/mach-tegra/tegra-ahb.c new file +2 -0
+	for (i = 0; i < ARRAY_SIZE(ahb_gizmo); i++)
+		ahb_gizmo[i].data = gizmo_readl(ahb_gizmo[i].offset);

+ ahb_gizmo[i].data = gizmo_readl(ahb->regs, ahb_gizmo[i].offset);

arch/arm/mach-tegra/tegra-ahb.c line 145

Quoted 6 lines
arch/arm/mach-tegra/tegra-ahb.c new file +6 -0
+	return 0;
+}
+
+static int tegra_ahb_resume(struct device *dev)
+{
+	int i;

struct tegra_ahb *ahb = dev_get_drvdata(dev);

arch/arm/mach-tegra/tegra-ahb.c line 143

Quoted 2 lines
arch/arm/mach-tegra/tegra-ahb.c new file +2 -0
+	for (i = 0; i < ARRAY_SIZE(ahb_gizmo); i++)
+		gizmo_writel(ahb_gizmo[i].data, ahb_gizmo[i].offset);

+ ahb_gizmo[i].data = gizmo_readl(ahb->regs, ahb_gizmo[i].offset);

arch/arm/mach-tegra/tegra-ahb.c line 151

Quoted 4 lines
arch/arm/mach-tegra/tegra-ahb.c new file +4 -0
+	return 0;
+}
+
+static void tegra_ahb_gizmo_init(void)

pass tegra_ahb as argument here

arch/arm/mach-tegra/tegra-ahb.c line 223

Quoted 13 lines
arch/arm/mach-tegra/tegra-ahb.c new file +13 -0
+static int __devinit tegra_ahb_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+
+	if (tegra_ahb)
+		return -ENODEV;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	res = devm_request_mem_region(&pdev->dev, res->start,
+				      resource_size(res), dev_name(&pdev->dev));

there's a nicer helper which you can use: devm_request_and_ioremap()

Quoted 5 lines
arch/arm/mach-tegra/tegra-ahb.c new file +5 -0
+	if (!res)
+		return -EBUSY;
+
+	tegra_ahb = devm_kzalloc(&pdev->dev, sizeof(*tegra_ahb), GFP_KERNEL);
+	if (!tegra_ahb)

arch/arm/mach-tegra/tegra-ahb.c line 238

Quoted 10 lines
arch/arm/mach-tegra/tegra-ahb.c new file +10 -0
+		return -ENOMEM;
+	tegra_ahb->dev = &pdev->dev;
+	tegra_ahb->regs = devm_ioremap(&pdev->dev,
+				       res->start, resource_size(res));
+	if (!tegra_ahb->regs) {
+		tegra_ahb = NULL;
+		return -ENOMEM;
+	}
+	platform_set_drvdata(pdev, tegra_ahb);
+	tegra_ahb_gizmo_init();

pass tegra_ahb as argument.

arch/arm/mach-tegra/tegra-ahb.c line 245

Quoted 7 lines
arch/arm/mach-tegra/tegra-ahb.c new file +7 -0
+	return 0;
+}
+
+static int __devexit tegra_ahb_remove(struct platform_device *pdev)
+{
+	platform_set_drvdata(pdev, NULL);
+	tegra_ahb = NULL;

this global pointer isn't needed at all.

arch/arm/mach-tegra/tegra-ahb.c line 257

Quoted 9 lines
arch/arm/mach-tegra/tegra-ahb.c new file +9 -0
+static const struct of_device_id tegra_ahb_of_match[] __devinitconst = {
+	{ .compatible = "nvidia,tegra30-ahb", },
+	{ .compatible = "nvidia,tegra20-ahb", },
+	{},
+};
+
+static const struct dev_pm_ops tegra_ahb_pm_ops __devinitconst = {
+	SET_RUNTIME_PM_OPS(tegra_ahb_suspend, tegra_ahb_resume, NULL)
+};

what about system suspend ? Should you be using UNIVERSAL_DEV_PM_OPS() instead ?

Quoted 12 lines
arch/arm/mach-tegra/tegra-ahb.c new file +12 -0
+static struct platform_driver tegra_ahb_driver = {
+	.probe = tegra_ahb_probe,
+	.remove = __devexit_p(tegra_ahb_remove),
+	.driver = {
+		.name = DRV_NAME,
+		.owner = THIS_MODULE,
+		.of_match_table = tegra_ahb_of_match,
+		.pm = &tegra_ahb_pm_ops,
+	},
+};
+
+static int __init tegra_ahb_init(void)

arch/arm/mach-tegra/tegra-ahb.c line 280

Quoted 10 lines
arch/arm/mach-tegra/tegra-ahb.c new file +10 -0
+{
+	return platform_driver_register(&tegra_ahb_driver);
+}
+postcore_initcall(tegra_ahb_init);
+
+static void __exit tegra_ahb_exit(void)
+{
+	platform_driver_unregister(&tegra_ahb_driver);
+}
+module_exit(tegra_ahb_exit);

please use module_platform_driver();

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120424/f3bd2670/attachment.sig>
#2 lore raw

Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB

In reply to Hiroshi DOYU

Hi,

Quoted 6 lines · Hiroshi DOYU
arch/arm/mach-tegra/tegra-ahb.c +2 -0
@@ -95,6 +98,21 @@ static inline void gizmo_writel(unsigned long value, unsigned long offset)
 	writel(value, tegra_ahb->regs + offset);
 }
 
+#ifdef CONFIG_ARCH_TEGRA_3x_SOC
+

arch/arm/mach-tegra/tegra-ahb.c static inline void gizmo_writel(unsigned long value, unsigned long offset) · line 112

Quoted 10 lines
arch/arm/mach-tegra/tegra-ahb.c +10 -0
+void tegra_ahb_enable_smmu(void)
+{
+	unsigned long val;
+
+	val = gizmo_readl(AHB_ARBITRATION_XBAR_CTRL);
+	val |= AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_DONE <<
+		AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_SHIFT;
+	gizmo_writel(val, AHB_ARBITRATION_XBAR_CTRL);
+}
+EXPORT_SYMBOL(tegra_ahb_enable_smmu);

ok, so this is the only place where you need that global pointer. Who would call this ? Can you do runtime detection of the SoC and enable SMMU based on that ?

I mean, will this function always be called for TEGRA 3 SoCs or is there another condition to that ?

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120424/68ab90d6/attachment.sig>
#3 lore raw

Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB

From: Felipe Balbi <[email protected]>
Subject: Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB
Date: Tue, 24 Apr 2012 14:32:52 +0200
Message-ID: <[email protected]>

Quoted 26 lines

* PGP Signed by an unknown key

Hi,

Quoted 6 lines · Hiroshi DOYU
arch/arm/mach-tegra/tegra-ahb.c +2 -0
@@ -95,6 +98,21 @@ static inline void gizmo_writel(unsigned long value, unsigned long offset)
 	writel(value, tegra_ahb->regs + offset);
 }
 
+#ifdef CONFIG_ARCH_TEGRA_3x_SOC
+

arch/arm/mach-tegra/tegra-ahb.c static inline void gizmo_writel(unsigned long value, unsigned long offset) · line 112

Quoted 10 lines
arch/arm/mach-tegra/tegra-ahb.c +10 -0
+void tegra_ahb_enable_smmu(void)
+{
+	unsigned long val;
+
+	val = gizmo_readl(AHB_ARBITRATION_XBAR_CTRL);
+	val |= AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_DONE <<
+		AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_SHIFT;
+	gizmo_writel(val, AHB_ARBITRATION_XBAR_CTRL);
+}
+EXPORT_SYMBOL(tegra_ahb_enable_smmu);

ok, so this is the only place where you need that global pointer. Who would call this ? Can you do runtime detection of the SoC and enable SMMU based on that ?

Quoted 2 lines

I mean, will this function always be called for TEGRA 3 SoCs or is there another condition to that ?

Only Tegra3 has SMMU.

#4 lore raw

Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB

Quoted 31 lines · Hiroshi Doyu

From: Felipe Balbi <[email protected]>
Subject: Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB
Date: Tue, 24 Apr 2012 14:32:52 +0200
Message-ID: <[email protected]>

Quoted 26 lines

* PGP Signed by an unknown key

Hi,

Quoted 6 lines · Hiroshi DOYU
arch/arm/mach-tegra/tegra-ahb.c +2 -0
@@ -95,6 +98,21 @@ static inline void gizmo_writel(unsigned long value, unsigned long offset)
 	writel(value, tegra_ahb->regs + offset);
 }
 
+#ifdef CONFIG_ARCH_TEGRA_3x_SOC
+

arch/arm/mach-tegra/tegra-ahb.c static inline void gizmo_writel(unsigned long value, unsigned long offset) · line 112

Quoted 10 lines
arch/arm/mach-tegra/tegra-ahb.c +10 -0
+void tegra_ahb_enable_smmu(void)
+{
+	unsigned long val;
+
+	val = gizmo_readl(AHB_ARBITRATION_XBAR_CTRL);
+	val |= AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_DONE <<
+		AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_SHIFT;
+	gizmo_writel(val, AHB_ARBITRATION_XBAR_CTRL);
+}
+EXPORT_SYMBOL(tegra_ahb_enable_smmu);

ok, so this is the only place where you need that global pointer. Who would call this ? Can you do runtime detection of the SoC and enable SMMU based on that ?

Quoted 4 lines
Quoted 2 lines

I mean, will this function always be called for TEGRA 3 SoCs or is there another condition to that ?

Only Tegra3 has SMMU.

but all of them ? In that case, you could call this from probe itself, right ? But an ifdef won't work in all cases, so you need to do runtime detection based on some revision register or cpu detection...

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120424/ad751114/attachment.sig>
#5 lore raw

Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB

From: Felipe Balbi <[email protected]>
Subject: Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB
Date: Tue, 24 Apr 2012 14:41:18 +0200
Message-ID: <[email protected]>

Quoted 34 lines

* PGP Signed by an unknown key

Quoted 31 lines · Hiroshi Doyu

From: Felipe Balbi <[email protected]>
Subject: Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB
Date: Tue, 24 Apr 2012 14:32:52 +0200
Message-ID: <[email protected]>

Quoted 26 lines
Quoted 1 line

Old Signed by an unknown key

Hi,

Quoted 6 lines · Hiroshi DOYU
arch/arm/mach-tegra/tegra-ahb.c +2 -0
@@ -95,6 +98,21 @@ static inline void gizmo_writel(unsigned long value, unsigned long offset)
 	writel(value, tegra_ahb->regs + offset);
 }
 
+#ifdef CONFIG_ARCH_TEGRA_3x_SOC
+

arch/arm/mach-tegra/tegra-ahb.c static inline void gizmo_writel(unsigned long value, unsigned long offset) · line 112

Quoted 10 lines
arch/arm/mach-tegra/tegra-ahb.c +10 -0
+void tegra_ahb_enable_smmu(void)
+{
+	unsigned long val;
+
+	val = gizmo_readl(AHB_ARBITRATION_XBAR_CTRL);
+	val |= AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_DONE <<
+		AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_SHIFT;
+	gizmo_writel(val, AHB_ARBITRATION_XBAR_CTRL);
+}
+EXPORT_SYMBOL(tegra_ahb_enable_smmu);

ok, so this is the only place where you need that global pointer. Who would call this ? Can you do runtime detection of the SoC and enable SMMU based on that ?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I mean, will this function always be called for TEGRA 3 SoCs or is there another condition to that ?

Only Tegra3 has SMMU.

but all of them ? In that case, you could call this from probe itself, right ? But an ifdef won't work in all cases, so you need to do runtime detection based on some revision register or cpu detection...

So far we don't have so many variants, and presently TEGRA_3x_SOC always has a SMMU. If there were some variants of TEGRA_3x_SOC, where some might not have SMMU, then runtime detection would make sense there. Now it's something like TEGRA_3x_SOC == SMMU.

#6 lore raw

Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB

Quoted 10 lines · Hiroshi Doyu
Quoted 5 lines
Quoted 1 line

Only Tegra3 has SMMU.

but all of them ? In that case, you could call this from probe itself, right ? But an ifdef won't work in all cases, so you need to do runtime detection based on some revision register or cpu detection...

So far we don't have so many variants, and presently TEGRA_3x_SOC always has a SMMU. If there were some variants of TEGRA_3x_SOC, where some might not have SMMU, then runtime detection would make sense there. Now it's something like TEGRA_3x_SOC == SMMU.

the problem is when you have single kernel for TEGRA 2 and TEGRA 3. If you rely on ifdef, one of them won't work properly, right ? ;-)

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120424/c8b50bf8/attachment.sig>
#10 lore raw
In reply to Felipe Balbi
Quoted 3 lines · Felipe Balbi
Quoted 2 lines · Hiroshi DOYU

The AHB Bus conforms to the AMBA Specification (Rev 2.0) Advanced High-performance Bus (AHB) architecture.

...

Quoted 5 lines
Quoted 5 lines
arch/arm/mach-tegra/tegra-ahb.c new file +5 -0
+static int __init tegra_ahb_init(void)
+{
+	return platform_driver_register(&tegra_ahb_driver);
+}
+postcore_initcall(tegra_ahb_init);
Quoted 8 lines

arch/arm/mach-tegra/tegra-ahb.c line 280

Quoted 6 lines
arch/arm/mach-tegra/tegra-ahb.c new file +6 -0
+
+static void __exit tegra_ahb_exit(void)
+{
+	platform_driver_unregister(&tegra_ahb_driver);
+}
+module_exit(tegra_ahb_exit);

please use module_platform_driver();

That won't work for a postcore_initcall.

#12 lore raw
In reply to Hiroshi DOYU
Quoted 13 lines · Hiroshi DOYU

The AHB Bus conforms to the AMBA Specification (Rev 2.0) Advanced High-performance Bus (AHB) architecture.

The AHB Arbiter controls AHB bus master arbitration. This effectively forms a second level of arbitration for access to the memory controller through the AHB Slave Memory device. The AHB pre-fetch logic can be configured to enhance performance for devices doing sequential access. Each AHB master is assigned to either the high or low priority bin. Both Tegra20/30 have this AHB bus.

Cc Felipe Balbi <[email protected]>
Cc Arnd Bergmann <[email protected]>
Quoted 7 lines

---
Update:
- Use platform_device to get info from dt dynamically.(Felipe/Arnd)

---
 arch/arm/mach-tegra/Makefile    |    1 +
 arch/arm/mach-tegra/tegra-ahb.c |  285 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 286 insertions(+), 0 deletions(-)

1. I thought we weren't going to have any more drivers under arch/arm
2. From the way you describe it above, this sounds like it should be some kind of generic driver, which obtains the necessary settings to be programmed into registers from (eg) DT.

#7 lore raw

Re: [PATCH v2 2/3] ARM: tegra: Add SMMU enabler in AHB

In reply to Hiroshi DOYU
Quoted 9 lines · Hiroshi DOYU
arch/arm/mach-tegra/tegra-ahb.c +3 -0
+#define AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_DONE	1
+#define AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_SHIFT	17
+
 struct __tegra_ahb {
 	void __iomem	*regs;
 	struct device	*dev;
@@ -95,6 +98,21 @@ static inline void gizmo_writel(unsigned long value, unsigned long offset)
 	writel(value, tegra_ahb->regs + offset);
 }

arch/arm/mach-tegra/tegra-ahb.c static inline void gizmo_writel(unsigned long value, unsigned long offset) · line 109

Quoted 10 lines
arch/arm/mach-tegra/tegra-ahb.c +9 -0
 
+#ifdef CONFIG_ARCH_TEGRA_3x_SOC
+
+void tegra_ahb_enable_smmu(void)
+{
+	unsigned long val;
+
+	val = gizmo_readl(AHB_ARBITRATION_XBAR_CTRL);
+	val |= AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_DONE <<
+		AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE_SHIFT;

In addition to what Felipe said...

Why do you need two constants where you have only one use point? What's wrong with having just a single definition which gives you the right bitmask?

#11 lore raw
In reply to Stephen Warren
Quoted 19 lines · Stephen Warren
Quoted 3 lines · Felipe Balbi
Quoted 2 lines · Hiroshi DOYU

The AHB Bus conforms to the AMBA Specification (Rev 2.0) Advanced High-performance Bus (AHB) architecture.

...

Quoted 5 lines
Quoted 5 lines
arch/arm/mach-tegra/tegra-ahb.c new file +5 -0
+static int __init tegra_ahb_init(void)
+{
+	return platform_driver_register(&tegra_ahb_driver);
+}
+postcore_initcall(tegra_ahb_init);
Quoted 8 lines

arch/arm/mach-tegra/tegra-ahb.c line 280

Quoted 6 lines
arch/arm/mach-tegra/tegra-ahb.c new file +6 -0
+
+static void __exit tegra_ahb_exit(void)
+{
+	platform_driver_unregister(&tegra_ahb_driver);
+}
+module_exit(tegra_ahb_exit);

please use module_platform_driver();

Quoted 1 line

That won't work for a postcore_initcall.

aaah, indeed. Missed that part ;-) My bad.

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120424/98fe68c4/attachment.sig>
#13 lore raw
In reply to Russell King - ARM Linux
Quoted 22 lines · On Tue, 24 Apr 2012 21:56:45 +0200 Russell King - ARM Linux…
Quoted 13 lines · Hiroshi DOYU

The AHB Bus conforms to the AMBA Specification (Rev 2.0) Advanced High-performance Bus (AHB) architecture.

The AHB Arbiter controls AHB bus master arbitration. This effectively forms a second level of arbitration for access to the memory controller through the AHB Slave Memory device. The AHB pre-fetch logic can be configured to enhance performance for devices doing sequential access. Each AHB master is assigned to either the high or low priority bin. Both Tegra20/30 have this AHB bus.

Cc Felipe Balbi <[email protected]>
Cc Arnd Bergmann <[email protected]>
Quoted 7 lines

---
Update:
- Use platform_device to get info from dt dynamically.(Felipe/Arnd)

---
 arch/arm/mach-tegra/Makefile    |    1 +
 arch/arm/mach-tegra/tegra-ahb.c |  285 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 286 insertions(+), 0 deletions(-)
Quoted 2 lines

1. I thought we weren't going to have any more drivers under arch/arm

Can this driver be located under "drivers/misc"? Or is there any better place?

Quoted 3 lines

2. From the way you describe it above, this sounds like it should be some kind of generic driver, which obtains the necessary settings to be programmed into registers from (eg) DT.

Agree.

#14 lore raw
Quoted 25 lines · Hiroshi Doyu
Quoted 22 lines · On Tue, 24 Apr 2012 21:56:45 +0200 Russell King - ARM Linux…
Quoted 20 lines · Hiroshi DOYU

The AHB Bus conforms to the AMBA Specification (Rev 2.0) Advanced High-performance Bus (AHB) architecture.

The AHB Arbiter controls AHB bus master arbitration. This effectively forms a second level of arbitration for access to the memory controller through the AHB Slave Memory device. The AHB pre-fetch logic can be configured to enhance performance for devices doing sequential access. Each AHB master is assigned to either the high or low priority bin. Both Tegra20/30 have this AHB bus.

Cc Felipe Balbi <[email protected]>
Cc Arnd Bergmann <[email protected]>

---
Update:
- Use platform_device to get info from dt dynamically.(Felipe/Arnd)

---
 arch/arm/mach-tegra/Makefile    |    1 +
 arch/arm/mach-tegra/tegra-ahb.c |  285 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 286 insertions(+), 0 deletions(-)
Quoted 4 lines
Quoted 2 lines

1. I thought we weren't going to have any more drivers under arch/arm

Can this driver be located under "drivers/misc"? Or is there any better place?

maybe drivers/platform/arm/ ??

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120425/0156126d/attachment-0001.sig>
#15 lore raw
Quoted 26 lines · Felipe Balbi
Quoted 25 lines · Hiroshi Doyu
Quoted 22 lines · On Tue, 24 Apr 2012 21:56:45 +0200 Russell King - ARM Linux…
Quoted 20 lines · Hiroshi DOYU

The AHB Bus conforms to the AMBA Specification (Rev 2.0) Advanced High-performance Bus (AHB) architecture.

The AHB Arbiter controls AHB bus master arbitration. This effectively forms a second level of arbitration for access to the memory controller through the AHB Slave Memory device. The AHB pre-fetch logic can be configured to enhance performance for devices doing sequential access. Each AHB master is assigned to either the high or low priority bin. Both Tegra20/30 have this AHB bus.

Cc Felipe Balbi <[email protected]>
Cc Arnd Bergmann <[email protected]>

---
Update:
- Use platform_device to get info from dt dynamically.(Felipe/Arnd)

---
 arch/arm/mach-tegra/Makefile    |    1 +
 arch/arm/mach-tegra/tegra-ahb.c |  285 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 286 insertions(+), 0 deletions(-)
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

1. I thought we weren't going to have any more drivers under arch/arm

Can this driver be located under "drivers/misc"? Or is there any better place?

maybe drivers/platform/arm/ ??

I really wouldn't want to add that directory: It has the risk of letting people add random crap there that may or may not be related to ARM (the company) and/or ARM (the architecture).

I think it could go into drivers/amba/ along with the primecell bus driver. The two drivers are for two different aspects of the AMBA spec and don't actually depend on one another as far as I can tell, but it's at least a fitting name, and it doesn't depend on the ARM architecture, which is important because the driver could be used on other architectures that are connected to an AHB bus.

Arnd

#16 lore raw
Quoted 1 line · Arnd Bergmann

On Wednesday 25 April 2012, Felipe Balbi wrote:

...

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Can this driver be located under "drivers/misc"? Or is there any better place?

maybe drivers/platform/arm/ ??

I really wouldn't want to add that directory: It has the risk of letting people add random crap there that may or may not be related to ARM (the company) and/or ARM (the architecture).

Quoted 6 lines

I think it could go into drivers/amba/ along with the primecell bus driver. The two drivers are for two different aspects of the AMBA spec and don't actually depend on one another as far as I can tell, but it's at least a fitting name, and it doesn't depend on the ARM architecture, which is important because the driver could be used on other architectures that are connected to an AHB bus.

Hiroshi, is this driver for something (registers/features) that AMBA actually specifies? AHB might be part of AMBA (I'm not familiar enough to know), but I don't think this aspect of Tegra's AHB bus is part of any core AHB/AMBA specification, rather than being some Tegra-specific control over the bus (given that the registers and bits correspond to Tegra-specific devices on the bus).

I'm not really convinced that low-level platform-specific drivers like this shouldn't be in the arch/arm/mach-* directories.

#17 lore raw
Quoted 18 lines · On Wed, 25 Apr 2012 17:59:40 +0200 Stephen Warren <[email protected]> wrote:
Quoted 1 line · Arnd Bergmann

On Wednesday 25 April 2012, Felipe Balbi wrote:

...

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Can this driver be located under "drivers/misc"? Or is there any better place?

maybe drivers/platform/arm/ ??

I really wouldn't want to add that directory: It has the risk of letting people add random crap there that may or may not be related to ARM (the company) and/or ARM (the architecture).

Quoted 6 lines

I think it could go into drivers/amba/ along with the primecell bus driver. The two drivers are for two different aspects of the AMBA spec and don't actually depend on one another as far as I can tell, but it's at least a fitting name, and it doesn't depend on the ARM architecture, which is important because the driver could be used on other architectures that are connected to an AHB bus.

Quoted 6 lines

Hiroshi, is this driver for something (registers/features) that AMBA actually specifies? AHB might be part of AMBA (I'm not familiar enough to know), but I don't think this aspect of Tegra's AHB bus is part of any core AHB/AMBA specification, rather than being some Tegra-specific control over the bus (given that the registers and bits correspond to Tegra-specific devices on the bus).

Agree.

Taking a look at AHB spec, this tegra-ahb part is a bit beyond that spec from S/W POV. If there's other similiar AHB drivers from othere SoC, we may be able to generalize them, but at the moment, it's hard to imagine how much/little part is common for similar AHB drivers, like registers/bit definitions. Most of the part may depends on SoC/Tegra.

Quoted 2 lines

I'm not really convinced that low-level platform-specific drivers like this shouldn't be in the arch/arm/mach-* directories.

So I think that keeping this kind of drivers under "arch/arm/mach-*" or "drivers/amba" as 'tegra'-ahb.c name. If similier drivers comes, then, what about thinking the generalization again? Either way would be ok for me.

#18 lore raw
In reply to Stephen Warren
Quoted 18 lines · Stephen Warren
Quoted 1 line · Arnd Bergmann

On Wednesday 25 April 2012, Felipe Balbi wrote:

...

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Can this driver be located under "drivers/misc"? Or is there any better place?

maybe drivers/platform/arm/ ??

I really wouldn't want to add that directory: It has the risk of letting people add random crap there that may or may not be related to ARM (the company) and/or ARM (the architecture).

Quoted 6 lines

I think it could go into drivers/amba/ along with the primecell bus driver. The two drivers are for two different aspects of the AMBA spec and don't actually depend on one another as far as I can tell, but it's at least a fitting name, and it doesn't depend on the ARM architecture, which is important because the driver could be used on other architectures that are connected to an AHB bus.

Quoted 7 lines

Hiroshi, is this driver for something (registers/features) that AMBA actually specifies? AHB might be part of AMBA (I'm not familiar enough to know), but I don't think this aspect of Tegra's AHB bus is part of any core AHB/AMBA specification, rather than being some Tegra-specific control over the bus (given that the registers and bits correspond to Tegra-specific devices on the bus).

The HW controlled by this 'driver' is roughly: the AHB arbiter, glue logic between IP blocks and the AHB bus and AHB memory controller slave. All of these are tegra specific AFAIK. So I don't see much point in a generic driver.

Cheers,

Peter.