diff options
author | 2016-08-15 14:17:34 +0000 | |
---|---|---|
committer | 2016-08-15 14:17:34 +0000 | |
commit | a5bce6081741d14c47f2c7f2ec27b5cf8c12bacd (patch) | |
tree | 949283b35840f0fb202406e68fc364f861d04555 | |
parent | Use lowercase 'tls' in debug and log messages for consistency. (diff) | |
download | wireguard-openbsd-a5bce6081741d14c47f2c7f2ec27b5cf8c12bacd.tar.xz wireguard-openbsd-a5bce6081741d14c47f2c7f2ec27b5cf8c12bacd.zip |
Allow com(4) to make use of the simplebus address translation.
This typically works for every simplebus client, but com(4) did not
make use of the supplied bus tag. Instead it references the global
a4x bus tag. This is needed as the ARM com(4) controllers use 4-byte
spaced registers, while com(4) operates on 1-byte. To be able to make
use of the address translation, copy the a4x bus tag and replace the
cookie and map function with the one supplied by simplebus.
ok kettenis@
-rw-r--r-- | sys/arch/armv7/dev/com_fdt.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/sys/arch/armv7/dev/com_fdt.c b/sys/arch/armv7/dev/com_fdt.c index 9e83c243779..e72da185bdf 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.1 2016/08/15 13:42:49 patrick Exp $ */ +/* $OpenBSD: com_fdt.c,v 1.2 2016/08/15 14:17:34 patrick Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. * All rights reserved. @@ -66,8 +66,13 @@ int com_fdt_activate(struct device *, int); extern int comcnspeed; extern int comcnmode; +struct com_fdt_softc { + struct com_softc sc; + struct bus_space sc_iot; +}; + struct cfattach com_fdt_ca = { - sizeof (struct com_softc), com_fdt_match, com_fdt_attach, NULL, + sizeof (struct com_fdt_softc), com_fdt_match, com_fdt_attach, NULL, com_fdt_activate }; @@ -100,29 +105,37 @@ com_fdt_match(struct device *parent, void *match, void *aux) void com_fdt_attach(struct device *parent, struct device *self, void *aux) { - struct com_softc *sc = (struct com_softc *)self; + struct com_fdt_softc *sc = (struct com_fdt_softc *)self; struct fdt_attach_args *faa = aux; if (faa->fa_nreg < 1) return; - sc->sc_iot = &armv7_a4x_bs_tag; /* XXX: This sucks */ - sc->sc_iobase = faa->fa_reg[0].addr; - sc->sc_frequency = 48000000; - sc->sc_uarttype = COM_UART_TI16750; - - if (bus_space_map(sc->sc_iot, sc->sc_iobase, - faa->fa_reg[0].size, 0, &sc->sc_ioh)) { + /* + * XXX This sucks. We need to get rid of the a4x bus tag + * altogether. For this we will need to change com(4). + */ + sc->sc_iot = armv7_a4x_bs_tag; + sc->sc_iot.bs_cookie = faa->fa_iot->bs_cookie; + sc->sc_iot.bs_map = faa->fa_iot->bs_map; + + sc->sc.sc_iot = &sc->sc_iot; + sc->sc.sc_iobase = faa->fa_reg[0].addr; + sc->sc.sc_frequency = 48000000; + sc->sc.sc_uarttype = COM_UART_TI16750; + + if (bus_space_map(sc->sc.sc_iot, sc->sc.sc_iobase, + faa->fa_reg[0].size, 0, &sc->sc.sc_ioh)) { printf("%s: bus_space_map failed\n", __func__); return; } pinctrl_byname(faa->fa_node, "default"); - com_attach_subr(sc); + com_attach_subr(&sc->sc); (void)arm_intr_establish_fdt(faa->fa_node, IPL_TTY, comintr, - sc, sc->sc_dev.dv_xname); + sc, sc->sc.sc_dev.dv_xname); } int |