#include <linux/bitops.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/gpio/driver.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/serial_core.h>
#include <linux/serial.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/spi/spi.h>
#include <linux/uaccess.h>
#define MAX310X_NAME …
#define MAX310X_MAJOR …
#define MAX310X_MINOR …
#define MAX310X_UART_NRMAX …
#define MAX310X_MAX_PORTS …
#define MAX310X_RHR_REG …
#define MAX310X_THR_REG …
#define MAX310X_IRQEN_REG …
#define MAX310X_IRQSTS_REG …
#define MAX310X_LSR_IRQEN_REG …
#define MAX310X_LSR_IRQSTS_REG …
#define MAX310X_REG_05 …
#define MAX310X_SPCHR_IRQEN_REG …
#define MAX310X_SPCHR_IRQSTS_REG …
#define MAX310X_STS_IRQEN_REG …
#define MAX310X_STS_IRQSTS_REG …
#define MAX310X_MODE1_REG …
#define MAX310X_MODE2_REG …
#define MAX310X_LCR_REG …
#define MAX310X_RXTO_REG …
#define MAX310X_HDPIXDELAY_REG …
#define MAX310X_IRDA_REG …
#define MAX310X_FLOWLVL_REG …
#define MAX310X_FIFOTRIGLVL_REG …
#define MAX310X_TXFIFOLVL_REG …
#define MAX310X_RXFIFOLVL_REG …
#define MAX310X_FLOWCTRL_REG …
#define MAX310X_XON1_REG …
#define MAX310X_XON2_REG …
#define MAX310X_XOFF1_REG …
#define MAX310X_XOFF2_REG …
#define MAX310X_GPIOCFG_REG …
#define MAX310X_GPIODATA_REG …
#define MAX310X_PLLCFG_REG …
#define MAX310X_BRGCFG_REG …
#define MAX310X_BRGDIVLSB_REG …
#define MAX310X_BRGDIVMSB_REG …
#define MAX310X_CLKSRC_REG …
#define MAX310X_REG_1F …
#define MAX310X_EXTREG_START …
#define MAX310X_REVID_REG …
#define MAX310X_GLOBALIRQ_REG …
#define MAX310X_GLOBALCMD_REG …
#define MAX310X_REVID_EXTREG …
#define MAX310X_IRQ_LSR_BIT …
#define MAX310X_IRQ_SPCHR_BIT …
#define MAX310X_IRQ_STS_BIT …
#define MAX310X_IRQ_RXFIFO_BIT …
#define MAX310X_IRQ_TXFIFO_BIT …
#define MAX310X_IRQ_TXEMPTY_BIT …
#define MAX310X_IRQ_RXEMPTY_BIT …
#define MAX310X_IRQ_CTS_BIT …
#define MAX310X_LSR_RXTO_BIT …
#define MAX310X_LSR_RXOVR_BIT …
#define MAX310X_LSR_RXPAR_BIT …
#define MAX310X_LSR_FRERR_BIT …
#define MAX310X_LSR_RXBRK_BIT …
#define MAX310X_LSR_RXNOISE_BIT …
#define MAX310X_LSR_CTS_BIT …
#define MAX310X_SPCHR_XON1_BIT …
#define MAX310X_SPCHR_XON2_BIT …
#define MAX310X_SPCHR_XOFF1_BIT …
#define MAX310X_SPCHR_XOFF2_BIT …
#define MAX310X_SPCHR_BREAK_BIT …
#define MAX310X_SPCHR_MULTIDROP_BIT …
#define MAX310X_STS_GPIO0_BIT …
#define MAX310X_STS_GPIO1_BIT …
#define MAX310X_STS_GPIO2_BIT …
#define MAX310X_STS_GPIO3_BIT …
#define MAX310X_STS_CLKREADY_BIT …
#define MAX310X_STS_SLEEP_BIT …
#define MAX310X_MODE1_RXDIS_BIT …
#define MAX310X_MODE1_TXDIS_BIT …
#define MAX310X_MODE1_TXHIZ_BIT …
#define MAX310X_MODE1_RTSHIZ_BIT …
#define MAX310X_MODE1_TRNSCVCTRL_BIT …
#define MAX310X_MODE1_FORCESLEEP_BIT …
#define MAX310X_MODE1_AUTOSLEEP_BIT …
#define MAX310X_MODE1_IRQSEL_BIT …
#define MAX310X_MODE2_RST_BIT …
#define MAX310X_MODE2_FIFORST_BIT …
#define MAX310X_MODE2_RXTRIGINV_BIT …
#define MAX310X_MODE2_RXEMPTINV_BIT …
#define MAX310X_MODE2_SPCHR_BIT …
#define MAX310X_MODE2_LOOPBACK_BIT …
#define MAX310X_MODE2_MULTIDROP_BIT …
#define MAX310X_MODE2_ECHOSUPR_BIT …
#define MAX310X_LCR_LENGTH0_BIT …
#define MAX310X_LCR_LENGTH1_BIT …
#define MAX310X_LCR_STOPLEN_BIT …
#define MAX310X_LCR_PARITY_BIT …
#define MAX310X_LCR_EVENPARITY_BIT …
#define MAX310X_LCR_FORCEPARITY_BIT …
#define MAX310X_LCR_TXBREAK_BIT …
#define MAX310X_LCR_RTS_BIT …
#define MAX310X_IRDA_IRDAEN_BIT …
#define MAX310X_IRDA_SIR_BIT …
#define MAX310X_FLOWLVL_HALT_MASK …
#define MAX310X_FLOWLVL_RES_MASK …
#define MAX310X_FLOWLVL_HALT(words) …
#define MAX310X_FLOWLVL_RES(words) …
#define MAX310X_FIFOTRIGLVL_TX_MASK …
#define MAX310X_FIFOTRIGLVL_RX_MASK …
#define MAX310X_FIFOTRIGLVL_TX(words) …
#define MAX310X_FIFOTRIGLVL_RX(words) …
#define MAX310X_FLOWCTRL_AUTORTS_BIT …
#define MAX310X_FLOWCTRL_AUTOCTS_BIT …
#define MAX310X_FLOWCTRL_GPIADDR_BIT …
#define MAX310X_FLOWCTRL_SWFLOWEN_BIT …
#define MAX310X_FLOWCTRL_SWFLOW0_BIT …
#define MAX310X_FLOWCTRL_SWFLOW1_BIT …
#define MAX310X_FLOWCTRL_SWFLOW2_BIT …
#define MAX310X_FLOWCTRL_SWFLOW3_BIT …
#define MAX310X_PLLCFG_PREDIV_MASK …
#define MAX310X_PLLCFG_PLLFACTOR_MASK …
#define MAX310X_BRGCFG_2XMODE_BIT …
#define MAX310X_BRGCFG_4XMODE_BIT …
#define MAX310X_CLKSRC_CRYST_BIT …
#define MAX310X_CLKSRC_PLL_BIT …
#define MAX310X_CLKSRC_PLLBYP_BIT …
#define MAX310X_CLKSRC_EXTCLK_BIT …
#define MAX310X_CLKSRC_CLK2RTS_BIT …
#define MAX310X_EXTREG_ENBL …
#define MAX310X_EXTREG_DSBL …
#define MAX310X_FIFO_SIZE …
#define MAX310x_REV_MASK …
#define MAX310X_WRITE_BIT …
#define MAX310X_PORT_STARTUP_WAIT_RETRIES …
#define MAX310X_PORT_STARTUP_WAIT_DELAY_MS …
#define MAX310X_XTAL_WAIT_RETRIES …
#define MAX310X_XTAL_WAIT_DELAY_MS …
#define MAX3107_REV_ID …
#define MAX3109_REV_ID …
#define MAX14830_BRGCFG_CLKDIS_BIT …
#define MAX14830_REV_ID …
struct max310x_if_cfg { … };
struct max310x_devtype { … };
struct max310x_one { … };
#define to_max310x_port(_port) …
struct max310x_port { … };
static struct uart_driver max310x_uart = …;
static DECLARE_BITMAP(max310x_lines, MAX310X_UART_NRMAX);
static u8 max310x_port_read(struct uart_port *port, u8 reg)
{ … }
static void max310x_port_write(struct uart_port *port, u8 reg, u8 val)
{ … }
static void max310x_port_update(struct uart_port *port, u8 reg, u8 mask, u8 val)
{ … }
static int max310x_detect(struct device *dev)
{ … }
static void max310x_power(struct uart_port *port, int on)
{ … }
static const struct max310x_devtype max3107_devtype = …;
static const struct max310x_devtype max3108_devtype = …;
static const struct max310x_devtype max3109_devtype = …;
static const struct max310x_devtype max14830_devtype = …;
static bool max310x_reg_writeable(struct device *dev, unsigned int reg)
{ … }
static bool max310x_reg_volatile(struct device *dev, unsigned int reg)
{ … }
static bool max310x_reg_precious(struct device *dev, unsigned int reg)
{ … }
static bool max310x_reg_noinc(struct device *dev, unsigned int reg)
{ … }
static int max310x_set_baud(struct uart_port *port, int baud)
{ … }
static int max310x_update_best_err(unsigned long f, long *besterr)
{ … }
static s32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
unsigned long freq, bool xtal)
{ … }
static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigned int len)
{ … }
static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned int len)
{ … }
static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen)
{ … }
static void max310x_handle_tx(struct uart_port *port)
{ … }
static void max310x_start_tx(struct uart_port *port)
{ … }
static irqreturn_t max310x_port_irq(struct max310x_port *s, int portno)
{ … }
static irqreturn_t max310x_ist(int irq, void *dev_id)
{ … }
static void max310x_tx_proc(struct work_struct *ws)
{ … }
static unsigned int max310x_tx_empty(struct uart_port *port)
{ … }
static unsigned int max310x_get_mctrl(struct uart_port *port)
{ … }
static void max310x_md_proc(struct work_struct *ws)
{ … }
static void max310x_set_mctrl(struct uart_port *port, unsigned int mctrl)
{ … }
static void max310x_break_ctl(struct uart_port *port, int break_state)
{ … }
static void max310x_set_termios(struct uart_port *port,
struct ktermios *termios,
const struct ktermios *old)
{ … }
static void max310x_rs_proc(struct work_struct *ws)
{ … }
static int max310x_rs485_config(struct uart_port *port, struct ktermios *termios,
struct serial_rs485 *rs485)
{ … }
static int max310x_startup(struct uart_port *port)
{ … }
static void max310x_shutdown(struct uart_port *port)
{ … }
static const char *max310x_type(struct uart_port *port)
{ … }
static int max310x_request_port(struct uart_port *port)
{ … }
static void max310x_config_port(struct uart_port *port, int flags)
{ … }
static int max310x_verify_port(struct uart_port *port, struct serial_struct *s)
{ … }
static void max310x_null_void(struct uart_port *port)
{ … }
static const struct uart_ops max310x_ops = …;
static int __maybe_unused max310x_suspend(struct device *dev)
{ … }
static int __maybe_unused max310x_resume(struct device *dev)
{ … }
static SIMPLE_DEV_PM_OPS(max310x_pm_ops, max310x_suspend, max310x_resume);
#ifdef CONFIG_GPIOLIB
static int max310x_gpio_get(struct gpio_chip *chip, unsigned int offset)
{ … }
static void max310x_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
{ … }
static int max310x_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
{ … }
static int max310x_gpio_direction_output(struct gpio_chip *chip,
unsigned int offset, int value)
{ … }
static int max310x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
unsigned long config)
{ … }
#endif
static const struct serial_rs485 max310x_rs485_supported = …;
static int max310x_probe(struct device *dev, const struct max310x_devtype *devtype,
const struct max310x_if_cfg *if_cfg,
struct regmap *regmaps[], int irq)
{ … }
static void max310x_remove(struct device *dev)
{ … }
static const struct of_device_id __maybe_unused max310x_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, max310x_dt_ids);
static struct regmap_config regcfg = …;
static const char *max310x_regmap_name(u8 port_id)
{ … }
#ifdef CONFIG_SPI_MASTER
static int max310x_spi_extended_reg_enable(struct device *dev, bool enable)
{ … }
static const struct max310x_if_cfg __maybe_unused max310x_spi_if_cfg = …;
static int max310x_spi_probe(struct spi_device *spi)
{ … }
static void max310x_spi_remove(struct spi_device *spi)
{ … }
static const struct spi_device_id max310x_id_table[] = …;
MODULE_DEVICE_TABLE(spi, max310x_id_table);
static struct spi_driver max310x_spi_driver = …;
#endif
#ifdef CONFIG_I2C
static int max310x_i2c_extended_reg_enable(struct device *dev, bool enable)
{ … }
static struct regmap_config regcfg_i2c = …;
static const struct max310x_if_cfg max310x_i2c_if_cfg = …;
static unsigned short max310x_i2c_slave_addr(unsigned short addr,
unsigned int nr)
{ … }
static int max310x_i2c_probe(struct i2c_client *client)
{ … }
static void max310x_i2c_remove(struct i2c_client *client)
{ … }
static const struct i2c_device_id max310x_i2c_id_table[] = …;
MODULE_DEVICE_TABLE(i2c, max310x_i2c_id_table);
static struct i2c_driver max310x_i2c_driver = …;
#endif
static int __init max310x_uart_init(void)
{ … }
module_init(…) …;
static void __exit max310x_uart_exit(void)
{ … }
module_exit(max310x_uart_exit);
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;