All of lore.kernel.org
 help / color / mirror / Atom feed
From: thomas.petazzoni@free-electrons.com (Thomas Petazzoni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/10] ARM: mvebu: prepare coherency code to support more SOCs
Date: Thu,  6 Mar 2014 17:46:26 +0100	[thread overview]
Message-ID: <1394124395-20030-2-git-send-email-thomas.petazzoni@free-electrons.com> (raw)
In-Reply-To: <1394124395-20030-1-git-send-email-thomas.petazzoni@free-electrons.com>

The code that handles the coherency fabric of Armada 370 and Armada XP
in arch/arm/mach-mvebu/coherency.c made the assumption that there was
only one type of coherency fabric. Unfortunately, it turns out that
upcoming SoCs have a slightly different coherency unit.

In preparation to the introduction of the coherency support for more
SoCs, this commit:

 * Introduces a data associated to the compatible string in the
   compatible string match table, so that the code can differantiate
   the variant of coherency unit being used.

 * Separates the coherency unit initialization code into its own
   function.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 .../devicetree/bindings/arm/coherency-fabric.txt   |  5 ++-
 arch/arm/mach-mvebu/coherency.c                    | 46 +++++++++++++++-------
 2 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/coherency-fabric.txt b/Documentation/devicetree/bindings/arm/coherency-fabric.txt
index 17d8cd1..f0bfa37 100644
--- a/Documentation/devicetree/bindings/arm/coherency-fabric.txt
+++ b/Documentation/devicetree/bindings/arm/coherency-fabric.txt
@@ -4,7 +4,10 @@ Available on Marvell SOCs: Armada 370 and Armada XP
 
 Required properties:
 
-- compatible: "marvell,coherency-fabric"
+- compatible: the possible values are:
+
+ * "marvell,coherency-fabric", to be used for the coherency fabric of
+   the Armada 370 and Armada XP.
 
 - reg: Should contain coherency fabric registers location and
   length. First pair for the coherency fabric registers, second pair
diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
index 4e9d581..72d8d75 100644
--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -38,8 +38,13 @@ static void __iomem *coherency_cpu_base;
 
 #define IO_SYNC_BARRIER_CTL_OFFSET		   0x0
 
+enum {
+	COHERENCY_FABRIC_TYPE_ARMADA_370_XP,
+};
+
 static struct of_device_id of_coherency_table[] = {
-	{.compatible = "marvell,coherency-fabric"},
+	{.compatible = "marvell,coherency-fabric",
+	 .data = (void*) COHERENCY_FABRIC_TYPE_ARMADA_370_XP },
 	{ /* end of list */ },
 };
 
@@ -121,26 +126,39 @@ static struct notifier_block mvebu_hwcc_platform_nb = {
 	.notifier_call = mvebu_hwcc_platform_notifier,
 };
 
+static void __init armada_370_coherency_init(struct device_node *np)
+{
+	struct resource res;
+	of_address_to_resource(np, 0, &res);
+	coherency_phys_base = res.start;
+	/*
+	 * Ensure secondary CPUs will see the updated value,
+	 * which they read before they join the coherency
+	 * fabric, and therefore before they are coherent with
+	 * the boot CPU cache.
+	 */
+	sync_cache_w(&coherency_phys_base);
+	coherency_base = of_iomap(np, 0);
+	coherency_cpu_base = of_iomap(np, 1);
+	set_cpu_coherent(cpu_logical_map(smp_processor_id()), 0);
+}
+
 int __init coherency_init(void)
 {
 	struct device_node *np;
 
 	np = of_find_matching_node(NULL, of_coherency_table);
 	if (np) {
-		struct resource res;
+                const struct of_device_id *match =
+                    of_match_node(of_coherency_table, np);
+		int type;
+
+		type = (int) match->data;
 		pr_info("Initializing Coherency fabric\n");
-		of_address_to_resource(np, 0, &res);
-		coherency_phys_base = res.start;
-		/*
-		 * Ensure secondary CPUs will see the updated value,
-		 * which they read before they join the coherency
-		 * fabric, and therefore before they are coherent with
-		 * the boot CPU cache.
-		 */
-		sync_cache_w(&coherency_phys_base);
-		coherency_base = of_iomap(np, 0);
-		coherency_cpu_base = of_iomap(np, 1);
-		set_cpu_coherent(cpu_logical_map(smp_processor_id()), 0);
+
+		if (type == COHERENCY_FABRIC_TYPE_ARMADA_370_XP)
+			armada_370_coherency_init(np);
+
 		of_node_put(np);
 	}
 
-- 
1.8.3.2

  reply	other threads:[~2014-03-06 16:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06 16:46 [PATCH 00/10] ARM: mvebu: Hardware coherency support for Armada 375 and 38x Thomas Petazzoni
2014-03-06 16:46 ` Thomas Petazzoni [this message]
2014-03-06 16:46 ` [PATCH 02/10] ARM: mvebu: add a coherency_available() call Thomas Petazzoni
2014-03-06 16:46 ` [PATCH 03/10] bus: mvebu: pass the coherency availability information at init time Thomas Petazzoni
2014-03-06 16:46 ` [PATCH 04/10] ARM: mvebu: ARM: mvebu: use of_find_matching_node_and_match() in coherency.c Thomas Petazzoni
2014-03-06 16:46 ` [PATCH 05/10] ARM: mvebu: enable the ARM SCU on Armada 375 and Armada 38x Thomas Petazzoni
2014-03-06 16:46 ` [PATCH 06/10] ARM: mvebu: add Armada 375 support to the coherency code Thomas Petazzoni
2014-03-06 16:46 ` [PATCH 07/10] ARM: mvebu: implement Armada 375 coherency workaround Thomas Petazzoni
2014-03-06 18:36   ` Jason Cooper
2014-03-06 21:18     ` Thomas Petazzoni
2014-03-06 16:46 ` [PATCH 08/10] ARM: mvebu: add Armada 38x support to the coherency code Thomas Petazzoni
2014-03-06 16:46 ` [PATCH 09/10] ARM: mvebu: enable the coherency fabric on Armada 375 Thomas Petazzoni
2014-03-06 16:46 ` [PATCH 10/10] ARM: mvebu: enable the coherency fabric on Armada 38x Thomas Petazzoni
2014-03-24 15:06 ` [PATCH 00/10] ARM: mvebu: Hardware coherency support for Armada 375 and 38x Thomas Petazzoni
2014-03-25  9:32   ` Andrew Lunn
2014-03-25 10:36     ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394124395-20030-2-git-send-email-thomas.petazzoni@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.