linux/drivers/tty/serial/sprd_serial.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2012-2015 Spreadtrum Communications Inc.
 */

#include <linux/clk.h>
#include <linux/console.h>
#include <linux/delay.h>
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
#include <linux/dma/sprd-dma.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/serial_core.h>
#include <linux/serial.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>

/* device name */
#define UART_NR_MAX
#define SPRD_TTY_NAME
#define SPRD_FIFO_SIZE
#define SPRD_DEF_RATE
#define SPRD_BAUD_IO_LIMIT
#define SPRD_TIMEOUT

/* the offset of serial registers and BITs for them */
/* data registers */
#define SPRD_TXD
#define SPRD_RXD

/* line status register and its BITs  */
#define SPRD_LSR
#define SPRD_LSR_OE
#define SPRD_LSR_FE
#define SPRD_LSR_PE
#define SPRD_LSR_BI
#define SPRD_LSR_TX_OVER

/* data number in TX and RX fifo */
#define SPRD_STS1
#define SPRD_RX_FIFO_CNT_MASK
#define SPRD_TX_FIFO_CNT_MASK

/* interrupt enable register and its BITs */
#define SPRD_IEN
#define SPRD_IEN_RX_FULL
#define SPRD_IEN_TX_EMPTY
#define SPRD_IEN_BREAK_DETECT
#define SPRD_IEN_TIMEOUT

/* interrupt clear register */
#define SPRD_ICLR
#define SPRD_ICLR_TIMEOUT

/* line control register */
#define SPRD_LCR
#define SPRD_LCR_STOP_1BIT
#define SPRD_LCR_STOP_2BIT
#define SPRD_LCR_DATA_LEN
#define SPRD_LCR_DATA_LEN5
#define SPRD_LCR_DATA_LEN6
#define SPRD_LCR_DATA_LEN7
#define SPRD_LCR_DATA_LEN8
#define SPRD_LCR_PARITY
#define SPRD_LCR_PARITY_EN
#define SPRD_LCR_EVEN_PAR
#define SPRD_LCR_ODD_PAR

/* control register 1 */
#define SPRD_CTL1
#define SPRD_DMA_EN
#define SPRD_LOOPBACK_EN
#define RX_HW_FLOW_CTL_THLD
#define RX_HW_FLOW_CTL_EN
#define TX_HW_FLOW_CTL_EN
#define RX_TOUT_THLD_DEF
#define RX_HFC_THLD_DEF

/* fifo threshold register */
#define SPRD_CTL2
#define THLD_TX_EMPTY
#define THLD_TX_EMPTY_SHIFT
#define THLD_RX_FULL
#define THLD_RX_FULL_MASK

/* config baud rate register */
#define SPRD_CLKD0
#define SPRD_CLKD0_MASK
#define SPRD_CLKD1
#define SPRD_CLKD1_MASK
#define SPRD_CLKD1_SHIFT

/* interrupt mask status register */
#define SPRD_IMSR
#define SPRD_IMSR_RX_FIFO_FULL
#define SPRD_IMSR_TX_FIFO_EMPTY
#define SPRD_IMSR_BREAK_DETECT
#define SPRD_IMSR_TIMEOUT
#define SPRD_DEFAULT_SOURCE_CLK

#define SPRD_RX_DMA_STEP
#define SPRD_RX_FIFO_FULL
#define SPRD_TX_FIFO_FULL
#define SPRD_UART_RX_SIZE

struct sprd_uart_dma {};

struct sprd_uart_port {};

static struct sprd_uart_port *sprd_port[UART_NR_MAX];
static int sprd_ports_num;

static int sprd_start_dma_rx(struct uart_port *port);
static int sprd_tx_dma_config(struct uart_port *port);

static inline unsigned int serial_in(struct uart_port *port,
				     unsigned int offset)
{}

static inline void serial_out(struct uart_port *port, unsigned int offset,
			      int value)
{}

static unsigned int sprd_tx_empty(struct uart_port *port)
{}

static unsigned int sprd_get_mctrl(struct uart_port *port)
{}

static void sprd_set_mctrl(struct uart_port *port, unsigned int mctrl)
{}

static void sprd_stop_rx(struct uart_port *port)
{}

static void sprd_uart_dma_enable(struct uart_port *port, bool enable)
{}

static void sprd_stop_tx_dma(struct uart_port *port)
{}

static int sprd_tx_buf_remap(struct uart_port *port)
{}

static void sprd_complete_tx_dma(void *data)
{}

static int sprd_uart_dma_submit(struct uart_port *port,
				struct sprd_uart_dma *ud, u32 trans_len,
				enum dma_transfer_direction direction,
				dma_async_tx_callback callback)
{}

static int sprd_tx_dma_config(struct uart_port *port)
{}

static void sprd_start_tx_dma(struct uart_port *port)
{}

static void sprd_rx_full_thld(struct uart_port *port, u32 thld)
{}

static int sprd_rx_alloc_buf(struct sprd_uart_port *sp)
{}

static void sprd_rx_free_buf(struct sprd_uart_port *sp)
{}

static int sprd_rx_dma_config(struct uart_port *port, u32 burst)
{}

static void sprd_uart_dma_rx(struct uart_port *port)
{}

static void sprd_uart_dma_irq(struct uart_port *port)
{}

static void sprd_complete_rx_dma(void *data)
{}

static int sprd_start_dma_rx(struct uart_port *port)
{}

static void sprd_release_dma(struct uart_port *port)
{}

static void sprd_request_dma(struct uart_port *port)
{}

static void sprd_stop_tx(struct uart_port *port)
{}

static void sprd_start_tx(struct uart_port *port)
{}

/* The Sprd serial does not support this function. */
static void sprd_break_ctl(struct uart_port *port, int break_state)
{}

static int handle_lsr_errors(struct uart_port *port,
			     u8 *flag,
			     unsigned int *lsr)
{}

static inline void sprd_rx(struct uart_port *port)
{}

static inline void sprd_tx(struct uart_port *port)
{}

/* this handles the interrupt from one port */
static irqreturn_t sprd_handle_irq(int irq, void *dev_id)
{}

static void sprd_uart_dma_startup(struct uart_port *port,
				  struct sprd_uart_port *sp)
{}

static int sprd_startup(struct uart_port *port)
{}

static void sprd_shutdown(struct uart_port *port)
{}

static void sprd_set_termios(struct uart_port *port, struct ktermios *termios,
		             const struct ktermios *old)
{}

static const char *sprd_type(struct uart_port *port)
{}

static void sprd_release_port(struct uart_port *port)
{}

static int sprd_request_port(struct uart_port *port)
{}

static void sprd_config_port(struct uart_port *port, int flags)
{}

static int sprd_verify_port(struct uart_port *port, struct serial_struct *ser)
{}

static void sprd_pm(struct uart_port *port, unsigned int state,
		unsigned int oldstate)
{}

#ifdef CONFIG_CONSOLE_POLL
static int sprd_poll_init(struct uart_port *port)
{}

static int sprd_poll_get_char(struct uart_port *port)
{}

static void sprd_poll_put_char(struct uart_port *port, unsigned char ch)
{}
#endif

static const struct uart_ops serial_sprd_ops =;

#ifdef CONFIG_SERIAL_SPRD_CONSOLE
static void wait_for_xmitr(struct uart_port *port)
{}

static void sprd_console_putchar(struct uart_port *port, unsigned char ch)
{}

static void sprd_console_write(struct console *co, const char *s,
			       unsigned int count)
{}

static int sprd_console_setup(struct console *co, char *options)
{}

static struct uart_driver sprd_uart_driver;
static struct console sprd_console =;

static int __init sprd_serial_console_init(void)
{}
console_initcall(sprd_serial_console_init);

#define SPRD_CONSOLE

/* Support for earlycon */
static void sprd_putc(struct uart_port *port, unsigned char c)
{}

static void sprd_early_write(struct console *con, const char *s, unsigned int n)
{}

static int __init sprd_early_console_setup(struct earlycon_device *device,
					   const char *opt)
{}
OF_EARLYCON_DECLARE();

#else /* !CONFIG_SERIAL_SPRD_CONSOLE */
#define SPRD_CONSOLE
#endif

static struct uart_driver sprd_uart_driver =;

static void sprd_remove(struct platform_device *dev)
{}

static bool sprd_uart_is_console(struct uart_port *uport)
{}

static int sprd_clk_init(struct uart_port *uport)
{}

static int sprd_probe(struct platform_device *pdev)
{}

#ifdef CONFIG_PM_SLEEP
static int sprd_suspend(struct device *dev)
{}

static int sprd_resume(struct device *dev)
{}
#endif

static SIMPLE_DEV_PM_OPS(sprd_pm_ops, sprd_suspend, sprd_resume);

static const struct of_device_id serial_ids[] =;
MODULE_DEVICE_TABLE(of, serial_ids);

static struct platform_driver sprd_platform_driver =;

module_platform_driver();

MODULE_LICENSE();
MODULE_DESCRIPTION();