summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-09-19 16:43:19 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-09-20 20:44:54 +0000
commitf27c00768489ae6b81a1366116744fec7f849ba8 (patch)
tree1ebe436e4d4776c81612c8fc26accba822ea92c0
parent883dd51006600d78ccfc6c6ff73a66943492538e (diff)
downloadchrome-ec-f27c00768489ae6b81a1366116744fec7f849ba8.tar.gz
lm4: make CONFIG_UART_HOST optional
Currently, CONFIG_UART_HOST must be defined for all LM4-based platforms. Future platforms may not need host UART support, so make it optional. BUG=chrome-os-partner:22802 BRANCH=none TEST=Temporarily comment out CONFIG_UART_HOST in board/link/board.h; code still compiles. Change-Id: I8775d9daaf8f6e45f1f374c9be7f10316611447f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170104 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--chip/lm4/lpc.c17
-rw-r--r--chip/lm4/uart.c25
2 files changed, 36 insertions, 6 deletions
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c
index 71938409d8..9d0a53162f 100644
--- a/chip/lm4/lpc.c
+++ b/chip/lm4/lpc.c
@@ -266,6 +266,8 @@ void lpc_keyboard_resume_irq(void)
lpc_manual_irq(1);
}
+#ifdef CONFIG_UART_HOST
+
int lpc_comx_has_char(void)
{
return LM4_LPC_ST(LPC_CH_COMX) & LM4_LPC_ST_FRMH;
@@ -282,6 +284,8 @@ void lpc_comx_put_char(int c)
/* TODO: manually trigger IRQ, like we do for keyboard? */
}
+#endif /* CONFIG_UART_HOST */
+
/**
* Update the host event status.
*
@@ -599,12 +603,14 @@ static void lpc_interrupt(void)
}
#endif
+#ifdef CONFIG_UART_HOST
/* Handle COMx */
if (lpc_comx_has_char()) {
/* Copy a character to the UART if there's space */
if (uart_comx_putc_ok())
uart_comx_putc(lpc_comx_get_char());
}
+#endif
/* Debugging: print changes to LPC0RESET */
if (mis & (1 << 31)) {
@@ -731,6 +737,7 @@ static void lpc_init(void)
LM4_LPC_ADR(LPC_CH_MEMMAP) = EC_LPC_ADDR_MEMMAP;
LM4_LPC_CTL(LPC_CH_MEMMAP) = 0x0019 | (LPC_POOL_OFFS_MEMMAP << (5 - 1));
+#ifdef CONFIG_UART_HOST
/*
* Set LPC channel 7 to COM port I/O address. Note that channel 7
* ignores the TYPE bit and is always an 8-byte range.
@@ -750,6 +757,7 @@ static void lpc_init(void)
* sensible to buffer input anyway.
*/
LM4_LPC_LPCIM |= LM4_LPC_INT_MASK(LPC_CH_COMX, 2);
+#endif /* CONFIG_UART_HOST */
/*
* Unmaksk LPC bus reset interrupt. This lets us monitor the PCH
@@ -764,8 +772,11 @@ static void lpc_init(void)
(1 << LPC_CH_CMD_DATA) |
(1 << LPC_CH_KEYBOARD) |
(1 << LPC_CH_CMD) |
- (1 << LPC_CH_MEMMAP) |
- (1 << LPC_CH_COMX);
+ (1 << LPC_CH_MEMMAP);
+
+#ifdef CONFIG_UART_HOST
+ LM4_LPC_LPCCTL |= 1 << LPC_CH_COMX;
+#endif
/*
* Ensure the EC (slave) has control of the memory-mapped I/O space.
@@ -793,8 +804,10 @@ static void lpc_init(void)
/* Enable LPC interrupt */
task_enable_irq(LM4_IRQ_LPC);
+#ifdef CONFIG_UART_HOST
/* Enable COMx UART */
uart_comx_enable();
+#endif
/* Restore event masks if needed */
lpc_post_sysjump();
diff --git a/chip/lm4/uart.c b/chip/lm4/uart.c
index ff24718a07..73570e1746 100644
--- a/chip/lm4/uart.c
+++ b/chip/lm4/uart.c
@@ -5,6 +5,7 @@
/* UART module for Chrome EC */
+#include "clock.h"
#include "common.h"
#include "console.h"
#include "gpio.h"
@@ -14,7 +15,9 @@
#include "uart.h"
#include "util.h"
+#ifdef CONFIG_UART_HOST
#define CONFIG_UART_HOST_IRQ CONCAT2(LM4_IRQ_UART, CONFIG_UART_HOST)
+#endif
static int init_done;
@@ -107,6 +110,8 @@ static void uart_ec_interrupt(void)
}
DECLARE_IRQ(LM4_IRQ_UART0, uart_ec_interrupt, 1);
+#ifdef CONFIG_UART_HOST
+
/**
* Interrupt handler for Host UART
*/
@@ -139,6 +144,8 @@ static void uart_host_interrupt(void)
/* Must be same prio as LPC interrupt handler so they don't preempt */
DECLARE_IRQ(CONFIG_UART_HOST_IRQ, uart_host_interrupt, 2);
+#endif /* CONFIG_UART_HOST */
+
static void uart_config(int port)
{
/* Disable the port */
@@ -173,17 +180,23 @@ static void uart_config(int port)
void uart_init(void)
{
- volatile uint32_t scratch __attribute__((unused));
-
/* Enable UART0 and Host UART and delay a few clocks */
- LM4_SYSTEM_RCGCUART |= (1 << CONFIG_UART_HOST) | 1;
- scratch = LM4_SYSTEM_RCGCUART;
+ LM4_SYSTEM_RCGCUART |= 1;
+
+#ifdef CONFIG_UART_HOST
+ LM4_SYSTEM_RCGCUART |= (1 << CONFIG_UART_HOST);
+#endif
+
+ clock_wait_cycles(3);
gpio_config_module(MODULE_UART, 1);
/* Configure UARTs (identically) */
uart_config(0);
+
+#ifdef CONFIG_UART_HOST
uart_config(CONFIG_UART_HOST);
+#endif
/*
* Enable interrupts for UART0 only. Host UART will have to wait
@@ -198,6 +211,8 @@ void uart_init(void)
/*****************************************************************************/
/* COMx functions */
+#ifdef CONFIG_UART_HOST
+
void uart_comx_enable(void)
{
uart_clear_rx_fifo(CONFIG_UART_HOST);
@@ -223,6 +238,8 @@ void uart_comx_putc(int c)
LM4_UART_DR(CONFIG_UART_HOST) = c;
}
+#endif /* CONFIG_UART_HOST */
+
/*****************************************************************************/
/* Console commands */