From patchwork Tue Oct 25 14:39:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 79190 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp3150954qge; Tue, 25 Oct 2016 07:39:57 -0700 (PDT) X-Received: by 10.98.194.68 with SMTP id l65mr40535808pfg.159.1477406397111; Tue, 25 Oct 2016 07:39:57 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t2si21045726pgn.273.2016.10.25.07.39.56; Tue, 25 Oct 2016 07:39:57 -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 S1758911AbcJYOji (ORCPT + 4 others); Tue, 25 Oct 2016 10:39:38 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:35978 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758410AbcJYOjh (ORCPT ); Tue, 25 Oct 2016 10:39:37 -0400 Received: by mail-wm0-f44.google.com with SMTP id b80so167475498wme.1 for ; Tue, 25 Oct 2016 07:39:15 -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=mVXp1Kd4/fJRp9TTw0yxnKNGmkfjrpY5ekOBVaYBuzHrn2Tv4MfNVF9/Q8ZaIFsZ98 GSKlH+mDepkTQvVgRO822+iABeWzrXUAUt+b4myBEKp8i1EEyVOjuj2SKwRVQe+Vixqv dg5l4qlOc0gg8X/EBrRkwZSM6xlgYH5YqHAunjpNIq3zVYG5erGSxd4WlE3ybTCM10Ns TaezQOO9qPpy9z12o6Py0Nu11d3Jtk6D7ynnKG0xL5Zp5LXKiJrJz2tbwVAg9a9a8cly Zy8QR9i5isH6H6VAC9OuZHCBubpBKYcf1bwIC0EXo7nKp6As8wLciSp+njAftssdaj70 zfNQ== 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=Phx1GLNKK+4W23MYHoto2A7SfpkV8HfyN7saS6WSUPhTbA3XvGrdPtNMgc3RzqLQv3 TDTbdgMdaxjbEVzPdHbl24+JEZR8nb8/AVlnt9DefsB5CcME/zZQbkacpPG85p7Hylhu i6rbvCYHAGfS8xDCaU+h+v9Z/nMnprJ60t6meptKoRPb+ONthj7cY8TfRnhH909pN06h ZlTSMmolzn5/AENQdVCDdxpke0dHwTMJ3o3rWNL1mlzsrf8ZrqTMVgXWYd5NIeKaYcmF gZaA+Xl9W9zIDrx5Nx5ZNvdLRiOoVzkXYl2JyMMTGMdTJFy2nEosth4yO2FxnvtaiJaB sz/w== X-Gm-Message-State: ABUngvf2Npexvig70GbmZqoTUAhe8ofTIJOx+wMEbfHBrf6VdespQ24CvcLKso61bd1Uqacy X-Received: by 10.28.4.16 with SMTP id 16mr3973471wme.39.1477406354042; Tue, 25 Oct 2016 07:39:14 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id r72sm4030723wmd.21.2016.10.25.07.39.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Oct 2016 07:39:13 -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 2/4] usb: musb: core: added helper function for parsing DT Date: Tue, 25 Oct 2016 16:39:03 +0200 Message-Id: <1477406345-27192-3-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1477406345-27192-1-git-send-email-abailon@baylibre.com> References: <1477406345-27192-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__ */