From patchwork Wed Oct 26 10:58:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 79394 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp341499qge; Wed, 26 Oct 2016 03:58:50 -0700 (PDT) X-Received: by 10.99.105.72 with SMTP id e69mr2589680pgc.158.1477479530092; Wed, 26 Oct 2016 03:58:50 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r133si1943828pgr.239.2016.10.26.03.58.49; Wed, 26 Oct 2016 03:58:50 -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 S1754783AbcJZK6h (ORCPT + 4 others); Wed, 26 Oct 2016 06:58:37 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:37620 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753753AbcJZK6e (ORCPT ); Wed, 26 Oct 2016 06:58:34 -0400 Received: by mail-wm0-f42.google.com with SMTP id 140so13539514wmv.0 for ; Wed, 26 Oct 2016 03:58:33 -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=Q4+6Qgy7yKGWA/aDa8n+6sUJ4xy0CpoTICG7HslspWs=; b=zKvIJCOf4BkyHs6Fp8sVIJqd/SS32fJumQlbb6nguj6KxWT6Ag7p0YqNxgndmOZg35 QZvNVOmk9hwFm7+o4w7S4cOC8BFkftgLZc31tQt+e42nKLuBPXQS5XcPw4aOtGTfnTht wVAXC9oOP4XBdOf9Y3wKPM5LRt2v9jQ0BZoIXVGrIr+fi5ctLbZJWFd22KW6ddB25nSj ZpoODo5PkvzrvN7tu7cJ63Jk/qQwN1xdBnatC8S9zRAC9nWEoLEc1bKQzZ5Nm5E5Akci zBtpj4HjLyfsKaZfIc9Zni5rLMOqSnpPzSG8sQ2hfTSHiqya3nvnGb/NUI4v0GGS8dMA x17w== 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=Q4+6Qgy7yKGWA/aDa8n+6sUJ4xy0CpoTICG7HslspWs=; b=EcTBhcZvh0KvDp006hSSBoq4qxoiuk37wBEiL0RyrlAGlt+ajROALsBkvXCaQNNJaf 3JPe05UNJZO34/Rah4TKRMFohYS9DDZsTRiEUzpL/w+6cPEuvC85tiTl98nqPV/9c0em IBx/SBPky/vLXZYYvq8RV/958VyvFry2U4nBipnI+jm30v//qKvlaQyexKvU/WCUfpjQ j15O1oR0Q8N0y4WHNwsKADEKRJz2DpaBSnHmNoqwp1Wv9+NKdlko/NFXvVagkOR9x4j5 hOHyWbM0sUtmcjnqqN7VzH+WMnY5ahpqAHQVH3QAisHlSB5+2mZvDsAXI1yF62c4E6wj Cf/g== X-Gm-Message-State: ABUngvforvXvz/cSu1uzkfuyNcIceWyTVEUBr52CiKaVMWogFnqfMX6EkIF91szwDaA25TiG X-Received: by 10.28.170.204 with SMTP id t195mr2081538wme.113.1477479512541; Wed, 26 Oct 2016 03:58:32 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id yo1sm1972572wjc.16.2016.10.26.03.58.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Oct 2016 03:58:32 -0700 (PDT) From: Alexandre Bailon To: khilman@baylibre.com, david@lechnology.com, b-liu@ti.com, balbi@kernel.org Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Alexandre Bailon Subject: [PATCH v2 2/3] phy: da8xx-usb: Configure CFGCHIP2 to support OTG workaround Date: Wed, 26 Oct 2016 12:58:22 +0200 Message-Id: <1477479503-5131-3-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1477479503-5131-1-git-send-email-abailon@baylibre.com> References: <1477479503-5131-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 If we configure the da8xx OTG phy in OTG mode, neither device or host mode will work. That is because the PHY is not able to detect and notify the driver that value of ID pin changed. To work despite this hardware limitation, the da8xx glue implement a workaround. But to work, the workaround require the VBUS sense and the session end comparator to enabled. Enable them if the phy is configured in OTG mode. Signed-off-by: Alexandre Bailon --- drivers/phy/phy-da8xx-usb.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) -- 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 32ae78c..fd39292 100644 --- a/drivers/phy/phy-da8xx-usb.c +++ b/drivers/phy/phy-da8xx-usb.c @@ -93,24 +93,31 @@ static int da8xx_usb20_phy_power_off(struct phy *phy) static int da8xx_usb20_phy_set_mode(struct phy *phy, enum phy_mode mode) { struct da8xx_usb_phy *d_phy = phy_get_drvdata(phy); + int ret; u32 val; + ret = regmap_read(d_phy->regmap, CFGCHIP(2), &val); + if (ret) + return ret; + + val &= ~CFGCHIP2_OTGMODE_MASK; + switch (mode) { case PHY_MODE_USB_HOST: /* Force VBUS valid, ID = 0 */ - val = CFGCHIP2_OTGMODE_FORCE_HOST; + val |= CFGCHIP2_OTGMODE_FORCE_HOST; break; case PHY_MODE_USB_DEVICE: /* Force VBUS valid, ID = 1 */ - val = CFGCHIP2_OTGMODE_FORCE_DEVICE; + val |= CFGCHIP2_OTGMODE_FORCE_DEVICE; break; case PHY_MODE_USB_OTG: /* Don't override the VBUS/ID comparators */ - val = CFGCHIP2_OTGMODE_NO_OVERRIDE; + val |= CFGCHIP2_OTGMODE_NO_OVERRIDE | + CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN; break; default: return -EINVAL; } - regmap_write_bits(d_phy->regmap, CFGCHIP(2), CFGCHIP2_OTGMODE_MASK, - val); + regmap_write(d_phy->regmap, CFGCHIP(2), val); return 0; }