All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/3] Make ohci-platform usable for omap3/4/5
@ 2017-05-22 16:00 Tony Lindgren
       [not found] ` <20170522160007.9264-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Tony Lindgren @ 2017-05-22 16:00 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

Hi,

Here's v2 of this series.

Regards,

Tony

Changes since v1:

- Update runtime PM support for ohci based on Alan's comments and
  more testing

- Just remove ohci-omap3 as it needs LS/FS USB PHY not available
  on most hardware

Tony Lindgren (3):
  usb: host: ohci-platform: Add basic runtime PM support
  usb: host: ohci-platform: Add support for omap3 and later
  usb: host: ohci-omap3: Remove driver in favor of ohci-platform

 Documentation/devicetree/bindings/usb/usb-ohci.txt |   1 +
 drivers/usb/host/Kconfig                           |   6 +-
 drivers/usb/host/Makefile                          |   1 -
 drivers/usb/host/ohci-omap3.c                      | 211 ---------------------
 drivers/usb/host/ohci-platform.c                   |  22 ++-
 5 files changed, 27 insertions(+), 214 deletions(-)
 delete mode 100644 drivers/usb/host/ohci-omap3.c

-- 
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support
       [not found] ` <20170522160007.9264-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2017-05-22 16:00   ` Tony Lindgren
       [not found]     ` <20170522160007.9264-2-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2017-05-22 16:00   ` [PATCH 2/3] usb: host: ohci-platform: Add support for omap3 and later Tony Lindgren
  2017-05-22 16:00   ` [PATCH 3/3] usb: host: ohci-omap3: Remove driver in favor of ohci-platform Tony Lindgren
  2 siblings, 1 reply; 14+ messages in thread
From: Tony Lindgren @ 2017-05-22 16:00 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, Rob Herring,
	Roger Quadros, Sebastian Reichel, Yoshihiro Shimoda

This is needed in preparation of adding support for omap3 and
later OHCI. The runtime PM will only do something on platforms
that implement it.

Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Cc: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
---

Alan, do you have some better ideas for the ohci_platform_remove()
path below?

---
 drivers/usb/host/ohci-platform.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/reset.h>
 #include <linux/usb/ohci_pdriver.h>
 #include <linux/usb.h>
@@ -242,6 +243,8 @@ static int ohci_platform_probe(struct platform_device *dev)
 	}
 #endif
 
+	pm_runtime_set_active(&dev->dev);
+	pm_runtime_enable(&dev->dev);
 	if (pdata->power_on) {
 		err = pdata->power_on(dev);
 		if (err < 0)
@@ -271,6 +274,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 	if (pdata->power_off)
 		pdata->power_off(dev);
 err_reset:
+	pm_runtime_disable(&dev->dev);
 	while (--rst >= 0)
 		reset_control_assert(priv->resets[rst]);
 err_put_clks:
@@ -290,7 +294,14 @@ static int ohci_platform_remove(struct platform_device *dev)
 	struct usb_hcd *hcd = platform_get_drvdata(dev);
 	struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
 	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
-	int clk, rst;
+	int clk, rst, enabled;
+
+	enabled = pm_runtime_get_sync(&dev->dev);
+	if (enabled < 0) {
+		dev_warn(&dev->dev, "pm_runtime_get failed: %i\n",
+			 enabled);
+		pm_runtime_put_noidle(&dev->dev);
+	}
 
 	usb_remove_hcd(hcd);
 
@@ -305,6 +316,10 @@ static int ohci_platform_remove(struct platform_device *dev)
 
 	usb_put_hcd(hcd);
 
+	if (enabled >= 0)
+		pm_runtime_put_sync(&dev->dev);
+	pm_runtime_disable(&dev->dev);
+
 	if (pdata == &ohci_platform_defaults)
 		dev->dev.platform_data = NULL;
 
-- 
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2/3] usb: host: ohci-platform: Add support for omap3 and later
       [not found] ` <20170522160007.9264-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2017-05-22 16:00   ` [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support Tony Lindgren
@ 2017-05-22 16:00   ` Tony Lindgren
       [not found]     ` <20170522160007.9264-3-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2017-05-22 16:00   ` [PATCH 3/3] usb: host: ohci-omap3: Remove driver in favor of ohci-platform Tony Lindgren
  2 siblings, 1 reply; 14+ messages in thread
From: Tony Lindgren @ 2017-05-22 16:00 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, Rob Herring,
	Yoshihiro Shimoda, Sebastian Reichel

With the runtime PM implemented for ohci-platform driver, we can
now support omap3 and later OHCI by adding one device tree
property.

Cc: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
Cc: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
Acked-by: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
Acked-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
---
 Documentation/devicetree/bindings/usb/usb-ohci.txt | 1 +
 drivers/usb/host/ohci-platform.c                   | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/usb-ohci.txt b/Documentation/devicetree/bindings/usb/usb-ohci.txt
--- a/Documentation/devicetree/bindings/usb/usb-ohci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-ohci.txt
@@ -10,6 +10,7 @@ Optional properties:
 - big-endian-desc : boolean, set this for hcds with big-endian descriptors
 - big-endian : boolean, for hcds with big-endian-regs + big-endian-desc
 - no-big-frame-no : boolean, set if frame_no lives in bits [15:0] of HCCA
+- remote-wakeup-connected: remote wakeup is wired on the platform
 - num-ports : u32, to override the detected port count
 - clocks : a list of phandle + clock specifier pairs
 - phys : phandle + phy specifier pair
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -164,6 +164,10 @@ static int ohci_platform_probe(struct platform_device *dev)
 		if (of_property_read_bool(dev->dev.of_node, "no-big-frame-no"))
 			ohci->flags |= OHCI_QUIRK_FRAME_NO;
 
+		if (of_property_read_bool(dev->dev.of_node,
+					  "remote-wakeup-connected"))
+			ohci->hc_control = OHCI_CTRL_RWC;
+
 		of_property_read_u32(dev->dev.of_node, "num-ports",
 				     &ohci->num_ports);
 
@@ -365,6 +369,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", },
+	{ .compatible = "ti,ohci-omap3", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ohci_platform_ids);
-- 
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 3/3] usb: host: ohci-omap3: Remove driver in favor of ohci-platform
       [not found] ` <20170522160007.9264-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2017-05-22 16:00   ` [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support Tony Lindgren
  2017-05-22 16:00   ` [PATCH 2/3] usb: host: ohci-platform: Add support for omap3 and later Tony Lindgren
@ 2017-05-22 16:00   ` Tony Lindgren
       [not found]     ` <20170522160007.9264-4-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2 siblings, 1 reply; 14+ messages in thread
From: Tony Lindgren @ 2017-05-22 16:00 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Roger Quadros,
	Sebastian Reichel

This driver is no longer needed and can be removed. The reason why
it's safe to remove this driver is that most omap devices don't have a
USB low-speed or full-speed compatible PHY installed and configured
with drivers/mfd/omap-usb-host.c. This means that devices like
beagleboard and pandaboard need to use a high-speed USB hub in order
to use devices like keyboard and mice.

Currently the only known configured for a full-speed PHY is the
mdm6600 modem on droid 4 and I've verified it works just fine with
ohci-platform.

Cc: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Cc: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
---
 drivers/usb/host/Kconfig      |   6 +-
 drivers/usb/host/Makefile     |   1 -
 drivers/usb/host/ohci-omap3.c | 211 ------------------------------------------
 3 files changed, 5 insertions(+), 213 deletions(-)
 delete mode 100644 drivers/usb/host/ohci-omap3.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -473,8 +473,12 @@ config USB_OHCI_HCD_AT91
 config USB_OHCI_HCD_OMAP3
 	tristate "OHCI support for OMAP3 and later chips"
 	depends on (ARCH_OMAP3 || ARCH_OMAP4 || SOC_OMAP5)
+	select USB_OHCI_HCD_PLATFORM
 	default y
-	---help---
+	help
+	  This option is deprecated now and the driver was removed, use
+	  USB_OHCI_HCD_PLATFORM instead.
+
 	  Enables support for the on-chip OHCI controller on
 	  OMAP3 and later chips.
 
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -52,7 +52,6 @@ obj-$(CONFIG_USB_OHCI_HCD_PCI)	+= ohci-pci.o
 obj-$(CONFIG_USB_OHCI_HCD_PLATFORM)	+= ohci-platform.o
 obj-$(CONFIG_USB_OHCI_EXYNOS)	+= ohci-exynos.o
 obj-$(CONFIG_USB_OHCI_HCD_OMAP1)	+= ohci-omap.o
-obj-$(CONFIG_USB_OHCI_HCD_OMAP3)	+= ohci-omap3.o
 obj-$(CONFIG_USB_OHCI_HCD_SPEAR)	+= ohci-spear.o
 obj-$(CONFIG_USB_OHCI_HCD_STI)	+= ohci-st.o
 obj-$(CONFIG_USB_OHCI_HCD_AT91)	+= ohci-at91.o
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
deleted file mode 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * ohci-omap3.c - driver for OHCI on OMAP3 and later processors
- *
- * Bus Glue for OMAP3 USBHOST 3 port OHCI controller
- * This controller is also used in later OMAPs and AM35x chips
- *
- * Copyright (C) 2007-2010 Texas Instruments, Inc.
- * Author: Vikram Pandita <vikram.pandita-l0cyMroinI0@public.gmane.org>
- * Author: Anand Gadiyar <gadiyar-l0cyMroinI0@public.gmane.org>
- * Author: Keshava Munegowda <keshava_mgowda-l0cyMroinI0@public.gmane.org>
- *
- * Based on ehci-omap.c and some other ohci glue layers
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
- * TODO (last updated Feb 27, 2011):
- *	- add kernel-doc
- */
-
-#include <linux/dma-mapping.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/usb/otg.h>
-#include <linux/platform_device.h>
-#include <linux/pm_runtime.h>
-#include <linux/usb.h>
-#include <linux/usb/hcd.h>
-
-#include "ohci.h"
-
-#define DRIVER_DESC "OHCI OMAP3 driver"
-
-static const char hcd_name[] = "ohci-omap3";
-static struct hc_driver __read_mostly ohci_omap3_hc_driver;
-
-/*
- * configure so an HC device and id are always provided
- * always called with process context; sleeping is OK
- */
-
-/**
- * ohci_hcd_omap3_probe - initialize OMAP-based HCDs
- *
- * Allocates basic resources for this USB host controller, and
- * then invokes the start() method for the HCD associated with it
- * through the hotplug entry's driver_data.
- */
-static int ohci_hcd_omap3_probe(struct platform_device *pdev)
-{
-	struct device		*dev = &pdev->dev;
-	struct ohci_hcd		*ohci;
-	struct usb_hcd		*hcd = NULL;
-	void __iomem		*regs = NULL;
-	struct resource		*res;
-	int			ret;
-	int			irq;
-
-	if (usb_disabled())
-		return -ENODEV;
-
-	if (!dev->parent) {
-		dev_err(dev, "Missing parent device\n");
-		return -ENODEV;
-	}
-
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0) {
-		dev_err(dev, "OHCI irq failed\n");
-		return -ENODEV;
-	}
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "UHH OHCI get resource failed\n");
-		return -ENOMEM;
-	}
-
-	regs = ioremap(res->start, resource_size(res));
-	if (!regs) {
-		dev_err(dev, "UHH OHCI ioremap failed\n");
-		return -ENOMEM;
-	}
-
-	/*
-	 * Right now device-tree probed devices don't get dma_mask set.
-	 * Since shared usb code relies on it, set it here for now.
-	 * Once we have dma capability bindings this can go away.
-	 */
-	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
-	if (ret)
-		goto err_io;
-
-	ret = -ENODEV;
-	hcd = usb_create_hcd(&ohci_omap3_hc_driver, dev,
-			dev_name(dev));
-	if (!hcd) {
-		dev_err(dev, "usb_create_hcd failed\n");
-		goto err_io;
-	}
-
-	hcd->rsrc_start = res->start;
-	hcd->rsrc_len = resource_size(res);
-	hcd->regs =  regs;
-
-	pm_runtime_enable(dev);
-	pm_runtime_get_sync(dev);
-
-	ohci = hcd_to_ohci(hcd);
-	/*
-	 * RemoteWakeupConnected has to be set explicitly before
-	 * calling ohci_run. The reset value of RWC is 0.
-	 */
-	ohci->hc_control = OHCI_CTRL_RWC;
-
-	ret = usb_add_hcd(hcd, irq, 0);
-	if (ret) {
-		dev_dbg(dev, "failed to add hcd with err %d\n", ret);
-		goto err_add_hcd;
-	}
-	device_wakeup_enable(hcd->self.controller);
-
-	return 0;
-
-err_add_hcd:
-	pm_runtime_put_sync(dev);
-	usb_put_hcd(hcd);
-
-err_io:
-	iounmap(regs);
-
-	return ret;
-}
-
-/*
- * may be called without controller electrically present
- * may be called with controller, bus, and devices active
- */
-
-/**
- * ohci_hcd_omap3_remove - shutdown processing for OHCI HCDs
- * @pdev: USB Host Controller being removed
- *
- * Reverses the effect of ohci_hcd_omap3_probe(), first invoking
- * the HCD's stop() method.  It is always called from a thread
- * context, normally "rmmod", "apmd", or something similar.
- */
-static int ohci_hcd_omap3_remove(struct platform_device *pdev)
-{
-	struct device *dev	= &pdev->dev;
-	struct usb_hcd *hcd	= dev_get_drvdata(dev);
-
-	iounmap(hcd->regs);
-	usb_remove_hcd(hcd);
-	pm_runtime_put_sync(dev);
-	pm_runtime_disable(dev);
-	usb_put_hcd(hcd);
-	return 0;
-}
-
-static const struct of_device_id omap_ohci_dt_ids[] = {
-	{ .compatible = "ti,ohci-omap3" },
-	{ }
-};
-
-MODULE_DEVICE_TABLE(of, omap_ohci_dt_ids);
-
-static struct platform_driver ohci_hcd_omap3_driver = {
-	.probe		= ohci_hcd_omap3_probe,
-	.remove		= ohci_hcd_omap3_remove,
-	.shutdown	= usb_hcd_platform_shutdown,
-	.driver		= {
-		.name	= "ohci-omap3",
-		.of_match_table = omap_ohci_dt_ids,
-	},
-};
-
-static int __init ohci_omap3_init(void)
-{
-	if (usb_disabled())
-		return -ENODEV;
-
-	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
-
-	ohci_init_driver(&ohci_omap3_hc_driver, NULL);
-	return platform_driver_register(&ohci_hcd_omap3_driver);
-}
-module_init(ohci_omap3_init);
-
-static void __exit ohci_omap3_cleanup(void)
-{
-	platform_driver_unregister(&ohci_hcd_omap3_driver);
-}
-module_exit(ohci_omap3_cleanup);

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/3] usb: host: ohci-platform: Add support for omap3 and later
       [not found]     ` <20170522160007.9264-3-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2017-05-22 16:03       ` Tony Lindgren
  0 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2017-05-22 16:03 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, Rob Herring,
	Yoshihiro Shimoda, Sebastian Reichel

* Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> [170522 09:03]:
> With the runtime PM implemented for ohci-platform driver, we can
> now support omap3 and later OHCI by adding one device tree
> property.

And the related dts patch from v1 series I can queue separately when
people are happy with the driver changes.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] usb: host: ohci-omap3: Remove driver in favor of ohci-platform
       [not found]     ` <20170522160007.9264-4-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2017-05-23  7:08       ` Roger Quadros
  2017-05-23  8:58       ` Sebastian Reichel
  2017-05-23 16:56       ` Alan Stern
  2 siblings, 0 replies; 14+ messages in thread
From: Roger Quadros @ 2017-05-23  7:08 UTC (permalink / raw)
  To: Tony Lindgren, Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Sebastian Reichel

On 22/05/17 19:00, Tony Lindgren wrote:
> This driver is no longer needed and can be removed. The reason why
> it's safe to remove this driver is that most omap devices don't have a
> USB low-speed or full-speed compatible PHY installed and configured
> with drivers/mfd/omap-usb-host.c. This means that devices like
> beagleboard and pandaboard need to use a high-speed USB hub in order
> to use devices like keyboard and mice.
> 
> Currently the only known configured for a full-speed PHY is the
> mdm6600 modem on droid 4 and I've verified it works just fine with
> ohci-platform.
> 
> Cc: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
> Cc: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
> Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>

Acked-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>

> ---
>  drivers/usb/host/Kconfig      |   6 +-
>  drivers/usb/host/Makefile     |   1 -
>  drivers/usb/host/ohci-omap3.c | 211 ------------------------------------------
>  3 files changed, 5 insertions(+), 213 deletions(-)
>  delete mode 100644 drivers/usb/host/ohci-omap3.c
> 
> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -473,8 +473,12 @@ config USB_OHCI_HCD_AT91
>  config USB_OHCI_HCD_OMAP3
>  	tristate "OHCI support for OMAP3 and later chips"
>  	depends on (ARCH_OMAP3 || ARCH_OMAP4 || SOC_OMAP5)
> +	select USB_OHCI_HCD_PLATFORM
>  	default y
> -	---help---
> +	help
> +	  This option is deprecated now and the driver was removed, use
> +	  USB_OHCI_HCD_PLATFORM instead.
> +
>  	  Enables support for the on-chip OHCI controller on
>  	  OMAP3 and later chips.
>  
> diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
> --- a/drivers/usb/host/Makefile
> +++ b/drivers/usb/host/Makefile
> @@ -52,7 +52,6 @@ obj-$(CONFIG_USB_OHCI_HCD_PCI)	+= ohci-pci.o
>  obj-$(CONFIG_USB_OHCI_HCD_PLATFORM)	+= ohci-platform.o
>  obj-$(CONFIG_USB_OHCI_EXYNOS)	+= ohci-exynos.o
>  obj-$(CONFIG_USB_OHCI_HCD_OMAP1)	+= ohci-omap.o
> -obj-$(CONFIG_USB_OHCI_HCD_OMAP3)	+= ohci-omap3.o
>  obj-$(CONFIG_USB_OHCI_HCD_SPEAR)	+= ohci-spear.o
>  obj-$(CONFIG_USB_OHCI_HCD_STI)	+= ohci-st.o
>  obj-$(CONFIG_USB_OHCI_HCD_AT91)	+= ohci-at91.o
> diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
> deleted file mode 100644
> --- a/drivers/usb/host/ohci-omap3.c
> +++ /dev/null
> @@ -1,211 +0,0 @@
> -/*
> - * ohci-omap3.c - driver for OHCI on OMAP3 and later processors
> - *
> - * Bus Glue for OMAP3 USBHOST 3 port OHCI controller
> - * This controller is also used in later OMAPs and AM35x chips
> - *
> - * Copyright (C) 2007-2010 Texas Instruments, Inc.
> - * Author: Vikram Pandita <vikram.pandita-l0cyMroinI0@public.gmane.org>
> - * Author: Anand Gadiyar <gadiyar-l0cyMroinI0@public.gmane.org>
> - * Author: Keshava Munegowda <keshava_mgowda-l0cyMroinI0@public.gmane.org>
> - *
> - * Based on ehci-omap.c and some other ohci glue layers
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
> - *
> - * TODO (last updated Feb 27, 2011):
> - *	- add kernel-doc
> - */
> -
> -#include <linux/dma-mapping.h>
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/of.h>
> -#include <linux/usb/otg.h>
> -#include <linux/platform_device.h>
> -#include <linux/pm_runtime.h>
> -#include <linux/usb.h>
> -#include <linux/usb/hcd.h>
> -
> -#include "ohci.h"
> -
> -#define DRIVER_DESC "OHCI OMAP3 driver"
> -
> -static const char hcd_name[] = "ohci-omap3";
> -static struct hc_driver __read_mostly ohci_omap3_hc_driver;
> -
> -/*
> - * configure so an HC device and id are always provided
> - * always called with process context; sleeping is OK
> - */
> -
> -/**
> - * ohci_hcd_omap3_probe - initialize OMAP-based HCDs
> - *
> - * Allocates basic resources for this USB host controller, and
> - * then invokes the start() method for the HCD associated with it
> - * through the hotplug entry's driver_data.
> - */
> -static int ohci_hcd_omap3_probe(struct platform_device *pdev)
> -{
> -	struct device		*dev = &pdev->dev;
> -	struct ohci_hcd		*ohci;
> -	struct usb_hcd		*hcd = NULL;
> -	void __iomem		*regs = NULL;
> -	struct resource		*res;
> -	int			ret;
> -	int			irq;
> -
> -	if (usb_disabled())
> -		return -ENODEV;
> -
> -	if (!dev->parent) {
> -		dev_err(dev, "Missing parent device\n");
> -		return -ENODEV;
> -	}
> -
> -	irq = platform_get_irq(pdev, 0);
> -	if (irq < 0) {
> -		dev_err(dev, "OHCI irq failed\n");
> -		return -ENODEV;
> -	}
> -
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(dev, "UHH OHCI get resource failed\n");
> -		return -ENOMEM;
> -	}
> -
> -	regs = ioremap(res->start, resource_size(res));
> -	if (!regs) {
> -		dev_err(dev, "UHH OHCI ioremap failed\n");
> -		return -ENOMEM;
> -	}
> -
> -	/*
> -	 * Right now device-tree probed devices don't get dma_mask set.
> -	 * Since shared usb code relies on it, set it here for now.
> -	 * Once we have dma capability bindings this can go away.
> -	 */
> -	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
> -	if (ret)
> -		goto err_io;
> -
> -	ret = -ENODEV;
> -	hcd = usb_create_hcd(&ohci_omap3_hc_driver, dev,
> -			dev_name(dev));
> -	if (!hcd) {
> -		dev_err(dev, "usb_create_hcd failed\n");
> -		goto err_io;
> -	}
> -
> -	hcd->rsrc_start = res->start;
> -	hcd->rsrc_len = resource_size(res);
> -	hcd->regs =  regs;
> -
> -	pm_runtime_enable(dev);
> -	pm_runtime_get_sync(dev);
> -
> -	ohci = hcd_to_ohci(hcd);
> -	/*
> -	 * RemoteWakeupConnected has to be set explicitly before
> -	 * calling ohci_run. The reset value of RWC is 0.
> -	 */
> -	ohci->hc_control = OHCI_CTRL_RWC;
> -
> -	ret = usb_add_hcd(hcd, irq, 0);
> -	if (ret) {
> -		dev_dbg(dev, "failed to add hcd with err %d\n", ret);
> -		goto err_add_hcd;
> -	}
> -	device_wakeup_enable(hcd->self.controller);
> -
> -	return 0;
> -
> -err_add_hcd:
> -	pm_runtime_put_sync(dev);
> -	usb_put_hcd(hcd);
> -
> -err_io:
> -	iounmap(regs);
> -
> -	return ret;
> -}
> -
> -/*
> - * may be called without controller electrically present
> - * may be called with controller, bus, and devices active
> - */
> -
> -/**
> - * ohci_hcd_omap3_remove - shutdown processing for OHCI HCDs
> - * @pdev: USB Host Controller being removed
> - *
> - * Reverses the effect of ohci_hcd_omap3_probe(), first invoking
> - * the HCD's stop() method.  It is always called from a thread
> - * context, normally "rmmod", "apmd", or something similar.
> - */
> -static int ohci_hcd_omap3_remove(struct platform_device *pdev)
> -{
> -	struct device *dev	= &pdev->dev;
> -	struct usb_hcd *hcd	= dev_get_drvdata(dev);
> -
> -	iounmap(hcd->regs);
> -	usb_remove_hcd(hcd);
> -	pm_runtime_put_sync(dev);
> -	pm_runtime_disable(dev);
> -	usb_put_hcd(hcd);
> -	return 0;
> -}
> -
> -static const struct of_device_id omap_ohci_dt_ids[] = {
> -	{ .compatible = "ti,ohci-omap3" },
> -	{ }
> -};
> -
> -MODULE_DEVICE_TABLE(of, omap_ohci_dt_ids);
> -
> -static struct platform_driver ohci_hcd_omap3_driver = {
> -	.probe		= ohci_hcd_omap3_probe,
> -	.remove		= ohci_hcd_omap3_remove,
> -	.shutdown	= usb_hcd_platform_shutdown,
> -	.driver		= {
> -		.name	= "ohci-omap3",
> -		.of_match_table = omap_ohci_dt_ids,
> -	},
> -};
> -
> -static int __init ohci_omap3_init(void)
> -{
> -	if (usb_disabled())
> -		return -ENODEV;
> -
> -	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
> -
> -	ohci_init_driver(&ohci_omap3_hc_driver, NULL);
> -	return platform_driver_register(&ohci_hcd_omap3_driver);
> -}
> -module_init(ohci_omap3_init);
> -
> -static void __exit ohci_omap3_cleanup(void)
> -{
> -	platform_driver_unregister(&ohci_hcd_omap3_driver);
> -}
> -module_exit(ohci_omap3_cleanup);
> -
> -MODULE_DESCRIPTION(DRIVER_DESC);
> -MODULE_ALIAS("platform:ohci-omap3");
> -MODULE_AUTHOR("Anand Gadiyar <gadiyar-l0cyMroinI0@public.gmane.org>");
> -MODULE_LICENSE("GPL");
> 

-- 
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support
       [not found]     ` <20170522160007.9264-2-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2017-05-23  7:11       ` Roger Quadros
       [not found]         ` <c040a768-dd2e-a85d-fb3f-3088988f61aa-l0cyMroinI0@public.gmane.org>
  2017-05-23 16:53       ` Alan Stern
  1 sibling, 1 reply; 14+ messages in thread
From: Roger Quadros @ 2017-05-23  7:11 UTC (permalink / raw)
  To: Tony Lindgren, Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, Rob Herring,
	Sebastian Reichel, Yoshihiro Shimoda

Hi,

On 22/05/17 19:00, Tony Lindgren wrote:
> This is needed in preparation of adding support for omap3 and
> later OHCI. The runtime PM will only do something on platforms
> that implement it.
> 
> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
> Cc: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
> Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> ---
> 
> Alan, do you have some better ideas for the ohci_platform_remove()
> path below?
> 
> ---
>  drivers/usb/host/ohci-platform.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
> --- a/drivers/usb/host/ohci-platform.c
> +++ b/drivers/usb/host/ohci-platform.c
> @@ -24,6 +24,7 @@
>  #include <linux/err.h>
>  #include <linux/phy/phy.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
>  #include <linux/reset.h>
>  #include <linux/usb/ohci_pdriver.h>
>  #include <linux/usb.h>
> @@ -242,6 +243,8 @@ static int ohci_platform_probe(struct platform_device *dev)
>  	}
>  #endif
>  
> +	pm_runtime_set_active(&dev->dev);
> +	pm_runtime_enable(&dev->dev);
>  	if (pdata->power_on) {
>  		err = pdata->power_on(dev);
>  		if (err < 0)
> @@ -271,6 +274,7 @@ static int ohci_platform_probe(struct platform_device *dev)
>  	if (pdata->power_off)
>  		pdata->power_off(dev);
>  err_reset:
> +	pm_runtime_disable(&dev->dev);
>  	while (--rst >= 0)
>  		reset_control_assert(priv->resets[rst]);
>  err_put_clks:
> @@ -290,7 +294,14 @@ static int ohci_platform_remove(struct platform_device *dev)
>  	struct usb_hcd *hcd = platform_get_drvdata(dev);
>  	struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
>  	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
> -	int clk, rst;
> +	int clk, rst, enabled;
> +
> +	enabled = pm_runtime_get_sync(&dev->dev);

Why do we need to pm_runtime_get_sync() here?

> +	if (enabled < 0) {
> +		dev_warn(&dev->dev, "pm_runtime_get failed: %i\n",
> +			 enabled);
> +		pm_runtime_put_noidle(&dev->dev);
> +	}
>  
>  	usb_remove_hcd(hcd);
>  
> @@ -305,6 +316,10 @@ static int ohci_platform_remove(struct platform_device *dev)
>  
>  	usb_put_hcd(hcd);
>  
> +	if (enabled >= 0)
> +		pm_runtime_put_sync(&dev->dev);
> +	pm_runtime_disable(&dev->dev);
> +
>  	if (pdata == &ohci_platform_defaults)
>  		dev->dev.platform_data = NULL;
>  
> 

-- 
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] usb: host: ohci-omap3: Remove driver in favor of ohci-platform
       [not found]     ` <20170522160007.9264-4-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2017-05-23  7:08       ` Roger Quadros
@ 2017-05-23  8:58       ` Sebastian Reichel
  2017-05-23 16:56       ` Alan Stern
  2 siblings, 0 replies; 14+ messages in thread
From: Sebastian Reichel @ 2017-05-23  8:58 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Alan Stern, Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Roger Quadros

[-- Attachment #1: Type: text/plain, Size: 8975 bytes --]

Hi,

On Mon, May 22, 2017 at 09:00:07AM -0700, Tony Lindgren wrote:
> This driver is no longer needed and can be removed. The reason why
> it's safe to remove this driver is that most omap devices don't have a
> USB low-speed or full-speed compatible PHY installed and configured
> with drivers/mfd/omap-usb-host.c. This means that devices like
> beagleboard and pandaboard need to use a high-speed USB hub in order
> to use devices like keyboard and mice.
> 
> Currently the only known configured for a full-speed PHY is the
> mdm6600 modem on droid 4 and I've verified it works just fine with
> ohci-platform.
> 
> Cc: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
> Cc: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
> Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>

Reviewed-by: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>

-- Sebastian

> ---
>  drivers/usb/host/Kconfig      |   6 +-
>  drivers/usb/host/Makefile     |   1 -
>  drivers/usb/host/ohci-omap3.c | 211 ------------------------------------------
>  3 files changed, 5 insertions(+), 213 deletions(-)
>  delete mode 100644 drivers/usb/host/ohci-omap3.c
> 
> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -473,8 +473,12 @@ config USB_OHCI_HCD_AT91
>  config USB_OHCI_HCD_OMAP3
>  	tristate "OHCI support for OMAP3 and later chips"
>  	depends on (ARCH_OMAP3 || ARCH_OMAP4 || SOC_OMAP5)
> +	select USB_OHCI_HCD_PLATFORM
>  	default y
> -	---help---
> +	help
> +	  This option is deprecated now and the driver was removed, use
> +	  USB_OHCI_HCD_PLATFORM instead.
> +
>  	  Enables support for the on-chip OHCI controller on
>  	  OMAP3 and later chips.
>  
> diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
> --- a/drivers/usb/host/Makefile
> +++ b/drivers/usb/host/Makefile
> @@ -52,7 +52,6 @@ obj-$(CONFIG_USB_OHCI_HCD_PCI)	+= ohci-pci.o
>  obj-$(CONFIG_USB_OHCI_HCD_PLATFORM)	+= ohci-platform.o
>  obj-$(CONFIG_USB_OHCI_EXYNOS)	+= ohci-exynos.o
>  obj-$(CONFIG_USB_OHCI_HCD_OMAP1)	+= ohci-omap.o
> -obj-$(CONFIG_USB_OHCI_HCD_OMAP3)	+= ohci-omap3.o
>  obj-$(CONFIG_USB_OHCI_HCD_SPEAR)	+= ohci-spear.o
>  obj-$(CONFIG_USB_OHCI_HCD_STI)	+= ohci-st.o
>  obj-$(CONFIG_USB_OHCI_HCD_AT91)	+= ohci-at91.o
> diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
> deleted file mode 100644
> --- a/drivers/usb/host/ohci-omap3.c
> +++ /dev/null
> @@ -1,211 +0,0 @@
> -/*
> - * ohci-omap3.c - driver for OHCI on OMAP3 and later processors
> - *
> - * Bus Glue for OMAP3 USBHOST 3 port OHCI controller
> - * This controller is also used in later OMAPs and AM35x chips
> - *
> - * Copyright (C) 2007-2010 Texas Instruments, Inc.
> - * Author: Vikram Pandita <vikram.pandita-l0cyMroinI0@public.gmane.org>
> - * Author: Anand Gadiyar <gadiyar-l0cyMroinI0@public.gmane.org>
> - * Author: Keshava Munegowda <keshava_mgowda-l0cyMroinI0@public.gmane.org>
> - *
> - * Based on ehci-omap.c and some other ohci glue layers
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
> - *
> - * TODO (last updated Feb 27, 2011):
> - *	- add kernel-doc
> - */
> -
> -#include <linux/dma-mapping.h>
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/of.h>
> -#include <linux/usb/otg.h>
> -#include <linux/platform_device.h>
> -#include <linux/pm_runtime.h>
> -#include <linux/usb.h>
> -#include <linux/usb/hcd.h>
> -
> -#include "ohci.h"
> -
> -#define DRIVER_DESC "OHCI OMAP3 driver"
> -
> -static const char hcd_name[] = "ohci-omap3";
> -static struct hc_driver __read_mostly ohci_omap3_hc_driver;
> -
> -/*
> - * configure so an HC device and id are always provided
> - * always called with process context; sleeping is OK
> - */
> -
> -/**
> - * ohci_hcd_omap3_probe - initialize OMAP-based HCDs
> - *
> - * Allocates basic resources for this USB host controller, and
> - * then invokes the start() method for the HCD associated with it
> - * through the hotplug entry's driver_data.
> - */
> -static int ohci_hcd_omap3_probe(struct platform_device *pdev)
> -{
> -	struct device		*dev = &pdev->dev;
> -	struct ohci_hcd		*ohci;
> -	struct usb_hcd		*hcd = NULL;
> -	void __iomem		*regs = NULL;
> -	struct resource		*res;
> -	int			ret;
> -	int			irq;
> -
> -	if (usb_disabled())
> -		return -ENODEV;
> -
> -	if (!dev->parent) {
> -		dev_err(dev, "Missing parent device\n");
> -		return -ENODEV;
> -	}
> -
> -	irq = platform_get_irq(pdev, 0);
> -	if (irq < 0) {
> -		dev_err(dev, "OHCI irq failed\n");
> -		return -ENODEV;
> -	}
> -
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(dev, "UHH OHCI get resource failed\n");
> -		return -ENOMEM;
> -	}
> -
> -	regs = ioremap(res->start, resource_size(res));
> -	if (!regs) {
> -		dev_err(dev, "UHH OHCI ioremap failed\n");
> -		return -ENOMEM;
> -	}
> -
> -	/*
> -	 * Right now device-tree probed devices don't get dma_mask set.
> -	 * Since shared usb code relies on it, set it here for now.
> -	 * Once we have dma capability bindings this can go away.
> -	 */
> -	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
> -	if (ret)
> -		goto err_io;
> -
> -	ret = -ENODEV;
> -	hcd = usb_create_hcd(&ohci_omap3_hc_driver, dev,
> -			dev_name(dev));
> -	if (!hcd) {
> -		dev_err(dev, "usb_create_hcd failed\n");
> -		goto err_io;
> -	}
> -
> -	hcd->rsrc_start = res->start;
> -	hcd->rsrc_len = resource_size(res);
> -	hcd->regs =  regs;
> -
> -	pm_runtime_enable(dev);
> -	pm_runtime_get_sync(dev);
> -
> -	ohci = hcd_to_ohci(hcd);
> -	/*
> -	 * RemoteWakeupConnected has to be set explicitly before
> -	 * calling ohci_run. The reset value of RWC is 0.
> -	 */
> -	ohci->hc_control = OHCI_CTRL_RWC;
> -
> -	ret = usb_add_hcd(hcd, irq, 0);
> -	if (ret) {
> -		dev_dbg(dev, "failed to add hcd with err %d\n", ret);
> -		goto err_add_hcd;
> -	}
> -	device_wakeup_enable(hcd->self.controller);
> -
> -	return 0;
> -
> -err_add_hcd:
> -	pm_runtime_put_sync(dev);
> -	usb_put_hcd(hcd);
> -
> -err_io:
> -	iounmap(regs);
> -
> -	return ret;
> -}
> -
> -/*
> - * may be called without controller electrically present
> - * may be called with controller, bus, and devices active
> - */
> -
> -/**
> - * ohci_hcd_omap3_remove - shutdown processing for OHCI HCDs
> - * @pdev: USB Host Controller being removed
> - *
> - * Reverses the effect of ohci_hcd_omap3_probe(), first invoking
> - * the HCD's stop() method.  It is always called from a thread
> - * context, normally "rmmod", "apmd", or something similar.
> - */
> -static int ohci_hcd_omap3_remove(struct platform_device *pdev)
> -{
> -	struct device *dev	= &pdev->dev;
> -	struct usb_hcd *hcd	= dev_get_drvdata(dev);
> -
> -	iounmap(hcd->regs);
> -	usb_remove_hcd(hcd);
> -	pm_runtime_put_sync(dev);
> -	pm_runtime_disable(dev);
> -	usb_put_hcd(hcd);
> -	return 0;
> -}
> -
> -static const struct of_device_id omap_ohci_dt_ids[] = {
> -	{ .compatible = "ti,ohci-omap3" },
> -	{ }
> -};
> -
> -MODULE_DEVICE_TABLE(of, omap_ohci_dt_ids);
> -
> -static struct platform_driver ohci_hcd_omap3_driver = {
> -	.probe		= ohci_hcd_omap3_probe,
> -	.remove		= ohci_hcd_omap3_remove,
> -	.shutdown	= usb_hcd_platform_shutdown,
> -	.driver		= {
> -		.name	= "ohci-omap3",
> -		.of_match_table = omap_ohci_dt_ids,
> -	},
> -};
> -
> -static int __init ohci_omap3_init(void)
> -{
> -	if (usb_disabled())
> -		return -ENODEV;
> -
> -	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
> -
> -	ohci_init_driver(&ohci_omap3_hc_driver, NULL);
> -	return platform_driver_register(&ohci_hcd_omap3_driver);
> -}
> -module_init(ohci_omap3_init);
> -
> -static void __exit ohci_omap3_cleanup(void)
> -{
> -	platform_driver_unregister(&ohci_hcd_omap3_driver);
> -}
> -module_exit(ohci_omap3_cleanup);
> -
> -MODULE_DESCRIPTION(DRIVER_DESC);
> -MODULE_ALIAS("platform:ohci-omap3");
> -MODULE_AUTHOR("Anand Gadiyar <gadiyar-l0cyMroinI0@public.gmane.org>");
> -MODULE_LICENSE("GPL");
> -- 
> 2.13.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support
       [not found]         ` <c040a768-dd2e-a85d-fb3f-3088988f61aa-l0cyMroinI0@public.gmane.org>
@ 2017-05-23 14:08           ` Tony Lindgren
       [not found]             ` <20170523140831.GV10472-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Tony Lindgren @ 2017-05-23 14:08 UTC (permalink / raw)
  To: Roger Quadros
  Cc: Alan Stern, Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, Rob Herring,
	Sebastian Reichel, Yoshihiro Shimoda

* Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org> [170523 00:14]:
> On 22/05/17 19:00, Tony Lindgren wrote:
> > --- a/drivers/usb/host/ohci-platform.c
> > +++ b/drivers/usb/host/ohci-platform.c
> > @@ -290,7 +294,14 @@ static int ohci_platform_remove(struct platform_device *dev)
> >  	struct usb_hcd *hcd = platform_get_drvdata(dev);
> >  	struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
> >  	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
> > -	int clk, rst;
> > +	int clk, rst, enabled;
> > +
> > +	enabled = pm_runtime_get_sync(&dev->dev);
> 
> Why do we need to pm_runtime_get_sync() here?

ohci_platform_remove()
	usb_remove_hcd()
		ohci_stop()

Will cause "external abort on non-linefetch" otherwise.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support
       [not found]     ` <20170522160007.9264-2-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2017-05-23  7:11       ` Roger Quadros
@ 2017-05-23 16:53       ` Alan Stern
       [not found]         ` <Pine.LNX.4.44L0.1705231250110.1853-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
  1 sibling, 1 reply; 14+ messages in thread
From: Alan Stern @ 2017-05-23 16:53 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, Rob Herring,
	Roger Quadros, Sebastian Reichel, Yoshihiro Shimoda

On Mon, 22 May 2017, Tony Lindgren wrote:

> This is needed in preparation of adding support for omap3 and
> later OHCI. The runtime PM will only do something on platforms
> that implement it.
> 
> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
> Cc: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
> Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> ---
> 
> Alan, do you have some better ideas for the ohci_platform_remove()
> path below?
> 
> ---
>  drivers/usb/host/ohci-platform.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
> --- a/drivers/usb/host/ohci-platform.c
> +++ b/drivers/usb/host/ohci-platform.c
> @@ -24,6 +24,7 @@
>  #include <linux/err.h>
>  #include <linux/phy/phy.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
>  #include <linux/reset.h>
>  #include <linux/usb/ohci_pdriver.h>
>  #include <linux/usb.h>
> @@ -242,6 +243,8 @@ static int ohci_platform_probe(struct platform_device *dev)
>  	}
>  #endif
>  
> +	pm_runtime_set_active(&dev->dev);
> +	pm_runtime_enable(&dev->dev);
>  	if (pdata->power_on) {
>  		err = pdata->power_on(dev);
>  		if (err < 0)
> @@ -271,6 +274,7 @@ static int ohci_platform_probe(struct platform_device *dev)
>  	if (pdata->power_off)
>  		pdata->power_off(dev);
>  err_reset:
> +	pm_runtime_disable(&dev->dev);
>  	while (--rst >= 0)
>  		reset_control_assert(priv->resets[rst]);
>  err_put_clks:
> @@ -290,7 +294,14 @@ static int ohci_platform_remove(struct platform_device *dev)
>  	struct usb_hcd *hcd = platform_get_drvdata(dev);
>  	struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
>  	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
> -	int clk, rst;
> +	int clk, rst, enabled;
> +
> +	enabled = pm_runtime_get_sync(&dev->dev);
> +	if (enabled < 0) {
> +		dev_warn(&dev->dev, "pm_runtime_get failed: %i\n",
> +			 enabled);
> +		pm_runtime_put_noidle(&dev->dev);
> +	}

I wouldn't worry about checking the return value.  There's no 
particular reason for this call to fail, is there?

>  
>  	usb_remove_hcd(hcd);
>  
> @@ -305,6 +316,10 @@ static int ohci_platform_remove(struct platform_device *dev)
>  
>  	usb_put_hcd(hcd);
>  
> +	if (enabled >= 0)
> +		pm_runtime_put_sync(&dev->dev);
> +	pm_runtime_disable(&dev->dev);

And here you could just do the put_sync, with no test.  If the get_sync
failed then this will probably fail too, but you won't be any worse off
for the attempt.

Alan Stern

> +
>  	if (pdata == &ohci_platform_defaults)
>  		dev->dev.platform_data = NULL;

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] usb: host: ohci-omap3: Remove driver in favor of ohci-platform
       [not found]     ` <20170522160007.9264-4-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
  2017-05-23  7:08       ` Roger Quadros
  2017-05-23  8:58       ` Sebastian Reichel
@ 2017-05-23 16:56       ` Alan Stern
  2 siblings, 0 replies; 14+ messages in thread
From: Alan Stern @ 2017-05-23 16:56 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Roger Quadros,
	Sebastian Reichel

On Mon, 22 May 2017, Tony Lindgren wrote:

> This driver is no longer needed and can be removed. The reason why
> it's safe to remove this driver is that most omap devices don't have a
> USB low-speed or full-speed compatible PHY installed and configured
> with drivers/mfd/omap-usb-host.c. This means that devices like
> beagleboard and pandaboard need to use a high-speed USB hub in order
> to use devices like keyboard and mice.
> 
> Currently the only known configured for a full-speed PHY is the
> mdm6600 modem on droid 4 and I've verified it works just fine with
> ohci-platform.
> 
> Cc: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
> Cc: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
> Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> ---
>  drivers/usb/host/Kconfig      |   6 +-
>  drivers/usb/host/Makefile     |   1 -
>  drivers/usb/host/ohci-omap3.c | 211 ------------------------------------------
>  3 files changed, 5 insertions(+), 213 deletions(-)
>  delete mode 100644 drivers/usb/host/ohci-omap3.c
> 
> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -473,8 +473,12 @@ config USB_OHCI_HCD_AT91
>  config USB_OHCI_HCD_OMAP3
>  	tristate "OHCI support for OMAP3 and later chips"
>  	depends on (ARCH_OMAP3 || ARCH_OMAP4 || SOC_OMAP5)
> +	select USB_OHCI_HCD_PLATFORM
>  	default y
> -	---help---
> +	help
> +	  This option is deprecated now and the driver was removed, use
> +	  USB_OHCI_HCD_PLATFORM instead.
> +
>  	  Enables support for the on-chip OHCI controller on
>  	  OMAP3 and later chips.
>  
...

Acked-by: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support
       [not found]         ` <Pine.LNX.4.44L0.1705231250110.1853-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
@ 2017-05-23 17:46           ` Tony Lindgren
  0 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2017-05-23 17:46 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, Rob Herring,
	Roger Quadros, Sebastian Reichel, Yoshihiro Shimoda

* Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org> [170523 09:57]:
> On Mon, 22 May 2017, Tony Lindgren wrote:
> > Alan, do you have some better ideas for the ohci_platform_remove()
> > path below?
...
> > --- a/drivers/usb/host/ohci-platform.c
> > +++ b/drivers/usb/host/ohci-platform.c
> > @@ -290,7 +294,14 @@ static int ohci_platform_remove(struct platform_device *dev)
> >  	struct usb_hcd *hcd = platform_get_drvdata(dev);
> >  	struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
> >  	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
> > -	int clk, rst;
> > +	int clk, rst, enabled;
> > +
> > +	enabled = pm_runtime_get_sync(&dev->dev);
> > +	if (enabled < 0) {
> > +		dev_warn(&dev->dev, "pm_runtime_get failed: %i\n",
> > +			 enabled);
> > +		pm_runtime_put_noidle(&dev->dev);
> > +	}
> 
> I wouldn't worry about checking the return value.  There's no 
> particular reason for this call to fail, is there?

OK yeah if it was to fail it would already fail on probe
already :)

> >  	usb_remove_hcd(hcd);
> >  
> > @@ -305,6 +316,10 @@ static int ohci_platform_remove(struct platform_device *dev)
> >  
> >  	usb_put_hcd(hcd);
> >  
> > +	if (enabled >= 0)
> > +		pm_runtime_put_sync(&dev->dev);
> > +	pm_runtime_disable(&dev->dev);
> 
> And here you could just do the put_sync, with no test.  If the get_sync
> failed then this will probably fail too, but you won't be any worse off
> for the attempt.

OK fine with me.

Thanks,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support
       [not found]             ` <20170523140831.GV10472-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2017-05-24  7:23               ` Roger Quadros
  0 siblings, 0 replies; 14+ messages in thread
From: Roger Quadros @ 2017-05-24  7:23 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Alan Stern, Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Hans de Goede, Rob Herring,
	Sebastian Reichel, Yoshihiro Shimoda

On 23/05/17 17:08, Tony Lindgren wrote:
> * Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org> [170523 00:14]:
>> On 22/05/17 19:00, Tony Lindgren wrote:
>>> --- a/drivers/usb/host/ohci-platform.c
>>> +++ b/drivers/usb/host/ohci-platform.c
>>> @@ -290,7 +294,14 @@ static int ohci_platform_remove(struct platform_device *dev)
>>>  	struct usb_hcd *hcd = platform_get_drvdata(dev);
>>>  	struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
>>>  	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
>>> -	int clk, rst;
>>> +	int clk, rst, enabled;
>>> +
>>> +	enabled = pm_runtime_get_sync(&dev->dev);
>>
>> Why do we need to pm_runtime_get_sync() here?
> 
> ohci_platform_remove()
> 	usb_remove_hcd()
> 		ohci_stop()
> 
> Will cause "external abort on non-linefetch" otherwise.

Got it, thanks.

> 
> Regards,
> 
> Tony
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 3/3] usb: host: ohci-omap3: Remove driver in favor of ohci-platform
       [not found] ` <20170525161333.32639-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
@ 2017-05-25 16:13   ` Tony Lindgren
  0 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2017-05-25 16:13 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

This driver is no longer needed and can be removed. The reason why
it's safe to remove this driver is that most omap devices don't have a
USB low-speed or full-speed compatible PHY installed and configured
with drivers/mfd/omap-usb-host.c. This means that devices like
beagleboard and pandaboard need to use a high-speed USB hub in order
to use devices like keyboard and mice.

Currently the only known configured for a full-speed PHY is the
mdm6600 modem on droid 4 and I've verified it works just fine with
ohci-platform.

Acked-by: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
Acked-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Reviewed-by: Sebastian Reichel <sebastian.reichel-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
---
 drivers/usb/host/Kconfig      |   6 +-
 drivers/usb/host/Makefile     |   1 -
 drivers/usb/host/ohci-omap3.c | 211 ------------------------------------------
 3 files changed, 5 insertions(+), 213 deletions(-)
 delete mode 100644 drivers/usb/host/ohci-omap3.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -473,8 +473,12 @@ config USB_OHCI_HCD_AT91
 config USB_OHCI_HCD_OMAP3
 	tristate "OHCI support for OMAP3 and later chips"
 	depends on (ARCH_OMAP3 || ARCH_OMAP4 || SOC_OMAP5)
+	select USB_OHCI_HCD_PLATFORM
 	default y
-	---help---
+	help
+	  This option is deprecated now and the driver was removed, use
+	  USB_OHCI_HCD_PLATFORM instead.
+
 	  Enables support for the on-chip OHCI controller on
 	  OMAP3 and later chips.
 
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -52,7 +52,6 @@ obj-$(CONFIG_USB_OHCI_HCD_PCI)	+= ohci-pci.o
 obj-$(CONFIG_USB_OHCI_HCD_PLATFORM)	+= ohci-platform.o
 obj-$(CONFIG_USB_OHCI_EXYNOS)	+= ohci-exynos.o
 obj-$(CONFIG_USB_OHCI_HCD_OMAP1)	+= ohci-omap.o
-obj-$(CONFIG_USB_OHCI_HCD_OMAP3)	+= ohci-omap3.o
 obj-$(CONFIG_USB_OHCI_HCD_SPEAR)	+= ohci-spear.o
 obj-$(CONFIG_USB_OHCI_HCD_STI)	+= ohci-st.o
 obj-$(CONFIG_USB_OHCI_HCD_AT91)	+= ohci-at91.o
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
deleted file mode 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * ohci-omap3.c - driver for OHCI on OMAP3 and later processors
- *
- * Bus Glue for OMAP3 USBHOST 3 port OHCI controller
- * This controller is also used in later OMAPs and AM35x chips
- *
- * Copyright (C) 2007-2010 Texas Instruments, Inc.
- * Author: Vikram Pandita <vikram.pandita-l0cyMroinI0@public.gmane.org>
- * Author: Anand Gadiyar <gadiyar-l0cyMroinI0@public.gmane.org>
- * Author: Keshava Munegowda <keshava_mgowda-l0cyMroinI0@public.gmane.org>
- *
- * Based on ehci-omap.c and some other ohci glue layers
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
- * TODO (last updated Feb 27, 2011):
- *	- add kernel-doc
- */
-
-#include <linux/dma-mapping.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/usb/otg.h>
-#include <linux/platform_device.h>
-#include <linux/pm_runtime.h>
-#include <linux/usb.h>
-#include <linux/usb/hcd.h>
-
-#include "ohci.h"
-
-#define DRIVER_DESC "OHCI OMAP3 driver"
-
-static const char hcd_name[] = "ohci-omap3";
-static struct hc_driver __read_mostly ohci_omap3_hc_driver;
-
-/*
- * configure so an HC device and id are always provided
- * always called with process context; sleeping is OK
- */
-
-/**
- * ohci_hcd_omap3_probe - initialize OMAP-based HCDs
- *
- * Allocates basic resources for this USB host controller, and
- * then invokes the start() method for the HCD associated with it
- * through the hotplug entry's driver_data.
- */
-static int ohci_hcd_omap3_probe(struct platform_device *pdev)
-{
-	struct device		*dev = &pdev->dev;
-	struct ohci_hcd		*ohci;
-	struct usb_hcd		*hcd = NULL;
-	void __iomem		*regs = NULL;
-	struct resource		*res;
-	int			ret;
-	int			irq;
-
-	if (usb_disabled())
-		return -ENODEV;
-
-	if (!dev->parent) {
-		dev_err(dev, "Missing parent device\n");
-		return -ENODEV;
-	}
-
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0) {
-		dev_err(dev, "OHCI irq failed\n");
-		return -ENODEV;
-	}
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "UHH OHCI get resource failed\n");
-		return -ENOMEM;
-	}
-
-	regs = ioremap(res->start, resource_size(res));
-	if (!regs) {
-		dev_err(dev, "UHH OHCI ioremap failed\n");
-		return -ENOMEM;
-	}
-
-	/*
-	 * Right now device-tree probed devices don't get dma_mask set.
-	 * Since shared usb code relies on it, set it here for now.
-	 * Once we have dma capability bindings this can go away.
-	 */
-	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
-	if (ret)
-		goto err_io;
-
-	ret = -ENODEV;
-	hcd = usb_create_hcd(&ohci_omap3_hc_driver, dev,
-			dev_name(dev));
-	if (!hcd) {
-		dev_err(dev, "usb_create_hcd failed\n");
-		goto err_io;
-	}
-
-	hcd->rsrc_start = res->start;
-	hcd->rsrc_len = resource_size(res);
-	hcd->regs =  regs;
-
-	pm_runtime_enable(dev);
-	pm_runtime_get_sync(dev);
-
-	ohci = hcd_to_ohci(hcd);
-	/*
-	 * RemoteWakeupConnected has to be set explicitly before
-	 * calling ohci_run. The reset value of RWC is 0.
-	 */
-	ohci->hc_control = OHCI_CTRL_RWC;
-
-	ret = usb_add_hcd(hcd, irq, 0);
-	if (ret) {
-		dev_dbg(dev, "failed to add hcd with err %d\n", ret);
-		goto err_add_hcd;
-	}
-	device_wakeup_enable(hcd->self.controller);
-
-	return 0;
-
-err_add_hcd:
-	pm_runtime_put_sync(dev);
-	usb_put_hcd(hcd);
-
-err_io:
-	iounmap(regs);
-
-	return ret;
-}
-
-/*
- * may be called without controller electrically present
- * may be called with controller, bus, and devices active
- */
-
-/**
- * ohci_hcd_omap3_remove - shutdown processing for OHCI HCDs
- * @pdev: USB Host Controller being removed
- *
- * Reverses the effect of ohci_hcd_omap3_probe(), first invoking
- * the HCD's stop() method.  It is always called from a thread
- * context, normally "rmmod", "apmd", or something similar.
- */
-static int ohci_hcd_omap3_remove(struct platform_device *pdev)
-{
-	struct device *dev	= &pdev->dev;
-	struct usb_hcd *hcd	= dev_get_drvdata(dev);
-
-	iounmap(hcd->regs);
-	usb_remove_hcd(hcd);
-	pm_runtime_put_sync(dev);
-	pm_runtime_disable(dev);
-	usb_put_hcd(hcd);
-	return 0;
-}
-
-static const struct of_device_id omap_ohci_dt_ids[] = {
-	{ .compatible = "ti,ohci-omap3" },
-	{ }
-};
-
-MODULE_DEVICE_TABLE(of, omap_ohci_dt_ids);
-
-static struct platform_driver ohci_hcd_omap3_driver = {
-	.probe		= ohci_hcd_omap3_probe,
-	.remove		= ohci_hcd_omap3_remove,
-	.shutdown	= usb_hcd_platform_shutdown,
-	.driver		= {
-		.name	= "ohci-omap3",
-		.of_match_table = omap_ohci_dt_ids,
-	},
-};
-
-static int __init ohci_omap3_init(void)
-{
-	if (usb_disabled())
-		return -ENODEV;
-
-	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
-
-	ohci_init_driver(&ohci_omap3_hc_driver, NULL);
-	return platform_driver_register(&ohci_hcd_omap3_driver);
-}
-module_init(ohci_omap3_init);
-
-static void __exit ohci_omap3_cleanup(void)
-{
-	platform_driver_unregister(&ohci_hcd_omap3_driver);
-}
-module_exit(ohci_omap3_cleanup);

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-05-25 16:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 16:00 [PATCHv2 0/3] Make ohci-platform usable for omap3/4/5 Tony Lindgren
     [not found] ` <20170522160007.9264-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-05-22 16:00   ` [PATCH 1/3] usb: host: ohci-platform: Add basic runtime PM support Tony Lindgren
     [not found]     ` <20170522160007.9264-2-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-05-23  7:11       ` Roger Quadros
     [not found]         ` <c040a768-dd2e-a85d-fb3f-3088988f61aa-l0cyMroinI0@public.gmane.org>
2017-05-23 14:08           ` Tony Lindgren
     [not found]             ` <20170523140831.GV10472-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-05-24  7:23               ` Roger Quadros
2017-05-23 16:53       ` Alan Stern
     [not found]         ` <Pine.LNX.4.44L0.1705231250110.1853-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2017-05-23 17:46           ` Tony Lindgren
2017-05-22 16:00   ` [PATCH 2/3] usb: host: ohci-platform: Add support for omap3 and later Tony Lindgren
     [not found]     ` <20170522160007.9264-3-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-05-22 16:03       ` Tony Lindgren
2017-05-22 16:00   ` [PATCH 3/3] usb: host: ohci-omap3: Remove driver in favor of ohci-platform Tony Lindgren
     [not found]     ` <20170522160007.9264-4-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-05-23  7:08       ` Roger Quadros
2017-05-23  8:58       ` Sebastian Reichel
2017-05-23 16:56       ` Alan Stern
2017-05-25 16:13 [PATCHv3 0/3] Make ohci-platform usable for omap3/4/5 Tony Lindgren
     [not found] ` <20170525161333.32639-1-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2017-05-25 16:13   ` [PATCH 3/3] usb: host: ohci-omap3: Remove driver in favor of ohci-platform Tony Lindgren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.