]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/arm/mach-mmp/devices.c
2 * linux/arch/arm/mach-mmp/devices.c
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 #include <linux/init.h>
10 #include <linux/platform_device.h>
11 #include <linux/dma-mapping.h>
14 #include <mach/devices.h>
16 int __init
pxa_register_device(struct pxa_device_desc
*desc
,
17 void *data
, size_t size
)
19 struct platform_device
*pdev
;
20 struct resource res
[2 + MAX_RESOURCE_DMA
];
21 int i
, ret
= 0, nres
= 0;
23 pdev
= platform_device_alloc(desc
->drv_name
, desc
->id
);
27 pdev
->dev
.coherent_dma_mask
= DMA_BIT_MASK(32);
29 memset(res
, 0, sizeof(res
));
31 if (desc
->start
!= -1ul && desc
->size
> 0) {
32 res
[nres
].start
= desc
->start
;
33 res
[nres
].end
= desc
->start
+ desc
->size
- 1;
34 res
[nres
].flags
= IORESOURCE_MEM
;
38 if (desc
->irq
!= NO_IRQ
) {
39 res
[nres
].start
= desc
->irq
;
40 res
[nres
].end
= desc
->irq
;
41 res
[nres
].flags
= IORESOURCE_IRQ
;
45 for (i
= 0; i
< MAX_RESOURCE_DMA
; i
++, nres
++) {
46 if (desc
->dma
[i
] == 0)
49 res
[nres
].start
= desc
->dma
[i
];
50 res
[nres
].end
= desc
->dma
[i
];
51 res
[nres
].flags
= IORESOURCE_DMA
;
54 ret
= platform_device_add_resources(pdev
, res
, nres
);
56 platform_device_put(pdev
);
61 ret
= platform_device_add_data(pdev
, data
, size
);
63 platform_device_put(pdev
);
68 return platform_device_add(pdev
);