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]
Message-ID: <ca9075db-de92-4545-8c47-d6c292d57ad9@linaro.org>
Date:   Fri, 15 Sep 2023 10:52:53 +0100
From:   Bryan O'Donoghue <bryan.odonoghue@...aro.org>
To:     Javier Carrasco <javier.carrasco@...fvision.net>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Conor Dooley <conor+dt@...nel.org>
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        devicetree@...r.kernel.org
Subject: Re: [PATCH 1/2] usb: typec: tps6598x: add reset gpio support

On 15/09/2023 07:50, Javier Carrasco wrote:
> The TPS6598x PD controller provides an active-high hardware reset input
> that reinitializes all device settings. If it is not grounded by
> design, the driver must be able to de-assert it in order to initialize
> the device.
> 
> The PD controller is not ready for registration right after the reset
> de-assertion and a delay must be introduced in that case. According to
> TI, the delay can reach up to 1000 ms [1], which is in line with the
> experimental results obtained with a TPS65987D.
> 
> Add a GPIO descriptor for the reset signal and basic reset management
> for initialization and suspend/resume.
> 
> [1] https://e2e.ti.com/support/power-management-group/power-management/
> f/power-management-forum/1269856/tps65987d-tps65987d-reset-de-assert-
> to-normal-operation/4809389#4809389
> 
> Signed-off-by: Javier Carrasco <javier.carrasco@...fvision.net>
> ---
>   drivers/usb/typec/tipd/core.c | 21 ++++++++++++++++++++-
>   1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 37b56ce75f39..550f5913e985 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -8,6 +8,7 @@
>   
>   #include <linux/i2c.h>
>   #include <linux/acpi.h>
> +#include <linux/gpio/consumer.h>
>   #include <linux/module.h>
>   #include <linux/of.h>
>   #include <linux/power_supply.h>
> @@ -43,6 +44,9 @@
>   /* TPS_REG_SYSTEM_CONF bits */
>   #define TPS_SYSCONF_PORTINFO(c)		((c) & 7)
>   
> +/* reset de-assertion to ready for operation */
> +#define SETUP_MS			1000
> +
>   enum {
>   	TPS_PORTINFO_SINK,
>   	TPS_PORTINFO_SINK_ACCESSORY,
> @@ -86,6 +90,7 @@ struct tps6598x {
>   	struct mutex lock; /* device lock */
>   	u8 i2c_protocol:1;
>   
> +	struct gpio_desc *reset;
>   	struct typec_port *port;
>   	struct typec_partner *partner;
>   	struct usb_pd_identity partner_identity;
> @@ -717,6 +722,13 @@ static int tps6598x_probe(struct i2c_client *client)
>   	mutex_init(&tps->lock);
>   	tps->dev = &client->dev;
>   
> +	tps->reset = devm_gpiod_get_optional(tps->dev, "reset", GPIOD_OUT_LOW);
> +	if (IS_ERR(tps->reset))
> +		return dev_err_probe(tps->dev, PTR_ERR(tps->reset),
> +				     "failed to get reset GPIO\n");
> +	if (tps->reset)
> +		msleep(SETUP_MS);
> +

This looks a bit odd to me, shouldn't you drive reset to zero ?

if (tps->reset) {
     gpiod_set_value_cansleep(tps->reset, 0);
     msleep(SETUP_MS);
}

also wouldn't it make sense to functionally decompose that and reuse in 
probe() and tps6598x_resume() ?

tps6598x_reset() {
     if (tps->reset) {
         gpiod_set_value_cansleep(tps->reset, 0);
         msleep(SETUP_MS);
     }
}

---
bod

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ