[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200414120325.GA28388@Mani-XPS-13-9360>
Date: Tue, 14 Apr 2020 17:38:26 +0530
From: Manivannan Sadhasivam <mani@...nel.org>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>,
Rob Herring <robh+dt@...nel.org>, narcisaanamaria12@...il.com,
Hartmut Knaack <knaack.h@....de>,
Lars-Peter Clausen <lars@...afoo.de>,
Peter Meerwald <pmeerw@...erw.net>,
linux-iio <linux-iio@...r.kernel.org>,
devicetree <devicetree@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/3] iio: chemical: Add support for external Reset and
Wakeup in CCS811
On Mon, Apr 13, 2020 at 11:20:42PM +0300, Andy Shevchenko wrote:
> On Mon, Apr 13, 2020 at 8:34 AM <mani@...nel.org> wrote:
> >
> > From: Manivannan Sadhasivam <mani@...nel.org>
> >
> > CCS811 VOC sensor exposes nRESET and nWAKE pins which can be connected
> > to GPIO pins of the host controller. These pins can be used to externally
> > release the device from reset and also to wake it up before any I2C
> > transaction. The initial driver support assumed that the nRESET pin is not
> > connected and the nWAKE pin is tied to ground.
> >
> > This commit improves it by adding support for controlling those two pins
> > externally using a host controller. For the case of reset, if the hardware
> > reset is not available, the mechanism to do software reset is also added.
> >
> > As a side effect of doing this, the IIO device allocation needs to be
> > slightly moved to top of probe to make use of priv data early.
>
> ...
>
> > +#define CCS811_SW_RESET 0xFF
>
>
> > + reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
> > + GPIOD_OUT_LOW);
> > + if (IS_ERR(reset_gpio)) {
> > + dev_err(&client->dev, "Failed to acquire reset gpio\n");
>
> > + return -EINVAL;
>
> Do not shadow actual error code.
>
Okay. Will change below instance as well.
> > + }
> > +
> > + /* Try to reset using nRESET pin if available else do SW reset */
> > + if (reset_gpio) {
> > + gpiod_set_value(reset_gpio, 1);
> > + usleep_range(20, 30);
> > + gpiod_set_value(reset_gpio, 0);
> > + } else {
>
> > + static const u8 reset_seq[] = {
> > + 0xFF, 0x11, 0xE5, 0x72, 0x8A,
> > + };
>
> Is 0xFF here is CCS811_SW_RESET? If so, can you put it explicitly?
>
Nope. CCS811_SW_RESET is the register address whereas 0xFF here is the actual
value return to the register. I don't know what these values in array represent.
So will keep them as it is.
Thanks,
Mani
> > + ret = i2c_smbus_write_i2c_block_data(client, CCS811_SW_RESET,
> > + sizeof(reset_seq), reset_seq);
> > + if (ret < 0) {
> > + dev_err(&client->dev, "Failed to reset sensor\n");
> > + return ret;
> > + }
> > + }
>
> ...
>
> > + data->wakeup_gpio = devm_gpiod_get_optional(&client->dev, "wakeup",
> > + GPIOD_OUT_HIGH);
> > + if (IS_ERR(data->wakeup_gpio)) {
> > + dev_err(&client->dev, "Failed to acquire wakeup gpio\n");
>
> > + return -EINVAL;
>
> Ditto.
>
> > + }
>
> --
> With Best Regards,
> Andy Shevchenko
Powered by blists - more mailing lists