[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
This commit is contained in:
Landon J. Fuller 2016-08-01 16:29:32 +00:00
parent 727c18a84f
commit 6ed73911fe
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=303623
2 changed files with 53 additions and 6 deletions

View File

@ -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, struct uart_bas *b2)
}
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, int uart, int baudrate)
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_devinfo *di)
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;

View File

@ -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"