aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/amba
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/amba')
-rw-r--r--drivers/amba/bus.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 246650673010..f60b2b6a0931 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -204,6 +204,7 @@ static void amba_device_release(struct device *dev)
204int amba_device_register(struct amba_device *dev, struct resource *parent) 204int amba_device_register(struct amba_device *dev, struct resource *parent)
205{ 205{
206 u32 pid, cid; 206 u32 pid, cid;
207 u32 size;
207 void __iomem *tmp; 208 void __iomem *tmp;
208 int i, ret; 209 int i, ret;
209 210
@@ -229,16 +230,25 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
229 if (ret) 230 if (ret)
230 goto err_out; 231 goto err_out;
231 232
232 tmp = ioremap(dev->res.start, SZ_4K); 233 /*
234 * Dynamically calculate the size of the resource
235 * and use this for iomap
236 */
237 size = resource_size(&dev->res);
238 tmp = ioremap(dev->res.start, size);
233 if (!tmp) { 239 if (!tmp) {
234 ret = -ENOMEM; 240 ret = -ENOMEM;
235 goto err_release; 241 goto err_release;
236 } 242 }
237 243
244 /*
245 * Read pid and cid based on size of resource
246 * they are located at end of region
247 */
238 for (pid = 0, i = 0; i < 4; i++) 248 for (pid = 0, i = 0; i < 4; i++)
239 pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8); 249 pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) << (i * 8);
240 for (cid = 0, i = 0; i < 4; i++) 250 for (cid = 0, i = 0; i < 4; i++)
241 cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8); 251 cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) << (i * 8);
242 252
243 iounmap(tmp); 253 iounmap(tmp);
244 254
@@ -353,11 +363,14 @@ amba_find_device(const char *busid, struct device *parent, unsigned int id,
353int amba_request_regions(struct amba_device *dev, const char *name) 363int amba_request_regions(struct amba_device *dev, const char *name)
354{ 364{
355 int ret = 0; 365 int ret = 0;
366 u32 size;
356 367
357 if (!name) 368 if (!name)
358 name = dev->dev.driver->name; 369 name = dev->dev.driver->name;
359 370
360 if (!request_mem_region(dev->res.start, SZ_4K, name)) 371 size = resource_size(&dev->res);
372
373 if (!request_mem_region(dev->res.start, size, name))
361 ret = -EBUSY; 374 ret = -EBUSY;
362 375
363 return ret; 376 return ret;
@@ -371,7 +384,10 @@ int amba_request_regions(struct amba_device *dev, const char *name)
371 */ 384 */
372void amba_release_regions(struct amba_device *dev) 385void amba_release_regions(struct amba_device *dev)
373{ 386{
374 release_mem_region(dev->res.start, SZ_4K); 387 u32 size;
388
389 size = resource_size(&dev->res);
390 release_mem_region(dev->res.start, size);
375} 391}
376 392
377EXPORT_SYMBOL(amba_driver_register); 393EXPORT_SYMBOL(amba_driver_register);