|
@@ -33,6 +33,7 @@
|
|
#define SX9500_IRQ_NAME "sx9500_event"
|
|
#define SX9500_IRQ_NAME "sx9500_event"
|
|
|
|
|
|
#define SX9500_GPIO_INT "interrupt"
|
|
#define SX9500_GPIO_INT "interrupt"
|
|
|
|
+#define SX9500_GPIO_RESET "reset"
|
|
|
|
|
|
/* Register definitions. */
|
|
/* Register definitions. */
|
|
#define SX9500_REG_IRQ_SRC 0x00
|
|
#define SX9500_REG_IRQ_SRC 0x00
|
|
@@ -85,6 +86,7 @@ struct sx9500_data {
|
|
struct i2c_client *client;
|
|
struct i2c_client *client;
|
|
struct iio_trigger *trig;
|
|
struct iio_trigger *trig;
|
|
struct regmap *regmap;
|
|
struct regmap *regmap;
|
|
|
|
+ struct gpio_desc *gpiod_rst;
|
|
/*
|
|
/*
|
|
* Last reading of the proximity status for each channel. We
|
|
* Last reading of the proximity status for each channel. We
|
|
* only send an event to user space when this changes.
|
|
* only send an event to user space when this changes.
|
|
@@ -829,6 +831,13 @@ static int sx9500_init_device(struct iio_dev *indio_dev)
|
|
int ret, i;
|
|
int ret, i;
|
|
unsigned int val;
|
|
unsigned int val;
|
|
|
|
|
|
|
|
+ if (data->gpiod_rst) {
|
|
|
|
+ gpiod_set_value_cansleep(data->gpiod_rst, 0);
|
|
|
|
+ usleep_range(1000, 2000);
|
|
|
|
+ gpiod_set_value_cansleep(data->gpiod_rst, 1);
|
|
|
|
+ usleep_range(1000, 2000);
|
|
|
|
+ }
|
|
|
|
+
|
|
ret = regmap_write(data->regmap, SX9500_REG_IRQ_MSK, 0);
|
|
ret = regmap_write(data->regmap, SX9500_REG_IRQ_MSK, 0);
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
return ret;
|
|
return ret;
|
|
@@ -875,6 +884,13 @@ static void sx9500_gpio_probe(struct i2c_client *client,
|
|
else
|
|
else
|
|
client->irq = gpiod_to_irq(gpio);
|
|
client->irq = gpiod_to_irq(gpio);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ data->gpiod_rst = devm_gpiod_get_index(dev, SX9500_GPIO_RESET,
|
|
|
|
+ 0, GPIOD_OUT_HIGH);
|
|
|
|
+ if (IS_ERR(data->gpiod_rst)) {
|
|
|
|
+ dev_warn(dev, "gpio get reset pin failed\n");
|
|
|
|
+ data->gpiod_rst = NULL;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
static int sx9500_probe(struct i2c_client *client,
|
|
static int sx9500_probe(struct i2c_client *client,
|
|
@@ -898,8 +914,6 @@ static int sx9500_probe(struct i2c_client *client,
|
|
if (IS_ERR(data->regmap))
|
|
if (IS_ERR(data->regmap))
|
|
return PTR_ERR(data->regmap);
|
|
return PTR_ERR(data->regmap);
|
|
|
|
|
|
- sx9500_init_device(indio_dev);
|
|
|
|
-
|
|
|
|
indio_dev->dev.parent = &client->dev;
|
|
indio_dev->dev.parent = &client->dev;
|
|
indio_dev->name = SX9500_DRIVER_NAME;
|
|
indio_dev->name = SX9500_DRIVER_NAME;
|
|
indio_dev->channels = sx9500_channels;
|
|
indio_dev->channels = sx9500_channels;
|
|
@@ -910,6 +924,10 @@ static int sx9500_probe(struct i2c_client *client,
|
|
|
|
|
|
sx9500_gpio_probe(client, data);
|
|
sx9500_gpio_probe(client, data);
|
|
|
|
|
|
|
|
+ ret = sx9500_init_device(indio_dev);
|
|
|
|
+ if (ret < 0)
|
|
|
|
+ return ret;
|
|
|
|
+
|
|
if (client->irq <= 0)
|
|
if (client->irq <= 0)
|
|
dev_warn(&client->dev, "no valid irq found\n");
|
|
dev_warn(&client->dev, "no valid irq found\n");
|
|
else {
|
|
else {
|