1139749Simp/*- 2119815Smarcel * Copyright (c) 2003 Marcel Moolenaar 3119815Smarcel * All rights reserved. 4119815Smarcel * 5119815Smarcel * Redistribution and use in source and binary forms, with or without 6119815Smarcel * modification, are permitted provided that the following conditions 7119815Smarcel * are met: 8119815Smarcel * 9119815Smarcel * 1. Redistributions of source code must retain the above copyright 10119815Smarcel * notice, this list of conditions and the following disclaimer. 11119815Smarcel * 2. Redistributions in binary form must reproduce the above copyright 12119815Smarcel * notice, this list of conditions and the following disclaimer in the 13119815Smarcel * documentation and/or other materials provided with the distribution. 14119815Smarcel * 15119815Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16119815Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17119815Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18119815Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19119815Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20119815Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21119815Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22119815Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23119815Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24119815Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25119815Smarcel * 26119815Smarcel * $FreeBSD: stable/11/sys/dev/uart/uart.h 340145 2018-11-04 23:28:56Z mmacy $ 27119815Smarcel */ 28119815Smarcel 29119815Smarcel#ifndef _DEV_UART_H_ 30119815Smarcel#define _DEV_UART_H_ 31119815Smarcel 32119815Smarcel/* 33119815Smarcel * Bus access structure. This structure holds the minimum information needed 34119815Smarcel * to access the UART. The rclk field, although not important to actually 35119815Smarcel * access the UART, is important for baudrate programming, delay loops and 36119815Smarcel * other timing related computations. 37119815Smarcel */ 38119815Smarcelstruct uart_bas { 39119815Smarcel bus_space_tag_t bst; 40119815Smarcel bus_space_handle_t bsh; 41120452Smarcel u_int chan; 42120452Smarcel u_int rclk; 43119815Smarcel u_int regshft; 44340145Smmacy u_int regiowidth; 45340145Smmacy u_int busy_detect; 46119815Smarcel}; 47119815Smarcel 48119815Smarcel#define uart_regofs(bas, reg) ((reg) << (bas)->regshft) 49340145Smmacy#define uart_regiowidth(bas) ((bas)->regiowidth) 50119815Smarcel 51119815Smarcel#define uart_getreg(bas, reg) \ 52119815Smarcel bus_space_read_1((bas)->bst, (bas)->bsh, uart_regofs(bas, reg)) 53119815Smarcel#define uart_setreg(bas, reg, value) \ 54119815Smarcel bus_space_write_1((bas)->bst, (bas)->bsh, uart_regofs(bas, reg), value) 55119815Smarcel 56119815Smarcel/* 57119815Smarcel * XXX we don't know the length of the bus space address range in use by 58119815Smarcel * the UART. Since barriers don't use the length field currently, we put 59119815Smarcel * a zero there for now. 60119815Smarcel */ 61119815Smarcel#define uart_barrier(bas) \ 62119815Smarcel bus_space_barrier((bas)->bst, (bas)->bsh, 0, 0, \ 63119815Smarcel BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE) 64119815Smarcel 65119815Smarcel/* 66168281Smarcel * UART device classes. 67168281Smarcel */ 68168281Smarcelstruct uart_class; 69168281Smarcel 70168281Smarcelextern struct uart_class uart_ns8250_class __attribute__((weak)); 71176771Srajextern struct uart_class uart_quicc_class __attribute__((weak)); 72252394Srayextern struct uart_class uart_s3c2410_class __attribute__((weak)); 73168281Smarcelextern struct uart_class uart_sab82532_class __attribute__((weak)); 74206451Smariusextern struct uart_class uart_sbbc_class __attribute__((weak)); 75168281Smarcelextern struct uart_class uart_z8530_class __attribute__((weak)); 76168281Smarcel 77182159Snyan#ifdef PC98 78182159Snyanstruct uart_class *uart_pc98_getdev(u_long port); 79182159Snyan#endif 80182159Snyan 81168281Smarcel/* 82119815Smarcel * Device flags. 83119815Smarcel */ 84119815Smarcel#define UART_FLAGS_CONSOLE(f) ((f) & 0x10) 85119815Smarcel#define UART_FLAGS_DBGPORT(f) ((f) & 0x80) 86177117Ssam#define UART_FLAGS_FCR_RX_LOW(f) ((f) & 0x100) 87177117Ssam#define UART_FLAGS_FCR_RX_MEDL(f) ((f) & 0x200) 88177117Ssam#define UART_FLAGS_FCR_RX_MEDH(f) ((f) & 0x400) 89177117Ssam#define UART_FLAGS_FCR_RX_HIGH(f) ((f) & 0x800) 90119815Smarcel 91119815Smarcel/* 92119815Smarcel * Data parity values (magical numbers related to ns8250). 93119815Smarcel */ 94119815Smarcel#define UART_PARITY_NONE 0 95119815Smarcel#define UART_PARITY_ODD 1 96119815Smarcel#define UART_PARITY_EVEN 3 97119815Smarcel#define UART_PARITY_MARK 5 98119815Smarcel#define UART_PARITY_SPACE 7 99119815Smarcel 100119815Smarcel#endif /* _DEV_UART_H_ */ 101