From: patrick Date: Mon, 15 Aug 2016 14:17:34 +0000 (+0000) Subject: Allow com(4) to make use of the simplebus address translation. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a5bce6081741d14c47f2c7f2ec27b5cf8c12bacd;p=openbsd 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@ --- 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