On 3/9/21 11:20 Péter Ujfalusi wrote: > > 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 I'll change it to be consistent in the next version. Thank you for the explanation. > > + 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. Okay, thanks. -- Alejandro Tafalla