[brcm63xx] do not register devices in device_initcall level, this breaks the SSB...
[openwrt.git] / target / linux / brcm63xx / patches-2.6.32 / 007-usb-ohci-support.patch
1 The bcm63xx SOC has an integrated OHCI controller, this patch adds
2 platform device registration and change board code to register ohci
3 device when necessary.
4
5 Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
6 ---
7  arch/mips/bcm63xx/Kconfig                          |    6 ++
8  arch/mips/bcm63xx/Makefile                         |    3 +-
9  arch/mips/bcm63xx/boards/board_bcm963xx.c          |    4 ++
10  arch/mips/bcm63xx/dev-usb-ohci.c                   |   49 ++++++++++++++++++++
11  .../asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h        |    6 ++
12  5 files changed, 67 insertions(+), 1 deletions(-)
13  create mode 100644 arch/mips/bcm63xx/dev-usb-ohci.c
14  create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h
15
16 diff --git a/arch/mips/bcm63xx/Kconfig b/arch/mips/bcm63xx/Kconfig
17 index fb177d6..76fbbf7 100644
18 --- a/arch/mips/bcm63xx/Kconfig
19 +++ b/arch/mips/bcm63xx/Kconfig
20 @@ -16,10 +16,16 @@ config BCM63XX_CPU_6345
21  config BCM63XX_CPU_6348
22         bool "support 6348 CPU"
23         select HW_HAS_PCI
24 +       select USB_ARCH_HAS_OHCI
25 +       select USB_OHCI_BIG_ENDIAN_DESC
26 +       select USB_OHCI_BIG_ENDIAN_MMIO
27  
28  config BCM63XX_CPU_6358
29         bool "support 6358 CPU"
30         select HW_HAS_PCI
31 +       select USB_ARCH_HAS_OHCI
32 +       select USB_OHCI_BIG_ENDIAN_DESC
33 +       select USB_OHCI_BIG_ENDIAN_MMIO
34  endmenu
35  
36  source "arch/mips/bcm63xx/boards/Kconfig"
37 diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile
38 index 00064b6..be5d7ad 100644
39 --- a/arch/mips/bcm63xx/Makefile
40 +++ b/arch/mips/bcm63xx/Makefile
41 @@ -1,5 +1,6 @@
42  obj-y          += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
43 -                  dev-dsp.o dev-enet.o dev-pcmcia.o dev-uart.o dev-wdt.o
44 +                  dev-dsp.o dev-enet.o dev-pcmcia.o dev-uart.o dev-wdt.o \
45 +                  dev-usb-ohci.o
46  obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
47  
48  obj-y          += boards/
49 diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
50 index ea17941..e2c0c36 100644
51 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
52 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
53 @@ -24,6 +24,7 @@
54  #include <bcm63xx_dev_enet.h>
55  #include <bcm63xx_dev_dsp.h>
56  #include <bcm63xx_dev_pcmcia.h>
57 +#include <bcm63xx_dev_usb_ohci.h>
58  #include <board_bcm963xx.h>
59  
60  #define PFX    "board_bcm963xx: "
61 @@ -803,6 +804,9 @@ int __init board_register_devices(void)
62             !board_get_mac_address(board.enet1.mac_addr))
63                 bcm63xx_enet_register(1, &board.enet1);
64  
65 +       if (board.has_ohci0)
66 +               bcm63xx_ohci_register();
67 +
68         if (board.has_dsp)
69                 bcm63xx_dsp_register(&board.dsp);
70  
71 diff --git a/arch/mips/bcm63xx/dev-usb-ohci.c b/arch/mips/bcm63xx/dev-usb-ohci.c
72 new file mode 100644
73 index 0000000..f1fb442
74 --- /dev/null
75 +++ b/arch/mips/bcm63xx/dev-usb-ohci.c
76 @@ -0,0 +1,49 @@
77 +/*
78 + * This file is subject to the terms and conditions of the GNU General Public
79 + * License.  See the file "COPYING" in the main directory of this archive
80 + * for more details.
81 + *
82 + * Copyright (C) 2010 Maxime Bizon <mbizon@freebox.fr>
83 + */
84 +
85 +#include <linux/init.h>
86 +#include <linux/kernel.h>
87 +#include <linux/platform_device.h>
88 +#include <bcm63xx_cpu.h>
89 +#include <bcm63xx_dev_usb_ohci.h>
90 +
91 +static struct resource ohci_resources[] = {
92 +       {
93 +               /* start & end filled at runtime */
94 +               .flags          = IORESOURCE_MEM,
95 +       },
96 +       {
97 +               /* start filled at runtime */
98 +               .flags          = IORESOURCE_IRQ,
99 +       },
100 +};
101 +
102 +static u64 ohci_dmamask = ~(u32)0;
103 +
104 +static struct platform_device bcm63xx_ohci_device = {
105 +       .name           = "bcm63xx_ohci",
106 +       .id             = 0,
107 +       .num_resources  = ARRAY_SIZE(ohci_resources),
108 +       .resource       = ohci_resources,
109 +       .dev            = {
110 +               .dma_mask               = &ohci_dmamask,
111 +               .coherent_dma_mask      = 0xffffffff,
112 +       },
113 +};
114 +
115 +int __init bcm63xx_ohci_register(void)
116 +{
117 +       if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358())
118 +               return 0;
119 +
120 +       ohci_resources[0].start = bcm63xx_regset_address(RSET_OHCI0);
121 +       ohci_resources[0].end = ohci_resources[0].start;
122 +       ohci_resources[0].end += RSET_OHCI_SIZE - 1;
123 +       ohci_resources[1].start = bcm63xx_get_irq_number(IRQ_OHCI0);
124 +       return platform_device_register(&bcm63xx_ohci_device);
125 +}
126 diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h
127 new file mode 100644
128 index 0000000..518a04d
129 --- /dev/null
130 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h
131 @@ -0,0 +1,6 @@
132 +#ifndef BCM63XX_DEV_USB_OHCI_H_
133 +#define BCM63XX_DEV_USB_OHCI_H_
134 +
135 +int bcm63xx_ohci_register(void);
136 +
137 +#endif /* BCM63XX_DEV_USB_OHCI_H_ */
138 -- 
139 1.6.3.3
140
141