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/10c6a2824b34
branches: trunk
changeset: 1026305:10c6a2824b34
user: jdc <jdc%NetBSD.org@localhost>
date: Wed Nov 17 11:57:27 2021 +0000
description:
PR port-evbarm/50416
Also check the "reset_gpios", "reset-assert-us", and "reset-deassert-us"
properties for ethernet MAC reset information. Makes the built-in ethernet
work on Odroid C1 and Odroid C2 (with mesongxbb_pinctrl.c >= r1.3).
Based on a hint from Jared. C2 tested by Martin.
diffstat:
sys/arch/arm/amlogic/meson_dwmac.c | 73 +++++++++++++++++++++++++++++--------
1 files changed, 56 insertions(+), 17 deletions(-)
diffs (102 lines):
diff -r 4d78ad243987 -r 10c6a2824b34 sys/arch/arm/amlogic/meson_dwmac.c
--- a/sys/arch/arm/amlogic/meson_dwmac.c Wed Nov 17 11:31:12 2021 +0000
+++ b/sys/arch/arm/amlogic/meson_dwmac.c Wed Nov 17 11:57:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meson_dwmac.c,v 1.12 2021/11/07 19:21:32 jmcneill Exp $ */
+/* $NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57: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.12 2021/11/07 19:21:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -70,29 +70,68 @@
{
struct fdtbus_gpio_pin *pin_reset;
const u_int *reset_delay_us;
+ const u_int *reset_assert_us, *reset_deassert_us, *reset_gpios;
bool reset_active_low;
int len, val;
- pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio", GPIO_PIN_OUTPUT);
- if (pin_reset == NULL)
- return 0;
+ /*
+ * 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_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;
- reset_active_low = of_hasprop(phandle, "snps,reset-active-low");
+ 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;
+ }
- val = reset_active_low ? 1 : 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;
- 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]));
+ 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 0;
+ }
+
+ return ENXIO;
}
static void
Home |
Main Index |
Thread Index |
Old Index