linux/drivers/usb/serial/mos7720.c

// SPDX-License-Identifier: GPL-2.0
/*
 * mos7720.c
 *   Controls the Moschip 7720 usb to dual port serial converter
 *
 * Copyright 2006 Moschip Semiconductor Tech. Ltd.
 *
 * Developed by:
 * 	Vijaya Kumar <[email protected]>
 *	Ajay Kumar <[email protected]>
 *	Gurudeva <[email protected]>
 *
 * Cleaned up from the original by:
 *	Greg Kroah-Hartman <[email protected]>
 *
 * Originally based on drivers/usb/serial/io_edgeport.c which is:
 *	Copyright (C) 2000 Inside Out Networks, All rights reserved.
 *	Copyright (C) 2001-2002 Greg Kroah-Hartman <[email protected]>
 */
#include <linux/kernel.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/serial.h>
#include <linux/serial_reg.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
#include <linux/uaccess.h>
#include <linux/parport.h>

#define DRIVER_AUTHOR
#define DRIVER_DESC

/* default urb timeout */
#define MOS_WDR_TIMEOUT

#define MOS_MAX_PORT
#define MOS_WRITE
#define MOS_READ

/* Interrupt Routines Defines	*/
#define SERIAL_IIR_RLS
#define SERIAL_IIR_RDA
#define SERIAL_IIR_CTI
#define SERIAL_IIR_THR
#define SERIAL_IIR_MS

#define NUM_URBS
#define URB_TRANSFER_BUFFER_SIZE

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

#define USB_VENDOR_ID_MOSCHIP
#define MOSCHIP_DEVICE_ID_7720
#define MOSCHIP_DEVICE_ID_7715

static const struct usb_device_id id_table[] =;
MODULE_DEVICE_TABLE(usb, id_table);

#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT

/* initial values for parport regs */
#define DCR_INIT_VAL
#define ECR_INIT_VAL

enum mos7715_pp_modes {};

struct mos7715_parport {};

/* lock guards against dereferencing NULL ptr in parport ops callbacks */
static DEFINE_SPINLOCK(release_lock);

#endif	/* CONFIG_USB_SERIAL_MOS7715_PARPORT */

static const unsigned int dummy; /* for clarity in register access fns */

enum mos_regs {};

/*
 * Return the correct value for the Windex field of the setup packet
 * for a control endpoint message.  See the 7715 datasheet.
 */
static inline __u16 get_reg_index(enum mos_regs reg)
{}

/*
 * Return the correct value for the upper byte of the Wvalue field of
 * the setup packet for a control endpoint message.
 */
static inline __u16 get_reg_value(enum mos_regs reg,
				  unsigned int serial_portnum)
{}

/*
 * Write data byte to the specified device register.  The data is embedded in
 * the value field of the setup packet. serial_portnum is ignored for registers
 * not specific to a particular serial port.
 */
static int write_mos_reg(struct usb_serial *serial, unsigned int serial_portnum,
			 enum mos_regs reg, __u8 data)
{}

/*
 * Read data byte from the specified device register.  The data returned by the
 * device is embedded in the value field of the setup packet.  serial_portnum is
 * ignored for registers that are not specific to a particular serial port.
 */
static int read_mos_reg(struct usb_serial *serial, unsigned int serial_portnum,
			enum mos_regs reg, __u8 *data)
{}

#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT

static inline int mos7715_change_mode(struct mos7715_parport *mos_parport,
				      enum mos7715_pp_modes mode)
{}

static void destroy_mos_parport(struct kref *kref)
{}

/*
 * This is the common top part of all parallel port callback operations that
 * send synchronous messages to the device.  This implements convoluted locking
 * that avoids two scenarios: (1) a port operation is called after usbserial
 * has called our release function, at which point struct mos7715_parport has
 * been destroyed, and (2) the device has been disconnected, but usbserial has
 * not called the release function yet because someone has a serial port open.
 * The shared release_lock prevents the first, and the mutex and disconnected
 * flag maintained by usbserial covers the second.  We also use the msg_pending
 * flag to ensure that all synchronous usb message calls have completed before
 * our release function can return.
 */
static int parport_prologue(struct parport *pp)
{}

/*
 * This is the common bottom part of all parallel port functions that send
 * synchronous messages to the device.
 */
static inline void parport_epilogue(struct parport *pp)
{}

static void deferred_restore_writes(struct work_struct *work)
{}

static void parport_mos7715_write_data(struct parport *pp, unsigned char d)
{}

static unsigned char parport_mos7715_read_data(struct parport *pp)
{}

static void parport_mos7715_write_control(struct parport *pp, unsigned char d)
{}

static unsigned char parport_mos7715_read_control(struct parport *pp)
{}

static unsigned char parport_mos7715_frob_control(struct parport *pp,
						  unsigned char mask,
						  unsigned char val)
{}

static unsigned char parport_mos7715_read_status(struct parport *pp)
{}

static void parport_mos7715_enable_irq(struct parport *pp)
{}

static void parport_mos7715_disable_irq(struct parport *pp)
{}

static void parport_mos7715_data_forward(struct parport *pp)
{}

static void parport_mos7715_data_reverse(struct parport *pp)
{}

static void parport_mos7715_init_state(struct pardevice *dev,
				       struct parport_state *s)
{}

/* N.B. Parport core code requires that this function not block */
static void parport_mos7715_save_state(struct parport *pp,
				       struct parport_state *s)
{}

/* N.B. Parport core code requires that this function not block */
static void parport_mos7715_restore_state(struct parport *pp,
					  struct parport_state *s)
{}

static size_t parport_mos7715_write_compat(struct parport *pp,
					   const void *buffer,
					   size_t len, int flags)
{}

static struct parport_operations parport_mos7715_ops =;

/*
 * Allocate and initialize parallel port control struct, initialize
 * the parallel port hardware device, and register with the parport subsystem.
 */
static int mos7715_parport_init(struct usb_serial *serial)
{}
#endif	/* CONFIG_USB_SERIAL_MOS7715_PARPORT */

/*
 * mos7720_interrupt_callback
 *	this is the callback function for when we have received data on the
 *	interrupt endpoint.
 */
static void mos7720_interrupt_callback(struct urb *urb)
{}

/*
 * mos7715_interrupt_callback
 *	this is the 7715's callback function for when we have received data on
 *	the interrupt endpoint.
 */
static void mos7715_interrupt_callback(struct urb *urb)
{}

/*
 * mos7720_bulk_in_callback
 *	this is the callback function for when we have received data on the
 *	bulk in endpoint.
 */
static void mos7720_bulk_in_callback(struct urb *urb)
{}

/*
 * mos7720_bulk_out_data_callback
 *	this is the callback function for when we have finished sending serial
 *	data on the bulk out endpoint.
 */
static void mos7720_bulk_out_data_callback(struct urb *urb)
{}

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

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

/*
 * mos7720_chars_in_buffer
 *	this function is called by the tty driver when it wants to know how many
 *	bytes of data we currently have outstanding in the port (data that has
 *	been written, but hasn't made it out the port yet)
 */
static unsigned int mos7720_chars_in_buffer(struct tty_struct *tty)
{}

static void mos7720_close(struct usb_serial_port *port)
{}

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

/*
 * mos7720_write_room
 *	this function is called by the tty driver when it wants to know how many
 *	bytes of data we can accept for a specific port.
 */
static unsigned int mos7720_write_room(struct tty_struct *tty)
{}

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

static void mos7720_throttle(struct tty_struct *tty)
{}

static void mos7720_unthrottle(struct tty_struct *tty)
{}

/* FIXME: this function does not work */
static int set_higher_rates(struct moschip_port *mos7720_port,
			    unsigned int baud)
{}

/* baud rate information */
struct divisor_table_entry {};

/* Define table of divisors for moschip 7720 hardware	   *
 * These assume a 3.6864MHz crystal, the standard /16, and *
 * MCR.7 = 0.						   */
static const struct divisor_table_entry divisor_table[] =;

/*****************************************************************************
 * calc_baud_rate_divisor
 *	this function calculates the proper baud rate divisor for the specified
 *	baud rate.
 *****************************************************************************/
static int calc_baud_rate_divisor(struct usb_serial_port *port, int baudrate, int *divisor)
{}

/*
 * send_cmd_write_baud_rate
 *	this function sends the proper command to change the baud rate of the
 *	specified port.
 */
static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
				    int baudrate)
{}

/*
 * change_port_settings
 *	This routine is called to set the UART on the device to match
 *      the specified new settings.
 */
static void change_port_settings(struct tty_struct *tty,
				 struct moschip_port *mos7720_port,
				 const struct ktermios *old_termios)
{}

/*
 * mos7720_set_termios
 *	this function is called by the tty driver when it wants to change the
 *	termios structure.
 */
static void mos7720_set_termios(struct tty_struct *tty,
				struct usb_serial_port *port,
				const struct ktermios *old_termios)
{}

/*
 * get_lsr_info - get line status register info
 *
 * Purpose: Let user call ioctl() to get info when the UART physically
 * 	    is emptied.  On bus types like RS485, the transmitter must
 * 	    release the bus after transmitting. This must be done when
 * 	    the transmit shift register is empty, not be done when the
 * 	    transmit holding register is empty.  This functionality
 * 	    allows an RS485 driver to be written in user space.
 */
static int get_lsr_info(struct tty_struct *tty,
		struct moschip_port *mos7720_port, unsigned int __user *value)
{}

static int mos7720_tiocmget(struct tty_struct *tty)
{}

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

static int mos7720_ioctl(struct tty_struct *tty,
			 unsigned int cmd, unsigned long arg)
{}

static int mos7720_startup(struct usb_serial *serial)
{}

static void mos7720_release(struct usb_serial *serial)
{}

static int mos7720_port_probe(struct usb_serial_port *port)
{}

static void mos7720_port_remove(struct usb_serial_port *port)
{}

static struct usb_serial_driver moschip7720_2port_driver =;

static struct usb_serial_driver * const serial_drivers[] =;

module_usb_serial_driver();

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