linux/drivers/usb/serial/io_ti.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Edgeport USB Serial Converter driver
 *
 * Copyright (C) 2000-2002 Inside Out Networks, All rights reserved.
 * Copyright (C) 2001-2002 Greg Kroah-Hartman <[email protected]>
 *
 * Supports the following devices:
 *	EP/1 EP/2 EP/4 EP/21 EP/22 EP/221 EP/42 EP/421 WATCHPORT
 *
 * For questions or problems with this driver, contact Inside Out
 * Networks technical support, or Peter Berger <[email protected]>,
 * or Al Borchers <[email protected]>.
 */

#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/errno.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/mutex.h>
#include <linux/serial.h>
#include <linux/swab.h>
#include <linux/kfifo.h>
#include <linux/ioctl.h>
#include <linux/firmware.h>
#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>

#include "io_16654.h"
#include "io_usbvend.h"
#include "io_ti.h"

#define DRIVER_AUTHOR
#define DRIVER_DESC

#define EPROM_PAGE_SIZE


/* different hardware types */
#define HARDWARE_TYPE_930
#define HARDWARE_TYPE_TIUMP

/* IOCTL_PRIVATE_TI_GET_MODE Definitions */
#define TI_MODE_CONFIGURING
#define TI_MODE_BOOT
#define TI_MODE_DOWNLOAD
#define TI_MODE_TRANSITIONING

/* read urb state */
#define EDGE_READ_URB_RUNNING
#define EDGE_READ_URB_STOPPING
#define EDGE_READ_URB_STOPPED


/* Product information read from the Edgeport */
struct product_info {} __packed;

/*
 * Edgeport firmware header
 *
 * "build_number" has been set to 0 in all three of the images I have
 * seen, and Digi Tech Support suggests that it is safe to ignore it.
 *
 * "length" is the number of bytes of actual data following the header.
 *
 * "checksum" is the low order byte resulting from adding the values of
 * all the data bytes.
 */
struct edgeport_fw_hdr {} __packed;

struct edgeport_port {};

struct edgeport_serial {};


/* Devices that this driver supports */
static const struct usb_device_id edgeport_1port_id_table[] =;

static const struct usb_device_id edgeport_2port_id_table[] =;

/* Devices that this driver supports */
static const struct usb_device_id id_table_combined[] =;

MODULE_DEVICE_TABLE(usb, id_table_combined);

static bool ignore_cpu_rev;
static int default_uart_mode;		/* RS232 */

static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data,
		int length);

static void stop_read(struct edgeport_port *edge_port);
static int restart_read(struct edgeport_port *edge_port);

static void edge_set_termios(struct tty_struct *tty,
			     struct usb_serial_port *port,
			     const struct ktermios *old_termios);
static void edge_send(struct usb_serial_port *port, struct tty_struct *tty);

static int do_download_mode(struct edgeport_serial *serial,
		const struct firmware *fw);
static int do_boot_mode(struct edgeport_serial *serial,
		const struct firmware *fw);

/* sysfs attributes */
static int edge_create_sysfs_attrs(struct usb_serial_port *port);
static int edge_remove_sysfs_attrs(struct usb_serial_port *port);

/*
 * Some release of Edgeport firmware "down3.bin" after version 4.80
 * introduced code to automatically disconnect idle devices on some
 * Edgeport models after periods of inactivity, typically ~60 seconds.
 * This occurs without regard to whether ports on the device are open
 * or not.  Digi International Tech Support suggested:
 *
 * 1.  Adding driver "heartbeat" code to reset the firmware timer by
 *     requesting a descriptor record every 15 seconds, which should be
 *     effective with newer firmware versions that require it, and benign
 *     with older versions that do not. In practice 40 seconds seems often
 *     enough.
 * 2.  The heartbeat code is currently required only on Edgeport/416 models.
 */
#define FW_HEARTBEAT_VERSION_CUTOFF
#define FW_HEARTBEAT_SECS

/* Timeouts in msecs: firmware downloads take longer */
#define TI_VSEND_TIMEOUT_DEFAULT
#define TI_VSEND_TIMEOUT_FW_DOWNLOAD

static int ti_vread_sync(struct usb_device *dev, u8 request, u16 value,
		u16 index, void *data, int size)
{}

static int ti_vsend_sync(struct usb_device *dev, u8 request, u16 value,
		u16 index, void *data, int size, int timeout)
{}

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

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

/* clear tx/rx buffers and fifo in TI UMP */
static int purge_port(struct usb_serial_port *port, u16 mask)
{}

/**
 * read_download_mem - Read edgeport memory from TI chip
 * @dev: usb device pointer
 * @start_address: Device CPU address at which to read
 * @length: Length of above data
 * @address_type: Can read both XDATA and I2C
 * @buffer: pointer to input data buffer
 */
static int read_download_mem(struct usb_device *dev, int start_address,
				int length, u8 address_type, u8 *buffer)
{}

static int read_ram(struct usb_device *dev, int start_address,
						int length, u8 *buffer)
{}

/* Read edgeport memory to a given block */
static int read_boot_mem(struct edgeport_serial *serial,
				int start_address, int length, u8 *buffer)
{}

/* Write given block to TI EPROM memory */
static int write_boot_mem(struct edgeport_serial *serial,
				int start_address, int length, u8 *buffer)
{}

/* Write edgeport I2C memory to TI chip	*/
static int write_i2c_mem(struct edgeport_serial *serial,
		int start_address, int length, u8 address_type, u8 *buffer)
{}

/*
 * Examine the UMP DMA registers and LSR
 *
 * Check the MSBit of the X and Y DMA byte count registers.
 * A zero in this bit indicates that the TX DMA buffers are empty
 * then check the TX Empty bit in the UART.
 */
static int tx_active(struct edgeport_port *port)
{}

static int choose_config(struct usb_device *dev)
{}

static int read_rom(struct edgeport_serial *serial,
				int start_address, int length, u8 *buffer)
{}

static int write_rom(struct edgeport_serial *serial, int start_address,
						int length, u8 *buffer)
{}

/* Read a descriptor header from I2C based on type */
static int get_descriptor_addr(struct edgeport_serial *serial,
				int desc_type, struct ti_i2c_desc *rom_desc)
{}

/* Validate descriptor checksum */
static int valid_csum(struct ti_i2c_desc *rom_desc, u8 *buffer)
{}

/* Make sure that the I2C image is good */
static int check_i2c_image(struct edgeport_serial *serial)
{}

static int get_manuf_info(struct edgeport_serial *serial, u8 *buffer)
{}

/* Build firmware header used for firmware update */
static int build_i2c_fw_hdr(u8 *header, const struct firmware *fw)
{}

/* Try to figure out what type of I2c we have */
static int i2c_type_bootmode(struct edgeport_serial *serial)
{}

static int bulk_xfer(struct usb_serial *serial, void *buffer,
						int length, int *num_sent)
{}

/* Download given firmware image to the device (IN BOOT MODE) */
static int download_code(struct edgeport_serial *serial, u8 *image,
							int image_length)
{}

/* FIXME!!! */
static int config_boot_dev(struct usb_device *dev)
{}

static int ti_cpu_rev(struct edge_ti_manuf_descriptor *desc)
{}

static int check_fw_sanity(struct edgeport_serial *serial,
		const struct firmware *fw)
{}

/*
 * DownloadTIFirmware - Download run-time operating firmware to the TI5052
 *
 * This routine downloads the main operating code into the TI5052, using the
 * boot code already burned into E2PROM or ROM.
 */
static int download_fw(struct edgeport_serial *serial)
{}

static int do_download_mode(struct edgeport_serial *serial,
		const struct firmware *fw)
{}

static int do_boot_mode(struct edgeport_serial *serial,
		const struct firmware *fw)
{}

static int ti_do_config(struct edgeport_port *port, int feature, int on)
{}

static int restore_mcr(struct edgeport_port *port, u8 mcr)
{}

/* Convert TI LSR to standard UART flags */
static u8 map_line_status(u8 ti_lsr)
{}

static void handle_new_msr(struct edgeport_port *edge_port, u8 msr)
{}

static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
							u8 lsr, u8 data)
{}

static void edge_interrupt_callback(struct urb *urb)
{}

static void edge_bulk_in_callback(struct urb *urb)
{}

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

static void edge_bulk_out_callback(struct urb *urb)
{}

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

static void edge_close(struct usb_serial_port *port)
{}

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

static void edge_send(struct usb_serial_port *port, struct tty_struct *tty)
{}

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

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

static bool edge_tx_empty(struct usb_serial_port *port)
{}

static void edge_throttle(struct tty_struct *tty)
{}

static void edge_unthrottle(struct tty_struct *tty)
{}

static void stop_read(struct edgeport_port *edge_port)
{}

static int restart_read(struct edgeport_port *edge_port)
{}

static void change_port_settings(struct tty_struct *tty,
		struct edgeport_port *edge_port, const struct ktermios *old_termios)
{}

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

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

static int edge_tiocmget(struct tty_struct *tty)
{}

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

static void edge_heartbeat_schedule(struct edgeport_serial *edge_serial)
{}

static void edge_heartbeat_work(struct work_struct *work)
{}

static int edge_calc_num_ports(struct usb_serial *serial,
				struct usb_serial_endpoints *epds)
{}

static int edge_startup(struct usb_serial *serial)
{}

static void edge_disconnect(struct usb_serial *serial)
{}

static void edge_release(struct usb_serial *serial)
{}

static int edge_port_probe(struct usb_serial_port *port)
{}

static void edge_port_remove(struct usb_serial_port *port)
{}

/* Sysfs Attributes */

static ssize_t uart_mode_show(struct device *dev,
	struct device_attribute *attr, char *buf)
{}

static ssize_t uart_mode_store(struct device *dev,
	struct device_attribute *attr, const char *valbuf, size_t count)
{}
static DEVICE_ATTR_RW(uart_mode);

static int edge_create_sysfs_attrs(struct usb_serial_port *port)
{}

static int edge_remove_sysfs_attrs(struct usb_serial_port *port)
{}

#ifdef CONFIG_PM
static int edge_suspend(struct usb_serial *serial, pm_message_t message)
{}

static int edge_resume(struct usb_serial *serial)
{}
#endif

static struct usb_serial_driver edgeport_1port_device =;

static struct usb_serial_driver edgeport_2port_device =;

static struct usb_serial_driver * const serial_drivers[] =;

module_usb_serial_driver();

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

module_param(ignore_cpu_rev, bool, 0644);
MODULE_PARM_DESC();

module_param(default_uart_mode, int, 0644);
MODULE_PARM_DESC();