All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Shawn Guo <shawn.guo@linaro.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>, linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: histb: improve GPIO reset implementation
Date: Wed, 8 Jan 2020 14:43:30 -0600	[thread overview]
Message-ID: <20200108204330.GA203835@google.com> (raw)
In-Reply-To: <20200107121256.16207-1-shawn.guo@linaro.org>

On Tue, Jan 07, 2020 at 08:12:56PM +0800, Shawn Guo wrote:
> It switches GPIO reset code to use gpio_desc, so that the code becomes
> simpler and cleaner.  Also the GPIO signal should be implemented as
> a pulse to trigger a reset, let's correct that in the meantime.

The changelog makes it sound like this is a cleanup + a bug fix.  If
so, please put them in separate patches and describe the effect of the
bug, e.g., "reset doesn't work before this fix" or whatever.

Capitalize the subject ("PCI: histb: Improve...").

> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/pci/controller/dwc/pcie-histb.c | 35 ++++++++++---------------
>  1 file changed, 14 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-histb.c b/drivers/pci/controller/dwc/pcie-histb.c
> index 811b5c6d62ea..d47a8e6d6fa3 100644
> --- a/drivers/pci/controller/dwc/pcie-histb.c
> +++ b/drivers/pci/controller/dwc/pcie-histb.c
> @@ -60,7 +60,7 @@ struct histb_pcie {
>  	struct reset_control *sys_reset;
>  	struct reset_control *bus_reset;
>  	void __iomem *ctrl;
> -	int reset_gpio;
> +	struct gpio_desc *reset_gpio;
>  	struct regulator *vpcie;
>  };
>  
> @@ -219,9 +219,6 @@ static void histb_pcie_host_disable(struct histb_pcie *hipcie)
>  	clk_disable_unprepare(hipcie->sys_clk);
>  	clk_disable_unprepare(hipcie->bus_clk);
>  
> -	if (gpio_is_valid(hipcie->reset_gpio))
> -		gpio_set_value_cansleep(hipcie->reset_gpio, 0);
> -
>  	if (hipcie->vpcie)
>  		regulator_disable(hipcie->vpcie);
>  }
> @@ -242,9 +239,6 @@ static int histb_pcie_host_enable(struct pcie_port *pp)
>  		}
>  	}
>  
> -	if (gpio_is_valid(hipcie->reset_gpio))
> -		gpio_set_value_cansleep(hipcie->reset_gpio, 1);
> -
>  	ret = clk_prepare_enable(hipcie->bus_clk);
>  	if (ret) {
>  		dev_err(dev, "cannot prepare/enable bus clk\n");
> @@ -278,6 +272,14 @@ static int histb_pcie_host_enable(struct pcie_port *pp)
>  	reset_control_assert(hipcie->bus_reset);
>  	reset_control_deassert(hipcie->bus_reset);
>  
> +	if (hipcie->reset_gpio) {
> +		gpiod_set_value_cansleep(hipcie->reset_gpio, 1);
> +		usleep_range(100, 200);
> +		gpiod_set_value_cansleep(hipcie->reset_gpio, 0);
> +		/* wait for 1ms */
> +		usleep_range(1000, 2000);
> +	}
> +
>  	return 0;
>  
>  err_aux_clk:
> @@ -305,10 +307,7 @@ static int histb_pcie_probe(struct platform_device *pdev)
>  	struct dw_pcie *pci;
>  	struct pcie_port *pp;
>  	struct resource *res;
> -	struct device_node *np = pdev->dev.of_node;
>  	struct device *dev = &pdev->dev;
> -	enum of_gpio_flags of_flags;
> -	unsigned long flag = GPIOF_DIR_OUT;
>  	int ret;
>  
>  	hipcie = devm_kzalloc(dev, sizeof(*hipcie), GFP_KERNEL);
> @@ -345,17 +344,11 @@ static int histb_pcie_probe(struct platform_device *pdev)
>  		hipcie->vpcie = NULL;
>  	}
>  
> -	hipcie->reset_gpio = of_get_named_gpio_flags(np,
> -				"reset-gpios", 0, &of_flags);
> -	if (of_flags & OF_GPIO_ACTIVE_LOW)
> -		flag |= GPIOF_ACTIVE_LOW;
> -	if (gpio_is_valid(hipcie->reset_gpio)) {
> -		ret = devm_gpio_request_one(dev, hipcie->reset_gpio,
> -				flag, "PCIe device power control");
> -		if (ret) {
> -			dev_err(dev, "unable to request gpio\n");
> -			return ret;
> -		}
> +	hipcie->reset_gpio = devm_gpiod_get_optional(dev, "reset",
> +						     GPIOD_OUT_LOW);
> +	if (IS_ERR(hipcie->reset_gpio)) {
> +		ret = PTR_ERR(hipcie->reset_gpio);
> +		return ret;
>  	}
>  
>  	hipcie->aux_clk = devm_clk_get(dev, "aux");
> -- 
> 2.17.1
> 

      reply	other threads:[~2020-01-08 20:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 12:12 [PATCH] PCI: histb: improve GPIO reset implementation Shawn Guo
2020-01-08 20:43 ` Bjorn Helgaas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200108204330.GA203835@google.com \
    --to=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=shawn.guo@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.