aboutsummaryrefslogtreecommitdiff
path: root/hw/lpc-uart.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2017-02-03 20:51:56 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-02-07 14:15:54 +1100
commit5bd0f9c20481a886a5367cf0ccd9b92b7e0feb87 (patch)
tree8c88bf39b48415df4e1aaea8533ab7103d20971e /hw/lpc-uart.c
parent0500d504b13eb95046bcea9b17ad6787ff18e843 (diff)
downloadskiboot-5bd0f9c20481a886a5367cf0ccd9b92b7e0feb87.zip
skiboot-5bd0f9c20481a886a5367cf0ccd9b92b7e0feb87.tar.gz
skiboot-5bd0f9c20481a886a5367cf0ccd9b92b7e0feb87.tar.bz2
uart: Fix Linux pass-through policy
This was broken on Rhesus. Also add an nvram way of overriding the policy Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/lpc-uart.c')
-rw-r--r--hw/lpc-uart.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c
index 17abe08..d063710 100644
--- a/hw/lpc-uart.c
+++ b/hw/lpc-uart.c
@@ -27,6 +27,7 @@
#include <cpu.h>
#include <chip.h>
#include <io.h>
+#include <nvram.h>
DEFINE_LOG_ENTRY(OPAL_RC_UART_INIT, OPAL_PLATFORM_ERR_EVT, OPAL_UART,
OPAL_CEC_HARDWARE, OPAL_PREDICTIVE_ERR_GENERAL,
@@ -68,6 +69,12 @@ static bool has_irq = false, irq_ok, rx_full, tx_full;
static uint8_t tx_room;
static uint8_t cached_ier;
static void *mmio_uart_base;
+static int uart_console_policy = UART_CONSOLE_OPAL;
+
+void uart_set_console_policy(int policy)
+{
+ uart_console_policy = policy;
+}
static void uart_trace(u8 ctx, u8 cnt, u8 irq_state, u8 in_count)
{
@@ -412,7 +419,7 @@ static void uart_irq(uint32_t chip_id __unused, uint32_t irq_mask __unused)
* Common setup/inits
*/
-void uart_setup_linux_passthrough(void)
+static void uart_setup_os_passthrough(void)
{
char *path;
@@ -423,7 +430,7 @@ void uart_setup_linux_passthrough(void)
prlog(PR_DEBUG, "UART: Enabled as OS pass-through\n");
}
-void uart_setup_opal_console(void)
+static void uart_setup_opal_console(void)
{
/* Add the opal console node */
add_opal_console_node(0, "raw", OUT_BUF_SIZE);
@@ -451,9 +458,33 @@ void uart_setup_opal_console(void)
opal_add_poller(uart_console_poll, NULL);
}
+static void uart_init_opal_console(void)
+{
+ const char *nv_policy;
+
+ /* Update the policy if the corresponding nvram variable
+ * is present
+ */
+ nv_policy = nvram_query("uart-con-policy");
+ if (nv_policy) {
+ if (!strcmp(nv_policy, "opal"))
+ uart_console_policy = UART_CONSOLE_OPAL;
+ else if (!strcmp(nv_policy, "os"))
+ uart_console_policy = UART_CONSOLE_OS;
+ else
+ prlog(PR_WARNING,
+ "UART: Unknown console policy in NVRAM: %s\n",
+ nv_policy);
+ }
+ if (uart_console_policy == UART_CONSOLE_OPAL)
+ uart_setup_opal_console();
+ else
+ uart_setup_os_passthrough();
+}
+
struct opal_con_ops uart_opal_con = {
.name = "OPAL UART console",
- .init = uart_setup_opal_console,
+ .init = uart_init_opal_console,
.read = uart_opal_read,
.write = uart_opal_write,
.space = uart_opal_write_buffer_space,