1 From ac9b0b574d54be28b300bf99ffe092a2c589484f Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <florian@openwrt.org>
3 Date: Mon, 28 Jan 2013 20:06:21 +0100
4 Subject: [PATCH 03/11] MIPS: BCM63XX: move code touching the USB private
7 This patch moves the code touching the USB private register in the
8 bcm63xx USB gadget driver to arch/mips/bcm63xx/usb-common.c in
9 preparation for adding support for OHCI and EHCI host controllers which
10 will also touch the USB private register.
12 Signed-off-by: Florian Fainelli <florian@openwrt.org>
14 arch/mips/bcm63xx/Makefile | 2 +-
15 arch/mips/bcm63xx/usb-common.c | 53 ++++++++++++++++++++
16 .../include/asm/mach-bcm63xx/bcm63xx_usb_priv.h | 9 ++++
17 drivers/usb/gadget/bcm63xx_udc.c | 27 ++--------
18 4 files changed, 67 insertions(+), 24 deletions(-)
19 create mode 100644 arch/mips/bcm63xx/usb-common.c
20 create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_usb_priv.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
29 + dev-wdt.o dev-usb-usbd.o usb-common.o
30 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
34 +++ b/arch/mips/bcm63xx/usb-common.c
37 + * Broadcom BCM63xx common USB device configuration code
39 + * This file is subject to the terms and conditions of the GNU General Public
40 + * License. See the file "COPYING" in the main directory of this archive
43 + * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com>
44 + * Copyright (C) 2012 Broadcom Corporation
47 +#include <linux/export.h>
49 +#include <bcm63xx_cpu.h>
50 +#include <bcm63xx_regs.h>
51 +#include <bcm63xx_io.h>
52 +#include <bcm63xx_usb_priv.h>
54 +void bcm63xx_usb_priv_select_phy_mode(u32 portmask, bool is_device)
58 + val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
60 + val |= (portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
61 + val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
63 + val &= ~(portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
64 + val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
66 + bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
68 + val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_6368_REG);
70 + val |= USBH_PRIV_SWAP_USBD_MASK;
72 + val &= ~USBH_PRIV_SWAP_USBD_MASK;
73 + bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_SWAP_6368_REG);
75 +EXPORT_SYMBOL(bcm63xx_usb_priv_select_phy_mode);
77 +void bcm63xx_usb_priv_select_pullup(u32 portmask, bool is_on)
81 + val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
83 + val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
85 + val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
86 + bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
88 +EXPORT_SYMBOL(bcm63xx_usb_priv_select_pullup);
90 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_usb_priv.h
92 +#ifndef BCM63XX_USB_PRIV_H_
93 +#define BCM63XX_USB_PRIV_H_
95 +#include <linux/types.h>
97 +void bcm63xx_usb_priv_select_phy_mode(u32 portmask, bool is_device);
98 +void bcm63xx_usb_priv_select_pullup(u32 portmask, bool is_on);
100 +#endif /* BCM63XX_USB_PRIV_H_ */
101 --- a/drivers/usb/gadget/udc/bcm63xx_udc.c
102 +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c
104 #include <bcm63xx_dev_usb_usbd.h>
105 #include <bcm63xx_io.h>
106 #include <bcm63xx_regs.h>
107 +#include <bcm63xx_usb_priv.h>
109 #define DRV_MODULE_NAME "bcm63xx_udc"
111 @@ -868,22 +869,7 @@ static void bcm63xx_select_phy_mode(stru
112 bcm_gpio_writel(val, GPIO_PINMUX_OTHR_REG);
115 - val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
117 - val |= (portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
118 - val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
120 - val &= ~(portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
121 - val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
123 - bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
125 - val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_6368_REG);
127 - val |= USBH_PRIV_SWAP_USBD_MASK;
129 - val &= ~USBH_PRIV_SWAP_USBD_MASK;
130 - bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_SWAP_6368_REG);
131 + bcm63xx_usb_priv_select_phy_mode(portmask, is_device);
135 @@ -897,14 +883,9 @@ static void bcm63xx_select_phy_mode(stru
137 static void bcm63xx_select_pullup(struct bcm63xx_udc *udc, bool is_on)
139 - u32 val, portmask = BIT(udc->pd->port_no);
140 + u32 portmask = BIT(udc->pd->port_no);
142 - val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
144 - val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
146 - val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
147 - bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
148 + bcm63xx_usb_priv_select_pullup(portmask, is_on);