linux-mips
[Top] [All Lists]

[PATCH 2/2] MIPS: CPC: Map registers using DT in mips_cpc_default_phys_b

To: linux-mips@linux-mips.org
Subject: [PATCH 2/2] MIPS: CPC: Map registers using DT in mips_cpc_default_phys_base()
From: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
Date: Fri, 15 Dec 2017 17:52:00 +0100
Cc: Paul Burton <paul.burton@mips.com>, Miodrag Dinic <miodrag.dinic@mips.com>, Aleksandar Markovic <aleksandar.markovic@mips.com>, Dengcheng Zhu <dengcheng.zhu@mips.com>, Douglas Leung <douglas.leung@mips.com>, Goran Ferenc <goran.ferenc@mips.com>, James Hogan <james.hogan@mips.com>, linux-kernel@vger.kernel.org, Matt Redfearn <matt.redfearn@mips.com>, Petar Jovanovic <petar.jovanovic@mips.com>, Raghu Gandham <raghu.gandham@mips.com>, Ralf Baechle <ralf@linux-mips.org>
In-reply-to: <1513356723-7393-1-git-send-email-aleksandar.markovic@rt-rk.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1513356723-7393-1-git-send-email-aleksandar.markovic@rt-rk.com>
Sender: linux-mips-bounce@linux-mips.org
From: Paul Burton <paul.burton@mips.com>

Reading mips_cpc_base value from the DT allows each platform
to define it according to its needs. This is especially
convenient for MIPS_GENERIC kernel where this kind of information
should be determined in runtime.

Use mti,mips-cpc compatible string with just a reg property to
specify the register mappings for your platform.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Signed-off-by: Miodrag Dinic <miodrag.dinic@mips.com>
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@mips.com>
---
 arch/mips/kernel/mips-cpc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c
index 19c88d7..fcf9af4 100644
--- a/arch/mips/kernel/mips-cpc.c
+++ b/arch/mips/kernel/mips-cpc.c
@@ -10,6 +10,8 @@
 
 #include <linux/errno.h>
 #include <linux/percpu.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/spinlock.h>
 
 #include <asm/mips-cps.h>
@@ -22,6 +24,17 @@ static DEFINE_PER_CPU_ALIGNED(unsigned long, 
cpc_core_lock_flags);
 
 phys_addr_t __weak mips_cpc_default_phys_base(void)
 {
+       struct device_node *cpc_node;
+       struct resource res;
+       int err;
+
+       cpc_node = of_find_compatible_node(of_root, NULL, "mti,mips-cpc");
+       if (cpc_node) {
+               err = of_address_to_resource(cpc_node, 0, &res);
+               if (!err)
+                       return res.start;
+       }
+
        return 0;
 }
 
-- 
2.7.4


<Prev in Thread] Current Thread [Next in Thread>