linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Yangbo Lu <yangbo.lu@freescale.com>
To: <linuxppc-dev@lists.ozlabs.org>, <scottwood@freescale.com>,
	<linux-mmc@vger.kernel.org>, <ulf.hansson@linaro.org>
Cc: Yangbo Lu <yangbo.lu@freescale.com>
Subject: [PATCH 2/3] powerpc/85xx: add 'cpu-rev' property for cpus node
Date: Tue, 21 Jul 2015 17:45:23 +0800	[thread overview]
Message-ID: <1437471923-34172-1-git-send-email-yangbo.lu@freescale.com> (raw)

Add 'cpu-rev' property for cpus node to support getting cpu revision
from dts, since it's not good to get cpu revision using powerpc specific
function(like SVR_REV()) in common drivers.

Signed-off-by: Yangbo Lu <yangbo.lu@freescale.com>
---
 arch/powerpc/platforms/85xx/common.c          | 34 +++++++++++++++++++++++++++
 arch/powerpc/platforms/85xx/corenet_generic.c |  3 +++
 arch/powerpc/platforms/85xx/mpc85xx.h         |  1 +
 3 files changed, 38 insertions(+)

diff --git a/arch/powerpc/platforms/85xx/common.c b/arch/powerpc/platforms/85xx/common.c
index 7bfb9b1..5c55c0a4 100644
--- a/arch/powerpc/platforms/85xx/common.c
+++ b/arch/powerpc/platforms/85xx/common.c
@@ -8,8 +8,10 @@
 
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 
 #include <asm/qe.h>
+#include <asm/mpc85xx.h>
 #include <sysdev/cpm2_pic.h>
 
 #include "mpc85xx.h"
@@ -44,8 +46,40 @@ static const struct of_device_id mpc85xx_common_ids[] __initconst = {
 	{},
 };
 
+/* Add 'cpu-rev' property into cpus node of device tree */
+int of_add_cpu_rev_property(void)
+{
+	struct device_node *cpus;
+	struct property *cpu_rev;
+	u8 *revision;
+	u32 svr;
+
+	svr = mfspr(SPRN_SVR);
+
+	revision = kzalloc(sizeof(*revision), GFP_KERNEL);
+	if (!revision)
+		return 0;
+	*revision = SVR_REV(svr);
+
+	cpu_rev = kzalloc(sizeof(*cpu_rev), GFP_KERNEL);
+	if (!cpu_rev)
+		return 0;
+	cpu_rev->name = "cpu-rev";
+	cpu_rev->value = revision;
+	cpu_rev->length = sizeof(*revision);
+
+	cpus = of_find_node_by_path("/cpus");
+	if (of_add_property(cpus, cpu_rev))
+		return 0;
+
+	return 1;
+}
+
 int __init mpc85xx_common_publish_devices(void)
 {
+	if (!of_add_cpu_rev_property())
+		pr_info("Add 'cpu-rev' property into cpus node: failed!\n");
+
 	return of_platform_bus_probe(NULL, mpc85xx_common_ids, NULL);
 }
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/corenet_generic.c b/arch/powerpc/platforms/85xx/corenet_generic.c
index bd839dc..880940f 100644
--- a/arch/powerpc/platforms/85xx/corenet_generic.c
+++ b/arch/powerpc/platforms/85xx/corenet_generic.c
@@ -132,6 +132,9 @@ static const struct of_device_id of_device_ids[] = {
 
 int __init corenet_gen_publish_devices(void)
 {
+	if (!of_add_cpu_rev_property())
+		pr_info("Add 'cpu-rev' property into cpus node: failed!\n");
+
 	return of_platform_bus_probe(NULL, of_device_ids, NULL);
 }
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index 39056f6..bcc18e2 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -1,5 +1,6 @@
 #ifndef MPC85xx_H
 #define MPC85xx_H
+extern int of_add_cpu_rev_property(void);
 extern int mpc85xx_common_publish_devices(void);
 
 #ifdef CONFIG_CPM2
-- 
2.1.0.27.g96db324

             reply	other threads:[~2015-07-21 10:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21  9:45 Yangbo Lu [this message]
2015-07-25  2:24 ` [PATCH 2/3] powerpc/85xx: add 'cpu-rev' property for cpus node Scott Wood

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=1437471923-34172-1-git-send-email-yangbo.lu@freescale.com \
    --to=yangbo.lu@freescale.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=scottwood@freescale.com \
    --cc=ulf.hansson@linaro.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).