base-files: diag does not need to insmod any drivers, procd already did it for us
[openwrt.git] / target / linux / brcm63xx / patches-3.9 / 108-MIPS-BCM63XX-add-support-for-the-on-chip-EHCI-contro.patch
1 From e38f13bd6408769c0b565bb1079024f496eee121 Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <florian@openwrt.org>
3 Date: Mon, 28 Jan 2013 20:06:27 +0100
4 Subject: [PATCH 09/11] MIPS: BCM63XX: add support for the on-chip EHCI
5  controller
6
7 Broadcom BCM63XX SoCs include an on-chip EHCI controller which can be
8 driven by the generic ehci-platform driver by using specific power
9 on/off/suspend callbacks to manage clocks and hardware specific
10 configuration.
11
12 Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
13 Signed-off-by: Florian Fainelli <florian@openwrt.org>
14 ---
15  arch/mips/bcm63xx/Makefile                         |    2 +-
16  arch/mips/bcm63xx/dev-usb-ehci.c                   |   92 ++++++++++++++++++++
17  .../asm/mach-bcm63xx/bcm63xx_dev_usb_ehci.h        |    6 ++
18  3 files changed, 99 insertions(+), 1 deletion(-)
19  create mode 100644 arch/mips/bcm63xx/dev-usb-ehci.c
20  create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ehci.h
21
22 --- a/arch/mips/bcm63xx/Makefile
23 +++ b/arch/mips/bcm63xx/Makefile
24 @@ -1,7 +1,7 @@
25  obj-y          += clk.o cpu.o cs.o gpio.o irq.o nvram.o prom.o reset.o \
26                    setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \
27                    dev-pcmcia.o dev-rng.o dev-spi.o dev-uart.o dev-wdt.o \
28 -                  dev-usb-ohci.o dev-usb-usbd.o usb-common.o
29 +                  dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o usb-common.o
30  obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
31  
32  obj-y          += boards/
33 --- /dev/null
34 +++ b/arch/mips/bcm63xx/dev-usb-ehci.c
35 @@ -0,0 +1,92 @@
36 +/*
37 + * This file is subject to the terms and conditions of the GNU General Public
38 + * License.  See the file "COPYING" in the main directory of this archive
39 + * for more details.
40 + *
41 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
42 + * Copyright (C) 2013 Florian Fainelli <florian@openwrt.org>
43 + */
44 +
45 +#include <linux/init.h>
46 +#include <linux/kernel.h>
47 +#include <linux/platform_device.h>
48 +#include <linux/clk.h>
49 +#include <linux/delay.h>
50 +#include <linux/usb/ehci_pdriver.h>
51 +#include <linux/dma-mapping.h>
52 +
53 +#include <bcm63xx_cpu.h>
54 +#include <bcm63xx_regs.h>
55 +#include <bcm63xx_io.h>
56 +#include <bcm63xx_usb_priv.h>
57 +#include <bcm63xx_dev_usb_ehci.h>
58 +
59 +static struct resource ehci_resources[] = {
60 +       {
61 +               .start          = -1, /* filled at runtime */
62 +               .end            = -1, /* filled at runtime */
63 +               .flags          = IORESOURCE_MEM,
64 +       },
65 +       {
66 +               .start          = -1, /* filled at runtime */
67 +               .flags          = IORESOURCE_IRQ,
68 +       },
69 +};
70 +
71 +static u64 ehci_dmamask = DMA_BIT_MASK(32);
72 +
73 +static struct clk *usb_host_clock;
74 +
75 +static int bcm63xx_ehci_power_on(struct platform_device *pdev)
76 +{
77 +       usb_host_clock = clk_get(&pdev->dev, "usbh");
78 +       if (IS_ERR_OR_NULL(usb_host_clock))
79 +               return -ENODEV;
80 +
81 +       clk_prepare_enable(usb_host_clock);
82 +
83 +       bcm63xx_usb_priv_ehci_cfg_set();
84 +
85 +       return 0;
86 +}
87 +
88 +static void bcm63xx_ehci_power_off(struct platform_device *pdev)
89 +{
90 +       if (!IS_ERR_OR_NULL(usb_host_clock)) {
91 +               clk_disable_unprepare(usb_host_clock);
92 +               clk_put(usb_host_clock);
93 +       }
94 +}
95 +
96 +static struct usb_ehci_pdata bcm63xx_ehci_pdata = {
97 +       .big_endian_desc        = 1,
98 +       .big_endian_mmio        = 1,
99 +       .power_on               = bcm63xx_ehci_power_on,
100 +       .power_off              = bcm63xx_ehci_power_off,
101 +       .power_suspend          = bcm63xx_ehci_power_off,
102 +};
103 +
104 +static struct platform_device bcm63xx_ehci_device = {
105 +       .name           = "ehci-platform",
106 +       .id             = -1,
107 +       .num_resources  = ARRAY_SIZE(ehci_resources),
108 +       .resource       = ehci_resources,
109 +       .dev            = {
110 +               .platform_data          = &bcm63xx_ehci_pdata,
111 +               .dma_mask               = &ehci_dmamask,
112 +               .coherent_dma_mask      = DMA_BIT_MASK(32),
113 +       },
114 +};
115 +
116 +int __init bcm63xx_ehci_register(void)
117 +{
118 +       if (!BCMCPU_IS_6328() && !BCMCPU_IS_6358() && !BCMCPU_IS_6362() && !BCMCPU_IS_6368())
119 +               return 0;
120 +
121 +       ehci_resources[0].start = bcm63xx_regset_address(RSET_EHCI0);
122 +       ehci_resources[0].end = ehci_resources[0].start;
123 +       ehci_resources[0].end += RSET_EHCI_SIZE - 1;
124 +       ehci_resources[1].start = bcm63xx_get_irq_number(IRQ_EHCI0);
125 +
126 +       return platform_device_register(&bcm63xx_ehci_device);
127 +}
128 --- /dev/null
129 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ehci.h
130 @@ -0,0 +1,6 @@
131 +#ifndef BCM63XX_DEV_USB_EHCI_H_
132 +#define BCM63XX_DEV_USB_EHCI_H_
133 +
134 +int bcm63xx_ehci_register(void);
135 +
136 +#endif /* BCM63XX_DEV_USB_EHCI_H_ */