summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-05-22 10:06:59 +0000
committerpatrick <patrick@openbsd.org>2020-05-22 10:06:59 +0000
commit2b29a96a54ba5cafbec6419b4f52dbbaee47b663 (patch)
treeca4bc3feb4fb12150ec5f605516fe260e09cd3b4
parentAlways defer attaching the mvneta(4) interfaces. Otherwise this (diff)
downloadwireguard-openbsd-2b29a96a54ba5cafbec6419b4f52dbbaee47b663.tar.xz
wireguard-openbsd-2b29a96a54ba5cafbec6419b4f52dbbaee47b663.zip
Attach mvpinctrl(4) to the Armada 3700's NB as well. As a consequence
mvclock(4) cannot attach to the NB's xtal clock anymore. Instead, have mvpinctrl(4) attach the xtal clock. With this we can use the SD card detect pins on the Turris Mox. ok kettenis@
-rw-r--r--sys/dev/fdt/mvclock.c25
-rw-r--r--sys/dev/fdt/mvpinctrl.c40
2 files changed, 38 insertions, 27 deletions
diff --git a/sys/dev/fdt/mvclock.c b/sys/dev/fdt/mvclock.c
index 3719ef106d0..5a999f174ef 100644
--- a/sys/dev/fdt/mvclock.c
+++ b/sys/dev/fdt/mvclock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mvclock.c,v 1.6 2020/04/15 15:40:06 kettenis Exp $ */
+/* $OpenBSD: mvclock.c,v 1.7 2020/05/22 10:06:59 patrick Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org>
*
@@ -65,7 +65,6 @@ uint32_t a3700_periph_nb_get_frequency(void *, uint32_t *);
void a3700_periph_sb_enable(void *, uint32_t *, int);
uint32_t a3700_periph_sb_get_frequency(void *, uint32_t *);
uint32_t a3700_tbg_get_frequency(void *, uint32_t *);
-uint32_t a3700_xtal_get_frequency(void *, uint32_t *);
int
mvclock_match(struct device *parent, void *match, void *aux)
@@ -114,8 +113,6 @@ mvclock_attach(struct device *parent, struct device *self, void *aux)
sc->sc_cd.cd_get_frequency = a3700_periph_sb_get_frequency;
} else if (OF_is_compatible(node, "marvell,armada-3700-tbg-clock")) {
sc->sc_cd.cd_get_frequency = a3700_tbg_get_frequency;
- } else if (OF_is_compatible(node, "marvell,armada-3700-xtal-clock")) {
- sc->sc_cd.cd_get_frequency = a3700_xtal_get_frequency;
}
clock_register(&sc->sc_cd);
}
@@ -472,23 +469,3 @@ a3700_tbg_get_frequency(void *cookie, uint32_t *cells)
freq = clock_get_frequency(sc->sc_cd.cd_node, NULL);
return (freq * mult) / div;
}
-
-/* Armada 3700 XTAL block */
-
-#define XTAL 0xc
-#define XTAL_MODE (1 << 31)
-
-uint32_t
-a3700_xtal_get_frequency(void *cookie, uint32_t *cells)
-{
- struct mvclock_softc *sc = cookie;
- struct regmap *rm;
-
- rm = regmap_bynode(OF_parent(sc->sc_cd.cd_node));
- KASSERT(rm != NULL);
-
- if (regmap_read_4(rm, XTAL) & XTAL_MODE)
- return 40000000;
- else
- return 25000000;
-}
diff --git a/sys/dev/fdt/mvpinctrl.c b/sys/dev/fdt/mvpinctrl.c
index 9c7d3459be7..8b07c3dac0e 100644
--- a/sys/dev/fdt/mvpinctrl.c
+++ b/sys/dev/fdt/mvpinctrl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mvpinctrl.c,v 1.6 2019/04/30 20:06:32 patrick Exp $ */
+/* $OpenBSD: mvpinctrl.c,v 1.7 2020/05/22 10:06:59 patrick Exp $ */
/*
* Copyright (c) 2013,2016 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2016 Mark Kettenis <kettenis@openbsd.org>
@@ -26,6 +26,7 @@
#include <machine/fdt.h>
#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_clock.h>
#include <dev/ofw/ofw_gpio.h>
#include <dev/ofw/ofw_misc.h>
#include <dev/ofw/ofw_pinctrl.h>
@@ -60,6 +61,7 @@ struct mvpinctrl_softc {
struct mvpinctrl_pin *sc_pins;
int sc_npins;
struct gpio_controller sc_gc;
+ struct clock_device sc_cd_xtal;
};
int mvpinctrl_match(struct device *, void *, void *);
@@ -70,6 +72,8 @@ void mvpinctrl_config_pin(void *, uint32_t *, int);
int mvpinctrl_get_pin(void *, uint32_t *);
void mvpinctrl_set_pin(void *, uint32_t *, int);
+uint32_t a3700_xtal_get_frequency(void *, uint32_t *);
+
struct cfattach mvpinctrl_ca = {
sizeof (struct mvpinctrl_softc), mvpinctrl_match, mvpinctrl_attach
};
@@ -136,7 +140,8 @@ mvpinctrl_match(struct device *parent, void *match, void *aux)
return 10;
}
- if (OF_is_compatible(faa->fa_node, "marvell,armada3710-sb-pinctrl"))
+ if (OF_is_compatible(faa->fa_node, "marvell,armada3710-nb-pinctrl") ||
+ OF_is_compatible(faa->fa_node, "marvell,armada3710-sb-pinctrl"))
return 10;
return 0;
@@ -172,7 +177,20 @@ mvpinctrl_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
- if (OF_is_compatible(faa->fa_node, "marvell,armada3710-sb-pinctrl")) {
+ if (OF_is_compatible(faa->fa_node, "marvell,armada3710-nb-pinctrl")) {
+ for (node = OF_child(faa->fa_node); node; node = OF_peer(node)) {
+ if (OF_is_compatible(node, "marvell,armada-3700-xtal-clock"))
+ break;
+ }
+ KASSERT(node != 0);
+ sc->sc_cd_xtal.cd_node = node;
+ sc->sc_cd_xtal.cd_cookie = sc;
+ sc->sc_cd_xtal.cd_get_frequency = a3700_xtal_get_frequency;
+ clock_register(&sc->sc_cd_xtal);
+ }
+
+ if (OF_is_compatible(faa->fa_node, "marvell,armada3710-nb-pinctrl") ||
+ OF_is_compatible(faa->fa_node, "marvell,armada3710-sb-pinctrl")) {
for (node = OF_child(faa->fa_node); node; node = OF_peer(node)) {
if (OF_getproplen(node, "gpio-controller") == 0)
break;
@@ -306,3 +324,19 @@ mvpinctrl_set_pin(void *cookie, uint32_t *cells, int val)
else
HCLR4(sc, GPIO_OUTPUT, (1 << pin));
}
+
+/* Armada 3700 XTAL block */
+
+#define XTAL 0xc
+#define XTAL_MODE (1 << 31)
+
+uint32_t
+a3700_xtal_get_frequency(void *cookie, uint32_t *cells)
+{
+ struct mvpinctrl_softc *sc = cookie;
+
+ if (regmap_read_4(sc->sc_rm, XTAL) & XTAL_MODE)
+ return 40000000;
+ else
+ return 25000000;
+}