summaryrefslogtreecommitdiff
path: root/uart_core.h
blob: 4cab20754d96911c74bc20907822b958f121e322 (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
/*
    Nios-sim - one simple NIOSII simulator only for personal interest and fun.
    Copyright (C) 2010  chysun2000@gmail.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __UART_CORE_H__
#define __UART_CORE_H__
	
#include <stdio.h>
#include "public.h"
#include "niosii.h"
#include "io_device.h"
	
#define UART_IRQ_MASK		(1 << 2)
#define UART_CORE_BASE_ADDR 	(0x80681000)
#define UART_CORE_REG_CNT 		(8)
	
/* Mask for registers */
/* copy from /drivers/serial/altuart.c */
#define ALTERA_UART_STATUS_PE_MSK         (0x1)
#define ALTERA_UART_STATUS_FE_MSK         (0x2)
#define ALTERA_UART_STATUS_BRK_MSK        (0x4)
#define ALTERA_UART_STATUS_ROE_MSK        (0x8)
#define ALTERA_UART_STATUS_TOE_MSK        (0x10)
#define ALTERA_UART_STATUS_TMT_MSK        (0x20)
#define ALTERA_UART_STATUS_TRDY_MSK       (0x40)
#define ALTERA_UART_STATUS_RRDY_MSK       (0x80)
#define ALTERA_UART_STATUS_E_MSK          (0x100)
#define ALTERA_UART_STATUS_DCTS_MSK       (0x400)
#define ALTERA_UART_STATUS_CTS_MSK        (0x800)
#define ALTERA_UART_STATUS_EOP_MSK        (0x1000)

#define ALTERA_UART_CONTROL_PE_MSK        (0x1)
#define ALTERA_UART_CONTROL_FE_MSK        (0x2)
#define ALTERA_UART_CONTROL_BRK_MSK       (0x4)
#define ALTERA_UART_CONTROL_ROE_MSK       (0x8)
#define ALTERA_UART_CONTROL_TOE_MSK       (0x10)
#define ALTERA_UART_CONTROL_TMT_MSK       (0x20)
#define ALTERA_UART_CONTROL_TRDY_MSK      (0x40)
#define ALTERA_UART_CONTROL_RRDY_MSK      (0x80)
#define ALTERA_UART_CONTROL_E_MSK         (0x100)
#define ALTERA_UART_CONTROL_TRBK_MSK      (0x200)
#define ALTERA_UART_CONTROL_DCTS_MSK      (0x400)
#define ALTERA_UART_CONTROL_RTS_MSK       (0x800)
#define ALTERA_UART_CONTROL_EOP_MSK       (0x1000)

#define ALTERA_UART_EOP_MSK               (0xFF)
#define ALTERA_UART_EOP_OFST              (0)

#define UART_HAS_NO_DATA_TO_RX (0x00)
#define UART_HAS_DATA_TO_RX (0x01)
#define UART_HAS_DATA_TO_TX (0x01)
#define UART_HAS_NO_DATA_TO_TX (0x00)

struct uart_core_hw {
	struct io_reg io_regs[UART_CORE_REG_CNT];
	uint32_t rx_status;
	uint32_t tx_status;
};

extern struct io_device uart_core;
#endif