public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <mani@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	narcisaanamaria12@gmail.com, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	linux-iio <linux-iio@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] iio: chemical: Add support for external Reset and Wakeup in CCS811
Date: Tue, 14 Apr 2020 17:38:26 +0530	[thread overview]
Message-ID: <20200414120325.GA28388@Mani-XPS-13-9360> (raw)
In-Reply-To: <CAHp75VdCK26wXiw0c=1fc0vKsea4w=tthCBrroLOqqaDbwuMVQ@mail.gmail.com>

On Mon, Apr 13, 2020 at 11:20:42PM +0300, Andy Shevchenko wrote:
> On Mon, Apr 13, 2020 at 8:34 AM <mani@kernel.org> wrote:
> >
> > From: Manivannan Sadhasivam <mani@kernel.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

  reply	other threads:[~2020-04-14 12:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-12 18:36 [PATCH 0/3] Add Reset and Wakeup support for CCS811 mani
2020-04-12 18:36 ` [PATCH 1/3] dt-bindings: iio: chemical: Add binding for CCS811 VOC sensor mani
2020-04-13 16:53   ` Jonathan Cameron
2020-04-14 12:10     ` Manivannan Sadhasivam
2020-04-14 13:27   ` Rob Herring
2020-04-14 14:08     ` Manivannan Sadhasivam
2020-04-12 18:36 ` [PATCH 2/3] iio: chemical: Add support for external Reset and Wakeup in CCS811 mani
2020-04-13 16:58   ` Jonathan Cameron
2020-04-13 20:20   ` Andy Shevchenko
2020-04-14 12:08     ` Manivannan Sadhasivam [this message]
2020-04-12 18:36 ` [PATCH 3/3] iio: chemical: Add OF match table for CCS811 VOC sensor mani
2020-04-13 16:50   ` Jonathan Cameron
2020-04-14 11:51     ` Manivannan Sadhasivam
2020-04-13 20:23   ` Andy Shevchenko
2020-04-14 11:53     ` Manivannan Sadhasivam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200414120325.GA28388@Mani-XPS-13-9360 \
    --to=mani@kernel.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=narcisaanamaria12@gmail.com \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox