From patchwork Fri Jun 10 13:07:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 69772 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp285543qgf; Fri, 10 Jun 2016 06:09:53 -0700 (PDT) X-Received: by 10.98.152.76 with SMTP id q73mr2396611pfd.38.1465564193157; Fri, 10 Jun 2016 06:09:53 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si12130902pan.36.2016.06.10.06.09.52; Fri, 10 Jun 2016 06:09:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161370AbcFJNJu (ORCPT + 30 others); Fri, 10 Jun 2016 09:09:50 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:52005 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161219AbcFJNIk (ORCPT ); Fri, 10 Jun 2016 09:08:40 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id u5AD8CKn000409; Fri, 10 Jun 2016 08:08:13 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5AD8To8015576; Fri, 10 Jun 2016 08:08:29 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Fri, 10 Jun 2016 08:08:29 -0500 Received: from lta0400828d.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5AD7ODn000644; Fri, 10 Jun 2016 08:08:24 -0500 From: Roger Quadros To: CC: , , , , , , , , , , , , , , , , , , Roger Quadros Subject: [PATCH v10 12/14] usb: hcd: Adapt to OTG core Date: Fri, 10 Jun 2016 16:07:21 +0300 Message-ID: <1465564043-27163-13-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1465564043-27163-1-git-send-email-rogerq@ti.com> References: <1465564043-27163-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce usb_otg_add/remove_hcd() for use by host controllers that are part of OTG/dual-role port. Non device tree platforms can use the otg_dev argument to specify the OTG controller device. If otg_dev is NULL then the device tree node's otg-controller property is used to get the otg_dev device. Signed-off-by: Roger Quadros Acked-by: Peter Chen --- drivers/usb/core/hcd.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/hcd.h | 4 ++++ 2 files changed, 59 insertions(+) -- 2.7.4 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index ae6c76d..c6f4155 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -46,6 +46,11 @@ #include #include #include +#include +#include + +#include +#include #include "usb.h" @@ -3025,6 +3030,56 @@ void usb_remove_hcd(struct usb_hcd *hcd) } EXPORT_SYMBOL_GPL(usb_remove_hcd); +static struct otg_hcd_ops otg_hcd_intf = { + .add = usb_add_hcd, + .remove = usb_remove_hcd, + .usb_bus_start_enum = usb_bus_start_enum, + .usb_control_msg = usb_control_msg, + .usb_hub_find_child = usb_hub_find_child, +}; + +/** + * usb_otg_add_hcd - Register the HCD with OTG core. + * @hcd: the usb_hcd structure to initialize + * @irqnum: Interrupt line to allocate + * @irqflags: Interrupt type flags + * @otg_dev: OTG controller device managing this HCD + * + * Registers the HCD with OTG core. OTG core will call usb_add_hcd() + * or usb_remove_hcd() as necessary. + * If otg_dev is NULL then device tree node is checked for OTG + * controller device via the otg-controller property. + */ +int usb_otg_add_hcd(struct usb_hcd *hcd, + unsigned int irqnum, unsigned long irqflags, + struct device *otg_dev) +{ + struct device *dev = hcd->self.controller; + + if (!otg_dev) { + hcd->otg_dev = of_usb_get_otg(dev->of_node); + if (!hcd->otg_dev) + return -ENODEV; + } else { + hcd->otg_dev = otg_dev; + } + + return usb_otg_register_hcd(hcd, irqnum, irqflags, &otg_hcd_intf); +} +EXPORT_SYMBOL_GPL(usb_otg_add_hcd); + +/** + * usb_otg_remove_hcd - Unregister the HCD with OTG core. + * @hcd: the usb_hcd structure to remove + * + * Unregisters the HCD from the OTG core. + */ +void usb_otg_remove_hcd(struct usb_hcd *hcd) +{ + usb_otg_unregister_hcd(hcd); +} +EXPORT_SYMBOL_GPL(usb_otg_remove_hcd); + void usb_hcd_platform_shutdown(struct platform_device *dev) { diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 36bd54f..0c70282 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -473,6 +473,10 @@ extern int usb_hcd_is_primary_hcd(struct usb_hcd *hcd); extern int usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags); extern void usb_remove_hcd(struct usb_hcd *hcd); +extern int usb_otg_add_hcd(struct usb_hcd *hcd, + unsigned int irqnum, unsigned long irqflags, + struct device *otg_dev); +extern void usb_otg_remove_hcd(struct usb_hcd *hcd); extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1); struct platform_device;