From patchwork Thu Nov 3 15:26:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 80684 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp692703qge; Thu, 3 Nov 2016 08:27:45 -0700 (PDT) X-Received: by 10.36.131.138 with SMTP id d132mr5782414ite.98.1478186865068; Thu, 03 Nov 2016 08:27:45 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wm3si8508331pab.75.2016.11.03.08.27.44; Thu, 03 Nov 2016 08:27:45 -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 S1758115AbcKCP1Y (ORCPT + 4 others); Thu, 3 Nov 2016 11:27:24 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:35903 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758088AbcKCP0Q (ORCPT ); Thu, 3 Nov 2016 11:26:16 -0400 Received: by mail-wm0-f47.google.com with SMTP id p190so340569042wmp.1 for ; Thu, 03 Nov 2016 08:26: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=9kIGS+J9UeDa+nhZ/yEkLgOvAq91y2VYAXZgk+fkrzM=; b=VYFq2yqpYIINDjUr/mpEFgZH1g7n7YD/uycKdMFc9XEDfl+44xgCUx+0kaCn4ADyLA aA5bITjbD3QEl5JQAQ9NfbYr3paq3wHY3ipD/sCGg5hBUhsnzGy6towjcjk/+ho4FI1f hud4nlZx75pduCBMeQ/IVMWCA/tyVrbecC4kr6bx/9gfs9X5IXGk0pt1zoV247r5czat tMQYz/O7SrieYYOGgvYB2084nR01jHLrCbggyRTbmDJ9/hmJt8RdbViaqQvo9Qph/e9+ +rxuKbMaBTQ3EE2ch9LBv55BVTMIG1x0uRzb6QkXYxC16uVXVcFndKd5faLKaIIAUjNg nSRQ== 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=9kIGS+J9UeDa+nhZ/yEkLgOvAq91y2VYAXZgk+fkrzM=; b=bHvLs6EqNCWR+/tXLeoLn+N2OUwAgVp6T5QpQUYfih4L91afoT9B00U7tl5v4YifT5 jhbwhFts2dkbNrcLKV6uQqbYlGX1IbY55Wxa0y8wDUAKMNtj/+4VOJPqKy7V51CtiT+h HncYCpkMCOn3SdwvGKiJS9IJNk+0cJDl89CNtglY1RzajsYfaHm/iHfgFLugHb1IWH0j GYPtPNh1JS0iNt4BMVP45xsaQQkC7YrWmk2hDfGqSpQmLW4F1vugCLy4ERzWg/GiSiTZ FB2J1iIAj89W3MdJ5bnbub1gepmoXMmyF3/EQx6w8cNjGhf5AociC+Xr9BPlYBabFJin ex6Q== X-Gm-Message-State: ABUngvey3ICTMvp8ZR3ATdKis4neTUhB6SemIV3xFyyQnIszw05XTHOkTc+ELs/uoceKW7DO X-Received: by 10.28.147.81 with SMTP id v78mr2751468wmd.60.1478186774243; Thu, 03 Nov 2016 08:26:14 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id wh3sm9108948wjb.49.2016.11.03.08.26.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Nov 2016 08:26:13 -0700 (PDT) From: Alexandre Bailon To: david@lechnology.com, b-liu@ti.com, balbi@kernel.org Cc: kishon@ti.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, nsekhar@ti.com, Alexandre Bailon Subject: [PATCH v3 4/5] phy: da8xx-usb: Use usb20_force_mode property to configure the phy mode Date: Thu, 3 Nov 2016 16:26:04 +0100 Message-Id: <1478186765-19840-5-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1478186765-19840-1-git-send-email-abailon@baylibre.com> References: <1478186765-19840-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 The USB PHY is able to operate in OTG, host or peripheral. Some board may be wired to work act only as host or peripheral. In such case, the dr_mode property of controller must be set to host or peripheral. But doing that will also configure the PHY in host or peripheral mode whereas OTG is able to detect which role the USB controller should take. The PHY's host or peripheral mode are actually only useful when hardware doesn't allow OTG to detect it's role. There is some issues when the PHY is forced in peripheral or host mode, and it worth to let the PHY in OTG when that is possible. Only force the PHY in a specific mode if usb20_force_mode is set in DT. Signed-off-by: Alexandre Bailon --- drivers/phy/phy-da8xx-usb.c | 11 +++++++++++ 1 file changed, 11 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/phy/phy-da8xx-usb.c b/drivers/phy/phy-da8xx-usb.c index fd39292..bf1b3af 100644 --- a/drivers/phy/phy-da8xx-usb.c +++ b/drivers/phy/phy-da8xx-usb.c @@ -22,6 +22,7 @@ #include #include #include +#include struct da8xx_usb_phy { struct phy_provider *phy_provider; @@ -109,6 +110,7 @@ static int da8xx_usb20_phy_set_mode(struct phy *phy, enum phy_mode mode) case PHY_MODE_USB_DEVICE: /* Force VBUS valid, ID = 1 */ val |= CFGCHIP2_OTGMODE_FORCE_DEVICE; break; + case PHY_MODE_INVALID: case PHY_MODE_USB_OTG: /* Don't override the VBUS/ID comparators */ val |= CFGCHIP2_OTGMODE_NO_OVERRIDE | CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN; @@ -152,6 +154,7 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *node = dev->of_node; struct da8xx_usb_phy *d_phy; + enum usb_dr_mode dr_mode = PHY_MODE_INVALID; d_phy = devm_kzalloc(dev, sizeof(*d_phy), GFP_KERNEL); if (!d_phy) @@ -202,6 +205,13 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev) dev_err(dev, "Failed to create phy provider\n"); return PTR_ERR(d_phy->phy_provider); } + + if (of_find_property(node, "usb20-force-mode", NULL)) { + dr_mode = of_usb_get_dr_mode_by_phy(node, 0); + if (dr_mode == USB_DR_MODE_UNKNOWN || + dr_mode == USB_DR_MODE_OTG) + dev_warn(dev, "dr_mode is not properly set\n"); + } } else { int ret; @@ -213,6 +223,7 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev) if (ret) dev_warn(dev, "Failed to create usb20 phy lookup\n"); } + da8xx_usb20_phy_set_mode(d_phy->usb20_phy, dr_mode); return 0; }