Commit 1c64222b authored by Pawe? Chmiel's avatar Pawe? Chmiel Committed by Mauro Carvalho Chehab

media: si470x-i2c: Add optional reset-gpio support

If reset-gpio is defined, use it to bring device out of reset.
Without this, it's not possible to access si470x registers.
Signed-off-by: default avatarPawe? Chmiel <pawel.mikolaj.chmiel@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent f86c51b6
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include "radio-si470x.h" #include "radio-si470x.h"
...@@ -392,6 +393,17 @@ static int si470x_i2c_probe(struct i2c_client *client, ...@@ -392,6 +393,17 @@ static int si470x_i2c_probe(struct i2c_client *client,
radio->videodev.release = video_device_release_empty; radio->videodev.release = video_device_release_empty;
video_set_drvdata(&radio->videodev, radio); video_set_drvdata(&radio->videodev, radio);
radio->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset",
GPIOD_OUT_LOW);
if (IS_ERR(radio->gpio_reset)) {
retval = PTR_ERR(radio->gpio_reset);
dev_err(&client->dev, "Failed to request gpio: %d\n", retval);
goto err_all;
}
if (radio->gpio_reset)
gpiod_set_value(radio->gpio_reset, 1);
/* power up : need 110ms */ /* power up : need 110ms */
radio->registers[POWERCFG] = POWERCFG_ENABLE; radio->registers[POWERCFG] = POWERCFG_ENABLE;
if (si470x_set_register(radio, POWERCFG) < 0) { if (si470x_set_register(radio, POWERCFG) < 0) {
...@@ -478,6 +490,9 @@ static int si470x_i2c_remove(struct i2c_client *client) ...@@ -478,6 +490,9 @@ static int si470x_i2c_remove(struct i2c_client *client)
video_unregister_device(&radio->videodev); video_unregister_device(&radio->videodev);
if (radio->gpio_reset)
gpiod_set_value(radio->gpio_reset, 0);
return 0; return 0;
} }
......
...@@ -189,6 +189,7 @@ struct si470x_device { ...@@ -189,6 +189,7 @@ struct si470x_device {
#if IS_ENABLED(CONFIG_I2C_SI470X) #if IS_ENABLED(CONFIG_I2C_SI470X)
struct i2c_client *client; struct i2c_client *client;
struct gpio_desc *gpio_reset;
#endif #endif
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment