1 From 30d22baef255c99a12c4858ce4ab0d45f0d8c9ae Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <florian@openwrt.org>
3 Date: Mon, 28 Jan 2013 20:06:24 +0100
4 Subject: [PATCH 06/11] MIPS: BCM63XX: add support for the on-chip OHCI
7 Broadcom BCM63XX SoCs include an on-chip OHCI controller which can be
8 driven by the ohci-platform generic driver by using specific power
9 on/off/suspend callback to manage clocks and hardware specific
12 Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
13 Signed-off-by: Florian Fainelli <florian@openwrt.org>
15 arch/mips/bcm63xx/Makefile | 2 +-
16 arch/mips/bcm63xx/dev-usb-ohci.c | 94 ++++++++++++++++++++
17 .../asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h | 6 ++
18 3 files changed, 101 insertions(+), 1 deletion(-)
19 create mode 100644 arch/mips/bcm63xx/dev-usb-ohci.c
20 create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h
22 --- a/arch/mips/bcm63xx/Makefile
23 +++ b/arch/mips/bcm63xx/Makefile
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-usbd.o usb-common.o
29 + dev-wdt.o dev-usb-ohci.o dev-usb-usbd.o usb-common.o
30 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
34 +++ b/arch/mips/bcm63xx/dev-usb-ohci.c
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
41 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
42 + * Copyright (C) 2013 Florian Fainelli <florian@openwrt.org>
45 +#include <linux/init.h>
46 +#include <linux/kernel.h>
47 +#include <linux/platform_device.h>
48 +#include <linux/usb/ohci_pdriver.h>
49 +#include <linux/dma-mapping.h>
50 +#include <linux/clk.h>
51 +#include <linux/delay.h>
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_ohci.h>
59 +static struct resource ohci_resources[] = {
61 + .start = -1, /* filled at runtime */
62 + .end = -1, /* filled at runtime */
63 + .flags = IORESOURCE_MEM,
66 + .start = -1, /* filled at runtime */
67 + .flags = IORESOURCE_IRQ,
71 +static u64 ohci_dmamask = DMA_BIT_MASK(32);
73 +static struct clk *usb_host_clock;
75 +static int bcm63xx_ohci_power_on(struct platform_device *pdev)
77 + usb_host_clock = clk_get(&pdev->dev, "usbh");
78 + if (IS_ERR_OR_NULL(usb_host_clock))
81 + clk_prepare_enable(usb_host_clock);
83 + bcm63xx_usb_priv_ohci_cfg_set();
88 +static void bcm63xx_ohci_power_off(struct platform_device *pdev)
90 + if (!IS_ERR_OR_NULL(usb_host_clock)) {
91 + clk_disable_unprepare(usb_host_clock);
92 + clk_put(usb_host_clock);
96 +static struct usb_ohci_pdata bcm63xx_ohci_pdata = {
97 + .big_endian_desc = 1,
98 + .big_endian_mmio = 1,
99 + .no_big_frame_no = 1,
101 + .power_on = bcm63xx_ohci_power_on,
102 + .power_off = bcm63xx_ohci_power_off,
103 + .power_suspend = bcm63xx_ohci_power_off,
106 +static struct platform_device bcm63xx_ohci_device = {
107 + .name = "ohci-platform",
109 + .num_resources = ARRAY_SIZE(ohci_resources),
110 + .resource = ohci_resources,
112 + .platform_data = &bcm63xx_ohci_pdata,
113 + .dma_mask = &ohci_dmamask,
114 + .coherent_dma_mask = DMA_BIT_MASK(32),
118 +int __init bcm63xx_ohci_register(void)
120 + if (BCMCPU_IS_6345() || BCMCPU_IS_6338())
123 + ohci_resources[0].start = bcm63xx_regset_address(RSET_OHCI0);
124 + ohci_resources[0].end = ohci_resources[0].start;
125 + ohci_resources[0].end += RSET_OHCI_SIZE - 1;
126 + ohci_resources[1].start = bcm63xx_get_irq_number(IRQ_OHCI0);
128 + return platform_device_register(&bcm63xx_ohci_device);
131 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_usb_ohci.h
133 +#ifndef BCM63XX_DEV_USB_OHCI_H_
134 +#define BCM63XX_DEV_USB_OHCI_H_
136 +int bcm63xx_ohci_register(void);
138 +#endif /* BCM63XX_DEV_USB_OHCI_H_ */