ARM: OMAP2+: omap_hwmod: Add support for earlycon
authorLokesh Vutla <lokeshvutla@ti.com>
Fri, 20 Jan 2017 18:39:10 +0000 (10:39 -0800)
committerTony Lindgren <tony@atomide.com>
Fri, 20 Jan 2017 18:39:10 +0000 (10:39 -0800)
Hwmod core tries to reset and idles each IP that is registered with hwmod.
In case of earlycon, that specific uart IP cannot be reset or keep it in
idle state else earlycon hangs once hwmod resets that uart IP. So add support
to not reset uart that is being used as earlycon only if CONFIG_SERIAL_EARLYCON
is enabled.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/omap_hwmod.c

index 759e1d45ba25c3977af1d7048bec577062a51b66..0ab29097a070975ce19135547e48d6f0df9bb9bc 100644 (file)
@@ -3248,6 +3248,36 @@ int __init omap_hwmod_setup_one(const char *oh_name)
        return 0;
 }
 
+/**
+ * omap_hwmod_setup_earlycon_flags - set up flags for early console
+ *
+ * Enable DEBUG_OMAPUART_FLAGS for uart hwmod that is being used as
+ * early concole so that hwmod core doesn't reset and keep it in idle
+ * that specific uart.
+ */
+#ifdef CONFIG_SERIAL_EARLYCON
+static void __init omap_hwmod_setup_earlycon_flags(void)
+{
+       struct device_node *np;
+       struct omap_hwmod *oh;
+       const char *uart;
+
+       np = of_find_node_by_path("/chosen");
+       if (np) {
+               uart = of_get_property(np, "stdout-path", NULL);
+               if (uart) {
+                       np = of_find_node_by_path(uart);
+                       if (np) {
+                               uart = of_get_property(np, "ti,hwmods", NULL);
+                               oh = omap_hwmod_lookup(uart);
+                               if (oh)
+                                       oh->flags |= DEBUG_OMAPUART_FLAGS;
+                       }
+               }
+       }
+}
+#endif
+
 /**
  * omap_hwmod_setup_all - set up all registered IP blocks
  *
@@ -3261,6 +3291,9 @@ static int __init omap_hwmod_setup_all(void)
        _ensure_mpu_hwmod_is_setup(NULL);
 
        omap_hwmod_for_each(_init, NULL);
+#ifdef CONFIG_SERIAL_EARLYCON
+       omap_hwmod_setup_earlycon_flags();
+#endif
        omap_hwmod_for_each(_setup, NULL);
 
        return 0;