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: <80973391-4579-e14b-6def-ed81f367a4a5@linux.intel.com>
Date:   Fri, 3 Sep 2021 12:20:37 +0300
From:   Péter Ujfalusi <peter.ujfalusi@...ux.intel.com>
To:     Alejandro <atafalla@...on.com>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>,
        Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     devicetree@...r.kernel.org, alsa-devel@...a-project.org,
        linux-kernel@...r.kernel.org, Takashi Iwai <tiwai@...e.com>,
        Rob Herring <robh+dt@...nel.org>
Subject: Re: [PATCH v3 1/2] ASoC: max98927: Handle reset gpio when probing i2c



On 03/09/2021 04:49, Alejandro wrote:
> From: Alejandro Tafalla <atafalla@...on.com>
> 
> Drive the reset gpio if defined in the DTS node.
> 
> Signed-off-by: Alejandro Tafalla <atafalla@...on.com>
> ---
>  sound/soc/codecs/max98927.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c
> index 8b206ee77709..daf06b503433 100644
> --- a/sound/soc/codecs/max98927.c
> +++ b/sound/soc/codecs/max98927.c
> @@ -868,6 +868,7 @@ static int max98927_i2c_probe(struct i2c_client *i2c,
>  	int ret = 0, value;
>  	int reg = 0;
>  	struct max98927_priv *max98927 = NULL;
> +	struct gpio_desc *reset_gpio;
>  
>  	max98927 = devm_kzalloc(&i2c->dev,
>  		sizeof(*max98927), GFP_KERNEL);
> @@ -898,6 +899,19 @@ static int max98927_i2c_probe(struct i2c_client *i2c,
>  		return ret;
>  	}
>  
> +	reset_gpio
> +		= devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_LOW);

If this is a 'reset' pin then it's ACTIVE state is when it places the
device to _reset_.
GPIOD_OUT_LOW == Deasserted state of the GPIO line.

If the reset pin should be pulled low for reset (GPIO_ACTIVE_LOW) and
you want the device initially  in reset then you need GPIOD_OUT_HIGH,
because:
GPIOD_OUT_HIGH == Asserted state of the GPIO line.

Same goes for the gpiod_set_value_cansleep():
0 - deasserted
1 = asserted

and this all depends on how the gpio is defined in DT
(GPIO_ACTIVE_LOW/HIGH), which depends on how the documentation refers to
the pin...

reset pin:
low to keep the device in reset, high to release it from reset:
GPIO_ACTIVE_LOW
gpiod_set_value_cansleep(0) to enable
gpiod_set_value_cansleep(1) to disable


enable pin:
high to enable the part, low to disable
GPIO_ACTIVE_HIGH
gpiod_set_value_cansleep(1) to enable
gpiod_set_value_cansleep(0) to disable

In both cases
electrical 0: reset/disable
electrical 1: enable

> +	if (IS_ERR(reset_gpio)) {
> +		ret = PTR_ERR(reset_gpio);
> +		return dev_err_probe(&i2c->dev, ret, "failed to request GPIO reset pin");
> +	}
> +
> +	if (reset_gpio) {
> +		usleep_range(8000, 10000);
> +		gpiod_set_value_cansleep(reset_gpio, 1);
> +		usleep_range(1000, 5000);
> +	}
> +

You might want to put the device to reset on remove at minimum.

>  	/* Check Revision ID */
>  	ret = regmap_read(max98927->regmap,
>  		MAX98927_R01FF_REV_ID, &reg);
> 

-- 
Péter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ