diff mbox series

[v2,4/4] net: dsa: microchip: Implement recommended reset timing

Message ID 20200907101208.1223-5-pbarker@konsulko.com
State New
Headers show
Series ksz9477 dsa switch driver improvements | expand

Commit Message

Paul Barker Sept. 7, 2020, 10:12 a.m. UTC
The datasheet for the ksz9893 and ksz9477 switches recommend waiting at
least 100us after the de-assertion of reset before trying to program the
device through any interface.

Also switch the existing msleep() call to usleep_range() as recommended
in Documentation/timers/timers-howto.rst. The 2ms range used here is
somewhat arbitrary, as long as the reset is asserted for at least 10ms
we should be ok.

Signed-off-by: Paul Barker <pbarker@konsulko.com>
---
 drivers/net/dsa/microchip/ksz_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Florian Fainelli Sept. 8, 2020, 4:09 a.m. UTC | #1
On 9/7/2020 3:12 AM, Paul Barker wrote:
> The datasheet for the ksz9893 and ksz9477 switches recommend waiting at
> least 100us after the de-assertion of reset before trying to program the
> device through any interface.
> 
> Also switch the existing msleep() call to usleep_range() as recommended
> in Documentation/timers/timers-howto.rst. The 2ms range used here is
> somewhat arbitrary, as long as the reset is asserted for at least 10ms
> we should be ok.
> 
> Signed-off-by: Paul Barker <pbarker@konsulko.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 8d53b12d40a8..a31738662d95 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -400,8 +400,9 @@  int ksz_switch_register(struct ksz_device *dev,
 
 	if (dev->reset_gpio) {
 		gpiod_set_value_cansleep(dev->reset_gpio, 1);
-		mdelay(10);
+		usleep_range(10000, 12000);
 		gpiod_set_value_cansleep(dev->reset_gpio, 0);
+		usleep_range(100, 1000);
 	}
 
 	mutex_init(&dev->dev_mutex);