Re: [PATCH 2/3] iio: chemical: Add support for external Reset and Wakeup in CCS811

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux