blob: 0ea284fdf15cf5cf03b2f9348debd45434ae85a7 [file] [log] [blame]
Anson Huang5aba17f2018-06-05 16:11:24 +08001/*
2 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef IMX8_LPUART_H
8#define IMX8_LPUART_H
Anson Huang5aba17f2018-06-05 16:11:24 +08009
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <drivers/console.h>
Anson Huang5aba17f2018-06-05 16:11:24 +080011
12#define VERID 0x0
13#define PARAM 0x4
14#define GLOBAL 0x8
15#define PINCFG 0xC
16#define BAUD 0x10
17#define STAT 0x14
18#define CTRL 0x18
19#define DATA 0x1C
20#define MATCH 0x20
21#define MODIR 0x24
22#define FIFO 0x28
23#define WATER 0x2c
24
25#define US1_TDRE (1 << 23)
26#define US1_RDRF (1 << 21)
27
28#define CTRL_TE (1 << 19)
29#define CTRL_RE (1 << 18)
30
31#define FIFO_TXFE 0x80
32#define FIFO_RXFE 0x40
33
34#define WATER_TXWATER_OFF 1
35#define WATER_RXWATER_OFF 16
36
37#define LPUART_CTRL_PT_MASK 0x1
38#define LPUART_CTRL_PE_MASK 0x2
39#define LPUART_CTRL_M_MASK 0x10
40
41#define LPUART_BAUD_OSR_MASK (0x1F000000U)
42#define LPUART_BAUD_OSR_SHIFT (24U)
43#define LPUART_BAUD_OSR(x) (((uint32_t)(((uint32_t)(x)) << LPUART_BAUD_OSR_SHIFT)) & LPUART_BAUD_OSR_MASK)
44
45#define LPUART_BAUD_SBR_MASK (0x1FFFU)
46#define LPUART_BAUD_SBR_SHIFT (0U)
47#define LPUART_BAUD_SBR(x) (((uint32_t)(((uint32_t)(x)) << LPUART_BAUD_SBR_SHIFT)) & LPUART_BAUD_SBR_MASK)
48
49#define LPUART_BAUD_SBNS_MASK (0x2000U)
50#define LPUART_BAUD_BOTHEDGE_MASK (0x20000U)
51#define LPUART_BAUD_M10_MASK (0x20000000U)
52
Julius Werner53456fc2019-07-09 13:49:11 -070053#ifndef __ASSEMBLER__
Anson Huang5aba17f2018-06-05 16:11:24 +080054
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +010055#include <stdint.h>
Anson Huang5aba17f2018-06-05 16:11:24 +080056
57typedef struct {
58 console_t console;
59 uintptr_t base;
60} console_lpuart_t;
61
62int console_lpuart_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud,
63 console_lpuart_t *console);
Julius Werner53456fc2019-07-09 13:49:11 -070064#endif /*__ASSEMBLER__*/
Anson Huang5aba17f2018-06-05 16:11:24 +080065
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000066#endif /* IMX8_LPUART_H */