[PATCH 1/3 v2] USB: host: Remove ehci-octeon and ohci-octeon drivers

2014-11-25 Thread Andreas Herrmann
From: Alan Stern st...@rowland.harvard.edu

Remove special-purpose octeon drivers and instead use ehci-platform
and ohci-platform as suggested with
http://marc.info/?l=linux-mipsm=140139694721623w=2

[andreas.herrmann:
fixed compile error]

Cc: David Daney david.da...@cavium.com
Cc: Alex Smith alex.sm...@imgtec.com
Signed-off-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Andreas Herrmann andreas.herrm...@caviumnetworks.com
Acked-by: Ralf Baechle r...@linux-mips.org
Tested-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/mips/cavium-octeon/octeon-platform.c |  274 -
 arch/mips/configs/cavium_octeon_defconfig |3 +
 drivers/usb/host/Kconfig  |   18 +-
 drivers/usb/host/Makefile |1 -
 drivers/usb/host/ehci-hcd.c   |5 -
 drivers/usb/host/ehci-octeon.c|  182 ---
 drivers/usb/host/octeon2-common.c |  200 -
 drivers/usb/host/ohci-hcd.c   |5 -
 drivers/usb/host/ohci-octeon.c|  196 -
 9 files changed, 285 insertions(+), 599 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-octeon.c
 delete mode 100644 drivers/usb/host/octeon2-common.c
 delete mode 100644 drivers/usb/host/ohci-octeon.c


There was a conflict with commits
073153bf22764 (host: ehci-octeon: remove duplicate check on resource)
c6d413cebd82c (host: ohci-octeon: remove duplicate check on resource)

I rebased the patch to your usb-next branch as of
v3.18-rc4-66-g69b7290.

Patch 2 and 3 of the series should apply w/o issues.


Thanks,

Andreas


diff --git a/arch/mips/cavium-octeon/octeon-platform.c 
b/arch/mips/cavium-octeon/octeon-platform.c
index 6df0f4d..b67ddf0 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -7,22 +7,27 @@
  * Copyright (C) 2008 Wind River Systems
  */
 
+#include linux/delay.h
 #include linux/init.h
 #include linux/irq.h
 #include linux/i2c.h
 #include linux/usb.h
 #include linux/dma-mapping.h
 #include linux/module.h
+#include linux/mutex.h
 #include linux/slab.h
 #include linux/platform_device.h
 #include linux/of_platform.h
 #include linux/of_fdt.h
 #include linux/libfdt.h
+#include linux/usb/ehci_pdriver.h
+#include linux/usb/ohci_pdriver.h
 
 #include asm/octeon/octeon.h
 #include asm/octeon/cvmx-rnm-defs.h
 #include asm/octeon/cvmx-helper.h
 #include asm/octeon/cvmx-helper-board.h
+#include asm/octeon/cvmx-uctlx-defs.h
 
 /* Octeon Random Number Generator.  */
 static int __init octeon_rng_device_init(void)
@@ -68,6 +73,229 @@ device_initcall(octeon_rng_device_init);
 
 #ifdef CONFIG_USB
 
+static DEFINE_MUTEX(octeon2_usb_clocks_mutex);
+
+static int octeon2_usb_clock_start_cnt;
+
+static void octeon2_usb_clocks_start(void)
+{
+   u64 div;
+   union cvmx_uctlx_if_ena if_ena;
+   union cvmx_uctlx_clk_rst_ctl clk_rst_ctl;
+   union cvmx_uctlx_uphy_ctl_status uphy_ctl_status;
+   union cvmx_uctlx_uphy_portx_ctl_status port_ctl_status;
+   int i;
+   unsigned long io_clk_64_to_ns;
+
+
+   mutex_lock(octeon2_usb_clocks_mutex);
+
+   octeon2_usb_clock_start_cnt++;
+   if (octeon2_usb_clock_start_cnt != 1)
+   goto exit;
+
+   io_clk_64_to_ns = 640ull / octeon_get_io_clock_rate();
+
+   /*
+* Step 1: Wait for voltages stable.  That surely happened
+* before starting the kernel.
+*
+* Step 2: Enable  SCLK of UCTL by writing UCTL0_IF_ENA[EN] = 1
+*/
+   if_ena.u64 = 0;
+   if_ena.s.en = 1;
+   cvmx_write_csr(CVMX_UCTLX_IF_ENA(0), if_ena.u64);
+
+   /* Step 3: Configure the reference clock, PHY, and HCLK */
+   clk_rst_ctl.u64 = cvmx_read_csr(CVMX_UCTLX_CLK_RST_CTL(0));
+
+   /*
+* If the UCTL looks like it has already been started, skip
+* the initialization, otherwise bus errors are obtained.
+*/
+   if (clk_rst_ctl.s.hrst)
+   goto end_clock;
+   /* 3a */
+   clk_rst_ctl.s.p_por = 1;
+   clk_rst_ctl.s.hrst = 0;
+   clk_rst_ctl.s.p_prst = 0;
+   clk_rst_ctl.s.h_clkdiv_rst = 0;
+   clk_rst_ctl.s.o_clkdiv_rst = 0;
+   clk_rst_ctl.s.h_clkdiv_en = 0;
+   clk_rst_ctl.s.o_clkdiv_en = 0;
+   cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64);
+
+   /* 3b */
+   /* 12MHz crystal. */
+   clk_rst_ctl.s.p_refclk_sel = 0;
+   clk_rst_ctl.s.p_refclk_div = 0;
+   cvmx_write_csr(CVMX_UCTLX_CLK_RST_CTL(0), clk_rst_ctl.u64);
+
+   /* 3c */
+   div = octeon_get_io_clock_rate() / 13000ull;
+
+   switch (div) {
+   case 0:
+   div = 1;
+   break;
+   case 1:
+   case 2:
+   case 3:
+   case 4:
+   break;
+   case 5:
+   div = 4;
+   break;
+   case 6:
+   case 7:
+   div = 6;
+   break;
+   case 8:
+   case 9:
+   case 10:

Re: [PATCH 1/3 v2] USB: host: Remove ehci-octeon and ohci-octeon drivers

2014-11-25 Thread Greg KH
On Tue, Nov 25, 2014 at 12:28:46PM +0100, Andreas Herrmann wrote:
 From: Alan Stern st...@rowland.harvard.edu
 
 Remove special-purpose octeon drivers and instead use ehci-platform
 and ohci-platform as suggested with
 http://marc.info/?l=linux-mipsm=140139694721623w=2
 
 [andreas.herrmann:
 fixed compile error]
 
 Cc: David Daney david.da...@cavium.com
 Cc: Alex Smith alex.sm...@imgtec.com
 Signed-off-by: Alan Stern st...@rowland.harvard.edu
 Signed-off-by: Andreas Herrmann andreas.herrm...@caviumnetworks.com
 Acked-by: Ralf Baechle r...@linux-mips.org
 Tested-by: Aaro Koskinen aaro.koski...@iki.fi
 ---
  arch/mips/cavium-octeon/octeon-platform.c |  274 
 -
  arch/mips/configs/cavium_octeon_defconfig |3 +
  drivers/usb/host/Kconfig  |   18 +-
  drivers/usb/host/Makefile |1 -
  drivers/usb/host/ehci-hcd.c   |5 -
  drivers/usb/host/ehci-octeon.c|  182 ---
  drivers/usb/host/octeon2-common.c |  200 -
  drivers/usb/host/ohci-hcd.c   |5 -
  drivers/usb/host/ohci-octeon.c|  196 -
  9 files changed, 285 insertions(+), 599 deletions(-)
  delete mode 100644 drivers/usb/host/ehci-octeon.c
  delete mode 100644 drivers/usb/host/octeon2-common.c
  delete mode 100644 drivers/usb/host/ohci-octeon.c
 
 
 There was a conflict with commits
 073153bf22764 (host: ehci-octeon: remove duplicate check on resource)
 c6d413cebd82c (host: ohci-octeon: remove duplicate check on resource)
 
 I rebased the patch to your usb-next branch as of
 v3.18-rc4-66-g69b7290.
 
 Patch 2 and 3 of the series should apply w/o issues.

They are long-gone from my queue, please resend.

thanks,

greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html