summaryrefslogtreecommitdiff
path: root/chip/lm4/uart.c
diff options
context:
space:
mode:
Diffstat (limited to 'chip/lm4/uart.c')
-rw-r--r--chip/lm4/uart.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/chip/lm4/uart.c b/chip/lm4/uart.c
index 13fad41be6..ad9c634947 100644
--- a/chip/lm4/uart.c
+++ b/chip/lm4/uart.c
@@ -11,6 +11,7 @@
#include "gpio.h"
#include "lpc.h"
#include "registers.h"
+#include "system.h"
#include "task.h"
#include "uart.h"
#include "util.h"
@@ -32,6 +33,9 @@ void uart_tx_start(void)
if (LM4_UART_IM(0) & 0x20)
return;
+ /* Do not allow deep sleep while transmit in progress */
+ disable_sleep(SLEEP_MASK_UART);
+
/*
* Re-enable the transmit interrupt, then forcibly trigger the
* interrupt. This works around a hardware problem with the
@@ -45,6 +49,9 @@ void uart_tx_start(void)
void uart_tx_stop(void)
{
LM4_UART_IM(0) &= ~0x20;
+
+ /* Re-allow deep sleep */
+ enable_sleep(SLEEP_MASK_UART);
}
void uart_tx_flush(void)
@@ -182,14 +189,19 @@ void uart_init(void)
{
uint32_t mask = 0;
- /* Enable UART0 and Host UART in run, sleep, and deep sleep modes. */
+ /*
+ * Enable UART0 in run, sleep, and deep sleep modes. Enable the Host
+ * UART in run and sleep modes.
+ */
mask |= 1;
+ clock_enable_peripheral(CGC_OFFSET_UART, mask, CGC_MODE_DSLEEP);
#ifdef CONFIG_UART_HOST
mask |= (1 << CONFIG_UART_HOST);
#endif
- clock_enable_peripheral(CGC_OFFSET_UART, mask, CGC_MODE_ALL);
+ clock_enable_peripheral(CGC_OFFSET_UART, mask,
+ CGC_MODE_RUN | CGC_MODE_SLEEP);
gpio_config_module(MODULE_UART, 1);