aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/uart/uart_cpu_fdt.c
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2016-07-20 17:19:47 +0000
committerAndrew Turner <andrew@FreeBSD.org>2016-07-20 17:19:47 +0000
commitd4c893910db65fc996011aea6a118b5672ae453c (patch)
tree822ad05a15835e3cb21ebe56ba053dc3d0fe9a3b /sys/dev/uart/uart_cpu_fdt.c
parentc17b0bd2a652a3594ddf30de03a6ac58ce1d32ab (diff)
Notes
Diffstat (limited to 'sys/dev/uart/uart_cpu_fdt.c')
-rw-r--r--sys/dev/uart/uart_cpu_fdt.c70
1 files changed, 11 insertions, 59 deletions
diff --git a/sys/dev/uart/uart_cpu_fdt.c b/sys/dev/uart/uart_cpu_fdt.c
index 4e5ff43cdb515..e73ff6a63bd98 100644
--- a/sys/dev/uart/uart_cpu_fdt.c
+++ b/sys/dev/uart/uart_cpu_fdt.c
@@ -120,14 +120,11 @@ uart_fdt_find_by_node(phandle_t node, int class_list)
int
uart_cpu_getdev(int devtype, struct uart_devinfo *di)
{
- const char *propnames[] = {"stdout-path", "linux,stdout-path", "stdout",
- "stdin-path", "stdin", NULL};
- const char **name;
struct uart_class *class;
- phandle_t node, chosen;
- pcell_t shift, br, rclk;
- char *cp;
- int err;
+ bus_space_tag_t bst;
+ bus_space_handle_t bsh;
+ u_int shift, rclk;
+ int br, err;
/* Allow overriding the FDT using the environment. */
class = &uart_ns8250_class;
@@ -138,69 +135,24 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
if (devtype != UART_DEV_CONSOLE)
return (ENXIO);
- /* Has the user forced a specific device node? */
- cp = kern_getenv("hw.fdt.console");
- if (cp == NULL) {
- /*
- * Retrieve /chosen/std{in,out}.
- */
- node = -1;
- if ((chosen = OF_finddevice("/chosen")) != -1) {
- for (name = propnames; *name != NULL; name++) {
- if (phandle_chosen_propdev(chosen, *name,
- &node) == 0)
- break;
- }
- }
- if (chosen == -1 || *name == NULL)
- node = OF_finddevice("serial0"); /* Last ditch */
- } else {
- node = OF_finddevice(cp);
- }
-
- if (node == -1) /* Can't find anything */
- return (ENXIO);
-
- /*
- * Check old style of UART definition first. Unfortunately, the common
- * FDT processing is not possible if we have clock, power domains and
- * pinmux stuff.
- */
- class = (struct uart_class *)uart_fdt_find_by_node(node, 0);
- if (class != NULL) {
- if ((err = uart_fdt_get_clock(node, &rclk)) != 0)
- return (err);
- } else {
- /* Check class only linker set */
- class =
- (struct uart_class *)uart_fdt_find_by_node(node, 1);
- if (class == NULL)
- return (ENXIO);
- rclk = 0;
- }
-
- /*
- * Retrieve serial attributes.
- */
- if (uart_fdt_get_shift(node, &shift) != 0)
- shift = uart_getregshift(class);
-
- if (OF_getencprop(node, "current-speed", &br, sizeof(br)) <= 0)
- br = 0;
+ err = uart_cpu_fdt_probe(&class, &bst, &bsh, &br, &rclk, &shift);
+ if (err != 0)
+ return (err);
/*
* Finalize configuration.
*/
di->bas.chan = 0;
- di->bas.regshft = (u_int)shift;
+ di->bas.regshft = shift;
di->baudrate = br;
- di->bas.rclk = (u_int)rclk;
+ di->bas.rclk = rclk;
di->ops = uart_getops(class);
di->databits = 8;
di->stopbits = 1;
di->parity = UART_PARITY_NONE;
+ di->bas.bst = bst;
+ di->bas.bsh = bsh;
- err = OF_decode_addr(node, 0, &di->bas.bst, &di->bas.bsh, NULL);
uart_bus_space_mem = di->bas.bst;
uart_bus_space_io = NULL;