1 /*
2  * Copyright (c) 2023 ENE Technology Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ENE_KB1200_SER_H
8 #define ENE_KB1200_SER_H
9 
10 /**
11  *  Structure type to access Serial Port Interface (SER).
12  */
13 struct serial_regs {
14 	volatile uint32_t SERCFG;  /*Configuration Register */
15 	volatile uint32_t SERIE;   /*Interrupt Enable Register */
16 	volatile uint32_t SERPF;   /*Pending flag Register */
17 	volatile uint32_t SERSTS;  /*Status Register */
18 	volatile uint32_t SERRBUF; /*Rx Data Buffer Register */
19 	volatile uint32_t SERTBUF; /*Tx Data Buffer Register */
20 	volatile uint32_t SERCTRL; /*Control Register */
21 };
22 
23 #define DIVIDER_BASE_CLK 24000000
24 
25 #define SERCTRL_MODE0 0 /* shift  */
26 #define SERCTRL_MODE1 1 /* 8-bit  */
27 #define SERCTRL_MODE2 2 /* 9-bit  */
28 #define SERCTRL_MODE3 3 /* 9-bit  */
29 
30 #define SERCFG_RX_ENABLE  0x01
31 #define SERCFG_TX_ENABLE  0x02
32 
33 #define SERCFG_PARITY_NONE  0
34 #define SERCFG_PARITY_ODD   1
35 #define SERCFG_PARITY_EVEN  3
36 
37 /* Pending Flag */
38 #define SERPF_RX_CNT_FULL 0x01
39 #define SERPF_TX_EMPTY    0x02
40 #define SERPF_RX_ERROR    0x04
41 
42 /* Interrupt Enable */
43 #define SERIE_RX_ENABLE   0x01
44 #define SERIE_TX_ENABLE   0x02
45 #define SERIE_RX_ERROR    0x04
46 
47 /* Status Flag */
48 #define SERSTS_FRAME_ERROR  0x0200
49 #define SERSTS_PARITY_ERROR 0x0100
50 #define SERSTS_RX_TIMEOUT   0x0080
51 #define SERSTS_RX_BUSY      0x0040
52 #define SERSTS_RX_OVERRUN   0x0020
53 #define SERSTS_RX_EMPTY     0x0010
54 #define SERSTS_TX_BUSY      0x0004
55 #define SERSTS_TX_OVERRUN   0x0002
56 #define SERSTS_TX_FULL      0x0001
57 
58 #endif /* ENE_KB1200_SER_H */
59