102-MIPS-BCM63XX-move-code-touching-the-USB-private-regi.patch 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. This patch moves the code touching the USB private register in the
  7. bcm63xx USB gadget driver to arch/mips/bcm63xx/usb-common.c in
  8. preparation for adding support for OHCI and EHCI host controllers which
  9. will also touch the USB private register.
  10. Signed-off-by: Florian Fainelli <florian@openwrt.org>
  11. ---
  12. arch/mips/bcm63xx/Makefile | 2 +-
  13. arch/mips/bcm63xx/usb-common.c | 53 ++++++++++++++++++++
  14. .../include/asm/mach-bcm63xx/bcm63xx_usb_priv.h | 9 ++++
  15. drivers/usb/gadget/bcm63xx_udc.c | 27 ++--------
  16. 4 files changed, 67 insertions(+), 24 deletions(-)
  17. create mode 100644 arch/mips/bcm63xx/usb-common.c
  18. create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_usb_priv.h
  19. --- a/arch/mips/bcm63xx/Makefile
  20. +++ b/arch/mips/bcm63xx/Makefile
  21. @@ -1,7 +1,7 @@
  22. obj-y += clk.o cpu.o cs.o gpio.o irq.o nvram.o prom.o reset.o \
  23. setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \
  24. dev-pcmcia.o dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o \
  25. - dev-wdt.o dev-usb-usbd.o
  26. + dev-wdt.o dev-usb-usbd.o usb-common.o
  27. obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  28. obj-y += boards/
  29. --- /dev/null
  30. +++ b/arch/mips/bcm63xx/usb-common.c
  31. @@ -0,0 +1,53 @@
  32. +/*
  33. + * Broadcom BCM63xx common USB device configuration code
  34. + *
  35. + * This file is subject to the terms and conditions of the GNU General Public
  36. + * License. See the file "COPYING" in the main directory of this archive
  37. + * for more details.
  38. + *
  39. + * Copyright (C) 2012 Kevin Cernekee <cernekee@gmail.com>
  40. + * Copyright (C) 2012 Broadcom Corporation
  41. + *
  42. + */
  43. +#include <linux/export.h>
  44. +
  45. +#include <bcm63xx_cpu.h>
  46. +#include <bcm63xx_regs.h>
  47. +#include <bcm63xx_io.h>
  48. +#include <bcm63xx_usb_priv.h>
  49. +
  50. +void bcm63xx_usb_priv_select_phy_mode(u32 portmask, bool is_device)
  51. +{
  52. + u32 val;
  53. +
  54. + val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
  55. + if (is_device) {
  56. + val |= (portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
  57. + val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
  58. + } else {
  59. + val &= ~(portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
  60. + val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
  61. + }
  62. + bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
  63. +
  64. + val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_6368_REG);
  65. + if (is_device)
  66. + val |= USBH_PRIV_SWAP_USBD_MASK;
  67. + else
  68. + val &= ~USBH_PRIV_SWAP_USBD_MASK;
  69. + bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_SWAP_6368_REG);
  70. +}
  71. +EXPORT_SYMBOL(bcm63xx_usb_priv_select_phy_mode);
  72. +
  73. +void bcm63xx_usb_priv_select_pullup(u32 portmask, bool is_on)
  74. +{
  75. + u32 val;
  76. +
  77. + val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
  78. + if (is_on)
  79. + val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
  80. + else
  81. + val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
  82. + bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
  83. +}
  84. +EXPORT_SYMBOL(bcm63xx_usb_priv_select_pullup);
  85. --- /dev/null
  86. +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_usb_priv.h
  87. @@ -0,0 +1,9 @@
  88. +#ifndef BCM63XX_USB_PRIV_H_
  89. +#define BCM63XX_USB_PRIV_H_
  90. +
  91. +#include <linux/types.h>
  92. +
  93. +void bcm63xx_usb_priv_select_phy_mode(u32 portmask, bool is_device);
  94. +void bcm63xx_usb_priv_select_pullup(u32 portmask, bool is_on);
  95. +
  96. +#endif /* BCM63XX_USB_PRIV_H_ */
  97. --- a/drivers/usb/gadget/udc/bcm63xx_udc.c
  98. +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c
  99. @@ -40,6 +40,7 @@
  100. #include <bcm63xx_dev_usb_usbd.h>
  101. #include <bcm63xx_io.h>
  102. #include <bcm63xx_regs.h>
  103. +#include <bcm63xx_usb_priv.h>
  104. #define DRV_MODULE_NAME "bcm63xx_udc"
  105. @@ -868,22 +869,7 @@ static void bcm63xx_select_phy_mode(stru
  106. bcm_gpio_writel(val, GPIO_PINMUX_OTHR_REG);
  107. }
  108. - val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
  109. - if (is_device) {
  110. - val |= (portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
  111. - val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
  112. - } else {
  113. - val &= ~(portmask << USBH_PRIV_UTMI_CTL_HOSTB_SHIFT);
  114. - val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
  115. - }
  116. - bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
  117. -
  118. - val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_6368_REG);
  119. - if (is_device)
  120. - val |= USBH_PRIV_SWAP_USBD_MASK;
  121. - else
  122. - val &= ~USBH_PRIV_SWAP_USBD_MASK;
  123. - bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_SWAP_6368_REG);
  124. + bcm63xx_usb_priv_select_phy_mode(portmask, is_device);
  125. }
  126. /**
  127. @@ -897,14 +883,9 @@ static void bcm63xx_select_phy_mode(stru
  128. */
  129. static void bcm63xx_select_pullup(struct bcm63xx_udc *udc, bool is_on)
  130. {
  131. - u32 val, portmask = BIT(udc->pd->port_no);
  132. + u32 portmask = BIT(udc->pd->port_no);
  133. - val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
  134. - if (is_on)
  135. - val &= ~(portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
  136. - else
  137. - val |= (portmask << USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
  138. - bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
  139. + bcm63xx_usb_priv_select_pullup(portmask, is_on);
  140. }
  141. /**