> Date: Mon, 2 Apr 2018 12:07:00 +0200 (CEST) > From: Mark Kettenis <mark.kette...@xs4all.nl> > > Diff below avoids using the "a4x" bus tag for the non-console bits of > the armv7 and arm64 glue for com(4). > > ok?
Just realized that the raspberry pi console needs 32-bit access as well but doesn't set the reg-io-width and reg-shift properties. So here is an updated diff that sets the defaults to 4 and 2 instead of 1 and 0. ok? Index: arch/armv7/dev/com_fdt.c =================================================================== RCS file: /cvs/src/sys/arch/armv7/dev/com_fdt.c,v retrieving revision 1.10 diff -u -p -r1.10 com_fdt.c --- arch/armv7/dev/com_fdt.c 29 Aug 2017 13:33:03 -0000 1.10 +++ arch/armv7/dev/com_fdt.c 2 Apr 2018 10:15:40 -0000 @@ -45,13 +45,8 @@ int com_fdt_intr_designware(void *); 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_fdt_softc), com_fdt_match, com_fdt_attach + sizeof (struct com_softc), com_fdt_match, com_fdt_attach }; int com_fdt_cngetc(dev_t); @@ -108,7 +103,7 @@ com_fdt_match(struct device *parent, voi void com_fdt_attach(struct device *parent, struct device *self, void *aux) { - struct com_fdt_softc *sc = (struct com_fdt_softc *)self; + struct com_softc *sc = (struct com_softc *)self; struct fdt_attach_args *faa = aux; int (*intr)(void *) = comintr; uint32_t freq; @@ -127,44 +122,39 @@ com_fdt_attach(struct device *parent, st if (freq == 0) freq = clock_get_frequency(faa->fa_node, NULL); - /* - * 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_uarttype = COM_UART_16550; - sc->sc.sc_frequency = freq ? freq : COM_FREQ; + sc->sc_iot = faa->fa_iot; + sc->sc_iobase = faa->fa_reg[0].addr; + sc->sc_uarttype = COM_UART_16550; + sc->sc_frequency = freq ? freq : COM_FREQ; + + sc->sc_reg_width = OF_getpropint(faa->fa_node, "reg-io-width", 4); + sc->sc_reg_shift = OF_getpropint(faa->fa_node, "reg-shift", 2); if (OF_is_compatible(faa->fa_node, "snps,dw-apb-uart")) intr = com_fdt_intr_designware; if (OF_is_compatible(faa->fa_node, "ti,omap3-uart") || OF_is_compatible(faa->fa_node, "ti,omap4-uart")) - sc->sc.sc_uarttype = COM_UART_TI16750; + sc->sc_uarttype = COM_UART_TI16750; if (stdout_node == faa->fa_node) { - SET(sc->sc.sc_hwflags, COM_HW_CONSOLE); - SET(sc->sc.sc_swflags, COM_SW_SOFTCAR); - comconsfreq = sc->sc.sc_frequency; + SET(sc->sc_hwflags, COM_HW_CONSOLE); + SET(sc->sc_swflags, COM_SW_SOFTCAR); + comconsfreq = sc->sc_frequency; } - if (bus_space_map(sc->sc.sc_iot, sc->sc.sc_iobase, - faa->fa_reg[0].size, 0, &sc->sc.sc_ioh)) { + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, + faa->fa_reg[0].size, 0, &sc->sc_ioh)) { printf("%s: bus_space_map failed\n", __func__); return; } pinctrl_byname(faa->fa_node, "default"); - com_attach_subr(&sc->sc); + com_attach_subr(sc); arm_intr_establish_fdt(faa->fa_node, IPL_TTY, intr, - sc, sc->sc.sc_dev.dv_xname); + sc, sc->sc_dev.dv_xname); } int @@ -172,7 +162,7 @@ com_fdt_intr_designware(void *cookie) { struct com_softc *sc = cookie; - bus_space_read_1(sc->sc_iot, sc->sc_ioh, com_usr); + com_read_reg(sc, com_usr); return comintr(sc); } Index: arch/arm64/dev/com_fdt.c =================================================================== RCS file: /cvs/src/sys/arch/arm64/dev/com_fdt.c,v retrieving revision 1.3 diff -u -p -r1.3 com_fdt.c --- arch/arm64/dev/com_fdt.c 29 Aug 2017 13:33:03 -0000 1.3 +++ arch/arm64/dev/com_fdt.c 2 Apr 2018 10:15:40 -0000 @@ -41,13 +41,8 @@ int com_fdt_match(struct device *, void void com_fdt_attach(struct device *, struct device *, void *); int com_fdt_intr_designware(void *); -struct com_fdt_softc { - struct com_softc sc; - struct bus_space sc_iot; -}; - struct cfattach com_fdt_ca = { - sizeof (struct com_fdt_softc), com_fdt_match, com_fdt_attach + sizeof (struct com_softc), com_fdt_match, com_fdt_attach }; int com_fdt_cngetc(dev_t); @@ -103,7 +98,7 @@ com_fdt_match(struct device *parent, voi void com_fdt_attach(struct device *parent, struct device *self, void *aux) { - struct com_fdt_softc *sc = (struct com_fdt_softc *)self; + struct com_softc *sc = (struct com_softc *)self; struct fdt_attach_args *faa = aux; int (*intr)(void *) = comintr; uint32_t freq; @@ -122,45 +117,39 @@ com_fdt_attach(struct device *parent, st if (freq == 0) freq = clock_get_frequency(faa->fa_node, NULL); - /* - * 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 = arm64_a4x_bs_tag; - sc->sc_iot.bus_base = faa->fa_iot->bus_base; - sc->sc_iot.bus_private = faa->fa_iot->bus_private; - sc->sc_iot._space_map = faa->fa_iot->_space_map; - - sc->sc.sc_iot = &sc->sc_iot; - sc->sc.sc_iobase = faa->fa_reg[0].addr; - sc->sc.sc_uarttype = COM_UART_16550; - sc->sc.sc_frequency = freq ? freq : COM_FREQ; + sc->sc_iot = faa->fa_iot; + sc->sc_iobase = faa->fa_reg[0].addr; + sc->sc_uarttype = COM_UART_16550; + sc->sc_frequency = freq ? freq : COM_FREQ; + + sc->sc_reg_width = OF_getpropint(faa->fa_node, "reg-io-width", 4); + sc->sc_reg_shift = OF_getpropint(faa->fa_node, "reg-shift", 2); if (OF_is_compatible(faa->fa_node, "snps,dw-apb-uart")) intr = com_fdt_intr_designware; if (OF_is_compatible(faa->fa_node, "ti,omap3-uart") || OF_is_compatible(faa->fa_node, "ti,omap4-uart")) - sc->sc.sc_uarttype = COM_UART_TI16750; + sc->sc_uarttype = COM_UART_TI16750; if (stdout_node == faa->fa_node) { - SET(sc->sc.sc_hwflags, COM_HW_CONSOLE); - SET(sc->sc.sc_swflags, COM_SW_SOFTCAR); - comconsfreq = sc->sc.sc_frequency; + SET(sc->sc_hwflags, COM_HW_CONSOLE); + SET(sc->sc_swflags, COM_SW_SOFTCAR); + comconsfreq = sc->sc_frequency; } - if (bus_space_map(sc->sc.sc_iot, sc->sc.sc_iobase, - faa->fa_reg[0].size, 0, &sc->sc.sc_ioh)) { + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, + faa->fa_reg[0].size, 0, &sc->sc_ioh)) { printf("%s: bus_space_map failed\n", __func__); return; } pinctrl_byname(faa->fa_node, "default"); - com_attach_subr(&sc->sc); + com_attach_subr(sc); arm_intr_establish_fdt(faa->fa_node, IPL_TTY, intr, - sc, sc->sc.sc_dev.dv_xname); + sc, sc->sc_dev.dv_xname); } int @@ -168,7 +157,7 @@ com_fdt_intr_designware(void *cookie) { struct com_softc *sc = cookie; - bus_space_read_1(sc->sc_iot, sc->sc_ioh, com_usr); + com_read_reg(sc, com_usr); return comintr(sc); }