summaryrefslogtreecommitdiffstats
path: root/sys/mips/broadcom/uart_cpu_chipc.c
diff options
context:
space:
mode:
authorlandonf <landonf@FreeBSD.org>2016-06-25 04:34:54 +0000
committerlandonf <landonf@FreeBSD.org>2016-06-25 04:34:54 +0000
commit36a6892b98e5dd5b41fa9dfd0510f5441d44f646 (patch)
tree44e3d8dae12b9ffa9e3984dbe02c527e4ce2a4da /sys/mips/broadcom/uart_cpu_chipc.c
parent61ca174a62a383aa36616626d0d9c04058348677 (diff)
downloadFreeBSD-src-36a6892b98e5dd5b41fa9dfd0510f5441d44f646.zip
FreeBSD-src-36a6892b98e5dd5b41fa9dfd0510f5441d44f646.tar.gz
Replace mips/sentry5 with mips/broadcom
The delta between SENTRY5 and BCM was already small due to BCM being derived from SENTRY5; re-integrating the two avoids the maintenance overhead of keeping them both in sync with bhnd(4) changes. - Re-integrate minor SENTRY5 deltas in bcm_machdep.c - Modify uart_cpu_chipc to allow specifying UART debug/console flags via kenv and device hints. - Switch SENTRY5 to std.broadcom - Enabled CFI flash support for SENTRY5 Reviewed by: Michael Zhilin <mizkha@gmail.com> (Broadcom MIPS support) Approved by: re (gjb), adrian (mentor) Differential Revision: https://reviews.freebsd.org/D6897
Diffstat (limited to 'sys/mips/broadcom/uart_cpu_chipc.c')
-rw-r--r--sys/mips/broadcom/uart_cpu_chipc.c63
1 files changed, 54 insertions, 9 deletions
diff --git a/sys/mips/broadcom/uart_cpu_chipc.c b/sys/mips/broadcom/uart_cpu_chipc.c
index 14cc9f3..9b91a2b 100644
--- a/sys/mips/broadcom/uart_cpu_chipc.c
+++ b/sys/mips/broadcom/uart_cpu_chipc.c
@@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
+#include <dev/bhnd/cores/chipc/chipcreg.h>
+
#include <dev/uart/uart.h>
#include <dev/uart/uart_bus.h>
#include <dev/uart/uart_cpu.h>
@@ -48,31 +50,74 @@ __FBSDID("$FreeBSD$");
bus_space_tag_t uart_bus_space_io;
bus_space_tag_t uart_bus_space_mem;
+static struct uart_class *chipc_uart_class = &uart_ns8250_class;
+
+#define CHIPC_UART_BAUDRATE 115200
+
int
uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
{
return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0);
}
-int
-uart_cpu_getdev(int devtype, struct uart_devinfo *di)
+static int
+uart_cpu_init(struct uart_devinfo *di, int uart, int baudrate)
{
- struct uart_class *class;
struct bcm_socinfo *socinfo;
+ if (uart >= CHIPC_UART_MAX)
+ return (EINVAL);
+
socinfo = bcm_get_socinfo();
- class = &uart_ns8250_class;
- di->ops = uart_getops(class);
+ di->ops = uart_getops(chipc_uart_class);
di->bas.chan = 0;
- di->bas.bst = mips_bus_space_generic;
- di->bas.bsh = (bus_space_handle_t)BCM_SOCREG(BCM_REG_CHIPC_UART);
+ di->bas.bst = uart_bus_space_mem;
+ di->bas.bsh = (bus_space_handle_t) BCM_SOCREG(CHIPC_UART(uart));
di->bas.regshft = 0;
di->bas.rclk = socinfo->uartrate; /* in Hz */
- di->baudrate = 115200;
+ di->baudrate = baudrate;
di->databits = 8;
di->stopbits = 1;
di->parity = UART_PARITY_NONE;
+
+ return (0);
+}
+
+int
+uart_cpu_getdev(int devtype, struct uart_devinfo *di)
+{
+ int ivar;
+
uart_bus_space_io = NULL;
uart_bus_space_mem = mips_bus_space_generic;
- return (0);
+
+ /* Check the 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++) {
+ if (resource_int_value("uart", i, "flags", &ivar))
+ continue;
+
+ /* Check usability */
+ if (devtype == UART_DEV_CONSOLE && !UART_FLAGS_CONSOLE(ivar))
+ continue;
+
+ if (devtype == UART_DEV_DBGPORT && !UART_FLAGS_DBGPORT(ivar))
+ continue;
+
+ if (resource_int_value("uart", i, "disabled", &ivar) == 0 &&
+ ivar == 0)
+ continue;
+
+ /* Found */
+ if (resource_int_value("uart", i, "baud", &ivar) != 0)
+ ivar = CHIPC_UART_BAUDRATE;
+
+ return (uart_cpu_init(di, i, ivar));
+ }
+
+ /* Default to uart0/115200 */
+ return (uart_cpu_init(di, 0, CHIPC_UART_BAUDRATE));
}
OpenPOWER on IntegriCloud