From patchwork Thu May 30 17:56:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruchika Kharwar X-Patchwork-Id: 2638511 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id EF322DF2A1 for ; Thu, 30 May 2013 17:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756220Ab3E3R4p (ORCPT ); Thu, 30 May 2013 13:56:45 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:35381 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755998Ab3E3R4o (ORCPT ); Thu, 30 May 2013 13:56:44 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4UHud3w016856; Thu, 30 May 2013 12:56:39 -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 r4UHud70029960; Thu, 30 May 2013 12:56:39 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Thu, 30 May 2013 12:56:39 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r4UHudQr013720; Thu, 30 May 2013 12:56:39 -0500 Received: from localhost (ula0875018.am.dhcp.ti.com [128.247.91.34]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r4UHudV21035; Thu, 30 May 2013 12:56:39 -0500 (CDT) From: Ruchika Kharwar To: , , CC: Felipe Balbi , Kishon Vijay Abraham I , Greg Kroah-Hartman , Rob Landley , Ruchika Kharwar Subject: [PATCH] usb: dwc3: Addition of "dr_mode" dt property. Date: Thu, 30 May 2013 12:56:31 -0500 Message-ID: <1369936591-29605-1-git-send-email-ruchika@ti.com> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This patch adds the possibility of the "mode" being specified in a device tree. This allows the scenario when there maybe multiple USB subsystems operating in different modes. Signed-off-by: Ruchika Kharwar --- Documentation/devicetree/bindings/usb/dwc3.txt | 3 ++- drivers/usb/dwc3/core.c | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 7a95c65..5c4db93 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -10,7 +10,8 @@ Required properties: Optional properties: - tx-fifo-resize: determines if the FIFO *has* to be reallocated. - + - dr_mode: determines the mode of core. This could be "gadget", "host", + "drd". This is usually a subnode to DWC3 glue to which it is connected. dwc3@4a030000 { diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c35d49d..cf211be 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -378,7 +378,7 @@ static int dwc3_probe(struct platform_device *pdev) void *mem; u8 mode; - + char *dr_mode; mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); if (!mem) { dev_err(dev, "not enough memory\n"); @@ -520,9 +520,23 @@ static int dwc3_probe(struct platform_device *pdev) mode = DWC3_MODE_HOST; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) mode = DWC3_MODE_DEVICE; - else - mode = DWC3_MODE_DRD; - + else { + if (of_property_read_string(node, "dr_mode", &dr_mode)) { + dev_warn(dev, "Missing dr_mode so assuming DWC3_MODE_DRD\n"); + mode = DWC3_MODE_DRD; + } else { + if (strcmp(dr_mode, "host") == 0) + mode = DWC3_MODE_HOST; + else if (strcmp(dr_mode, "gadget") == 0) + mode = DWC3_MODE_DEVICE; + else if (strcmp(dr_mode, "drd") == 0) + mode = DWC3_MODE_DRD; + else { + dev_err(dev, "invalid dr_mode property value\n"); + goto err0; + } + } + } switch (mode) { case DWC3_MODE_DEVICE: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);