linux/drivers/usb/serial/keyspan.c

// SPDX-License-Identifier: GPL-2.0+
/*
  Keyspan USB to Serial Converter driver

  (C) Copyright (C) 2000-2001	Hugh Blemings <[email protected]>
  (C) Copyright (C) 2002	Greg Kroah-Hartman <[email protected]>

  See http://blemings.org/hugh/keyspan.html for more information.

  Code in this driver inspired by and in a number of places taken
  from Brian Warner's original Keyspan-PDA driver.

  This driver has been put together with the support of Innosys, Inc.
  and Keyspan, Inc the manufacturers of the Keyspan USB-serial products.
  Thanks Guys :)

  Thanks to Paulus for miscellaneous tidy ups, some largish chunks
  of much nicer and/or completely new code and (perhaps most uniquely)
  having the patience to sit down and explain why and where he'd changed
  stuff.

  Tip 'o the hat to IBM (and previously Linuxcare :) for supporting
  staff in their work on open source projects.
*/


#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/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
#include <linux/usb/ezusb.h>

#define DRIVER_AUTHOR
#define DRIVER_DESC

static void keyspan_send_setup(struct usb_serial_port *port, int reset_port);

static int keyspan_usa19_calc_baud(struct usb_serial_port *port,
				   u32 baud_rate, u32 baudclk,
				   u8 *rate_hi, u8 *rate_low,
				   u8 *prescaler, int portnum);
static int keyspan_usa19w_calc_baud(struct usb_serial_port *port,
				    u32 baud_rate, u32 baudclk,
				    u8 *rate_hi, u8 *rate_low,
				    u8 *prescaler, int portnum);
static int keyspan_usa28_calc_baud(struct usb_serial_port *port,
				   u32 baud_rate, u32 baudclk,
				   u8 *rate_hi, u8 *rate_low,
				   u8 *prescaler, int portnum);
static int keyspan_usa19hs_calc_baud(struct usb_serial_port *port,
				     u32 baud_rate, u32 baudclk,
				     u8 *rate_hi, u8 *rate_low,
				     u8 *prescaler, int portnum);

static int keyspan_usa28_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port);
static int keyspan_usa26_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port);
static int keyspan_usa49_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port);
static int keyspan_usa90_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port);
static int keyspan_usa67_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port);

/* Values used for baud rate calculation - device specific */
#define KEYSPAN_INVALID_BAUD_RATE
#define KEYSPAN_BAUD_RATE_OK
#define KEYSPAN_USA18X_BAUDCLK
#define KEYSPAN_USA19_BAUDCLK
#define KEYSPAN_USA19W_BAUDCLK
#define KEYSPAN_USA19HS_BAUDCLK
#define KEYSPAN_USA28_BAUDCLK
#define KEYSPAN_USA28X_BAUDCLK
#define KEYSPAN_USA49W_BAUDCLK

/* Some constants used to characterise each device.  */
#define KEYSPAN_MAX_NUM_PORTS
#define KEYSPAN_MAX_FLIPS

/*
 * Device info for the Keyspan serial converter, used by the overall
 * usb-serial probe function.
 */
#define KEYSPAN_VENDOR_ID

/* Product IDs for the products supported, pre-renumeration */
#define keyspan_usa18x_pre_product_id
#define keyspan_usa19_pre_product_id
#define keyspan_usa19qi_pre_product_id
#define keyspan_mpr_pre_product_id
#define keyspan_usa19qw_pre_product_id
#define keyspan_usa19w_pre_product_id
#define keyspan_usa28_pre_product_id
#define keyspan_usa28x_pre_product_id
#define keyspan_usa28xa_pre_product_id
#define keyspan_usa28xb_pre_product_id
#define keyspan_usa49w_pre_product_id
#define keyspan_usa49wlc_pre_product_id

/*
 * Product IDs post-renumeration.  Note that the 28x and 28xb have the same
 * id's post-renumeration but behave identically so it's not an issue. As
 * such, the 28xb is not listed in any of the device tables.
 */
#define keyspan_usa18x_product_id
#define keyspan_usa19_product_id
#define keyspan_usa19qi_product_id
#define keyspan_usa19hs_product_id
#define keyspan_mpr_product_id
#define keyspan_usa19qw_product_id
#define keyspan_usa19w_product_id
#define keyspan_usa28_product_id
#define keyspan_usa28x_product_id
#define keyspan_usa28xa_product_id
#define keyspan_usa28xb_product_id
#define keyspan_usa28xg_product_id
#define keyspan_usa49w_product_id
#define keyspan_usa49wlc_product_id
#define keyspan_usa49wg_product_id

struct keyspan_device_details {};

/*
 * Now for each device type we setup the device detail structure with the
 * appropriate information (provided in Keyspan's documentation)
 */

static const struct keyspan_device_details usa18x_device_details =;

static const struct keyspan_device_details usa19_device_details =;

static const struct keyspan_device_details usa19qi_device_details =;

static const struct keyspan_device_details mpr_device_details =;

static const struct keyspan_device_details usa19qw_device_details =;

static const struct keyspan_device_details usa19w_device_details =;

static const struct keyspan_device_details usa19hs_device_details =;

static const struct keyspan_device_details usa28_device_details =;

static const struct keyspan_device_details usa28x_device_details =;

static const struct keyspan_device_details usa28xa_device_details =;

static const struct keyspan_device_details usa28xg_device_details =;
/*
 * We don't need a separate entry for the usa28xb as it appears as a 28x
 * anyway.
 */

static const struct keyspan_device_details usa49w_device_details =;

static const struct keyspan_device_details usa49wlc_device_details =;

static const struct keyspan_device_details usa49wg_device_details =;

static const struct keyspan_device_details *keyspan_devices[] =;

static const struct usb_device_id keyspan_ids_combined[] =;

MODULE_DEVICE_TABLE(usb, keyspan_ids_combined);

/* usb_device_id table for the pre-firmware download keyspan devices */
static const struct usb_device_id keyspan_pre_ids[] =;

static const struct usb_device_id keyspan_1port_ids[] =;

static const struct usb_device_id keyspan_2port_ids[] =;

static const struct usb_device_id keyspan_4port_ids[] =;

#define INSTAT_BUFLEN
#define GLOCONT_BUFLEN
#define INDAT49W_BUFLEN
#define IN_BUFLEN
#define OUT_BUFLEN
#define INACK_BUFLEN
#define OUTCONT_BUFLEN

	/* Per device and per port private data */
struct keyspan_serial_private {};

struct keyspan_port_private {};

/* Include Keyspan message headers.  All current Keyspan Adapters
   make use of one of five message formats which are referred
   to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and
   within this driver. */
#include "keyspan_usa26msg.h"
#include "keyspan_usa28msg.h"
#include "keyspan_usa49msg.h"
#include "keyspan_usa90msg.h"
#include "keyspan_usa67msg.h"


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


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

static int keyspan_tiocmget(struct tty_struct *tty)
{}

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

/* Write function is similar for the four protocols used
   with only a minor change for usa90 (usa19hs) required */
static int keyspan_write(struct tty_struct *tty,
	struct usb_serial_port *port, const unsigned char *buf, int count)
{}

static void	usa26_indat_callback(struct urb *urb)
{}

/* Outdat handling is common for all devices */
static void	usa2x_outdat_callback(struct urb *urb)
{}

static void	usa26_inack_callback(struct urb *urb)
{}

static void	usa26_outcont_callback(struct urb *urb)
{}

static void	usa26_instat_callback(struct urb *urb)
{}

static void	usa26_glocont_callback(struct urb *urb)
{}


static void usa28_indat_callback(struct urb *urb)
{}

static void	usa28_inack_callback(struct urb *urb)
{}

static void	usa28_outcont_callback(struct urb *urb)
{}

static void	usa28_instat_callback(struct urb *urb)
{}

static void	usa28_glocont_callback(struct urb *urb)
{}


static void	usa49_glocont_callback(struct urb *urb)
{}

	/* This is actually called glostat in the Keyspan
	   doco */
static void	usa49_instat_callback(struct urb *urb)
{}

static void	usa49_inack_callback(struct urb *urb)
{}

static void	usa49_indat_callback(struct urb *urb)
{}

static void usa49wg_indat_callback(struct urb *urb)
{}

/* not used, usa-49 doesn't have per-port control endpoints */
static void usa49_outcont_callback(struct urb *urb)
{}

static void usa90_indat_callback(struct urb *urb)
{}


static void	usa90_instat_callback(struct urb *urb)
{}

static void	usa90_outcont_callback(struct urb *urb)
{}

/* Status messages from the 28xg */
static void	usa67_instat_callback(struct urb *urb)
{}

static void usa67_glocont_callback(struct urb *urb)
{}

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


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

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

static void keyspan_close(struct usb_serial_port *port)
{}

/* download the firmware to a pre-renumeration device */
static int keyspan_fake_startup(struct usb_serial *serial)
{}

/* Helper functions used by keyspan_setup_urbs */
static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *serial,
						     int endpoint)
{}

static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
				      int dir, void *ctx, char *buf, int len,
				      void (*callback)(struct urb *))
{}

static struct callbacks {} keyspan_callbacks[] =;

	/* Generic setup urbs function that uses
	   data in device_details */
static void keyspan_setup_urbs(struct usb_serial *serial)
{}

/* usa19 function doesn't require prescaler */
static int keyspan_usa19_calc_baud(struct usb_serial_port *port,
				   u32 baud_rate, u32 baudclk, u8 *rate_hi,
				   u8 *rate_low, u8 *prescaler, int portnum)
{}

/* usa19hs function doesn't require prescaler */
static int keyspan_usa19hs_calc_baud(struct usb_serial_port *port,
				     u32 baud_rate, u32 baudclk, u8 *rate_hi,
				     u8 *rate_low, u8 *prescaler, int portnum)
{}

static int keyspan_usa19w_calc_baud(struct usb_serial_port *port,
				    u32 baud_rate, u32 baudclk, u8 *rate_hi,
				    u8 *rate_low, u8 *prescaler, int portnum)
{}

	/* USA-28 supports different maximum baud rates on each port */
static int keyspan_usa28_calc_baud(struct usb_serial_port *port,
				   u32 baud_rate, u32 baudclk, u8 *rate_hi,
				   u8 *rate_low, u8 *prescaler, int portnum)
{}

static int keyspan_usa26_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port)
{}

static int keyspan_usa28_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port)
{}

static int keyspan_usa49_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port)
{}

static int keyspan_usa90_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port)
{}

static int keyspan_usa67_send_setup(struct usb_serial *serial,
				    struct usb_serial_port *port,
				    int reset_port)
{}

static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
{}


/* Gets called by the "real" driver (ie once firmware is loaded
   and renumeration has taken place. */
static int keyspan_startup(struct usb_serial *serial)
{}

static void keyspan_disconnect(struct usb_serial *serial)
{}

static void keyspan_release(struct usb_serial *serial)
{}

static int keyspan_port_probe(struct usb_serial_port *port)
{}

static void keyspan_port_remove(struct usb_serial_port *port)
{}

/* Structs for the devices, pre and post renumeration. */
static struct usb_serial_driver keyspan_pre_device =;

static struct usb_serial_driver keyspan_1port_device =;

static struct usb_serial_driver keyspan_2port_device =;

static struct usb_serial_driver keyspan_4port_device =;

static struct usb_serial_driver * const serial_drivers[] =;

module_usb_serial_driver();

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();