[brcm63xx] fix SPI register switch and prepare for UDC, thanks to Henk Vergonet ...
[openwrt.git] / target / linux / brcm63xx / files / arch / mips / bcm63xx / dev-usb-udc.c
1 /*
2  * Copyright (C) 2009   Henk Vergonet <Henk.Vergonet@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 #include <linux/init.h>
19 #include <linux/kernel.h>
20 #include <linux/platform_device.h>
21 #include <bcm63xx_cpu.h>
22
23 static struct resource udc_resources[] = {
24         {
25                 .start          = -1, /* filled at runtime */
26                 .end            = -1, /* filled at runtime */
27                 .flags          = IORESOURCE_MEM,
28         },
29         {
30                 .start          = -1, /* filled at runtime */
31                 .flags          = IORESOURCE_IRQ,
32         },
33 };
34
35 static u64 udc_dmamask = ~(u32)0;
36
37 static struct platform_device bcm63xx_udc_device = {
38         .name           = "bcm63xx-udc",
39         .id             = 0,
40         .num_resources  = ARRAY_SIZE(udc_resources),
41         .resource       = udc_resources,
42         .dev            = {
43                 .dma_mask               = &udc_dmamask,
44                 .coherent_dma_mask      = 0xffffffff,
45         },
46 };
47
48 int __init bcm63xx_udc_register(void)
49 {
50         if (!BCMCPU_IS_6338() && !BCMCPU_IS_6348())
51                 return 0;
52
53         udc_resources[0].start = bcm63xx_regset_address(RSET_UDC0);
54         udc_resources[0].end = udc_resources[0].start;
55         udc_resources[0].end += RSET_UDC_SIZE - 1;
56         udc_resources[1].start = bcm63xx_get_irq_number(IRQ_UDC0);
57         return platform_device_register(&bcm63xx_udc_device);
58 }