summaryrefslogtreecommitdiff
path: root/chip/nrf51/uart.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /chip/nrf51/uart.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14388.52.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'chip/nrf51/uart.c')
-rw-r--r--chip/nrf51/uart.c120
1 files changed, 0 insertions, 120 deletions
diff --git a/chip/nrf51/uart.c b/chip/nrf51/uart.c
deleted file mode 100644
index 1f546a2b79..0000000000
--- a/chip/nrf51/uart.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* Copyright 2014 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* USART driver for Chrome EC */
-
-#include "clock.h"
-#include "console.h"
-#include "common.h"
-#include "dma.h"
-#include "hooks.h"
-#include "registers.h"
-#include "system.h"
-#include "task.h"
-#include "uart.h"
-#include "util.h"
-
-#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
-#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
-
-
-static int ever_sent; /* if we ever sent byte to TXD? */
-static int init_done; /* Initialization done? */
-static int should_stop; /* Last TX control action */
-
-int uart_init_done(void)
-{
- return init_done;
-}
-
-void uart_tx_start(void)
-{
- disable_sleep(SLEEP_MASK_UART);
- should_stop = 0;
- NRF51_UART_INTENSET = BIT(NRF55_UART_TXDRDY_BIT);
- task_trigger_irq(NRF51_PERID_USART);
-}
-
-void uart_tx_stop(void)
-{
- NRF51_UART_INTENCLR = BIT(NRF55_UART_TXDRDY_BIT);
- should_stop = 1;
- enable_sleep(SLEEP_MASK_UART);
-}
-
-int uart_tx_ready(void)
-{
- /*
- * nRF51 design is NOT tx-empty style. Instead, it is if a byte is
- * ever transmitted from TxD. This means NRF51_UART_TXDRDY is always
- * 0 after reset. So, we use 'ever_sent' to send the first byte.
- */
- return NRF51_UART_TXDRDY || (!ever_sent);
-}
-
-int uart_rx_available(void)
-{
- return NRF51_UART_RXDRDY;
-}
-
-void uart_tx_flush(void)
-{
- while (!uart_tx_ready())
- ;
-}
-
-void uart_write_char(char c)
-{
- ever_sent = 1;
- NRF51_UART_TXDRDY = 0;
- NRF51_UART_TXD = c;
- NRF51_UART_STARTTX = 1;
-}
-
-int uart_read_char(void)
-{
- NRF51_UART_RXDRDY = 0;
- return NRF51_UART_RXD;
-}
-
-/* Interrupt handler for console USART */
-void uart_interrupt(void)
-{
-#ifndef CONFIG_UART_RX_DMA
- /*
- * Read input FIFO until empty. DMA-based receive does this from a
- * hook in the UART buffering module.
- */
- uart_process_input();
-#endif
-
- /* Fill output FIFO */
- uart_process_output();
-
-#ifndef CONFIG_UART_TX_DMA
- if (!should_stop)
- NRF51_UART_INTENSET = BIT(NRF55_UART_TXDRDY_BIT);
-#endif /* CONFIG_UART_TX_DMA */
-
-}
-DECLARE_IRQ(NRF51_PERID_USART, uart_interrupt, 2);
-
-
-void uart_init(void)
-{
- NRF51_UART_PSELTXD = NRF51_UART_TX_PIN; /* GPIO Port for Tx */
- NRF51_UART_PSELRXD = NRF51_UART_RX_PIN; /* GPIO Port for Rx */
- NRF51_UART_CONFIG = 0; /* disable HW flow control, no parity bit */
- NRF51_UART_BAUDRATE = 0x01d7e000; /* 115200 */
- NRF51_UART_ENABLE = 0x4; /* Enable UART */
-
- task_enable_irq(NRF51_PERID_USART);
-
- NRF51_UART_INTENSET = BIT(NRF55_UART_RXDRDY_BIT);
- NRF51_UART_STARTRX = 1;
-
- init_done = 1;
-}