Skip to content

Commit 6a0834e

Browse files
committed
FIX: PL011 RPi4 UART configuration
- Page alignment is required for Bao; all UARTs except for UART0 in the RPi4 are not page aligned, thus requiring an offset. This must be defined by the platform's user (plat/platform.h). - UART_CLK must be overridable and defined by the platform's user (plat/platform.h): in RPi4 PL011 run at 48 MHz Signed-off-by: ElectroQuanta <29806215+ElectroQuanta@users.noreply.github.com> CI validated
1 parent 96a78ae commit 6a0834e

File tree

1 file changed

+41
-33
lines changed

1 file changed

+41
-33
lines changed

src/platform/drivers/pl011_uart/inc/drivers/pl011_uart.h

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,34 @@
88

99
#include <stdint.h>
1010

11+
#include <plat/platform.h>
12+
#ifndef PL011_PAGE_OFFSET
13+
#define PL011_PAGE_OFFSET (0x000) /**< offset in range of 0-0xFFF */
14+
#endif
15+
1116
/* UART Base Address (PL011) */
1217

13-
#define UART_BASE_0 0xFDF02000
14-
#define UART_BASE_1 0xFDF00000
15-
#define UART_BASE_2 0xFDF03000
16-
#define UART_BASE_4 0xFDF01000
17-
#define UART_BASE_5 0xFDF05000
18-
#define UART_BASE_6 0xFFF32000
18+
#define UART_BASE_0 0xFDF02000
19+
#define UART_BASE_1 0xFDF00000
20+
#define UART_BASE_2 0xFDF03000
21+
#define UART_BASE_4 0xFDF01000
22+
#define UART_BASE_5 0xFDF05000
23+
#define UART_BASE_6 0xFFF32000
1924

2025
/* UART Interrupts */
2126

22-
#define UART_0_INTERRUPT 106
23-
#define UART_1_INTERRUPT 107
24-
#define UART_2_INTERRUPT 108
25-
#define UART_4_INTERRUPT 109
26-
#define UART_5_INTERRUPT 110
27-
#define UART_6_INTERRUPT 111
27+
#define UART_0_INTERRUPT 106
28+
#define UART_1_INTERRUPT 107
29+
#define UART_2_INTERRUPT 108
30+
#define UART_4_INTERRUPT 109
31+
#define UART_5_INTERRUPT 110
32+
#define UART_6_INTERRUPT 111
2833

29-
#define NUM_UART 6
34+
#define NUM_UART 6
3035

31-
#define UART_CLK 19200000
36+
#ifndef UART_CLK
37+
#define UART_CLK 19200000
38+
#endif
3239
#define UART_BAUD_RATE 115200
3340

3441
/* UART Data Register */
@@ -177,25 +184,26 @@
177184
/* UART (PL011) register structure */
178185

179186
struct Pl011_Uart_hw {
180-
volatile uint32_t data; // UART Data Register
181-
volatile uint32_t status_error; // UART Receive Status Register/Error Clear
182-
// Register
183-
const uint32_t reserved1[4]; // Reserved: 4(0x4) bytes
184-
volatile uint32_t flag; // UART Flag Register
185-
const uint32_t reserved2[1]; // Reserved: 1(0x1) bytes
186-
volatile uint32_t lp_counter; // UART Low-power Counter Register
187-
volatile uint32_t integer_br; // UART Integer Baud Rate Register
188-
volatile uint32_t fractional_br; // UART Fractional Baud Rate Register
189-
volatile uint32_t line_control; // UART Line Control Register
190-
volatile uint32_t control; // UART Control Register
191-
volatile uint32_t isr_fifo_level_sel; // UART Interrupt FIFO level Select
192-
// Register
193-
volatile uint32_t isr_mask; // UART Interrupt Mask Set/Clear Register
194-
volatile uint32_t raw_isr_status; // UART Raw Interrupt Status Register
195-
volatile uint32_t masked_isr_status; // UART Masked Interrupt Status
196-
// Register
197-
volatile uint32_t isr_clear; // UART Interrupt Clear Register
198-
volatile uint32_t DMA_control; // UART DMA control Register
187+
const uint8_t offset[PL011_PAGE_OFFSET]; // Offset for page alignment
188+
volatile uint32_t data; // UART Data Register
189+
volatile uint32_t status_error; // UART Receive Status Register/Error Clear
190+
// Register
191+
const uint32_t reserved1[4]; // Reserved: 4(0x4) bytes
192+
volatile uint32_t flag; // UART Flag Register
193+
const uint32_t reserved2[1]; // Reserved: 1(0x1) bytes
194+
volatile uint32_t lp_counter; // UART Low-power Counter Register
195+
volatile uint32_t integer_br; // UART Integer Baud Rate Register
196+
volatile uint32_t fractional_br; // UART Fractional Baud Rate Register
197+
volatile uint32_t line_control; // UART Line Control Register
198+
volatile uint32_t control; // UART Control Register
199+
volatile uint32_t isr_fifo_level_sel; // UART Interrupt FIFO level Select
200+
// Register
201+
volatile uint32_t isr_mask; // UART Interrupt Mask Set/Clear Register
202+
volatile uint32_t raw_isr_status; // UART Raw Interrupt Status Register
203+
volatile uint32_t masked_isr_status; // UART Masked Interrupt Status
204+
// Register
205+
volatile uint32_t isr_clear; // UART Interrupt Clear Register
206+
volatile uint32_t DMA_control; // UART DMA control Register
199207
};
200208

201209
typedef struct Pl011_Uart_hw bao_uart_t;

0 commit comments

Comments
 (0)