<p>Andre Heider has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/23795">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">soc/nvidia/tegra210: add console UART helper functions<br><br>These small helper functions aim at supporting the user setting<br>CONFIG_CONSOLE_SERIAL_TEGRA210_UARTx.<br><br>Change-Id: I71423a0424927ff383bcbf194c9fbaa452d810a1<br>Signed-off-by: Andre Heider <a.heider@gmail.com><br>---<br>A src/soc/nvidia/tegra210/include/soc/console_uart.h<br>1 file changed, 113 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/95/23795/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/soc/nvidia/tegra210/include/soc/console_uart.h b/src/soc/nvidia/tegra210/include/soc/console_uart.h</span><br><span>new file mode 100644</span><br><span>index 0000000..fc30481</span><br><span>--- /dev/null</span><br><span>+++ b/src/soc/nvidia/tegra210/include/soc/console_uart.h</span><br><span>@@ -0,0 +1,113 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright 2018 Andre Heider <a.heider@gmail.com></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef __SOC_NVIDIA_TEGRA210_INCLUDE_SOC_CONSOLE_UART_H__</span><br><span style="color: hsl(120, 100%, 40%);">+#define __SOC_NVIDIA_TEGRA210_INCLUDE_SOC_CONSOLE_UART_H__</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/clock.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+enum console_uart_id {</span><br><span style="color: hsl(120, 100%, 40%);">+  UART_ID_NONE    = -1,</span><br><span style="color: hsl(120, 100%, 40%);">+ UART_ID_A       = 0,</span><br><span style="color: hsl(120, 100%, 40%);">+  UART_ID_B       = 1,</span><br><span style="color: hsl(120, 100%, 40%);">+  UART_ID_C       = 2,</span><br><span style="color: hsl(120, 100%, 40%);">+  UART_ID_D       = 3,</span><br><span style="color: hsl(120, 100%, 40%);">+  UART_ID_E       = 4,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static inline enum console_uart_id console_uart_get_id(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   if (IS_ENABLED(CONFIG_CONSOLE_SERIAL_TEGRA210_UARTA))</span><br><span style="color: hsl(120, 100%, 40%);">+         return UART_ID_A;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (IS_ENABLED(CONFIG_CONSOLE_SERIAL_TEGRA210_UARTB))</span><br><span style="color: hsl(120, 100%, 40%);">+         return UART_ID_B;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (IS_ENABLED(CONFIG_CONSOLE_SERIAL_TEGRA210_UARTC))</span><br><span style="color: hsl(120, 100%, 40%);">+         return UART_ID_C;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (IS_ENABLED(CONFIG_CONSOLE_SERIAL_TEGRA210_UARTD))</span><br><span style="color: hsl(120, 100%, 40%);">+         return UART_ID_D;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (IS_ENABLED(CONFIG_CONSOLE_SERIAL_TEGRA210_UARTE))</span><br><span style="color: hsl(120, 100%, 40%);">+         return UART_ID_E;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return UART_ID_NONE;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static inline void *console_uart_clk_rst_reg(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      switch (console_uart_get_id()) {</span><br><span style="color: hsl(120, 100%, 40%);">+      case UART_ID_NONE:</span><br><span style="color: hsl(120, 100%, 40%);">+            return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+  case UART_ID_A:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_RST_REG(clk_src_uarta);</span><br><span style="color: hsl(120, 100%, 40%);">+    case UART_ID_B:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_RST_REG(clk_src_uartb);</span><br><span style="color: hsl(120, 100%, 40%);">+    case UART_ID_C:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_RST_REG(clk_src_uartc);</span><br><span style="color: hsl(120, 100%, 40%);">+    case UART_ID_D:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_RST_REG(clk_src_uartd);</span><br><span style="color: hsl(120, 100%, 40%);">+    case UART_ID_E:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_RST_REG(clk_src_uarte);</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static inline uint32_t console_uart_clk_src_dev_id(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        switch (console_uart_get_id()) {</span><br><span style="color: hsl(120, 100%, 40%);">+      case UART_ID_NONE:</span><br><span style="color: hsl(120, 100%, 40%);">+            return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     case UART_ID_A:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_SRC_DEV_ID(UARTA, PLLP);</span><br><span style="color: hsl(120, 100%, 40%);">+   case UART_ID_B:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_SRC_DEV_ID(UARTB, PLLP);</span><br><span style="color: hsl(120, 100%, 40%);">+   case UART_ID_C:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_SRC_DEV_ID(UARTC, PLLP);</span><br><span style="color: hsl(120, 100%, 40%);">+   case UART_ID_D:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_SRC_DEV_ID(UARTD, PLLP);</span><br><span style="color: hsl(120, 100%, 40%);">+   case UART_ID_E:</span><br><span style="color: hsl(120, 100%, 40%);">+               return CLK_SRC_DEV_ID(UARTE, PLLP);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static inline void console_uart_clock_enable_clear_reset(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     switch (console_uart_get_id()) {</span><br><span style="color: hsl(120, 100%, 40%);">+      case UART_ID_NONE:</span><br><span style="color: hsl(120, 100%, 40%);">+            return;</span><br><span style="color: hsl(120, 100%, 40%);">+       case UART_ID_A:</span><br><span style="color: hsl(120, 100%, 40%);">+               clock_enable_clear_reset_l(CLK_L_UARTA);</span><br><span style="color: hsl(120, 100%, 40%);">+              break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case UART_ID_B:</span><br><span style="color: hsl(120, 100%, 40%);">+               clock_enable_clear_reset_l(CLK_L_UARTB);</span><br><span style="color: hsl(120, 100%, 40%);">+              break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case UART_ID_C:</span><br><span style="color: hsl(120, 100%, 40%);">+               clock_enable_clear_reset_h(CLK_H_UARTC);</span><br><span style="color: hsl(120, 100%, 40%);">+              break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case UART_ID_D:</span><br><span style="color: hsl(120, 100%, 40%);">+               clock_enable_clear_reset_u(CLK_U_UARTD);</span><br><span style="color: hsl(120, 100%, 40%);">+              break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case UART_ID_E:</span><br><span style="color: hsl(120, 100%, 40%);">+               clock_enable_clear_reset_u(CLK_U_UARTE);</span><br><span style="color: hsl(120, 100%, 40%);">+              break;</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* __SOC_NVIDIA_TEGRA210_INCLUDE_SOC_CONSOLE_UART_H__ */</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/23795">change 23795</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/23795"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I71423a0424927ff383bcbf194c9fbaa452d810a1 </div>
<div style="display:none"> Gerrit-Change-Number: 23795 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Andre Heider <a.heider@gmail.com> </div>