-/* $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.
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
};
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