summaryrefslogtreecommitdiff
path: root/sys/arch/armv7/exynos
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2016-08-21 06:36:24 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2016-08-21 06:36:24 +0000
commited7497cd9f5c02073f2d420f62e25843c09ba7ab (patch)
tree4a8604a5e8b559822803bca72319f541700b0754 /sys/arch/armv7/exynos
parentccc1d5cdc1fa6ccbb3c49367b54e531105f44663 (diff)
Dynamically attach exuart using the FDT.
Diffstat (limited to 'sys/arch/armv7/exynos')
-rw-r--r--sys/arch/armv7/exynos/exuart.c97
-rw-r--r--sys/arch/armv7/exynos/exynos.c11
-rw-r--r--sys/arch/armv7/exynos/files.exynos4
3 files changed, 41 insertions, 71 deletions
diff --git a/sys/arch/armv7/exynos/exuart.c b/sys/arch/armv7/exynos/exuart.c
index 58d24361765..81453164748 100644
--- a/sys/arch/armv7/exynos/exuart.c
+++ b/sys/arch/armv7/exynos/exuart.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exuart.c,v 1.6 2016/07/26 22:10:10 patrick Exp $ */
+/* $OpenBSD: exuart.c,v 1.7 2016/08/21 06:36:23 jsg Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@motorola.com>
*
@@ -36,6 +36,7 @@
#endif
#include <machine/bus.h>
+#include <machine/fdt.h>
#include <arm/armv7/armv7var.h>
#include <armv7/exynos/exuartreg.h>
#include <armv7/exynos/exuartvar.h>
@@ -44,6 +45,7 @@
#include <armv7/exynos/exclockvar.h>
#include <dev/ofw/fdt.h>
+#include <dev/ofw/openfirm.h>
#define DEVUNIT(x) (minor(x) & 0x7f)
#define DEVCUA(x) (minor(x) & 0x80)
@@ -89,7 +91,6 @@ struct exuart_softc {
int exuartprobe(struct device *parent, void *self, void *aux);
-int exuartprobe_fdt(struct device *parent, void *self, void *aux);
void exuartattach(struct device *parent, struct device *self, void *aux);
void exuartcnprobe(struct consdev *cp);
@@ -124,9 +125,6 @@ struct cfdriver exuart_cd = {
struct cfattach exuart_ca = {
sizeof(struct exuart_softc), exuartprobe, exuartattach
};
-struct cfattach exuart_fdt_ca = {
- sizeof(struct exuart_softc), exuartprobe_fdt, exuartattach
-};
bus_space_tag_t exuartconsiot;
bus_space_handle_t exuartconsioh;
@@ -138,16 +136,24 @@ void
exuart_init_cons(void)
{
struct fdt_reg reg;
- void *node;
+ void *node, *root;
if ((node = fdt_find_cons("samsung,exynos4210-uart")) == NULL)
return;
- if (fdt_get_reg(node, 0, &reg))
- return;
/* dtb uses serial2, qemu uses serial0 */
- if (board_id == BOARD_ID_EXYNOS4_SMDKC210)
- reg.addr = 0x13800000;
+ root = fdt_find_node("/");
+ if (root == NULL)
+ panic("%s: could not get fdt root node", __func__);
+ if (fdt_is_compatible(root, "samsung,universal_c210")) {
+ if ((node = fdt_find_node("/serial@13800000")) == NULL) {
+ return;
+ }
+ stdout_node = OF_finddevice("/serial@13800000");
+ }
+
+ if (fdt_get_reg(node, 0, &reg))
+ return;
exuartcnattach(&armv7_bs_tag, reg.addr, comcnspeed, comcnmode);
}
@@ -155,68 +161,41 @@ exuart_init_cons(void)
int
exuartprobe(struct device *parent, void *self, void *aux)
{
- return 1;
-}
-
-int
-exuartprobe_fdt(struct device *parent, void *self, void *aux)
-{
-#if NFDT > 0
- struct armv7_attach_args *aa = aux;
+ struct fdt_attach_args *faa = aux;
- if (fdt_node_compatible("samsung,exynos4210-uart", aa->aa_node))
- return 1;
-#endif
-
- return 0;
+ return OF_is_compatible(faa->fa_node, "samsung,exynos4210-uart");
}
struct cdevsw exuartdev =
cdev_tty_init(3/*XXX NEXUART */ ,exuart); /* 12: serial port */
void
-exuartattach(struct device *parent, struct device *self, void *args)
+exuartattach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = args;
+ struct fdt_attach_args *faa = aux;
struct exuart_softc *sc = (struct exuart_softc *) self;
- struct armv7mem mem;
- int irq;
-
- sc->sc_iot = aa->aa_iot;
-#if NFDT > 0
- if (aa->aa_node) {
- struct fdt_reg reg;
- uint32_t ints[3];
-
- if (fdt_get_reg(aa->aa_node, 0, &reg))
- panic("%s: could not extract memory data from FDT",
- __func__);
-
- /* TODO: Add interrupt FDT API. */
- if (fdt_node_property_ints(aa->aa_node, "interrupts",
- ints, 3) != 3)
- panic("%s: could not extract interrupt data from FDT",
- __func__);
-
- mem.addr = reg.addr;
- mem.size = reg.size;
-
- irq = ints[1];
- } else
-#endif
- {
- irq = aa->aa_dev->irq[0];
- mem.addr = aa->aa_dev->mem[0].addr;
- mem.size = aa->aa_dev->mem[0].size;
- }
+ int maj;
- sc->sc_irq = arm_intr_establish(irq, IPL_TTY,
+ if (faa->fa_nreg < 1)
+ return;
+
+ sc->sc_iot = faa->fa_iot;
+
+ sc->sc_irq = arm_intr_establish_fdt(faa->fa_node, IPL_TTY,
exuart_intr, sc, sc->sc_dev.dv_xname);
- if (bus_space_map(sc->sc_iot, mem.addr, mem.size, 0, &sc->sc_ioh))
+ if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, faa->fa_reg[0].size,
+ 0, &sc->sc_ioh))
panic("%s: bus_space_map failed!", __func__);
- if (mem.addr == exuartconsaddr)
- printf(" console");
+ if (stdout_node == faa->fa_node) {
+ /* Locate the major number. */
+ for (maj = 0; maj < nchrdev; maj++)
+ if (cdevsw[maj].d_open == exuartopen)
+ break;
+ cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit);
+
+ printf(": console");
+ }
timeout_set(&sc->sc_diag_tmo, exuart_diag, sc);
timeout_set(&sc->sc_dtr_tmo, exuart_raisedtr, sc);
diff --git a/sys/arch/armv7/exynos/exynos.c b/sys/arch/armv7/exynos/exynos.c
index 175888e14cc..bec588a53ae 100644
--- a/sys/arch/armv7/exynos/exynos.c
+++ b/sys/arch/armv7/exynos/exynos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exynos.c,v 1.12 2016/06/04 18:09:16 jsg Exp $ */
+/* $OpenBSD: exynos.c,v 1.13 2016/08/21 06:36:23 jsg Exp $ */
/*
* Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com>
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
@@ -43,7 +43,6 @@ struct board_dev chromebook_devs[] = {
{ "exclock", 0 },
{ "expower", 0 },
{ "exsysreg", 0 },
-// { "exuart", 1 },
{ "exgpio", 0 },
{ "exgpio", 1 },
{ "exgpio", 2 },
@@ -65,10 +64,6 @@ struct board_dev nuri_devs[] = {
// { "exclock", 0 },
{ "expower", 0 },
{ "exsysreg", 0 },
-// { "exuart", 0 },
- { "exuart", 1 },
- { "exuart", 2 },
- { "exuart", 3 },
{ "exgpio", 0 },
{ "exgpio", 1 },
{ "exgpio", 2 },
@@ -91,10 +86,6 @@ struct board_dev smdkc210_devs[] = {
// { "exclock", 0 },
{ "expower", 0 },
{ "exsysreg", 0 },
-// { "exuart", 0 },
- { "exuart", 1 },
- { "exuart", 2 },
- { "exuart", 3 },
{ "exgpio", 0 },
{ "exgpio", 1 },
{ "exgpio", 2 },
diff --git a/sys/arch/armv7/exynos/files.exynos b/sys/arch/armv7/exynos/files.exynos
index ca121ce8b7c..d9a6832e9ff 100644
--- a/sys/arch/armv7/exynos/files.exynos
+++ b/sys/arch/armv7/exynos/files.exynos
@@ -1,4 +1,4 @@
-# $OpenBSD: files.exynos,v 1.4 2016/05/02 08:15:55 patrick Exp $
+# $OpenBSD: files.exynos,v 1.5 2016/08/21 06:36:23 jsg Exp $
define exynos {}
device exynos: exynos
@@ -10,7 +10,7 @@ file arch/armv7/exynos/exynos5.c exynos
# serial ports
device exuart
-attach exuart at exynos
+attach exuart at fdt
file arch/armv7/exynos/exuart.c exuart
device exdisplay: wsemuldisplaydev, rasops16