diff options
Diffstat (limited to 'drivers/amba')
-rw-r--r-- | drivers/amba/bus.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 3d763fdf99b7..f60b2b6a0931 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c | |||
@@ -204,9 +204,20 @@ 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 | ||
211 | device_initialize(&dev->dev); | ||
212 | |||
213 | /* | ||
214 | * Copy from device_add | ||
215 | */ | ||
216 | if (dev->dev.init_name) { | ||
217 | dev_set_name(&dev->dev, "%s", dev->dev.init_name); | ||
218 | dev->dev.init_name = NULL; | ||
219 | } | ||
220 | |||
210 | dev->dev.release = amba_device_release; | 221 | dev->dev.release = amba_device_release; |
211 | dev->dev.bus = &amba_bustype; | 222 | dev->dev.bus = &amba_bustype; |
212 | dev->dev.dma_mask = &dev->dma_mask; | 223 | dev->dev.dma_mask = &dev->dma_mask; |
@@ -219,16 +230,25 @@ int amba_device_register(struct amba_device *dev, struct resource *parent) | |||
219 | if (ret) | 230 | if (ret) |
220 | goto err_out; | 231 | goto err_out; |
221 | 232 | ||
222 | 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); | ||
223 | if (!tmp) { | 239 | if (!tmp) { |
224 | ret = -ENOMEM; | 240 | ret = -ENOMEM; |
225 | goto err_release; | 241 | goto err_release; |
226 | } | 242 | } |
227 | 243 | ||
244 | /* | ||
245 | * Read pid and cid based on size of resource | ||
246 | * they are located at end of region | ||
247 | */ | ||
228 | for (pid = 0, i = 0; i < 4; i++) | 248 | for (pid = 0, i = 0; i < 4; i++) |
229 | pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8); | 249 | pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) << (i * 8); |
230 | for (cid = 0, i = 0; i < 4; i++) | 250 | for (cid = 0, i = 0; i < 4; i++) |
231 | cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8); | 251 | cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) << (i * 8); |
232 | 252 | ||
233 | iounmap(tmp); | 253 | iounmap(tmp); |
234 | 254 | ||
@@ -240,7 +260,7 @@ int amba_device_register(struct amba_device *dev, struct resource *parent) | |||
240 | goto err_release; | 260 | goto err_release; |
241 | } | 261 | } |
242 | 262 | ||
243 | ret = device_register(&dev->dev); | 263 | ret = device_add(&dev->dev); |
244 | if (ret) | 264 | if (ret) |
245 | goto err_release; | 265 | goto err_release; |
246 | 266 | ||
@@ -343,11 +363,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) | 363 | int amba_request_regions(struct amba_device *dev, const char *name) |
344 | { | 364 | { |
345 | int ret = 0; | 365 | int ret = 0; |
366 | u32 size; | ||
346 | 367 | ||
347 | if (!name) | 368 | if (!name) |
348 | name = dev->dev.driver->name; | 369 | name = dev->dev.driver->name; |
349 | 370 | ||
350 | 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)) | ||
351 | ret = -EBUSY; | 374 | ret = -EBUSY; |
352 | 375 | ||
353 | return ret; | 376 | return ret; |
@@ -361,7 +384,10 @@ int amba_request_regions(struct amba_device *dev, const char *name) | |||
361 | */ | 384 | */ |
362 | void amba_release_regions(struct amba_device *dev) | 385 | void amba_release_regions(struct amba_device *dev) |
363 | { | 386 | { |
364 | 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); | ||
365 | } | 391 | } |
366 | 392 | ||
367 | EXPORT_SYMBOL(amba_driver_register); | 393 | EXPORT_SYMBOL(amba_driver_register); |