From patchwork Wed Oct 26 15:03:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9397447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6736A60236 for ; Wed, 26 Oct 2016 15:07:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48E8D29BFB for ; Wed, 26 Oct 2016 15:07:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BF0329C03; Wed, 26 Oct 2016 15:07:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A6FE529BFB for ; Wed, 26 Oct 2016 15:07:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bzPmP-0003kQ-C4; Wed, 26 Oct 2016 15:06:13 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bzPkn-0001bG-PC for linux-arm-kernel@bombadil.infradead.org; Wed, 26 Oct 2016 15:04:33 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by merlin.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bzPki-0004kR-WF for linux-arm-kernel@lists.infradead.org; Wed, 26 Oct 2016 15:04:32 +0000 Received: by mail-wm0-x230.google.com with SMTP id e69so36703463wmg.0 for ; Wed, 26 Oct 2016 08:04:06 -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=w2kly9zpn+ykftSw2AnJYvCUbUNfldLPwMqG6pTTfqI=; b=fkHx4UeVWSsnRfqOm0iqX8D6H1lP+FZhUopXyKl47J+veVNhNJOY4EPzjmHP3Fslmz gCakQ8fEiBx3LIF1IsKOE8SVoDJ+rdo+mhc8t1d5tUJK8rKPSep13lx+fc5H55StR8b0 usyTByo97vp1FYae07x620pWw3kAxQhSZHHVNEtLz+bRNNhzZpy4+bDyuz76gg43bxix 4HJJf6b3/e0vEJwRwFd4egyF3zvEUg4BGdsOSriDTGsVG6QxuUu11WXduy17f+9s9zBw Ac9SRNlJfS1J5323ThFdefT29kcHp6LrVaDl99cbY9yzpa+eI5EpeqyDIfWnjt66FVHq nbkw== 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=w2kly9zpn+ykftSw2AnJYvCUbUNfldLPwMqG6pTTfqI=; b=bx4wLUFE+hE9cgMWz/4wxHPF8fo6oV2MTzxI7Iggf0AK54oQbjZd6FR7486nsUoMay q/GknQgVSXuinIh1u6y+k7h5eMHQeOQ+yjs4Ra5k9Lsmqb+ooCUFeoyLhiE/tEYjHQDM LKMH122Z28WAuIJxYNJyzGZoX8zgPcEEu0Glao1Zty0DtIr/6rJQhuGLsQWREresWQAe UghPgf7ermJEftaKCA7e3mmLYAH8Lp8fEcpXok3wyYuGuORL6I5YPY2rAvmChQigzSVW gGMrTHgcVA+MI+WZSmZlS2+xzI/FQa5Tr3oZYR7soKej5F1m4rfWbKkAV5qzuPEGWlPu gfcA== X-Gm-Message-State: ABUngve9QJRR+PMSz8NROetOMI5iY9g3dCzLFn5GO05cNrKB4TNXjEenZMruhKCTJLzFmKbz X-Received: by 10.28.57.84 with SMTP id g81mr3205891wma.91.1477494244347; Wed, 26 Oct 2016 08:04:04 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id p184sm3604259wmg.3.2016.10.26.08.04.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Oct 2016 08:04:03 -0700 (PDT) From: Alexandre Bailon To: khilman@baylibre.com, robh+dt@kernel.org, b-liu@ti.com Subject: [PATCH v2 2/4] usb: musb: core: added helper function for parsing DT Date: Wed, 26 Oct 2016 17:03:55 +0200 Message-Id: <1477494237-22831-3-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1477494237-22831-1-git-send-email-abailon@baylibre.com> References: <1477494237-22831-1-git-send-email-abailon@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161026_110429_164799_365C6B26 X-CRM114-Status: GOOD ( 14.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Kulhavy , Alexandre Bailon , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/usb/musb/musb_core.c | 19 +++++++++++++++++++ drivers/usb/musb/musb_core.h | 5 +++++ 2 files changed, 24 insertions(+) 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..a406468 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -617,4 +617,9 @@ 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__ */