blob: 7ab6df047df7d3f76a98a970607eaa2b28364ca5 [file] [log] [blame]
Soren Brinkmannf9a31192016-03-06 20:14:51 -08001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soren Brinkmannf9a31192016-03-06 20:14:51 -08005 */
6
7#ifndef __CADENCE_UART_H__
8#define __CADENCE_UART_H__
9
Julius Werner1343ad52017-09-18 17:01:06 -070010#include <console.h>
11
Soren Brinkmannf9a31192016-03-06 20:14:51 -080012/* This is very minimalistic and will only work in QEMU. */
13
14/* CADENCE Registers */
15#define R_UART_CR 0
16#define R_UART_CR_RXRST (1 << 0) /* RX logic reset */
17#define R_UART_CR_TXRST (1 << 1) /* TX logic reset */
18#define R_UART_CR_RX_EN (1 << 2) /* RX enabled */
19#define R_UART_CR_TX_EN (1 << 4) /* TX enabled */
20
21#define R_UART_SR 0x2C
22#define UART_SR_INTR_REMPTY_BIT 1
23#define UART_SR_INTR_TFUL_BIT 4
24
25#define R_UART_TX 0x30
26#define R_UART_RX 0x30
27
Julius Werner1343ad52017-09-18 17:01:06 -070028#define CONSOLE_T_CDNS_BASE CONSOLE_T_DRVDATA
29
30#ifndef __ASSEMBLY__
31
32#include <types.h>
33
34typedef struct {
35 console_t console;
36 uintptr_t base;
37} console_cdns_t;
38
39/*
40 * Initialize a new Cadence console instance and register it with the console
41 * framework. The |console| pointer must point to storage that will be valid
42 * for the lifetime of the console, such as a global or static local variable.
43 * Its contents will be reinitialized from scratch.
44 */
45int console_cdns_register(uint64_t baseaddr, uint32_t clock, uint32_t baud,
46 console_cdns_t *console);
47
48#endif /*__ASSEMBLY__*/
49
Soren Brinkmannf9a31192016-03-06 20:14:51 -080050#endif