aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-08-29 02:56:16 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-10-11 01:53:37 -0400
commit5f33af4c0059255bcbf82a98a3789a01171b72e5 (patch)
treea2daef32b34be24efb3569d6c3d897e204f220f4 /arch/powerpc
parentaaa63093dd4c393391a3368e1c7305b0cc620571 (diff)
powerpc/scom: Add support for "reg" property
When devices are direct children of a scom controller node, they should be able to use the normal "reg" property instead of "scom-reg". In that case, they also use #address-cells rather than #scom-cells to indicate the size of an entry. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/sysdev/scom.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/arch/powerpc/sysdev/scom.c b/arch/powerpc/sysdev/scom.c
index 10f1d9e56612..413622d54395 100644
--- a/arch/powerpc/sysdev/scom.c
+++ b/arch/powerpc/sysdev/scom.c
@@ -53,7 +53,7 @@ scom_map_t scom_map_device(struct device_node *dev, int index)
53{ 53{
54 struct device_node *parent; 54 struct device_node *parent;
55 unsigned int cells, size; 55 unsigned int cells, size;
56 const u32 *prop; 56 const __be32 *prop, *sprop;
57 u64 reg, cnt; 57 u64 reg, cnt;
58 scom_map_t ret; 58 scom_map_t ret;
59 59
@@ -62,12 +62,24 @@ scom_map_t scom_map_device(struct device_node *dev, int index)
62 if (parent == NULL) 62 if (parent == NULL)
63 return 0; 63 return 0;
64 64
65 prop = of_get_property(parent, "#scom-cells", NULL); 65 /*
66 cells = prop ? *prop : 1; 66 * We support "scom-reg" properties for adding scom registers
67 67 * to a random device-tree node with an explicit scom-parent
68 *
69 * We also support the simple "reg" property if the device is
70 * a direct child of a scom controller.
71 *
72 * In case both exist, "scom-reg" takes precedence.
73 */
68 prop = of_get_property(dev, "scom-reg", &size); 74 prop = of_get_property(dev, "scom-reg", &size);
75 sprop = of_get_property(parent, "#scom-cells", NULL);
76 if (!prop && parent == dev->parent) {
77 prop = of_get_property(dev, "reg", &size);
78 sprop = of_get_property(parent, "#address-cells", NULL);
79 }
69 if (!prop) 80 if (!prop)
70 return 0; 81 return NULL;
82 cells = sprop ? be32_to_cpup(sprop) : 1;
71 size >>= 2; 83 size >>= 2;
72 84
73 if (index >= (size / (2*cells))) 85 if (index >= (size / (2*cells)))