1*6e3d02bbSandvar /* $NetBSD: plcomreg.h,v 1.9 2024/02/05 22:08:04 andvar Exp $ */ 219cf921bSrearnsha 319cf921bSrearnsha /*- 419cf921bSrearnsha * Copyright (c) 2001 ARM Ltd 519cf921bSrearnsha * All rights reserved. 619cf921bSrearnsha * 719cf921bSrearnsha * Redistribution and use in source and binary forms, with or without 819cf921bSrearnsha * modification, are permitted provided that the following conditions 919cf921bSrearnsha * are met: 1019cf921bSrearnsha * 1. Redistributions of source code must retain the above copyright 1119cf921bSrearnsha * notice, this list of conditions and the following disclaimer. 1219cf921bSrearnsha * 2. Redistributions in binary form must reproduce the above copyright 1319cf921bSrearnsha * notice, this list of conditions and the following disclaimer in the 1419cf921bSrearnsha * documentation and/or other materials provided with the distribution. 1519cf921bSrearnsha * 3. The name of the company may not be used to endorse or promote 1619cf921bSrearnsha * products derived from this software without specific prior written 1719cf921bSrearnsha * permission. 1819cf921bSrearnsha * 1919cf921bSrearnsha * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 2019cf921bSrearnsha * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 2119cf921bSrearnsha * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2219cf921bSrearnsha * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 2319cf921bSrearnsha * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 2419cf921bSrearnsha * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 2519cf921bSrearnsha * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2619cf921bSrearnsha * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2719cf921bSrearnsha * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2819cf921bSrearnsha * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2919cf921bSrearnsha * SUCH DAMAGE. 3019cf921bSrearnsha */ 3119cf921bSrearnsha 32210924e6Sriastradh #ifndef _SYS_ARCH_EVBARM_DEV_PLCOMREG_H_ 33210924e6Sriastradh #define _SYS_ARCH_EVBARM_DEV_PLCOMREG_H_ 3419cf921bSrearnsha 3519cf921bSrearnsha #define PLCOM_FREQ 1843200 /* 16-bit baud rate divisor */ 3619cf921bSrearnsha #define PLCOM_TOLERANCE 30 /* baud rate tolerance, in 0.1% units */ 3719cf921bSrearnsha 3819cf921bSrearnsha /* control register */ 39b9703c3dSskrll #define PL011_CR_CTSEN 0x8000 /* CTS HW flow control enable */ 40b9703c3dSskrll #define PL011_CR_RTSEN 0x4000 /* RTS HW flow control enable */ 41b9703c3dSskrll #define PL011_CR_OUT2 0x2000 /* Complement of UART Out2 MSR */ 42b9703c3dSskrll #define PL011_CR_OUT1 0x1000 /* Complement of UART Out1 MSR */ 43b9703c3dSskrll #define PL011_CR_RTS 0x0800 /* Request to send */ 44b9703c3dSskrll #define PL011_CR_DTR 0x0400 /* Data transmit Ready */ 45b9703c3dSskrll #define PL011_CR_RXE 0x0200 /* Receive enable */ 46b9703c3dSskrll #define PL011_CR_TXE 0x0100 /* Transmit enable */ 47b9703c3dSskrll #define PL01X_CR_LBE 0x0080 /* Loopback enable */ 48b9703c3dSskrll #define PL010_CR_RTIE 0x0040 /* Receive timeout interrupt enable */ 49b9703c3dSskrll #define PL010_CR_TIE 0x0020 /* Transmit interrupt enable */ 50*6e3d02bbSandvar #define PL010_CR_RIE 0x0010 /* Receive interrupt enable */ 51b9703c3dSskrll #define PL010_CR_MSIE 0x0008 /* Modem status interrupt enable */ 52b9703c3dSskrll #define PL01X_CR_SIRLP 0x0004 /* IrDA SIR Low power mode */ 53b9703c3dSskrll #define PL01X_CR_SIREN 0x0002 /* SIR Enable */ 54b9703c3dSskrll #define PL01X_CR_UARTEN 0x0001 /* Uart enable */ 5519cf921bSrearnsha 5619cf921bSrearnsha /* interrupt identification register */ 57b9703c3dSskrll #define PL010_IIR_RTIS 0x08 58b9703c3dSskrll #define PL010_IIR_TIS 0x04 59b9703c3dSskrll #define PL010_IIR_RIS 0x02 60b9703c3dSskrll #define PL010_IIR_MIS 0x01 614c5a9380Sskrll #define PL010_IIR_IMASK \ 624c5a9380Sskrll (PL010_IIR_RTIS | PL010_IIR_TIS | PL010_IIR_RIS | PL010_IIR_MIS) 6319cf921bSrearnsha 6419cf921bSrearnsha /* line control register */ 65b9703c3dSskrll #define PL011_LCR_SPS 0x80 /* Stick parity select */ 66b9703c3dSskrll #define PL01X_LCR_WLEN 0x60 /* Mask of size bits */ 67b9703c3dSskrll #define PL01X_LCR_8BITS 0x60 /* 8 bits per serial word */ 68b9703c3dSskrll #define PL01X_LCR_7BITS 0x40 /* 7 bits */ 69b9703c3dSskrll #define PL01X_LCR_6BITS 0x20 /* 6 bits */ 70b9703c3dSskrll #define PL01X_LCR_5BITS 0x00 /* 5 bits */ 71b9703c3dSskrll #define PL01X_LCR_FEN 0x10 /* FIFO enable */ 72b9703c3dSskrll #define PL01X_LCR_STP2 0x08 /* 2 stop bits per serial word */ 73b9703c3dSskrll #define PL01X_LCR_EPS 0x04 /* Even parity select */ 74b9703c3dSskrll #define PL01X_LCR_PEN 0x02 /* Parity enable */ 75b9703c3dSskrll #define PL01X_LCR_PEVEN (PL01X_LCR_PEN | PL01X_LCR_EPS) 76b9703c3dSskrll #define PL01X_LCR_PODD PL01X_LCR_PEN 77b9703c3dSskrll #define PL01X_LCR_PNONE 0x00 /* No parity */ 78b9703c3dSskrll #define PL01X_LCR_BRK 0x01 /* Break Control */ 7919cf921bSrearnsha 8019cf921bSrearnsha /* modem control register */ 81b9703c3dSskrll #define PL01X_MCR_RTS 0x02 /* Request To Send */ 82b9703c3dSskrll #define PL01X_MCR_DTR 0x01 /* Data Terminal Ready */ 834c5a9380Sskrll #define PL011_MCR(mcr) ((mcr) << 10) /* MCR to CR bit values for PL011 */ 8419cf921bSrearnsha 8519cf921bSrearnsha /* receive status register */ 86b9703c3dSskrll #define PL01X_RSR_OE 0x08 /* Overrun Error */ 87b9703c3dSskrll #define PL01X_RSR_BE 0x04 /* Break */ 88b9703c3dSskrll #define PL01X_RSR_PE 0x02 /* Parity Error */ 89b9703c3dSskrll #define PL01X_RSR_FE 0x01 /* Framing Error */ 904c5a9380Sskrll #define PL01X_RSR_ERROR \ 914c5a9380Sskrll (PL01X_RSR_OE | PL01X_RSR_BE | PL01X_RSR_PE | PL01X_RSR_FE) 9219cf921bSrearnsha 9319cf921bSrearnsha /* flag register */ 944c5a9380Sskrll #define PL011_FR_RI 0x100 /* Ring Indicator */ 95b9703c3dSskrll #define PL01X_FR_TXFE 0x080 /* Transmit fifo empty */ 96e1ca6a87Smsaitoh #define PL01X_FR_RXFF 0x040 /* Receive fifo full */ 97b9703c3dSskrll #define PL01X_FR_TXFF 0x020 /* Transmit fifo full */ 98b9703c3dSskrll #define PL01X_FR_RXFE 0x010 /* Receive fifo empty */ 99b9703c3dSskrll #define PL01X_FR_BUSY 0x008 /* Uart Busy */ 100b9703c3dSskrll #define PL01X_FR_DCD 0x004 /* Data carrier detect */ 101b9703c3dSskrll #define PL01X_FR_DSR 0x002 /* Data set ready */ 102b9703c3dSskrll #define PL01X_FR_CTS 0x001 /* Clear to send */ 10319cf921bSrearnsha 10419cf921bSrearnsha /* modem status register */ 10519cf921bSrearnsha /* All deltas are from the last read of the MSR. */ 106b9703c3dSskrll #define PL01X_MSR_DCD PL01X_FR_DCD 107b9703c3dSskrll #define PL01X_MSR_DSR PL01X_FR_DSR 108b9703c3dSskrll #define PL01X_MSR_CTS PL01X_FR_CTS 1094c5a9380Sskrll #define PL011_MSR_RI PL011_FR_RI 110b9703c3dSskrll 111975e296aSskrll /* ifls */ 112820c39ceSmlelstv #define PL011_IFLS_MASK 0x001f 113975e296aSskrll #define PL011_IFLS_1EIGHTH 0 114975e296aSskrll #define PL011_IFLS_1QUARTER 1 115975e296aSskrll #define PL011_IFLS_1HALF 2 116975e296aSskrll #define PL011_IFLS_3QUARTERS 3 117975e296aSskrll #define PL011_IFLS_7EIGHTHS 4 118975e296aSskrll #define PL011_IFLS_RXIFLS(x) (((x) & 0x7) << 3) 119975e296aSskrll #define PL011_IFLS_TXIFLS(x) (((x) & 0x7) << 0) 120975e296aSskrll 121b9703c3dSskrll /* All interrupt status/clear registers */ 122b9703c3dSskrll #define PL011_INT_OE 0x400 123b9703c3dSskrll #define PL011_INT_BE 0x200 124b9703c3dSskrll #define PL011_INT_PE 0x100 125b9703c3dSskrll #define PL011_INT_FE 0x080 126b9703c3dSskrll #define PL011_INT_RT 0x040 127b9703c3dSskrll #define PL011_INT_TX 0x020 128b9703c3dSskrll #define PL011_INT_RX 0x010 129b9703c3dSskrll #define PL011_INT_DSR 0x008 130b9703c3dSskrll #define PL011_INT_DCD 0x004 131b9703c3dSskrll #define PL011_INT_CTS 0x002 132b9703c3dSskrll #define PL011_INT_RIR 0x001 1334c5a9380Sskrll #define PL011_INT_MSMASK \ 1344c5a9380Sskrll (PL011_INT_DSR | PL011_INT_DCD | PL011_INT_CTS | PL011_INT_RIR) 1354c5a9380Sskrll 1364c5a9380Sskrll #define PL011_INT_ALLMASK \ 1374c5a9380Sskrll (PL011_INT_RT | PL011_INT_TX | PL011_INT_RX | PL011_INT_MSMASK) 1384c5a9380Sskrll 139820c39ceSmlelstv /* PL011 HW revision bits in PID (0..3 combined little endian) */ 140820c39ceSmlelstv #define PL011_HWREV_MASK 0x00f00000 141820c39ceSmlelstv #define PL011_DESIGNER_MASK 0x000ff000 142820c39ceSmlelstv #define PL011_DESIGNER_ARM 0x00041000 143b9703c3dSskrll 144b9703c3dSskrll /* DMA control registers */ 145b9703c3dSskrll #define PL011_DMA_ONERR 0x4 146b9703c3dSskrll #define PL011_DMA_TXE 0x2 147b9703c3dSskrll #define PL011_DMA_RXE 0x1 14819cf921bSrearnsha 14919cf921bSrearnsha /* Register offsets */ 1504c5a9380Sskrll #define PL01XCOM_DR 0x00 /* Data Register */ 1514c5a9380Sskrll #define PL01XCOM_RSR 0x04 /* Receive status register */ 1524c5a9380Sskrll #define PL01XCOM_ECR 0x04 /* Error clear register - same as RSR */ 1534c5a9380Sskrll #define PL010COM_LCR 0x08 /* Line Control Register */ 1544c5a9380Sskrll #define PL010COM_DLBH 0x0c 1554c5a9380Sskrll #define PL010COM_DLBL 0x10 1564c5a9380Sskrll #define PL010COM_CR 0x14 1574c5a9380Sskrll #define PL01XCOM_FR 0x18 /* Flag Register */ 1584c5a9380Sskrll #define PL010COM_IIR 0x1c 1594c5a9380Sskrll #define PL010COM_ICR 0x1c 1604c5a9380Sskrll #define PL01XCOM_ILPR 0x20 /* IrDA low-power control register */ 1614c5a9380Sskrll #define PL011COM_IBRD 0x24 /* Integer baud rate divisor register */ 1624c5a9380Sskrll #define PL011COM_FBRD 0x28 /* Fractional baud rate divisor register */ 1634c5a9380Sskrll #define PL011COM_LCRH 0x2c /* Line control register */ 1644c5a9380Sskrll #define PL011COM_CR 0x30 /* Control register */ 1654c5a9380Sskrll #define PL011COM_IFLS 0x34 /* Interrupt FIFO level select register */ 1664c5a9380Sskrll #define PL011COM_IMSC 0x38 /* Interrupt mask set/clear register */ 1674c5a9380Sskrll #define PL011COM_RIS 0x3c /* Raw interrupt status register */ 1684c5a9380Sskrll #define PL011COM_MIS 0x40 /* Masked interrupt status register */ 1694c5a9380Sskrll #define PL011COM_ICR 0x44 /* Interrupt clear register register */ 1704c5a9380Sskrll #define PL011COM_DMACR 0x48 /* DMA control register register */ 171820c39ceSmlelstv #define PL011COM_PID0 0xfe0 /* Peripheral ID register 0 */ 172820c39ceSmlelstv #define PL011COM_PID1 0xfe4 /* Peripheral ID register 1 */ 173820c39ceSmlelstv #define PL011COM_PID2 0xfe8 /* Peripheral ID register 2 */ 174820c39ceSmlelstv #define PL011COM_PID3 0xfec /* Peripheral ID register 3 */ 17519cf921bSrearnsha 1764c5a9380Sskrll #define PL010COM_UART_SIZE 0x100 1774c5a9380Sskrll #define PL011COM_UART_SIZE 0x1000 178210924e6Sriastradh 179210924e6Sriastradh #endif /* _SYS_ARCH_EVBARM_DEV_PLCOMREG_H_ */ 180