From: Mark Kettenis Subject: Re: com(4): support mediatek uart To: James Hastings Cc: moosetek4@gmail.com,tech@openbsd.org Date: Mon, 29 Jan 2024 11:15:58 +0100 > From: James Hastings > Date: Mon, 29 Jan 2024 01:29:46 -0500 (EST) > > Add support to com(4) for the UARTs found on MediaTek SoCs. > > The "common compatible" on mainstream devicetree is "mediatek,mt6577-uart". > This supports most arm64 and armv7 MediaTek SoCs. > > Datasheets claim 16550A compatibility so set sc_uarttype accordingly. > > Serial output below from Banana Pi BPI-R64 (MT7622). > > ok? ok kettenis@ > Index: dev/fdt/com_fdt.c > =================================================================== > RCS file: /cvs/src/sys/dev/fdt/com_fdt.c,v > retrieving revision 1.8 > diff -u -p -r1.8 com_fdt.c > --- dev/fdt/com_fdt.c 15 Aug 2023 07:56:27 -0000 1.8 > +++ dev/fdt/com_fdt.c 23 Jan 2024 00:35:15 -0000 > @@ -55,6 +55,7 @@ com_fdt_init_cons(void) > > if ((node = fdt_find_cons("brcm,bcm2835-aux-uart")) == NULL && > (node = fdt_find_cons("marvell,armada-38x-uart")) == NULL && > + (node = fdt_find_cons("mediatek,mt6577-uart")) == NULL && > (node = fdt_find_cons("ns16550a")) == NULL && > (node = fdt_find_cons("snps,dw-apb-uart")) == NULL && > (node = fdt_find_cons("ti,omap3-uart")) == NULL && > @@ -96,6 +97,7 @@ com_fdt_match(struct device *parent, voi > > return (OF_is_compatible(faa->fa_node, "brcm,bcm2835-aux-uart") || > OF_is_compatible(faa->fa_node, "marvell,armada-38x-uart") || > + OF_is_compatible(faa->fa_node, "mediatek,mt6577-uart") || > OF_is_compatible(faa->fa_node, "ns16550a") || > OF_is_compatible(faa->fa_node, "snps,dw-apb-uart") || > OF_is_compatible(faa->fa_node, "ti,omap3-uart") || > @@ -140,6 +142,9 @@ com_fdt_attach(struct device *parent, st > > sc->sc_reg_width = OF_getpropint(faa->fa_node, "reg-io-width", width); > sc->sc_reg_shift = OF_getpropint(faa->fa_node, "reg-shift", shift); > + > + if (OF_is_compatible(faa->fa_node, "mediatek,mt6577-uart")) > + sc->sc_uarttype = COM_UART_16550A; > > if (OF_is_compatible(faa->fa_node, "snps,dw-apb-uart") || > OF_is_compatible(faa->fa_node, "marvell,armada-38x-uart")) { > > > > MT7622> dhcp BOOTAA64.EFI > MT7622> tftpboot 0x48800000 mt7622-bpi-r64.dtb > MT7622> bootefi 0x48000000 0x48800000 > Booting /BOOTAA64.EFI > disks: sd0 sd1 > >> OpenBSD/arm64 BOOTAA64 1.18 > boot> bsd > booting tftp0a:bsd > [ using 2914592 bytes of bsd ELF symbol table ] > Copyright (c) 1982, 1986, 1989, 1991, 1993 > The Regents of the University of California. All rights reserved. > Copyright (c) 1995-2024 OpenBSD. All rights reserved. https://www.OpenBSD.org > > OpenBSD 7.4-current (GENERIC.MP) #11: Sat Jan 20 21:28:19 EST 2024 > hastings@arm64.moose-tek.test:/usr/src/sys/arch/arm64/compile/GENERIC.MP > real mem = 1072095232 (1022MB) > avail mem = 998666240 (952MB) > random: good seed from bootblocks > mainbus0 at root: Bananapi BPI-R64 > psci0 at mainbus0: PSCI 1.1, SMCCC 1.4, SYSTEM_SUSPEND > efi0 at mainbus0: UEFI 2.10 > efi0: Das U-Boot rev 0x20230700 > smbios0 at efi0: SMBIOS 3.0 > smbios0: vendor U-Boot version "2023.07.02-OpenWrt-r24627-3eca9ba53f" date 07/01/2023 > smbios0: Unknown Unknown Product > cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4 > cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache > cpu0: 256KB 64b/line 16-way L2 cache > cpu0: CRC32,SHA2,SHA1,AES+PMULL,ASID16 > cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4 > cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache > cpu1: 256KB 64b/line 16-way L2 cache > cpu1: CRC32,SHA2,SHA1,AES+PMULL,ASID16 > "ramoops" at mainbus0 not configured > "secmon" at mainbus0 not configured > apm0 at mainbus0 > syscon0 at mainbus0: "infracfg" > syscon1 at mainbus0: "pericfg" > syscon2 at mainbus0: "power-controller" > syscon3 at mainbus0: "apmixedsys" > syscon4 at mainbus0: "topckgen" > ampintc0 at mainbus0 nirq 288, ncpu 4 ipi: 0, 1, 2: "interrupt-controller" > syscon5 at mainbus0: "clock-controller" > syscon6 at mainbus0: "ssusbsys" > syscon7 at mainbus0: "pciesys" > syscon8 at mainbus0: "pciecfg" > syscon9 at mainbus0: "syscon" > syscon10 at mainbus0: "syscon" > syscon11 at mainbus0: "pcie-mirror" > syscon12 at mainbus0: "wed" > syscon13 at mainbus0: "wed" > syscon14 at mainbus0: "ethernet" > syscon15 at mainbus0: "sgmiisys" > "opp-table" at mainbus0 not configured > "dummy40m" at mainbus0 not configured > "oscillator" at mainbus0 not configured > "pmu" at mainbus0 not configured > agtimer0 at mainbus0: 12500 kHz > "pwrap" at mainbus0 not configured > "cir" at mainbus0 not configured > "interrupt-controller" at mainbus0 not configured > "efuse" at mainbus0 not configured > "rng" at mainbus0 not configured > "pinctrl" at mainbus0 not configured > "watchdog" at mainbus0 not configured > "rtc" at mainbus0 not configured > "cci" at mainbus0 not configured > "adc" at mainbus0 not configured > com0 at mainbus0: ns16550a, 16 byte fifo > com0: console > "pwm" at mainbus0 not configured > "i2c" at mainbus0 not configured > "i2c" at mainbus0 not configured > "spi" at mainbus0 not configured > "thermal" at mainbus0 not configured > "serial" at mainbus0 not configured > "spi" at mainbus0 not configured > "ecc" at mainbus0 not configured > "mmc" at mainbus0 not configured > "mmc" at mainbus0 not configured > "wmac" at mainbus0 not configured > "usb" at mainbus0 not configured > "t-phy" at mainbus0 not configured > "pcie" at mainbus0 not configured > "pcie" at mainbus0 not configured > "dma-controller" at mainbus0 not configured > gpiokeys0 at mainbus0: "factory", "wps" > gpioleds0 at mainbus0: "bpi-r64:pio:green", "bpi-r64:pio:red" > "regulator-1p8v" at mainbus0 not configured > "regulator-3p3v" at mainbus0 not configured > "regulator-5v" at mainbus0 not configured > vscsi0 at root > scsibus0 at vscsi0: 256 targets > softraid0 at root > scsibus1 at softraid0: 256 targets > root device: > use one of: exit > root device: exit > syncing disks... done > >