From owner-svn-src-all@freebsd.org Wed Dec 2 21:01:53 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BAEF84A60D3; Wed, 2 Dec 2020 21:01:53 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CmWcK4xsrz3nmL; Wed, 2 Dec 2020 21:01:53 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9CB235C6F; Wed, 2 Dec 2020 21:01:53 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0B2L1rTM060918; Wed, 2 Dec 2020 21:01:53 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0B2L1q0a060914; Wed, 2 Dec 2020 21:01:52 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202012022101.0B2L1q0a060914@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Wed, 2 Dec 2020 21:01:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368284 - head/sys/dev/uart X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: head/sys/dev/uart X-SVN-Commit-Revision: 368284 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Dec 2020 21:01:53 -0000 Author: mhorne Date: Wed Dec 2 21:01:52 2020 New Revision: 368284 URL: https://svnweb.freebsd.org/changeset/base/368284 Log: uart: allow UART_DEV_DBGPORT for fdt consoles Allow fdt devices to be used as debug ports for gdb(4). A debug console can be specified with the "freebsd,debug-path" property in the device tree's /chosen node, or using the environment variable hw.fdt.dbgport. The device should be specified by its name in the device tree, for example hw.fdt.dbgport="serial2". PR: 251053 Submitted by: Dmitry Salychev Submitted by: stevek (original patch, D5986) Reviewed by: andrew, mhorne Differential Revision: https://reviews.freebsd.org/D27422 Modified: head/sys/dev/uart/uart_bus_fdt.c head/sys/dev/uart/uart_cpu_arm64.c head/sys/dev/uart/uart_cpu_fdt.c head/sys/dev/uart/uart_cpu_fdt.h Modified: head/sys/dev/uart/uart_bus_fdt.c ============================================================================== --- head/sys/dev/uart/uart_bus_fdt.c Wed Dec 2 20:54:03 2020 (r368283) +++ head/sys/dev/uart/uart_bus_fdt.c Wed Dec 2 21:01:52 2020 (r368284) @@ -175,26 +175,39 @@ uart_fdt_find_by_node(phandle_t node, int class_list) int uart_cpu_fdt_probe(struct uart_class **classp, bus_space_tag_t *bst, bus_space_handle_t *bsh, int *baud, u_int *rclk, u_int *shiftp, - u_int *iowidthp) + u_int *iowidthp, const int devtype) { const char *propnames[] = {"stdout-path", "linux,stdout-path", "stdout", "stdin-path", "stdin", NULL}; + const char *propnames_dbgport[] = {"freebsd,debug-path", NULL}; const char **name; struct uart_class *class; phandle_t node, chosen; pcell_t br, clk, shift, iowidth; - char *cp; + char *cp = NULL; int err; /* Has the user forced a specific device node? */ - cp = kern_getenv("hw.fdt.console"); + switch (devtype) { + case UART_DEV_DBGPORT: + cp = kern_getenv("hw.fdt.dbgport"); + name = propnames_dbgport; + break; + case UART_DEV_CONSOLE: + cp = kern_getenv("hw.fdt.console"); + name = propnames; + break; + default: + return (ENXIO); + } + if (cp == NULL) { /* - * Retrieve /chosen/std{in,out}. + * Retrieve a node from /chosen. */ node = -1; if ((chosen = OF_finddevice("/chosen")) != -1) { - for (name = propnames; *name != NULL; name++) { + for (; *name != NULL; name++) { if (phandle_chosen_propdev(chosen, *name, &node) == 0) break; Modified: head/sys/dev/uart/uart_cpu_arm64.c ============================================================================== --- head/sys/dev/uart/uart_cpu_arm64.c Wed Dec 2 20:54:03 2020 (r368283) +++ head/sys/dev/uart/uart_cpu_arm64.c Wed Dec 2 21:01:52 2020 (r368284) @@ -100,15 +100,11 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di) if (uart_cpu_acpi_spcr(devtype, di) == 0) return (0); #endif - - if (devtype != UART_DEV_CONSOLE) - return (ENXIO); - err = ENXIO; #ifdef FDT if (err != 0) { err = uart_cpu_fdt_probe(&class, &bst, &bsh, &br, &rclk, - &shift, &iowidth); + &shift, &iowidth, devtype); } #endif if (err != 0) Modified: head/sys/dev/uart/uart_cpu_fdt.c ============================================================================== --- head/sys/dev/uart/uart_cpu_fdt.c Wed Dec 2 20:54:03 2020 (r368283) +++ head/sys/dev/uart/uart_cpu_fdt.c Wed Dec 2 21:01:52 2020 (r368284) @@ -87,10 +87,8 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di) if (!err) return (0); - if (devtype != UART_DEV_CONSOLE) - return (ENXIO); - - err = uart_cpu_fdt_probe(&class, &bst, &bsh, &br, &rclk, &shift, &iowidth); + err = uart_cpu_fdt_probe(&class, &bst, &bsh, &br, &rclk, + &shift, &iowidth, devtype); if (err != 0) return (err); Modified: head/sys/dev/uart/uart_cpu_fdt.h ============================================================================== --- head/sys/dev/uart/uart_cpu_fdt.h Wed Dec 2 20:54:03 2020 (r368283) +++ head/sys/dev/uart/uart_cpu_fdt.h Wed Dec 2 21:01:52 2020 (r368284) @@ -51,7 +51,7 @@ SET_DECLARE(uart_fdt_class_set, struct ofw_compat_data DATA_SET(uart_fdt_class_set, data) int uart_cpu_fdt_probe(struct uart_class **, bus_space_tag_t *, - bus_space_handle_t *, int *, u_int *, u_int *, u_int *); + bus_space_handle_t *, int *, u_int *, u_int *, u_int *, const int); int uart_fdt_get_clock(phandle_t node, pcell_t *cell); int uart_fdt_get_shift(phandle_t node, pcell_t *cell); int uart_fdt_get_io_width(phandle_t node, pcell_t *cell);