aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2007-01-11 00:08:41 -0500
committerPaul Mackerras <paulus@samba.org>2007-01-22 05:27:35 -0500
commit6984ee797a8798128e94ab2447c8ed91f0156eb5 (patch)
tree6751131ceab7ab2f776b9a984986fb85c55125c6 /arch/powerpc
parent4ef6e68117e93111590d9d4ada1a282304241169 (diff)
[POWERPC] Fix cell's mmio nvram to properly parse device tree
The mmio nvram driver (used by cell only atm) isn't properly parsing the device-tree, meaning that nvram isn't found correctly on the new Cell blades. It works ok for old blades where the nvram is at the root of the device tree but fails on Malta and CAB when it's hanging off axon. This fixes it by using the proper OF parsing functions. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/sysdev/mmio_nvram.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/arch/powerpc/sysdev/mmio_nvram.c b/arch/powerpc/sysdev/mmio_nvram.c
index ff23f5a4d4b9..e073e246293d 100644
--- a/arch/powerpc/sysdev/mmio_nvram.c
+++ b/arch/powerpc/sysdev/mmio_nvram.c
@@ -80,33 +80,39 @@ static ssize_t mmio_nvram_get_size(void)
80int __init mmio_nvram_init(void) 80int __init mmio_nvram_init(void)
81{ 81{
82 struct device_node *nvram_node; 82 struct device_node *nvram_node;
83 const unsigned long *buffer;
84 int proplen;
85 unsigned long nvram_addr; 83 unsigned long nvram_addr;
84 struct resource r;
86 int ret; 85 int ret;
87 86
88 ret = -ENODEV;
89 nvram_node = of_find_node_by_type(NULL, "nvram"); 87 nvram_node = of_find_node_by_type(NULL, "nvram");
90 if (!nvram_node) 88 if (!nvram_node) {
89 printk(KERN_WARNING "nvram: no node found in device-tree\n");
90 return -ENODEV;
91 }
92
93 ret = of_address_to_resource(nvram_node, 0, &r);
94 if (ret) {
95 printk(KERN_WARNING "nvram: failed to get address (err %d)\n",
96 ret);
91 goto out; 97 goto out;
92 98 }
93 ret = -EIO; 99 nvram_addr = r.start;
94 buffer = get_property(nvram_node, "reg", &proplen); 100 mmio_nvram_len = r.end - r.start + 1;
95 if (proplen != 2*sizeof(unsigned long)) 101 if ( (!mmio_nvram_len) || (!nvram_addr) ) {
96 goto out; 102 printk(KERN_WARNING "nvram: address or lenght is 0\n");
97 103 ret = -EIO;
98 ret = -ENODEV;
99 nvram_addr = buffer[0];
100 mmio_nvram_len = buffer[1];
101 if ( (!mmio_nvram_len) || (!nvram_addr) )
102 goto out; 104 goto out;
105 }
103 106
104 mmio_nvram_start = ioremap(nvram_addr, mmio_nvram_len); 107 mmio_nvram_start = ioremap(nvram_addr, mmio_nvram_len);
105 if (!mmio_nvram_start) 108 if (!mmio_nvram_start) {
109 printk(KERN_WARNING "nvram: failed to ioremap\n");
110 ret = -ENOMEM;
106 goto out; 111 goto out;
112 }
107 113
108 printk(KERN_INFO "mmio NVRAM, %luk mapped to %p\n", 114 printk(KERN_INFO "mmio NVRAM, %luk at 0x%lx mapped to %p\n",
109 mmio_nvram_len >> 10, mmio_nvram_start); 115 mmio_nvram_len >> 10, nvram_addr, mmio_nvram_start);
110 116
111 ppc_md.nvram_read = mmio_nvram_read; 117 ppc_md.nvram_read = mmio_nvram_read;
112 ppc_md.nvram_write = mmio_nvram_write; 118 ppc_md.nvram_write = mmio_nvram_write;