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: 79434 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp112769qge; Wed, 26 Oct 2016 08:06:03 -0700 (PDT) X-Received: by 10.98.142.26 with SMTP id k26mr5041806pfe.26.1477494363130; Wed, 26 Oct 2016 08:06:03 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b85si3141731pfl.136.2016.10.26.08.06.02; Wed, 26 Oct 2016 08:06:03 -0700 (PDT) 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 S1754096AbcJZPEI (ORCPT + 4 others); Wed, 26 Oct 2016 11:04:08 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:33948 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbcJZPEG (ORCPT ); Wed, 26 Oct 2016 11:04:06 -0400 Received: by mail-wm0-f44.google.com with SMTP id d128so13820752wmf.1 for ; Wed, 26 Oct 2016 08:04:05 -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=BtZcWqZ6/Yy+dlyIjBmS4SttU5XSU3UR7/JmZc6w7JyM7YCAozHBWiVkX6Hl7EsEmF +hWdsoe/Bmsi/NeMXAyxyKou+BukK4XC7yz0gRWYYO8ZCwi4mOtgUjX9p36BJ+/0PV20 SoIcyFpTxS9Pvq0baVkp0POobhJfXWpIk8oc3KNZOmYqjW9vYkokMN1igmFIYrHIsUa8 oN3/6ScpCUCwsSBKhy7iIv1HhEhfTBwH1LTY1Jfd6DaqdsZuxkd8W4Cb4QkyGVG1Pgx4 c3sx0OIB1I5XdkOTwrC3vODUaQVDWx2kg54HA0deBaX7cQKzBAMRUvtKlj2sVUyAMcgv 3ilA== X-Gm-Message-State: ABUngveqEc0dxEz/C99tpNo69VpVGvINETMbw96/cIdaGkg97F9hFhhTJPcRfKGlSW3WvpmL 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 Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Petr Kulhavy , Alexandre Bailon 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> 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 --- drivers/usb/musb/musb_core.c | 19 +++++++++++++++++++ drivers/usb/musb/musb_core.h | 5 +++++ 2 files changed, 24 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 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__ */