blob: b03d0dd4a29ad592f5c4b802073477cab044792f (
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
|
/***************************************************************************
* Copyright (c) 2025 10xEngineers
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
#ifndef RISCV_UART_H
#define RISCV_UART_H
/* SpacemiT K1 UART0
*
* DTS node: /soc/serial@d4017000
* serial@d4017000 {
* power-domains = <0x20 0x00>;
* reg-io-width = <0x04>;
* clk-fpga = <0xe11130>;
* pinctrl-names = "default";
* interconnect-names = "dma-mem";
* pinctrl-0 = <0x23>;
* interconnects = <0x22>;
* resets = <0x1d 0x01>;
* interrupts = <0x2a>;
* clocks = <0x03 0x3a 0x03 0xb4>;
* interrupt-parent = <0x1e>;
* dma-names = "rx", "tx";
* cpuidle,pm-runtime,sleep;
* compatible = "spacemit,pxa-uart";
* status = "okay";
* reg = <0x00 0xd4017000 0x00 0x100>;
* dmas = <0x21 0x04 0x01 0x21 0x03 0x01>;
* reg-shift = <0x02>;
* };
* K1 User Manual Section 16.3.4 defines the register layout. Because
* reg-shift = 2, the logical 16550A register indices (0..7) map to
* byte offsets 0x00, 0x04, 0x08, ..., 0x1C (stride of 4).
*
* Register map (at UART0 + offset):
*
* Offset Name R/W Description
* ────── ────────── ─── ────────────────────────────────────
* 0x00 RBR/THR/DLL R/W Receive Buffer / Transmit Holding /
* Divisor Latch Low (when LCR.DLAB=1)
* 0x04 IER/DLH R/W Interrupt Enable /
* Divisor Latch High (when LCR.DLAB=1)
* 0x08 IIR/FCR R/W Interrupt Identification (R) /
* FIFO Control (W)
* 0x0C LCR R/W Line Control
* 0x10 MCR R/W Modem Control
* 0x14 LSR R Line Status
* 0x18 MSR R Modem Status
* 0x1C SPR R/W Scratchpad
*
*/
#define UART0 0xD4017000UL
#define UART0_SIZE 0x100UL /* 256 bytes, from DTS reg */
#define UART0_IRQ 42 /* DTS: interrupts = <0x2a> */
#define UART0_REG_SHIFT 2 /* DTS: reg-shift = <0x02> */
#define puts uart_puts
int uart_init(void);
int uart_putc(int ch);
int uart_puts(const char *str);
#endif /* RISCV_UART_H */
|