aboutsummaryrefslogtreecommitdiff
path: root/drivers/serial
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2017-07-11 20:28:46 -0400
committerTom Rini <trini@konsulko.com>2017-07-11 20:28:46 -0400
commit8d3a25685e4aac7070365a2b3c53c2c81b27930f (patch)
tree7956bf5e00e3490169a7fc41c42a4416da8db51f /drivers/serial
parentd43ef73bf26614af9b01fd57baa1a1fcf24bfade (diff)
parent8c9eaadaaad888e0cd77512553d0d02d476b4dde (diff)
downloadu-boot-8d3a25685e4aac7070365a2b3c53c2c81b27930f.zip
u-boot-8d3a25685e4aac7070365a2b3c53c2c81b27930f.tar.gz
u-boot-8d3a25685e4aac7070365a2b3c53c2c81b27930f.tar.bz2
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/ns16550.c3
-rw-r--r--drivers/serial/serial-uclass.c92
2 files changed, 55 insertions, 40 deletions
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index e0e7024..c702304 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -8,7 +8,6 @@
#include <clk.h>
#include <dm.h>
#include <errno.h>
-#include <fdtdec.h>
#include <ns16550.h>
#include <serial.h>
#include <watchdog.h>
@@ -395,7 +394,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
int err;
/* try Processor Local Bus device first */
- addr = devfdt_get_addr(dev);
+ addr = dev_read_addr(dev);
#if defined(CONFIG_PCI) && defined(CONFIG_DM_PCI)
if (addr == FDT_ADDR_T_NONE) {
/* then try pci device */
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 200f4b9..f360534 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -8,13 +8,13 @@
#include <dm.h>
#include <environment.h>
#include <errno.h>
-#include <fdtdec.h>
#include <os.h>
#include <serial.h>
#include <stdio_dev.h>
#include <watchdog.h>
#include <dm/lists.h>
#include <dm/device-internal.h>
+#include <dm/of_access.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -27,11 +27,53 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
#error "Serial is required before relocation - define CONFIG_SYS_MALLOC_F_LEN to make this work"
#endif
+static int serial_check_stdout(const void *blob, struct udevice **devp)
+{
+ int node;
+
+ /* Check for a chosen console */
+ node = fdtdec_get_chosen_node(blob, "stdout-path");
+ if (node < 0) {
+ const char *str, *p, *name;
+
+ /*
+ * Deal with things like
+ * stdout-path = "serial0:115200n8";
+ *
+ * We need to look up the alias and then follow it to the
+ * correct node.
+ */
+ str = fdtdec_get_chosen_prop(blob, "stdout-path");
+ if (str) {
+ p = strchr(str, ':');
+ name = fdt_get_alias_namelen(blob, str,
+ p ? p - str : strlen(str));
+ if (name)
+ node = fdt_path_offset(blob, name);
+ }
+ }
+ if (node < 0)
+ node = fdt_path_offset(blob, "console");
+ if (!uclass_get_device_by_of_offset(UCLASS_SERIAL, node, devp))
+ return 0;
+
+ /*
+ * If the console is not marked to be bound before relocation, bind it
+ * anyway.
+ */
+ if (node > 0 && !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node),
+ devp)) {
+ if (!device_probe(*devp))
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
static void serial_find_console_or_panic(void)
{
const void *blob = gd->fdt_blob;
struct udevice *dev;
- int node;
if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
uclass_first_device(UCLASS_SERIAL, &dev);
@@ -40,43 +82,17 @@ static void serial_find_console_or_panic(void)
return;
}
} else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
- /* Check for a chosen console */
- node = fdtdec_get_chosen_node(blob, "stdout-path");
- if (node < 0) {
- const char *str, *p, *name;
-
- /*
- * Deal with things like
- * stdout-path = "serial0:115200n8";
- *
- * We need to look up the alias and then follow it to
- * the correct node.
- */
- str = fdtdec_get_chosen_prop(blob, "stdout-path");
- if (str) {
- p = strchr(str, ':');
- name = fdt_get_alias_namelen(blob, str,
- p ? p - str : strlen(str));
- if (name)
- node = fdt_path_offset(blob, name);
- }
- }
- if (node < 0)
- node = fdt_path_offset(blob, "console");
- if (!uclass_get_device_by_of_offset(UCLASS_SERIAL, node,
- &dev)) {
- gd->cur_serial_dev = dev;
- return;
- }
+ /* Live tree has support for stdout */
+ if (of_live_active()) {
+ struct device_node *np = of_get_stdout();
- /*
- * If the console is not marked to be bound before relocation,
- * bind it anyway.
- */
- if (node > 0 &&
- !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node),
- &dev)) {
- if (!device_probe(dev)) {
+ if (np && !uclass_get_device_by_ofnode(UCLASS_SERIAL,
+ np_to_ofnode(np), &dev)) {
+ gd->cur_serial_dev = dev;
+ return;
+ }
+ } else {
+ if (!serial_check_stdout(blob, &dev)) {
gd->cur_serial_dev = dev;
return;
}