aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/cell/spu_manage.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/platforms/cell/spu_manage.c')
-rw-r--r--arch/powerpc/platforms/cell/spu_manage.c102
1 files changed, 24 insertions, 78 deletions
diff --git a/arch/powerpc/platforms/cell/spu_manage.c b/arch/powerpc/platforms/cell/spu_manage.c
index d8b39fe39cdd..e34599f53d28 100644
--- a/arch/powerpc/platforms/cell/spu_manage.c
+++ b/arch/powerpc/platforms/cell/spu_manage.c
@@ -59,63 +59,6 @@ static u64 __init find_spu_unit_number(struct device_node *spe)
59 return 0; 59 return 0;
60} 60}
61 61
62static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
63 const char *prop)
64{
65 const struct address_prop {
66 unsigned long address;
67 unsigned int len;
68 } __attribute__((packed)) *p;
69 int proplen;
70
71 unsigned long start_pfn, nr_pages;
72 struct pglist_data *pgdata;
73 struct zone *zone;
74 int ret;
75
76 p = get_property(spe, prop, &proplen);
77 WARN_ON(proplen != sizeof (*p));
78
79 start_pfn = p->address >> PAGE_SHIFT;
80 nr_pages = ((unsigned long)p->len + PAGE_SIZE - 1) >> PAGE_SHIFT;
81
82 pgdata = NODE_DATA(spu->node);
83 zone = pgdata->node_zones;
84
85 ret = __add_pages(zone, start_pfn, nr_pages);
86
87 return ret;
88}
89
90static void __iomem * __init map_spe_prop(struct spu *spu,
91 struct device_node *n, const char *name)
92{
93 const struct address_prop {
94 unsigned long address;
95 unsigned int len;
96 } __attribute__((packed)) *prop;
97
98 const void *p;
99 int proplen;
100 void __iomem *ret = NULL;
101 int err = 0;
102
103 p = get_property(n, name, &proplen);
104 if (proplen != sizeof (struct address_prop))
105 return NULL;
106
107 prop = p;
108
109 err = cell_spuprop_present(spu, n, name);
110 if (err && (err != -EEXIST))
111 goto out;
112
113 ret = ioremap(prop->address, prop->len);
114
115 out:
116 return ret;
117}
118
119static void spu_unmap(struct spu *spu) 62static void spu_unmap(struct spu *spu)
120{ 63{
121 if (!firmware_has_feature(FW_FEATURE_LPAR)) 64 if (!firmware_has_feature(FW_FEATURE_LPAR))
@@ -157,6 +100,23 @@ static int __init spu_map_interrupts_old(struct spu *spu,
157 return spu->irqs[2] == NO_IRQ ? -EINVAL : 0; 100 return spu->irqs[2] == NO_IRQ ? -EINVAL : 0;
158} 101}
159 102
103static void __iomem * __init spu_map_prop_old(struct spu *spu,
104 struct device_node *n,
105 const char *name)
106{
107 const struct address_prop {
108 unsigned long address;
109 unsigned int len;
110 } __attribute__((packed)) *prop;
111 int proplen;
112
113 prop = get_property(n, name, &proplen);
114 if (prop == NULL || proplen != sizeof (struct address_prop))
115 return NULL;
116
117 return ioremap(prop->address, prop->len);
118}
119
160static int __init spu_map_device_old(struct spu *spu) 120static int __init spu_map_device_old(struct spu *spu)
161{ 121{
162 struct device_node *node = spu->devnode; 122 struct device_node *node = spu->devnode;
@@ -175,7 +135,7 @@ static int __init spu_map_device_old(struct spu *spu)
175 135
176 /* we use local store as ram, not io memory */ 136 /* we use local store as ram, not io memory */
177 spu->local_store = (void __force *) 137 spu->local_store = (void __force *)
178 map_spe_prop(spu, node, "local-store"); 138 spu_map_prop_old(spu, node, "local-store");
179 if (!spu->local_store) 139 if (!spu->local_store)
180 goto out; 140 goto out;
181 141
@@ -184,16 +144,16 @@ static int __init spu_map_device_old(struct spu *spu)
184 goto out_unmap; 144 goto out_unmap;
185 spu->problem_phys = *(unsigned long *)prop; 145 spu->problem_phys = *(unsigned long *)prop;
186 146
187 spu->problem = map_spe_prop(spu, node, "problem"); 147 spu->problem = spu_map_prop_old(spu, node, "problem");
188 if (!spu->problem) 148 if (!spu->problem)
189 goto out_unmap; 149 goto out_unmap;
190 150
191 spu->priv2 = map_spe_prop(spu, node, "priv2"); 151 spu->priv2 = spu_map_prop_old(spu, node, "priv2");
192 if (!spu->priv2) 152 if (!spu->priv2)
193 goto out_unmap; 153 goto out_unmap;
194 154
195 if (!firmware_has_feature(FW_FEATURE_LPAR)) { 155 if (!firmware_has_feature(FW_FEATURE_LPAR)) {
196 spu->priv1 = map_spe_prop(spu, node, "priv1"); 156 spu->priv1 = spu_map_prop_old(spu, node, "priv1");
197 if (!spu->priv1) 157 if (!spu->priv1)
198 goto out_unmap; 158 goto out_unmap;
199 } 159 }
@@ -245,34 +205,20 @@ static int spu_map_resource(struct spu *spu, int nr,
245 void __iomem** virt, unsigned long *phys) 205 void __iomem** virt, unsigned long *phys)
246{ 206{
247 struct device_node *np = spu->devnode; 207 struct device_node *np = spu->devnode;
248 unsigned long start_pfn, nr_pages;
249 struct pglist_data *pgdata;
250 struct zone *zone;
251 struct resource resource = { }; 208 struct resource resource = { };
252 unsigned long len; 209 unsigned long len;
253 int ret; 210 int ret;
254 211
255 ret = of_address_to_resource(np, nr, &resource); 212 ret = of_address_to_resource(np, nr, &resource);
256 if (ret) 213 if (ret)
257 goto out; 214 return ret;
258
259 if (phys) 215 if (phys)
260 *phys = resource.start; 216 *phys = resource.start;
261 len = resource.end - resource.start + 1; 217 len = resource.end - resource.start + 1;
262 *virt = ioremap(resource.start, len); 218 *virt = ioremap(resource.start, len);
263 if (!*virt) 219 if (!*virt)
264 ret = -EINVAL; 220 return -EINVAL;
265 221 return 0;
266 start_pfn = resource.start >> PAGE_SHIFT;
267 nr_pages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
268
269 pgdata = NODE_DATA(spu->node);
270 zone = pgdata->node_zones;
271
272 ret = __add_pages(zone, start_pfn, nr_pages);
273
274out:
275 return ret;
276} 222}
277 223
278static int __init spu_map_device(struct spu *spu) 224static int __init spu_map_device(struct spu *spu)