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

iio: sx9500: add GPIO reset pin

If a GPIO reset pin is listed in ACPI or Device Tree, use it to reset
the device on initialization.

Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Vlad Dogaru and committed by
Jonathan Cameron
45fd5f8e 821ace29

+20 -2
+20 -2
drivers/iio/proximity/sx9500.c
··· 33 33 #define SX9500_IRQ_NAME "sx9500_event" 34 34 35 35 #define SX9500_GPIO_INT "interrupt" 36 + #define SX9500_GPIO_RESET "reset" 36 37 37 38 /* Register definitions. */ 38 39 #define SX9500_REG_IRQ_SRC 0x00 ··· 86 85 struct i2c_client *client; 87 86 struct iio_trigger *trig; 88 87 struct regmap *regmap; 88 + struct gpio_desc *gpiod_rst; 89 89 /* 90 90 * Last reading of the proximity status for each channel. We 91 91 * only send an event to user space when this changes. ··· 831 829 int ret, i; 832 830 unsigned int val; 833 831 832 + if (data->gpiod_rst) { 833 + gpiod_set_value_cansleep(data->gpiod_rst, 0); 834 + usleep_range(1000, 2000); 835 + gpiod_set_value_cansleep(data->gpiod_rst, 1); 836 + usleep_range(1000, 2000); 837 + } 838 + 834 839 ret = regmap_write(data->regmap, SX9500_REG_IRQ_MSK, 0); 835 840 if (ret < 0) 836 841 return ret; ··· 884 875 else 885 876 client->irq = gpiod_to_irq(gpio); 886 877 } 878 + 879 + data->gpiod_rst = devm_gpiod_get_index(dev, SX9500_GPIO_RESET, 880 + 0, GPIOD_OUT_HIGH); 881 + if (IS_ERR(data->gpiod_rst)) { 882 + dev_warn(dev, "gpio get reset pin failed\n"); 883 + data->gpiod_rst = NULL; 884 + } 887 885 } 888 886 889 887 static int sx9500_probe(struct i2c_client *client, ··· 914 898 if (IS_ERR(data->regmap)) 915 899 return PTR_ERR(data->regmap); 916 900 917 - sx9500_init_device(indio_dev); 918 - 919 901 indio_dev->dev.parent = &client->dev; 920 902 indio_dev->name = SX9500_DRIVER_NAME; 921 903 indio_dev->channels = sx9500_channels; ··· 923 909 i2c_set_clientdata(client, indio_dev); 924 910 925 911 sx9500_gpio_probe(client, data); 912 + 913 + ret = sx9500_init_device(indio_dev); 914 + if (ret < 0) 915 + return ret; 926 916 927 917 if (client->irq <= 0) 928 918 dev_warn(&client->dev, "no valid irq found\n");