diff options
author | Kevin Cernekee <cernekee@gmail.com> | 2012-07-14 14:01:09 -0400 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2012-08-30 14:15:52 -0400 |
commit | 22df90f6bb687db58298084a200782dd0148d247 (patch) | |
tree | d344148a22e2959f922395e337f5b72c72aa4093 /arch/mips/bcm63xx/dev-usb-usbd.c | |
parent | 5fd66c2b2b7ce5cfc660cc75abbb3bf248ba3e9b (diff) |
MIPS: BCM63XX: Create platform_device for USBD
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Patchwork: http://patchwork.linux-mips.org/patch/4111/
Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'arch/mips/bcm63xx/dev-usb-usbd.c')
-rw-r--r-- | arch/mips/bcm63xx/dev-usb-usbd.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/mips/bcm63xx/dev-usb-usbd.c b/arch/mips/bcm63xx/dev-usb-usbd.c new file mode 100644 index 000000000000..508bd9d8df27 --- /dev/null +++ b/arch/mips/bcm63xx/dev-usb-usbd.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> | ||
7 | * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com> | ||
8 | * Copyright (C) 2012 Broadcom Corporation | ||
9 | */ | ||
10 | |||
11 | #include <linux/init.h> | ||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/dma-mapping.h> | ||
15 | #include <bcm63xx_cpu.h> | ||
16 | #include <bcm63xx_dev_usb_usbd.h> | ||
17 | |||
18 | #define NUM_MMIO 2 | ||
19 | #define NUM_IRQ 7 | ||
20 | |||
21 | static struct resource usbd_resources[NUM_MMIO + NUM_IRQ]; | ||
22 | |||
23 | static u64 usbd_dmamask = DMA_BIT_MASK(32); | ||
24 | |||
25 | static struct platform_device bcm63xx_usbd_device = { | ||
26 | .name = "bcm63xx_udc", | ||
27 | .id = -1, | ||
28 | .num_resources = ARRAY_SIZE(usbd_resources), | ||
29 | .resource = usbd_resources, | ||
30 | .dev = { | ||
31 | .dma_mask = &usbd_dmamask, | ||
32 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
33 | }, | ||
34 | }; | ||
35 | |||
36 | int __init bcm63xx_usbd_register(const struct bcm63xx_usbd_platform_data *pd) | ||
37 | { | ||
38 | const int irq_list[NUM_IRQ] = { IRQ_USBD, | ||
39 | IRQ_USBD_RXDMA0, IRQ_USBD_TXDMA0, | ||
40 | IRQ_USBD_RXDMA1, IRQ_USBD_TXDMA1, | ||
41 | IRQ_USBD_RXDMA2, IRQ_USBD_TXDMA2 }; | ||
42 | int i; | ||
43 | |||
44 | if (!BCMCPU_IS_6328() && !BCMCPU_IS_6368()) | ||
45 | return 0; | ||
46 | |||
47 | usbd_resources[0].start = bcm63xx_regset_address(RSET_USBD); | ||
48 | usbd_resources[0].end = usbd_resources[0].start + RSET_USBD_SIZE - 1; | ||
49 | usbd_resources[0].flags = IORESOURCE_MEM; | ||
50 | |||
51 | usbd_resources[1].start = bcm63xx_regset_address(RSET_USBDMA); | ||
52 | usbd_resources[1].end = usbd_resources[1].start + RSET_USBDMA_SIZE - 1; | ||
53 | usbd_resources[1].flags = IORESOURCE_MEM; | ||
54 | |||
55 | for (i = 0; i < NUM_IRQ; i++) { | ||
56 | struct resource *r = &usbd_resources[NUM_MMIO + i]; | ||
57 | |||
58 | r->start = r->end = bcm63xx_get_irq_number(irq_list[i]); | ||
59 | r->flags = IORESOURCE_IRQ; | ||
60 | } | ||
61 | |||
62 | platform_device_add_data(&bcm63xx_usbd_device, pd, sizeof(*pd)); | ||
63 | |||
64 | return platform_device_register(&bcm63xx_usbd_device); | ||
65 | } | ||