brcm63xx: Fixed 96348GW (Tecom Gx00) LED definitions to match reality (vs reference...
[openwrt.git] / target / linux / brcm63xx / patches-2.6.32 / 180-udc_preliminary_support.patch
1 Index: linux-2.6.32.13/arch/mips/bcm63xx/boards/board_bcm963xx.c
2 ===================================================================
3 --- linux-2.6.32.13.orig/arch/mips/bcm63xx/boards/board_bcm963xx.c      2010-05-27 21:43:41.000000000 -0400
4 +++ linux-2.6.32.13/arch/mips/bcm63xx/boards/board_bcm963xx.c   2010-05-27 21:44:19.000000000 -0400
5 @@ -28,6 +28,7 @@
6  #include <bcm63xx_dev_pcmcia.h>
7  #include <bcm63xx_dev_usb_ohci.h>
8  #include <bcm63xx_dev_usb_ehci.h>
9 +#include <bcm63xx_dev_usb_udc.h>
10  #include <board_bcm963xx.h>
11  
12  #define PFX    "board_bcm963xx: "
13 @@ -390,6 +391,7 @@
14          .has_ohci0 = 1,
15          .has_pccard = 1,
16          .has_ehci0 = 1,
17 +       .has_udc0                       = 1,
18  };
19  
20  static struct board_info __initdata board_rta1025w_16 = {
21 @@ -934,6 +936,9 @@
22         if (board.has_dsp)
23                 bcm63xx_dsp_register(&board.dsp);
24  
25 +       if (board.has_udc0)
26 +               bcm63xx_udc_register();
27 +
28         /* Generate MAC address for WLAN and
29          * register our SPROM */
30  #ifdef CONFIG_SSB_PCIHOST
31 Index: linux-2.6.32.13/arch/mips/bcm63xx/dev-usb-udc.c
32 ===================================================================
33 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
34 +++ linux-2.6.32.13/arch/mips/bcm63xx/dev-usb-udc.c     2010-05-27 21:44:19.000000000 -0400
35 @@ -0,0 +1,58 @@
36 +/*
37 + * Copyright (C) 2009  Henk Vergonet <Henk.Vergonet@gmail.com>
38 + *
39 + * This program is free software; you can redistribute it and/or
40 + * modify it under the terms of the GNU General Public License as
41 + * published by the Free Software Foundation; either version 2 of
42 + * the License, or (at your option) any later version.
43 + *
44 + * This program is distributed in the hope that it will be useful,
45 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
46 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47 + * GNU General Public License for more details.
48 + *
49 + * You should have received a copy of the GNU General Public License
50 + * along with this program; if not, write to the Free Software
51 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
52 + */
53 +#include <linux/init.h>
54 +#include <linux/kernel.h>
55 +#include <linux/platform_device.h>
56 +#include <bcm63xx_cpu.h>
57 +
58 +static struct resource udc_resources[] = {
59 +       {
60 +               .start          = -1, /* filled at runtime */
61 +               .end            = -1, /* filled at runtime */
62 +               .flags          = IORESOURCE_MEM,
63 +       },
64 +       {
65 +               .start          = -1, /* filled at runtime */
66 +               .flags          = IORESOURCE_IRQ,
67 +       },
68 +};
69 +
70 +static u64 udc_dmamask = ~(u32)0;
71 +
72 +static struct platform_device bcm63xx_udc_device = {
73 +       .name           = "bcm63xx-udc",
74 +       .id             = 0,
75 +       .num_resources  = ARRAY_SIZE(udc_resources),
76 +       .resource       = udc_resources,
77 +       .dev            = {
78 +               .dma_mask               = &udc_dmamask,
79 +               .coherent_dma_mask      = 0xffffffff,
80 +       },
81 +};
82 +
83 +int __init bcm63xx_udc_register(void)
84 +{
85 +       if (!BCMCPU_IS_6338() && !BCMCPU_IS_6345() && !BCMCPU_IS_6348())
86 +               return 0;
87 +
88 +       udc_resources[0].start = bcm63xx_regset_address(RSET_UDC0);
89 +       udc_resources[0].end = udc_resources[0].start;
90 +       udc_resources[0].end += RSET_UDC_SIZE - 1;
91 +       udc_resources[1].start = bcm63xx_get_irq_number(IRQ_UDC0);
92 +       return platform_device_register(&bcm63xx_udc_device);
93 +}
94 Index: linux-2.6.32.13/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
95 ===================================================================
96 --- linux-2.6.32.13.orig/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h       2010-05-27 21:34:56.000000000 -0400
97 +++ linux-2.6.32.13/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h    2010-05-27 21:44:19.000000000 -0400
98 @@ -125,7 +125,7 @@
99  #define BCM_6338_UART0_BASE            (0xfffe0300)
100  #define BCM_6338_GPIO_BASE             (0xfffe0400)
101  #define BCM_6338_SPI_BASE              (0xfffe0c00)
102 -#define BCM_6338_UDC0_BASE             (0xdeadbeef)
103 +#define BCM_6338_UDC0_BASE             (0xfffe3000)
104  #define BCM_6338_USBDMA_BASE           (0xfffe2400)
105  #define BCM_6338_OHCI0_BASE            (0xdeadbeef)
106  #define BCM_6338_OHCI_PRIV_BASE                (0xfffe3000)
107 @@ -155,7 +155,7 @@
108  #define BCM_6345_UART0_BASE            (0xfffe0300)
109  #define BCM_6345_GPIO_BASE             (0xfffe0400)
110  #define BCM_6345_SPI_BASE              (0xdeadbeef)
111 -#define BCM_6345_UDC0_BASE             (0xdeadbeef)
112 +#define BCM_6345_UDC0_BASE             (0xfffe2100)
113  #define BCM_6345_USBDMA_BASE           (0xfffe2800)
114  #define BCM_6345_ENET0_BASE            (0xfffe1800)
115  #define BCM_6345_ENETDMA_BASE          (0xfffe2800)
116 @@ -210,7 +210,7 @@
117  #define BCM_6358_UART0_BASE            (0xfffe0100)
118  #define BCM_6358_GPIO_BASE             (0xfffe0080)
119  #define BCM_6358_SPI_BASE              (0xdeadbeef)
120 -#define BCM_6358_UDC0_BASE             (0xfffe0800)
121 +#define BCM_6358_UDC0_BASE             (0xfffe0400)
122  #define BCM_6358_OHCI0_BASE            (0xfffe1400)
123  #define BCM_6358_OHCI_PRIV_BASE                (0xdeadbeef)
124  #define BCM_6358_USBH_PRIV_BASE                (0xfffe1500)
125 @@ -430,6 +430,7 @@
126         IRQ_TIMER = 0,
127         IRQ_UART0,
128         IRQ_DSL,
129 +       IRQ_UDC0,
130         IRQ_ENET0,
131         IRQ_ENET1,
132         IRQ_ENET_PHY,
133 @@ -472,7 +473,7 @@
134  #define BCM_6345_UART0_IRQ             (IRQ_INTERNAL_BASE + 2)
135  #define BCM_6345_DSL_IRQ               (IRQ_INTERNAL_BASE + 3)
136  #define BCM_6345_ATM_IRQ               (IRQ_INTERNAL_BASE + 4)
137 -#define BCM_6345_USB_IRQ               (IRQ_INTERNAL_BASE + 5)
138 +#define BCM_6345_UDC0_IRQ              (IRQ_INTERNAL_BASE + 5)
139  #define BCM_6345_ENET0_IRQ             (IRQ_INTERNAL_BASE + 8)
140  #define BCM_6345_ENET_PHY_IRQ          (IRQ_INTERNAL_BASE + 12)
141  #define BCM_6345_ENET0_RXDMA_IRQ       (IRQ_INTERNAL_BASE + 13 + 1)
142 @@ -494,10 +495,17 @@
143  #define BCM_6348_TIMER_IRQ             (IRQ_INTERNAL_BASE + 0)
144  #define BCM_6348_UART0_IRQ             (IRQ_INTERNAL_BASE + 2)
145  #define BCM_6348_DSL_IRQ               (IRQ_INTERNAL_BASE + 4)
146 +#define BCM_6348_UDC0_IRQ              (IRQ_INTERNAL_BASE + 6)
147  #define BCM_6348_ENET1_IRQ             (IRQ_INTERNAL_BASE + 7)
148  #define BCM_6348_ENET0_IRQ             (IRQ_INTERNAL_BASE + 8)
149  #define BCM_6348_ENET_PHY_IRQ          (IRQ_INTERNAL_BASE + 9)
150  #define BCM_6348_OHCI0_IRQ             (IRQ_INTERNAL_BASE + 12)
151 +#define BCM_6348_USB_CNTL_RX_DMA_IRQ   (IRQ_INTERNAL_BASE + 14)
152 +#define BCM_6348_USB_CNTL_TX_DMA_IRQ   (IRQ_INTERNAL_BASE + 15)
153 +#define BCM_6348_USB_BULK_RX_DMA_IRQ   (IRQ_INTERNAL_BASE + 16)
154 +#define BCM_6348_USB_BULK_TX_DMA_IRQ   (IRQ_INTERNAL_BASE + 17)
155 +#define BCM_6348_USB_ISO_RX_DMA_IRQ    (IRQ_INTERNAL_BASE + 18)
156 +#define BCM_6348_USB_ISO_TX_DMA_IRQ    (IRQ_INTERNAL_BASE + 19)
157  #define BCM_6348_ENET0_RXDMA_IRQ       (IRQ_INTERNAL_BASE + 20)
158  #define BCM_6348_ENET0_TXDMA_IRQ       (IRQ_INTERNAL_BASE + 21)
159  #define BCM_6348_ENET1_RXDMA_IRQ       (IRQ_INTERNAL_BASE + 22)
160 Index: linux-2.6.32.13/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_udc.h
161 ===================================================================
162 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
163 +++ linux-2.6.32.13/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_udc.h    2010-05-27 21:44:19.000000000 -0400
164 @@ -0,0 +1,6 @@
165 +#ifndef BCM63XX_DEV_USB_UDC_H_
166 +#define BCM63XX_DEV_USB_UDC_H_
167 +
168 +int bcm63xx_udc_register(void);
169 +
170 +#endif /* BCM63XX_DEV_USB_UDC_H_ */
171 Index: linux-2.6.32.13/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
172 ===================================================================
173 --- linux-2.6.32.13.orig/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h    2010-05-27 21:42:10.000000000 -0400
174 +++ linux-2.6.32.13/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h 2010-05-27 21:44:19.000000000 -0400
175 @@ -45,6 +45,7 @@
176         unsigned int    has_ohci0:1;
177         unsigned int    has_ehci0:1;
178         unsigned int    has_dsp:1;
179 +       unsigned int    has_udc0:1;
180  
181         /* ethernet config */
182         struct bcm63xx_enet_platform_data enet0;
183 Index: linux-2.6.32.13/arch/mips/bcm63xx/Makefile
184 ===================================================================
185 --- linux-2.6.32.13.orig/arch/mips/bcm63xx/Makefile     2010-05-27 21:34:56.000000000 -0400
186 +++ linux-2.6.32.13/arch/mips/bcm63xx/Makefile  2010-05-27 21:44:19.000000000 -0400
187 @@ -1,6 +1,6 @@
188  obj-y          += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
189                    dev-dsp.o dev-enet.o dev-pcmcia.o dev-uart.o dev-wdt.o \
190 -                  dev-usb-ohci.o dev-usb-ehci.o
191 +                  dev-usb-ohci.o dev-usb-ehci.o dev-usb-udc.o
192  obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
193  
194  obj-y          += boards/
195 Index: linux-2.6.32.13/arch/mips/bcm63xx/clk.c
196 ===================================================================
197 --- linux-2.6.32.13.orig/arch/mips/bcm63xx/clk.c        2010-05-27 21:34:56.000000000 -0400
198 +++ linux-2.6.32.13/arch/mips/bcm63xx/clk.c     2010-05-27 21:44:19.000000000 -0400
199 @@ -141,6 +141,30 @@
200  };
201  
202  /*
203 + * USB slave clock
204 + */
205 +static void usbs_set(struct clk *clk, int enable)
206 +{
207 +       u32 mask;
208 +
209 +       switch(bcm63xx_get_cpu_id()) {
210 +       case BCM6338_CPU_ID:
211 +               mask = CKCTL_6338_USBS_EN;
212 +               break;
213 +       case BCM6348_CPU_ID:
214 +               mask = CKCTL_6348_USBS_EN;
215 +               break;
216 +       default:
217 +               return;
218 +       }
219 +       bcm_hwclock_set(mask, enable);
220 +}
221 +
222 +static struct clk clk_usbs = {
223 +       .set    = usbs_set,
224 +};
225 +
226 +/*
227   * SPI clock
228   */
229  static void spi_set(struct clk *clk, int enable)
230 @@ -208,6 +232,8 @@
231                 return &clk_ephy;
232         if (!strcmp(id, "usbh"))
233                 return &clk_usbh;
234 +       if (!strcmp(id, "usbs"))
235 +               return &clk_usbs;
236         if (!strcmp(id, "spi"))
237                 return &clk_spi;
238         if (!strcmp(id, "periph"))
239 Index: linux-2.6.32.13/arch/mips/bcm63xx/Kconfig
240 ===================================================================
241 --- linux-2.6.32.13.orig/arch/mips/bcm63xx/Kconfig      2010-05-27 21:34:56.000000000 -0400
242 +++ linux-2.6.32.13/arch/mips/bcm63xx/Kconfig   2010-05-27 21:44:19.000000000 -0400
243 @@ -7,6 +7,7 @@
244         select USB_ARCH_HAS_OHCI
245         select USB_OHCI_BIG_ENDIAN_DESC
246         select USB_OHCI_BIG_ENDIAN_MMIO
247 +       select USB_ARCH_HAS_UDC
248  
249  config BCM63XX_CPU_6345
250         bool "support 6345 CPU"
251 @@ -19,6 +20,7 @@
252         select USB_ARCH_HAS_OHCI
253         select USB_OHCI_BIG_ENDIAN_DESC
254         select USB_OHCI_BIG_ENDIAN_MMIO
255 +       select USB_ARCH_HAS_UDC
256  
257  config BCM63XX_CPU_6358
258         bool "support 6358 CPU"