From patchwork Wed Nov 16 10:52:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 82479 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp82817qge; Wed, 16 Nov 2016 02:52:51 -0800 (PST) X-Received: by 10.99.5.21 with SMTP id 21mr6901861pgf.32.1479293571650; Wed, 16 Nov 2016 02:52:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n22si31304160pfi.246.2016.11.16.02.52.51; Wed, 16 Nov 2016 02:52:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755377AbcKPKwk (ORCPT + 4 others); Wed, 16 Nov 2016 05:52:40 -0500 Received: from mail-wm0-f46.google.com ([74.125.82.46]:38631 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751955AbcKPKwh (ORCPT ); Wed, 16 Nov 2016 05:52:37 -0500 Received: by mail-wm0-f46.google.com with SMTP id f82so64286228wmf.1 for ; Wed, 16 Nov 2016 02:52:37 -0800 (PST) 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=vBE1brYGi+guj1TzD9s/lwoJAGFu7MUrKvezv69HxcE=; b=JC//rIH0OPziPMurkrgv53Clo8LCdcs1UYtTk62QUbaHi/YgSS45y8uUPMVDMHHhuA wZuyhDltJRYmy26gUw/oPqUvhqR/QqVC1ipbH/nw9xzpUu29RFR7eUpKcKmLkVfum7FA fsHmPtPak/cSLVBAHkjTTVrz3F4sMyqCzuLHT3WFhyzfXczRzlYixPkxsDKwWkBBT9KE T8nrwE4qGWwANzrjpga16cq6/AEs8mD5T4s0CVMJoZ7wgYp2wUvHN+JDdUCspFuN+CWv SU+gDuLP0q0gM4QelWsDAEQdGs4hG2IIgHfUBKADoJ9xg4jDxaItq4cN2ZeLnkUMsLXm auOg== 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=vBE1brYGi+guj1TzD9s/lwoJAGFu7MUrKvezv69HxcE=; b=hJVCBuZ8YUtTJo8RsywxZMn5CG91hM+bN9o7PPcHzyTP92PpnhdC9q/fVAvTDtW0hn 2sMOhaQks6SHBMaB3ijbouMnKa4n1mqcvzIzKGj2SamO6FT1OmX1sCDnUFfeqsQrsPxp BVpZb2hl+0u4kV8S/bkzuoU3ig6GlbeRkCdd02DVX9MVqrJtwPLd5QUoe4A7COBruVha CwytrU15sTxijvsy9mrjcgo9mCcRK3rDvFqEY3pJiPjE+idg2kjSI1otAmQCOl7uGEPc HDVQZO6GG2hXX9AKkWvEjSDkL1dY0aOPAJgbVOswsGIkJHhfWnJ/NBgDjd3ogJzyrEYk YUDg== X-Gm-Message-State: ABUngveB6XGUBYd2ZWUc90n/pSojWC/mkzQbanq4puiy2JQ4wj4D0W3ABzXEg22OQiflNcOC X-Received: by 10.28.135.5 with SMTP id j5mr6650903wmd.3.1479293556536; Wed, 16 Nov 2016 02:52:36 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id m9sm9444479wma.0.2016.11.16.02.52.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Nov 2016 02:52:36 -0800 (PST) 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 v5 2/3] usb: musb: core: added helper function for parsing DT Date: Wed, 16 Nov 2016 11:52:24 +0100 Message-Id: <1479293545-7516-3-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1479293545-7516-1-git-send-email-abailon@baylibre.com> References: <1479293545-7516-1-git-send-email-abailon@baylibre.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index e01116e..9b44566 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__ */