From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932835AbcJZPlB (ORCPT ); Wed, 26 Oct 2016 11:41:01 -0400 Received: from vern.gendns.com ([206.190.152.46]:41227 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932173AbcJZPk7 (ORCPT ); Wed, 26 Oct 2016 11:40:59 -0400 Subject: Re: [PATCH v2 2/3] phy: da8xx-usb: Configure CFGCHIP2 to support OTG workaround To: Alexandre Bailon , khilman@baylibre.com, b-liu@ti.com, balbi@kernel.org References: <1477479503-5131-1-git-send-email-abailon@baylibre.com> <1477479503-5131-3-git-send-email-abailon@baylibre.com> Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Kishon Vijay Abraham I From: David Lechner Message-ID: <8e83a891-5088-9f14-021f-67e90d2c17ca@lechnology.com> Date: Wed, 26 Oct 2016 10:40:58 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1477479503-5131-3-git-send-email-abailon@baylibre.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/26/2016 05:58 AM, Alexandre Bailon wrote: > 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(-) > > 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; The AM1808 TRM indicates that CFGCHIP2_SESENDEN and CFGCHIP2_VBDTCTEN (and CFGCHIP2_DATPOL) should be on for normal operation of the USB 2.0 PHY. They do not appear to be associated with the OTG mode specifically. It seems to me that it would be more appropriate to set these in da8xx_usb20_phy_power_on() instead of here in da8xx_usb20_phy_set_mode(). > 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; > } > Also cc'ing phy maintainer since this is a phy driver.