From 76920ef61a560773894c48eb13f2f050eec36638 Mon Sep 17 00:00:00 2001 From: kettenis Date: Sat, 25 Mar 2023 10:14:58 +0000 Subject: [PATCH] The "snps,reset-*" properties are deprecatedand are being replaced with "reset-*" proprties on the PHY device tree nodes. Add support for this. ok dlg@ --- sys/dev/fdt/if_dwqe_fdt.c | 45 +++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/sys/dev/fdt/if_dwqe_fdt.c b/sys/dev/fdt/if_dwqe_fdt.c index f11d4f49cd3..da582e4237b 100644 --- a/sys/dev/fdt/if_dwqe_fdt.c +++ b/sys/dev/fdt/if_dwqe_fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dwqe_fdt.c,v 1.3 2023/03/19 08:41:49 kettenis Exp $ */ +/* $OpenBSD: if_dwqe_fdt.c,v 1.4 2023/03/25 10:14:58 kettenis Exp $ */ /* * Copyright (c) 2008, 2019 Mark Kettenis * Copyright (c) 2017, 2022 Patrick Wildt @@ -69,7 +69,7 @@ const struct cfattach dwqe_fdt_ca = { sizeof(struct dwqe_softc), dwqe_fdt_match, dwqe_fdt_attach }; -void dwqe_reset_phy(struct dwqe_softc *); +void dwqe_reset_phy(struct dwqe_softc *, uint32_t); int dwqe_fdt_match(struct device *parent, void *cfdata, void *aux) @@ -140,7 +140,7 @@ dwqe_fdt_attach(struct device *parent, struct device *self, void *aux) regulator_enable(phy_supply); /* Reset PHY */ - dwqe_reset_phy(sc); + dwqe_reset_phy(sc, phy); sc->sc_clk = clock_get_frequency(faa->fa_node, "stmmaceth"); if (sc->sc_clk > 500000000) @@ -206,26 +206,39 @@ dwqe_fdt_attach(struct device *parent, struct device *self, void *aux) } void -dwqe_reset_phy(struct dwqe_softc *sc) +dwqe_reset_phy(struct dwqe_softc *sc, uint32_t phy) { uint32_t *gpio; uint32_t delays[3]; int active = 1; - int len; + int node, len; - len = OF_getproplen(sc->sc_node, "snps,reset-gpio"); - if (len <= 0) - return; + node = OF_getnodebyphandle(phy); + if (node && OF_getproplen(node, "reset-gpios") > 0) { + len = OF_getproplen(node, "reset-gpios"); - gpio = malloc(len, M_TEMP, M_WAITOK); + gpio = malloc(len, M_TEMP, M_WAITOK); - /* Gather information. */ - OF_getpropintarray(sc->sc_node, "snps,reset-gpio", gpio, len); - if (OF_getpropbool(sc->sc_node, "snps-reset-active-low")) - active = 0; - delays[0] = delays[1] = delays[2] = 0; - OF_getpropintarray(sc->sc_node, "snps,reset-delays-us", delays, - sizeof(delays)); + /* Gather information. */ + OF_getpropintarray(node, "reset-gpios", gpio, len); + delays[0] = OF_getpropint(node, "reset-deassert-us", 0); + delays[1] = OF_getpropint(node, "reset-assert-us", 0); + delays[2] = OF_getpropint(node, "reset-deassert-us", 0); + } else { + len = OF_getproplen(sc->sc_node, "snps,reset-gpio"); + if (len <= 0) + return; + + gpio = malloc(len, M_TEMP, M_WAITOK); + + /* Gather information. */ + OF_getpropintarray(sc->sc_node, "snps,reset-gpio", gpio, len); + if (OF_getpropbool(sc->sc_node, "snps-reset-active-low")) + active = 0; + delays[0] = delays[1] = delays[2] = 0; + OF_getpropintarray(sc->sc_node, "snps,reset-delays-us", delays, + sizeof(delays)); + } /* Perform reset sequence. */ gpio_controller_config_pin(gpio, GPIO_CONFIG_OUTPUT); -- 2.20.1