linux/drivers/tty/serial/omap-serial.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Driver for OMAP-UART controller.
 * Based on drivers/serial/8250.c
 *
 * Copyright (C) 2010 Texas Instruments.
 *
 * Authors:
 *	Govindraj R	<[email protected]>
 *	Thara Gopinath	<[email protected]>
 *
 * Note: This driver is made separate from 8250 driver as we cannot
 * over load 8250 driver with omap platform specific configuration for
 * features like DMA, it makes easier to implement features like DMA and
 * hardware flow control and software flow control configuration with
 * this driver as required for the omap-platform.
 */

#include <linux/module.h>
#include <linux/init.h>
#include <linux/console.h>
#include <linux/serial.h>
#include <linux/serial_reg.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/serial_core.h>
#include <linux/irq.h>
#include <linux/pm_runtime.h>
#include <linux/pm_wakeirq.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/gpio/consumer.h>
#include <linux/platform_data/serial-omap.h>

#define OMAP_MAX_HSUART_PORTS

#define UART_BUILD_REVISION(x, y)

#define OMAP_UART_REV_42
#define OMAP_UART_REV_46
#define OMAP_UART_REV_52
#define OMAP_UART_REV_63

#define OMAP_UART_TX_WAKEUP_EN

/* Feature flags */
#define OMAP_UART_WER_HAS_TX_WAKEUP

#define UART_ERRATA_i202_MDR1_ACCESS
#define UART_ERRATA_i291_DMA_FORCEIDLE

#define DEFAULT_CLK_SPEED

/* SCR register bitmasks */
#define OMAP_UART_SCR_RX_TRIG_GRANU1_MASK
#define OMAP_UART_SCR_TX_TRIG_GRANU1_MASK
#define OMAP_UART_SCR_TX_EMPTY

/* FCR register bitmasks */
#define OMAP_UART_FCR_RX_FIFO_TRIG_MASK
#define OMAP_UART_FCR_TX_FIFO_TRIG_MASK

/* MVR register bitmasks */
#define OMAP_UART_MVR_SCHEME_SHIFT

#define OMAP_UART_LEGACY_MVR_MAJ_MASK
#define OMAP_UART_LEGACY_MVR_MAJ_SHIFT
#define OMAP_UART_LEGACY_MVR_MIN_MASK

#define OMAP_UART_MVR_MAJ_MASK
#define OMAP_UART_MVR_MAJ_SHIFT
#define OMAP_UART_MVR_MIN_MASK

#define OMAP_UART_DMA_CH_FREE

#define MSR_SAVE_FLAGS
#define OMAP_MODE13X_SPEED

/* WER = 0x7F
 * Enable module level wakeup in WER reg
 */
#define OMAP_UART_WER_MOD_WKUP

/* Enable XON/XOFF flow control on output */
#define OMAP_UART_SW_TX

/* Enable XON/XOFF flow control on input */
#define OMAP_UART_SW_RX

#define OMAP_UART_SW_CLR

#define OMAP_UART_TCR_TRIG

struct uart_omap_dma {};

struct uart_omap_port {};

#define to_uart_omap_port(p)

static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];

/* Forward declaration of functions */
static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1);

static inline unsigned int serial_in(struct uart_omap_port *up, int offset)
{}

static inline void serial_out(struct uart_omap_port *up, int offset, int value)
{}

static inline void serial_omap_clear_fifos(struct uart_omap_port *up)
{}

#ifdef CONFIG_PM
static int serial_omap_get_context_loss_count(struct uart_omap_port *up)
{}

/* REVISIT: Remove this when omap3 boots in device tree only mode */
static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable)
{}
#endif /* CONFIG_PM */

/*
 * Calculate the absolute difference between the desired and actual baud
 * rate for the given mode.
 */
static inline int calculate_baud_abs_diff(struct uart_port *port,
				unsigned int baud, unsigned int mode)
{}

/*
 * serial_omap_baud_is_mode16 - check if baud rate is MODE16X
 * @port: uart port info
 * @baud: baudrate for which mode needs to be determined
 *
 * Returns true if baud rate is MODE16X and false if MODE13X
 * Original table in OMAP TRM named "UART Mode Baud Rates, Divisor Values,
 * and Error Rates" determines modes not for all common baud rates.
 * E.g. for 1000000 baud rate mode must be 16x, but according to that
 * table it's determined as 13x.
 */
static bool
serial_omap_baud_is_mode16(struct uart_port *port, unsigned int baud)
{}

/*
 * serial_omap_get_divisor - calculate divisor value
 * @port: uart port info
 * @baud: baudrate for which divisor needs to be calculated.
 */
static unsigned int
serial_omap_get_divisor(struct uart_port *port, unsigned int baud)
{}

static void serial_omap_enable_ms(struct uart_port *port)
{}

static void serial_omap_stop_tx(struct uart_port *port)
{}

static void serial_omap_stop_rx(struct uart_port *port)
{}

static void serial_omap_put_char(struct uart_omap_port *up, unsigned char ch)
{}

static void transmit_chars(struct uart_omap_port *up, unsigned int lsr)
{}

static inline void serial_omap_enable_ier_thri(struct uart_omap_port *up)
{}

static void serial_omap_start_tx(struct uart_port *port)
{}

static void serial_omap_throttle(struct uart_port *port)
{}

static void serial_omap_unthrottle(struct uart_port *port)
{}

static unsigned int check_modem_status(struct uart_omap_port *up)
{}

static void serial_omap_rlsi(struct uart_omap_port *up, unsigned int lsr)
{}

static void serial_omap_rdi(struct uart_omap_port *up, unsigned int lsr)
{}

/**
 * serial_omap_irq() - This handles the interrupt from one port
 * @irq: uart port irq number
 * @dev_id: uart port info
 */
static irqreturn_t serial_omap_irq(int irq, void *dev_id)
{}

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

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

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

static void serial_omap_break_ctl(struct uart_port *port, int break_state)
{}

static int serial_omap_startup(struct uart_port *port)
{}

static void serial_omap_shutdown(struct uart_port *port)
{}

static void serial_omap_uart_qos_work(struct work_struct *work)
{}

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

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

static void serial_omap_release_port(struct uart_port *port)
{}

static int serial_omap_request_port(struct uart_port *port)
{}

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

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

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

static void __maybe_unused wait_for_xmitr(struct uart_omap_port *up)
{}

#ifdef CONFIG_CONSOLE_POLL

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

static int serial_omap_poll_get_char(struct uart_port *port)
{}

#endif /* CONFIG_CONSOLE_POLL */

#ifdef CONFIG_SERIAL_OMAP_CONSOLE

#ifdef CONFIG_SERIAL_EARLYCON
static unsigned int omap_serial_early_in(struct uart_port *port, int offset)
{}

static void omap_serial_early_out(struct uart_port *port, int offset,
				  int value)
{}

static void omap_serial_early_putc(struct uart_port *port, unsigned char c)
{}

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

static int __init early_omap_serial_setup(struct earlycon_device *device,
					  const char *options)
{}

OF_EARLYCON_DECLARE();
OF_EARLYCON_DECLARE();
OF_EARLYCON_DECLARE();
#endif /* CONFIG_SERIAL_EARLYCON */

static struct uart_omap_port *serial_omap_console_ports[OMAP_MAX_HSUART_PORTS];

static struct uart_driver serial_omap_reg;

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

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

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

static struct console serial_omap_console =;

static void serial_omap_add_console_port(struct uart_omap_port *up)
{}

#define OMAP_CONSOLE

#else

#define OMAP_CONSOLE

static inline void serial_omap_add_console_port(struct uart_omap_port *up)
{}

#endif

/* Enable or disable the rs485 support */
static int
serial_omap_config_rs485(struct uart_port *port, struct ktermios *termios,
			 struct serial_rs485 *rs485)
{}

static const struct uart_ops serial_omap_pops =;

static struct uart_driver serial_omap_reg =;

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

static void serial_omap_complete(struct device *dev)
{}

static int serial_omap_suspend(struct device *dev)
{}

static int serial_omap_resume(struct device *dev)
{}
#else
#define serial_omap_prepare
#define serial_omap_complete
#endif /* CONFIG_PM_SLEEP */

static void omap_serial_fill_features_erratas(struct uart_omap_port *up)
{}

static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev)
{}

static const struct serial_rs485 serial_omap_rs485_supported =;

static int serial_omap_probe_rs485(struct uart_omap_port *up,
				   struct device *dev)
{}

static int serial_omap_probe(struct platform_device *pdev)
{}

static void serial_omap_remove(struct platform_device *dev)
{}

/*
 * Work Around for Errata i202 (2430, 3430, 3630, 4430 and 4460)
 * The access to uart register after MDR1 Access
 * causes UART to corrupt data.
 *
 * Need a delay =
 * 5 L4 clock cycles + 5 UART functional clock cycle (@48MHz = ~0.2uS)
 * give 10 times as much
 */
static void serial_omap_mdr1_errataset(struct uart_omap_port *up, u8 mdr1)
{}

#ifdef CONFIG_PM
static void serial_omap_restore_context(struct uart_omap_port *up)
{}

static int serial_omap_runtime_suspend(struct device *dev)
{}

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

static const struct dev_pm_ops serial_omap_dev_pm_ops =;

#if defined(CONFIG_OF)
static const struct of_device_id omap_serial_of_match[] =;
MODULE_DEVICE_TABLE(of, omap_serial_of_match);
#endif

static struct platform_driver serial_omap_driver =;

static int __init serial_omap_init(void)
{}

static void __exit serial_omap_exit(void)
{}

module_init();
module_exit(serial_omap_exit);

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();