Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp822936ybe; Wed, 11 Sep 2019 05:23:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqEdUJUoN4wALmcfw+IZu/ir8mBSxWYy6o1HdTc5jo+280UKwarpVaFj5dgg7Yy0EwGRz3 X-Received: by 2002:a17:906:2929:: with SMTP id v9mr29238402ejd.108.1568204585576; Wed, 11 Sep 2019 05:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568204585; cv=none; d=google.com; s=arc-20160816; b=gwIAJkQlUcWIKvLuWjVskt3mNj55AHhEoVmNn2hCXhA404kiN4u01OsZ96M5o25n3b mFMfS0nKIct+a49dmsY9wlFCYelZewfJQrhdfcYM+LyztZgeEi9fcFjZ7k5jOGjOxRrC JDDvt3OpXd2onx35I/2X3zmkozIiCRrrdMRryiojsxbkkhrwqrL+iV97USRpwZd0DfDs A3jhG1udXopkYaYb27QK58VHa5ZGgCSniV1hUtQbp0dO0jiPS0uyHFiui7+ZECcGiSry uqTtnMFLZ+iqLLPONmrlLPvxLgcAHih7S5zpF48E1wXPNyNYSHmy0KnpfVnHys/IR/Om eQTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=0LwczQ2EhvtUXQItTMDPFgI+63YVyTk+0FsSDqerSa4=; b=Cs0+6diciJIteUtLeszJQuR8CElCsYb3G7eHVAzxv1BPCWvhtktCaP1in4kKDr/tFj vrJfZjDv9nQkUp1aobUZnjwoMqh6zUMVJiJavqtUMWX8C7VgbowMobUxXc6Dro7uZjYf M6XwU89t7PSBIYfgLte7Nf2E7CnYSMI2JBc4tJSIUirZIVqBIMotUVT+EJPI9UCtFf4d LmjHlG/k7ZzVI6UxICTCG+soVzaQRe3f/rLvPGqhE5/lCBLCgCzxPLGoUCHA+R1idqXn eLEUgTJP1bnPEnblThKLe3zxycv8Bvz/cj6cWeJZIMjbmtXYvddwM2w75V8at1IlLmn1 brTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u15si10569723ejx.216.2019.09.11.05.22.41; Wed, 11 Sep 2019 05:23:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727839AbfIKMT7 (ORCPT + 99 others); Wed, 11 Sep 2019 08:19:59 -0400 Received: from foss.arm.com ([217.140.110.172]:46592 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727786AbfIKMT7 (ORCPT ); Wed, 11 Sep 2019 08:19:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3D1D91000; Wed, 11 Sep 2019 05:19:58 -0700 (PDT) Received: from localhost (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A969D3F59C; Wed, 11 Sep 2019 05:19:57 -0700 (PDT) Date: Wed, 11 Sep 2019 13:19:56 +0100 From: Andrew Murray To: Neil Armstrong Cc: khilman@baylibre.com, bhelgaas@google.com, lorenzo.pieralisi@arm.com, yue.wang@Amlogic.com, kishon@ti.com, repk@triplefau.lt, maz@kernel.org, linux-amlogic@lists.infradead.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/6] phy: meson-g12a-usb3-pcie: Add support for PCIe mode Message-ID: <20190911121954.GS9720@e119886-lin.cambridge.arm.com> References: <1567950178-4466-1-git-send-email-narmstrong@baylibre.com> <1567950178-4466-5-git-send-email-narmstrong@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1567950178-4466-5-git-send-email-narmstrong@baylibre.com> User-Agent: Mutt/1.10.1+81 (426a6c1) (2018-08-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 08, 2019 at 01:42:56PM +0000, Neil Armstrong wrote: > This adds extended PCIe PHY functions for the Amlogic G12A > USB3+PCIE Combo PHY to support reset, power_on and power_off for > PCIe exclusively. > > With these callbacks, we can handle all the needed operations of the > Amlogic PCIe controller driver. > > Signed-off-by: Neil Armstrong > --- > .../phy/amlogic/phy-meson-g12a-usb3-pcie.c | 70 ++++++++++++++++--- > 1 file changed, 61 insertions(+), 9 deletions(-) > > diff --git a/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c b/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c > index ac322d643c7a..08e322789e59 100644 > --- a/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c > +++ b/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c > @@ -50,6 +50,8 @@ > #define PHY_R5_PHY_CR_ACK BIT(16) > #define PHY_R5_PHY_BS_OUT BIT(17) > > +#define PCIE_RESET_DELAY 500 > + > struct phy_g12a_usb3_pcie_priv { > struct regmap *regmap; > struct regmap *regmap_cr; > @@ -196,6 +198,10 @@ static int phy_g12a_usb3_init(struct phy *phy) > struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy); > int data, ret; > > + ret = reset_control_reset(priv->reset); > + if (ret) > + return ret; > + Right, so we've moved this to apply to USB only, thus assuming PCI will call .reset for its reset (why the asymmetry?). Thanks, Andrew Murray > /* Switch PHY to USB3 */ > /* TODO figure out how to handle when PCIe was set in the bootloader */ > regmap_update_bits(priv->regmap, PHY_R0, > @@ -272,24 +278,64 @@ static int phy_g12a_usb3_init(struct phy *phy) > return 0; > } > > -static int phy_g12a_usb3_pcie_init(struct phy *phy) > +static int phy_g12a_usb3_pcie_power_on(struct phy *phy) > +{ > + struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy); > + > + if (priv->mode == PHY_TYPE_USB3) > + return 0; > + > + regmap_update_bits(priv->regmap, PHY_R0, > + PHY_R0_PCIE_POWER_STATE, > + FIELD_PREP(PHY_R0_PCIE_POWER_STATE, 0x1c)); > + > + return 0; > +} > + > +static int phy_g12a_usb3_pcie_power_off(struct phy *phy) > +{ > + struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy); > + > + if (priv->mode == PHY_TYPE_USB3) > + return 0; > + > + regmap_update_bits(priv->regmap, PHY_R0, > + PHY_R0_PCIE_POWER_STATE, > + FIELD_PREP(PHY_R0_PCIE_POWER_STATE, 0x1d)); > + > + return 0; > +} > + > +static int phy_g12a_usb3_pcie_reset(struct phy *phy) > { > struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy); > int ret; > > - ret = reset_control_reset(priv->reset); > + if (priv->mode == PHY_TYPE_USB3) > + return 0; > + > + ret = reset_control_assert(priv->reset); > if (ret) > return ret; > > + udelay(PCIE_RESET_DELAY); > + > + ret = reset_control_deassert(priv->reset); > + if (ret) > + return ret; > + > + udelay(PCIE_RESET_DELAY); > + > + return 0; > +} > + > +static int phy_g12a_usb3_pcie_init(struct phy *phy) > +{ > + struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy); > + > if (priv->mode == PHY_TYPE_USB3) > return phy_g12a_usb3_init(phy); > > - /* Power UP PCIE */ > - /* TODO figure out when the bootloader has set USB3 mode before */ > - regmap_update_bits(priv->regmap, PHY_R0, > - PHY_R0_PCIE_POWER_STATE, > - FIELD_PREP(PHY_R0_PCIE_POWER_STATE, 0x1c)); > - > return 0; > } > > @@ -297,7 +343,10 @@ static int phy_g12a_usb3_pcie_exit(struct phy *phy) > { > struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy); > > - return reset_control_reset(priv->reset); > + if (priv->mode == PHY_TYPE_USB3) > + return reset_control_reset(priv->reset); > + > + return 0; > } > > static struct phy *phy_g12a_usb3_pcie_xlate(struct device *dev, > @@ -326,6 +375,9 @@ static struct phy *phy_g12a_usb3_pcie_xlate(struct device *dev, > static const struct phy_ops phy_g12a_usb3_pcie_ops = { > .init = phy_g12a_usb3_pcie_init, > .exit = phy_g12a_usb3_pcie_exit, > + .power_on = phy_g12a_usb3_pcie_power_on, > + .power_off = phy_g12a_usb3_pcie_power_off, > + .reset = phy_g12a_usb3_pcie_reset, > .owner = THIS_MODULE, > }; > > -- > 2.17.1 >