linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
To: linux-mips@linux-mips.org
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>,
	James Hogan <jhogan@kernel.org>,
	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>
Subject: [PATCH v4 2/2] MIPS: CPC: Map registers using DT in mips_cpc_default_phys_base()
Date: Fri, 19 Jan 2018 16:40:49 +0100	[thread overview]
Message-ID: <1516376459-25672-3-git-send-email-aleksandar.markovic@rt-rk.com> (raw)
In-Reply-To: <1516376459-25672-1-git-send-email-aleksandar.markovic@rt-rk.com>

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 location 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

  parent reply	other threads:[~2018-01-19 15:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 15:40 [PATCH v4 0/2] MIPS: Augment CPC support Aleksandar Markovic
2018-01-19 15:40 ` [PATCH v4 1/2] dt-bindings: Document mti,mips-cpc binding Aleksandar Markovic
2018-01-19 15:40 ` Aleksandar Markovic [this message]
2018-02-08 14:19 ` [PATCH v4 0/2] MIPS: Augment CPC support James Hogan

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=1516376459-25672-3-git-send-email-aleksandar.markovic@rt-rk.com \
    --to=aleksandar.markovic@rt-rk.com \
    --cc=aleksandar.markovic@mips.com \
    --cc=dengcheng.zhu@mips.com \
    --cc=douglas.leung@mips.com \
    --cc=goran.ferenc@mips.com \
    --cc=james.hogan@mips.com \
    --cc=jhogan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=matt.redfearn@mips.com \
    --cc=miodrag.dinic@mips.com \
    --cc=paul.burton@mips.com \
    --cc=petar.jovanovic@mips.com \
    --cc=raghu.gandham@mips.com \
    --cc=ralf@linux-mips.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 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).