Skip to content

Commit 34cbf87

Browse files
ptpt52frank-w
authored andcommitted
net: dsa: mt7530: Use GPIO polarity to generate correct reset sequence
The MT7530/MT7531 reset pin is active-low in hardware, but the driver historically hardcoded a high-active reset sequence by toggling the GPIO as 0 → 1. This only worked because several DTS files incorrectly marked the reset GPIO as active-high, making both DTS and driver wrong in the same way. This patch changes the driver to respect the GPIO polarity using gpiod_is_active_low(), and generates the reset sequence as: assert = drive logical active level deassert = drive logical inactive level As a result, both cases now correctly produce the required high → low → high transition on the actual reset pin. Compatibility ------------- This change makes the driver fully backward-compatible with older, incorrect DTS files that marked the reset line as GPIO_ACTIVE_HIGH: * Old DTS marked active-high: is_active_low = 0 driver drives 0 → 1 actual levels: high → low → high (correct) * New DTS marked active-low: is_active_low = 1 driver drives 1 → 0 actual levels: high → low → high (correct) Therefore, regardless of whether a DTS is old or new, correct or incorrect, the driver now generates the correct electrical reset pulse. Going forward, DTS files should use GPIO_ACTIVE_LOW to match the hardware, but no regressions will occur with older DTS blobs. Signed-off-by: Chen Minqiang <[email protected]>
1 parent 827f4e3 commit 34cbf87

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,9 +2405,10 @@ mt7530_setup(struct dsa_switch *ds)
24052405
usleep_range(5000, 5100);
24062406
reset_control_deassert(priv->rstc);
24072407
} else {
2408-
gpiod_set_value_cansleep(priv->reset, 0);
2408+
int is_active_low = !!gpiod_is_active_low(priv->reset);
2409+
gpiod_set_value_cansleep(priv->reset, is_active_low);
24092410
usleep_range(5000, 5100);
2410-
gpiod_set_value_cansleep(priv->reset, 1);
2411+
gpiod_set_value_cansleep(priv->reset, !is_active_low);
24112412
}
24122413

24132414
/* Waiting for MT7530 got to stable */
@@ -2643,9 +2644,10 @@ mt7531_setup(struct dsa_switch *ds)
26432644
usleep_range(5000, 5100);
26442645
reset_control_deassert(priv->rstc);
26452646
} else {
2646-
gpiod_set_value_cansleep(priv->reset, 0);
2647+
int is_active_low = !!gpiod_is_active_low(priv->reset);
2648+
gpiod_set_value_cansleep(priv->reset, is_active_low);
26472649
usleep_range(5000, 5100);
2648-
gpiod_set_value_cansleep(priv->reset, 1);
2650+
gpiod_set_value_cansleep(priv->reset, !is_active_low);
26492651
}
26502652

26512653
/* Waiting for MT7530 got to stable */

0 commit comments

Comments
 (0)