Skip to content
Snippets Groups Projects
Commit 60d4da69 authored by Tobias Kahlki's avatar Tobias Kahlki Committed by Tobias Kahlki
Browse files

driver:gpio: Added reset gpio to PI4IO

BCS 746-001106
parent 9b6e3ea4
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,7 @@ struct pi4io_priv {
struct i2c_client *i2c;
struct regmap *regmap;
struct gpio_chip gpio;
struct gpio_desc *reset_gpio;
};
static int pi4io_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
......@@ -181,6 +182,27 @@ static int pi4io_gpio_setup(struct pi4io_priv *pi4io)
return 0;
}
static int pi4io_reset(struct pi4io_priv *pi4io)
{
struct device *dev = &pi4io->i2c->dev;
if (pi4io->reset_gpio) {
dev_dbg(dev, "Performing reset");
/*
* According to the datasheet, the reset time should
* be 150 ns. However, when using 150 ns, the device
* doesn't come up correctly.
*/
gpiod_set_value(pi4io->reset_gpio, 1);
udelay(150);
gpiod_set_value(pi4io->reset_gpio, 0);
udelay(150);
}
return 0;
};
static int pi4io_probe(
struct i2c_client *client, const struct i2c_device_id *id)
{
......@@ -196,6 +218,12 @@ static int pi4io_probe(
i2c_set_clientdata(client, pi4io);
pi4io->i2c = client;
pi4io->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
if (!pi4io->reset_gpio)
dev_warn(dev, "Could not get reset-gpios");
pi4io_reset(pi4io);
pi4io->regmap = devm_regmap_init_i2c(client, &pi4io_regmap);
ret = regmap_read(pi4io->regmap, PI4IO_CHIP_ID, &chip_id);
if (ret < 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment