Skip to contentSkip to conversation

net: dsa: microchip: Adjust reset release timing to match reference reset circuit

PATCH In review Marek Vasut 5 participants 7 messages Jan 20, 2021 – Jan 21, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: dsa: microchip: Adjust reset release timing to match reference reset circuit

KSZ8794CNX datasheet section 8.0 RESET CIRCUIT describes recommended circuit for interfacing with CPU/FPGA reset consisting of 10k pullup resistor and 10uF capacitor to ground. This circuit takes ~100 ms to rise enough to release the reset.

For maximum supply voltage VDDIO=3.3V VIH=2.0V R=10kR C=10uF that is
VDDIO - VIH
t = R * C * -ln( ------------- ) = 10000*0.00001*-(-0.93)=0.093 s
VDDIO
so we need ~95 ms for the reset to really de-assert, and then the original 100us for the switch itself to come out of reset. Simply msleep() for 100 ms which fits the constraint with a bit of extra space.

Fixes 5b797980908a ("net: dsa: microchip: Implement recommended reset timing")
Cc Andrew Lunn <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Michael Grzeschik <[email protected]>
Cc Paul Barker <[email protected]>

---
V2: Use lowercase 's' for second

---
 drivers/net/dsa/microchip/ksz_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/microchip/ksz_common.c +1 -1
index 489963664443..389abfd27770 100644
@@ -400,7 +400,7 @@ int ksz_switch_register(struct ksz_device *dev,
 		gpiod_set_value_cansleep(dev->reset_gpio, 1);
 		usleep_range(10000, 12000);
 		gpiod_set_value_cansleep(dev->reset_gpio, 0);
-		usleep_range(100, 1000);
+		msleep(100);
 	}
 
 	mutex_init(&dev->dev_mutex);
Signature · 1 line
2.29.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Marek Vasut

KSZ8794CNX datasheet section 8.0 RESET CIRCUIT describes recommended circuit for interfacing with CPU/FPGA reset consisting of 10k pullup resistor and 10uF capacitor to ground. This circuit takes ~100 ms to rise enough to release the reset.

Quoted 8 lines

For maximum supply voltage VDDIO=3.3V VIH=2.0V R=10kR C=10uF that is
VDDIO - VIH
t = R * C * -ln( ------------- ) = 10000*0.00001*-(-0.93)=0.093 s
VDDIO
so we need ~95 ms for the reset to really de-assert, and then the original 100us for the switch itself to come out of reset. Simply msleep() for 100 ms which fits the constraint with a bit of extra space.

This makes sense if someone is using that device and following the reference circuit exactly. Working with the ksz9477 I can tell you that the reference reset circuit in figure 7.2 of the datasheet doesn't work with a VDDIO of 1.8V. And hardware engineers like to take some liberties anyway...

But 100ms is reasonable in general. It will allow for the expected rise time of a wide range of possible reset circuit designs and isn't so long that it will have a major impact on start-up time.

So it looks good to me.

Signature · 2 lines
Paul Barker
Konsulko Group
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Marek Vasut
Quoted 14 lines · Marek Vasut

KSZ8794CNX datasheet section 8.0 RESET CIRCUIT describes recommended circuit for interfacing with CPU/FPGA reset consisting of 10k pullup resistor and 10uF capacitor to ground. This circuit takes ~100 ms to rise enough to release the reset.

For maximum supply voltage VDDIO=3.3V VIH=2.0V R=10kR C=10uF that is
VDDIO - VIH
t = R * C * -ln( ------------- ) = 10000*0.00001*-(-0.93)=0.093 s
VDDIO
so we need ~95 ms for the reset to really de-assert, and then the original 100us for the switch itself to come out of reset. Simply msleep() for 100 ms which fits the constraint with a bit of extra space.

Quoted 8 lines
Fixes 5b797980908a ("net: dsa: microchip: Implement recommended reset timing")
Cc Andrew Lunn <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Michael Grzeschik <[email protected]>
Cc Paul Barker <[email protected]>

Andrew

maintainer
#3 lore raw
In reply to Marek Vasut
Quoted 14 lines · On Wed, 20 Jan 2021 04:05:02 +0100 Marek Vasut wrote:

KSZ8794CNX datasheet section 8.0 RESET CIRCUIT describes recommended circuit for interfacing with CPU/FPGA reset consisting of 10k pullup resistor and 10uF capacitor to ground. This circuit takes ~100 ms to rise enough to release the reset.

For maximum supply voltage VDDIO=3.3V VIH=2.0V R=10kR C=10uF that is
VDDIO - VIH
t = R * C * -ln( ------------- ) = 10000*0.00001*-(-0.93)=0.093 s
VDDIO
so we need ~95 ms for the reset to really de-assert, and then the original 100us for the switch itself to come out of reset. Simply msleep() for 100 ms which fits the constraint with a bit of extra space.

Quoted 3 lines
Fixes 5b797980908a ("net: dsa: microchip: Implement recommended reset timing")

I'm slightly confused whether this is just future proofing or you actually have a board where this matters. The tree is tagged as net-next but there is a Fixes tag which normally indicates net+stable.

Please advise.

#4 lore raw
Quoted 15 lines · Jakub Kicinski
Quoted 14 lines · On Wed, 20 Jan 2021 04:05:02 +0100 Marek Vasut wrote:

KSZ8794CNX datasheet section 8.0 RESET CIRCUIT describes recommended circuit for interfacing with CPU/FPGA reset consisting of 10k pullup resistor and 10uF capacitor to ground. This circuit takes ~100 ms to rise enough to release the reset.

For maximum supply voltage VDDIO=3.3V VIH=2.0V R=10kR C=10uF that is
VDDIO - VIH
t = R * C * -ln( ------------- ) = 10000*0.00001*-(-0.93)=0.093 s
VDDIO
so we need ~95 ms for the reset to really de-assert, and then the original 100us for the switch itself to come out of reset. Simply msleep() for 100 ms which fits the constraint with a bit of extra space.

Quoted 7 lines
Quoted 3 lines
Fixes 5b797980908a ("net: dsa: microchip: Implement recommended reset timing")

I'm slightly confused whether this is just future proofing or you actually have a board where this matters. The tree is tagged as net-next but there is a Fixes tag which normally indicates net+stable.

I have a board where I trigger this problem, that's how I found it. It should be passed to stable too. So the correct tree / tag is "net" ?

#5 lore raw
Quoted 21 lines · Marek Vasut
Quoted 20 lines · Jakub Kicinski
Quoted 18 lines · On Wed, 20 Jan 2021 04:05:02 +0100 Marek Vasut wrote:

KSZ8794CNX datasheet section 8.0 RESET CIRCUIT describes recommended circuit for interfacing with CPU/FPGA reset consisting of 10k pullup resistor and 10uF capacitor to ground. This circuit takes ~100 ms to rise enough to release the reset.

For maximum supply voltage VDDIO=3.3V VIH=2.0V R=10kR C=10uF that is VDDIO - VIH
   t = R * C * -ln( ------------- ) = 10000*0.00001*-(-0.93)=0.093 s VDDIO
so we need ~95 ms for the reset to really de-assert, and then the original 100us for the switch itself to come out of reset. Simply msleep() for 100 ms which fits the constraint with a bit of extra space.

Fixes 5b797980908a ("net: dsa: microchip: Implement recommended

reset timing")

Quoted 6 lines
Quoted 3 lines

I'm slightly confused whether this is just future proofing or you actually have a board where this matters. The tree is tagged as net-next but there is a Fixes tag which normally indicates net+stable.

I have a board where I trigger this problem, that's how I found it. It should be passed to stable too. So the correct tree / tag is "net" ?

If this is a bug fix for a commit that is not only in 'net-next', then yes, targeting 'net' is more appropriate:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/netdev-FAQ.rst#n28

Signature · 1 line
Florian
maintainer
#6 lore raw
Quoted 26 lines · On Wed, 20 Jan 2021 18:10:59 -0800 Florian Fainelli wrote:
Quoted 25 lines · Marek Vasut
Quoted 23 lines · Jakub Kicinski
Quoted 14 lines · On Wed, 20 Jan 2021 04:05:02 +0100 Marek Vasut wrote:

KSZ8794CNX datasheet section 8.0 RESET CIRCUIT describes recommended circuit for interfacing with CPU/FPGA reset consisting of 10k pullup resistor and 10uF capacitor to ground. This circuit takes ~100 ms to rise enough to release the reset.

For maximum supply voltage VDDIO=3.3V VIH=2.0V R=10kR C=10uF that is VDDIO - VIH
   t = R * C * -ln( ------------- ) = 10000*0.00001*-(-0.93)=0.093 s VDDIO
so we need ~95 ms for the reset to really de-assert, and then the original 100us for the switch itself to come out of reset. Simply msleep() for 100 ms which fits the constraint with a bit of extra space.

Quoted 4 lines
Fixes 5b797980908a ("net: dsa: microchip: Implement recommended

reset timing")

I'm slightly confused whether this is just future proofing or you actually have a board where this matters. The tree is tagged as net-next but there is a Fixes tag which normally indicates net+stable.

Quoted 7 lines
Quoted 2 lines

I have a board where I trigger this problem, that's how I found it. It should be passed to stable too. So the correct tree / tag is "net" ?

If this is a bug fix for a commit that is not only in 'net-next', then yes, targeting 'net' is more appropriate:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/netdev-FAQ.rst#n28

Yup, in that case applied this one and the port map fix to net.

Thanks everyone!