Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/amlogic PR port-evbarm/50416
details: https://anonhg.NetBSD.org/src/rev/cbef911bef9c
branches: trunk
changeset: 1026319:cbef911bef9c
user: jdc <jdc%NetBSD.org@localhost>
date: Fri Nov 19 07:04:27 2021 +0000
description:
PR port-evbarm/50416
Redo the previous change. The "snps,..." properties are on the ethernet
node and the "reset-..." properties are on the phy node. Handle this by
creating a separate reset routine for each case. Idea from Jared.
diffstat:
sys/arch/arm/amlogic/meson_dwmac.c | 122 +++++++++++++++++++-----------------
1 files changed, 65 insertions(+), 57 deletions(-)
diffs (163 lines):
diff -r 8bcdc4ce1d10 -r cbef911bef9c sys/arch/arm/amlogic/meson_dwmac.c
--- a/sys/arch/arm/amlogic/meson_dwmac.c Thu Nov 18 23:26:58 2021 +0000
+++ b/sys/arch/arm/amlogic/meson_dwmac.c Fri Nov 19 07:04:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $ */
+/* $NetBSD: meson_dwmac.c,v 1.14 2021/11/19 07:04:27 jdc Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.14 2021/11/19 07:04:27 jdc Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -66,72 +66,69 @@
};
static int
-meson_dwmac_reset(const int phandle)
+meson_dwmac_reset_eth(const int phandle)
{
struct fdtbus_gpio_pin *pin_reset;
const u_int *reset_delay_us;
+ bool reset_active_low;
+ int len, val;
+
+ pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio",
+ GPIO_PIN_OUTPUT);
+ if (pin_reset == NULL)
+ return ENXIO;
+
+ reset_delay_us = fdtbus_get_prop(phandle, "snps,reset-delays-us", &len);
+ if (reset_delay_us == NULL || len != 12)
+ return ENXIO;
+
+ reset_active_low = of_hasprop(phandle, "snps,reset-active-low");
+
+ val = reset_active_low ? 1 : 0;
+
+ fdtbus_gpio_write(pin_reset, val);
+ delay(be32toh(reset_delay_us[0]));
+ fdtbus_gpio_write(pin_reset, !val);
+ delay(be32toh(reset_delay_us[1]));
+ fdtbus_gpio_write(pin_reset, val);
+ delay(be32toh(reset_delay_us[2]));
+
+ return 0;
+}
+
+static int
+meson_dwmac_reset_phy(const int phandle)
+{
+ struct fdtbus_gpio_pin *pin_reset;
const u_int *reset_assert_us, *reset_deassert_us, *reset_gpios;
bool reset_active_low;
int len, val;
- /*
- * Depending on the DTS, we need to check either the "snps,...",
- * or the "reset-..." properties for the MAC reset information.
- */
-
- pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio",
- GPIO_PIN_OUTPUT);
- if (pin_reset != NULL) {
-
- reset_delay_us = fdtbus_get_prop(phandle,
- "snps,reset-delays-us", &len);
- if (reset_delay_us == NULL || len != 12)
- return ENXIO;
-
- reset_active_low = of_hasprop(phandle, "snps,reset-active-low");
-
- val = reset_active_low ? 1 : 0;
-
- fdtbus_gpio_write(pin_reset, val);
- delay(be32toh(reset_delay_us[0]));
- fdtbus_gpio_write(pin_reset, !val);
- delay(be32toh(reset_delay_us[1]));
- fdtbus_gpio_write(pin_reset, val);
- delay(be32toh(reset_delay_us[2]));
-
- return 0;
- }
-
pin_reset = fdtbus_gpio_acquire(phandle, "reset-gpios",
GPIO_PIN_OUTPUT);
- if (pin_reset != NULL) {
- reset_assert_us = fdtbus_get_prop(phandle,
- "reset-assert-us", &len);
- if (reset_assert_us == NULL || len != 4)
- return ENXIO;
- reset_deassert_us = fdtbus_get_prop(phandle,
- "reset-deassert-us", &len);
- if (reset_deassert_us == NULL || len != 4)
- return ENXIO;
- reset_gpios = fdtbus_get_prop(phandle,
- "reset-gpios", &len);
- if (reset_gpios == NULL || len != 12)
- return ENXIO;
+ if (pin_reset == NULL)
+ return ENXIO;
- reset_active_low = be32toh(reset_gpios[2]);
-
- val = reset_active_low ? 1 : 0;
-
+ reset_assert_us = fdtbus_get_prop(phandle, "reset-assert-us", &len);
+ if (reset_assert_us == NULL || len != 4)
+ return ENXIO;
+ reset_deassert_us = fdtbus_get_prop(phandle, "reset-deassert-us", &len);
+ if (reset_deassert_us == NULL || len != 4)
+ return ENXIO;
+ reset_gpios = fdtbus_get_prop(phandle, "reset-gpios", &len);
+ if (reset_gpios == NULL || len != 12)
+ return ENXIO;
- fdtbus_gpio_write(pin_reset, val);
- delay(be32toh(reset_assert_us[0]));
- fdtbus_gpio_write(pin_reset, !val);
- delay(be32toh(reset_deassert_us[0]));
+ reset_active_low = be32toh(reset_gpios[2]);
+
+ val = reset_active_low ? 1 : 0;
- return 0;
- }
+ fdtbus_gpio_write(pin_reset, val);
+ delay(be32toh(reset_assert_us[0]));
+ fdtbus_gpio_write(pin_reset, !val);
+ delay(be32toh(reset_deassert_us[0]));
- return ENXIO;
+ return 0;
}
static void
@@ -276,8 +273,19 @@
}
aprint_normal_dev(self, "interrupting on %s\n", intrstr);
- if (meson_dwmac_reset(phandle_phy) != 0)
- aprint_error_dev(self, "PHY reset failed\n");
+ /*
+ * Depending on the DTS, we need to check either the "snps,...",
+ * properties on the ethernet node, or the "reset-..."
+ * properties on the phy node for the MAC reset information.
+ */
+
+ if (of_hasprop(phandle, "snps,reset-gpio")) {
+ if (meson_dwmac_reset_eth(phandle) != 0)
+ aprint_error_dev(self, "PHY reset failed\n");
+ } else {
+ if (meson_dwmac_reset_phy(phandle_phy) != 0)
+ aprint_error_dev(self, "PHY reset failed\n");
+ }
miiclk_rate = clk_get_rate(clk_gmac);
if (miiclk_rate > 250 * 1000 * 1000)
Home |
Main Index |
Thread Index |
Old Index