brcm63xx: update development kernel to linux 3.14
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-3.14 / 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,8 @@
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-hsspi.o dev-uart.o \
28 - dev-wdt.o dev-usb-ohci.o dev-usb-usbd.o usb-common.o
29 + dev-wdt.o dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o \
30 + usb-common.o
31 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
32
33 obj-y += boards/
34 --- /dev/null
35 +++ b/arch/mips/bcm63xx/dev-usb-ehci.c
36 @@ -0,0 +1,92 @@
37 +/*
38 + * This file is subject to the terms and conditions of the GNU General Public
39 + * License. See the file "COPYING" in the main directory of this archive
40 + * for more details.
41 + *
42 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
43 + * Copyright (C) 2013 Florian Fainelli <florian@openwrt.org>
44 + */
45 +
46 +#include <linux/init.h>
47 +#include <linux/kernel.h>
48 +#include <linux/platform_device.h>
49 +#include <linux/clk.h>
50 +#include <linux/delay.h>
51 +#include <linux/usb/ehci_pdriver.h>
52 +#include <linux/dma-mapping.h>
53 +
54 +#include <bcm63xx_cpu.h>
55 +#include <bcm63xx_regs.h>
56 +#include <bcm63xx_io.h>
57 +#include <bcm63xx_usb_priv.h>
58 +#include <bcm63xx_dev_usb_ehci.h>
59 +
60 +static struct resource ehci_resources[] = {
61 + {
62 + .start = -1, /* filled at runtime */
63 + .end = -1, /* filled at runtime */
64 + .flags = IORESOURCE_MEM,
65 + },
66 + {
67 + .start = -1, /* filled at runtime */
68 + .flags = IORESOURCE_IRQ,
69 + },
70 +};
71 +
72 +static u64 ehci_dmamask = DMA_BIT_MASK(32);
73 +
74 +static struct clk *usb_host_clock;
75 +
76 +static int bcm63xx_ehci_power_on(struct platform_device *pdev)
77 +{
78 + usb_host_clock = clk_get(&pdev->dev, "usbh");
79 + if (IS_ERR_OR_NULL(usb_host_clock))
80 + return -ENODEV;
81 +
82 + clk_prepare_enable(usb_host_clock);
83 +
84 + bcm63xx_usb_priv_ehci_cfg_set();
85 +
86 + return 0;
87 +}
88 +
89 +static void bcm63xx_ehci_power_off(struct platform_device *pdev)
90 +{
91 + if (!IS_ERR_OR_NULL(usb_host_clock)) {
92 + clk_disable_unprepare(usb_host_clock);
93 + clk_put(usb_host_clock);
94 + }
95 +}
96 +
97 +static struct usb_ehci_pdata bcm63xx_ehci_pdata = {
98 + .big_endian_desc = 1,
99 + .big_endian_mmio = 1,
100 + .power_on = bcm63xx_ehci_power_on,
101 + .power_off = bcm63xx_ehci_power_off,
102 + .power_suspend = bcm63xx_ehci_power_off,
103 +};
104 +
105 +static struct platform_device bcm63xx_ehci_device = {
106 + .name = "ehci-platform",
107 + .id = -1,
108 + .num_resources = ARRAY_SIZE(ehci_resources),
109 + .resource = ehci_resources,
110 + .dev = {
111 + .platform_data = &bcm63xx_ehci_pdata,
112 + .dma_mask = &ehci_dmamask,
113 + .coherent_dma_mask = DMA_BIT_MASK(32),
114 + },
115 +};
116 +
117 +int __init bcm63xx_ehci_register(void)
118 +{
119 + if (!BCMCPU_IS_6328() && !BCMCPU_IS_6358() && !BCMCPU_IS_6362() && !BCMCPU_IS_6368())
120 + return 0;
121 +
122 + ehci_resources[0].start = bcm63xx_regset_address(RSET_EHCI0);
123 + ehci_resources[0].end = ehci_resources[0].start;
124 + ehci_resources[0].end += RSET_EHCI_SIZE - 1;
125 + ehci_resources[1].start = bcm63xx_get_irq_number(IRQ_EHCI0);
126 +
127 + return platform_device_register(&bcm63xx_ehci_device);
128 +}
129 --- /dev/null
130 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ehci.h
131 @@ -0,0 +1,6 @@
132 +#ifndef BCM63XX_DEV_USB_EHCI_H_
133 +#define BCM63XX_DEV_USB_EHCI_H_
134 +
135 +int bcm63xx_ehci_register(void);
136 +
137 +#endif /* BCM63XX_DEV_USB_EHCI_H_ */