summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2018-05-07 14:13:55 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2018-05-07 14:13:55 +0000
commit7b5613fc1ae6dae65c6d864bca30a6f9b0d3ff6e (patch)
tree7eb85935a3c03aeb1c16de2646f05cb871439616 /sys/arch
parent5614b8ad61e8c13faa22e01c444b27fcf7ec29d9 (diff)
Use speed from device tree for serial console on armv7 too.
ok visa@, patrick@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm/include/fdt.h3
-rw-r--r--sys/arch/armv7/armv7/armv7_machdep.c35
-rw-r--r--sys/arch/armv7/dev/com_fdt.c6
3 files changed, 36 insertions, 8 deletions
diff --git a/sys/arch/arm/include/fdt.h b/sys/arch/arm/include/fdt.h
index b8c8f3b5b69..d13fcf0752d 100644
--- a/sys/arch/arm/include/fdt.h
+++ b/sys/arch/arm/include/fdt.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdt.h,v 1.6 2018/03/20 23:04:48 patrick Exp $ */
+/* $OpenBSD: fdt.h,v 1.7 2018/05/07 14:13:54 kettenis Exp $ */
/*
* Copyright (c) 2016 Patrick Wildt <patrick@blueri.se>
*
@@ -35,6 +35,7 @@ struct fdt_attach_args {
};
extern int stdout_node;
+extern int stdout_speed;
extern bus_space_tag_t fdt_cons_bs_tag;
void *fdt_find_cons(const char *);
diff --git a/sys/arch/armv7/armv7/armv7_machdep.c b/sys/arch/armv7/armv7/armv7_machdep.c
index 8b077666f31..10e2a8493da 100644
--- a/sys/arch/armv7/armv7/armv7_machdep.c
+++ b/sys/arch/armv7/armv7/armv7_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: armv7_machdep.c,v 1.51 2018/03/31 18:19:12 patrick Exp $ */
+/* $OpenBSD: armv7_machdep.c,v 1.52 2018/05/07 14:13:54 kettenis Exp $ */
/* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */
/*
@@ -217,7 +217,8 @@ bs_protos(bs_notimpl);
int comcnspeed = CONSPEED;
int comcnmode = CONMODE;
-int stdout_node = 0;
+int stdout_node;
+int stdout_speed;
void (*cpuresetfn)(void);
void (*powerdownfn)(void);
@@ -873,6 +874,30 @@ process_kernel_args(char *args)
}
}
+static int
+atoi(const char *s)
+{
+ int n, neg;
+
+ n = 0;
+ neg = 0;
+
+ while (*s == '-') {
+ s++;
+ neg = !neg;
+ }
+
+ while (*s != '\0') {
+ if (*s < '0' || *s > '9')
+ break;
+
+ n = (10 * n) + (*s - '0');
+ s++;
+ }
+
+ return (neg ? -n : n);
+}
+
void *
fdt_find_cons(const char *name)
{
@@ -888,8 +913,10 @@ fdt_find_cons(const char *name)
if (fdt_node_property(node, "stdout-path", &stdout) > 0) {
if (strchr(stdout, ':') != NULL) {
strlcpy(buf, stdout, sizeof(buf));
- if ((p = strchr(buf, ':')) != NULL)
- *p = '\0';
+ if ((p = strchr(buf, ':')) != NULL) {
+ *p++ = '\0';
+ stdout_speed = atoi(p);
+ }
stdout = buf;
}
if (stdout[0] != '/') {
diff --git a/sys/arch/armv7/dev/com_fdt.c b/sys/arch/armv7/dev/com_fdt.c
index 053064e77c1..579489f4655 100644
--- a/sys/arch/armv7/dev/com_fdt.c
+++ b/sys/arch/armv7/dev/com_fdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com_fdt.c,v 1.11 2018/04/02 12:59:39 kettenis Exp $ */
+/* $OpenBSD: com_fdt.c,v 1.12 2018/05/07 14:13:54 kettenis Exp $ */
/*
* Copyright (c) 2016 Patrick Wildt <patrick@blueri.se>
*
@@ -84,8 +84,6 @@ com_fdt_init_cons(void)
if (bus_space_map(comconsiot, reg.addr, reg.size, 0, &comconsioh))
return;
- comconsrate = comcnspeed;
- comconscflag = comcnmode;
cn_tab = &com_fdt_cons;
}
@@ -141,6 +139,8 @@ com_fdt_attach(struct device *parent, struct device *self, void *aux)
SET(sc->sc_hwflags, COM_HW_CONSOLE);
SET(sc->sc_swflags, COM_SW_SOFTCAR);
comconsfreq = sc->sc_frequency;
+ comconsrate = stdout_speed ? stdout_speed : comcnspeed;
+ comconscflag = comcnmode;
}
if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,