18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 28c2ecf20Sopenharmony_ci/************************************************************************ 38c2ecf20Sopenharmony_ci * Copyright 2003 Digi International (www.digi.com) 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2004 IBM Corporation. All rights reserved. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Contact Information: 88c2ecf20Sopenharmony_ci * Scott H Kilau <Scott_Kilau@digi.com> 98c2ecf20Sopenharmony_ci * Wendy Xiong <wendyx@us.ibm.com> 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci ***********************************************************************/ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef __JSM_DRIVER_H 148c2ecf20Sopenharmony_ci#define __JSM_DRIVER_H 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/kernel.h> 178c2ecf20Sopenharmony_ci#include <linux/types.h> /* To pick up the varions Linux types */ 188c2ecf20Sopenharmony_ci#include <linux/tty.h> 198c2ecf20Sopenharmony_ci#include <linux/serial_core.h> 208c2ecf20Sopenharmony_ci#include <linux/device.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * Debugging levels can be set using debug insmod variable 248c2ecf20Sopenharmony_ci * They can also be compiled out completely. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_cienum { 278c2ecf20Sopenharmony_ci DBG_INIT = 0x01, 288c2ecf20Sopenharmony_ci DBG_BASIC = 0x02, 298c2ecf20Sopenharmony_ci DBG_CORE = 0x04, 308c2ecf20Sopenharmony_ci DBG_OPEN = 0x08, 318c2ecf20Sopenharmony_ci DBG_CLOSE = 0x10, 328c2ecf20Sopenharmony_ci DBG_READ = 0x20, 338c2ecf20Sopenharmony_ci DBG_WRITE = 0x40, 348c2ecf20Sopenharmony_ci DBG_IOCTL = 0x80, 358c2ecf20Sopenharmony_ci DBG_PROC = 0x100, 368c2ecf20Sopenharmony_ci DBG_PARAM = 0x200, 378c2ecf20Sopenharmony_ci DBG_PSCAN = 0x400, 388c2ecf20Sopenharmony_ci DBG_EVENT = 0x800, 398c2ecf20Sopenharmony_ci DBG_DRAIN = 0x1000, 408c2ecf20Sopenharmony_ci DBG_MSIGS = 0x2000, 418c2ecf20Sopenharmony_ci DBG_MGMT = 0x4000, 428c2ecf20Sopenharmony_ci DBG_INTR = 0x8000, 438c2ecf20Sopenharmony_ci DBG_CARR = 0x10000, 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define jsm_dbg(nlevel, pdev, fmt, ...) \ 478c2ecf20Sopenharmony_cido { \ 488c2ecf20Sopenharmony_ci if (DBG_##nlevel & jsm_debug) \ 498c2ecf20Sopenharmony_ci dev_dbg(pdev->dev, fmt, ##__VA_ARGS__); \ 508c2ecf20Sopenharmony_ci} while (0) 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define MAXLINES 256 538c2ecf20Sopenharmony_ci#define MAXPORTS 8 548c2ecf20Sopenharmony_ci#define MAX_STOPS_SENT 5 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* Board ids */ 578c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_CLASSIC_4 0x0028 588c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_CLASSIC_8 0x0029 598c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_CLASSIC_4_422 0x00D0 608c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_CLASSIC_8_422 0x00D1 618c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NEO_4 0x00B0 628c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NEO_1_422 0x00CC 638c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NEO_1_422_485 0x00CD 648c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_NEO_2_422_485 0x00CE 658c2ecf20Sopenharmony_ci#define PCIE_DEVICE_ID_NEO_8 0x00F0 668c2ecf20Sopenharmony_ci#define PCIE_DEVICE_ID_NEO_4 0x00F1 678c2ecf20Sopenharmony_ci#define PCIE_DEVICE_ID_NEO_4RJ45 0x00F2 688c2ecf20Sopenharmony_ci#define PCIE_DEVICE_ID_NEO_8RJ45 0x00F3 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* Board type definitions */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define T_NEO 0000 738c2ecf20Sopenharmony_ci#define T_CLASSIC 0001 748c2ecf20Sopenharmony_ci#define T_PCIBUS 0400 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* Board State Definitions */ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define BD_RUNNING 0x0 798c2ecf20Sopenharmony_ci#define BD_REASON 0x7f 808c2ecf20Sopenharmony_ci#define BD_NOTFOUND 0x1 818c2ecf20Sopenharmony_ci#define BD_NOIOPORT 0x2 828c2ecf20Sopenharmony_ci#define BD_NOMEM 0x3 838c2ecf20Sopenharmony_ci#define BD_NOBIOS 0x4 848c2ecf20Sopenharmony_ci#define BD_NOFEP 0x5 858c2ecf20Sopenharmony_ci#define BD_FAILED 0x6 868c2ecf20Sopenharmony_ci#define BD_ALLOCATED 0x7 878c2ecf20Sopenharmony_ci#define BD_TRIBOOT 0x8 888c2ecf20Sopenharmony_ci#define BD_BADKME 0x80 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* 4 extra for alignment play space */ 928c2ecf20Sopenharmony_ci#define WRITEBUFLEN ((4096) + 4) 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define JSM_VERSION "jsm: 1.2-1-INKERNEL" 958c2ecf20Sopenharmony_ci#define JSM_PARTNUM "40002438_A-INKERNEL" 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistruct jsm_board; 988c2ecf20Sopenharmony_cistruct jsm_channel; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci/************************************************************************ 1018c2ecf20Sopenharmony_ci * Per board operations structure * 1028c2ecf20Sopenharmony_ci ************************************************************************/ 1038c2ecf20Sopenharmony_cistruct board_ops { 1048c2ecf20Sopenharmony_ci irq_handler_t intr; 1058c2ecf20Sopenharmony_ci void (*uart_init)(struct jsm_channel *ch); 1068c2ecf20Sopenharmony_ci void (*uart_off)(struct jsm_channel *ch); 1078c2ecf20Sopenharmony_ci void (*param)(struct jsm_channel *ch); 1088c2ecf20Sopenharmony_ci void (*assert_modem_signals)(struct jsm_channel *ch); 1098c2ecf20Sopenharmony_ci void (*flush_uart_write)(struct jsm_channel *ch); 1108c2ecf20Sopenharmony_ci void (*flush_uart_read)(struct jsm_channel *ch); 1118c2ecf20Sopenharmony_ci void (*disable_receiver)(struct jsm_channel *ch); 1128c2ecf20Sopenharmony_ci void (*enable_receiver)(struct jsm_channel *ch); 1138c2ecf20Sopenharmony_ci void (*send_break)(struct jsm_channel *ch); 1148c2ecf20Sopenharmony_ci void (*clear_break)(struct jsm_channel *ch); 1158c2ecf20Sopenharmony_ci void (*send_start_character)(struct jsm_channel *ch); 1168c2ecf20Sopenharmony_ci void (*send_stop_character)(struct jsm_channel *ch); 1178c2ecf20Sopenharmony_ci void (*copy_data_from_queue_to_uart)(struct jsm_channel *ch); 1188c2ecf20Sopenharmony_ci u32 (*get_uart_bytes_left)(struct jsm_channel *ch); 1198c2ecf20Sopenharmony_ci void (*send_immediate_char)(struct jsm_channel *ch, unsigned char); 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci/* 1248c2ecf20Sopenharmony_ci * Per-board information 1258c2ecf20Sopenharmony_ci */ 1268c2ecf20Sopenharmony_cistruct jsm_board 1278c2ecf20Sopenharmony_ci{ 1288c2ecf20Sopenharmony_ci int boardnum; /* Board number: 0-32 */ 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci int type; /* Type of board */ 1318c2ecf20Sopenharmony_ci u8 rev; /* PCI revision ID */ 1328c2ecf20Sopenharmony_ci struct pci_dev *pci_dev; 1338c2ecf20Sopenharmony_ci u32 maxports; /* MAX ports this board can handle */ 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci spinlock_t bd_intr_lock; /* Used to protect the poller tasklet and 1368c2ecf20Sopenharmony_ci * the interrupt routine from each other. 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci u32 nasync; /* Number of ports on card */ 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci u32 irq; /* Interrupt request number */ 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci u64 membase; /* Start of base memory of the card */ 1448c2ecf20Sopenharmony_ci u64 membase_end; /* End of base memory of the card */ 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci u8 __iomem *re_map_membase;/* Remapped memory of the card */ 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci u64 iobase; /* Start of io base of the card */ 1498c2ecf20Sopenharmony_ci u64 iobase_end; /* End of io base of the card */ 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci u32 bd_uart_offset; /* Space between each UART */ 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci struct jsm_channel *channels[MAXPORTS]; /* array of pointers to our channels. */ 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci u32 bd_dividend; /* Board/UARTs specific dividend */ 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci struct board_ops *bd_ops; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci struct list_head jsm_board_entry; 1608c2ecf20Sopenharmony_ci}; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci/************************************************************************ 1638c2ecf20Sopenharmony_ci * Device flag definitions for ch_flags. 1648c2ecf20Sopenharmony_ci ************************************************************************/ 1658c2ecf20Sopenharmony_ci#define CH_PRON 0x0001 /* Printer on string */ 1668c2ecf20Sopenharmony_ci#define CH_STOP 0x0002 /* Output is stopped */ 1678c2ecf20Sopenharmony_ci#define CH_STOPI 0x0004 /* Input is stopped */ 1688c2ecf20Sopenharmony_ci#define CH_CD 0x0008 /* Carrier is present */ 1698c2ecf20Sopenharmony_ci#define CH_FCAR 0x0010 /* Carrier forced on */ 1708c2ecf20Sopenharmony_ci#define CH_HANGUP 0x0020 /* Hangup received */ 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci#define CH_RECEIVER_OFF 0x0040 /* Receiver is off */ 1738c2ecf20Sopenharmony_ci#define CH_OPENING 0x0080 /* Port in fragile open state */ 1748c2ecf20Sopenharmony_ci#define CH_CLOSING 0x0100 /* Port in fragile close state */ 1758c2ecf20Sopenharmony_ci#define CH_FIFO_ENABLED 0x0200 /* Port has FIFOs enabled */ 1768c2ecf20Sopenharmony_ci#define CH_TX_FIFO_EMPTY 0x0400 /* TX Fifo is completely empty */ 1778c2ecf20Sopenharmony_ci#define CH_TX_FIFO_LWM 0x0800 /* TX Fifo is below Low Water */ 1788c2ecf20Sopenharmony_ci#define CH_BREAK_SENDING 0x1000 /* Break is being sent */ 1798c2ecf20Sopenharmony_ci#define CH_LOOPBACK 0x2000 /* Channel is in lookback mode */ 1808c2ecf20Sopenharmony_ci#define CH_BAUD0 0x08000 /* Used for checking B0 transitions */ 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci/* Our Read/Error queue sizes */ 1838c2ecf20Sopenharmony_ci#define RQUEUEMASK 0x1FFF /* 8 K - 1 */ 1848c2ecf20Sopenharmony_ci#define EQUEUEMASK 0x1FFF /* 8 K - 1 */ 1858c2ecf20Sopenharmony_ci#define RQUEUESIZE (RQUEUEMASK + 1) 1868c2ecf20Sopenharmony_ci#define EQUEUESIZE RQUEUESIZE 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci/************************************************************************ 1908c2ecf20Sopenharmony_ci * Channel information structure. 1918c2ecf20Sopenharmony_ci ************************************************************************/ 1928c2ecf20Sopenharmony_cistruct jsm_channel { 1938c2ecf20Sopenharmony_ci struct uart_port uart_port; 1948c2ecf20Sopenharmony_ci struct jsm_board *ch_bd; /* Board structure pointer */ 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci spinlock_t ch_lock; /* provide for serialization */ 1978c2ecf20Sopenharmony_ci wait_queue_head_t ch_flags_wait; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci u32 ch_portnum; /* Port number, 0 offset. */ 2008c2ecf20Sopenharmony_ci u32 ch_open_count; /* open count */ 2018c2ecf20Sopenharmony_ci u32 ch_flags; /* Channel flags */ 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci u64 ch_close_delay; /* How long we should drop RTS/DTR for */ 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci tcflag_t ch_c_iflag; /* channel iflags */ 2068c2ecf20Sopenharmony_ci tcflag_t ch_c_cflag; /* channel cflags */ 2078c2ecf20Sopenharmony_ci tcflag_t ch_c_oflag; /* channel oflags */ 2088c2ecf20Sopenharmony_ci tcflag_t ch_c_lflag; /* channel lflags */ 2098c2ecf20Sopenharmony_ci u8 ch_stopc; /* Stop character */ 2108c2ecf20Sopenharmony_ci u8 ch_startc; /* Start character */ 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci u8 ch_mostat; /* FEP output modem status */ 2138c2ecf20Sopenharmony_ci u8 ch_mistat; /* FEP input modem status */ 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci /* Pointers to the "mapped" UART structs */ 2168c2ecf20Sopenharmony_ci struct neo_uart_struct __iomem *ch_neo_uart; /* NEO card */ 2178c2ecf20Sopenharmony_ci struct cls_uart_struct __iomem *ch_cls_uart; /* Classic card */ 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci u8 ch_cached_lsr; /* Cached value of the LSR register */ 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci u8 *ch_rqueue; /* Our read queue buffer - malloc'ed */ 2228c2ecf20Sopenharmony_ci u16 ch_r_head; /* Head location of the read queue */ 2238c2ecf20Sopenharmony_ci u16 ch_r_tail; /* Tail location of the read queue */ 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci u8 *ch_equeue; /* Our error queue buffer - malloc'ed */ 2268c2ecf20Sopenharmony_ci u16 ch_e_head; /* Head location of the error queue */ 2278c2ecf20Sopenharmony_ci u16 ch_e_tail; /* Tail location of the error queue */ 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci u64 ch_rxcount; /* total of data received so far */ 2308c2ecf20Sopenharmony_ci u64 ch_txcount; /* total of data transmitted so far */ 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci u8 ch_r_tlevel; /* Receive Trigger level */ 2338c2ecf20Sopenharmony_ci u8 ch_t_tlevel; /* Transmit Trigger level */ 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci u8 ch_r_watermark; /* Receive Watermark */ 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci u32 ch_stops_sent; /* How many times I have sent a stop character 2398c2ecf20Sopenharmony_ci * to try to stop the other guy sending. 2408c2ecf20Sopenharmony_ci */ 2418c2ecf20Sopenharmony_ci u64 ch_err_parity; /* Count of parity errors on channel */ 2428c2ecf20Sopenharmony_ci u64 ch_err_frame; /* Count of framing errors on channel */ 2438c2ecf20Sopenharmony_ci u64 ch_err_break; /* Count of breaks on channel */ 2448c2ecf20Sopenharmony_ci u64 ch_err_overrun; /* Count of overruns on channel */ 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci u64 ch_xon_sends; /* Count of xons transmitted */ 2478c2ecf20Sopenharmony_ci u64 ch_xoff_sends; /* Count of xoffs transmitted */ 2488c2ecf20Sopenharmony_ci}; 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci/************************************************************************ 2518c2ecf20Sopenharmony_ci * Per channel/port Classic UART structures * 2528c2ecf20Sopenharmony_ci ************************************************************************ 2538c2ecf20Sopenharmony_ci * Base Structure Entries Usage Meanings to Host * 2548c2ecf20Sopenharmony_ci * * 2558c2ecf20Sopenharmony_ci * W = read write R = read only * 2568c2ecf20Sopenharmony_ci * U = Unused. * 2578c2ecf20Sopenharmony_ci ************************************************************************/ 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_cistruct cls_uart_struct { 2608c2ecf20Sopenharmony_ci u8 txrx; /* WR RHR/THR - Holding Reg */ 2618c2ecf20Sopenharmony_ci u8 ier; /* WR IER - Interrupt Enable Reg */ 2628c2ecf20Sopenharmony_ci u8 isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg*/ 2638c2ecf20Sopenharmony_ci u8 lcr; /* WR LCR - Line Control Reg */ 2648c2ecf20Sopenharmony_ci u8 mcr; /* WR MCR - Modem Control Reg */ 2658c2ecf20Sopenharmony_ci u8 lsr; /* WR LSR - Line Status Reg */ 2668c2ecf20Sopenharmony_ci u8 msr; /* WR MSR - Modem Status Reg */ 2678c2ecf20Sopenharmony_ci u8 spr; /* WR SPR - Scratch Pad Reg */ 2688c2ecf20Sopenharmony_ci}; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci/* Where to read the interrupt register (8bits) */ 2718c2ecf20Sopenharmony_ci#define UART_CLASSIC_POLL_ADDR_OFFSET 0x40 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci#define UART_EXAR654_ENHANCED_REGISTER_SET 0xBF 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci#define UART_16654_FCR_TXTRIGGER_8 0x0 2768c2ecf20Sopenharmony_ci#define UART_16654_FCR_TXTRIGGER_16 0x10 2778c2ecf20Sopenharmony_ci#define UART_16654_FCR_TXTRIGGER_32 0x20 2788c2ecf20Sopenharmony_ci#define UART_16654_FCR_TXTRIGGER_56 0x30 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci#define UART_16654_FCR_RXTRIGGER_8 0x0 2818c2ecf20Sopenharmony_ci#define UART_16654_FCR_RXTRIGGER_16 0x40 2828c2ecf20Sopenharmony_ci#define UART_16654_FCR_RXTRIGGER_56 0x80 2838c2ecf20Sopenharmony_ci#define UART_16654_FCR_RXTRIGGER_60 0xC0 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci#define UART_IIR_CTSRTS 0x20 /* Received CTS/RTS change of state */ 2868c2ecf20Sopenharmony_ci#define UART_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */ 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci/* 2898c2ecf20Sopenharmony_ci * These are the EXTENDED definitions for the Exar 654's Interrupt 2908c2ecf20Sopenharmony_ci * Enable Register. 2918c2ecf20Sopenharmony_ci */ 2928c2ecf20Sopenharmony_ci#define UART_EXAR654_EFR_ECB 0x10 /* Enhanced control bit */ 2938c2ecf20Sopenharmony_ci#define UART_EXAR654_EFR_IXON 0x2 /* Receiver compares Xon1/Xoff1 */ 2948c2ecf20Sopenharmony_ci#define UART_EXAR654_EFR_IXOFF 0x8 /* Transmit Xon1/Xoff1 */ 2958c2ecf20Sopenharmony_ci#define UART_EXAR654_EFR_RTSDTR 0x40 /* Auto RTS/DTR Flow Control Enable */ 2968c2ecf20Sopenharmony_ci#define UART_EXAR654_EFR_CTSDSR 0x80 /* Auto CTS/DSR Flow COntrol Enable */ 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci#define UART_EXAR654_XOFF_DETECT 0x1 /* Indicates whether chip saw an incoming XOFF char */ 2998c2ecf20Sopenharmony_ci#define UART_EXAR654_XON_DETECT 0x2 /* Indicates whether chip saw an incoming XON char */ 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci#define UART_EXAR654_IER_XOFF 0x20 /* Xoff Interrupt Enable */ 3028c2ecf20Sopenharmony_ci#define UART_EXAR654_IER_RTSDTR 0x40 /* Output Interrupt Enable */ 3038c2ecf20Sopenharmony_ci#define UART_EXAR654_IER_CTSDSR 0x80 /* Input Interrupt Enable */ 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci/************************************************************************ 3068c2ecf20Sopenharmony_ci * Per channel/port NEO UART structure * 3078c2ecf20Sopenharmony_ci ************************************************************************ 3088c2ecf20Sopenharmony_ci * Base Structure Entries Usage Meanings to Host * 3098c2ecf20Sopenharmony_ci * * 3108c2ecf20Sopenharmony_ci * W = read write R = read only * 3118c2ecf20Sopenharmony_ci * U = Unused. * 3128c2ecf20Sopenharmony_ci ************************************************************************/ 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_cistruct neo_uart_struct { 3158c2ecf20Sopenharmony_ci u8 txrx; /* WR RHR/THR - Holding Reg */ 3168c2ecf20Sopenharmony_ci u8 ier; /* WR IER - Interrupt Enable Reg */ 3178c2ecf20Sopenharmony_ci u8 isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */ 3188c2ecf20Sopenharmony_ci u8 lcr; /* WR LCR - Line Control Reg */ 3198c2ecf20Sopenharmony_ci u8 mcr; /* WR MCR - Modem Control Reg */ 3208c2ecf20Sopenharmony_ci u8 lsr; /* WR LSR - Line Status Reg */ 3218c2ecf20Sopenharmony_ci u8 msr; /* WR MSR - Modem Status Reg */ 3228c2ecf20Sopenharmony_ci u8 spr; /* WR SPR - Scratch Pad Reg */ 3238c2ecf20Sopenharmony_ci u8 fctr; /* WR FCTR - Feature Control Reg */ 3248c2ecf20Sopenharmony_ci u8 efr; /* WR EFR - Enhanced Function Reg */ 3258c2ecf20Sopenharmony_ci u8 tfifo; /* WR TXCNT/TXTRG - Transmit FIFO Reg */ 3268c2ecf20Sopenharmony_ci u8 rfifo; /* WR RXCNT/RXTRG - Receive FIFO Reg */ 3278c2ecf20Sopenharmony_ci u8 xoffchar1; /* WR XOFF 1 - XOff Character 1 Reg */ 3288c2ecf20Sopenharmony_ci u8 xoffchar2; /* WR XOFF 2 - XOff Character 2 Reg */ 3298c2ecf20Sopenharmony_ci u8 xonchar1; /* WR XON 1 - Xon Character 1 Reg */ 3308c2ecf20Sopenharmony_ci u8 xonchar2; /* WR XON 2 - XOn Character 2 Reg */ 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci u8 reserved1[0x2ff - 0x200]; /* U Reserved by Exar */ 3338c2ecf20Sopenharmony_ci u8 txrxburst[64]; /* RW 64 bytes of RX/TX FIFO Data */ 3348c2ecf20Sopenharmony_ci u8 reserved2[0x37f - 0x340]; /* U Reserved by Exar */ 3358c2ecf20Sopenharmony_ci u8 rxburst_with_errors[64]; /* R 64 bytes of RX FIFO Data + LSR */ 3368c2ecf20Sopenharmony_ci}; 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci/* Where to read the extended interrupt register (32bits instead of 8bits) */ 3398c2ecf20Sopenharmony_ci#define UART_17158_POLL_ADDR_OFFSET 0x80 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci/* 3428c2ecf20Sopenharmony_ci * These are the redefinitions for the FCTR on the XR17C158, since 3438c2ecf20Sopenharmony_ci * Exar made them different than their earlier design. (XR16C854) 3448c2ecf20Sopenharmony_ci */ 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci/* These are only applicable when table D is selected */ 3478c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_NODELAY 0x00 3488c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_4DELAY 0x01 3498c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_6DELAY 0x02 3508c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_8DELAY 0x03 3518c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_12DELAY 0x12 3528c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_16DELAY 0x05 3538c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_20DELAY 0x13 3548c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_24DELAY 0x06 3558c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_28DELAY 0x14 3568c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_32DELAY 0x07 3578c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_36DELAY 0x16 3588c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_40DELAY 0x08 3598c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_44DELAY 0x09 3608c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_48DELAY 0x10 3618c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_52DELAY 0x11 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RTS_IRDA 0x10 3648c2ecf20Sopenharmony_ci#define UART_17158_FCTR_RS485 0x20 3658c2ecf20Sopenharmony_ci#define UART_17158_FCTR_TRGA 0x00 3668c2ecf20Sopenharmony_ci#define UART_17158_FCTR_TRGB 0x40 3678c2ecf20Sopenharmony_ci#define UART_17158_FCTR_TRGC 0x80 3688c2ecf20Sopenharmony_ci#define UART_17158_FCTR_TRGD 0xC0 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci/* 17158 trigger table selects.. */ 3718c2ecf20Sopenharmony_ci#define UART_17158_FCTR_BIT6 0x40 3728c2ecf20Sopenharmony_ci#define UART_17158_FCTR_BIT7 0x80 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci/* 17158 TX/RX memmapped buffer offsets */ 3758c2ecf20Sopenharmony_ci#define UART_17158_RX_FIFOSIZE 64 3768c2ecf20Sopenharmony_ci#define UART_17158_TX_FIFOSIZE 64 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_ci/* 17158 Extended IIR's */ 3798c2ecf20Sopenharmony_ci#define UART_17158_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */ 3808c2ecf20Sopenharmony_ci#define UART_17158_IIR_XONXOFF 0x10 /* Received an XON/XOFF char */ 3818c2ecf20Sopenharmony_ci#define UART_17158_IIR_HWFLOW_STATE_CHANGE 0x20 /* CTS/DSR or RTS/DTR state change */ 3828c2ecf20Sopenharmony_ci#define UART_17158_IIR_FIFO_ENABLED 0xC0 /* 16550 FIFOs are Enabled */ 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci/* 3858c2ecf20Sopenharmony_ci * These are the extended interrupts that get sent 3868c2ecf20Sopenharmony_ci * back to us from the UART's 32bit interrupt register 3878c2ecf20Sopenharmony_ci */ 3888c2ecf20Sopenharmony_ci#define UART_17158_RX_LINE_STATUS 0x1 /* RX Ready */ 3898c2ecf20Sopenharmony_ci#define UART_17158_RXRDY_TIMEOUT 0x2 /* RX Ready Timeout */ 3908c2ecf20Sopenharmony_ci#define UART_17158_TXRDY 0x3 /* TX Ready */ 3918c2ecf20Sopenharmony_ci#define UART_17158_MSR 0x4 /* Modem State Change */ 3928c2ecf20Sopenharmony_ci#define UART_17158_TX_AND_FIFO_CLR 0x40 /* Transmitter Holding Reg Empty */ 3938c2ecf20Sopenharmony_ci#define UART_17158_RX_FIFO_DATA_ERROR 0x80 /* UART detected an RX FIFO Data error */ 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ci/* 3968c2ecf20Sopenharmony_ci * These are the EXTENDED definitions for the 17C158's Interrupt 3978c2ecf20Sopenharmony_ci * Enable Register. 3988c2ecf20Sopenharmony_ci */ 3998c2ecf20Sopenharmony_ci#define UART_17158_EFR_ECB 0x10 /* Enhanced control bit */ 4008c2ecf20Sopenharmony_ci#define UART_17158_EFR_IXON 0x2 /* Receiver compares Xon1/Xoff1 */ 4018c2ecf20Sopenharmony_ci#define UART_17158_EFR_IXOFF 0x8 /* Transmit Xon1/Xoff1 */ 4028c2ecf20Sopenharmony_ci#define UART_17158_EFR_RTSDTR 0x40 /* Auto RTS/DTR Flow Control Enable */ 4038c2ecf20Sopenharmony_ci#define UART_17158_EFR_CTSDSR 0x80 /* Auto CTS/DSR Flow COntrol Enable */ 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ci#define UART_17158_XOFF_DETECT 0x1 /* Indicates whether chip saw an incoming XOFF char */ 4068c2ecf20Sopenharmony_ci#define UART_17158_XON_DETECT 0x2 /* Indicates whether chip saw an incoming XON char */ 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci#define UART_17158_IER_RSVD1 0x10 /* Reserved by Exar */ 4098c2ecf20Sopenharmony_ci#define UART_17158_IER_XOFF 0x20 /* Xoff Interrupt Enable */ 4108c2ecf20Sopenharmony_ci#define UART_17158_IER_RTSDTR 0x40 /* Output Interrupt Enable */ 4118c2ecf20Sopenharmony_ci#define UART_17158_IER_CTSDSR 0x80 /* Input Interrupt Enable */ 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci#define PCI_DEVICE_NEO_2DB9_PCI_NAME "Neo 2 - DB9 Universal PCI" 4148c2ecf20Sopenharmony_ci#define PCI_DEVICE_NEO_2DB9PRI_PCI_NAME "Neo 2 - DB9 Universal PCI - Powered Ring Indicator" 4158c2ecf20Sopenharmony_ci#define PCI_DEVICE_NEO_2RJ45_PCI_NAME "Neo 2 - RJ45 Universal PCI" 4168c2ecf20Sopenharmony_ci#define PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME "Neo 2 - RJ45 Universal PCI - Powered Ring Indicator" 4178c2ecf20Sopenharmony_ci#define PCIE_DEVICE_NEO_IBM_PCI_NAME "Neo 4 - PCI Express - IBM" 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci/* 4208c2ecf20Sopenharmony_ci * Our Global Variables. 4218c2ecf20Sopenharmony_ci */ 4228c2ecf20Sopenharmony_ciextern struct uart_driver jsm_uart_driver; 4238c2ecf20Sopenharmony_ciextern struct board_ops jsm_neo_ops; 4248c2ecf20Sopenharmony_ciextern struct board_ops jsm_cls_ops; 4258c2ecf20Sopenharmony_ciextern int jsm_debug; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci/************************************************************************* 4288c2ecf20Sopenharmony_ci * 4298c2ecf20Sopenharmony_ci * Prototypes for non-static functions used in more than one module 4308c2ecf20Sopenharmony_ci * 4318c2ecf20Sopenharmony_ci *************************************************************************/ 4328c2ecf20Sopenharmony_ciint jsm_tty_init(struct jsm_board *); 4338c2ecf20Sopenharmony_ciint jsm_uart_port_init(struct jsm_board *); 4348c2ecf20Sopenharmony_ciint jsm_remove_uart_port(struct jsm_board *); 4358c2ecf20Sopenharmony_civoid jsm_input(struct jsm_channel *ch); 4368c2ecf20Sopenharmony_civoid jsm_check_queue_flow_control(struct jsm_channel *ch); 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci#endif 439