USB: host: Misc patches to remove hard-coded octeon platform information
Subsystems (4)
cover USB: host: Misc patches to remove hard-coded octeon platform information
Hi Alan,
With following patches I want to base octeon ehci/ohci device configuration on device tree information.
I picked up patches that were submitted in May. See
http://marc.info/?l=linux-usb&m=140135823325811&w=2
and http://marc.info/?l=linux-mips&m=140139694721623&w=2
Patch #1 is your "untested preliminary pass" to remove
[oe]hci-octeon drivers.
Patch #2 is the removal of hard-coded platform information (but now
rebased on your patch)
Patch #3 adapts dma_mask for ehci (as used in ehci-octeon)
Overall diffstat is
arch/mips/cavium-octeon/octeon-platform.c | 380 +++++++++++++++++++++++------ 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 | 188 -------------- drivers/usb/host/ehci-platform.c | 4 +- drivers/usb/host/octeon2-common.c | 200 --------------- drivers/usb/host/ohci-hcd.c | 5 - drivers/usb/host/ohci-octeon.c | 202 --------------- drivers/usb/host/ohci-platform.c | 1 + include/linux/usb/ehci_pdriver.h | 1 + 12 files changed, 330 insertions(+), 678 deletions(-)
Patches are based on v3.18-rc4-65-g2c54396
Comments welcome.
Thanks,
Andreas
PATCH 1/3 USB: host: Remove ehci-octeon and ohci-octeon drivers
From: Alan Stern <[email protected]>
From: Alan Stern <[email protected]>
Remove special-purpose octeon drivers and instead use ehci-platform and ohci-platform as suggested with
http://marc.info/?l=linux-mips&m=140139694721623&w=2
[andreas.herrmann:
fixed compile error]
--- 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 | 188 -------------------- drivers/usb/host/octeon2-common.c | 200 --------------------- drivers/usb/host/ohci-hcd.c | 5 - drivers/usb/host/ohci-octeon.c | 202 --------------------- 9 files changed, 285 insertions(+), 611 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
arch/mips/cavium-octeon/octeon-platform.c +272 -2
@@ -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 =64000000000ull /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 () /130000000ull ; + +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 : +case 11 : + div =8 ; +break ; +default : + div =12 ; +break ; + } + clk_rst_ctl.s.h_div = div; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); +/* Read it back, */ + clk_rst_ctl.u64 =cvmx_read_csr (CVMX_UCTLX_CLK_RST_CTL (0 )); + clk_rst_ctl.s.h_clkdiv_en =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); +/* 3d */ + clk_rst_ctl.s.h_clkdiv_rst =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* 3e: delay 64 io clocks */ +ndelay (io_clk_64_to_ns); + +/* +* Step 4: Program the power-on reset field in the UCTL +* clock-reset-control register. +*/ + clk_rst_ctl.s.p_por =0 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* Step 5: Wait 1 ms for the PHY clock to start. */ +mdelay (1 ); + +/* +* Step 6: Program the reset input from automatic test +* equipment field in the UPHY CSR +*/ + uphy_ctl_status.u64 =cvmx_read_csr (CVMX_UCTLX_UPHY_CTL_STATUS (0 )); + uphy_ctl_status.s.ate_reset =1 ; +cvmx_write_csr (CVMX_UCTLX_UPHY_CTL_STATUS (0 ), uphy_ctl_status.u64); + +/* Step 7: Wait for at least 10ns. */ +ndelay (10 ); + +/* Step 8: Clear the ATE_RESET field in the UPHY CSR. */ + uphy_ctl_status.s.ate_reset =0 ; +cvmx_write_csr (CVMX_UCTLX_UPHY_CTL_STATUS (0 ), uphy_ctl_status.u64); + +/* +* Step 9: Wait for at least 20ns for UPHY to output PHY clock +* signals and OHCI_CLK48 +*/ +ndelay (20 ); + +/* Step 10: Configure the OHCI_CLK48 and OHCI_CLK12 clocks. */ +/* 10a */ + clk_rst_ctl.s.o_clkdiv_rst =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* 10b */ + clk_rst_ctl.s.o_clkdiv_en =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* 10c */ +ndelay (io_clk_64_to_ns); + +/* +* Step 11: Program the PHY reset field: +* UCTL0_CLK_RST_CTL[P_PRST] = 1 +*/ + clk_rst_ctl.s.p_prst =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* Step 12: Wait 1 uS. */ +udelay (1 ); + +/* Step 13: Program the HRESET_N field: UCTL0_CLK_RST_CTL[HRST] = 1 */ + clk_rst_ctl.s.hrst =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +end_clock: +/* Now we can set some other registers. */ + +for (i =0 ; i <=1 ; i++) { + port_ctl_status.u64 = +cvmx_read_csr (CVMX_UCTLX_UPHY_PORTX_CTL_STATUS (i,0 )); +/* Set txvreftune to 15 to obtain compliant 'eye' diagram. */ + port_ctl_status.s.txvreftune =15 ; + port_ctl_status.s.txrisetune =1 ; + port_ctl_status.s.txpreemphasistune =1 ; +cvmx_write_csr (CVMX_UCTLX_UPHY_PORTX_CTL_STATUS (i,0 ), + port_ctl_status.u64); + } + +/* Set uSOF cycle period to 60,000 bits. */ +cvmx_write_csr (CVMX_UCTLX_EHCI_FLA (0 ),0x20ull ); +exit: +mutex_unlock (&octeon2_usb_clocks_mutex); +} + +static void octeon2_usb_clocks_stop (void ) +{ +mutex_lock (&octeon2_usb_clocks_mutex); + octeon2_usb_clock_start_cnt--; +mutex_unlock (&octeon2_usb_clocks_mutex); +} + +static int octeon_ehci_power_on (struct platform_device *pdev) +{ +octeon2_usb_clocks_start (); +return 0 ; +} + +static void octeon_ehci_power_off (struct platform_device *pdev) +{ +octeon2_usb_clocks_stop (); +} + +static struct usb_ehci_pdata octeon_ehci_pdata = { +/* Octeon EHCI matches CPU endianness. */ +#ifdef __BIG_ENDIAN + .big_endian_mmio =1 , +#endif + .power_on = octeon_ehci_power_on, + .power_off = octeon_ehci_power_off, +}; + +static void __init octeon_ehci_hw_start (void ) +{ +union cvmx_uctlx_ehci_ctl ehci_ctl; + +octeon2_usb_clocks_start (); + + ehci_ctl.u64 =cvmx_read_csr (CVMX_UCTLX_EHCI_CTL (0 )); +/* Use 64-bit addressing. */ + ehci_ctl.s.ehci_64b_addr_en =1 ; + ehci_ctl.s.l2c_addr_msb =0 ; + ehci_ctl.s.l2c_buff_emod =1 ;/* Byte swapped. */ + ehci_ctl.s.l2c_desc_emod =1 ;/* Byte swapped. */ +cvmx_write_csr (CVMX_UCTLX_EHCI_CTL (0 ), ehci_ctl.u64); + +octeon2_usb_clocks_stop (); +} + +static u64 octeon_ehci_dma_mask =DMA_BIT_MASK (64 ); +static int __init octeon_ehci_device_init (void ) {struct platform_device *pd;
@@ -88,7 +316,7 @@ static int __init octeon_ehci_device_init(void)if (octeon_is_simulation () ||usb_disabled ())return 0 ;/* No USB in the simulator. */ - pd =platform_device_alloc ("octeon-ehci" ,0 ); + pd =platform_device_alloc ("ehci-platform" ,0 );if (!pd) { ret = -ENOMEM ; goto out;
@@ -105,6 +333,10 @@ static int __init octeon_ehci_device_init(void)if (ret) goto fail; + pd->dev.dma_mask = &octeon_ehci_dma_mask; + pd->dev.platform_data = &octeon_ehci_pdata; +octeon_ehci_hw_start (); + ret =platform_device_add (pd);if (ret) goto fail;
@@ -117,6 +349,41 @@ out: }device_initcall (octeon_ehci_device_init); +static int octeon_ohci_power_on (struct platform_device *pdev) +{ +octeon2_usb_clocks_start (); +return 0 ; +} + +static void octeon_ohci_power_off (struct platform_device *pdev) +{ +octeon2_usb_clocks_stop (); +} + +static struct usb_ohci_pdata octeon_ohci_pdata = { +/* Octeon OHCI matches CPU endianness. */ +#ifdef __BIG_ENDIAN + .big_endian_mmio =1 , +#endif + .power_on = octeon_ohci_power_on, + .power_off = octeon_ohci_power_off, +}; + +static void __init octeon_ohci_hw_start (void ) +{ +union cvmx_uctlx_ohci_ctl ohci_ctl; + +octeon2_usb_clocks_start (); + + ohci_ctl.u64 =cvmx_read_csr (CVMX_UCTLX_OHCI_CTL (0 )); + ohci_ctl.s.l2c_addr_msb =0 ; + ohci_ctl.s.l2c_buff_emod =1 ;/* Byte swapped. */ + ohci_ctl.s.l2c_desc_emod =1 ;/* Byte swapped. */ +cvmx_write_csr (CVMX_UCTLX_OHCI_CTL (0 ), ohci_ctl.u64); + +octeon2_usb_clocks_stop (); +} +static int __init octeon_ohci_device_init (void ) {struct platform_device *pd;
@@ -137,7 +404,7 @@ static int __init octeon_ohci_device_init(void)if (octeon_is_simulation () ||usb_disabled ())return 0 ;/* No USB in the simulator. */ - pd =platform_device_alloc ("octeon-ohci" ,0 ); + pd =platform_device_alloc ("ohci-platform" ,0 );if (!pd) { ret = -ENOMEM ; goto out;
@@ -154,6 +421,9 @@ static int __init octeon_ohci_device_init(void)if (ret) goto fail; + pd->dev.platform_data = &octeon_ohci_pdata; +octeon_ohci_hw_start (); + ret =platform_device_add (pd);if (ret) goto fail;
arch/mips/configs/cavium_octeon_defconfig +3 -0
@@ -120,6 +120,9 @@ CONFIG_SPI_OCTEON=y # CONFIG_HWMON is not set CONFIG_WATCHDOG=y # CONFIG_USB_SUPPORT is not set +CONFIG_USB_EHCI_BIG_ENDIAN_MMIO=y +CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y +CONFIG_USB_OHCI_LITTLE_ENDIAN=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_DS1307=y CONFIG_STAGING=y
drivers/usb/host/Kconfig +10 -8
@@ -292,11 +292,15 @@ config USB_EHCI_HCD_PLATFORM If unsure, say N. config USB_OCTEON_EHCI - bool "Octeon on-chip EHCI support" + bool "Octeon on-chip EHCI support (DEPRECATED)" depends on CAVIUM_OCTEON_SOC default n select USB_EHCI_BIG_ENDIAN_MMIO + select USB_EHCI_HCD_PLATFORM help + This option is deprecated now and the driver was removed, use + USB_EHCI_HCD_PLATFORM instead. + Enable support for the Octeon II SOC's on-chip EHCI controller. It is needed for high-speed (480Mbit/sec) USB 2.0 device support. All CN6XXX based chips with USB are
@@ -575,12 +579,16 @@ config USB_OHCI_HCD_PLATFORM If unsure, say N. config USB_OCTEON_OHCI - bool "Octeon on-chip OHCI support" + bool "Octeon on-chip OHCI support (DEPRECATED)" depends on CAVIUM_OCTEON_SOC default USB_OCTEON_EHCI select USB_OHCI_BIG_ENDIAN_MMIO select USB_OHCI_LITTLE_ENDIAN + select USB_OHCI_HCD_PLATFORM help + This option is deprecated now and the driver was removed, use + USB_OHCI_HCD_PLATFORM instead. + Enable support for the Octeon II SOC's on-chip OHCI controller. It is needed for low-speed USB 1.0 device support. All CN6XXX based chips with USB are supported.
@@ -754,12 +762,6 @@ config USB_IMX21_HCD To compile this driver as a module, choose M here: the module will be called "imx21-hcd". - - -config USB_OCTEON2_COMMON - bool - default y if USB_OCTEON_EHCI || USB_OCTEON_OHCI - config USB_HCD_BCMA tristate "BCMA usb host driver" depends on BCMA
drivers/usb/host/Makefile +0 -1
@@ -73,7 +73,6 @@ obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o -obj-$(CONFIG_USB_OCTEON2_COMMON) += octeon2-common.o obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o obj-$(CONFIG_USB_FUSBH200_HCD) += fusbh200-hcd.o
drivers/usb/host/ehci-hcd.c +0 -5
@@ -1268,11 +1268,6 @@ MODULE_LICENSE ("GPL");#define XILINX_OF_PLATFORM_DRIVER ehci_hcd_xilinx_of_driver#endif -#ifdef CONFIG_USB_OCTEON_EHCI -#include "ehci-octeon.c" -#define PLATFORM_DRIVER ehci_octeon_driver -#endif -#ifdef CONFIG_TILE_USB #include "ehci-tilegx.c" #define PLATFORM_DRIVER ehci_hcd_tilegx_driver
drivers/usb/host/ehci-octeon.c deleted +0 -188
188 lines not on this page · raw message
drivers/usb/host/octeon2-common.c deleted +0 -200
200 lines not on this page · raw message
drivers/usb/host/ohci-hcd.c +0 -5
@@ -1249,11 +1249,6 @@ MODULE_LICENSE ("GPL");#define PLATFORM_DRIVER ohci_hcd_jz4740_driver#endif -#ifdef CONFIG_USB_OCTEON_OHCI -#include "ohci-octeon.c" -#define PLATFORM_DRIVER ohci_octeon_driver -#endif -#ifdef CONFIG_TILE_USB #include "ohci-tilegx.c" #define PLATFORM_DRIVER ohci_hcd_tilegx_driver
drivers/usb/host/ohci-octeon.c deleted +0 -202
202 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH 1/3] USB: host: Remove ehci-octeon and ohci-octeon drivers
Quoted 3 lines · Andreas Herrmann
From: Alan Stern <[email protected]>
From: Alan Stern <[email protected]>
Is there an echo?
Is there an echo?
Quoted 12 lines
Remove special-purpose octeon drivers and instead use ehci-platform and ohci-platform as suggested with
http://marc.info/?l=linux-mips&m=140139694721623&w=2[andreas.herrmann:
fixed compile error]Cc David Daney <[email protected]>Cc Alex Smith <[email protected]>Cc Alan Stern <[email protected]>Signed-off-by Alan Stern <[email protected]>Signed-off-by Andreas Herrmann <[email protected]>
Quoted 14 lines
--- 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 | 188 -------------------- drivers/usb/host/octeon2-common.c | 200 --------------------- drivers/usb/host/ohci-hcd.c | 5 - drivers/usb/host/ohci-octeon.c | 202 --------------------- 9 files changed, 285 insertions(+), 611 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
For the MIPS bits:
For the MIPS bits:
Ralf
Ralf
Re: [PATCH 1/3] USB: host: Remove ehci-octeon and ohci-octeon drivers
Quoted 7 lines · Ralf Baechle
Quoted 3 lines · Andreas Herrmann
From: Alan Stern <[email protected]>
From: Alan Stern <[email protected]>
Is there an echo?
Oops.
Quoted 1 line
Is there an echo?
LOL.
Quoted 31 lines
Quoted 12 lines
Remove special-purpose octeon drivers and instead use ehci-platform and ohci-platform as suggested with
http://marc.info/?l=linux-mips&m=140139694721623&w=2[andreas.herrmann:
fixed compile error]Cc David Daney <[email protected]>Cc Alex Smith <[email protected]>Cc Alan Stern <[email protected]>Signed-off-by Alan Stern <[email protected]>Signed-off-by Andreas Herrmann <[email protected]>Quoted 14 lines
--- 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 | 188 -------------------- drivers/usb/host/octeon2-common.c | 200 --------------------- drivers/usb/host/ohci-hcd.c | 5 - drivers/usb/host/ohci-octeon.c | 202 --------------------- 9 files changed, 285 insertions(+), 611 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.cFor the MIPS bits:
For the MIPS bits:
Quoted 7 lines
Acked-by Ralf Baechle <[email protected]>Acked-by Ralf Baechle <[email protected]>Ralf
Ralf
Double thanks,
Andreas
Re: [PATCH 1/3] USB: host: Remove ehci-octeon and ohci-octeon drivers
In reply to Andreas HerrmannQuoted 15 lines · Andreas Herrmann
From: Alan Stern <[email protected]>
Remove special-purpose octeon drivers and instead use ehci-platform and ohci-platform as suggested with
http://marc.info/?l=linux-mips&m=140139694721623&w=2[andreas.herrmann:
fixed compile error]Cc David Daney <[email protected]>Cc Alex Smith <[email protected]>Signed-off-by Alan Stern <[email protected]>Signed-off-by Andreas Herrmann <[email protected]>Acked-by Ralf Baechle <[email protected]>Tested-by Aaro Koskinen <[email protected]>
Quoted 14 lines
--- 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 | 188 -------------------- drivers/usb/host/octeon2-common.c | 200 --------------------- drivers/usb/host/ohci-hcd.c | 5 - drivers/usb/host/ohci-octeon.c | 202 --------------------- 9 files changed, 285 insertions(+), 611 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
This doesn't apply to my usb-next or usb-testing branch of usb.git on git.kernel.org, so I can't apply it :(
Re: [PATCH 1/3] USB: host: Remove ehci-octeon and ohci-octeon drivers
Quoted 31 lines · Greg KH
Quoted 15 lines · Andreas Herrmann
From: Alan Stern <[email protected]>
Remove special-purpose octeon drivers and instead use ehci-platform and ohci-platform as suggested with
http://marc.info/?l=linux-mips&m=140139694721623&w=2[andreas.herrmann:
fixed compile error]Cc David Daney <[email protected]>Cc Alex Smith <[email protected]>Signed-off-by Alan Stern <[email protected]>Signed-off-by Andreas Herrmann <[email protected]>Acked-by Ralf Baechle <[email protected]>Tested-by Aaro Koskinen <[email protected]>Quoted 14 lines
--- 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 | 188 -------------------- drivers/usb/host/octeon2-common.c | 200 --------------------- drivers/usb/host/ohci-hcd.c | 5 - drivers/usb/host/ohci-octeon.c | 202 --------------------- 9 files changed, 285 insertions(+), 611 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
Quoted 2 lines
This doesn't apply to my usb-next or usb-testing branch of usb.git on git.kernel.org, so I can't apply it :(
Sorry, I need to rebase it (on usb-next).
Andreas
PATCH v2 1/3 USB: host: Remove ehci-octeon and ohci-octeon drivers
From: Alan Stern <[email protected]>
Remove special-purpose octeon drivers and instead use ehci-platform and ohci-platform as suggested with
http://marc.info/?l=linux-mips&m=140139694721623&w=2
[andreas.herrmann:
fixed compile error]
--- 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 commits073153bf22764 (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
arch/mips/cavium-octeon/octeon-platform.c +272 -2
@@ -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 =64000000000ull /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 () /130000000ull ; + +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 : +case 11 : + div =8 ; +break ; +default : + div =12 ; +break ; + } + clk_rst_ctl.s.h_div = div; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); +/* Read it back, */ + clk_rst_ctl.u64 =cvmx_read_csr (CVMX_UCTLX_CLK_RST_CTL (0 )); + clk_rst_ctl.s.h_clkdiv_en =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); +/* 3d */ + clk_rst_ctl.s.h_clkdiv_rst =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* 3e: delay 64 io clocks */ +ndelay (io_clk_64_to_ns); + +/* +* Step 4: Program the power-on reset field in the UCTL +* clock-reset-control register. +*/ + clk_rst_ctl.s.p_por =0 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* Step 5: Wait 1 ms for the PHY clock to start. */ +mdelay (1 ); + +/* +* Step 6: Program the reset input from automatic test +* equipment field in the UPHY CSR +*/ + uphy_ctl_status.u64 =cvmx_read_csr (CVMX_UCTLX_UPHY_CTL_STATUS (0 )); + uphy_ctl_status.s.ate_reset =1 ; +cvmx_write_csr (CVMX_UCTLX_UPHY_CTL_STATUS (0 ), uphy_ctl_status.u64); + +/* Step 7: Wait for at least 10ns. */ +ndelay (10 ); + +/* Step 8: Clear the ATE_RESET field in the UPHY CSR. */ + uphy_ctl_status.s.ate_reset =0 ; +cvmx_write_csr (CVMX_UCTLX_UPHY_CTL_STATUS (0 ), uphy_ctl_status.u64); + +/* +* Step 9: Wait for at least 20ns for UPHY to output PHY clock +* signals and OHCI_CLK48 +*/ +ndelay (20 ); + +/* Step 10: Configure the OHCI_CLK48 and OHCI_CLK12 clocks. */ +/* 10a */ + clk_rst_ctl.s.o_clkdiv_rst =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* 10b */ + clk_rst_ctl.s.o_clkdiv_en =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* 10c */ +ndelay (io_clk_64_to_ns); + +/* +* Step 11: Program the PHY reset field: +* UCTL0_CLK_RST_CTL[P_PRST] = 1 +*/ + clk_rst_ctl.s.p_prst =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +/* Step 12: Wait 1 uS. */ +udelay (1 ); + +/* Step 13: Program the HRESET_N field: UCTL0_CLK_RST_CTL[HRST] = 1 */ + clk_rst_ctl.s.hrst =1 ; +cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64); + +end_clock: +/* Now we can set some other registers. */ + +for (i =0 ; i <=1 ; i++) { + port_ctl_status.u64 = +cvmx_read_csr (CVMX_UCTLX_UPHY_PORTX_CTL_STATUS (i,0 )); +/* Set txvreftune to 15 to obtain compliant 'eye' diagram. */ + port_ctl_status.s.txvreftune =15 ; + port_ctl_status.s.txrisetune =1 ; + port_ctl_status.s.txpreemphasistune =1 ; +cvmx_write_csr (CVMX_UCTLX_UPHY_PORTX_CTL_STATUS (i,0 ), + port_ctl_status.u64); + } + +/* Set uSOF cycle period to 60,000 bits. */ +cvmx_write_csr (CVMX_UCTLX_EHCI_FLA (0 ),0x20ull ); +exit: +mutex_unlock (&octeon2_usb_clocks_mutex); +} + +static void octeon2_usb_clocks_stop (void ) +{ +mutex_lock (&octeon2_usb_clocks_mutex); + octeon2_usb_clock_start_cnt--; +mutex_unlock (&octeon2_usb_clocks_mutex); +} + +static int octeon_ehci_power_on (struct platform_device *pdev) +{ +octeon2_usb_clocks_start (); +return 0 ; +} + +static void octeon_ehci_power_off (struct platform_device *pdev) +{ +octeon2_usb_clocks_stop (); +} + +static struct usb_ehci_pdata octeon_ehci_pdata = { +/* Octeon EHCI matches CPU endianness. */ +#ifdef __BIG_ENDIAN + .big_endian_mmio =1 , +#endif + .power_on = octeon_ehci_power_on, + .power_off = octeon_ehci_power_off, +}; + +static void __init octeon_ehci_hw_start (void ) +{ +union cvmx_uctlx_ehci_ctl ehci_ctl; + +octeon2_usb_clocks_start (); + + ehci_ctl.u64 =cvmx_read_csr (CVMX_UCTLX_EHCI_CTL (0 )); +/* Use 64-bit addressing. */ + ehci_ctl.s.ehci_64b_addr_en =1 ; + ehci_ctl.s.l2c_addr_msb =0 ; + ehci_ctl.s.l2c_buff_emod =1 ;/* Byte swapped. */ + ehci_ctl.s.l2c_desc_emod =1 ;/* Byte swapped. */ +cvmx_write_csr (CVMX_UCTLX_EHCI_CTL (0 ), ehci_ctl.u64); + +octeon2_usb_clocks_stop (); +} + +static u64 octeon_ehci_dma_mask =DMA_BIT_MASK (64 ); +static int __init octeon_ehci_device_init (void ) {struct platform_device *pd;
@@ -88,7 +316,7 @@ static int __init octeon_ehci_device_init(void)if (octeon_is_simulation () ||usb_disabled ())return 0 ;/* No USB in the simulator. */ - pd =platform_device_alloc ("octeon-ehci" ,0 ); + pd =platform_device_alloc ("ehci-platform" ,0 );if (!pd) { ret = -ENOMEM ; goto out;
@@ -105,6 +333,10 @@ static int __init octeon_ehci_device_init(void)if (ret) goto fail; + pd->dev.dma_mask = &octeon_ehci_dma_mask; + pd->dev.platform_data = &octeon_ehci_pdata; +octeon_ehci_hw_start (); + ret =platform_device_add (pd);if (ret) goto fail;
@@ -117,6 +349,41 @@ out: }device_initcall (octeon_ehci_device_init); +static int octeon_ohci_power_on (struct platform_device *pdev) +{ +octeon2_usb_clocks_start (); +return 0 ; +} + +static void octeon_ohci_power_off (struct platform_device *pdev) +{ +octeon2_usb_clocks_stop (); +} + +static struct usb_ohci_pdata octeon_ohci_pdata = { +/* Octeon OHCI matches CPU endianness. */ +#ifdef __BIG_ENDIAN + .big_endian_mmio =1 , +#endif + .power_on = octeon_ohci_power_on, + .power_off = octeon_ohci_power_off, +}; + +static void __init octeon_ohci_hw_start (void ) +{ +union cvmx_uctlx_ohci_ctl ohci_ctl; + +octeon2_usb_clocks_start (); + + ohci_ctl.u64 =cvmx_read_csr (CVMX_UCTLX_OHCI_CTL (0 )); + ohci_ctl.s.l2c_addr_msb =0 ; + ohci_ctl.s.l2c_buff_emod =1 ;/* Byte swapped. */ + ohci_ctl.s.l2c_desc_emod =1 ;/* Byte swapped. */ +cvmx_write_csr (CVMX_UCTLX_OHCI_CTL (0 ), ohci_ctl.u64); + +octeon2_usb_clocks_stop (); +} +static int __init octeon_ohci_device_init (void ) {struct platform_device *pd;
@@ -137,7 +404,7 @@ static int __init octeon_ohci_device_init(void)if (octeon_is_simulation () ||usb_disabled ())return 0 ;/* No USB in the simulator. */ - pd =platform_device_alloc ("octeon-ohci" ,0 ); + pd =platform_device_alloc ("ohci-platform" ,0 );if (!pd) { ret = -ENOMEM ; goto out;
@@ -154,6 +421,9 @@ static int __init octeon_ohci_device_init(void)if (ret) goto fail; + pd->dev.platform_data = &octeon_ohci_pdata; +octeon_ohci_hw_start (); + ret =platform_device_add (pd);if (ret) goto fail;
arch/mips/configs/cavium_octeon_defconfig +3 -0
@@ -120,6 +120,9 @@ CONFIG_SPI_OCTEON=y # CONFIG_HWMON is not set CONFIG_WATCHDOG=y # CONFIG_USB_SUPPORT is not set +CONFIG_USB_EHCI_BIG_ENDIAN_MMIO=y +CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y +CONFIG_USB_OHCI_LITTLE_ENDIAN=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_DS1307=y CONFIG_STAGING=y
drivers/usb/host/Kconfig +10 -8
@@ -292,11 +292,15 @@ config USB_EHCI_HCD_PLATFORM If unsure, say N. config USB_OCTEON_EHCI - bool "Octeon on-chip EHCI support" + bool "Octeon on-chip EHCI support (DEPRECATED)" depends on CAVIUM_OCTEON_SOC default n select USB_EHCI_BIG_ENDIAN_MMIO + select USB_EHCI_HCD_PLATFORM help + This option is deprecated now and the driver was removed, use + USB_EHCI_HCD_PLATFORM instead. + Enable support for the Octeon II SOC's on-chip EHCI controller. It is needed for high-speed (480Mbit/sec) USB 2.0 device support. All CN6XXX based chips with USB are
@@ -575,12 +579,16 @@ config USB_OHCI_HCD_PLATFORM If unsure, say N. config USB_OCTEON_OHCI - bool "Octeon on-chip OHCI support" + bool "Octeon on-chip OHCI support (DEPRECATED)" depends on CAVIUM_OCTEON_SOC default USB_OCTEON_EHCI select USB_OHCI_BIG_ENDIAN_MMIO select USB_OHCI_LITTLE_ENDIAN + select USB_OHCI_HCD_PLATFORM help + This option is deprecated now and the driver was removed, use + USB_OHCI_HCD_PLATFORM instead. + Enable support for the Octeon II SOC's on-chip OHCI controller. It is needed for low-speed USB 1.0 device support. All CN6XXX based chips with USB are supported.
@@ -754,12 +762,6 @@ config USB_IMX21_HCD To compile this driver as a module, choose M here: the module will be called "imx21-hcd". - - -config USB_OCTEON2_COMMON - bool - default y if USB_OCTEON_EHCI || USB_OCTEON_OHCI - config USB_HCD_BCMA tristate "BCMA usb host driver" depends on BCMA
drivers/usb/host/Makefile +0 -1
@@ -73,7 +73,6 @@ obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o -obj-$(CONFIG_USB_OCTEON2_COMMON) += octeon2-common.o obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o obj-$(CONFIG_USB_FUSBH200_HCD) += fusbh200-hcd.o
drivers/usb/host/ehci-hcd.c +0 -5
@@ -1275,11 +1275,6 @@ MODULE_LICENSE ("GPL");#define XILINX_OF_PLATFORM_DRIVER ehci_hcd_xilinx_of_driver#endif -#ifdef CONFIG_USB_OCTEON_EHCI -#include "ehci-octeon.c" -#define PLATFORM_DRIVER ehci_octeon_driver -#endif -#ifdef CONFIG_TILE_USB #include "ehci-tilegx.c" #define PLATFORM_DRIVER ehci_hcd_tilegx_driver
drivers/usb/host/ehci-octeon.c deleted +0 -182
182 lines not on this page · raw message
drivers/usb/host/octeon2-common.c deleted +0 -200
200 lines not on this page · raw message
drivers/usb/host/ohci-hcd.c +0 -5
@@ -1249,11 +1249,6 @@ MODULE_LICENSE ("GPL");#define PLATFORM_DRIVER ohci_hcd_jz4740_driver#endif -#ifdef CONFIG_USB_OCTEON_OHCI -#include "ohci-octeon.c" -#define PLATFORM_DRIVER ohci_octeon_driver -#endif -#ifdef CONFIG_TILE_USB #include "ohci-tilegx.c" #define PLATFORM_DRIVER ohci_hcd_tilegx_driver
drivers/usb/host/ohci-octeon.c deleted +0 -196
196 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH 1/3 v2] USB: host: Remove ehci-octeon and ohci-octeon drivers
Quoted 31 lines · Andreas Herrmann
From: Alan Stern <[email protected]>
Remove special-purpose octeon drivers and instead use ehci-platform and ohci-platform as suggested with
http://marc.info/?l=linux-mips&m=140139694721623&w=2[andreas.herrmann:
fixed compile error]Cc David Daney <[email protected]>Cc Alex Smith <[email protected]>Signed-off-by Alan Stern <[email protected]>Signed-off-by Andreas Herrmann <[email protected]>Acked-by Ralf Baechle <[email protected]>Tested-by Aaro Koskinen <[email protected]>--- 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
Quoted 8 lines
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
PATCH 2/3 USB: host: Remove hard-coded octeon platform information for ehci/ohci
In reply to Andreas HerrmannInstead rely on device tree information for ehci and ohci.
This was suggested with
http://www.linux-mips.org/archives/linux-mips/2014-05/msg00307.html
"The device tree will *always* have correct ehci/ohci clock configuration, so use it. This allows us to remove a big chunk of platform configuration code from octeon-platform.c."
More or less I rebased that patch on Alan's work to remove ehci-octeon and ohci-octeon drivers.
--- arch/mips/cavium-octeon/octeon-platform.c | 148 ++++++++++++----------------- drivers/usb/host/ehci-platform.c | 1 + drivers/usb/host/ohci-platform.c | 1 + 3 files changed, 64 insertions(+), 86 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +62 -86
@@ -77,7 +77,7 @@ static DEFINE_MUTEX(octeon2_usb_clocks_mutex);static int octeon2_usb_clock_start_cnt; -static void octeon2_usb_clocks_start (void ) +static void octeon2_usb_clocks_start (struct device *dev) {u64 div;union cvmx_uctlx_if_ena if_ena;
@@ -86,6 +86,8 @@ static void octeon2_usb_clocks_start(void)union cvmx_uctlx_uphy_portx_ctl_status port_ctl_status;int i;unsigned long io_clk_64_to_ns; +u32 clock_rate =12000000 ; +bool is_crystal_clock = false;mutex_lock (&octeon2_usb_clocks_mutex);
@@ -96,6 +98,28 @@ static void octeon2_usb_clocks_start(void) io_clk_64_to_ns =64000000000ull /octeon_get_io_clock_rate (); +if (dev->of_node) { +struct device_node *uctl_node; +const char *clock_type; + + uctl_node =of_get_parent (dev->of_node); +if (!uctl_node) { +dev_err (dev,"No UCTL device node\n" ); + goto exit; + } + i =of_property_read_u32 (uctl_node, +"refclk-frequency" , &clock_rate); +if (i) { +dev_err (dev,"No UCTL \"refclk-frequency\"\n" ); + goto exit; + } + i =of_property_read_string (uctl_node, +"refclk-type" , &clock_type); + +if (!i &&strcmp ("crystal" , clock_type) ==0 ) + is_crystal_clock = true; + } +/* * Step 1: Wait for voltages stable. That surely happened * before starting the kernel.
@@ -126,9 +150,22 @@ static void octeon2_usb_clocks_start(void)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 ; + clk_rst_ctl.s.p_refclk_sel = is_crystal_clock ?0 :1 ; +switch (clock_rate) { +default : +pr_err ("Invalid UCTL clock rate of %u, using 12000000 instead\n" , + clock_rate); +/* Fall through */ +case 12000000 : + clk_rst_ctl.s.p_refclk_div =0 ; +break ; +case 24000000 : + clk_rst_ctl.s.p_refclk_div =1 ; +break ; +case 48000000 : + clk_rst_ctl.s.p_refclk_div =2 ; +break ; + }cvmx_write_csr (CVMX_UCTLX_CLK_RST_CTL (0 ), clk_rst_ctl.u64);/* 3c */
@@ -259,7 +296,7 @@ static void octeon2_usb_clocks_stop(void)static int octeon_ehci_power_on (struct platform_device *pdev) { -octeon2_usb_clocks_start (); +octeon2_usb_clocks_start (&pdev->dev);return 0 ; }
@@ -277,11 +314,11 @@ static struct usb_ehci_pdata octeon_ehci_pdata = { .power_off = octeon_ehci_power_off, }; -static void __init octeon_ehci_hw_start (void ) +static void __init octeon_ehci_hw_start (struct device *dev) {union cvmx_uctlx_ehci_ctl ehci_ctl; -octeon2_usb_clocks_start (); +octeon2_usb_clocks_start (dev); ehci_ctl.u64 =cvmx_read_csr (CVMX_UCTLX_EHCI_CTL (0 ));/* Use 64-bit addressing. */
@@ -299,59 +336,28 @@ static u64 octeon_ehci_dma_mask = DMA_BIT_MASK(64);static int __init octeon_ehci_device_init (void ) {struct platform_device *pd; +struct device_node *ehci_node;int ret =0 ; -struct resource usb_resources[] = { - { - .flags =IORESOURCE_MEM , - }, { - .flags =IORESOURCE_IRQ , - } - }; - -/* Only Octeon2 has ehci/ohci */ -if (!OCTEON_IS_MODEL (OCTEON_CN63XX )) + ehci_node =of_find_node_by_name (NULL ,"ehci" ); +if (!ehci_node)return 0 ; -if (octeon_is_simulation () ||usb_disabled ()) -return 0 ;/* No USB in the simulator. */ - - pd =platform_device_alloc ("ehci-platform" ,0 ); -if (!pd) { - ret = -ENOMEM ; - goto out; - } - - usb_resources[0 ].start =0x00016F0000000000ULL ; - usb_resources[0 ].end = usb_resources[0 ].start +0x100 ; - - usb_resources[1 ].start =OCTEON_IRQ_USB0 ; - usb_resources[1 ].end =OCTEON_IRQ_USB0 ; - - ret =platform_device_add_resources (pd, usb_resources, -ARRAY_SIZE (usb_resources)); -if (ret) - goto fail; + pd =of_find_device_by_node (ehci_node); +if (!pd) +return 0 ; pd->dev.dma_mask = &octeon_ehci_dma_mask; pd->dev.platform_data = &octeon_ehci_pdata; -octeon_ehci_hw_start (); - - ret =platform_device_add (pd); -if (ret) - goto fail; +octeon_ehci_hw_start (&pd->dev);return ret; -fail: -platform_device_put (pd); -out: -return ret; }device_initcall (octeon_ehci_device_init);static int octeon_ohci_power_on (struct platform_device *pdev) { -octeon2_usb_clocks_start (); +octeon2_usb_clocks_start (&pdev->dev);return 0 ; }
@@ -369,11 +375,11 @@ static struct usb_ohci_pdata octeon_ohci_pdata = { .power_off = octeon_ohci_power_off, }; -static void __init octeon_ohci_hw_start (void ) +static void __init octeon_ohci_hw_start (struct device *dev) {union cvmx_uctlx_ohci_ctl ohci_ctl; -octeon2_usb_clocks_start (); +octeon2_usb_clocks_start (dev); ohci_ctl.u64 =cvmx_read_csr (CVMX_UCTLX_OHCI_CTL (0 )); ohci_ctl.s.l2c_addr_msb =0 ;
@@ -387,57 +393,27 @@ static void __init octeon_ohci_hw_start(void)static int __init octeon_ohci_device_init (void ) {struct platform_device *pd; +struct device_node *ohci_node;int ret =0 ; -struct resource usb_resources[] = { - { - .flags =IORESOURCE_MEM , - }, { - .flags =IORESOURCE_IRQ , - } - }; - -/* Only Octeon2 has ehci/ohci */ -if (!OCTEON_IS_MODEL (OCTEON_CN63XX )) + ohci_node =of_find_node_by_name (NULL ,"ohci" ); +if (!ohci_node)return 0 ; -if (octeon_is_simulation () ||usb_disabled ()) -return 0 ;/* No USB in the simulator. */ - - pd =platform_device_alloc ("ohci-platform" ,0 ); -if (!pd) { - ret = -ENOMEM ; - goto out; - } - - usb_resources[0 ].start =0x00016F0000000400ULL ; - usb_resources[0 ].end = usb_resources[0 ].start +0x100 ; - - usb_resources[1 ].start =OCTEON_IRQ_USB0 ; - usb_resources[1 ].end =OCTEON_IRQ_USB0 ; - - ret =platform_device_add_resources (pd, usb_resources, -ARRAY_SIZE (usb_resources)); -if (ret) - goto fail; + pd =of_find_device_by_node (ohci_node); +if (!pd) +return 0 ; pd->dev.platform_data = &octeon_ohci_pdata; -octeon_ohci_hw_start (); - - ret =platform_device_add (pd); -if (ret) - goto fail; +octeon_ohci_hw_start (&pd->dev);return ret; -fail: -platform_device_put (pd); -out: -return ret; }device_initcall (octeon_ohci_device_init);#endif /* CONFIG_USB */ +static struct of_device_id __initdata octeon_ids[] = { { .compatible ="simple-bus" , }, { .compatible ="cavium,octeon-6335-uctl" , },
drivers/usb/host/ehci-platform.c +1 -0
@@ -358,6 +358,7 @@ static const struct of_device_id vt8500_ehci_ids[] = { { .compatible = "via,vt8500-ehci", }, { .compatible = "wm,prizm-ehci", }, { .compatible = "generic-ehci", }, + { .compatible = "cavium,octeon-6335-ehci", }, {} }; MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);
drivers/usb/host/ohci-platform.c +1 -0
@@ -343,6 +343,7 @@ static int ohci_platform_resume(struct device *dev)static const struct of_device_id ohci_platform_ids[] = { { .compatible ="generic-ohci" , }, + { .compatible ="cavium,octeon-6335-ohci" , }, { } };MODULE_DEVICE_TABLE (of, ohci_platform_ids);
Signature · 1 line
1.7.9.5
Re: [PATCH 2/3] USB: host: Remove hard-coded octeon platform information for ehci/ohci
Quoted 9 lines · Andreas Herrmann
Instead rely on device tree information for ehci and ohci.
This was suggested with
http://www.linux-mips.org/archives/linux-mips/2014-05/msg00307.html"The device tree will *always* have correct ehci/ohci clock configuration, so use it. This allows us to remove a big chunk of platform configuration code from
octeon-platform.c."
Quoted 7 lines
More or less I rebased that patch on Alan's work to remove ehci-octeon and ohci-octeon drivers.
Cc David Daney <[email protected]>Cc Alex Smith <[email protected]>Cc Alan Stern <[email protected]>Signed-off-by Andreas Herrmann <[email protected]>
For the MIPS bits:
Ralf
PATCH 3/3 USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform
In reply to Andreas Herrmannehci-octeon driver used a 64-bit dma_mask. With removal of ehci-octeon and usage of ehci-platform ehci dma_mask is now limited to 32 bits (coerced in ehci_platform_probe).
Provide a flag in ehci platform data to allow use of 64 bits for dma_mask.
--- arch/mips/cavium-octeon/octeon-platform.c | 4 +--- drivers/usb/host/ehci-platform.c | 3 ++- include/linux/usb/ehci_pdriver.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +1 -3
@@ -310,6 +310,7 @@ static struct usb_ehci_pdata octeon_ehci_pdata = {#ifdef __BIG_ENDIAN .big_endian_mmio = 1, #endif + .dma_mask_64 = 1, .power_on = octeon_ehci_power_on, .power_off = octeon_ehci_power_off, };
@@ -331,8 +332,6 @@ static void __init octeon_ehci_hw_start(struct device *dev)octeon2_usb_clocks_stop (); } -static u64 octeon_ehci_dma_mask =DMA_BIT_MASK (64 ); -static int __init octeon_ehci_device_init (void ) {struct platform_device *pd;
@@ -347,7 +346,6 @@ static int __init octeon_ehci_device_init(void)if (!pd)return 0 ; - pd->dev.dma_mask = &octeon_ehci_dma_mask; pd->dev.platform_data = &octeon_ehci_pdata;octeon_ehci_hw_start (&pd->dev);
drivers/usb/host/ehci-platform.c +2 -1
@@ -155,7 +155,8 @@ static int ehci_platform_probe(struct platform_device *dev)if (!pdata) pdata = &ehci_platform_defaults; - err =dma_coerce_mask_and_coherent (&dev->dev,DMA_BIT_MASK (32 )); + err =dma_coerce_mask_and_coherent (&dev->dev, + pdata->dma_mask_64 ?DMA_BIT_MASK (64 ) :DMA_BIT_MASK (32 ));if (err)return err;
include/linux/usb/ehci_pdriver.h +1 -0
@@ -45,6 +45,7 @@ struct usb_ehci_pdata { unsigned big_endian_desc:1; unsigned big_endian_mmio:1; unsigned no_io_watchdog:1; + unsigned dma_mask_64:1;/* Turn on all power and clocks */ int (*power_on)(struct platform_device *pdev);
Signature · 1 line
1.7.9.5
Re: [PATCH 3/3] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform
2014-11-13 13:36 GMT-08:00 Andreas Herrmann
<[email protected]>:
Quoted 6 lines
ehci-octeon driver used a 64-bit
dma_mask. With removal of ehci-octeon and usage of ehci-platform ehcidma_maskis now limited to 32 bits (coerced inehci_platform_probe).Provide a flag in ehci platform data to allow use of 64 bits for
dma_mask.
Why not just allow enforcing an arbitrary DMA mask?
Quoted 70 lines
Cc David Daney <[email protected]>Cc Alex Smith <[email protected]>Cc Alan Stern <[email protected]>Signed-off-by Andreas Herrmann <[email protected]>--- arch/mips/cavium-octeon/octeon-platform.c | 4 +--- drivers/usb/host/ehci-platform.c | 3 ++- include/linux/usb/ehci_pdriver.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-)arch/mips/cavium-octeon/octeon-platform.c +1
-3@@ -310,6 +310,7 @@ static struct usb_ehci_pdata octeon_ehci_pdata = {#ifdef __BIG_ENDIAN .big_endian_mmio = 1, #endif + .dma_mask_64 = 1, .power_on = octeon_ehci_power_on, .power_off = octeon_ehci_power_off, };@@ -331,8 +332,6 @@ static void __init octeon_ehci_hw_start(struct device *dev)octeon2_usb_clocks_stop (); } -static u64 octeon_ehci_dma_mask =DMA_BIT_MASK (64 ); -static int __init octeon_ehci_device_init (void ) {struct platform_device *pd;@@ -347,7 +346,6 @@ static int __init octeon_ehci_device_init(void)if (!pd)return 0 ; - pd->dev.dma_mask = &octeon_ehci_dma_mask; pd->dev.platform_data = &octeon_ehci_pdata;octeon_ehci_hw_start (&pd->dev);drivers/usb/host/ehci-platform.c +2
-1@@ -155,7 +155,8 @@ static int ehci_platform_probe(struct platform_device *dev)if (!pdata) pdata = &ehci_platform_defaults; - err =dma_coerce_mask_and_coherent (&dev->dev,DMA_BIT_MASK (32 )); + err =dma_coerce_mask_and_coherent (&dev->dev, + pdata->dma_mask_64 ?DMA_BIT_MASK (64 ) :DMA_BIT_MASK (32 ));if (err)return err;include/linux/usb/ehci_pdriver.h +1
-1@@ -45,6 +45,7 @@ struct usb_ehci_pdata { unsigned big_endian_desc:1; unsigned big_endian_mmio:1; unsigned no_io_watchdog:1; + unsigned dma_mask_64:1;/* Turn on all power and clocks */ int (*power_on)(struct platform_device *pdev); --1.7.9.5
Signature · 1 line
Florian
Re: [PATCH 3/3] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform
Quoted 10 lines · Florian Fainelli
2014-11-13 13:36 GMT-08:00 Andreas Herrmann
<[email protected]>:Quoted 6 lines
ehci-octeon driver used a 64-bit
dma_mask. With removal of ehci-octeon and usage of ehci-platform ehcidma_maskis now limited to 32 bits (coerced inehci_platform_probe).Provide a flag in ehci platform data to allow use of 64 bits for
dma_mask.Why not just allow enforcing an arbitrary DMA mask?
I thought about that but as it's currently just 32 or 64 bits a flag is sufficient. (At the moment I am not aware that other ehci-platform devices would require something else.)
I'll change the flag to a mask if desired.
Alan, what's your opinion about this?
Andreas
Quoted 74 lines
Quoted 69 lines
Cc David Daney <[email protected]>Cc Alex Smith <[email protected]>Cc Alan Stern <[email protected]>Signed-off-by Andreas Herrmann <[email protected]>--- arch/mips/cavium-octeon/octeon-platform.c | 4 +--- drivers/usb/host/ehci-platform.c | 3 ++- include/linux/usb/ehci_pdriver.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-)arch/mips/cavium-octeon/octeon-platform.c +1
-3@@ -310,6 +310,7 @@ static struct usb_ehci_pdata octeon_ehci_pdata = {#ifdef __BIG_ENDIAN .big_endian_mmio = 1, #endif + .dma_mask_64 = 1, .power_on = octeon_ehci_power_on, .power_off = octeon_ehci_power_off, };@@ -331,8 +332,6 @@ static void __init octeon_ehci_hw_start(struct device *dev)octeon2_usb_clocks_stop (); } -static u64 octeon_ehci_dma_mask =DMA_BIT_MASK (64 ); -static int __init octeon_ehci_device_init (void ) {struct platform_device *pd;@@ -347,7 +346,6 @@ static int __init octeon_ehci_device_init(void)if (!pd)return 0 ; - pd->dev.dma_mask = &octeon_ehci_dma_mask; pd->dev.platform_data = &octeon_ehci_pdata;octeon_ehci_hw_start (&pd->dev);drivers/usb/host/ehci-platform.c +2
-1@@ -155,7 +155,8 @@ static int ehci_platform_probe(struct platform_device *dev)if (!pdata) pdata = &ehci_platform_defaults; - err =dma_coerce_mask_and_coherent (&dev->dev,DMA_BIT_MASK (32 )); + err =dma_coerce_mask_and_coherent (&dev->dev, + pdata->dma_mask_64 ?DMA_BIT_MASK (64 ) :DMA_BIT_MASK (32 ));if (err)return err;include/linux/usb/ehci_pdriver.h +1
-1@@ -45,6 +45,7 @@ struct usb_ehci_pdata { unsigned big_endian_desc:1; unsigned big_endian_mmio:1; unsigned no_io_watchdog:1; + unsigned dma_mask_64:1;/* Turn on all power and clocks */ int (*power_on)(struct platform_device *pdev); --1.7.9.5
Signature · 1 line
Florian
Alan Stern
maintainerRe: [PATCH 3/3] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform
Quoted 10 lines · Andreas Herrmann
Quoted 9 lines · Florian Fainelli
2014-11-13 13:36 GMT-08:00 Andreas Herrmann
<[email protected]>:Quoted 6 lines
ehci-octeon driver used a 64-bit
dma_mask. With removal of ehci-octeon and usage of ehci-platform ehcidma_maskis now limited to 32 bits (coerced inehci_platform_probe).Provide a flag in ehci platform data to allow use of 64 bits for
dma_mask.
Quoted 8 lines
Quoted 1 line
Why not just allow enforcing an arbitrary DMA mask?
I thought about that but as it's currently just 32 or 64 bits a flag is sufficient. (At the moment I am not aware that other ehci-platform devices would require something else.)
I'll change the flag to a mask if desired.
Alan, what's your opinion about this?
I'm not aware of any devices that need a different DMA mask either.
Florian, do you have any reason for thinking such a thing might come along? Like Andreas, I don't mind making it more general if there's a good reason to do so.
Alan Stern
Re: [PATCH 3/3] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform
Quoted 18 lines · Alan Stern
Quoted 16 lines · Andreas Herrmann
Quoted 10 lines · Florian Fainelli
2014-11-13 13:36 GMT-08:00 Andreas Herrmann
<[email protected]>:Quoted 6 lines
ehci-octeon driver used a 64-bit
dma_mask. With removal of ehci-octeon and usage of ehci-platform ehcidma_maskis now limited to 32 bits (coerced inehci_platform_probe).Provide a flag in ehci platform data to allow use of 64 bits for
dma_mask.Why not just allow enforcing an arbitrary DMA mask?
I thought about that but as it's currently just 32 or 64 bits a flag is sufficient. (At the moment I am not aware that other ehci-platform devices would require something else.)
Quoted 8 lines
Quoted 2 lines
I'll change the flag to a mask if desired.
Alan, what's your opinion about this?I'm not aware of any devices that need a different DMA mask either.
Florian, do you have any reason for thinking such a thing might come along? Like Andreas, I don't mind making it more general if there's a good reason to do so.
I don't have a specific platform I am thinking about, just that while we are there allowing a dma_mask to be specified, I would rather pass an u64 that covers all possible cases.
Thanks!
--
Florian
Alan Stern
maintainerQuoted 31 lines · Andreas Herrmann
Hi Alan,
With following patches I want to base octeon ehci/ohci device configuration on device tree information.
I picked up patches that were submitted in May. See
http://marc.info/?l=linux-usb&m=140135823325811&w=2
and http://marc.info/?l=linux-mips&m=140139694721623&w=2Patch #1 is your "untested preliminary pass" to remove
[oe]hci-octeon drivers.
Patch #2 is the removal of hard-coded platform information (but now
rebased on your patch)
Patch #3 adaptsdma_maskfor ehci (as used in ehci-octeon)Overall diffstat is
arch/mips/cavium-octeon/octeon-platform.c | 380 +++++++++++++++++++++++------ 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 | 188 -------------- drivers/usb/host/ehci-platform.c | 4 +- drivers/usb/host/octeon2-common.c | 200 --------------- drivers/usb/host/ohci-hcd.c | 5 - drivers/usb/host/ohci-octeon.c | 202 --------------- drivers/usb/host/ohci-platform.c | 1 + include/linux/usb/ehci_pdriver.h | 1 + 12 files changed, 330 insertions(+), 678 deletions(-)
Quoted 3 lines
Patches are based on v3.18-rc4-65-g2c54396
Comments welcome.
At a very quick first glance, it looks great. Have you tested it thoroughly?
Alan Stern
Quoted 33 lines · Alan Stern
Quoted 31 lines · Andreas Herrmann
Hi Alan,
With following patches I want to base octeon ehci/ohci device configuration on device tree information.
I picked up patches that were submitted in May. See
http://marc.info/?l=linux-usb&m=140135823325811&w=2
and http://marc.info/?l=linux-mips&m=140139694721623&w=2Patch #1 is your "untested preliminary pass" to remove
[oe]hci-octeon drivers.
Patch #2 is the removal of hard-coded platform information (but now
rebased on your patch)
Patch #3 adaptsdma_maskfor ehci (as used in ehci-octeon)Overall diffstat is
arch/mips/cavium-octeon/octeon-platform.c | 380 +++++++++++++++++++++++------ 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 | 188 -------------- drivers/usb/host/ehci-platform.c | 4 +- drivers/usb/host/octeon2-common.c | 200 --------------- drivers/usb/host/ohci-hcd.c | 5 - drivers/usb/host/ohci-octeon.c | 202 --------------- drivers/usb/host/ohci-platform.c | 1 + include/linux/usb/ehci_pdriver.h | 1 + 12 files changed, 330 insertions(+), 678 deletions(-)
Quoted 6 lines
Quoted 3 lines
Patches are based on v3.18-rc4-65-g2c54396
Comments welcome.
At a very quick first glance, it looks great. Have you tested it thoroughly?
[sorry have to use another mail account, so far your mail didn't show
up at my caviumnetworks account]
I've tested it only on an EdgeRouterPro (Octeon II system, which I have on-site).
octeon_ehci_device_init and octeon_ohci_device_init run way before ehci-platform and ohci-platform probe for devices. So everything should be initialized orderly.
With current mainline (w/o these patches) USB doesn't work on my EdgeRouterPro due to an (inappropriate) OCTEON_IS_MODEL check.
I'd say having the patches in linux-next for awhile wouldn't hurt.
Andreas
Aaro Koskinen
Tested-byQuoted 9 lines · Andreas Herrmann
Quoted 2 lines · Alan Stern
At a very quick first glance, it looks great. Have you tested it thoroughly?
[sorry have to use another mail account, so far your mail didn't show
up at my caviumnetworks account]I've tested it only on an EdgeRouterPro (Octeon II system, which I have on-site).
I have also tested them on EdgeRouter Pro. Thanks, this is great improvement.
A.