RTEMS 6.1-rc4
Loading...
Searching...
No Matches
arm-pl011.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
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
42#include <bspopts.h>
43#ifdef __cplusplus
44extern "C" {
45#endif /* __cplusplus */
46
53typedef 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;
65
66typedef struct {
68 volatile arm_pl011_uart *regs;
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;
87#endif
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
103extern const rtems_termios_device_handler arm_pl011_fns;
104
113
121
131
140
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 Register definitions.
int arm_pl011_read_polled(rtems_termios_device_context *base)
Read a char using polling mode.
Definition: arm-pl011.c:426
bool arm_pl011_probe(rtems_termios_device_context *base)
Initialize pl011 registers.
Definition: arm-pl011.c:59
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
volatile arm_pl011_uart * arm_pl011_get_regs(rtems_termios_device_context *base)
Get register base address.
Definition: arm-pl011.c:54
void arm_pl011_write_polled(rtems_termios_device_context *base, char c)
Write a char using polling mode.
Definition: arm-pl011.c:437
ISR_Vector_number rtems_vector_number
This integer type represents interrupt vector numbers.
Definition: intr.h:102
Definition: arm-pl011.h:66
Definition: arm-pl011.h:53
Definition: arm-pl011-regs.h:48
Termios device context.
Definition: termiosdevice.h:68
Termios device handler.
Definition: termiosdevice.h:100
Definition: termiostypes.h:94