diff options
-rw-r--r-- | drivers/amba/bus.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 3d763fdf99b7..768d973d0ded 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c | |||
@@ -204,6 +204,7 @@ static void amba_device_release(struct device *dev) | |||
204 | int amba_device_register(struct amba_device *dev, struct resource *parent) | 204 | int 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 | ||
@@ -219,16 +220,25 @@ int amba_device_register(struct amba_device *dev, struct resource *parent) | |||
219 | if (ret) | 220 | if (ret) |
220 | goto err_out; | 221 | goto err_out; |
221 | 222 | ||
222 | tmp = ioremap(dev->res.start, SZ_4K); | 223 | /* |
224 | * Dynamically calculate the size of the resource | ||
225 | * and use this for iomap | ||
226 | */ | ||
227 | size = resource_size(&dev->res); | ||
228 | tmp = ioremap(dev->res.start, size); | ||
223 | if (!tmp) { | 229 | if (!tmp) { |
224 | ret = -ENOMEM; | 230 | ret = -ENOMEM; |
225 | goto err_release; | 231 | goto err_release; |
226 | } | 232 | } |
227 | 233 | ||
234 | /* | ||
235 | * Read pid and cid based on size of resource | ||
236 | * they are located at end of region | ||
237 | */ | ||
228 | for (pid = 0, i = 0; i < 4; i++) | 238 | for (pid = 0, i = 0; i < 4; i++) |
229 | pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8); | 239 | pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) << (i * 8); |
230 | for (cid = 0, i = 0; i < 4; i++) | 240 | for (cid = 0, i = 0; i < 4; i++) |
231 | cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8); | 241 | cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) << (i * 8); |
232 | 242 | ||
233 | iounmap(tmp); | 243 | iounmap(tmp); |
234 | 244 | ||
@@ -343,11 +353,14 @@ amba_find_device(const char *busid, struct device *parent, unsigned int id, | |||
343 | int amba_request_regions(struct amba_device *dev, const char *name) | 353 | int amba_request_regions(struct amba_device *dev, const char *name) |
344 | { | 354 | { |
345 | int ret = 0; | 355 | int ret = 0; |
356 | u32 size; | ||
346 | 357 | ||
347 | if (!name) | 358 | if (!name) |
348 | name = dev->dev.driver->name; | 359 | name = dev->dev.driver->name; |
349 | 360 | ||
350 | if (!request_mem_region(dev->res.start, SZ_4K, name)) | 361 | size = resource_size(&dev->res); |
362 | |||
363 | if (!request_mem_region(dev->res.start, size, name)) | ||
351 | ret = -EBUSY; | 364 | ret = -EBUSY; |
352 | 365 | ||
353 | return ret; | 366 | return ret; |
@@ -361,7 +374,10 @@ int amba_request_regions(struct amba_device *dev, const char *name) | |||
361 | */ | 374 | */ |
362 | void amba_release_regions(struct amba_device *dev) | 375 | void amba_release_regions(struct amba_device *dev) |
363 | { | 376 | { |
364 | release_mem_region(dev->res.start, SZ_4K); | 377 | u32 size; |
378 | |||
379 | size = resource_size(&dev->res); | ||
380 | release_mem_region(dev->res.start, size); | ||
365 | } | 381 | } |
366 | 382 | ||
367 | EXPORT_SYMBOL(amba_driver_register); | 383 | EXPORT_SYMBOL(amba_driver_register); |