Openwrt/target/linux/ramips/patches-3.14/0038-USB-add-OHCI-EHCI-OF-binding.patch
John Crispin 843fc45e27 ralink: fix mt7620 ohci 3.14
the ohci phy was not reset properly

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 42291
2014-08-25 16:31:05 +00:00

190 lines
5.3 KiB
Diff

From ffb27de4760595c356ef619c97f25722c8db28e7 Mon Sep 17 00:00:00 2001
From: John Crispin <blogic@openwrt.org>
Date: Sun, 27 Jul 2014 09:49:07 +0100
Subject: [PATCH 38/57] USB: add OHCI/EHCI OF binding
based on f3bc64d6d1f21c1b92d75f233a37b75d77af6963
Signed-off-by: John Crispin <blogic@openwrt.org>
---
drivers/usb/Makefile | 3 ++-
drivers/usb/host/ehci-platform.c | 21 +++++++++++++++++----
drivers/usb/host/ohci-platform.c | 37 +++++++++++++++++++++++++++++++------
3 files changed, 50 insertions(+), 11 deletions(-)
Index: linux-3.14.16/drivers/usb/Makefile
===================================================================
--- linux-3.14.16.orig/drivers/usb/Makefile 2014-08-08 01:50:59.000000000 +0200
+++ linux-3.14.16/drivers/usb/Makefile 2014-08-24 14:33:57.590539754 +0200
@@ -11,6 +11,8 @@
obj-$(CONFIG_USB_MON) += mon/
+obj-$(CONFIG_USB_PHY) += phy/
+
obj-$(CONFIG_PCI) += host/
obj-$(CONFIG_USB_EHCI_HCD) += host/
obj-$(CONFIG_USB_ISP116X_HCD) += host/
@@ -41,7 +43,6 @@
obj-$(CONFIG_USB_STORAGE) += storage/
obj-$(CONFIG_USB) += storage/
-obj-$(CONFIG_USB_MDC800) += image/
obj-$(CONFIG_USB_MICROTEK) += image/
obj-$(CONFIG_USB_SERIAL) += serial/
Index: linux-3.14.16/drivers/usb/host/ehci-platform.c
===================================================================
--- linux-3.14.16.orig/drivers/usb/host/ehci-platform.c 2014-08-24 12:39:18.806371411 +0200
+++ linux-3.14.16/drivers/usb/host/ehci-platform.c 2014-08-24 12:39:21.102371467 +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"
@@ -124,6 +126,15 @@
hcd->rsrc_start = res_mem->start;
hcd->rsrc_len = resource_size(res_mem);
+#ifdef CONFIG_USB_PHY
+ 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);
@@ -161,6 +172,9 @@
if (pdata == &ehci_platform_defaults)
dev->dev.platform_data = NULL;
+ if (pdata == &ehci_platform_defaults)
+ dev->dev.platform_data = NULL;
+
return 0;
}
@@ -205,9 +219,8 @@
#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", },
{}
};
@@ -231,7 +244,7 @@
.owner = THIS_MODULE,
.name = "ehci-platform",
.pm = &ehci_platform_pm_ops,
- .of_match_table = vt8500_ehci_ids,
+ .of_match_table = ralink_ehci_ids,
}
};
Index: linux-3.14.16/drivers/usb/host/ohci-platform.c
===================================================================
--- linux-3.14.16.orig/drivers/usb/host/ohci-platform.c 2014-08-08 01:50:59.000000000 +0200
+++ linux-3.14.16/drivers/usb/host/ohci-platform.c 2014-08-24 12:41:51.422375146 +0200
@@ -22,18 +22,22 @@
#include <linux/platform_device.h>
#include <linux/usb/ohci_pdriver.h>
#include <linux/usb.h>
+#include <linux/usb/phy.h>
#include <linux/usb/hcd.h>
+#include <linux/dma-mapping.h>
+#include <linux/of.h>
#include "ohci.h"
#define DRIVER_DESC "OHCI generic platform driver"
+static struct usb_ohci_pdata ohci_platform_defaults;
static const char hcd_name[] = "ohci-platform";
static int ohci_platform_reset(struct usb_hcd *hcd)
{
struct platform_device *pdev = to_platform_device(hcd->self.controller);
- struct usb_ohci_pdata *pdata = dev_get_platdata(&pdev->dev);
+ struct usb_ohci_pdata *pdata = dev_get_platdata(&pdev->dev);;
struct ohci_hcd *ohci = hcd_to_ohci(hcd);
if (pdata->big_endian_desc)
@@ -63,11 +67,18 @@
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;
@@ -99,6 +110,12 @@
hcd->rsrc_start = res_mem->start;
hcd->rsrc_len = resource_size(res_mem);
+#ifdef CONFIG_USB_PHY
+ 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);
@@ -134,6 +151,9 @@
if (pdata->power_off)
pdata->power_off(dev);
+ if (pdata == &ohci_platform_defaults)
+ dev->dev.platform_data = NULL;
+
return 0;
}
@@ -180,6 +200,11 @@
#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 },
{ }
@@ -200,6 +225,7 @@
.owner = THIS_MODULE,
.name = "ohci-platform",
.pm = &ohci_platform_pm_ops,
+ .of_match_table = of_match_ptr(ralink_ohci_ids),
}
};