lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 02 May 2022 11:31:11 +0100
From:   Marc Zyngier <maz@...nel.org>
To:     Hector Martin <marcan@...can.st>
Cc:     Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Rob Herring <robh@...nel.org>,
        Krzysztof WilczyƄski <kw@...ux.com>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Alyssa Rosenzweig <alyssa@...enzweig.io>,
        Sven Peter <sven@...npeter.dev>, linux-pci@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] PCI: apple: Add support for optional PWREN GPIO

On Mon, 02 May 2022 10:38:32 +0100,
Hector Martin <marcan@...can.st> wrote:
> 
> WiFi and SD card devices on M1 Macs have a separate power enable GPIO.
> Add support for this to the PCIe controller. This is modeled after how
> pcie-fu740 does it.

Please update the DT binding to reflect this as an optional property.

> 
> Signed-off-by: Hector Martin <marcan@...can.st>
> ---
>  drivers/pci/controller/pcie-apple.c | 35 ++++++++++++++++++++++++++---
>  1 file changed, 32 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> index e3aa2d461739..5b73c03ebe94 100644
> --- a/drivers/pci/controller/pcie-apple.c
> +++ b/drivers/pci/controller/pcie-apple.c
> @@ -518,6 +518,16 @@ static int apple_pcie_probe_port(struct device_node *np)
>  	}
>  
>  	gpiod_put(gd);
> +
> +	gd = gpiod_get_from_of_node(np, "pwren-gpios", 0,
> +				    GPIOD_OUT_LOW, "PWREN");
> +	if (IS_ERR(gd)) {
> +		if (PTR_ERR(gd) != -ENOENT)
> +			return PTR_ERR(gd);
> +	} else {
> +		gpiod_put(gd);
> +	}
> +
>  	return 0;
>  }
>  
> @@ -526,7 +536,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
>  {
>  	struct platform_device *platform = to_platform_device(pcie->dev);
>  	struct apple_pcie_port *port;
> -	struct gpio_desc *reset;
> +	struct gpio_desc *reset, *pwren = NULL;
>  	u32 stat, idx;
>  	int ret, i;
>  
> @@ -535,6 +545,15 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
>  	if (IS_ERR(reset))
>  		return PTR_ERR(reset);
>  
> +	pwren = devm_gpiod_get_from_of_node(pcie->dev, np, "pwren-gpios", 0,
> +					    GPIOD_OUT_LOW, "PWREN");
> +	if (IS_ERR(pwren)) {
> +		if (PTR_ERR(pwren) == -ENOENT)
> +			pwren = NULL;
> +		else
> +			return PTR_ERR(pwren);
> +	}
> +
>  	port = devm_kzalloc(pcie->dev, sizeof(*port), GFP_KERNEL);
>  	if (!port)
>  		return -ENOMEM;
> @@ -557,12 +576,22 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
>  	/* Assert PERST# before setting up the clock */
>  	gpiod_set_value_cansleep(reset, 1);
>  
> +	/* Power on the device if required */
> +	if (pwren)
> +		gpiod_set_value_cansleep(pwren, 1);

nit: AFAICT, the gpiod_* helpers already check for a NULL descriptor,
and silently return without an error.

> +
>  	ret = apple_pcie_setup_refclk(pcie, port);
>  	if (ret < 0)
>  		return ret;
>  
> -	/* The minimal Tperst-clk value is 100us (PCIe CEM r5.0, 2.9.2) */
> -	usleep_range(100, 200);
> +	/*
> +	 * The minimal Tperst-clk value is 100us (PCIe CEM r5.0, 2.9.2)
> +	 * If powering up, the minimal Tpvperl is 100ms
> +	 */
> +	if (pwren)
> +		msleep(100);
> +	else
> +		usleep_range(100, 200);
>  
>  	/* Deassert PERST# */
>  	rmw_set(PORT_PERST_OFF, port->base + PORT_PERST);

With the documentation aspect addressed:

Acked-by: Marc Zyngier <maz@...nel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ