[PATCH net-next v4 3/3] net: ethernet: oa_tc6: add reset-gpios support

From: Alessandro Zini

Date: Fri Sep 18 2026 - 19:15:32 EST


OPEN Alliance 10BASE-T1x MAC-PHY Serial Interface specification
(v1.1, section 8.2) defines an external RESET pin as an optional reset
source for the MAC-PHY.

Add support for an optional reset GPIO in oa_tc6_init(). The GPIO is
requested asserted, kept asserted for 10 us and, once deasserted, 1 ms of
settle time is allowed for the crystal oscillator startup before the
initial TC6 control protection check and software reset are performed.

As the reset handling lives in the common library, it is available to all
MAC-PHY devices using oa_tc6_init() that provide an external reset pin.

Suggested-by: Parthiban Veerasooran <parthiban.veerasooran@xxxxxxxxxxxxx>
Signed-off-by: Alessandro Zini <alessandro.zini@xxxxxxxxxxx>
---
Changes in v4:
- Clarified commit message regarding devices with external reset pins
(renumbered from 4/4 to 3/3).

Changes in v3:
- Request the GPIO with GPIOD_OUT_HIGH and drop the now redundant
gpiod_set_value_cansleep(..., 1) call, as suggested by Qingfang Deng.
- Return the error from dev_err_probe() so that -EPROBE_DEFER is
propagated to the driver core.
- Reworded comment to stay within 80 columns.
- Sorted the new includes into the existing include block.

Changes in v2:
- Moved reset GPIO handling from lan865x.c to common oa_tc6.c as suggested
by Parthiban Veerasooran.
drivers/net/ethernet/oa_tc6.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/net/ethernet/oa_tc6.c b/drivers/net/ethernet/oa_tc6.c
index 8c82bc8354ede..364027c39fa4a 100644
--- a/drivers/net/ethernet/oa_tc6.c
+++ b/drivers/net/ethernet/oa_tc6.c
@@ -6,6 +6,8 @@
*/

#include <linux/bitfield.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/iopoll.h>
#include <linux/interrupt.h>
#include <linux/mdio.h>
@@ -88,6 +90,7 @@ struct oa_tc6 {
bool disable_traffic;
bool prot_ctrl;
enum oa_tc6_quirk_flag quirk_flags;
+ struct gpio_desc *reset_gpio;
};

enum oa_tc6_header_type {
@@ -1504,6 +1507,22 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev,
if (!tc6->spi_data_rx_buf)
return ERR_PTR(-ENOMEM);

+ tc6->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset",
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(tc6->reset_gpio))
+ return ERR_PTR(dev_err_probe(&spi->dev,
+ PTR_ERR(tc6->reset_gpio),
+ "failed to get reset gpio\n"));
+
+ if (tc6->reset_gpio) {
+ /* Keep the reset asserted for 10 us and then allow 1 ms of
+ * settle time for the crystal oscillator startup.
+ */
+ fsleep(10);
+ gpiod_set_value_cansleep(tc6->reset_gpio, 0);
+ fsleep(1000);
+ }
+
/* Check the PROTE bit status so that we can reset the device */
ret = oa_tc6_check_ctrl_protection(tc6);
if (ret) {
--
2.55.0