summaryrefslogtreecommitdiffstats
path: root/libgloss/or1k/or1k_uart.h
blob: dc8a3dbce248fa6c62309e4f7bd3fd1077db27d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* or1k_uart.h -- UART definitions for OpenRISC 1000.
 *
 * Copyright (c) 2014 Authors
 *
 * Contributor Stefan Wallentowitz <stefan.wallentowitz@tum.de>
 *
 * The authors hereby grant permission to use, copy, modify, distribute,
 * and license this software and its documentation for any purpose, provided
 * that existing copyright notices are retained in all copies and that this
 * notice is included verbatim in any distributions. No written agreement,
 * license, or royalty fee is required for any of the authorized uses.
 * Modifications to this software may be copyrighted by their authors
 * and need not follow the licensing terms described here, provided that
 * the new terms are clearly indicated on the first page of each file where
 * they apply.
 */

/* This is the generic board support for the OpenCores UART device */

#include <stdint.h>

#include "board.h"

extern void (*_or1k_uart_read_cb)(char c);

void _or1k_uart_interrupt_handler(uint32_t data);

int _or1k_uart_init(void);
void _or1k_uart_write(char c);

#define RB  _or1k_board_uart_base + 0
#define THR _or1k_board_uart_base + 0
#define IER _or1k_board_uart_base + 1
#define IIR _or1k_board_uart_base + 2
#define FCR _or1k_board_uart_base + 2
#define LCR _or1k_board_uart_base + 3
#define MCR _or1k_board_uart_base + 4
#define LSR _or1k_board_uart_base + 5
#define MSR _or1k_board_uart_base + 6

#define DLB1 _or1k_board_uart_base + 0
#define DLB2 _or1k_board_uart_base + 1

#define IER_RDAI 0
#define IER_TEI  1
#define IER_RLSI 2
#define IER_MSI  3

#define IIR_RLS  0xC3
#define IIR_RDA  0xC2
#define IIR_TO   0xC6
#define IIR_THRE 0xC1
#define IIT_MS   0xC0

#define FCR_CLRRECV 0x1
#define FCR_CLRTMIT 0x2
#define FCR_TRIG_1  0x0
#define FCR_TRIG_4  0x40
#define FCR_TRIG_8  0x80
#define FCR_TRIG_14 0xC0

#define LCR_BPC_MASK 0x3
#define LCR_SB_MASK  0x4

#define LCR_BPC_5 0x0
#define LCR_BPC_6 0x1
#define LCR_BPC_7 0x2
#define LCR_BPC_8 0x3
#define LCR_SB_1  0x0
#define LCR_SB_2  0x4
#define LCR_PE    0x8
#define LCR_EPS   0x10
#define LCR_SP    0x20
#define LCR_BC    0x40
#define LCR_DLA   0x80

#define LSR_DR  0x0
#define LSR_OE  0x2
#define LSR_PE  0x4
#define LSR_FE  0x8
#define LSR_BI  0x10
#define LSR_TFE 0x20
#define LSR_TEI 0x40