From patchwork Thu Nov 3 15:59:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 80691 Delivered-To: patch@linaro.org Received: by 10.80.170.210 with SMTP id r18csp692360edc; Thu, 3 Nov 2016 09:00:28 -0700 (PDT) X-Received: by 10.98.210.10 with SMTP id c10mr18097537pfg.23.1478188828586; Thu, 03 Nov 2016 09:00:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b186si10317843pgc.335.2016.11.03.09.00.28; Thu, 03 Nov 2016 09:00:28 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.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 S1758568AbcKCP7Y (ORCPT + 27 others); Thu, 3 Nov 2016 11:59:24 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:35338 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758489AbcKCP7U (ORCPT ); Thu, 3 Nov 2016 11:59:20 -0400 Received: by mail-wm0-f46.google.com with SMTP id a197so214402130wmd.0 for ; Thu, 03 Nov 2016 08:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Broqzb8s6iVwaKIY4kKD7q9hr4ChCOUHhbDYmT5jRDs=; b=LNenOAmoOfl3AaCKIE6vWza4/kVhv0mOteb+TlfoWRrcj1pBEeZC4pwpQEpEn5Wtx+ 9O7c72pBbUE0oUp/Req0wlUKHd76VvRv/GQ61TvptGwK/IfV7EfFDElf8pLvNA0JKwfm 1/HHDU08iVjS7y48bG1GziR6UjftzlqiLjRBIAaGigy2AaY+s+fvZoNP28YcfUPx66N9 YyItaOyOYrp64RgjI7NHWdMBICmL/u6A11wG1pHk/PJUyBSrWdcyPzTPj6ICX7lXgn/a xJ1DdYQW2TgapcqKMkScesw3IaVSADf92SaQZjCtRdWOMhweP/N0FEdm2NahQM9Y+0a1 v0BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Broqzb8s6iVwaKIY4kKD7q9hr4ChCOUHhbDYmT5jRDs=; b=LrsA2Fd9DK2azc7+lUERVfcbxPQeMpUdd7amlBug9ZsNglPG1Dp4NUbXhRsWp265B8 C44u/ewcAXfuDCWOKStYJeVrD0lpNLYFYv7plfLPG6jUzdF4enSvXsPqQlp6faS+e8XL R+j5/csoKejSMf8Fi7jluVnIBDsaDchEJ+Q27anmrvLGDeoda+GKE4+gKOCUWNgwdKh+ KEXuoignVjK/WpBNzwAwGILc8yLG7HgN55z8okVKRrFTuoMN5HenxOIzbjs6HUGe1+lJ 32h/HyGg1IRgFro5mzlhvS5H4la8wtke0s1Cg1l1WBI6hC5ULs8c1rlzDd0r78/Ef7UE Y/4g== X-Gm-Message-State: ABUngveYSiDBYz2B9x4aiA5Gh/v1X/iVy2aCa1tOFkb7i3Bnre/1gaIGawcMPs+OH+tbal1z X-Received: by 10.28.189.69 with SMTP id n66mr2645602wmf.35.1478188757898; Thu, 03 Nov 2016 08:59:17 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id k17sm42957574wmd.8.2016.11.03.08.59.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Nov 2016 08:59:17 -0700 (PDT) From: Alexandre Bailon To: khilman@baylibre.com, robh+dt@kernel.org, b-liu@ti.com Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, nsekhar@ti.com, Petr Kulhavy , Alexandre Bailon Subject: [PATCH v4 2/4] usb: musb: core: added helper function for parsing DT Date: Thu, 3 Nov 2016 16:59:10 +0100 Message-Id: <1478188752-22447-3-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1478188752-22447-1-git-send-email-abailon@baylibre.com> References: <1478188752-22447-1-git-send-email-abailon@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Petr Kulhavy This adds the function musb_get_mode() to get the DT property "dr_mode" Signed-off-by: Petr Kulhavy Acked-by: Sergei Shtylyov Signed-off-by: Alexandre Bailon Tested-by: David Lechner Reviewed-by: Kevin Hilman --- drivers/usb/musb/musb_core.c | 19 +++++++++++++++++++ drivers/usb/musb/musb_core.h | 6 ++++++ 2 files changed, 25 insertions(+) -- 2.7.3 diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 27dadc0..bba07e7 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -100,6 +100,7 @@ #include #include #include +#include #include "musb_core.h" #include "musb_trace.h" @@ -130,6 +131,24 @@ static inline struct musb *dev_to_musb(struct device *dev) return dev_get_drvdata(dev); } +enum musb_mode musb_get_mode(struct device *dev) +{ + enum usb_dr_mode mode; + + mode = usb_get_dr_mode(dev); + switch (mode) { + case USB_DR_MODE_HOST: + return MUSB_HOST; + case USB_DR_MODE_PERIPHERAL: + return MUSB_PERIPHERAL; + case USB_DR_MODE_OTG: + case USB_DR_MODE_UNKNOWN: + default: + return MUSB_OTG; + } +} +EXPORT_SYMBOL_GPL(musb_get_mode); + /*-------------------------------------------------------------------------*/ #ifndef CONFIG_BLACKFIN diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 2cb88a49..76f00f6 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -617,4 +617,10 @@ static inline void musb_platform_post_root_reset_end(struct musb *musb) musb->ops->post_root_reset_end(musb); } +/* + * gets the "dr_mode" property from DT and converts it into musb_mode + * if the property is not found or not recognized returns MUSB_OTG + */ +extern enum musb_mode musb_get_mode(struct device *dev); + #endif /* __MUSB_CORE_H__ */