* [PATCH 2/3] powerpc/85xx: add 'cpu-rev' property for cpus node
@ 2015-07-21 9:45 ` Yangbo Lu
0 siblings, 0 replies; 4+ messages in thread
From: Yangbo Lu @ 2015-07-21 9:45 UTC (permalink / raw)
To: linuxppc-dev, scottwood, linux-mmc, ulf.hansson; +Cc: Yangbo Lu
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] powerpc/85xx: add 'cpu-rev' property for cpus node
@ 2015-07-21 9:45 ` Yangbo Lu
0 siblings, 0 replies; 4+ messages in thread
From: Yangbo Lu @ 2015-07-21 9:45 UTC (permalink / raw)
To: linuxppc-dev, scottwood, linux-mmc, ulf.hansson; +Cc: Yangbo Lu
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/3] powerpc/85xx: add 'cpu-rev' property for cpus node
2015-07-21 9:45 ` Yangbo Lu
@ 2015-07-25 2:24 ` Scott Wood
-1 siblings, 0 replies; 4+ messages in thread
From: Scott Wood @ 2015-07-25 2:24 UTC (permalink / raw)
To: Yangbo Lu; +Cc: linuxppc-dev, linux-mmc, ulf.hansson
On Tue, 2015-07-21 at 17:45 +0800, Yangbo Lu wrote:
> 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.
No. Don't modify the device tree within Linux without a really good reason
(e.g. platform code to fix up a broken device tree).
Why not just read SVR from guts, which works on both PPC and ARM?
-Scott
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/3] powerpc/85xx: add 'cpu-rev' property for cpus node
@ 2015-07-25 2:24 ` Scott Wood
0 siblings, 0 replies; 4+ messages in thread
From: Scott Wood @ 2015-07-25 2:24 UTC (permalink / raw)
To: Yangbo Lu; +Cc: linuxppc-dev, linux-mmc, ulf.hansson
On Tue, 2015-07-21 at 17:45 +0800, Yangbo Lu wrote:
> 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.
No. Don't modify the device tree within Linux without a really good reason
(e.g. platform code to fix up a broken device tree).
Why not just read SVR from guts, which works on both PPC and ARM?
-Scott
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-07-25 2:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21 9:45 [PATCH 2/3] powerpc/85xx: add 'cpu-rev' property for cpus node Yangbo Lu
2015-07-21 9:45 ` Yangbo Lu
2015-07-25 2:24 ` Scott Wood
2015-07-25 2:24 ` Scott Wood
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.