linux/drivers/usb/serial/ti_usb_3410_5052.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * TI 3410/5052 USB Serial Driver
 *
 * Copyright (C) 2004 Texas Instruments
 *
 * This driver is based on the Linux io_ti driver, which is
 *   Copyright (C) 2000-2002 Inside Out Networks
 *   Copyright (C) 2001-2002 Greg Kroah-Hartman
 *
 * For questions or problems with this driver, contact Texas Instruments
 * technical support, or Al Borchers <[email protected]>, or
 * Peter Berger <[email protected]>.
 */

#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/firmware.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/ioctl.h>
#include <linux/serial.h>
#include <linux/kfifo.h>
#include <linux/mutex.h>
#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>

/* Configuration ids */
#define TI_BOOT_CONFIG
#define TI_ACTIVE_CONFIG

/* Vendor and product ids */
#define TI_VENDOR_ID
#define IBM_VENDOR_ID
#define STARTECH_VENDOR_ID
#define TI_3410_PRODUCT_ID
#define IBM_4543_PRODUCT_ID
#define IBM_454B_PRODUCT_ID
#define IBM_454C_PRODUCT_ID
#define TI_3410_EZ430_ID
#define TI_5052_BOOT_PRODUCT_ID
#define TI_5152_BOOT_PRODUCT_ID
#define TI_5052_EEPROM_PRODUCT_ID
#define TI_5052_FIRMWARE_PRODUCT_ID
#define FRI2_PRODUCT_ID

/* Multi-Tech vendor and product ids */
#define MTS_VENDOR_ID
#define MTS_GSM_NO_FW_PRODUCT_ID
#define MTS_CDMA_NO_FW_PRODUCT_ID
#define MTS_CDMA_PRODUCT_ID
#define MTS_GSM_PRODUCT_ID
#define MTS_EDGE_PRODUCT_ID
#define MTS_MT9234MU_PRODUCT_ID
#define MTS_MT9234ZBA_PRODUCT_ID
#define MTS_MT9234ZBAOLD_PRODUCT_ID

/* Abbott Diabetics vendor and product ids */
#define ABBOTT_VENDOR_ID
#define ABBOTT_STEREO_PLUG_ID
#define ABBOTT_PRODUCT_ID
#define ABBOTT_STRIP_PORT_ID

/* Honeywell vendor and product IDs */
#define HONEYWELL_VENDOR_ID
#define HONEYWELL_HGI80_PRODUCT_ID

/* Moxa UPORT 11x0 vendor and product IDs */
#define MXU1_VENDOR_ID
#define MXU1_1110_PRODUCT_ID
#define MXU1_1130_PRODUCT_ID
#define MXU1_1150_PRODUCT_ID
#define MXU1_1151_PRODUCT_ID
#define MXU1_1131_PRODUCT_ID

/* Commands */
#define TI_GET_VERSION
#define TI_GET_PORT_STATUS
#define TI_GET_PORT_DEV_INFO
#define TI_GET_CONFIG
#define TI_SET_CONFIG
#define TI_OPEN_PORT
#define TI_CLOSE_PORT
#define TI_START_PORT
#define TI_STOP_PORT
#define TI_TEST_PORT
#define TI_PURGE_PORT
#define TI_RESET_EXT_DEVICE
#define TI_WRITE_DATA
#define TI_READ_DATA
#define TI_REQ_TYPE_CLASS

/* Module identifiers */
#define TI_I2C_PORT
#define TI_IEEE1284_PORT
#define TI_UART1_PORT
#define TI_UART2_PORT
#define TI_RAM_PORT

/* Modem status */
#define TI_MSR_DELTA_CTS
#define TI_MSR_DELTA_DSR
#define TI_MSR_DELTA_RI
#define TI_MSR_DELTA_CD
#define TI_MSR_CTS
#define TI_MSR_DSR
#define TI_MSR_RI
#define TI_MSR_CD
#define TI_MSR_DELTA_MASK
#define TI_MSR_MASK

/* Line status */
#define TI_LSR_OVERRUN_ERROR
#define TI_LSR_PARITY_ERROR
#define TI_LSR_FRAMING_ERROR
#define TI_LSR_BREAK
#define TI_LSR_ERROR
#define TI_LSR_RX_FULL
#define TI_LSR_TX_EMPTY
#define TI_LSR_TX_EMPTY_BOTH

/* Line control */
#define TI_LCR_BREAK

/* Modem control */
#define TI_MCR_LOOP
#define TI_MCR_DTR
#define TI_MCR_RTS

/* Mask settings */
#define TI_UART_ENABLE_RTS_IN
#define TI_UART_DISABLE_RTS
#define TI_UART_ENABLE_PARITY_CHECKING
#define TI_UART_ENABLE_DSR_OUT
#define TI_UART_ENABLE_CTS_OUT
#define TI_UART_ENABLE_X_OUT
#define TI_UART_ENABLE_XA_OUT
#define TI_UART_ENABLE_X_IN
#define TI_UART_ENABLE_DTR_IN
#define TI_UART_DISABLE_DTR
#define TI_UART_ENABLE_MS_INTS
#define TI_UART_ENABLE_AUTO_START_DMA

/* Parity */
#define TI_UART_NO_PARITY
#define TI_UART_ODD_PARITY
#define TI_UART_EVEN_PARITY
#define TI_UART_MARK_PARITY
#define TI_UART_SPACE_PARITY

/* Stop bits */
#define TI_UART_1_STOP_BITS
#define TI_UART_1_5_STOP_BITS
#define TI_UART_2_STOP_BITS

/* Bits per character */
#define TI_UART_5_DATA_BITS
#define TI_UART_6_DATA_BITS
#define TI_UART_7_DATA_BITS
#define TI_UART_8_DATA_BITS

/* 232/485 modes */
#define TI_UART_232
#define TI_UART_485_RECEIVER_DISABLED
#define TI_UART_485_RECEIVER_ENABLED

/* Pipe transfer mode and timeout */
#define TI_PIPE_MODE_CONTINUOUS
#define TI_PIPE_MODE_MASK
#define TI_PIPE_TIMEOUT_MASK
#define TI_PIPE_TIMEOUT_ENABLE

/* Config struct */
struct ti_uart_config {};

/* Get port status */
struct ti_port_status {};

/* Purge modes */
#define TI_PURGE_OUTPUT
#define TI_PURGE_INPUT

/* Read/Write data */
#define TI_RW_DATA_ADDR_SFR
#define TI_RW_DATA_ADDR_IDATA
#define TI_RW_DATA_ADDR_XDATA
#define TI_RW_DATA_ADDR_CODE
#define TI_RW_DATA_ADDR_GPIO
#define TI_RW_DATA_ADDR_I2C
#define TI_RW_DATA_ADDR_FLASH
#define TI_RW_DATA_ADDR_DSP

#define TI_RW_DATA_UNSPECIFIED
#define TI_RW_DATA_BYTE
#define TI_RW_DATA_WORD
#define TI_RW_DATA_DOUBLE_WORD

struct ti_write_data_bytes {} __packed;

struct ti_read_data_request {} __packed;

struct ti_read_data_bytes {};

/* Interrupt struct */
struct ti_interrupt {};

/* Interrupt codes */
#define TI_CODE_HARDWARE_ERROR
#define TI_CODE_DATA_ERROR
#define TI_CODE_MODEM_STATUS

/* Download firmware max packet size */
#define TI_DOWNLOAD_MAX_PACKET_SIZE

/* Firmware image header */
struct ti_firmware_header {} __packed;

/* UART addresses */
#define TI_UART1_BASE_ADDR
#define TI_UART2_BASE_ADDR
#define TI_UART_OFFSET_LCR
#define TI_UART_OFFSET_MCR

#define TI_DRIVER_AUTHOR
#define TI_DRIVER_DESC

#define TI_FIRMWARE_BUF_SIZE

#define TI_TRANSFER_TIMEOUT

/* read urb states */
#define TI_READ_URB_RUNNING
#define TI_READ_URB_STOPPING
#define TI_READ_URB_STOPPED

#define TI_EXTRA_VID_PID_COUNT

struct ti_port {};

struct ti_device {};

static int ti_startup(struct usb_serial *serial);
static void ti_release(struct usb_serial *serial);
static int ti_port_probe(struct usb_serial_port *port);
static void ti_port_remove(struct usb_serial_port *port);
static int ti_open(struct tty_struct *tty, struct usb_serial_port *port);
static void ti_close(struct usb_serial_port *port);
static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
		const unsigned char *data, int count);
static unsigned int ti_write_room(struct tty_struct *tty);
static unsigned int ti_chars_in_buffer(struct tty_struct *tty);
static bool ti_tx_empty(struct usb_serial_port *port);
static void ti_throttle(struct tty_struct *tty);
static void ti_unthrottle(struct tty_struct *tty);
static void ti_set_termios(struct tty_struct *tty,
			   struct usb_serial_port *port,
			   const struct ktermios *old_termios);
static int ti_tiocmget(struct tty_struct *tty);
static int ti_tiocmset(struct tty_struct *tty,
		unsigned int set, unsigned int clear);
static int ti_break(struct tty_struct *tty, int break_state);
static void ti_interrupt_callback(struct urb *urb);
static void ti_bulk_in_callback(struct urb *urb);
static void ti_bulk_out_callback(struct urb *urb);

static void ti_recv(struct usb_serial_port *port, unsigned char *data,
		int length);
static void ti_send(struct ti_port *tport);
static int ti_set_mcr(struct ti_port *tport, unsigned int mcr);
static int ti_get_lsr(struct ti_port *tport, u8 *lsr);
static void ti_get_serial_info(struct tty_struct *tty, struct serial_struct *ss);
static void ti_handle_new_msr(struct ti_port *tport, u8 msr);

static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty);
static int ti_restart_read(struct ti_port *tport, struct tty_struct *tty);

static int ti_command_out_sync(struct usb_device *udev, u8 command,
		u16 moduleid, u16 value, void *data, int size);
static int ti_command_in_sync(struct usb_device *udev, u8 command,
		u16 moduleid, u16 value, void *data, int size);
static int ti_port_cmd_out(struct usb_serial_port *port, u8 command,
		u16 value, void *data, int size);
static int ti_port_cmd_in(struct usb_serial_port *port, u8 command,
		u16 value, void *data, int size);

static int ti_write_byte(struct usb_serial_port *port, struct ti_device *tdev,
			 unsigned long addr, u8 mask, u8 byte);

static int ti_download_firmware(struct ti_device *tdev);

static const struct usb_device_id ti_id_table_3410[] =;

static const struct usb_device_id ti_id_table_5052[] =;

static const struct usb_device_id ti_id_table_combined[] =;

static struct usb_serial_driver ti_1port_device =;

static struct usb_serial_driver ti_2port_device =;

static struct usb_serial_driver * const serial_drivers[] =;

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

MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();
MODULE_FIRMWARE();

MODULE_DEVICE_TABLE(usb, ti_id_table_combined);

module_usb_serial_driver();

static int ti_startup(struct usb_serial *serial)
{}


static void ti_release(struct usb_serial *serial)
{}

static int ti_port_probe(struct usb_serial_port *port)
{}

static void ti_port_remove(struct usb_serial_port *port)
{}

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


static void ti_close(struct usb_serial_port *port)
{}


static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
			const unsigned char *data, int count)
{}


static unsigned int ti_write_room(struct tty_struct *tty)
{}


static unsigned int ti_chars_in_buffer(struct tty_struct *tty)
{}

static bool ti_tx_empty(struct usb_serial_port *port)
{}

static void ti_throttle(struct tty_struct *tty)
{}


static void ti_unthrottle(struct tty_struct *tty)
{}

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


static int ti_tiocmget(struct tty_struct *tty)
{}


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


static int ti_break(struct tty_struct *tty, int break_state)
{}

static int ti_get_port_from_code(unsigned char code)
{}

static int ti_get_func_from_code(unsigned char code)
{}

static void ti_interrupt_callback(struct urb *urb)
{}


static void ti_bulk_in_callback(struct urb *urb)
{}


static void ti_bulk_out_callback(struct urb *urb)
{}


static void ti_recv(struct usb_serial_port *port, unsigned char *data,
		int length)
{}


static void ti_send(struct ti_port *tport)
{}


static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)
{}


static int ti_get_lsr(struct ti_port *tport, u8 *lsr)
{}


static void ti_get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
{}


static void ti_handle_new_msr(struct ti_port *tport, u8 msr)
{}


static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty)
{}


static int ti_restart_read(struct ti_port *tport, struct tty_struct *tty)
{}

static int ti_command_out_sync(struct usb_device *udev, u8 command,
		u16 moduleid, u16 value, void *data, int size)
{}

static int ti_command_in_sync(struct usb_device *udev, u8 command,
		u16 moduleid, u16 value, void *data, int size)
{}

static int ti_port_cmd_out(struct usb_serial_port *port, u8 command,
		u16 value, void *data, int size)
{}

static int ti_port_cmd_in(struct usb_serial_port *port, u8 command,
		u16 value, void *data, int size)
{}

static int ti_write_byte(struct usb_serial_port *port,
			 struct ti_device *tdev, unsigned long addr,
			 u8 mask, u8 byte)
{}

static int ti_do_download(struct usb_device *dev, int pipe,
						u8 *buffer, int size)
{}

static int ti_download_firmware(struct ti_device *tdev)
{}