#include <linux/circ_buf.h>
#include <linux/tty.h>
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/serial.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/console.h>
#include <linux/sysrq.h>
#include <linux/tty_flip.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/atmel_pdc.h>
#include <linux/uaccess.h>
#include <linux/platform_data/atmel.h>
#include <linux/timer.h>
#include <linux/err.h>
#include <linux/irq.h>
#include <linux/suspend.h>
#include <linux/mm.h>
#include <linux/io.h>
#include <asm/div64.h>
#include <asm/ioctls.h>
#define PDC_BUFFER_SIZE …
#define PDC_RX_TIMEOUT …
#define ATMEL_MIN_FIFO_SIZE …
#define ATMEL_RTS_HIGH_OFFSET …
#define ATMEL_RTS_LOW_OFFSET …
#include <linux/serial_core.h>
#include "serial_mctrl_gpio.h"
#include "atmel_serial.h"
static void atmel_start_rx(struct uart_port *port);
static void atmel_stop_rx(struct uart_port *port);
#ifdef CONFIG_SERIAL_ATMEL_TTYAT
#define SERIAL_ATMEL_MAJOR …
#define MINOR_START …
#define ATMEL_DEVICENAME …
#else
#define SERIAL_ATMEL_MAJOR …
#define MINOR_START …
#define ATMEL_DEVICENAME …
#endif
#define ATMEL_ISR_PASS_LIMIT …
struct atmel_dma_buffer { … };
struct atmel_uart_char { … };
#define ATMEL_SERIAL_RINGSIZE …
#define ATMEL_SERIAL_RX_SIZE …
#define ATMEL_MAX_UART …
struct atmel_uart_port { … };
static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART];
static DECLARE_BITMAP(atmel_ports_in_use, ATMEL_MAX_UART);
#if defined(CONFIG_OF)
static const struct of_device_id atmel_serial_dt_ids[] = …;
#endif
static inline struct atmel_uart_port *
to_atmel_uart_port(struct uart_port *uart)
{ … }
static inline u32 atmel_uart_readl(struct uart_port *port, u32 reg)
{ … }
static inline void atmel_uart_writel(struct uart_port *port, u32 reg, u32 value)
{ … }
static inline u8 atmel_uart_read_char(struct uart_port *port)
{ … }
static inline void atmel_uart_write_char(struct uart_port *port, u8 value)
{ … }
static inline int atmel_uart_is_half_duplex(struct uart_port *port)
{ … }
static inline int atmel_error_rate(int desired_value, int actual_value)
{ … }
#ifdef CONFIG_SERIAL_ATMEL_PDC
static bool atmel_use_pdc_rx(struct uart_port *port)
{ … }
static bool atmel_use_pdc_tx(struct uart_port *port)
{ … }
#else
static bool atmel_use_pdc_rx(struct uart_port *port)
{
return false;
}
static bool atmel_use_pdc_tx(struct uart_port *port)
{
return false;
}
#endif
static bool atmel_use_dma_tx(struct uart_port *port)
{ … }
static bool atmel_use_dma_rx(struct uart_port *port)
{ … }
static bool atmel_use_fifo(struct uart_port *port)
{ … }
static void atmel_tasklet_schedule(struct atmel_uart_port *atmel_port,
struct tasklet_struct *t)
{ … }
static int atmel_config_rs485(struct uart_port *port, struct ktermios *termios,
struct serial_rs485 *rs485conf)
{ … }
static unsigned int atmel_calc_cd(struct uart_port *port,
struct serial_iso7816 *iso7816conf)
{ … }
static unsigned int atmel_calc_fidi(struct uart_port *port,
struct serial_iso7816 *iso7816conf)
{ … }
static int atmel_config_iso7816(struct uart_port *port,
struct serial_iso7816 *iso7816conf)
{ … }
static u_int atmel_tx_empty(struct uart_port *port)
{ … }
static void atmel_set_mctrl(struct uart_port *port, u_int mctrl)
{ … }
static u_int atmel_get_mctrl(struct uart_port *port)
{ … }
static void atmel_stop_tx(struct uart_port *port)
{ … }
static void atmel_start_tx(struct uart_port *port)
{ … }
static void atmel_start_rx(struct uart_port *port)
{ … }
static void atmel_stop_rx(struct uart_port *port)
{ … }
static void atmel_enable_ms(struct uart_port *port)
{ … }
static void atmel_disable_ms(struct uart_port *port)
{ … }
static void atmel_break_ctl(struct uart_port *port, int break_state)
{ … }
static void
atmel_buffer_rx_char(struct uart_port *port, unsigned int status,
unsigned int ch)
{ … }
static void atmel_pdc_rxerr(struct uart_port *port, unsigned int status)
{ … }
static void atmel_rx_chars(struct uart_port *port)
{ … }
static void atmel_tx_chars(struct uart_port *port)
{ … }
static void atmel_complete_tx_dma(void *arg)
{ … }
static void atmel_release_tx_dma(struct uart_port *port)
{ … }
static void atmel_tx_dma(struct uart_port *port)
{ … }
static int atmel_prepare_tx_dma(struct uart_port *port)
{ … }
static void atmel_complete_rx_dma(void *arg)
{ … }
static void atmel_release_rx_dma(struct uart_port *port)
{ … }
static void atmel_rx_from_dma(struct uart_port *port)
{ … }
static int atmel_prepare_rx_dma(struct uart_port *port)
{ … }
static void atmel_uart_timer_callback(struct timer_list *t)
{ … }
static void
atmel_handle_receive(struct uart_port *port, unsigned int pending)
{ … }
static void
atmel_handle_transmit(struct uart_port *port, unsigned int pending)
{ … }
static void
atmel_handle_status(struct uart_port *port, unsigned int pending,
unsigned int status)
{ … }
static irqreturn_t atmel_interrupt(int irq, void *dev_id)
{ … }
static void atmel_release_tx_pdc(struct uart_port *port)
{ … }
static void atmel_tx_pdc(struct uart_port *port)
{ … }
static int atmel_prepare_tx_pdc(struct uart_port *port)
{ … }
static void atmel_rx_from_ring(struct uart_port *port)
{ … }
static void atmel_release_rx_pdc(struct uart_port *port)
{ … }
static void atmel_rx_from_pdc(struct uart_port *port)
{ … }
static int atmel_prepare_rx_pdc(struct uart_port *port)
{ … }
static void atmel_tasklet_rx_func(struct tasklet_struct *t)
{ … }
static void atmel_tasklet_tx_func(struct tasklet_struct *t)
{ … }
static void atmel_init_property(struct atmel_uart_port *atmel_port,
struct platform_device *pdev)
{ … }
static void atmel_set_ops(struct uart_port *port)
{ … }
static void atmel_get_ip_name(struct uart_port *port)
{ … }
static int atmel_startup(struct uart_port *port)
{ … }
static void atmel_flush_buffer(struct uart_port *port)
{ … }
static void atmel_shutdown(struct uart_port *port)
{ … }
static void atmel_serial_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate)
{ … }
static void atmel_set_termios(struct uart_port *port,
struct ktermios *termios,
const struct ktermios *old)
{ … }
static void atmel_set_ldisc(struct uart_port *port, struct ktermios *termios)
{ … }
static const char *atmel_type(struct uart_port *port)
{ … }
static void atmel_release_port(struct uart_port *port)
{ … }
static int atmel_request_port(struct uart_port *port)
{ … }
static void atmel_config_port(struct uart_port *port, int flags)
{ … }
static int atmel_verify_port(struct uart_port *port, struct serial_struct *ser)
{ … }
#ifdef CONFIG_CONSOLE_POLL
static int atmel_poll_get_char(struct uart_port *port)
{ … }
static void atmel_poll_put_char(struct uart_port *port, unsigned char ch)
{ … }
#endif
static const struct uart_ops atmel_pops = …;
static const struct serial_rs485 atmel_rs485_supported = …;
static int atmel_init_port(struct atmel_uart_port *atmel_port,
struct platform_device *pdev)
{ … }
#ifdef CONFIG_SERIAL_ATMEL_CONSOLE
static void atmel_console_putchar(struct uart_port *port, unsigned char ch)
{ … }
static void atmel_console_write(struct console *co, const char *s, u_int count)
{ … }
static void __init atmel_console_get_options(struct uart_port *port, int *baud,
int *parity, int *bits)
{ … }
static int __init atmel_console_setup(struct console *co, char *options)
{ … }
static struct uart_driver atmel_uart;
static struct console atmel_console = …;
static void atmel_serial_early_write(struct console *con, const char *s,
unsigned int n)
{ … }
static int __init atmel_early_console_setup(struct earlycon_device *device,
const char *options)
{ … }
OF_EARLYCON_DECLARE(…);
OF_EARLYCON_DECLARE(…);
#define ATMEL_CONSOLE_DEVICE …
#else
#define ATMEL_CONSOLE_DEVICE …
#endif
static struct uart_driver atmel_uart = …;
static bool atmel_serial_clk_will_stop(void)
{ … }
static int __maybe_unused atmel_serial_suspend(struct device *dev)
{ … }
static int __maybe_unused atmel_serial_resume(struct device *dev)
{ … }
static void atmel_serial_probe_fifos(struct atmel_uart_port *atmel_port,
struct platform_device *pdev)
{ … }
static int atmel_serial_probe(struct platform_device *pdev)
{ … }
static void atmel_serial_remove(struct platform_device *pdev)
{ … }
static SIMPLE_DEV_PM_OPS(atmel_serial_pm_ops, atmel_serial_suspend,
atmel_serial_resume);
static struct platform_driver atmel_serial_driver = …;
static int __init atmel_serial_init(void)
{ … }
device_initcall(atmel_serial_init);