Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ad7768-1: Add reset gpio

Implement asynchronous hardware reset GPIO.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Co-developed-by: Jonathan Santos <Jonathan.Santos@analog.com>
Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Link: https://patch.msgid.link/25a413babeddf29583f1c26abf4234dfd606a595.1744325346.git.Jonathan.Santos@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Sergiu Cuciurean and committed by
Jonathan Cameron
1fa0f4ea 3f4bc0b1

+24 -12
+24 -12
drivers/iio/adc/ad7768-1.c
··· 163 163 struct completion completion; 164 164 struct iio_trigger *trig; 165 165 struct gpio_desc *gpio_sync_in; 166 + struct gpio_desc *gpio_reset; 166 167 const char *labels[ARRAY_SIZE(ad7768_channels)]; 167 168 /* 168 169 * DMA (thus cache coherency maintenance) may require the ··· 488 487 { 489 488 int ret; 490 489 491 - /* 492 - * Two writes to the SPI_RESET[1:0] bits are required to initiate 493 - * a software reset. The bits must first be set to 11, and then 494 - * to 10. When the sequence is detected, the reset occurs. 495 - * See the datasheet, page 70. 496 - */ 497 - ret = regmap_write(st->regmap, AD7768_REG_SYNC_RESET, 0x3); 498 - if (ret) 499 - return ret; 490 + st->gpio_reset = devm_gpiod_get_optional(&st->spi->dev, "reset", 491 + GPIOD_OUT_HIGH); 492 + if (IS_ERR(st->gpio_reset)) 493 + return PTR_ERR(st->gpio_reset); 500 494 501 - ret = regmap_write(st->regmap, AD7768_REG_SYNC_RESET, 0x2); 502 - if (ret) 503 - return ret; 495 + if (st->gpio_reset) { 496 + fsleep(10); 497 + gpiod_set_value_cansleep(st->gpio_reset, 0); 498 + fsleep(200); 499 + } else { 500 + /* 501 + * Two writes to the SPI_RESET[1:0] bits are required to initiate 502 + * a software reset. The bits must first be set to 11, and then 503 + * to 10. When the sequence is detected, the reset occurs. 504 + * See the datasheet, page 70. 505 + */ 506 + ret = regmap_write(st->regmap, AD7768_REG_SYNC_RESET, 0x3); 507 + if (ret) 508 + return ret; 509 + 510 + ret = regmap_write(st->regmap, AD7768_REG_SYNC_RESET, 0x2); 511 + if (ret) 512 + return ret; 513 + } 504 514 505 515 st->gpio_sync_in = devm_gpiod_get(&st->spi->dev, "adi,sync-in", 506 516 GPIOD_OUT_LOW);