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 | |
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>
-rw-r--r-- | arch/mips/bcm63xx/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/bcm63xx/boards/board_bcm963xx.c | 10 | ||||
-rw-r--r-- | arch/mips/bcm63xx/dev-usb-usbd.c | 65 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_usbd.h | 17 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h | 5 |
5 files changed, 98 insertions, 1 deletions
diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile index 833af72c852a..9bbb30a9dc20 100644 --- a/arch/mips/bcm63xx/Makefile +++ b/arch/mips/bcm63xx/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | obj-y += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \ | 1 | obj-y += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \ |
2 | dev-dsp.o dev-enet.o dev-flash.o dev-pcmcia.o dev-rng.o \ | 2 | dev-dsp.o dev-enet.o dev-flash.o dev-pcmcia.o dev-rng.o \ |
3 | dev-spi.o dev-uart.o dev-wdt.o | 3 | dev-spi.o dev-uart.o dev-wdt.o dev-usb-usbd.o |
4 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | 4 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
5 | 5 | ||
6 | obj-y += boards/ | 6 | obj-y += boards/ |
diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c index feb05258a4d1..ea4ea77c6297 100644 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <bcm63xx_dev_flash.h> | 24 | #include <bcm63xx_dev_flash.h> |
25 | #include <bcm63xx_dev_pcmcia.h> | 25 | #include <bcm63xx_dev_pcmcia.h> |
26 | #include <bcm63xx_dev_spi.h> | 26 | #include <bcm63xx_dev_spi.h> |
27 | #include <bcm63xx_dev_usb_usbd.h> | ||
27 | #include <board_bcm963xx.h> | 28 | #include <board_bcm963xx.h> |
28 | 29 | ||
29 | #define PFX "board_bcm963xx: " | 30 | #define PFX "board_bcm963xx: " |
@@ -42,6 +43,12 @@ static struct board_info __initdata board_96328avng = { | |||
42 | 43 | ||
43 | .has_uart0 = 1, | 44 | .has_uart0 = 1, |
44 | .has_pci = 1, | 45 | .has_pci = 1, |
46 | .has_usbd = 0, | ||
47 | |||
48 | .usbd = { | ||
49 | .use_fullspeed = 0, | ||
50 | .port_no = 0, | ||
51 | }, | ||
45 | 52 | ||
46 | .leds = { | 53 | .leds = { |
47 | { | 54 | { |
@@ -888,6 +895,9 @@ int __init board_register_devices(void) | |||
888 | !board_get_mac_address(board.enet1.mac_addr)) | 895 | !board_get_mac_address(board.enet1.mac_addr)) |
889 | bcm63xx_enet_register(1, &board.enet1); | 896 | bcm63xx_enet_register(1, &board.enet1); |
890 | 897 | ||
898 | if (board.has_usbd) | ||
899 | bcm63xx_usbd_register(&board.usbd); | ||
900 | |||
891 | if (board.has_dsp) | 901 | if (board.has_dsp) |
892 | bcm63xx_dsp_register(&board.dsp); | 902 | bcm63xx_dsp_register(&board.dsp); |
893 | 903 | ||
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 | } | ||
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_usbd.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_usbd.h new file mode 100644 index 000000000000..5d6d6986f40b --- /dev/null +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_usbd.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef BCM63XX_DEV_USB_USBD_H_ | ||
2 | #define BCM63XX_DEV_USB_USBD_H_ | ||
3 | |||
4 | /* | ||
5 | * usb device platform data | ||
6 | */ | ||
7 | struct bcm63xx_usbd_platform_data { | ||
8 | /* board can only support full speed (USB 1.1) */ | ||
9 | int use_fullspeed; | ||
10 | |||
11 | /* 0-based port index, for chips with >1 USB PHY */ | ||
12 | int port_no; | ||
13 | }; | ||
14 | |||
15 | int bcm63xx_usbd_register(const struct bcm63xx_usbd_platform_data *pd); | ||
16 | |||
17 | #endif /* BCM63XX_DEV_USB_USBD_H_ */ | ||
diff --git a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h index 474daaa53497..b0dd4bb53f7e 100644 --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/gpio.h> | 5 | #include <linux/gpio.h> |
6 | #include <linux/leds.h> | 6 | #include <linux/leds.h> |
7 | #include <bcm63xx_dev_enet.h> | 7 | #include <bcm63xx_dev_enet.h> |
8 | #include <bcm63xx_dev_usb_usbd.h> | ||
8 | #include <bcm63xx_dev_dsp.h> | 9 | #include <bcm63xx_dev_dsp.h> |
9 | 10 | ||
10 | /* | 11 | /* |
@@ -44,6 +45,7 @@ struct board_info { | |||
44 | unsigned int has_pccard:1; | 45 | unsigned int has_pccard:1; |
45 | unsigned int has_ohci0:1; | 46 | unsigned int has_ohci0:1; |
46 | unsigned int has_ehci0:1; | 47 | unsigned int has_ehci0:1; |
48 | unsigned int has_usbd:1; | ||
47 | unsigned int has_dsp:1; | 49 | unsigned int has_dsp:1; |
48 | unsigned int has_uart0:1; | 50 | unsigned int has_uart0:1; |
49 | unsigned int has_uart1:1; | 51 | unsigned int has_uart1:1; |
@@ -52,6 +54,9 @@ struct board_info { | |||
52 | struct bcm63xx_enet_platform_data enet0; | 54 | struct bcm63xx_enet_platform_data enet0; |
53 | struct bcm63xx_enet_platform_data enet1; | 55 | struct bcm63xx_enet_platform_data enet1; |
54 | 56 | ||
57 | /* USB config */ | ||
58 | struct bcm63xx_usbd_platform_data usbd; | ||
59 | |||
55 | /* DSP config */ | 60 | /* DSP config */ |
56 | struct bcm63xx_dsp_platform_data dsp; | 61 | struct bcm63xx_dsp_platform_data dsp; |
57 | 62 | ||