diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-05-06 17:16:49 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-05-06 17:16:49 +0000 |
commit | 7fdf9a1606362b2fe3de19e189ddff9581bdf41d (patch) | |
tree | b49a2e8212c0c7bf807d493867a2f2cdfdd11379 /sys/arch/arm64 | |
parent | 427cf8985a24df94a1b8f7694aa71e0522713f6f (diff) |
Use speed from device tree for serial console. Makes it possible to boot
and install systems where the firmware uses a non-standard speed. This is
important for various boards that use a Rockchip SoC where the vendor thinks
using 1500000 bps as the serial console speed is a good idea (it isn't).
ok deraadt@, visa@, patrick@
Diffstat (limited to 'sys/arch/arm64')
-rw-r--r-- | sys/arch/arm64/arm64/machdep.c | 35 | ||||
-rw-r--r-- | sys/arch/arm64/dev/com_fdt.c | 4 | ||||
-rw-r--r-- | sys/arch/arm64/include/fdt.h | 3 |
3 files changed, 35 insertions, 7 deletions
diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index efb99c6e626..cebcdec787f 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.31 2018/03/29 21:35:23 patrick Exp $ */ +/* $OpenBSD: machdep.c,v 1.32 2018/05/06 17:16:48 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se> * @@ -56,7 +56,8 @@ uint8_t *bootmac = NULL; extern uint64_t esym; -int stdout_node = 0; +int stdout_node; +int stdout_speed; void (*cpuresetfn)(void); void (*powerdownfn)(void); @@ -150,6 +151,30 @@ inittodr(time_t base) printf("WARNING: CHECK AND RESET THE DATE!\n"); } +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) { @@ -165,8 +190,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/arm64/dev/com_fdt.c b/sys/arch/arm64/dev/com_fdt.c index 0b0e08f0a00..3a9b925e67d 100644 --- a/sys/arch/arm64/dev/com_fdt.c +++ b/sys/arch/arm64/dev/com_fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_fdt.c,v 1.4 2018/04/02 12:59:39 kettenis Exp $ */ +/* $OpenBSD: com_fdt.c,v 1.5 2018/05/06 17:16:48 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * @@ -80,7 +80,6 @@ com_fdt_init_cons(void) if (bus_space_map(comconsiot, reg.addr, reg.size, 0, &comconsioh)) return; - comconsrate = B115200; cn_tab = &com_fdt_cons; } @@ -136,6 +135,7 @@ 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 : B115200; } if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, diff --git a/sys/arch/arm64/include/fdt.h b/sys/arch/arm64/include/fdt.h index b60077ca82e..2ec9cc06b65 100644 --- a/sys/arch/arm64/include/fdt.h +++ b/sys/arch/arm64/include/fdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.h,v 1.3 2018/03/20 23:04:48 patrick Exp $ */ +/* $OpenBSD: fdt.h,v 1.4 2018/05/06 17:16:48 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 *); |