net: pse-pd: tps23881: Reset GPIO support
Subsystems (4)
cover net: pse-pd: tps23881: Reset GPIO support
On some boards, the TPS2388x's reset line (active low) is pulled low to keep the chip in reset until the SoC pulls the device out of reset. This series updates the device-tree binding for the tps23881 and then adds support for the reset gpio handling in the tps23881 driver.
---
Kyle Swenson (2):
dt-bindings: net: pse-pd: tps23881: add reset-gpios
net: pse-pd: tps23881: Support reset-gpios
.../devicetree/bindings/net/pse-pd/ti,tps23881.yaml | 3 +++ drivers/net/pse-pd/tps23881.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
PATCH 1/2 dt-bindings: net: pse-pd: tps23881: add reset-gpios
The TPS23881 has an active-low reset pin that can be connected to an SoC. Document this with the device-tree binding.
--- Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml +3 -0
@@ -21,10 +21,13 @@ properties: maxItems: 1 '#pse-cells': const: 1 + reset-gpios: + maxItems: 1 + channels: description: each set of 8 ports can be assigned to one physical channels or two for PoE4. This parameter describes the configuration of the ports conversion matrix that establishes relationship between the logical ports and the physical channels.
Signature · 1 line
2.43.0
Re: [PATCH net-next 1/2] dt-bindings: net: pse-pd: tps23881: add reset-gpios
Quoted 7 lines · Kyle Swenson
The TPS23881 has an active-low reset pin that can be connected to an SoC. Document this with the device-tree binding.
Signed-off-by Kyle Swenson <[email protected]>--- Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml | 3 +++ 1 file changed, 3 insertions(+)
Best regards,
Krzysztof
PATCH 2/2 net: pse-pd: tps23881: support reset-gpios
In reply to Kyle SwensonThe 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.
--- drivers/net/pse-pd/tps23881.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/pse-pd/tps23881.c +12 -1
@@ -6,16 +6,16 @@*/ #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> #include <linux/platform_device.h> #include <linux/pse-pd/pse.h> -#define TPS23881_MAX_CHANS 8#define TPS23881_REG_PW_STATUS 0x10#define TPS23881_REG_OP_MODE 0x12#define TPS23881_OP_MODE_SEMIAUTO 0xaaaa
@@ -735,10 +735,11 @@ static int tps23881_flash_sram_fw(struct i2c_client *client)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;if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_err (dev,"i2c check functionality failed\n" );
@@ -747,10 +748,20 @@ static int tps23881_i2c_probe(struct i2c_client *client) priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );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) { +usleep_range (1000 ,10000 ); +gpiod_set_value_cansleep (reset,0 );/* De-assert reset */ +usleep_range (1000 ,10000 ); + } + ret =i2c_smbus_read_byte_data (client,TPS23881_REG_DEVID );if (ret <0 )return ret;if (FIELD_GET (TPS23881_REG_DEVID_MASK , ret) !=TPS23881_DEVICE_ID ) {
Signature · 1 line
2.43.0
Oleksij Rempel
maintainerRe: [PATCH net-next 2/2] net: pse-pd: tps23881: support reset-gpios
Hi Kyle,
thank you for you patch.
Quoted 17 lines · Kyle Swenson
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]>--- drivers/net/pse-pd/tps23881.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/net/pse-pd/tps23881.c +0
-0@@ -6,16 +6,16 @@*/
drivers/net/pse-pd/tps23881.c line 16
Quoted 10 lines
drivers/net/pse-pd/tps23881.c +1
-1#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> #include <linux/platform_device.h> #include <linux/pse-pd/pse.h> -
No need to remove space here.
Quoted 21 lines
drivers/net/pse-pd/tps23881.c +1
-0#define TPS23881_MAX_CHANS 8#define TPS23881_REG_PW_STATUS 0x10#define TPS23881_REG_OP_MODE 0x12#define TPS23881_OP_MODE_SEMIAUTO 0xaaaa@@ -735,10 +735,11 @@ static int tps23881_flash_sram_fw(struct i2c_client *client)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;if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_err (dev,"i2c check functionality failed\n" );@@ -747,10 +748,20 @@ static int tps23881_i2c_probe(struct i2c_client *client) priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );if (!priv)
drivers/net/pse-pd/tps23881.c static int tps23881_i2c_probe(struct i2c_client *client) · line 760
Quoted 10 lines
drivers/net/pse-pd/tps23881.c +8
-0return -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) { +usleep_range (1000 ,10000 ); +gpiod_set_value_cansleep (reset,0 );/* De-assert reset */ +usleep_range (1000 ,10000 );
According to the datasheet, page 13:
https://www.ti.com/lit/ds/symlink/tps23880.pdf
Minimal reset time is 5 microseconds and the delay after power on reset should be at least 20 milliseconds. Both sleep values should be corrected.
Regards,
Oleksij
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH net-next 2/2] net: pse-pd: tps23881: support reset-gpios
Hi Oleksij,
Quoted 3 lines · Oleksij Rempel
Hi Kyle,
thank you for you patch.
Thanks for the review!
Quoted 19 lines · Kyle Swenson
Quoted 17 lines
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]>--- drivers/net/pse-pd/tps23881.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/net/pse-pd/tps23881.c +0
-0@@ -6,16 +6,16 @@*/
Quoted 12 lines
drivers/net/pse-pd/tps23881.c line 16
Quoted 10 lines
drivers/net/pse-pd/tps23881.c +1
-1#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> #include <linux/platform_device.h> #include <linux/pse-pd/pse.h> -No need to remove space here.
Sorry about this, somehow I missed this gratuitous diff
Quoted 36 lines
Quoted 22 lines
drivers/net/pse-pd/tps23881.c +1
-0#define TPS23881_MAX_CHANS 8#define TPS23881_REG_PW_STATUS 0x10#define TPS23881_REG_OP_MODE 0x12#define TPS23881_OP_MODE_SEMIAUTO 0xaaaa@@ -735,10 +735,11 @@ static int tps23881_flash_sram_fw(struct i2c_client *client)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;if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_err (dev,"i2c check functionality failed\n" );@@ -747,10 +748,20 @@ static int tps23881_i2c_probe(struct i2c_client *client) priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );if (!priv)drivers/net/pse-pd/tps23881.c static int tps23881_i2c_probe(struct i2c_client *client) · line 760
Quoted 10 lines
drivers/net/pse-pd/tps23881.c +8
-0return -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) { +usleep_range (1000 ,10000 ); +gpiod_set_value_cansleep (reset,0 );/* De-assert reset */ +usleep_range (1000 ,10000 );According to the datasheet, page 13:
https://www.ti.com/lit/ds/symlink/tps23880.pdf
Quoted 2 lines
Minimal reset time is 5 microseconds and the delay after power on reset should be at least 20 milliseconds. Both sleep values should be corrected.
Sounds reasonable, I'll change the first delay to be closer to the 5us minimum reset time. I need to review the docs around delays to pick the correct one for this case.
For the 2nd delay, I (now) see the 20ms you're referring to in the datasheet.
I was looking at the SRAM programming document
(https://www.ti.com/lit/pdf/SLVAE1) and it indicates we should delay the SRAM and parity programming by at least 50ms after initial power on.
Should we guarantee we meet that 50ms requirement with the 2nd delay or would you prefer I just meet the 20ms requirement in the datasheet?
Quoted 8 lines
Regards,
OleksijSignature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Thanks again for the review!
Cheers,
Kyle
Re: [PATCH net-next 2/2] net: pse-pd: tps23881: support reset-gpios
Quoted 80 lines · Kyle Swenson
Hi Oleksij,
Quoted 3 lines · Oleksij Rempel
Hi Kyle,
thank you for you patch.
Thanks for the review!
Quoted 19 lines · Kyle Swenson
Quoted 17 lines
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]>--- drivers/net/pse-pd/tps23881.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/net/pse-pd/tps23881.c +0
-0@@ -6,16 +6,16 @@*/ Quoted 12 lines
drivers/net/pse-pd/tps23881.c line 16
Quoted 10 lines
drivers/net/pse-pd/tps23881.c +1
-1#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> #include <linux/platform_device.h> #include <linux/pse-pd/pse.h> -No need to remove space here.
Sorry about this, somehow I missed this gratuitous diff
Quoted 36 lines
Quoted 22 lines
drivers/net/pse-pd/tps23881.c +1
-0#define TPS23881_MAX_CHANS 8#define TPS23881_REG_PW_STATUS 0x10#define TPS23881_REG_OP_MODE 0x12#define TPS23881_OP_MODE_SEMIAUTO 0xaaaa@@ -735,10 +735,11 @@ static int tps23881_flash_sram_fw(struct i2c_client *client)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;if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_err (dev,"i2c check functionality failed\n" );@@ -747,10 +748,20 @@ static int tps23881_i2c_probe(struct i2c_client *client) priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );if (!priv)drivers/net/pse-pd/tps23881.c static int tps23881_i2c_probe(struct i2c_client *client) · line 760
Quoted 10 lines
drivers/net/pse-pd/tps23881.c +8
-0return -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) { +usleep_range (1000 ,10000 ); +gpiod_set_value_cansleep (reset,0 );/* De-assert reset */ +usleep_range (1000 ,10000 );According to the datasheet, page 13:
https://www.ti.com/lit/ds/symlink/tps23880.pdfQuoted 2 lines
Minimal reset time is 5 microseconds and the delay after power on reset should be at least 20 milliseconds. Both sleep values should be corrected.
Quoted 8 lines
Sounds reasonable, I'll change the first delay to be closer to the 5us minimum reset time. I need to review the docs around delays to pick the correct one for this case.
For the 2nd delay, I (now) see the 20ms you're referring to in the datasheet.
I was looking at the SRAM programming document
(https://www.ti.com/lit/pdf/SLVAE1) and it indicates we should delay the
Sorry, this is the wrong link. Let me try again:
https://www.ti.com/lit/pdf/slvae12
Quoted 18 lines
SRAM and parity programming by at least 50ms after initial power on.
Should we guarantee we meet that 50ms requirement with the 2nd delay or would you prefer I just meet the 20ms requirement in the datasheet?
Quoted 8 lines
Regards,
OleksijSignature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |Thanks again for the review!
Cheers,
Kyle
Oleksij Rempel
maintainerRe: [PATCH net-next 2/2] net: pse-pd: tps23881: support reset-gpios
Hi Kyle,
Quoted 85 lines · Kyle Swenson
Quoted 84 lines · Kyle Swenson
Hi Oleksij,
Quoted 3 lines · Oleksij Rempel
Hi Kyle,
thank you for you patch.
Thanks for the review!
Quoted 19 lines · Kyle Swenson
Quoted 17 lines
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]>--- drivers/net/pse-pd/tps23881.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/net/pse-pd/tps23881.c +0
-0@@ -6,16 +6,16 @@*/ Quoted 12 lines
drivers/net/pse-pd/tps23881.c line 16
Quoted 10 lines
drivers/net/pse-pd/tps23881.c +1
-1#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> #include <linux/platform_device.h> #include <linux/pse-pd/pse.h> -No need to remove space here.
Sorry about this, somehow I missed this gratuitous diff
Quoted 36 lines
Quoted 22 lines
drivers/net/pse-pd/tps23881.c +1
-0#define TPS23881_MAX_CHANS 8#define TPS23881_REG_PW_STATUS 0x10#define TPS23881_REG_OP_MODE 0x12#define TPS23881_OP_MODE_SEMIAUTO 0xaaaa@@ -735,10 +735,11 @@ static int tps23881_flash_sram_fw(struct i2c_client *client)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;if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_err (dev,"i2c check functionality failed\n" );@@ -747,10 +748,20 @@ static int tps23881_i2c_probe(struct i2c_client *client) priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );if (!priv)drivers/net/pse-pd/tps23881.c static int tps23881_i2c_probe(struct i2c_client *client) · line 760
Quoted 10 lines
drivers/net/pse-pd/tps23881.c +8
-0return -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) { +usleep_range (1000 ,10000 ); +gpiod_set_value_cansleep (reset,0 );/* De-assert reset */ +usleep_range (1000 ,10000 );According to the datasheet, page 13:
https://www.ti.com/lit/ds/symlink/tps23880.pdfQuoted 2 lines
Minimal reset time is 5 microseconds and the delay after power on reset should be at least 20 milliseconds. Both sleep values should be corrected.
Sounds reasonable, I'll change the first delay to be closer to the 5us minimum reset time. I need to review the docs around delays to pick the correct one for this case.
Quoted 14 lines
Quoted 4 lines
For the 2nd delay, I (now) see the 20ms you're referring to in the datasheet.
I was looking at the SRAM programming document
(https://www.ti.com/lit/pdf/SLVAE1) and it indicates we should delay theSorry, this is the wrong link. Let me try again:
https://www.ti.com/lit/pdf/slvae12
Quoted 4 lines
SRAM and parity programming by at least 50ms after initial power on.
Should we guarantee we meet that 50ms requirement with the 2nd delay or would you prefer I just meet the 20ms requirement in the datasheet?
Ah, I see. The easiest way would be to wait 50ms, otherwise we will need to do some more code to get this 50ms requirement.
Please add comments to the code describing the reason for one or another delay. And, please use name and revision of documentation you used for this choice.
Regards,
Oleksij
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |