Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef IMX8_LPUART_H |
| 8 | #define IMX8_LPUART_H |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 9 | |
| 10 | #include <console.h> |
| 11 | |
| 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 | |
| 53 | #ifndef __ASSEMBLY__ |
| 54 | |
Antonio Nino Diaz | 4b32e62 | 2018-08-16 16:52:57 +0100 | [diff] [blame] | 55 | #include <stdint.h> |
Anson Huang | 5aba17f | 2018-06-05 16:11:24 +0800 | [diff] [blame] | 56 | |
| 57 | typedef struct { |
| 58 | console_t console; |
| 59 | uintptr_t base; |
| 60 | } console_lpuart_t; |
| 61 | |
| 62 | int console_lpuart_register(uintptr_t baseaddr, uint32_t clock, uint32_t baud, |
| 63 | console_lpuart_t *console); |
| 64 | #endif /*__ASSEMBLY__*/ |
| 65 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 66 | #endif /* IMX8_LPUART_H */ |