// SPDX-License-Identifier: GPL-2.0
/*
* Serial driver for the amiga builtin port.
*
* This code was created by taking serial.c version 4.30 from kernel
* release 2.3.22, replacing all hardware related stuff with the
* corresponding amiga hardware actions, and removing all irrelevant
* code. As a consequence, it uses many of the constants and names
* associated with the registers and bits of 16550 compatible UARTS -
* but only to keep track of status, etc in the state variables. It
* was done this was to make it easier to keep the code in line with
* (non hardware specific) changes to serial.c.
*
* The port is registered with the tty driver as minor device 64, and
* therefore other ports should only use 65 upwards.
*
* Richard Lucock 28/12/99
*
* Copyright (C) 1991, 1992 Linus Torvalds
* Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997,
* 1998, 1999 Theodore Ts'o
*
*/
/* Set of debugging defines */
#undef SERIAL_DEBUG_INTR
#undef SERIAL_DEBUG_OPEN
#undef SERIAL_DEBUG_FLOW
#undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
/*
* End of serial driver configuration section.
*/
#include <linux/bitops.h>
#include <linux/circ_buf.h>
#include <linux/console.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/fcntl.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/ptrace.h>
#include <linux/seq_file.h>
#include <linux/serial.h>
#include <linux/serial_reg.h>
#include <linux/serial_core.h>
#include <linux/sched.h>
#include <linux/signal.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/tty_flip.h>
#include <linux/tty.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <asm/amigahw.h>
#include <asm/amigaints.h>
#include <asm/irq.h>
#include <asm/setup.h>
struct serial_state {
struct tty_port tport;
struct circ_buf xmit;
struct async_icount icount;
unsigned long port;
int baud_base;
int custom_divisor;
int read_status_mask;
int ignore_status_mask;
int timeout;
int quot;
int IER; /* Interrupt Enable Register */
int MCR; /* Modem control register */
u8 x_char; /* xon/xoff character */
};
static struct tty_driver *serial_driver;
/* number of characters left in xmit buffer before we ask for more */
#define WAKEUP_CHARS 256
#define XMIT_FIFO_SIZE 1
static unsigned char current_ctl_bits;
static void change_speed(struct tty_struct *tty, struct serial_state *info,
const struct ktermios *old);
static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
static struct serial_state serial_state;
/* some serial hardware definitions */
#define SDR_OVRUN (1<<15)
#define SDR_RBF (1<<14)
#define SDR_TBE (1&l
|