Module Name: src Committed By: jmcneill Date: Mon Sep 28 11:32:19 UTC 2020
Modified Files: src/sys/dev/fdt: dw_apb_uart.c Log Message: Use com_init_regs_stride instead of a4x tag To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/dw_apb_uart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/fdt/dw_apb_uart.c diff -u src/sys/dev/fdt/dw_apb_uart.c:1.5 src/sys/dev/fdt/dw_apb_uart.c:1.6 --- src/sys/dev/fdt/dw_apb_uart.c:1.5 Sun Jul 21 15:57:23 2019 +++ src/sys/dev/fdt/dw_apb_uart.c Mon Sep 28 11:32:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dw_apb_uart.c,v 1.5 2019/07/21 15:57:23 rin Exp $ */ +/* $NetBSD: dw_apb_uart.c,v 1.6 2020/09/28 11:32:19 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill <jmcne...@invisible.ca> @@ -28,7 +28,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: dw_apb_uart.c,v 1.5 2019/07/21 15:57:23 rin Exp $"); +__KERNEL_RCSID(1, "$NetBSD: dw_apb_uart.c,v 1.6 2020/09/28 11:32:19 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -76,8 +76,8 @@ dw_apb_uart_attach(device_t parent, devi struct dw_apb_uart_softc * const ssc = device_private(self); struct com_softc * const sc = &ssc->ssc_sc; struct fdt_attach_args * const faa = aux; + bus_space_tag_t bst = faa->faa_bst; bus_space_handle_t bsh; - bus_space_tag_t bst; char intrstr[128]; bus_addr_t addr; bus_size_t size; @@ -91,17 +91,7 @@ dw_apb_uart_attach(device_t parent, devi if (of_getprop_uint32(faa->faa_phandle, "reg-shift", ®_shift)) { /* missing or bad reg-shift property, assume 2 */ - bst = faa->faa_a4x_bst; - } else { - if (reg_shift == 2) { - bst = faa->faa_a4x_bst; - } else if (reg_shift == 0) { - bst = faa->faa_bst; - } else { - aprint_error(": unsupported reg-shift value %d\n", - reg_shift); - return; - } + reg_shift = 2; } sc->sc_dev = self; @@ -137,7 +127,7 @@ dw_apb_uart_attach(device_t parent, devi return; } - com_init_regs(&sc->sc_regs, bst, bsh, addr); + com_init_regs_stride(&sc->sc_regs, bst, bsh, addr, reg_shift); com_attach_subr(sc); @@ -169,9 +159,12 @@ static void dw_apb_uart_console_consinit(struct fdt_attach_args *faa, u_int uart_freq) { const int phandle = faa->faa_phandle; - bus_space_tag_t bst = faa->faa_a4x_bst; + bus_space_tag_t bst = faa->faa_bst; + bus_space_handle_t dummy_bsh; + struct com_regs regs; bus_addr_t addr; tcflag_t flags; + u_int reg_shift; int speed; fdtbus_get_reg(phandle, 0, &addr, NULL); @@ -180,7 +173,15 @@ dw_apb_uart_console_consinit(struct fdt_ speed = 115200; /* default */ flags = fdtbus_get_stdout_flags(); - if (comcnattach(bst, addr, speed, uart_freq, COM_TYPE_DW_APB, flags)) + if (of_getprop_uint32(phandle, "reg-shift", ®_shift)) { + /* missing or bad reg-shift property, assume 0 */ + reg_shift = 0; + } + + memset(&dummy_bsh, 0, sizeof(dummy_bsh)); + com_init_regs_stride(®s, bst, dummy_bsh, addr, reg_shift); + + if (comcnattach1(®s, speed, uart_freq, COM_TYPE_DW_APB, flags)) panic("Cannot initialize dw-apb-uart console"); cn_set_magic("+++++");