bcm63xx: add support for linux 3.8
[openwrt.git] / target / linux / brcm63xx / patches-3.8 / 110-MIPS-BCM63XX-move-code-touching-the-USB-private-regi.patch
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
5  register
6
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.
11
12 Signed-off-by: Florian Fainelli <florian@openwrt.org>
13 ---
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
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-usbd.o
29 +                  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/usb-common.c
35 @@ -0,0 +1,53 @@
36 +/*
37 + * Broadcom BCM63xx common USB device configuration code
38 + *
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
41 + * for more details.
42 + *
43 + * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com>
44 + * Copyright (C) 2012 Broadcom Corporation
45 + *
46 + */
47 +#include <linux/export.h>
48 +
49 +#include <bcm63xx_cpu.h>
50 +#include <bcm63xx_regs.h>
51 +#include <bcm63xx_io.h>
52 +#include <bcm63xx_usb_priv.h>
53 +
54 +void bcm63xx_usb_priv_select_phy_mode(u32 portmask, bool is_device)
55 +{
56 +       u32 val;
57 +
58 +       val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
59 +       if (is_device) {
60 +               val |= (portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
61 +               val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
62 +       } else {
63 +               val &= ~(portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
64 +               val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
65 +       }
66 +       bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
67 +
68 +       val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_6368_REG);
69 +       if (is_device)
70 +               val |= USBH_PRIV_SWAP_USBD_MASK;
71 +       else
72 +               val &= ~USBH_PRIV_SWAP_USBD_MASK;
73 +       bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_SWAP_6368_REG);
74 +}
75 +EXPORT_SYMBOL(bcm63xx_usb_priv_select_phy_mode);
76 +
77 +void bcm63xx_usb_priv_select_pullup(u32 portmask, bool is_on)
78 +{
79 +       u32 val;
80 +
81 +       val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
82 +       if (is_on)
83 +               val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
84 +       else
85 +               val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
86 +       bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
87 +}
88 +EXPORT_SYMBOL(bcm63xx_usb_priv_select_pullup);
89 --- /dev/null
90 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_usb_priv.h
91 @@ -0,0 +1,9 @@
92 +#ifndef BCM63XX_USB_PRIV_H_
93 +#define BCM63XX_USB_PRIV_H_
94 +
95 +#include <linux/types.h>
96 +
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);
99 +
100 +#endif /* BCM63XX_USB_PRIV_H_ */
101 --- a/drivers/usb/gadget/bcm63xx_udc.c
102 +++ b/drivers/usb/gadget/bcm63xx_udc.c
103 @@ -41,6 +41,7 @@
104  #include <bcm63xx_dev_usb_usbd.h>
105  #include <bcm63xx_io.h>
106  #include <bcm63xx_regs.h>
107 +#include <bcm63xx_usb_priv.h>
108  
109  #define DRV_MODULE_NAME                "bcm63xx_udc"
110  
111 @@ -863,22 +864,7 @@ static void bcm63xx_select_phy_mode(stru
112                 bcm_gpio_writel(val, GPIO_PINMUX_OTHR_REG);
113         }
114  
115 -       val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
116 -       if (is_device) {
117 -               val |= (portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
118 -               val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
119 -       } else {
120 -               val &= ~(portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
121 -               val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
122 -       }
123 -       bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
124 -
125 -       val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_6368_REG);
126 -       if (is_device)
127 -               val |= USBH_PRIV_SWAP_USBD_MASK;
128 -       else
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);
132  }
133  
134  /**
135 @@ -892,14 +878,9 @@ static void bcm63xx_select_phy_mode(stru
136   */
137  static void bcm63xx_select_pullup(struct bcm63xx_udc *udc, bool is_on)
138  {
139 -       u32 val, portmask = BIT(udc->pd->port_no);
140 +       u32 portmask = BIT(udc->pd->port_no);
141  
142 -       val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
143 -       if (is_on)
144 -               val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
145 -       else
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);
149  }
150  
151  /**