diff options
author | Leo Chen <leochen@broadcom.com> | 2009-07-28 18:34:59 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-09-02 06:21:15 -0400 |
commit | 8afe0b96b36bb967a00658003736ffa97967ee80 (patch) | |
tree | 301b831fe01a7c2e557f1c725f7b9e20e98e78ed /drivers/amba/bus.c | |
parent | 98b0979f025e5b98ce8f24e6dc0f9713e6f6c88c (diff) |
ARM: 5625/1: fix hard coded 4K resource size in amba bus detection
This patch modifies the amba bus detection logic in the kernel
to detect the AMBA devices using the calculated resource
size information rather than the hard coded 4K size.
It also calculates the resource size when request mem region
and release mem region.
Signed-off-by: Leo Chen <leochen@broadcom.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/amba/bus.c')
-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); |