linux/drivers/usb/serial/mxuport.c

// SPDX-License-Identifier: GPL-2.0+
/*
 *	mxuport.c - MOXA UPort series driver
 *
 *	Copyright (c) 2006 Moxa Technologies Co., Ltd.
 *	Copyright (c) 2013 Andrew Lunn <[email protected]>
 *
 *	Supports the following Moxa USB to serial converters:
 *	 2 ports : UPort 1250, UPort 1250I
 *	 4 ports : UPort 1410, UPort 1450, UPort 1450I
 *	 8 ports : UPort 1610-8, UPort 1650-8
 *	16 ports : UPort 1610-16, UPort 1650-16
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/firmware.h>
#include <linux/jiffies.h>
#include <linux/serial.h>
#include <linux/serial_reg.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
#include <asm/unaligned.h>

/* Definitions for the vendor ID and device ID */
#define MX_USBSERIAL_VID
#define MX_UPORT1250_PID
#define MX_UPORT1251_PID
#define MX_UPORT1410_PID
#define MX_UPORT1450_PID
#define MX_UPORT1451_PID
#define MX_UPORT1618_PID
#define MX_UPORT1658_PID
#define MX_UPORT1613_PID
#define MX_UPORT1653_PID

/* Definitions for USB info */
#define HEADER_SIZE
#define EVENT_LENGTH
#define DOWN_BLOCK_SIZE

/* Definitions for firmware info */
#define VER_ADDR_1
#define VER_ADDR_2
#define VER_ADDR_3

/* Definitions for USB vendor request */
#define RQ_VENDOR_NONE
#define RQ_VENDOR_SET_BAUD
#define RQ_VENDOR_SET_LINE
#define RQ_VENDOR_SET_CHARS
#define RQ_VENDOR_SET_RTS
#define RQ_VENDOR_SET_DTR
#define RQ_VENDOR_SET_XONXOFF
#define RQ_VENDOR_SET_RX_HOST_EN
#define RQ_VENDOR_SET_OPEN
#define RQ_VENDOR_PURGE
#define RQ_VENDOR_SET_MCR
#define RQ_VENDOR_SET_BREAK

#define RQ_VENDOR_START_FW_DOWN
#define RQ_VENDOR_STOP_FW_DOWN
#define RQ_VENDOR_QUERY_FW_READY

#define RQ_VENDOR_SET_FIFO_DISABLE
#define RQ_VENDOR_SET_INTERFACE
#define RQ_VENDOR_SET_HIGH_PERFOR

#define RQ_VENDOR_ERASE_BLOCK
#define RQ_VENDOR_WRITE_PAGE
#define RQ_VENDOR_PREPARE_WRITE
#define RQ_VENDOR_CONFIRM_WRITE
#define RQ_VENDOR_LOCATE

#define RQ_VENDOR_START_ROM_DOWN
#define RQ_VENDOR_ROM_DATA
#define RQ_VENDOR_STOP_ROM_DOWN
#define RQ_VENDOR_FW_DATA

#define RQ_VENDOR_RESET_DEVICE
#define RQ_VENDOR_QUERY_FW_CONFIG

#define RQ_VENDOR_GET_VERSION
#define RQ_VENDOR_GET_PAGE
#define RQ_VENDOR_GET_ROM_PROC

#define RQ_VENDOR_GET_INQUEUE
#define RQ_VENDOR_GET_OUTQUEUE

#define RQ_VENDOR_GET_MSR

/* Definitions for UPort event type */
#define UPORT_EVENT_NONE
#define UPORT_EVENT_TXBUF_THRESHOLD
#define UPORT_EVENT_SEND_NEXT
#define UPORT_EVENT_MSR
#define UPORT_EVENT_LSR
#define UPORT_EVENT_MCR

/* Definitions for serial event type */
#define SERIAL_EV_CTS
#define SERIAL_EV_DSR
#define SERIAL_EV_RLSD

/* Definitions for modem control event type */
#define SERIAL_EV_XOFF

/* Definitions for line control of communication */
#define MX_WORDLENGTH_5
#define MX_WORDLENGTH_6
#define MX_WORDLENGTH_7
#define MX_WORDLENGTH_8

#define MX_PARITY_NONE
#define MX_PARITY_ODD
#define MX_PARITY_EVEN
#define MX_PARITY_MARK
#define MX_PARITY_SPACE

#define MX_STOP_BITS_1
#define MX_STOP_BITS_1_5
#define MX_STOP_BITS_2

#define MX_RTS_DISABLE
#define MX_RTS_ENABLE
#define MX_RTS_HW
#define MX_RTS_NO_CHANGE

#define MX_INT_RS232
#define MX_INT_2W_RS485
#define MX_INT_RS422
#define MX_INT_4W_RS485

/* Definitions for holding reason */
#define MX_WAIT_FOR_CTS
#define MX_WAIT_FOR_DSR
#define MX_WAIT_FOR_DCD
#define MX_WAIT_FOR_XON
#define MX_WAIT_FOR_START_TX
#define MX_WAIT_FOR_UNTHROTTLE
#define MX_WAIT_FOR_LOW_WATER
#define MX_WAIT_FOR_SEND_NEXT

#define MX_UPORT_2_PORT
#define MX_UPORT_4_PORT
#define MX_UPORT_8_PORT
#define MX_UPORT_16_PORT

/* This structure holds all of the local port information */
struct mxuport_port {};

/* Table of devices that work with this driver */
static const struct usb_device_id mxuport_idtable[] =;

MODULE_DEVICE_TABLE(usb, mxuport_idtable);

/*
 * Add a four byte header containing the port number and the number of
 * bytes of data in the message. Return the number of bytes in the
 * buffer.
 */
static int mxuport_prepare_write_buffer(struct usb_serial_port *port,
					void *dest, size_t size)
{}

/* Read the given buffer in from the control pipe. */
static int mxuport_recv_ctrl_urb(struct usb_serial *serial,
				 u8 request, u16 value, u16 index,
				 u8 *data, size_t size)
{}

/* Write the given buffer out to the control pipe.  */
static int mxuport_send_ctrl_data_urb(struct usb_serial *serial,
				      u8 request,
				      u16 value, u16 index,
				      u8 *data, size_t size)
{}

/* Send a vendor request without any data */
static int mxuport_send_ctrl_urb(struct usb_serial *serial,
				 u8 request, u16 value, u16 index)
{}

/*
 * mxuport_throttle - throttle function of driver
 *
 * This function is called by the tty driver when it wants to stop the
 * data being read from the port. Since all the data comes over one
 * bulk in endpoint, we cannot stop submitting urbs by setting
 * port->throttle. Instead tell the device to stop sending us data for
 * the port.
 */
static void mxuport_throttle(struct tty_struct *tty)
{}

/*
 * mxuport_unthrottle - unthrottle function of driver
 *
 * This function is called by the tty driver when it wants to resume
 * the data being read from the port. Tell the device it can resume
 * sending us received data from the port.
 */
static void mxuport_unthrottle(struct tty_struct *tty)
{}

/*
 * Processes one chunk of data received for a port.  Mostly a copy of
 * usb_serial_generic_process_read_urb().
 */
static void mxuport_process_read_urb_data(struct usb_serial_port *port,
					  char *data, int size)
{}

static void mxuport_msr_event(struct usb_serial_port *port, u8 buf[4])
{}

static void mxuport_lsr_event(struct usb_serial_port *port, u8 buf[4])
{}

/*
 * When something interesting happens, modem control lines XON/XOFF
 * etc, the device sends an event. Process these events.
 */
static void mxuport_process_read_urb_event(struct usb_serial_port *port,
					   u8 buf[4], u32 event)
{}

/*
 * One URB can contain data for multiple ports. Demultiplex the data,
 * checking the port exists, is opened and the message is valid.
 */
static void mxuport_process_read_urb_demux_data(struct urb *urb)
{}

/*
 * One URB can contain events for multiple ports. Demultiplex the event,
 * checking the port exists, and is opened.
 */
static void mxuport_process_read_urb_demux_event(struct urb *urb)
{}

/*
 * This is called when we have received data on the bulk in
 * endpoint. Depending on which port it was received on, it can
 * contain serial data or events.
 */
static void mxuport_process_read_urb(struct urb *urb)
{}

/*
 * Ask the device how many bytes it has queued to be sent out. If
 * there are none, return true.
 */
static bool mxuport_tx_empty(struct usb_serial_port *port)
{}

static int mxuport_set_mcr(struct usb_serial_port *port, u8 mcr_state)
{}

static int mxuport_set_dtr(struct usb_serial_port *port, int on)
{}

static int mxuport_set_rts(struct usb_serial_port *port, u8 state)
{}

static void mxuport_dtr_rts(struct usb_serial_port *port, int on)
{}

static int mxuport_tiocmset(struct tty_struct *tty, unsigned int set,
			    unsigned int clear)
{}

static int mxuport_tiocmget(struct tty_struct *tty)
{}

static int mxuport_set_termios_flow(struct tty_struct *tty,
				    const struct ktermios *old_termios,
				    struct usb_serial_port *port,
				    struct usb_serial *serial)
{}

static void mxuport_set_termios(struct tty_struct *tty,
				struct usb_serial_port *port,
				const struct ktermios *old_termios)
{}

/*
 * Determine how many ports this device has dynamically.  It will be
 * called after the probe() callback is called, but before attach().
 */
static int mxuport_calc_num_ports(struct usb_serial *serial,
					struct usb_serial_endpoints *epds)
{}

/* Get the version of the firmware currently running. */
static int mxuport_get_fw_version(struct usb_serial *serial, u32 *version)
{}

/* Given a firmware blob, download it to the device. */
static int mxuport_download_fw(struct usb_serial *serial,
			       const struct firmware *fw_p)
{}

static int mxuport_probe(struct usb_serial *serial,
			 const struct usb_device_id *id)
{}


static int mxuport_port_probe(struct usb_serial_port *port)
{}

static int mxuport_attach(struct usb_serial *serial)
{}

static void mxuport_release(struct usb_serial *serial)
{}

static int mxuport_open(struct tty_struct *tty, struct usb_serial_port *port)
{}

static void mxuport_close(struct usb_serial_port *port)
{}

/* Send a break to the port. */
static int mxuport_break_ctl(struct tty_struct *tty, int break_state)
{}

static int mxuport_resume(struct usb_serial *serial)
{}

static struct usb_serial_driver mxuport_device =;

static struct usb_serial_driver *const serial_drivers[] =;

module_usb_serial_driver();

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