2013-07-15 18:06:55 +08:00
|
|
|
From 40b9d3026ed0b3bcd59f90391195df5b2adabad2 Mon Sep 17 00:00:00 2001
|
|
|
|
From: John Crispin <blogic@openwrt.org>
|
|
|
|
Date: Sun, 14 Jul 2013 23:34:53 +0200
|
|
|
|
Subject: [PATCH 19/33] USB: add OHCI/EHCI OF binding
|
|
|
|
|
|
|
|
based on f3bc64d6d1f21c1b92d75f233a37b75d77af6963
|
|
|
|
|
|
|
|
Signed-off-by: John Crispin <blogic@openwrt.org>
|
|
|
|
---
|
|
|
|
arch/mips/ralink/Kconfig | 2 ++
|
|
|
|
drivers/usb/Makefile | 3 ++-
|
|
|
|
drivers/usb/host/ehci-platform.c | 19 +++++++++++++++----
|
|
|
|
drivers/usb/host/ohci-platform.c | 37 ++++++++++++++++++++++++++++++++-----
|
|
|
|
4 files changed, 51 insertions(+), 10 deletions(-)
|
|
|
|
|
2013-07-16 05:05:47 +08:00
|
|
|
Index: linux-3.10.1/arch/mips/ralink/Kconfig
|
|
|
|
===================================================================
|
|
|
|
--- linux-3.10.1.orig/arch/mips/ralink/Kconfig 2013-07-15 17:35:28.021178556 +0200
|
|
|
|
+++ linux-3.10.1/arch/mips/ralink/Kconfig 2013-07-15 20:00:19.501385660 +0200
|
|
|
|
@@ -24,6 +24,8 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
|
|
|
|
config SOC_MT7620
|
|
|
|
bool "MT7620"
|
|
|
|
+ select USB_ARCH_HAS_OHCI
|
|
|
|
+ select USB_ARCH_HAS_EHCI
|
|
|
|
select HW_HAS_PCI
|
|
|
|
|
|
|
|
endchoice
|
2013-07-16 05:05:47 +08:00
|
|
|
Index: linux-3.10.1/drivers/usb/Makefile
|
|
|
|
===================================================================
|
|
|
|
--- linux-3.10.1.orig/drivers/usb/Makefile 2013-07-13 20:42:41.000000000 +0200
|
|
|
|
+++ linux-3.10.1/drivers/usb/Makefile 2013-07-15 19:47:26.725367249 +0200
|
|
|
|
@@ -10,6 +10,8 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
|
|
|
|
obj-$(CONFIG_USB_MON) += mon/
|
|
|
|
|
2013-07-16 05:05:47 +08:00
|
|
|
+obj-$(CONFIG_USB_PHY) += phy/
|
2013-07-15 18:06:55 +08:00
|
|
|
+
|
|
|
|
obj-$(CONFIG_PCI) += host/
|
|
|
|
obj-$(CONFIG_USB_EHCI_HCD) += host/
|
|
|
|
obj-$(CONFIG_USB_ISP116X_HCD) += host/
|
2013-07-16 05:05:47 +08:00
|
|
|
@@ -44,7 +46,6 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
obj-$(CONFIG_USB_SERIAL) += serial/
|
|
|
|
|
|
|
|
obj-$(CONFIG_USB) += misc/
|
|
|
|
-obj-$(CONFIG_USB_PHY) += phy/
|
|
|
|
obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/
|
|
|
|
|
|
|
|
obj-$(CONFIG_USB_ATM) += atm/
|
2013-07-16 05:05:47 +08:00
|
|
|
Index: linux-3.10.1/drivers/usb/host/ehci-platform.c
|
|
|
|
===================================================================
|
|
|
|
--- linux-3.10.1.orig/drivers/usb/host/ehci-platform.c 2013-07-15 17:35:22.761178428 +0200
|
|
|
|
+++ linux-3.10.1/drivers/usb/host/ehci-platform.c 2013-07-15 19:47:14.525366961 +0200
|
|
|
|
@@ -29,6 +29,8 @@
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/usb/hcd.h>
|
|
|
|
#include <linux/usb/ehci_pdriver.h>
|
|
|
|
+#include <linux/usb/phy.h>
|
|
|
|
+#include <linux/usb/otg.h>
|
|
|
|
|
|
|
|
#include "ehci.h"
|
|
|
|
|
|
|
|
@@ -118,6 +120,15 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
hcd->rsrc_start = res_mem->start;
|
|
|
|
hcd->rsrc_len = resource_size(res_mem);
|
|
|
|
|
2013-07-16 05:05:47 +08:00
|
|
|
+#ifdef CONFIG_USB_PHY
|
2013-07-15 18:06:55 +08:00
|
|
|
+ hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
|
|
|
|
+ if (!IS_ERR_OR_NULL(hcd->phy)) {
|
|
|
|
+ otg_set_host(hcd->phy->otg,
|
|
|
|
+ &hcd->self);
|
|
|
|
+ usb_phy_init(hcd->phy);
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
|
|
|
|
if (IS_ERR(hcd->regs)) {
|
|
|
|
err = PTR_ERR(hcd->regs);
|
2013-07-16 05:05:47 +08:00
|
|
|
@@ -155,6 +166,9 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
if (pdata == &ehci_platform_defaults)
|
|
|
|
dev->dev.platform_data = NULL;
|
|
|
|
|
|
|
|
+ if (pdata == &ehci_platform_defaults)
|
|
|
|
+ dev->dev.platform_data = NULL;
|
|
|
|
+
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-16 05:05:47 +08:00
|
|
|
@@ -199,9 +213,8 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
#define ehci_platform_resume NULL
|
|
|
|
#endif /* CONFIG_PM */
|
|
|
|
|
|
|
|
-static const struct of_device_id vt8500_ehci_ids[] = {
|
|
|
|
- { .compatible = "via,vt8500-ehci", },
|
|
|
|
- { .compatible = "wm,prizm-ehci", },
|
|
|
|
+static const struct of_device_id ralink_ehci_ids[] = {
|
|
|
|
+ { .compatible = "ralink,rt3xxx-ehci", },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2013-07-16 05:05:47 +08:00
|
|
|
@@ -225,7 +238,7 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "ehci-platform",
|
|
|
|
.pm = &ehci_platform_pm_ops,
|
|
|
|
- .of_match_table = of_match_ptr(vt8500_ehci_ids),
|
|
|
|
+ .of_match_table = of_match_ptr(ralink_ehci_ids),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-07-16 05:05:47 +08:00
|
|
|
Index: linux-3.10.1/drivers/usb/host/ohci-platform.c
|
|
|
|
===================================================================
|
|
|
|
--- linux-3.10.1.orig/drivers/usb/host/ohci-platform.c 2013-07-13 20:42:41.000000000 +0200
|
|
|
|
+++ linux-3.10.1/drivers/usb/host/ohci-platform.c 2013-07-15 19:55:15.913378428 +0200
|
2013-07-15 18:06:55 +08:00
|
|
|
@@ -16,6 +16,10 @@
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/usb/ohci_pdriver.h>
|
|
|
|
+#include <linux/dma-mapping.h>
|
|
|
|
+#include <linux/of.h>
|
|
|
|
+
|
|
|
|
+static struct usb_ohci_pdata ohci_platform_defaults;
|
|
|
|
|
|
|
|
static int ohci_platform_reset(struct usb_hcd *hcd)
|
|
|
|
{
|
2013-07-16 05:05:47 +08:00
|
|
|
@@ -88,14 +92,22 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
{
|
|
|
|
struct usb_hcd *hcd;
|
|
|
|
struct resource *res_mem;
|
|
|
|
- struct usb_ohci_pdata *pdata = dev->dev.platform_data;
|
|
|
|
+ struct usb_ohci_pdata *pdata;
|
|
|
|
int irq;
|
|
|
|
int err = -ENOMEM;
|
|
|
|
|
|
|
|
- if (!pdata) {
|
|
|
|
- WARN_ON(1);
|
|
|
|
- return -ENODEV;
|
|
|
|
- }
|
|
|
|
+ /*
|
|
|
|
+ * use reasonable defaults so platforms don't have to provide these.
|
|
|
|
+ * with DT probing on ARM, none of these are set.
|
|
|
|
+ */
|
|
|
|
+ if (!dev->dev.platform_data)
|
|
|
|
+ dev->dev.platform_data = &ohci_platform_defaults;
|
|
|
|
+ if (!dev->dev.dma_mask)
|
|
|
|
+ dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
|
|
|
|
+ if (!dev->dev.coherent_dma_mask)
|
|
|
|
+ dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
|
|
|
|
+
|
|
|
|
+ pdata = dev->dev.platform_data;
|
|
|
|
|
|
|
|
if (usb_disabled())
|
|
|
|
return -ENODEV;
|
2013-07-16 05:05:47 +08:00
|
|
|
@@ -128,6 +140,12 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
hcd->rsrc_start = res_mem->start;
|
|
|
|
hcd->rsrc_len = resource_size(res_mem);
|
|
|
|
|
2013-07-16 05:05:47 +08:00
|
|
|
+#ifdef CONFIG_USB_PHY
|
2013-07-15 18:06:55 +08:00
|
|
|
+ hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
|
|
|
|
+ if (!IS_ERR_OR_NULL(hcd->phy))
|
|
|
|
+ usb_phy_init(hcd->phy);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
|
|
|
|
if (IS_ERR(hcd->regs)) {
|
|
|
|
err = PTR_ERR(hcd->regs);
|
2013-07-16 05:05:47 +08:00
|
|
|
@@ -162,6 +180,9 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
if (pdata->power_off)
|
|
|
|
pdata->power_off(dev);
|
|
|
|
|
|
|
|
+ if (pdata == &ohci_platform_defaults)
|
|
|
|
+ dev->dev.platform_data = NULL;
|
|
|
|
+
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-16 05:05:47 +08:00
|
|
|
@@ -201,6 +222,11 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
#define ohci_platform_resume NULL
|
|
|
|
#endif /* CONFIG_PM */
|
|
|
|
|
|
|
|
+static const struct of_device_id ralink_ohci_ids[] = {
|
|
|
|
+ { .compatible = "ralink,rt3xxx-ohci", },
|
|
|
|
+ {}
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
static const struct platform_device_id ohci_platform_table[] = {
|
|
|
|
{ "ohci-platform", 0 },
|
|
|
|
{ }
|
2013-07-16 05:05:47 +08:00
|
|
|
@@ -221,5 +247,6 @@
|
2013-07-15 18:06:55 +08:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "ohci-platform",
|
|
|
|
.pm = &ohci_platform_pm_ops,
|
|
|
|
+ .of_match_table = of_match_ptr(ralink_ohci_ids),
|
|
|
|
}
|
|
|
|
};
|