linux/drivers/tty/serial/uartlite.c

// SPDX-License-Identifier: GPL-2.0
/*
 * uartlite.c: Serial driver for Xilinx uartlite serial controller
 *
 * Copyright (C) 2006 Peter Korsgaard <[email protected]>
 * Copyright (C) 2007 Secret Lab Technologies Ltd.
 */

#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/bitfield.h>
#include <linux/console.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/of.h>
#include <linux/clk.h>
#include <linux/pm_runtime.h>

#define ULITE_NAME
#if CONFIG_SERIAL_UARTLITE_NR_UARTS > 4
#define ULITE_MAJOR
#define ULITE_MINOR
#else
#define ULITE_MAJOR
#define ULITE_MINOR
#endif
#define ULITE_NR_UARTS

/* ---------------------------------------------------------------------
 * Register definitions
 *
 * For register details see datasheet:
 * https://www.xilinx.com/support/documentation/ip_documentation/opb_uartlite.pdf
 */

#define ULITE_RX
#define ULITE_TX
#define ULITE_STATUS
#define ULITE_CONTROL

#define ULITE_REGION

#define ULITE_STATUS_RXVALID
#define ULITE_STATUS_RXFULL
#define ULITE_STATUS_TXEMPTY
#define ULITE_STATUS_TXFULL
#define ULITE_STATUS_IE
#define ULITE_STATUS_OVERRUN
#define ULITE_STATUS_FRAME
#define ULITE_STATUS_PARITY

#define ULITE_CONTROL_RST_TX
#define ULITE_CONTROL_RST_RX
#define ULITE_CONTROL_IE
#define UART_AUTOSUSPEND_TIMEOUT

/* Static pointer to console port */
#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
static struct uart_port *console_port;
#endif

/**
 * struct uartlite_data - Driver private data
 * @reg_ops: Functions to read/write registers
 * @clk: Our parent clock, if present
 * @baud: The baud rate configured when this device was synthesized
 * @cflags: The cflags for parity and data bits
 */
struct uartlite_data {};

struct uartlite_reg_ops {};

static u32 uartlite_inbe32(void __iomem *addr)
{}

static void uartlite_outbe32(u32 val, void __iomem *addr)
{}

static const struct uartlite_reg_ops uartlite_be =;

static u32 uartlite_inle32(void __iomem *addr)
{}

static void uartlite_outle32(u32 val, void __iomem *addr)
{}

static const struct uartlite_reg_ops uartlite_le =;

static inline u32 uart_in32(u32 offset, struct uart_port *port)
{}

static inline void uart_out32(u32 val, u32 offset, struct uart_port *port)
{}

static struct uart_port ulite_ports[ULITE_NR_UARTS];

static struct uart_driver ulite_uart_driver;

/* ---------------------------------------------------------------------
 * Core UART driver operations
 */

static int ulite_receive(struct uart_port *port, int stat)
{}

static int ulite_transmit(struct uart_port *port, int stat)
{}

static irqreturn_t ulite_isr(int irq, void *dev_id)
{}

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

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

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

static void ulite_stop_tx(struct uart_port *port)
{}

static void ulite_start_tx(struct uart_port *port)
{}

static void ulite_stop_rx(struct uart_port *port)
{}

static void ulite_break_ctl(struct uart_port *port, int ctl)
{}

static int ulite_startup(struct uart_port *port)
{}

static void ulite_shutdown(struct uart_port *port)
{}

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

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

static void ulite_release_port(struct uart_port *port)
{}

static int ulite_request_port(struct uart_port *port)
{}

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

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

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

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

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

static const struct uart_ops ulite_ops =;

/* ---------------------------------------------------------------------
 * Console driver operations
 */

#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
static void ulite_console_wait_tx(struct uart_port *port)
{}

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

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

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

static struct console ulite_console =;

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

static void early_uartlite_write(struct console *console,
				 const char *s, unsigned n)
{}

static int __init early_uartlite_setup(struct earlycon_device *device,
				       const char *options)
{}
EARLYCON_DECLARE();
OF_EARLYCON_DECLARE();
OF_EARLYCON_DECLARE();

#endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */

static struct uart_driver ulite_uart_driver =;

/* ---------------------------------------------------------------------
 * Port assignment functions (mapping devices to uart_port structures)
 */

/** ulite_assign: register a uartlite device with the driver
 *
 * @dev: pointer to device structure
 * @id: requested id number.  Pass -1 for automatic port assignment
 * @base: base address of uartlite registers
 * @irq: irq number for uartlite
 * @pdata: private data for uartlite
 *
 * Returns: 0 on success, <0 otherwise
 */
static int ulite_assign(struct device *dev, int id, phys_addr_t base, int irq,
			struct uartlite_data *pdata)
{}

/** ulite_release: register a uartlite device with the driver
 *
 * @dev: pointer to device structure
 */
static void ulite_release(struct device *dev)
{}

/**
 * ulite_suspend - Stop the device.
 *
 * @dev: handle to the device structure.
 * Return: 0 always.
 */
static int __maybe_unused ulite_suspend(struct device *dev)
{}

/**
 * ulite_resume - Resume the device.
 *
 * @dev: handle to the device structure.
 * Return: 0 on success, errno otherwise.
 */
static int __maybe_unused ulite_resume(struct device *dev)
{}

static int __maybe_unused ulite_runtime_suspend(struct device *dev)
{
	struct uart_port *port = dev_get_drvdata(dev);
	struct uartlite_data *pdata = port->private_data;

	clk_disable(pdata->clk);
	return 0;
};

static int __maybe_unused ulite_runtime_resume(struct device *dev)
{}

/* ---------------------------------------------------------------------
 * Platform bus binding
 */

static const struct dev_pm_ops ulite_pm_ops =;

#if defined(CONFIG_OF)
/* Match table for of_platform binding */
static const struct of_device_id ulite_of_match[] =;
MODULE_DEVICE_TABLE(of, ulite_of_match);
#endif /* CONFIG_OF */

static int ulite_probe(struct platform_device *pdev)
{}

static void ulite_remove(struct platform_device *pdev)
{}

/* work with hotplug and coldplug */
MODULE_ALIAS();

static struct platform_driver ulite_platform_driver =;

/* ---------------------------------------------------------------------
 * Module setup/teardown
 */

static int __init ulite_init(void)
{}

static void __exit ulite_exit(void)
{}

module_init();
module_exit(ulite_exit);

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