Skip to content

Commit 69f47ca

Browse files
kyle-swenson-estkuba-moo
authored andcommitted
net: pse-pd: tps23881: Support reset-gpios
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 <[email protected]> Acked-by: Oleksij Rempel <[email protected]> Reviewed-by: Kory Maincent <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ec82fa2 commit 69f47ca

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/net/pse-pd/tps23881.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/bitfield.h>
99
#include <linux/delay.h>
1010
#include <linux/firmware.h>
11+
#include <linux/gpio/consumer.h>
1112
#include <linux/i2c.h>
1213
#include <linux/module.h>
1314
#include <linux/of.h>
@@ -737,6 +738,7 @@ static int tps23881_i2c_probe(struct i2c_client *client)
737738
{
738739
struct device *dev = &client->dev;
739740
struct tps23881_priv *priv;
741+
struct gpio_desc *reset;
740742
int ret;
741743
u8 val;
742744

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

754+
reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
755+
if (IS_ERR(reset))
756+
return dev_err_probe(&client->dev, PTR_ERR(reset), "Failed to get reset GPIO\n");
757+
758+
if (reset) {
759+
/* TPS23880 datasheet (Rev G) indicates minimum reset pulse is 5us */
760+
usleep_range(5, 10);
761+
gpiod_set_value_cansleep(reset, 0); /* De-assert reset */
762+
763+
/* TPS23880 datasheet indicates the minimum time after power on reset
764+
* should be 20ms, but the document describing how to load SRAM ("How
765+
* to Load TPS2388x SRAM and Parity Code over I2C" (Rev E))
766+
* indicates we should delay that programming by at least 50ms. So
767+
* we'll wait the entire 50ms here to ensure we're safe to go to the
768+
* SRAM loading proceedure.
769+
*/
770+
msleep(50);
771+
}
772+
752773
ret = i2c_smbus_read_byte_data(client, TPS23881_REG_DEVID);
753774
if (ret < 0)
754775
return ret;

0 commit comments

Comments
 (0)