aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/amba/bus.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2012-04-03 06:58:42 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-04-19 14:31:33 -0400
commit6026aa907b16677d32593c5b7dea134380f51f7f (patch)
tree89506b4f6d409e498886410bbf4f8518fb6a1d63 /drivers/amba/bus.c
parente816b57a337ea3b755de72bec38c10c864f23015 (diff)
ARM: 7369/1: amba: add functions to add devices dynamically
Add two functions to add APB and AHB devices to the amba (PrimeCell) bus dynamically. This is modeled after the static definition macros recently introduced into <linux/amba/bus.h> and can help us in factoring out a bunch of code across the kernel. Since a lot of call sites seem to be using a returned struct amba device* pointer, let's use that. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/amba/bus.c')
-rw-r--r--drivers/amba/bus.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index cc273226dbd0..9469d8722038 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -543,6 +543,55 @@ int amba_device_add(struct amba_device *dev, struct resource *parent)
543} 543}
544EXPORT_SYMBOL_GPL(amba_device_add); 544EXPORT_SYMBOL_GPL(amba_device_add);
545 545
546static struct amba_device *
547amba_aphb_device_add(struct device *parent, const char *name,
548 resource_size_t base, size_t size, int irq1, int irq2,
549 void *pdata, unsigned int periphid, u64 dma_mask)
550{
551 struct amba_device *dev;
552 int ret;
553
554 dev = amba_device_alloc(name, base, size);
555 if (!dev)
556 return ERR_PTR(-ENOMEM);
557
558 dev->dma_mask = dma_mask;
559 dev->dev.coherent_dma_mask = dma_mask;
560 dev->irq[0] = irq1;
561 dev->irq[1] = irq2;
562 dev->periphid = periphid;
563 dev->dev.platform_data = pdata;
564 dev->dev.parent = parent;
565
566 ret = amba_device_add(dev, &iomem_resource);
567 if (ret) {
568 amba_device_put(dev);
569 return ERR_PTR(ret);
570 }
571
572 return dev;
573}
574
575struct amba_device *
576amba_apb_device_add(struct device *parent, const char *name,
577 resource_size_t base, size_t size, int irq1, int irq2,
578 void *pdata, unsigned int periphid)
579{
580 return amba_aphb_device_add(parent, name, base, size, irq1, irq2, pdata,
581 periphid, 0);
582}
583EXPORT_SYMBOL_GPL(amba_apb_device_add);
584
585struct amba_device *
586amba_ahb_device_add(struct device *parent, const char *name,
587 resource_size_t base, size_t size, int irq1, int irq2,
588 void *pdata, unsigned int periphid)
589{
590 return amba_aphb_device_add(parent, name, base, size, irq1, irq2, pdata,
591 periphid, ~0ULL);
592}
593EXPORT_SYMBOL_GPL(amba_ahb_device_add);
594
546static void amba_device_initialize(struct amba_device *dev, const char *name) 595static void amba_device_initialize(struct amba_device *dev, const char *name)
547{ 596{
548 device_initialize(&dev->dev); 597 device_initialize(&dev->dev);