lkml.org 
[lkml]   [2019]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [PATCH 2/4] nvmem: add support for the write-protect pin
Hi Khouloud,

more comments!

On Wed, Nov 20, 2019 at 3:21 PM Khouloud Touil <ktouil@baylibre.com> wrote:

> + if (nvmem->reg_write) {
> + gpiod_set_value_cansleep(nvmem->wp_gpio, 0);
> + ret = nvmem->reg_write(nvmem->priv, offset, val, bytes);
> + gpiod_set_value_cansleep(nvmem->wp_gpio, 1);
> + return ret;
> + }

Since I requested that the GPIO line shall be flagged as
active low in the device tree, make sure to invert this
and toss in a comment:

/*
* We assert and deassert the write protection GPIO line.
* This line is often active low, but that semantic is handled
* in gpiolib in respons to flags in the machine description,
* such as the device tree or ACPI.
*/
gpiod_set_value_cansleep(nvmem->wp_gpio, 1);
ret = nvmem->reg_write(nvmem->priv, offset, val, bytes);
gpiod_set_value_cansleep(nvmem->wp_gpio, 0);

> @@ -365,6 +372,15 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> kfree(nvmem);
> return ERR_PTR(rval);
> }
> + if (config->wp_gpio)
> + nvmem->wp_gpio = config->wp_gpio;
> + else
> + nvmem->wp_gpio = gpiod_get_optional(config->dev,
> + "wp",
> + GPIOD_OUT_HIGH);

GPIOD_OUT_LOW as it will be inverted.

Apart from this I like the idea in this patch!

Yours,
Linus Walleij

\
 
 \ /
  Last update: 2019-11-22 13:47    [W:0.176 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site