From owner-svn-src-head@freebsd.org Mon Aug 1 16:29:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEB45BAA6F2; Mon, 1 Aug 2016 16:29:33 +0000 (UTC) (envelope-from landonf@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 mx1.freebsd.org (Postfix) with ESMTPS id CCB8A1278; Mon, 1 Aug 2016 16:29:33 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u71GTXER083186; Mon, 1 Aug 2016 16:29:33 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u71GTWOA083183; Mon, 1 Aug 2016 16:29:32 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201608011629.u71GTWOA083183@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Mon, 1 Aug 2016 16:29:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303623 - in head/sys/mips: broadcom conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2016 16:29:34 -0000 Author: landonf Date: Mon Aug 1 16:29:32 2016 New Revision: 303623 URL: https://svnweb.freebsd.org/changeset/base/303623 Log: [mips/broadcom] Fetch UART console configuration from CFE. Relying on the boot loader console configuration allows us to use a common set of device hints for all SENTRY5 devices. Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D7376 Modified: head/sys/mips/broadcom/uart_cpu_chipc.c head/sys/mips/conf/SENTRY5.hints Modified: head/sys/mips/broadcom/uart_cpu_chipc.c ============================================================================== --- head/sys/mips/broadcom/uart_cpu_chipc.c Mon Aug 1 16:29:04 2016 (r303622) +++ head/sys/mips/broadcom/uart_cpu_chipc.c Mon Aug 1 16:29:32 2016 (r303623) @@ -47,6 +47,12 @@ __FBSDID("$FreeBSD$"); #include "bcm_socinfo.h" +#ifdef CFE +#include +#include +#include +#endif + bus_space_tag_t uart_bus_space_io; bus_space_tag_t uart_bus_space_mem; @@ -61,7 +67,7 @@ uart_cpu_eqres(struct uart_bas *b1, stru } static int -uart_cpu_init(struct uart_devinfo *di, int uart, int baudrate) +uart_cpu_init(struct uart_devinfo *di, u_int uart, int baudrate) { struct bcm_socinfo *socinfo; @@ -83,6 +89,44 @@ uart_cpu_init(struct uart_devinfo *di, i return (0); } +#ifdef CFE +static int +uart_getenv_cfe(int devtype, struct uart_devinfo *di) +{ + char device[sizeof("uartXX")]; + int baud, fd, len; + int ret; + u_int uart; + + /* CFE only vends console configuration */ + if (devtype != UART_DEV_CONSOLE) + return (ENODEV); + + /* Fetch console device */ + ret = cfe_getenv("BOOT_CONSOLE", device, sizeof(device)); + if (ret != CFE_OK) + return (ENXIO); + + /* Parse serial console unit. Fails on non-uart devices. */ + if (sscanf(device, "uart%u", &uart) != 1) + return (ENXIO); + + /* Fetch device handle */ + fd = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE); + if (fd < 0) + return (ENXIO); + + /* Fetch serial configuration */ + ret = cfe_ioctl(fd, IOCTL_SERIAL_GETSPEED, (unsigned char *)&baud, + sizeof(baud), &len, 0); + if (ret != CFE_OK) + baud = CHIPC_UART_BAUDRATE; + + /* Initialize device info */ + return (uart_cpu_init(di, uart, baud)); +} +#endif /* CFE */ + int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { @@ -91,12 +135,18 @@ uart_cpu_getdev(int devtype, struct uart uart_bus_space_io = NULL; uart_bus_space_mem = mips_bus_space_generic; - /* Check the environment. */ +#ifdef CFE + /* Check the CFE environment */ + if (uart_getenv_cfe(devtype, di) == 0) + return (0); +#endif /* CFE */ + + /* Check the kernel environment. */ if (uart_getenv(devtype, di, chipc_uart_class) == 0) return (0); /* Scan the device hints for the first matching device */ - for (int i = 0; i < CHIPC_UART_MAX; i++) { + for (u_int i = 0; i < CHIPC_UART_MAX; i++) { if (resource_int_value("uart", i, "flags", &ivar)) continue; Modified: head/sys/mips/conf/SENTRY5.hints ============================================================================== --- head/sys/mips/conf/SENTRY5.hints Mon Aug 1 16:29:04 2016 (r303622) +++ head/sys/mips/conf/SENTRY5.hints Mon Aug 1 16:29:32 2016 (r303623) @@ -2,6 +2,3 @@ hint.bhnd.0.at="nexus0" hint.bhnd.0.maddr="0x18000000" hint.bhnd.0.msize="0x00100000" - -# console on uart1 -hint.uart.1.flags="0x10"