Skip to content

Commit

Permalink
net: pse-pd: tps23881: Support reset-gpios
Browse files Browse the repository at this point in the history
The TPS23880/1 has an active-low reset pin that some boards connect to
the SoC to control when the TPS23880 is pulled out of reset.

Add support for this via a reset-gpios property in the DTS.

Signed-off-by: Kyle Swenson <kyle.swenson@est.tech>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://patch.msgid.link/20240822220100.3030184-3-kyle.swenson@est.tech
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Kyle Swenson authored and Jakub Kicinski committed Aug 26, 2024
1 parent ec82fa2 commit 69f47ca
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions drivers/net/pse-pd/tps23881.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/of.h>
Expand Down Expand Up @@ -737,6 +738,7 @@ static int tps23881_i2c_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct tps23881_priv *priv;
struct gpio_desc *reset;
int ret;
u8 val;

Expand All @@ -749,6 +751,25 @@ static int tps23881_i2c_probe(struct i2c_client *client)
if (!priv)
return -ENOMEM;

reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(reset))
return dev_err_probe(&client->dev, PTR_ERR(reset), "Failed to get reset GPIO\n");

if (reset) {
/* TPS23880 datasheet (Rev G) indicates minimum reset pulse is 5us */
usleep_range(5, 10);
gpiod_set_value_cansleep(reset, 0); /* De-assert reset */

/* TPS23880 datasheet indicates the minimum time after power on reset
* should be 20ms, but the document describing how to load SRAM ("How
* to Load TPS2388x SRAM and Parity Code over I2C" (Rev E))
* indicates we should delay that programming by at least 50ms. So
* we'll wait the entire 50ms here to ensure we're safe to go to the
* SRAM loading proceedure.
*/
msleep(50);
}

ret = i2c_smbus_read_byte_data(client, TPS23881_REG_DEVID);
if (ret < 0)
return ret;
Expand Down

0 comments on commit 69f47ca

Please sign in to comment.