Date: Mon, 1 Aug 2016 16:29:32 +0000 (UTC) From: "Landon J. Fuller" <landonf@FreeBSD.org> 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 Message-ID: <201608011629.u71GTWOA083183@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <dev/cfe/cfe_api.h> +#include <dev/cfe/cfe_ioctl.h> +#include <dev/cfe/cfe_error.h> +#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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608011629.u71GTWOA083183>