RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
bsps
include
dev
serial
arm-pl011.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
10
11
/*
12
* Copyright (C) 2013, 2014 embedded brains GmbH & Co. KG
13
*
14
* Redistribution and use in source and binary forms, with or without
15
* modification, are permitted provided that the following conditions
16
* are met:
17
* 1. Redistributions of source code must retain the above copyright
18
* notice, this list of conditions and the following disclaimer.
19
* 2. Redistributions in binary form must reproduce the above copyright
20
* notice, this list of conditions and the following disclaimer in the
21
* documentation and/or other materials provided with the distribution.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
* POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
#ifndef LIBBSP_ARM_SHARED_ARM_PL011_H
37
#define LIBBSP_ARM_SHARED_ARM_PL011_H
38
39
#include <
rtems/termiostypes.h
>
40
41
#include <
dev/serial/arm-pl011-regs.h
>
42
#include <bspopts.h>
43
#ifdef __cplusplus
44
extern
"C"
{
45
#endif
/* __cplusplus */
46
52
53
typedef
struct
{
54
pl011_base
base;
55
uint32_t reserved_4c[997];
56
uint32_t uartperiphid0;
57
uint32_t uartperiphid1;
58
uint32_t uartperiphid2;
59
uint32_t uartperiphid3;
60
uint32_t uartpcellid0;
61
uint32_t uartpcellid1;
62
uint32_t uartpcellid2;
63
uint32_t uartpcellid3;
64
}
arm_pl011_uart
;
65
66
typedef
struct
{
67
rtems_termios_device_context
base;
68
volatile
arm_pl011_uart
*regs;
69
rtems_vector_number
irq;
70
uint32_t initial_baud;
71
uint32_t clock;
72
73
#ifdef BSP_CONSOLE_USE_INTERRUPTS
74
/*
75
* Due to HW limitation, the first TX interrupt should be triggered by the
76
* software. This is because TX interrupts are based on transition through
77
* a level, rather than on the level itself. When the UART interrupt and
78
* UART is enabled before any data is written to the TXFIFO, the interrupt
79
* is not set. The interrupt is only set once the TXFIFO becomes empty
80
* after being filled to the trigger level. Until then, this flag variable
81
* ensures that the interrupt handler is software triggered.
82
*/
83
bool
needs_sw_triggered_tx_irq;
84
85
int
tx_queued_chars;
86
rtems_termios_tty
* tty;
87
#endif
88
}
arm_pl011_context
;
89
90
#ifdef BSP_CONSOLE_USE_INTERRUPTS
91
92
#define FIFO_LEVEL_ONE_EIGHTH 0
93
#define FIFO_LEVEL_ONE_FOURTH 1
94
#define FIFO_LEVEL_ONE_HALF 2
95
#define FIFO_LEVEL_THREE_FOURTH 3
96
#define FIFO_LELEL_SEVEN_HALF 4
97
98
#define TXFIFO_IRQ_TRIGGER_LEVEL FIFO_LEVEL_ONE_EIGHTH
99
#define RXFIFO_IRQ_TRIGGER_LEVEL FIFO_LEVEL_ONE_HALF
100
101
#endif
102
103
extern
const
rtems_termios_device_handler
arm_pl011_fns;
104
112
bool
arm_pl011_probe
(
rtems_termios_device_context
*base);
113
120
void
arm_pl011_write_polled
(
rtems_termios_device_context
*base,
char
c);
121
130
int
arm_pl011_read_polled
(
rtems_termios_device_context
*base);
131
139
volatile
arm_pl011_uart
*
arm_pl011_get_regs
(
rtems_termios_device_context
*base);
140
154
int
arm_pl011_compute_baudrate_params
(
155
uint32_t *ibrd,
156
uint32_t *fbrd,
157
const
uint32_t baudrate,
158
const
uint32_t clock,
159
const
unsigned
short
max_error
160
);
161
162
#ifdef __cplusplus
163
}
164
#endif
/* __cplusplus */
165
166
#endif
/* LIBBSP_ARM_SHARED_ARM_PL011_H */
arm-pl011-regs.h
ARM PL011 Register definitions.
arm_pl011_read_polled
int arm_pl011_read_polled(rtems_termios_device_context *base)
Read a char using polling mode.
Definition
arm-pl011.c:426
arm_pl011_probe
bool arm_pl011_probe(rtems_termios_device_context *base)
Initialize pl011 registers.
Definition
arm-pl011.c:59
arm_pl011_compute_baudrate_params
int arm_pl011_compute_baudrate_params(uint32_t *ibrd, uint32_t *fbrd, const uint32_t baudrate, const uint32_t clock, const unsigned short max_error)
Compute baudrate params.
Definition
arm-pl011.c:188
arm_pl011_get_regs
volatile arm_pl011_uart * arm_pl011_get_regs(rtems_termios_device_context *base)
Get register base address.
Definition
arm-pl011.c:54
arm_pl011_write_polled
void arm_pl011_write_polled(rtems_termios_device_context *base, char c)
Write a char using polling mode.
Definition
arm-pl011.c:437
rtems_vector_number
ISR_Vector_number rtems_vector_number
This integer type represents interrupt vector numbers.
Definition
intr.h:102
arm_pl011_context
Definition
arm-pl011.h:66
arm_pl011_uart
Definition
arm-pl011.h:53
pl011_base
Definition
arm-pl011-regs.h:48
rtems_termios_device_context
Termios device context.
Definition
termiosdevice.h:68
rtems_termios_device_handler
Termios device handler.
Definition
termiosdevice.h:100
rtems_termios_tty
Definition
termiostypes.h:94
termiostypes.h
Generated by
1.18.0