[PATCH 09/25] MIPS: Octeon: use ehci-platform driver

From: Florian Fainelli
Date: Wed Oct 03 2012 - 11:46:23 EST


Signed-off-by: Florian Fainelli <florian@xxxxxxxxxxx>
---
arch/mips/cavium-octeon/octeon-platform.c | 43 ++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index 0938df1..539e1bc 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -18,9 +18,11 @@
#include <linux/of_platform.h>
#include <linux/of_fdt.h>
#include <linux/libfdt.h>
+#include <linux/usb/ehci_pdriver.h>

#include <asm/octeon/octeon.h>
#include <asm/octeon/cvmx-rnm-defs.h>
+#include <asm/octeon/cvmx-uctlx-defs.h>
#include <asm/octeon/cvmx-helper.h>
#include <asm/octeon/cvmx-helper-board.h>

@@ -169,6 +171,41 @@ out:
device_initcall(octeon_rng_device_init);

#ifdef CONFIG_USB
+void octeon2_usb_clocks_start(void);
+void octeon2_usb_clocks_stop(void);
+
+static int octeon_ehci_power_on(struct platform_device *pdev)
+{
+ 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);
+
+ return 0;
+}
+
+static void octeon_ehci_power_off(struct platform_device *pdev)
+{
+ octeon2_usb_clocks_stop();
+}
+
+static struct usb_ehci_pdata octeon_ehci_pdata = {
+#ifdef __BIG_ENDIAN
+ .big_endian_mmio = 1,
+#endif
+ .port_power_on = 1,
+ .power_on = octeon_ehci_power_on,
+ .power_off = octeon_ehci_power_off,
+};
+
+static u64 octeon_ehci_dma_mask = DMA_BIT_MASK(64);

static int __init octeon_ehci_device_init(void)
{
@@ -190,7 +227,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;
@@ -207,6 +244,10 @@ static int __init octeon_ehci_device_init(void)
if (ret)
goto fail;

+ pd.dev.platform_data = &octeon_ehci_pdata;
+ pd.dev.coherent_dma_mask = DMA_BIT_MASK(32);
+ pd.dev.dma_mask = &octeon_ehci_dma_mask;
+
ret = platform_device_add(pd);
if (ret)
goto fail;
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/