2017-11-03 18:28:30 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
Keyspan USB to Serial Converter driver
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
(C) Copyright (C) 2000-2001 Hugh Blemings <hugh@blemings.org>
|
|
|
|
(C) Copyright (C) 2002 Greg Kroah-Hartman <greg@kroah.com>
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2010-10-18 17:03:14 +08:00
|
|
|
See http://blemings.org/hugh/keyspan.html for more information.
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
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 :)
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
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
|
2008-07-22 18:13:08 +08:00
|
|
|
stuff.
|
|
|
|
|
|
|
|
Tip 'o the hat to IBM (and previously Linuxcare :) for supporting
|
2005-04-17 06:20:36 +08:00
|
|
|
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>
|
2008-07-22 18:13:08 +08:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/usb.h>
|
2006-07-12 12:22:58 +08:00
|
|
|
#include <linux/usb/serial.h>
|
2012-09-18 15:00:41 +08:00
|
|
|
#include <linux/usb/ezusb.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define DRIVER_AUTHOR "Hugh Blemings <hugh@misc.nu"
|
|
|
|
#define DRIVER_DESC "Keyspan USB to Serial Converter Driver"
|
|
|
|
|
2017-02-15 18:09:51 +08:00
|
|
|
/* Function prototypes for Keyspan serial converter */
|
|
|
|
static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port);
|
|
|
|
static void keyspan_close(struct usb_serial_port *port);
|
|
|
|
static void keyspan_dtr_rts(struct usb_serial_port *port, int on);
|
|
|
|
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 int keyspan_port_remove(struct usb_serial_port *port);
|
|
|
|
static int keyspan_write_room(struct tty_struct *tty);
|
|
|
|
static int keyspan_write(struct tty_struct *tty, struct usb_serial_port *port,
|
|
|
|
const unsigned char *buf, int count);
|
|
|
|
static void keyspan_send_setup(struct usb_serial_port *port, int reset_port);
|
|
|
|
static void keyspan_set_termios(struct tty_struct *tty,
|
|
|
|
struct usb_serial_port *port,
|
|
|
|
struct ktermios *old);
|
|
|
|
static void keyspan_break_ctl(struct tty_struct *tty, int break_state);
|
|
|
|
static int keyspan_tiocmget(struct tty_struct *tty);
|
|
|
|
static int keyspan_tiocmset(struct tty_struct *tty, unsigned int set,
|
|
|
|
unsigned int clear);
|
|
|
|
static int keyspan_fake_startup(struct usb_serial *serial);
|
|
|
|
|
|
|
|
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 (-1)
|
|
|
|
#define KEYSPAN_BAUD_RATE_OK (0)
|
|
|
|
#define KEYSPAN_USA18X_BAUDCLK (12000000L) /* a guess */
|
|
|
|
#define KEYSPAN_USA19_BAUDCLK (12000000L)
|
|
|
|
#define KEYSPAN_USA19W_BAUDCLK (24000000L)
|
|
|
|
#define KEYSPAN_USA19HS_BAUDCLK (14769231L)
|
|
|
|
#define KEYSPAN_USA28_BAUDCLK (1843200L)
|
|
|
|
#define KEYSPAN_USA28X_BAUDCLK (12000000L)
|
|
|
|
#define KEYSPAN_USA49W_BAUDCLK (48000000L)
|
|
|
|
|
|
|
|
/* Some constants used to characterise each device. */
|
|
|
|
#define KEYSPAN_MAX_NUM_PORTS (4)
|
|
|
|
#define KEYSPAN_MAX_FLIPS (2)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Device info for the Keyspan serial converter, used by the overall
|
|
|
|
* usb-serial probe function.
|
|
|
|
*/
|
|
|
|
#define KEYSPAN_VENDOR_ID (0x06cd)
|
|
|
|
|
|
|
|
/* Product IDs for the products supported, pre-renumeration */
|
|
|
|
#define keyspan_usa18x_pre_product_id 0x0105
|
|
|
|
#define keyspan_usa19_pre_product_id 0x0103
|
|
|
|
#define keyspan_usa19qi_pre_product_id 0x010b
|
|
|
|
#define keyspan_mpr_pre_product_id 0x011b
|
|
|
|
#define keyspan_usa19qw_pre_product_id 0x0118
|
|
|
|
#define keyspan_usa19w_pre_product_id 0x0106
|
|
|
|
#define keyspan_usa28_pre_product_id 0x0101
|
|
|
|
#define keyspan_usa28x_pre_product_id 0x0102
|
|
|
|
#define keyspan_usa28xa_pre_product_id 0x0114
|
|
|
|
#define keyspan_usa28xb_pre_product_id 0x0113
|
|
|
|
#define keyspan_usa49w_pre_product_id 0x0109
|
|
|
|
#define keyspan_usa49wlc_pre_product_id 0x011a
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 0x0112
|
|
|
|
#define keyspan_usa19_product_id 0x0107
|
|
|
|
#define keyspan_usa19qi_product_id 0x010c
|
|
|
|
#define keyspan_usa19hs_product_id 0x0121
|
|
|
|
#define keyspan_mpr_product_id 0x011c
|
|
|
|
#define keyspan_usa19qw_product_id 0x0119
|
|
|
|
#define keyspan_usa19w_product_id 0x0108
|
|
|
|
#define keyspan_usa28_product_id 0x010f
|
|
|
|
#define keyspan_usa28x_product_id 0x0110
|
|
|
|
#define keyspan_usa28xa_product_id 0x0115
|
|
|
|
#define keyspan_usa28xb_product_id 0x0110
|
|
|
|
#define keyspan_usa28xg_product_id 0x0135
|
|
|
|
#define keyspan_usa49w_product_id 0x010a
|
|
|
|
#define keyspan_usa49wlc_product_id 0x012a
|
|
|
|
#define keyspan_usa49wg_product_id 0x0131
|
|
|
|
|
|
|
|
struct keyspan_device_details {
|
|
|
|
/* product ID value */
|
|
|
|
int product_id;
|
|
|
|
|
|
|
|
enum {msg_usa26, msg_usa28, msg_usa49, msg_usa90, msg_usa67} msg_format;
|
|
|
|
|
|
|
|
/* Number of physical ports */
|
|
|
|
int num_ports;
|
|
|
|
|
|
|
|
/* 1 if endpoint flipping used on input, 0 if not */
|
|
|
|
int indat_endp_flip;
|
|
|
|
|
|
|
|
/* 1 if endpoint flipping used on output, 0 if not */
|
|
|
|
int outdat_endp_flip;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Table mapping input data endpoint IDs to physical port
|
|
|
|
* number and flip if used
|
|
|
|
*/
|
|
|
|
int indat_endpoints[KEYSPAN_MAX_NUM_PORTS];
|
|
|
|
|
|
|
|
/* Same for output endpoints */
|
|
|
|
int outdat_endpoints[KEYSPAN_MAX_NUM_PORTS];
|
|
|
|
|
|
|
|
/* Input acknowledge endpoints */
|
|
|
|
int inack_endpoints[KEYSPAN_MAX_NUM_PORTS];
|
|
|
|
|
|
|
|
/* Output control endpoints */
|
|
|
|
int outcont_endpoints[KEYSPAN_MAX_NUM_PORTS];
|
|
|
|
|
|
|
|
/* Endpoint used for input status */
|
|
|
|
int instat_endpoint;
|
|
|
|
|
|
|
|
/* Endpoint used for input data 49WG only */
|
|
|
|
int indat_endpoint;
|
|
|
|
|
|
|
|
/* Endpoint used for global control functions */
|
|
|
|
int glocont_endpoint;
|
|
|
|
|
|
|
|
int (*calculate_baud_rate)(struct usb_serial_port *port,
|
|
|
|
u32 baud_rate, u32 baudclk,
|
|
|
|
u8 *rate_hi, u8 *rate_low, u8 *prescaler,
|
|
|
|
int portnum);
|
|
|
|
u32 baudclk;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 = {
|
|
|
|
.product_id = keyspan_usa18x_product_id,
|
|
|
|
.msg_format = msg_usa26,
|
|
|
|
.num_ports = 1,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 1,
|
|
|
|
.indat_endpoints = {0x81},
|
|
|
|
.outdat_endpoints = {0x01},
|
|
|
|
.inack_endpoints = {0x85},
|
|
|
|
.outcont_endpoints = {0x05},
|
|
|
|
.instat_endpoint = 0x87,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = 0x07,
|
|
|
|
.calculate_baud_rate = keyspan_usa19w_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA18X_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa19_device_details = {
|
|
|
|
.product_id = keyspan_usa19_product_id,
|
|
|
|
.msg_format = msg_usa28,
|
|
|
|
.num_ports = 1,
|
|
|
|
.indat_endp_flip = 1,
|
|
|
|
.outdat_endp_flip = 1,
|
|
|
|
.indat_endpoints = {0x81},
|
|
|
|
.outdat_endpoints = {0x01},
|
|
|
|
.inack_endpoints = {0x83},
|
|
|
|
.outcont_endpoints = {0x03},
|
|
|
|
.instat_endpoint = 0x84,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = -1,
|
|
|
|
.calculate_baud_rate = keyspan_usa19_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA19_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa19qi_device_details = {
|
|
|
|
.product_id = keyspan_usa19qi_product_id,
|
|
|
|
.msg_format = msg_usa28,
|
|
|
|
.num_ports = 1,
|
|
|
|
.indat_endp_flip = 1,
|
|
|
|
.outdat_endp_flip = 1,
|
|
|
|
.indat_endpoints = {0x81},
|
|
|
|
.outdat_endpoints = {0x01},
|
|
|
|
.inack_endpoints = {0x83},
|
|
|
|
.outcont_endpoints = {0x03},
|
|
|
|
.instat_endpoint = 0x84,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = -1,
|
|
|
|
.calculate_baud_rate = keyspan_usa28_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA19_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details mpr_device_details = {
|
|
|
|
.product_id = keyspan_mpr_product_id,
|
|
|
|
.msg_format = msg_usa28,
|
|
|
|
.num_ports = 1,
|
|
|
|
.indat_endp_flip = 1,
|
|
|
|
.outdat_endp_flip = 1,
|
|
|
|
.indat_endpoints = {0x81},
|
|
|
|
.outdat_endpoints = {0x01},
|
|
|
|
.inack_endpoints = {0x83},
|
|
|
|
.outcont_endpoints = {0x03},
|
|
|
|
.instat_endpoint = 0x84,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = -1,
|
|
|
|
.calculate_baud_rate = keyspan_usa28_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA19_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa19qw_device_details = {
|
|
|
|
.product_id = keyspan_usa19qw_product_id,
|
|
|
|
.msg_format = msg_usa26,
|
|
|
|
.num_ports = 1,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 1,
|
|
|
|
.indat_endpoints = {0x81},
|
|
|
|
.outdat_endpoints = {0x01},
|
|
|
|
.inack_endpoints = {0x85},
|
|
|
|
.outcont_endpoints = {0x05},
|
|
|
|
.instat_endpoint = 0x87,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = 0x07,
|
|
|
|
.calculate_baud_rate = keyspan_usa19w_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA19W_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa19w_device_details = {
|
|
|
|
.product_id = keyspan_usa19w_product_id,
|
|
|
|
.msg_format = msg_usa26,
|
|
|
|
.num_ports = 1,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 1,
|
|
|
|
.indat_endpoints = {0x81},
|
|
|
|
.outdat_endpoints = {0x01},
|
|
|
|
.inack_endpoints = {0x85},
|
|
|
|
.outcont_endpoints = {0x05},
|
|
|
|
.instat_endpoint = 0x87,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = 0x07,
|
|
|
|
.calculate_baud_rate = keyspan_usa19w_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA19W_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa19hs_device_details = {
|
|
|
|
.product_id = keyspan_usa19hs_product_id,
|
|
|
|
.msg_format = msg_usa90,
|
|
|
|
.num_ports = 1,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 0,
|
|
|
|
.indat_endpoints = {0x81},
|
|
|
|
.outdat_endpoints = {0x01},
|
|
|
|
.inack_endpoints = {-1},
|
|
|
|
.outcont_endpoints = {0x02},
|
|
|
|
.instat_endpoint = 0x82,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = -1,
|
|
|
|
.calculate_baud_rate = keyspan_usa19hs_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA19HS_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa28_device_details = {
|
|
|
|
.product_id = keyspan_usa28_product_id,
|
|
|
|
.msg_format = msg_usa28,
|
|
|
|
.num_ports = 2,
|
|
|
|
.indat_endp_flip = 1,
|
|
|
|
.outdat_endp_flip = 1,
|
|
|
|
.indat_endpoints = {0x81, 0x83},
|
|
|
|
.outdat_endpoints = {0x01, 0x03},
|
|
|
|
.inack_endpoints = {0x85, 0x86},
|
|
|
|
.outcont_endpoints = {0x05, 0x06},
|
|
|
|
.instat_endpoint = 0x87,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = 0x07,
|
|
|
|
.calculate_baud_rate = keyspan_usa28_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA28_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa28x_device_details = {
|
|
|
|
.product_id = keyspan_usa28x_product_id,
|
|
|
|
.msg_format = msg_usa26,
|
|
|
|
.num_ports = 2,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 1,
|
|
|
|
.indat_endpoints = {0x81, 0x83},
|
|
|
|
.outdat_endpoints = {0x01, 0x03},
|
|
|
|
.inack_endpoints = {0x85, 0x86},
|
|
|
|
.outcont_endpoints = {0x05, 0x06},
|
|
|
|
.instat_endpoint = 0x87,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = 0x07,
|
|
|
|
.calculate_baud_rate = keyspan_usa19w_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA28X_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa28xa_device_details = {
|
|
|
|
.product_id = keyspan_usa28xa_product_id,
|
|
|
|
.msg_format = msg_usa26,
|
|
|
|
.num_ports = 2,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 1,
|
|
|
|
.indat_endpoints = {0x81, 0x83},
|
|
|
|
.outdat_endpoints = {0x01, 0x03},
|
|
|
|
.inack_endpoints = {0x85, 0x86},
|
|
|
|
.outcont_endpoints = {0x05, 0x06},
|
|
|
|
.instat_endpoint = 0x87,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = 0x07,
|
|
|
|
.calculate_baud_rate = keyspan_usa19w_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA28X_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa28xg_device_details = {
|
|
|
|
.product_id = keyspan_usa28xg_product_id,
|
|
|
|
.msg_format = msg_usa67,
|
|
|
|
.num_ports = 2,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 0,
|
|
|
|
.indat_endpoints = {0x84, 0x88},
|
|
|
|
.outdat_endpoints = {0x02, 0x06},
|
|
|
|
.inack_endpoints = {-1, -1},
|
|
|
|
.outcont_endpoints = {-1, -1},
|
|
|
|
.instat_endpoint = 0x81,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = 0x01,
|
|
|
|
.calculate_baud_rate = keyspan_usa19w_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA28X_BAUDCLK,
|
|
|
|
};
|
|
|
|
/*
|
|
|
|
* 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 = {
|
|
|
|
.product_id = keyspan_usa49w_product_id,
|
|
|
|
.msg_format = msg_usa49,
|
|
|
|
.num_ports = 4,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 0,
|
|
|
|
.indat_endpoints = {0x81, 0x82, 0x83, 0x84},
|
|
|
|
.outdat_endpoints = {0x01, 0x02, 0x03, 0x04},
|
|
|
|
.inack_endpoints = {-1, -1, -1, -1},
|
|
|
|
.outcont_endpoints = {-1, -1, -1, -1},
|
|
|
|
.instat_endpoint = 0x87,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = 0x07,
|
|
|
|
.calculate_baud_rate = keyspan_usa19w_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA49W_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa49wlc_device_details = {
|
|
|
|
.product_id = keyspan_usa49wlc_product_id,
|
|
|
|
.msg_format = msg_usa49,
|
|
|
|
.num_ports = 4,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 0,
|
|
|
|
.indat_endpoints = {0x81, 0x82, 0x83, 0x84},
|
|
|
|
.outdat_endpoints = {0x01, 0x02, 0x03, 0x04},
|
|
|
|
.inack_endpoints = {-1, -1, -1, -1},
|
|
|
|
.outcont_endpoints = {-1, -1, -1, -1},
|
|
|
|
.instat_endpoint = 0x87,
|
|
|
|
.indat_endpoint = -1,
|
|
|
|
.glocont_endpoint = 0x07,
|
|
|
|
.calculate_baud_rate = keyspan_usa19w_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA19W_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details usa49wg_device_details = {
|
|
|
|
.product_id = keyspan_usa49wg_product_id,
|
|
|
|
.msg_format = msg_usa49,
|
|
|
|
.num_ports = 4,
|
|
|
|
.indat_endp_flip = 0,
|
|
|
|
.outdat_endp_flip = 0,
|
|
|
|
.indat_endpoints = {-1, -1, -1, -1}, /* single 'global' data in EP */
|
|
|
|
.outdat_endpoints = {0x01, 0x02, 0x04, 0x06},
|
|
|
|
.inack_endpoints = {-1, -1, -1, -1},
|
|
|
|
.outcont_endpoints = {-1, -1, -1, -1},
|
|
|
|
.instat_endpoint = 0x81,
|
|
|
|
.indat_endpoint = 0x88,
|
|
|
|
.glocont_endpoint = 0x00, /* uses control EP */
|
|
|
|
.calculate_baud_rate = keyspan_usa19w_calc_baud,
|
|
|
|
.baudclk = KEYSPAN_USA19W_BAUDCLK,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct keyspan_device_details *keyspan_devices[] = {
|
|
|
|
&usa18x_device_details,
|
|
|
|
&usa19_device_details,
|
|
|
|
&usa19qi_device_details,
|
|
|
|
&mpr_device_details,
|
|
|
|
&usa19qw_device_details,
|
|
|
|
&usa19w_device_details,
|
|
|
|
&usa19hs_device_details,
|
|
|
|
&usa28_device_details,
|
|
|
|
&usa28x_device_details,
|
|
|
|
&usa28xa_device_details,
|
|
|
|
&usa28xg_device_details,
|
|
|
|
/* 28xb not required as it renumerates as a 28x */
|
|
|
|
&usa49w_device_details,
|
|
|
|
&usa49wlc_device_details,
|
|
|
|
&usa49wg_device_details,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct usb_device_id keyspan_ids_combined[] = {
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19hs_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id)},
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)},
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)},
|
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
|
|
|
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[] = {
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_pre_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_pre_product_id) },
|
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct usb_device_id keyspan_1port_ids[] = {
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19hs_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_product_id) },
|
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct usb_device_id keyspan_2port_ids[] = {
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) },
|
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct usb_device_id keyspan_4port_ids[] = {
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id) },
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)},
|
|
|
|
{ USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)},
|
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define INSTAT_BUFLEN 32
|
|
|
|
#define GLOCONT_BUFLEN 64
|
2007-05-19 03:10:41 +08:00
|
|
|
#define INDAT49W_BUFLEN 512
|
2013-08-13 19:27:37 +08:00
|
|
|
#define IN_BUFLEN 64
|
|
|
|
#define OUT_BUFLEN 64
|
|
|
|
#define INACK_BUFLEN 1
|
|
|
|
#define OUTCONT_BUFLEN 64
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Per device and per port private data */
|
|
|
|
struct keyspan_serial_private {
|
|
|
|
const struct keyspan_device_details *device_details;
|
|
|
|
|
|
|
|
struct urb *instat_urb;
|
2013-08-13 19:27:36 +08:00
|
|
|
char *instat_buf;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* added to support 49wg, where data from all 4 ports comes in
|
|
|
|
on 1 EP and high-speed supported */
|
2007-05-19 03:10:41 +08:00
|
|
|
struct urb *indat_urb;
|
2013-08-13 19:27:36 +08:00
|
|
|
char *indat_buf;
|
2007-05-19 03:10:41 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* XXX this one probably will need a lock */
|
|
|
|
struct urb *glocont_urb;
|
2013-08-13 19:27:36 +08:00
|
|
|
char *glocont_buf;
|
|
|
|
char *ctrl_buf; /* for EP0 control message */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct keyspan_port_private {
|
|
|
|
/* Keep track of which input & output endpoints to use */
|
|
|
|
int in_flip;
|
|
|
|
int out_flip;
|
|
|
|
|
|
|
|
/* Keep duplicate of device details in each port
|
|
|
|
structure as well - simplifies some of the
|
|
|
|
callback functions etc. */
|
|
|
|
const struct keyspan_device_details *device_details;
|
|
|
|
|
|
|
|
/* Input endpoints and buffer for this port */
|
|
|
|
struct urb *in_urbs[2];
|
2013-08-13 19:27:37 +08:00
|
|
|
char *in_buffer[2];
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Output endpoints and buffer for this port */
|
|
|
|
struct urb *out_urbs[2];
|
2013-08-13 19:27:37 +08:00
|
|
|
char *out_buffer[2];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Input ack endpoint */
|
|
|
|
struct urb *inack_urb;
|
2013-08-13 19:27:37 +08:00
|
|
|
char *inack_buffer;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Output control endpoint */
|
|
|
|
struct urb *outcont_urb;
|
2013-08-13 19:27:37 +08:00
|
|
|
char *outcont_buffer;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Settings for the port */
|
|
|
|
int baud;
|
|
|
|
int old_baud;
|
|
|
|
unsigned int cflag;
|
|
|
|
unsigned int old_cflag;
|
|
|
|
enum {flow_none, flow_cts, flow_xon} flow_control;
|
|
|
|
int rts_state; /* Handshaking pins (outputs) */
|
|
|
|
int dtr_state;
|
|
|
|
int cts_state; /* Handshaking pins (inputs) */
|
|
|
|
int dsr_state;
|
|
|
|
int dcd_state;
|
|
|
|
int ri_state;
|
|
|
|
int break_on;
|
|
|
|
|
|
|
|
unsigned long tx_start_time[2];
|
|
|
|
int resend_cont; /* need to resend control packet */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Include Keyspan message headers. All current Keyspan Adapters
|
2007-05-19 03:10:41 +08:00
|
|
|
make use of one of five message formats which are referred
|
2008-07-22 18:13:08 +08:00
|
|
|
to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and
|
|
|
|
within this driver. */
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "keyspan_usa26msg.h"
|
|
|
|
#include "keyspan_usa28msg.h"
|
|
|
|
#include "keyspan_usa49msg.h"
|
|
|
|
#include "keyspan_usa90msg.h"
|
2007-05-19 03:10:41 +08:00
|
|
|
#include "keyspan_usa67msg.h"
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:09:07 +08:00
|
|
|
static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-07-22 18:09:07 +08:00
|
|
|
struct usb_serial_port *port = tty->driver_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
|
|
|
|
if (break_state == -1)
|
|
|
|
p_priv->break_on = 1;
|
|
|
|
else
|
|
|
|
p_priv->break_on = 0;
|
|
|
|
|
|
|
|
keyspan_send_setup(port, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
static void keyspan_set_termios(struct tty_struct *tty,
|
2008-07-22 18:09:07 +08:00
|
|
|
struct usb_serial_port *port, struct ktermios *old_termios)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int baud_rate, device_port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
unsigned int cflag;
|
|
|
|
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
d_details = p_priv->device_details;
|
2012-07-14 22:31:47 +08:00
|
|
|
cflag = tty->termios.c_cflag;
|
2013-06-07 01:32:00 +08:00
|
|
|
device_port = port->port_number;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Baud rate calculation takes baud rate as an integer
|
|
|
|
so other rates can be generated if desired. */
|
2007-10-18 16:24:20 +08:00
|
|
|
baud_rate = tty_get_baud_rate(tty);
|
2008-07-22 18:13:08 +08:00
|
|
|
/* If no match or invalid, don't change */
|
2012-09-15 07:30:23 +08:00
|
|
|
if (d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk,
|
2005-04-17 06:20:36 +08:00
|
|
|
NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
|
|
|
|
/* FIXME - more to do here to ensure rate changes cleanly */
|
2014-01-02 21:59:24 +08:00
|
|
|
/* FIXME - calculate exact rate from divisor ? */
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->baud = baud_rate;
|
2007-10-18 16:24:20 +08:00
|
|
|
} else
|
|
|
|
baud_rate = tty_termios_baud_rate(old_termios);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-18 16:24:20 +08:00
|
|
|
tty_encode_baud_rate(tty, baud_rate, baud_rate);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* set CTS/RTS handshake etc. */
|
|
|
|
p_priv->cflag = cflag;
|
2012-07-11 22:10:16 +08:00
|
|
|
p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-18 16:24:20 +08:00
|
|
|
/* Mark/Space not supported */
|
2012-07-14 22:31:47 +08:00
|
|
|
tty->termios.c_cflag &= ~CMSPAR;
|
2007-10-18 16:24:20 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
keyspan_send_setup(port, 0);
|
|
|
|
}
|
|
|
|
|
2011-02-15 00:26:14 +08:00
|
|
|
static int keyspan_tiocmget(struct tty_struct *tty)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-07-22 18:09:07 +08:00
|
|
|
struct usb_serial_port *port = tty->driver_data;
|
|
|
|
struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int value;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
value = ((p_priv->rts_state) ? TIOCM_RTS : 0) |
|
|
|
|
((p_priv->dtr_state) ? TIOCM_DTR : 0) |
|
|
|
|
((p_priv->cts_state) ? TIOCM_CTS : 0) |
|
|
|
|
((p_priv->dsr_state) ? TIOCM_DSR : 0) |
|
|
|
|
((p_priv->dcd_state) ? TIOCM_CAR : 0) |
|
2008-07-22 18:13:08 +08:00
|
|
|
((p_priv->ri_state) ? TIOCM_RNG : 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2011-02-15 00:26:50 +08:00
|
|
|
static int keyspan_tiocmset(struct tty_struct *tty,
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int set, unsigned int clear)
|
|
|
|
{
|
2008-07-22 18:09:07 +08:00
|
|
|
struct usb_serial_port *port = tty->driver_data;
|
|
|
|
struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (set & TIOCM_RTS)
|
|
|
|
p_priv->rts_state = 1;
|
|
|
|
if (set & TIOCM_DTR)
|
|
|
|
p_priv->dtr_state = 1;
|
|
|
|
if (clear & TIOCM_RTS)
|
|
|
|
p_priv->rts_state = 0;
|
|
|
|
if (clear & TIOCM_DTR)
|
|
|
|
p_priv->dtr_state = 0;
|
|
|
|
keyspan_send_setup(port, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:09:07 +08:00
|
|
|
/* 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)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
int flip;
|
|
|
|
int left, todo;
|
|
|
|
struct urb *this_urb;
|
2008-07-22 18:13:08 +08:00
|
|
|
int err, maxDataLen, dataOffset;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
d_details = p_priv->device_details;
|
|
|
|
|
|
|
|
if (d_details->msg_format == msg_usa90) {
|
2008-07-22 18:13:08 +08:00
|
|
|
maxDataLen = 64;
|
2005-04-17 06:20:36 +08:00
|
|
|
dataOffset = 0;
|
|
|
|
} else {
|
|
|
|
maxDataLen = 63;
|
|
|
|
dataOffset = 1;
|
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2013-06-07 01:32:00 +08:00
|
|
|
dev_dbg(&port->dev, "%s - %d chars, flip=%d\n", __func__, count,
|
|
|
|
p_priv->out_flip);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
for (left = count; left > 0; left -= todo) {
|
|
|
|
todo = left;
|
|
|
|
if (todo > maxDataLen)
|
|
|
|
todo = maxDataLen;
|
|
|
|
|
|
|
|
flip = p_priv->out_flip;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Check we have a valid urb/endpoint before we use it... */
|
2008-07-22 18:13:08 +08:00
|
|
|
this_urb = p_priv->out_urbs[flip];
|
|
|
|
if (this_urb == NULL) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* no bulk out, so return 0 bytes written */
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - no output urb :(\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&port->dev, "%s - endpoint %x flip %d\n",
|
2008-07-22 18:13:08 +08:00
|
|
|
__func__, usb_pipeendpoint(this_urb->pipe), flip);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (this_urb->status == -EINPROGRESS) {
|
2008-07-22 18:13:08 +08:00
|
|
|
if (time_before(jiffies,
|
|
|
|
p_priv->tx_start_time[flip] + 10 * HZ))
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
usb_unlink_urb(this_urb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* First byte in buffer is "last flag" (except for usa19hx)
|
|
|
|
- unused so for now so set to zero */
|
2005-04-17 06:20:36 +08:00
|
|
|
((char *)this_urb->transfer_buffer)[0] = 0;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
memcpy(this_urb->transfer_buffer + dataOffset, buf, todo);
|
2005-04-17 06:20:36 +08:00
|
|
|
buf += todo;
|
|
|
|
|
|
|
|
/* send the data out the bulk port */
|
|
|
|
this_urb->transfer_buffer_length = todo + dataOffset;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
err = usb_submit_urb(this_urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "usb_submit_urb(write bulk) failed (%d)\n", err);
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->tx_start_time[flip] = jiffies;
|
|
|
|
|
|
|
|
/* Flip for next time if usa26 or usa28 interface
|
|
|
|
(not used on usa49) */
|
|
|
|
p_priv->out_flip = (flip + 1) & d_details->outdat_endp_flip;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count - left;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa26_indat_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i, err;
|
|
|
|
int endpoint;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
unsigned char *data = urb->transfer_buffer;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
endpoint = usb_pipeendpoint(urb->pipe);
|
|
|
|
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n",
|
2012-09-15 07:30:23 +08:00
|
|
|
__func__, status, endpoint);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
port = urb->context;
|
2013-01-03 22:53:06 +08:00
|
|
|
if (urb->actual_length) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* 0x80 bit is error flag */
|
|
|
|
if ((data[0] & 0x80) == 0) {
|
2008-07-22 18:13:08 +08:00
|
|
|
/* no errors on individual bytes, only
|
|
|
|
possible overrun err */
|
2014-11-18 18:25:20 +08:00
|
|
|
if (data[0] & RXERROR_OVERRUN) {
|
|
|
|
tty_insert_flip_char(&port->port, 0,
|
|
|
|
TTY_OVERRUN);
|
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
for (i = 1; i < urb->actual_length ; ++i)
|
2014-11-18 18:25:20 +08:00
|
|
|
tty_insert_flip_char(&port->port, data[i],
|
|
|
|
TTY_NORMAL);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
/* some bytes had errors, every byte has status */
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i + 1 < urb->actual_length; i += 2) {
|
2014-11-18 18:25:19 +08:00
|
|
|
int stat = data[i];
|
|
|
|
int flag = TTY_NORMAL;
|
|
|
|
|
|
|
|
if (stat & RXERROR_OVERRUN) {
|
|
|
|
tty_insert_flip_char(&port->port, 0,
|
|
|
|
TTY_OVERRUN);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
/* XXX should handle break (0x10) */
|
2014-11-18 18:25:19 +08:00
|
|
|
if (stat & RXERROR_PARITY)
|
|
|
|
flag = TTY_PARITY;
|
|
|
|
else if (stat & RXERROR_FRAMING)
|
|
|
|
flag = TTY_FRAME;
|
|
|
|
|
2013-01-03 22:53:03 +08:00
|
|
|
tty_insert_flip_char(&port->port, data[i+1],
|
|
|
|
flag);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2013-01-03 22:53:06 +08:00
|
|
|
tty_flip_buffer_push(&port->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
|
|
|
|
/* Resubmit urb so we continue receiving */
|
2010-02-17 23:05:47 +08:00
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Outdat handling is common for all devices */
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa2x_outdat_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
port = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv = usb_get_serial_port_data(port);
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - urb %d\n", __func__, urb == p_priv->out_urbs[1]);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-02-17 23:05:47 +08:00
|
|
|
usb_serial_port_softint(port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa26_inack_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa26_outcont_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
port = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
|
|
|
|
if (p_priv->resend_cont) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - sending setup\n", __func__);
|
2008-07-22 18:13:08 +08:00
|
|
|
keyspan_usa26_send_setup(port->serial, port,
|
|
|
|
p_priv->resend_cont - 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa26_instat_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned char *data = urb->transfer_buffer;
|
|
|
|
struct keyspan_usa26_portStatusMessage *msg;
|
|
|
|
struct usb_serial *serial;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
int old_dcd_state, err;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
serial = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
|
|
|
|
__func__, status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (urb->actual_length != 9) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = (struct keyspan_usa26_portStatusMessage *)data;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Check port number from message and retrieve private data */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (msg->port >= serial->num_ports) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
port = serial->port[msg->port];
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
2014-12-23 01:39:39 +08:00
|
|
|
if (!p_priv)
|
|
|
|
goto resubmit;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Update handshaking pin state information */
|
|
|
|
old_dcd_state = p_priv->dcd_state;
|
|
|
|
p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
|
|
|
|
p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
|
|
|
|
p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
|
|
|
|
p_priv->ri_state = ((msg->ri) ? 1 : 0);
|
|
|
|
|
2013-03-07 20:12:30 +08:00
|
|
|
if (old_dcd_state != p_priv->dcd_state)
|
|
|
|
tty_port_tty_hangup(&port->port, true);
|
2014-12-23 01:39:39 +08:00
|
|
|
resubmit:
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Resubmit urb so we continue receiving */
|
2008-07-22 18:13:08 +08:00
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
exit: ;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa26_glocont_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa28_indat_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-07-22 18:13:32 +08:00
|
|
|
int err;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct usb_serial_port *port;
|
|
|
|
unsigned char *data;
|
|
|
|
struct keyspan_port_private *p_priv;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
port = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
data = urb->transfer_buffer;
|
|
|
|
|
|
|
|
if (urb != p_priv->in_urbs[p_priv->in_flip])
|
|
|
|
return;
|
|
|
|
|
|
|
|
do {
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n",
|
2012-09-15 07:30:23 +08:00
|
|
|
__func__, status, usb_pipeendpoint(urb->pipe));
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
port = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
data = urb->transfer_buffer;
|
|
|
|
|
2013-01-03 22:53:06 +08:00
|
|
|
if (urb->actual_length) {
|
2013-01-03 22:53:04 +08:00
|
|
|
tty_insert_flip_string(&port->port, data,
|
|
|
|
urb->actual_length);
|
2013-01-03 22:53:06 +08:00
|
|
|
tty_flip_buffer_push(&port->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Resubmit urb so we continue receiving */
|
2010-02-17 23:05:47 +08:00
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n",
|
2010-02-17 23:05:47 +08:00
|
|
|
__func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->in_flip ^= 1;
|
|
|
|
|
|
|
|
urb = p_priv->in_urbs[p_priv->in_flip];
|
|
|
|
} while (urb->status != -EINPROGRESS);
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa28_inack_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa28_outcont_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
port = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
|
|
|
|
if (p_priv->resend_cont) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - sending setup\n", __func__);
|
2008-07-22 18:13:08 +08:00
|
|
|
keyspan_usa28_send_setup(port->serial, port,
|
|
|
|
p_priv->resend_cont - 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa28_instat_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
unsigned char *data = urb->transfer_buffer;
|
|
|
|
struct keyspan_usa28_portStatusMessage *msg;
|
|
|
|
struct usb_serial *serial;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
int old_dcd_state;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
serial = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
|
|
|
|
__func__, status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
msg = (struct keyspan_usa28_portStatusMessage *)data;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Check port number from message and retrieve private data */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (msg->port >= serial->num_ports) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
port = serial->port[msg->port];
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
2014-12-23 01:39:39 +08:00
|
|
|
if (!p_priv)
|
|
|
|
goto resubmit;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Update handshaking pin state information */
|
|
|
|
old_dcd_state = p_priv->dcd_state;
|
|
|
|
p_priv->cts_state = ((msg->cts) ? 1 : 0);
|
|
|
|
p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
|
|
|
|
p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
|
|
|
|
p_priv->ri_state = ((msg->ri) ? 1 : 0);
|
|
|
|
|
2013-03-07 20:12:30 +08:00
|
|
|
if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
|
|
|
|
tty_port_tty_hangup(&port->port, true);
|
2014-12-23 01:39:39 +08:00
|
|
|
resubmit:
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Resubmit urb so we continue receiving */
|
2008-07-22 18:13:08 +08:00
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
exit: ;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa28_glocont_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa49_glocont_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct usb_serial *serial;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
int i;
|
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
serial = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < serial->num_ports; ++i) {
|
|
|
|
port = serial->port[i];
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
|
|
|
|
if (p_priv->resend_cont) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - sending setup\n", __func__);
|
2008-07-22 18:13:08 +08:00
|
|
|
keyspan_usa49_send_setup(serial, port,
|
|
|
|
p_priv->resend_cont - 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is actually called glostat in the Keyspan
|
|
|
|
doco */
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa49_instat_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
unsigned char *data = urb->transfer_buffer;
|
|
|
|
struct keyspan_usa49_portStatusMessage *msg;
|
|
|
|
struct usb_serial *serial;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
int old_dcd_state;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
serial = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
|
|
|
|
__func__, status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
if (urb->actual_length !=
|
|
|
|
sizeof(struct keyspan_usa49_portStatusMessage)) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = (struct keyspan_usa49_portStatusMessage *)data;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Check port number from message and retrieve private data */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (msg->portNumber >= serial->num_ports) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
|
|
|
|
__func__, msg->portNumber);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
port = serial->port[msg->portNumber];
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
2014-12-23 01:39:39 +08:00
|
|
|
if (!p_priv)
|
|
|
|
goto resubmit;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Update handshaking pin state information */
|
|
|
|
old_dcd_state = p_priv->dcd_state;
|
|
|
|
p_priv->cts_state = ((msg->cts) ? 1 : 0);
|
|
|
|
p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
|
|
|
|
p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
|
|
|
|
p_priv->ri_state = ((msg->ri) ? 1 : 0);
|
|
|
|
|
2013-03-07 20:12:30 +08:00
|
|
|
if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
|
|
|
|
tty_port_tty_hangup(&port->port, true);
|
2014-12-23 01:39:39 +08:00
|
|
|
resubmit:
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Resubmit urb so we continue receiving */
|
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
exit: ;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa49_inack_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa49_indat_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i, err;
|
|
|
|
int endpoint;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
unsigned char *data = urb->transfer_buffer;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
endpoint = usb_pipeendpoint(urb->pipe);
|
|
|
|
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n",
|
2012-09-15 07:30:23 +08:00
|
|
|
__func__, status, endpoint);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
port = urb->context;
|
2013-01-03 22:53:06 +08:00
|
|
|
if (urb->actual_length) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* 0x80 bit is error flag */
|
|
|
|
if ((data[0] & 0x80) == 0) {
|
|
|
|
/* no error on any byte */
|
2013-01-03 22:53:04 +08:00
|
|
|
tty_insert_flip_string(&port->port, data + 1,
|
2008-07-22 18:13:32 +08:00
|
|
|
urb->actual_length - 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
/* some bytes had errors, every byte has status */
|
|
|
|
for (i = 0; i + 1 < urb->actual_length; i += 2) {
|
2014-11-18 18:25:19 +08:00
|
|
|
int stat = data[i];
|
|
|
|
int flag = TTY_NORMAL;
|
|
|
|
|
|
|
|
if (stat & RXERROR_OVERRUN) {
|
|
|
|
tty_insert_flip_char(&port->port, 0,
|
|
|
|
TTY_OVERRUN);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
/* XXX should handle break (0x10) */
|
2014-11-18 18:25:19 +08:00
|
|
|
if (stat & RXERROR_PARITY)
|
|
|
|
flag = TTY_PARITY;
|
|
|
|
else if (stat & RXERROR_FRAMING)
|
|
|
|
flag = TTY_FRAME;
|
|
|
|
|
2013-01-03 22:53:03 +08:00
|
|
|
tty_insert_flip_char(&port->port, data[i+1],
|
|
|
|
flag);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
2013-01-03 22:53:06 +08:00
|
|
|
tty_flip_buffer_push(&port->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
|
|
|
|
/* Resubmit urb so we continue receiving */
|
2010-02-17 23:05:47 +08:00
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:10:41 +08:00
|
|
|
static void usa49wg_indat_callback(struct urb *urb)
|
|
|
|
{
|
|
|
|
int i, len, x, err;
|
|
|
|
struct usb_serial *serial;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
unsigned char *data = urb->transfer_buffer;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2007-05-19 03:10:41 +08:00
|
|
|
|
|
|
|
serial = urb->context;
|
|
|
|
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
|
|
|
|
__func__, status);
|
2007-05-19 03:10:41 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* inbound data is in the form P#, len, status, data */
|
|
|
|
i = 0;
|
|
|
|
len = 0;
|
|
|
|
|
2013-04-05 13:42:41 +08:00
|
|
|
while (i < urb->actual_length) {
|
2007-05-19 03:10:41 +08:00
|
|
|
|
2013-04-05 13:42:41 +08:00
|
|
|
/* Check port number from message */
|
|
|
|
if (data[i] >= serial->num_ports) {
|
|
|
|
dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
|
|
|
|
__func__, data[i]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
port = serial->port[data[i++]];
|
|
|
|
len = data[i++];
|
2007-05-19 03:10:41 +08:00
|
|
|
|
2013-04-05 13:42:41 +08:00
|
|
|
/* 0x80 bit is error flag */
|
|
|
|
if ((data[i] & 0x80) == 0) {
|
|
|
|
/* no error on any byte */
|
|
|
|
i++;
|
2013-04-05 13:43:20 +08:00
|
|
|
for (x = 1; x < len && i < urb->actual_length; ++x)
|
2013-04-05 13:42:41 +08:00
|
|
|
tty_insert_flip_char(&port->port,
|
|
|
|
data[i++], 0);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* some bytes had errors, every byte has status
|
|
|
|
*/
|
2013-04-05 13:43:20 +08:00
|
|
|
for (x = 0; x + 1 < len &&
|
|
|
|
i + 1 < urb->actual_length; x += 2) {
|
2014-11-18 18:25:19 +08:00
|
|
|
int stat = data[i];
|
|
|
|
int flag = TTY_NORMAL;
|
2013-04-05 13:42:41 +08:00
|
|
|
|
2014-11-18 18:25:19 +08:00
|
|
|
if (stat & RXERROR_OVERRUN) {
|
|
|
|
tty_insert_flip_char(&port->port, 0,
|
|
|
|
TTY_OVERRUN);
|
|
|
|
}
|
2013-04-05 13:42:41 +08:00
|
|
|
/* XXX should handle break (0x10) */
|
2014-11-18 18:25:19 +08:00
|
|
|
if (stat & RXERROR_PARITY)
|
|
|
|
flag = TTY_PARITY;
|
|
|
|
else if (stat & RXERROR_FRAMING)
|
|
|
|
flag = TTY_FRAME;
|
|
|
|
|
2013-04-05 13:42:41 +08:00
|
|
|
tty_insert_flip_char(&port->port, data[i+1],
|
|
|
|
flag);
|
|
|
|
i += 2;
|
2007-05-19 03:10:41 +08:00
|
|
|
}
|
|
|
|
}
|
2013-04-05 13:42:41 +08:00
|
|
|
tty_flip_buffer_push(&port->port);
|
2007-05-19 03:10:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Resubmit urb so we continue receiving */
|
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
|
2007-05-19 03:10:41 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* not used, usa-49 doesn't have per-port control endpoints */
|
2007-05-19 03:10:41 +08:00
|
|
|
static void usa49_outcont_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-19 03:10:41 +08:00
|
|
|
static void usa90_indat_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i, err;
|
|
|
|
int endpoint;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
unsigned char *data = urb->transfer_buffer;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
endpoint = usb_pipeendpoint(urb->pipe);
|
|
|
|
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint %x\n",
|
|
|
|
__func__, status, endpoint);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
port = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
|
|
|
|
if (urb->actual_length) {
|
|
|
|
/* if current mode is DMA, looks like usa28 format
|
2008-07-22 18:13:08 +08:00
|
|
|
otherwise looks like usa26 data format */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:32 +08:00
|
|
|
if (p_priv->baud > 57600)
|
2013-01-03 22:53:04 +08:00
|
|
|
tty_insert_flip_string(&port->port, data,
|
|
|
|
urb->actual_length);
|
2008-07-22 18:13:32 +08:00
|
|
|
else {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* 0x80 bit is error flag */
|
|
|
|
if ((data[0] & 0x80) == 0) {
|
2008-07-22 18:13:08 +08:00
|
|
|
/* no errors on individual bytes, only
|
|
|
|
possible overrun err*/
|
2014-11-18 18:25:20 +08:00
|
|
|
if (data[0] & RXERROR_OVERRUN) {
|
|
|
|
tty_insert_flip_char(&port->port, 0,
|
|
|
|
TTY_OVERRUN);
|
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
for (i = 1; i < urb->actual_length ; ++i)
|
2013-01-03 22:53:03 +08:00
|
|
|
tty_insert_flip_char(&port->port,
|
2014-11-18 18:25:20 +08:00
|
|
|
data[i], TTY_NORMAL);
|
2008-07-22 18:13:08 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* some bytes had errors, every byte has status */
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i + 1 < urb->actual_length; i += 2) {
|
2014-11-18 18:25:19 +08:00
|
|
|
int stat = data[i];
|
|
|
|
int flag = TTY_NORMAL;
|
|
|
|
|
|
|
|
if (stat & RXERROR_OVERRUN) {
|
|
|
|
tty_insert_flip_char(
|
|
|
|
&port->port, 0,
|
|
|
|
TTY_OVERRUN);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
/* XXX should handle break (0x10) */
|
2014-11-18 18:25:19 +08:00
|
|
|
if (stat & RXERROR_PARITY)
|
|
|
|
flag = TTY_PARITY;
|
|
|
|
else if (stat & RXERROR_FRAMING)
|
|
|
|
flag = TTY_FRAME;
|
|
|
|
|
2013-01-03 22:53:03 +08:00
|
|
|
tty_insert_flip_char(&port->port,
|
|
|
|
data[i+1], flag);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-03 22:53:06 +08:00
|
|
|
tty_flip_buffer_push(&port->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Resubmit urb so we continue receiving */
|
2010-02-17 23:05:47 +08:00
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa90_instat_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned char *data = urb->transfer_buffer;
|
|
|
|
struct keyspan_usa90_portStatusMessage *msg;
|
|
|
|
struct usb_serial *serial;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
int old_dcd_state, err;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
serial = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
|
|
|
|
__func__, status);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (urb->actual_length < 14) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = (struct keyspan_usa90_portStatusMessage *)data;
|
|
|
|
|
|
|
|
/* Now do something useful with the data */
|
|
|
|
|
|
|
|
port = serial->port[0];
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
2014-12-23 01:39:39 +08:00
|
|
|
if (!p_priv)
|
|
|
|
goto resubmit;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Update handshaking pin state information */
|
|
|
|
old_dcd_state = p_priv->dcd_state;
|
|
|
|
p_priv->cts_state = ((msg->cts) ? 1 : 0);
|
|
|
|
p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
|
|
|
|
p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
|
|
|
|
p_priv->ri_state = ((msg->ri) ? 1 : 0);
|
|
|
|
|
2013-03-07 20:12:30 +08:00
|
|
|
if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
|
|
|
|
tty_port_tty_hangup(&port->port, true);
|
2014-12-23 01:39:39 +08:00
|
|
|
resubmit:
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Resubmit urb so we continue receiving */
|
2008-07-22 18:13:08 +08:00
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
exit:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static void usa90_outcont_callback(struct urb *urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
|
2008-02-24 18:41:47 +08:00
|
|
|
port = urb->context;
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
|
|
|
|
if (p_priv->resend_cont) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - sending setup\n", __func__);
|
2008-07-22 18:13:08 +08:00
|
|
|
keyspan_usa90_send_setup(port->serial, port,
|
|
|
|
p_priv->resend_cont - 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-19 03:10:41 +08:00
|
|
|
/* Status messages from the 28xg */
|
|
|
|
static void usa67_instat_callback(struct urb *urb)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
unsigned char *data = urb->transfer_buffer;
|
|
|
|
struct keyspan_usa67_portStatusMessage *msg;
|
|
|
|
struct usb_serial *serial;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
int old_dcd_state;
|
2007-06-16 06:44:13 +08:00
|
|
|
int status = urb->status;
|
2007-05-19 03:10:41 +08:00
|
|
|
|
|
|
|
serial = urb->context;
|
|
|
|
|
2007-06-16 06:44:13 +08:00
|
|
|
if (status) {
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
|
|
|
|
__func__, status);
|
2007-05-19 03:10:41 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
if (urb->actual_length !=
|
|
|
|
sizeof(struct keyspan_usa67_portStatusMessage)) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
|
2007-05-19 03:10:41 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Now do something useful with the data */
|
|
|
|
msg = (struct keyspan_usa67_portStatusMessage *)data;
|
|
|
|
|
|
|
|
/* Check port number from message and retrieve private data */
|
|
|
|
if (msg->port >= serial->num_ports) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
|
2007-05-19 03:10:41 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
port = serial->port[msg->port];
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
2014-12-23 01:39:39 +08:00
|
|
|
if (!p_priv)
|
|
|
|
goto resubmit;
|
2007-05-19 03:10:41 +08:00
|
|
|
|
|
|
|
/* Update handshaking pin state information */
|
|
|
|
old_dcd_state = p_priv->dcd_state;
|
|
|
|
p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
|
|
|
|
p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
|
|
|
|
|
2013-03-07 20:12:30 +08:00
|
|
|
if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
|
|
|
|
tty_port_tty_hangup(&port->port, true);
|
2014-12-23 01:39:39 +08:00
|
|
|
resubmit:
|
2007-05-19 03:10:41 +08:00
|
|
|
/* Resubmit urb so we continue receiving */
|
|
|
|
err = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
|
2007-05-19 03:10:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void usa67_glocont_callback(struct urb *urb)
|
|
|
|
{
|
|
|
|
struct usb_serial *serial;
|
|
|
|
struct usb_serial_port *port;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
serial = urb->context;
|
|
|
|
for (i = 0; i < serial->num_ports; ++i) {
|
|
|
|
port = serial->port[i];
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
|
|
|
|
if (p_priv->resend_cont) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - sending setup\n", __func__);
|
2007-05-19 03:10:41 +08:00
|
|
|
keyspan_usa67_send_setup(serial, port,
|
|
|
|
p_priv->resend_cont - 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:09:07 +08:00
|
|
|
static int keyspan_write_room(struct tty_struct *tty)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-07-22 18:09:07 +08:00
|
|
|
struct usb_serial_port *port = tty->driver_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
int flip;
|
|
|
|
int data_len;
|
|
|
|
struct urb *this_urb;
|
|
|
|
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
d_details = p_priv->device_details;
|
|
|
|
|
2008-04-09 00:16:06 +08:00
|
|
|
/* FIXME: locking */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (d_details->msg_format == msg_usa90)
|
2008-07-22 18:13:08 +08:00
|
|
|
data_len = 64;
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
|
|
|
data_len = 63;
|
|
|
|
|
|
|
|
flip = p_priv->out_flip;
|
|
|
|
|
|
|
|
/* Check both endpoints to see if any are available. */
|
2008-07-22 18:13:08 +08:00
|
|
|
this_urb = p_priv->out_urbs[flip];
|
|
|
|
if (this_urb != NULL) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (this_urb->status != -EINPROGRESS)
|
2008-07-22 18:13:08 +08:00
|
|
|
return data_len;
|
|
|
|
flip = (flip + 1) & d_details->outdat_endp_flip;
|
|
|
|
this_urb = p_priv->out_urbs[flip];
|
|
|
|
if (this_urb != NULL) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (this_urb->status != -EINPROGRESS)
|
2008-07-22 18:13:08 +08:00
|
|
|
return data_len;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-04-09 00:16:06 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-20 04:13:26 +08:00
|
|
|
static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-11-29 08:21:54 +08:00
|
|
|
struct keyspan_port_private *p_priv;
|
2005-04-17 06:20:36 +08:00
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
int i, err;
|
2007-11-29 08:21:54 +08:00
|
|
|
int baud_rate, device_port;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct urb *urb;
|
2008-07-22 18:09:07 +08:00
|
|
|
unsigned int cflag = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
d_details = p_priv->device_details;
|
2007-11-15 09:00:39 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Set some sane defaults */
|
|
|
|
p_priv->rts_state = 1;
|
|
|
|
p_priv->dtr_state = 1;
|
|
|
|
p_priv->baud = 9600;
|
|
|
|
|
|
|
|
/* force baud and lcr to be set on open */
|
|
|
|
p_priv->old_baud = 0;
|
|
|
|
p_priv->old_cflag = 0;
|
|
|
|
|
|
|
|
p_priv->out_flip = 0;
|
|
|
|
p_priv->in_flip = 0;
|
|
|
|
|
|
|
|
/* Reset low level data toggle and start reading from endpoints */
|
|
|
|
for (i = 0; i < 2; i++) {
|
2008-07-22 18:13:08 +08:00
|
|
|
urb = p_priv->in_urbs[i];
|
|
|
|
if (urb == NULL)
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* make sure endpoint data toggle is synchronized
|
|
|
|
with the device */
|
2005-04-17 06:20:36 +08:00
|
|
|
usb_clear_halt(urb->dev, urb->pipe);
|
2008-07-22 18:13:08 +08:00
|
|
|
err = usb_submit_urb(urb, GFP_KERNEL);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - submit urb %d failed (%d)\n", __func__, i, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset low level data toggle on out endpoints */
|
|
|
|
for (i = 0; i < 2; i++) {
|
2008-07-22 18:13:08 +08:00
|
|
|
urb = p_priv->out_urbs[i];
|
|
|
|
if (urb == NULL)
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
2008-07-22 18:13:08 +08:00
|
|
|
/* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
|
|
|
|
usb_pipeout(urb->pipe), 0); */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-11-29 08:21:54 +08:00
|
|
|
/* get the terminal config for the setup message now so we don't
|
|
|
|
* need to send 2 of them */
|
|
|
|
|
2013-06-07 01:32:00 +08:00
|
|
|
device_port = port->port_number;
|
2008-07-22 18:09:07 +08:00
|
|
|
if (tty) {
|
2012-07-14 22:31:47 +08:00
|
|
|
cflag = tty->termios.c_cflag;
|
2008-07-22 18:09:07 +08:00
|
|
|
/* Baud rate calculation takes baud rate as an integer
|
|
|
|
so other rates can be generated if desired. */
|
|
|
|
baud_rate = tty_get_baud_rate(tty);
|
|
|
|
/* If no match or invalid, leave as default */
|
|
|
|
if (baud_rate >= 0
|
2012-09-15 07:30:23 +08:00
|
|
|
&& d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk,
|
2008-07-22 18:09:07 +08:00
|
|
|
NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
|
|
|
|
p_priv->baud = baud_rate;
|
|
|
|
}
|
2007-11-29 08:21:54 +08:00
|
|
|
}
|
|
|
|
/* set CTS/RTS handshake etc. */
|
|
|
|
p_priv->cflag = cflag;
|
2012-07-11 22:10:16 +08:00
|
|
|
p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none;
|
2007-11-29 08:21:54 +08:00
|
|
|
|
|
|
|
keyspan_send_setup(port, 1);
|
2008-07-22 18:13:08 +08:00
|
|
|
/* mdelay(100); */
|
|
|
|
/* keyspan_set_termios(port, NULL); */
|
2007-11-29 08:21:54 +08:00
|
|
|
|
2008-04-09 00:16:06 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-06-11 19:26:29 +08:00
|
|
|
static void keyspan_dtr_rts(struct usb_serial_port *port, int on)
|
|
|
|
{
|
|
|
|
struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
|
|
|
|
|
|
|
|
p_priv->rts_state = on;
|
|
|
|
p_priv->dtr_state = on;
|
|
|
|
keyspan_send_setup(port, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void keyspan_close(struct usb_serial_port *port)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->rts_state = 0;
|
|
|
|
p_priv->dtr_state = 0;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2013-03-21 19:36:32 +08:00
|
|
|
keyspan_send_setup(port, 2);
|
|
|
|
/* pilot-xfer seems to work best with this delay */
|
|
|
|
mdelay(100);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
p_priv->out_flip = 0;
|
|
|
|
p_priv->in_flip = 0;
|
|
|
|
|
2016-05-09 02:07:59 +08:00
|
|
|
usb_kill_urb(p_priv->inack_urb);
|
2013-03-21 19:36:32 +08:00
|
|
|
for (i = 0; i < 2; i++) {
|
2016-05-09 02:07:59 +08:00
|
|
|
usb_kill_urb(p_priv->in_urbs[i]);
|
|
|
|
usb_kill_urb(p_priv->out_urbs[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* download the firmware to a pre-renumeration device */
|
|
|
|
static int keyspan_fake_startup(struct usb_serial *serial)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2012-09-18 15:02:01 +08:00
|
|
|
char *fw_name;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&serial->dev->dev, "Keyspan startup version %04x product %04x\n",
|
|
|
|
le16_to_cpu(serial->dev->descriptor.bcdDevice),
|
|
|
|
le16_to_cpu(serial->dev->descriptor.idProduct));
|
2008-07-22 18:13:08 +08:00
|
|
|
|
|
|
|
if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000)
|
|
|
|
!= 0x8000) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&serial->dev->dev, "Firmware already loaded. Quitting.\n");
|
2008-07-22 18:13:08 +08:00
|
|
|
return 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Select firmware image on the basis of idProduct */
|
|
|
|
switch (le16_to_cpu(serial->dev->descriptor.idProduct)) {
|
|
|
|
case keyspan_usa28_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa28.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case keyspan_usa28x_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa28x.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case keyspan_usa28xa_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa28xa.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case keyspan_usa28xb_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa28xb.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case keyspan_usa19_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa19.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
case keyspan_usa19qi_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa19qi.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
case keyspan_mpr_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/mpr.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case keyspan_usa19qw_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa19qw.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
case keyspan_usa18x_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa18x.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
case keyspan_usa19w_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa19w.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
case keyspan_usa49w_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa49w.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case keyspan_usa49wlc_pre_product_id:
|
2008-05-30 19:04:03 +08:00
|
|
|
fw_name = "keyspan/usa49wlc.fw";
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-05-30 19:04:03 +08:00
|
|
|
dev_err(&serial->dev->dev, "Unknown product ID (%04x)\n",
|
|
|
|
le16_to_cpu(serial->dev->descriptor.idProduct));
|
|
|
|
return 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-09-18 15:02:01 +08:00
|
|
|
if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) {
|
|
|
|
dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n",
|
|
|
|
fw_name);
|
|
|
|
return -ENOENT;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2012-09-18 15:02:01 +08:00
|
|
|
|
|
|
|
/* after downloading firmware Renumeration will occur in a
|
|
|
|
moment and the new device will bind to the real driver */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* we don't want this device to have a driver assigned to it. */
|
2008-07-22 18:13:08 +08:00
|
|
|
return 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper functions used by keyspan_setup_urbs */
|
2007-01-03 22:36:25 +08:00
|
|
|
static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *serial,
|
|
|
|
int endpoint)
|
|
|
|
{
|
|
|
|
struct usb_host_interface *iface_desc;
|
|
|
|
struct usb_endpoint_descriptor *ep;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
iface_desc = serial->interface->cur_altsetting;
|
|
|
|
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
|
|
|
|
ep = &iface_desc->endpoint[i].desc;
|
|
|
|
if (ep->bEndpointAddress == endpoint)
|
|
|
|
return ep;
|
|
|
|
}
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_warn(&serial->interface->dev, "found no endpoint descriptor for endpoint %x\n",
|
|
|
|
endpoint);
|
2007-01-03 22:36:25 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
|
2005-04-17 06:20:36 +08:00
|
|
|
int dir, void *ctx, char *buf, int len,
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
void (*callback)(struct urb *))
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct urb *urb;
|
2007-01-03 22:36:25 +08:00
|
|
|
struct usb_endpoint_descriptor const *ep_desc;
|
|
|
|
char const *ep_type_name;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (endpoint == -1)
|
|
|
|
return NULL; /* endpoint not needed */
|
|
|
|
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %x\n",
|
|
|
|
__func__, endpoint);
|
2005-04-17 06:20:36 +08:00
|
|
|
urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
|
2013-12-30 02:22:56 +08:00
|
|
|
if (!urb)
|
2005-04-17 06:20:36 +08:00
|
|
|
return NULL;
|
|
|
|
|
2007-05-19 03:10:41 +08:00
|
|
|
if (endpoint == 0) {
|
|
|
|
/* control EP filled in when used */
|
|
|
|
return urb;
|
|
|
|
}
|
|
|
|
|
2007-01-03 22:36:25 +08:00
|
|
|
ep_desc = find_ep(serial, endpoint);
|
|
|
|
if (!ep_desc) {
|
|
|
|
/* leak the urb, something's wrong and the callers don't care */
|
|
|
|
return urb;
|
|
|
|
}
|
|
|
|
if (usb_endpoint_xfer_int(ep_desc)) {
|
|
|
|
ep_type_name = "INT";
|
|
|
|
usb_fill_int_urb(urb, serial->dev,
|
|
|
|
usb_sndintpipe(serial->dev, endpoint) | dir,
|
|
|
|
buf, len, callback, ctx,
|
|
|
|
ep_desc->bInterval);
|
|
|
|
} else if (usb_endpoint_xfer_bulk(ep_desc)) {
|
|
|
|
ep_type_name = "BULK";
|
|
|
|
usb_fill_bulk_urb(urb, serial->dev,
|
|
|
|
usb_sndbulkpipe(serial->dev, endpoint) | dir,
|
|
|
|
buf, len, callback, ctx);
|
|
|
|
} else {
|
|
|
|
dev_warn(&serial->interface->dev,
|
|
|
|
"unsupported endpoint type %x\n",
|
2008-12-29 18:22:14 +08:00
|
|
|
usb_endpoint_type(ep_desc));
|
2007-01-03 22:36:25 +08:00
|
|
|
usb_free_urb(urb);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&serial->interface->dev, "%s - using urb %p for %s endpoint %x\n",
|
2007-01-03 22:36:25 +08:00
|
|
|
__func__, urb, ep_type_name, endpoint);
|
2005-04-17 06:20:36 +08:00
|
|
|
return urb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct callbacks {
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
void (*instat_callback)(struct urb *);
|
|
|
|
void (*glocont_callback)(struct urb *);
|
|
|
|
void (*indat_callback)(struct urb *);
|
|
|
|
void (*outdat_callback)(struct urb *);
|
|
|
|
void (*inack_callback)(struct urb *);
|
|
|
|
void (*outcont_callback)(struct urb *);
|
2005-04-17 06:20:36 +08:00
|
|
|
} keyspan_callbacks[] = {
|
|
|
|
{
|
|
|
|
/* msg_usa26 callbacks */
|
|
|
|
.instat_callback = usa26_instat_callback,
|
|
|
|
.glocont_callback = usa26_glocont_callback,
|
|
|
|
.indat_callback = usa26_indat_callback,
|
|
|
|
.outdat_callback = usa2x_outdat_callback,
|
|
|
|
.inack_callback = usa26_inack_callback,
|
|
|
|
.outcont_callback = usa26_outcont_callback,
|
|
|
|
}, {
|
|
|
|
/* msg_usa28 callbacks */
|
|
|
|
.instat_callback = usa28_instat_callback,
|
|
|
|
.glocont_callback = usa28_glocont_callback,
|
|
|
|
.indat_callback = usa28_indat_callback,
|
|
|
|
.outdat_callback = usa2x_outdat_callback,
|
|
|
|
.inack_callback = usa28_inack_callback,
|
|
|
|
.outcont_callback = usa28_outcont_callback,
|
|
|
|
}, {
|
|
|
|
/* msg_usa49 callbacks */
|
|
|
|
.instat_callback = usa49_instat_callback,
|
|
|
|
.glocont_callback = usa49_glocont_callback,
|
|
|
|
.indat_callback = usa49_indat_callback,
|
|
|
|
.outdat_callback = usa2x_outdat_callback,
|
|
|
|
.inack_callback = usa49_inack_callback,
|
|
|
|
.outcont_callback = usa49_outcont_callback,
|
|
|
|
}, {
|
|
|
|
/* msg_usa90 callbacks */
|
|
|
|
.instat_callback = usa90_instat_callback,
|
2008-07-22 18:13:08 +08:00
|
|
|
.glocont_callback = usa28_glocont_callback,
|
2005-04-17 06:20:36 +08:00
|
|
|
.indat_callback = usa90_indat_callback,
|
|
|
|
.outdat_callback = usa2x_outdat_callback,
|
|
|
|
.inack_callback = usa28_inack_callback,
|
|
|
|
.outcont_callback = usa90_outcont_callback,
|
2007-05-19 03:10:41 +08:00
|
|
|
}, {
|
|
|
|
/* msg_usa67 callbacks */
|
|
|
|
.instat_callback = usa67_instat_callback,
|
|
|
|
.glocont_callback = usa67_glocont_callback,
|
|
|
|
.indat_callback = usa26_indat_callback,
|
|
|
|
.outdat_callback = usa2x_outdat_callback,
|
|
|
|
.inack_callback = usa26_inack_callback,
|
|
|
|
.outcont_callback = usa26_outcont_callback,
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Generic setup urbs function that uses
|
|
|
|
data in device_details */
|
|
|
|
static void keyspan_setup_urbs(struct usb_serial *serial)
|
|
|
|
{
|
|
|
|
struct keyspan_serial_private *s_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
struct callbacks *cback;
|
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
|
|
|
d_details = s_priv->device_details;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Setup values for the various callback routines */
|
2005-04-17 06:20:36 +08:00
|
|
|
cback = &keyspan_callbacks[d_details->msg_format];
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Allocate and set up urbs for each one that is in use,
|
|
|
|
starting with instat endpoints */
|
2005-04-17 06:20:36 +08:00
|
|
|
s_priv->instat_urb = keyspan_setup_urb
|
|
|
|
(serial, d_details->instat_endpoint, USB_DIR_IN,
|
|
|
|
serial, s_priv->instat_buf, INSTAT_BUFLEN,
|
|
|
|
cback->instat_callback);
|
|
|
|
|
2007-05-19 03:10:41 +08:00
|
|
|
s_priv->indat_urb = keyspan_setup_urb
|
|
|
|
(serial, d_details->indat_endpoint, USB_DIR_IN,
|
|
|
|
serial, s_priv->indat_buf, INDAT49W_BUFLEN,
|
|
|
|
usa49wg_indat_callback);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
s_priv->glocont_urb = keyspan_setup_urb
|
|
|
|
(serial, d_details->glocont_endpoint, USB_DIR_OUT,
|
|
|
|
serial, s_priv->glocont_buf, GLOCONT_BUFLEN,
|
|
|
|
cback->glocont_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* usa19 function doesn't require prescaler */
|
2012-09-15 07:30:23 +08:00
|
|
|
static int keyspan_usa19_calc_baud(struct usb_serial_port *port,
|
|
|
|
u32 baud_rate, u32 baudclk, u8 *rate_hi,
|
2005-04-17 06:20:36 +08:00
|
|
|
u8 *rate_low, u8 *prescaler, int portnum)
|
|
|
|
{
|
|
|
|
u32 b16, /* baud rate times 16 (actual rate used internally) */
|
2008-07-22 18:13:08 +08:00
|
|
|
div, /* divisor */
|
2005-04-17 06:20:36 +08:00
|
|
|
cnt; /* inverse of divisor (programmed into 8051) */
|
|
|
|
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
|
2008-07-22 18:13:08 +08:00
|
|
|
|
|
|
|
/* prevent divide by zero... */
|
|
|
|
b16 = baud_rate * 16L;
|
|
|
|
if (b16 == 0)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
|
|
|
/* Any "standard" rate over 57k6 is marginal on the USA-19
|
|
|
|
as we run out of divisor resolution. */
|
|
|
|
if (baud_rate > 57600)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
|
|
|
|
|
|
|
/* calculate the divisor and the counter (its inverse) */
|
|
|
|
div = baudclk / b16;
|
|
|
|
if (div == 0)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
|
|
|
else
|
2005-04-17 06:20:36 +08:00
|
|
|
cnt = 0 - div;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
if (div > 0xffff)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* return the counter values if non-null */
|
|
|
|
if (rate_low)
|
2005-04-17 06:20:36 +08:00
|
|
|
*rate_low = (u8) (cnt & 0xff);
|
2008-07-22 18:13:08 +08:00
|
|
|
if (rate_hi)
|
2005-04-17 06:20:36 +08:00
|
|
|
*rate_hi = (u8) ((cnt >> 8) & 0xff);
|
2008-07-22 18:13:08 +08:00
|
|
|
if (rate_low && rate_hi)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
|
2008-07-22 18:13:08 +08:00
|
|
|
__func__, baud_rate, *rate_hi, *rate_low);
|
|
|
|
return KEYSPAN_BAUD_RATE_OK;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* usa19hs function doesn't require prescaler */
|
2012-09-15 07:30:23 +08:00
|
|
|
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)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
u32 b16, /* baud rate times 16 (actual rate used internally) */
|
2008-07-22 18:13:08 +08:00
|
|
|
div; /* divisor */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* prevent divide by zero... */
|
|
|
|
b16 = baud_rate * 16L;
|
|
|
|
if (b16 == 0)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* calculate the divisor */
|
|
|
|
div = baudclk / b16;
|
|
|
|
if (div == 0)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
if (div > 0xffff)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* return the counter values if non-null */
|
|
|
|
if (rate_low)
|
2005-04-17 06:20:36 +08:00
|
|
|
*rate_low = (u8) (div & 0xff);
|
2008-07-22 18:13:08 +08:00
|
|
|
|
|
|
|
if (rate_hi)
|
2005-04-17 06:20:36 +08:00
|
|
|
*rate_hi = (u8) ((div >> 8) & 0xff);
|
2008-07-22 18:13:08 +08:00
|
|
|
|
|
|
|
if (rate_low && rate_hi)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
|
2008-07-22 18:13:08 +08:00
|
|
|
__func__, baud_rate, *rate_hi, *rate_low);
|
|
|
|
|
|
|
|
return KEYSPAN_BAUD_RATE_OK;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-09-15 07:30:23 +08:00
|
|
|
static int keyspan_usa19w_calc_baud(struct usb_serial_port *port,
|
|
|
|
u32 baud_rate, u32 baudclk, u8 *rate_hi,
|
2005-04-17 06:20:36 +08:00
|
|
|
u8 *rate_low, u8 *prescaler, int portnum)
|
|
|
|
{
|
|
|
|
u32 b16, /* baud rate times 16 (actual rate used internally) */
|
|
|
|
clk, /* clock with 13/8 prescaler */
|
2008-07-22 18:13:08 +08:00
|
|
|
div, /* divisor using 13/8 prescaler */
|
2005-04-17 06:20:36 +08:00
|
|
|
res, /* resulting baud rate using 13/8 prescaler */
|
|
|
|
diff, /* error using 13/8 prescaler */
|
|
|
|
smallest_diff;
|
|
|
|
u8 best_prescaler;
|
|
|
|
int i;
|
|
|
|
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* prevent divide by zero */
|
|
|
|
b16 = baud_rate * 16L;
|
|
|
|
if (b16 == 0)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Calculate prescaler by trying them all and looking
|
|
|
|
for best fit */
|
|
|
|
|
|
|
|
/* start with largest possible difference */
|
2005-04-17 06:20:36 +08:00
|
|
|
smallest_diff = 0xffffffff;
|
|
|
|
|
|
|
|
/* 0 is an invalid prescaler, used as a flag */
|
|
|
|
best_prescaler = 0;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
for (i = 8; i <= 0xff; ++i) {
|
2005-04-17 06:20:36 +08:00
|
|
|
clk = (baudclk * 8) / (u32) i;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
|
|
|
div = clk / b16;
|
|
|
|
if (div == 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
|
|
|
|
res = clk / div;
|
2008-07-22 18:13:08 +08:00
|
|
|
diff = (res > b16) ? (res-b16) : (b16-res);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
if (diff < smallest_diff) {
|
2005-04-17 06:20:36 +08:00
|
|
|
best_prescaler = i;
|
|
|
|
smallest_diff = diff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
if (best_prescaler == 0)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
clk = (baudclk * 8) / (u32) best_prescaler;
|
|
|
|
div = clk / b16;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* return the divisor and prescaler if non-null */
|
|
|
|
if (rate_low)
|
2005-04-17 06:20:36 +08:00
|
|
|
*rate_low = (u8) (div & 0xff);
|
2008-07-22 18:13:08 +08:00
|
|
|
if (rate_hi)
|
2005-04-17 06:20:36 +08:00
|
|
|
*rate_hi = (u8) ((div >> 8) & 0xff);
|
|
|
|
if (prescaler) {
|
|
|
|
*prescaler = best_prescaler;
|
2012-09-15 07:30:23 +08:00
|
|
|
/* dev_dbg(&port->dev, "%s - %d %d\n", __func__, *prescaler, div); */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
return KEYSPAN_BAUD_RATE_OK;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* USA-28 supports different maximum baud rates on each port */
|
2012-09-15 07:30:23 +08:00
|
|
|
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)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
u32 b16, /* baud rate times 16 (actual rate used internally) */
|
2008-07-22 18:13:08 +08:00
|
|
|
div, /* divisor */
|
2005-04-17 06:20:36 +08:00
|
|
|
cnt; /* inverse of divisor (programmed into 8051) */
|
|
|
|
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* prevent divide by zero */
|
2008-07-22 18:13:08 +08:00
|
|
|
b16 = baud_rate * 16L;
|
|
|
|
if (b16 == 0)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
|
|
|
|
|
|
|
/* calculate the divisor and the counter (its inverse) */
|
|
|
|
div = KEYSPAN_USA28_BAUDCLK / b16;
|
|
|
|
if (div == 0)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
|
|
|
else
|
2005-04-17 06:20:36 +08:00
|
|
|
cnt = 0 - div;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* check for out of range, based on portnum,
|
|
|
|
and return result */
|
|
|
|
if (portnum == 0) {
|
|
|
|
if (div > 0xffff)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
|
|
|
} else {
|
|
|
|
if (portnum == 1) {
|
|
|
|
if (div > 0xff)
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
|
|
|
} else
|
|
|
|
return KEYSPAN_INVALID_BAUD_RATE;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return the counter values if not NULL
|
|
|
|
(port 1 will ignore retHi) */
|
2008-07-22 18:13:08 +08:00
|
|
|
if (rate_low)
|
2005-04-17 06:20:36 +08:00
|
|
|
*rate_low = (u8) (cnt & 0xff);
|
2008-07-22 18:13:08 +08:00
|
|
|
if (rate_hi)
|
2005-04-17 06:20:36 +08:00
|
|
|
*rate_hi = (u8) ((cnt >> 8) & 0xff);
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - %d OK.\n", __func__, baud_rate);
|
2008-07-22 18:13:08 +08:00
|
|
|
return KEYSPAN_BAUD_RATE_OK;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int keyspan_usa26_send_setup(struct usb_serial *serial,
|
|
|
|
struct usb_serial_port *port,
|
|
|
|
int reset_port)
|
|
|
|
{
|
2008-07-22 18:13:08 +08:00
|
|
|
struct keyspan_usa26_portControlMessage msg;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct keyspan_serial_private *s_priv;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
struct urb *this_urb;
|
|
|
|
int device_port, err;
|
|
|
|
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s reset=%d\n", __func__, reset_port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
d_details = s_priv->device_details;
|
2013-06-07 01:32:00 +08:00
|
|
|
device_port = port->port_number;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
this_urb = p_priv->outcont_urb;
|
|
|
|
|
|
|
|
/* Make sure we have an urb then send the message */
|
|
|
|
if (this_urb == NULL) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&port->dev, "%s - endpoint %x\n",
|
|
|
|
__func__, usb_pipeendpoint(this_urb->pipe));
|
2014-05-16 23:39:13 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Save reset port val for resend.
|
2007-05-19 03:10:41 +08:00
|
|
|
Don't overwrite resend for open/close condition. */
|
|
|
|
if ((reset_port + 1) > p_priv->resend_cont)
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->resend_cont = reset_port + 1;
|
|
|
|
if (this_urb->status == -EINPROGRESS) {
|
2012-09-15 07:30:23 +08:00
|
|
|
/* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
|
2005-04-17 06:20:36 +08:00
|
|
|
mdelay(5);
|
2008-07-22 18:13:08 +08:00
|
|
|
return -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage));
|
|
|
|
|
|
|
|
/* Only set baud rate if it's changed */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (p_priv->old_baud != p_priv->baud) {
|
|
|
|
p_priv->old_baud = p_priv->baud;
|
|
|
|
msg.setClocking = 0xff;
|
2012-09-15 07:30:23 +08:00
|
|
|
if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
|
|
|
|
&msg.baudHi, &msg.baudLo, &msg.prescaler,
|
|
|
|
device_port) == KEYSPAN_INVALID_BAUD_RATE) {
|
|
|
|
dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
|
|
|
|
__func__, p_priv->baud);
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.baudLo = 0;
|
|
|
|
msg.baudHi = 125; /* Values for 9600 baud */
|
|
|
|
msg.prescaler = 10;
|
|
|
|
}
|
|
|
|
msg.setPrescaler = 0xff;
|
|
|
|
}
|
|
|
|
|
2012-07-11 22:10:16 +08:00
|
|
|
msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
|
2005-04-17 06:20:36 +08:00
|
|
|
switch (p_priv->cflag & CSIZE) {
|
|
|
|
case CS5:
|
|
|
|
msg.lcr |= USA_DATABITS_5;
|
|
|
|
break;
|
|
|
|
case CS6:
|
|
|
|
msg.lcr |= USA_DATABITS_6;
|
|
|
|
break;
|
|
|
|
case CS7:
|
|
|
|
msg.lcr |= USA_DATABITS_7;
|
|
|
|
break;
|
|
|
|
case CS8:
|
|
|
|
msg.lcr |= USA_DATABITS_8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p_priv->cflag & PARENB) {
|
|
|
|
/* note USA_PARITY_NONE == 0 */
|
2012-07-11 22:10:16 +08:00
|
|
|
msg.lcr |= (p_priv->cflag & PARODD) ?
|
2008-07-22 18:13:08 +08:00
|
|
|
USA_PARITY_ODD : USA_PARITY_EVEN;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
msg.setLcr = 0xff;
|
|
|
|
|
|
|
|
msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
|
|
|
|
msg.xonFlowControl = 0;
|
|
|
|
msg.setFlowControl = 0xff;
|
|
|
|
msg.forwardingLength = 16;
|
|
|
|
msg.xonChar = 17;
|
|
|
|
msg.xoffChar = 19;
|
|
|
|
|
|
|
|
/* Opening port */
|
|
|
|
if (reset_port == 1) {
|
|
|
|
msg._txOn = 1;
|
|
|
|
msg._txOff = 0;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txBreak = 0;
|
|
|
|
msg.rxOn = 1;
|
|
|
|
msg.rxOff = 0;
|
|
|
|
msg.rxFlush = 1;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Closing port */
|
|
|
|
else if (reset_port == 2) {
|
|
|
|
msg._txOn = 0;
|
|
|
|
msg._txOff = 1;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txBreak = 0;
|
|
|
|
msg.rxOn = 0;
|
|
|
|
msg.rxOff = 1;
|
|
|
|
msg.rxFlush = 1;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sending intermediate configs */
|
|
|
|
else {
|
2008-07-22 18:13:08 +08:00
|
|
|
msg._txOn = (!p_priv->break_on);
|
2005-04-17 06:20:36 +08:00
|
|
|
msg._txOff = 0;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txBreak = (p_priv->break_on);
|
|
|
|
msg.rxOn = 0;
|
|
|
|
msg.rxOff = 0;
|
|
|
|
msg.rxFlush = 0;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0x0;
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Do handshaking outputs */
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.setTxTriState_setRts = 0xff;
|
|
|
|
msg.txTriState_rts = p_priv->rts_state;
|
|
|
|
|
|
|
|
msg.setHskoa_setDtr = 0xff;
|
|
|
|
msg.hskoa_dtr = p_priv->dtr_state;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->resend_cont = 0;
|
2008-07-22 18:13:08 +08:00
|
|
|
memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* send the data out the device on control endpoint */
|
|
|
|
this_urb->transfer_buffer_length = sizeof(msg);
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
err = usb_submit_urb(this_urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
|
2008-04-09 00:16:06 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int keyspan_usa28_send_setup(struct usb_serial *serial,
|
|
|
|
struct usb_serial_port *port,
|
|
|
|
int reset_port)
|
|
|
|
{
|
2008-07-22 18:13:08 +08:00
|
|
|
struct keyspan_usa28_portControlMessage msg;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct keyspan_serial_private *s_priv;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
struct urb *this_urb;
|
|
|
|
int device_port, err;
|
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
d_details = s_priv->device_details;
|
2013-06-07 01:32:00 +08:00
|
|
|
device_port = port->port_number;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* only do something if we have a bulk out endpoint */
|
2008-07-22 18:13:08 +08:00
|
|
|
this_urb = p_priv->outcont_urb;
|
|
|
|
if (this_urb == NULL) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save reset port val for resend.
|
2007-05-19 03:10:41 +08:00
|
|
|
Don't overwrite resend for open/close condition. */
|
|
|
|
if ((reset_port + 1) > p_priv->resend_cont)
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->resend_cont = reset_port + 1;
|
|
|
|
if (this_urb->status == -EINPROGRESS) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s already writing\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
mdelay(5);
|
2008-07-22 18:13:08 +08:00
|
|
|
return -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
msg.setBaudRate = 1;
|
2012-09-15 07:30:23 +08:00
|
|
|
if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
|
|
|
|
&msg.baudHi, &msg.baudLo, NULL,
|
|
|
|
device_port) == KEYSPAN_INVALID_BAUD_RATE) {
|
|
|
|
dev_dbg(&port->dev, "%s - Invalid baud rate requested %d.\n",
|
2008-07-22 18:13:08 +08:00
|
|
|
__func__, p_priv->baud);
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.baudLo = 0xff;
|
|
|
|
msg.baudHi = 0xb2; /* Values for 9600 baud */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If parity is enabled, we must calculate it ourselves. */
|
|
|
|
msg.parity = 0; /* XXX for now */
|
|
|
|
|
|
|
|
msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
|
|
|
|
msg.xonFlowControl = 0;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Do handshaking outputs, DTR is inverted relative to RTS */
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.rts = p_priv->rts_state;
|
|
|
|
msg.dtr = p_priv->dtr_state;
|
|
|
|
|
|
|
|
msg.forwardingLength = 16;
|
|
|
|
msg.forwardMs = 10;
|
|
|
|
msg.breakThreshold = 45;
|
|
|
|
msg.xonChar = 17;
|
|
|
|
msg.xoffChar = 19;
|
|
|
|
|
|
|
|
/*msg.returnStatus = 1;
|
|
|
|
msg.resetDataToggle = 0xff;*/
|
|
|
|
/* Opening port */
|
|
|
|
if (reset_port == 1) {
|
|
|
|
msg._txOn = 1;
|
|
|
|
msg._txOff = 0;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txForceXoff = 0;
|
|
|
|
msg.txBreak = 0;
|
|
|
|
msg.rxOn = 1;
|
|
|
|
msg.rxOff = 0;
|
|
|
|
msg.rxFlush = 1;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0xff;
|
|
|
|
}
|
|
|
|
/* Closing port */
|
|
|
|
else if (reset_port == 2) {
|
|
|
|
msg._txOn = 0;
|
|
|
|
msg._txOff = 1;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txForceXoff = 0;
|
|
|
|
msg.txBreak = 0;
|
|
|
|
msg.rxOn = 0;
|
|
|
|
msg.rxOff = 1;
|
|
|
|
msg.rxFlush = 1;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0;
|
|
|
|
}
|
|
|
|
/* Sending intermediate configs */
|
|
|
|
else {
|
2008-07-22 18:13:08 +08:00
|
|
|
msg._txOn = (!p_priv->break_on);
|
2005-04-17 06:20:36 +08:00
|
|
|
msg._txOff = 0;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txForceXoff = 0;
|
|
|
|
msg.txBreak = (p_priv->break_on);
|
|
|
|
msg.rxOn = 0;
|
|
|
|
msg.rxOff = 0;
|
|
|
|
msg.rxFlush = 0;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0x0;
|
|
|
|
}
|
|
|
|
|
|
|
|
p_priv->resend_cont = 0;
|
2008-07-22 18:13:08 +08:00
|
|
|
memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* send the data out the device on control endpoint */
|
|
|
|
this_urb->transfer_buffer_length = sizeof(msg);
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
err = usb_submit_urb(this_urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-09 00:16:06 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int keyspan_usa49_send_setup(struct usb_serial *serial,
|
|
|
|
struct usb_serial_port *port,
|
|
|
|
int reset_port)
|
|
|
|
{
|
2007-05-19 03:10:41 +08:00
|
|
|
struct keyspan_usa49_portControlMessage msg;
|
|
|
|
struct usb_ctrlrequest *dr = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct keyspan_serial_private *s_priv;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
struct urb *this_urb;
|
|
|
|
int err, device_port;
|
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
d_details = s_priv->device_details;
|
|
|
|
|
|
|
|
this_urb = s_priv->glocont_urb;
|
|
|
|
|
2007-05-19 03:10:41 +08:00
|
|
|
/* Work out which port within the device is being setup */
|
2013-06-07 01:32:00 +08:00
|
|
|
device_port = port->port_number;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-02-21 15:28:44 +08:00
|
|
|
/* Make sure we have an urb then send the message */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (this_urb == NULL) {
|
2013-06-07 01:32:00 +08:00
|
|
|
dev_dbg(&port->dev, "%s - oops no urb for port.\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-05-09 02:08:00 +08:00
|
|
|
dev_dbg(&port->dev, "%s - endpoint %x (%d)\n",
|
2013-06-07 01:32:00 +08:00
|
|
|
__func__, usb_pipeendpoint(this_urb->pipe), device_port);
|
2011-02-21 15:28:44 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Save reset port val for resend.
|
2007-05-19 03:10:41 +08:00
|
|
|
Don't overwrite resend for open/close condition. */
|
|
|
|
if ((reset_port + 1) > p_priv->resend_cont)
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->resend_cont = reset_port + 1;
|
2007-05-19 03:10:41 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (this_urb->status == -EINPROGRESS) {
|
2012-09-15 07:30:23 +08:00
|
|
|
/* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
|
2005-04-17 06:20:36 +08:00
|
|
|
mdelay(5);
|
2008-07-22 18:13:08 +08:00
|
|
|
return -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
memset(&msg, 0, sizeof(struct keyspan_usa49_portControlMessage));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
msg.portNumber = device_port;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
|
|
|
/* Only set baud rate if it's changed */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (p_priv->old_baud != p_priv->baud) {
|
|
|
|
p_priv->old_baud = p_priv->baud;
|
|
|
|
msg.setClocking = 0xff;
|
2012-09-15 07:30:23 +08:00
|
|
|
if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
|
|
|
|
&msg.baudHi, &msg.baudLo, &msg.prescaler,
|
|
|
|
device_port) == KEYSPAN_INVALID_BAUD_RATE) {
|
|
|
|
dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
|
|
|
|
__func__, p_priv->baud);
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.baudLo = 0;
|
|
|
|
msg.baudHi = 125; /* Values for 9600 baud */
|
|
|
|
msg.prescaler = 10;
|
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
/* msg.setPrescaler = 0xff; */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-07-11 22:10:16 +08:00
|
|
|
msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
|
2005-04-17 06:20:36 +08:00
|
|
|
switch (p_priv->cflag & CSIZE) {
|
|
|
|
case CS5:
|
|
|
|
msg.lcr |= USA_DATABITS_5;
|
|
|
|
break;
|
|
|
|
case CS6:
|
|
|
|
msg.lcr |= USA_DATABITS_6;
|
|
|
|
break;
|
|
|
|
case CS7:
|
|
|
|
msg.lcr |= USA_DATABITS_7;
|
|
|
|
break;
|
|
|
|
case CS8:
|
|
|
|
msg.lcr |= USA_DATABITS_8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p_priv->cflag & PARENB) {
|
|
|
|
/* note USA_PARITY_NONE == 0 */
|
2012-07-11 22:10:16 +08:00
|
|
|
msg.lcr |= (p_priv->cflag & PARODD) ?
|
2008-07-22 18:13:08 +08:00
|
|
|
USA_PARITY_ODD : USA_PARITY_EVEN;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
msg.setLcr = 0xff;
|
|
|
|
|
|
|
|
msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
|
|
|
|
msg.xonFlowControl = 0;
|
|
|
|
msg.setFlowControl = 0xff;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.forwardingLength = 16;
|
|
|
|
msg.xonChar = 17;
|
|
|
|
msg.xoffChar = 19;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Opening port */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (reset_port == 1) {
|
|
|
|
msg._txOn = 1;
|
|
|
|
msg._txOff = 0;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txBreak = 0;
|
|
|
|
msg.rxOn = 1;
|
|
|
|
msg.rxOff = 0;
|
|
|
|
msg.rxFlush = 1;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0xff;
|
|
|
|
msg.enablePort = 1;
|
|
|
|
msg.disablePort = 0;
|
|
|
|
}
|
|
|
|
/* Closing port */
|
|
|
|
else if (reset_port == 2) {
|
|
|
|
msg._txOn = 0;
|
|
|
|
msg._txOff = 1;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txBreak = 0;
|
|
|
|
msg.rxOn = 0;
|
|
|
|
msg.rxOff = 1;
|
|
|
|
msg.rxFlush = 1;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0;
|
|
|
|
msg.enablePort = 0;
|
|
|
|
msg.disablePort = 1;
|
|
|
|
}
|
|
|
|
/* Sending intermediate configs */
|
|
|
|
else {
|
2008-07-22 18:13:08 +08:00
|
|
|
msg._txOn = (!p_priv->break_on);
|
2005-04-17 06:20:36 +08:00
|
|
|
msg._txOff = 0;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txBreak = (p_priv->break_on);
|
|
|
|
msg.rxOn = 0;
|
|
|
|
msg.rxOff = 0;
|
|
|
|
msg.rxFlush = 0;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0x0;
|
|
|
|
msg.enablePort = 0;
|
|
|
|
msg.disablePort = 0;
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Do handshaking outputs */
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.setRts = 0xff;
|
|
|
|
msg.rts = p_priv->rts_state;
|
|
|
|
|
|
|
|
msg.setDtr = 0xff;
|
|
|
|
msg.dtr = p_priv->dtr_state;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->resend_cont = 0;
|
2007-05-19 03:10:41 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* if the device is a 49wg, we send control message on usb
|
|
|
|
control EP 0 */
|
2007-05-19 03:10:41 +08:00
|
|
|
|
|
|
|
if (d_details->product_id == keyspan_usa49wg_product_id) {
|
|
|
|
dr = (void *)(s_priv->ctrl_buf);
|
|
|
|
dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT;
|
2016-02-05 02:01:30 +08:00
|
|
|
dr->bRequest = 0xB0; /* 49wg control message */
|
2007-05-19 03:10:41 +08:00
|
|
|
dr->wValue = 0;
|
|
|
|
dr->wIndex = 0;
|
|
|
|
dr->wLength = cpu_to_le16(sizeof(msg));
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
memcpy(s_priv->glocont_buf, &msg, sizeof(msg));
|
2007-05-19 03:10:41 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
usb_fill_control_urb(this_urb, serial->dev,
|
|
|
|
usb_sndctrlpipe(serial->dev, 0),
|
|
|
|
(unsigned char *)dr, s_priv->glocont_buf,
|
|
|
|
sizeof(msg), usa49_glocont_callback, serial);
|
2007-05-19 03:10:41 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2007-05-19 03:10:41 +08:00
|
|
|
/* send the data out the device on control endpoint */
|
|
|
|
this_urb->transfer_buffer_length = sizeof(msg);
|
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
err = usb_submit_urb(this_urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-09 00:16:06 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int keyspan_usa90_send_setup(struct usb_serial *serial,
|
|
|
|
struct usb_serial_port *port,
|
|
|
|
int reset_port)
|
|
|
|
{
|
2008-07-22 18:13:08 +08:00
|
|
|
struct keyspan_usa90_portControlMessage msg;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct keyspan_serial_private *s_priv;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
struct urb *this_urb;
|
|
|
|
int err;
|
|
|
|
u8 prescaler;
|
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
d_details = s_priv->device_details;
|
|
|
|
|
|
|
|
/* only do something if we have a bulk out endpoint */
|
2008-07-22 18:13:08 +08:00
|
|
|
this_urb = p_priv->outcont_urb;
|
|
|
|
if (this_urb == NULL) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save reset port val for resend.
|
|
|
|
Don't overwrite resend for open/close condition. */
|
|
|
|
if ((reset_port + 1) > p_priv->resend_cont)
|
|
|
|
p_priv->resend_cont = reset_port + 1;
|
|
|
|
if (this_urb->status == -EINPROGRESS) {
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s already writing\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
mdelay(5);
|
2008-07-22 18:13:08 +08:00
|
|
|
return -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
memset(&msg, 0, sizeof(struct keyspan_usa90_portControlMessage));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Only set baud rate if it's changed */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (p_priv->old_baud != p_priv->baud) {
|
|
|
|
p_priv->old_baud = p_priv->baud;
|
|
|
|
msg.setClocking = 0x01;
|
2012-09-15 07:30:23 +08:00
|
|
|
if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
|
|
|
|
&msg.baudHi, &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) {
|
|
|
|
dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
|
|
|
|
__func__, p_priv->baud);
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->baud = 9600;
|
2012-09-15 07:30:23 +08:00
|
|
|
d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
|
2005-04-17 06:20:36 +08:00
|
|
|
&msg.baudHi, &msg.baudLo, &prescaler, 0);
|
|
|
|
}
|
|
|
|
msg.setRxMode = 1;
|
|
|
|
msg.setTxMode = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* modes must always be correctly specified */
|
2008-07-22 18:13:08 +08:00
|
|
|
if (p_priv->baud > 57600) {
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.rxMode = RXMODE_DMA;
|
|
|
|
msg.txMode = TXMODE_DMA;
|
2008-07-22 18:13:08 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.rxMode = RXMODE_BYHAND;
|
|
|
|
msg.txMode = TXMODE_BYHAND;
|
|
|
|
}
|
|
|
|
|
2012-07-11 22:10:16 +08:00
|
|
|
msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
|
2005-04-17 06:20:36 +08:00
|
|
|
switch (p_priv->cflag & CSIZE) {
|
|
|
|
case CS5:
|
|
|
|
msg.lcr |= USA_DATABITS_5;
|
|
|
|
break;
|
|
|
|
case CS6:
|
|
|
|
msg.lcr |= USA_DATABITS_6;
|
|
|
|
break;
|
|
|
|
case CS7:
|
|
|
|
msg.lcr |= USA_DATABITS_7;
|
|
|
|
break;
|
|
|
|
case CS8:
|
|
|
|
msg.lcr |= USA_DATABITS_8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p_priv->cflag & PARENB) {
|
|
|
|
/* note USA_PARITY_NONE == 0 */
|
2012-07-11 22:10:16 +08:00
|
|
|
msg.lcr |= (p_priv->cflag & PARODD) ?
|
2008-07-22 18:13:08 +08:00
|
|
|
USA_PARITY_ODD : USA_PARITY_EVEN;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (p_priv->old_cflag != p_priv->cflag) {
|
|
|
|
p_priv->old_cflag = p_priv->cflag;
|
|
|
|
msg.setLcr = 0x01;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_priv->flow_control == flow_cts)
|
|
|
|
msg.txFlowControl = TXFLOW_CTS;
|
|
|
|
msg.setTxFlowControl = 0x01;
|
|
|
|
msg.setRxFlowControl = 0x01;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.rxForwardingLength = 16;
|
2008-07-22 18:13:08 +08:00
|
|
|
msg.rxForwardingTimeout = 16;
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.txAckSetting = 0;
|
|
|
|
msg.xonChar = 17;
|
|
|
|
msg.xoffChar = 19;
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Opening port */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (reset_port == 1) {
|
|
|
|
msg.portEnabled = 1;
|
|
|
|
msg.rxFlush = 1;
|
|
|
|
msg.txBreak = (p_priv->break_on);
|
|
|
|
}
|
|
|
|
/* Closing port */
|
2008-07-22 18:13:08 +08:00
|
|
|
else if (reset_port == 2)
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.portEnabled = 0;
|
|
|
|
/* Sending intermediate configs */
|
|
|
|
else {
|
2010-02-17 23:05:47 +08:00
|
|
|
msg.portEnabled = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.txBreak = (p_priv->break_on);
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
/* Do handshaking outputs */
|
2005-04-17 06:20:36 +08:00
|
|
|
msg.setRts = 0x01;
|
|
|
|
msg.rts = p_priv->rts_state;
|
|
|
|
|
|
|
|
msg.setDtr = 0x01;
|
|
|
|
msg.dtr = p_priv->dtr_state;
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
p_priv->resend_cont = 0;
|
2008-07-22 18:13:08 +08:00
|
|
|
memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* send the data out the device on control endpoint */
|
|
|
|
this_urb->transfer_buffer_length = sizeof(msg);
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
err = usb_submit_urb(this_urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
|
2008-04-09 00:16:06 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:10:41 +08:00
|
|
|
static int keyspan_usa67_send_setup(struct usb_serial *serial,
|
|
|
|
struct usb_serial_port *port,
|
|
|
|
int reset_port)
|
|
|
|
{
|
|
|
|
struct keyspan_usa67_portControlMessage msg;
|
|
|
|
struct keyspan_serial_private *s_priv;
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
struct urb *this_urb;
|
|
|
|
int err, device_port;
|
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
d_details = s_priv->device_details;
|
|
|
|
|
|
|
|
this_urb = s_priv->glocont_urb;
|
|
|
|
|
|
|
|
/* Work out which port within the device is being setup */
|
2013-06-07 01:32:00 +08:00
|
|
|
device_port = port->port_number;
|
2007-05-19 03:10:41 +08:00
|
|
|
|
|
|
|
/* Make sure we have an urb then send the message */
|
|
|
|
if (this_urb == NULL) {
|
2013-06-07 01:32:00 +08:00
|
|
|
dev_dbg(&port->dev, "%s - oops no urb for port.\n", __func__);
|
2007-05-19 03:10:41 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save reset port val for resend.
|
|
|
|
Don't overwrite resend for open/close condition. */
|
|
|
|
if ((reset_port + 1) > p_priv->resend_cont)
|
|
|
|
p_priv->resend_cont = reset_port + 1;
|
|
|
|
if (this_urb->status == -EINPROGRESS) {
|
2012-09-15 07:30:23 +08:00
|
|
|
/* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
|
2007-05-19 03:10:41 +08:00
|
|
|
mdelay(5);
|
2008-07-22 18:13:08 +08:00
|
|
|
return -1;
|
2007-05-19 03:10:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage));
|
|
|
|
|
|
|
|
msg.port = device_port;
|
|
|
|
|
|
|
|
/* Only set baud rate if it's changed */
|
|
|
|
if (p_priv->old_baud != p_priv->baud) {
|
|
|
|
p_priv->old_baud = p_priv->baud;
|
|
|
|
msg.setClocking = 0xff;
|
2012-09-15 07:30:23 +08:00
|
|
|
if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
|
|
|
|
&msg.baudHi, &msg.baudLo, &msg.prescaler,
|
|
|
|
device_port) == KEYSPAN_INVALID_BAUD_RATE) {
|
|
|
|
dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
|
|
|
|
__func__, p_priv->baud);
|
2007-05-19 03:10:41 +08:00
|
|
|
msg.baudLo = 0;
|
|
|
|
msg.baudHi = 125; /* Values for 9600 baud */
|
|
|
|
msg.prescaler = 10;
|
|
|
|
}
|
|
|
|
msg.setPrescaler = 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
|
|
|
|
switch (p_priv->cflag & CSIZE) {
|
|
|
|
case CS5:
|
|
|
|
msg.lcr |= USA_DATABITS_5;
|
|
|
|
break;
|
|
|
|
case CS6:
|
|
|
|
msg.lcr |= USA_DATABITS_6;
|
|
|
|
break;
|
|
|
|
case CS7:
|
|
|
|
msg.lcr |= USA_DATABITS_7;
|
|
|
|
break;
|
|
|
|
case CS8:
|
|
|
|
msg.lcr |= USA_DATABITS_8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p_priv->cflag & PARENB) {
|
|
|
|
/* note USA_PARITY_NONE == 0 */
|
2012-07-11 22:10:16 +08:00
|
|
|
msg.lcr |= (p_priv->cflag & PARODD) ?
|
2008-07-22 18:13:08 +08:00
|
|
|
USA_PARITY_ODD : USA_PARITY_EVEN;
|
2007-05-19 03:10:41 +08:00
|
|
|
}
|
|
|
|
msg.setLcr = 0xff;
|
|
|
|
|
|
|
|
msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
|
|
|
|
msg.xonFlowControl = 0;
|
|
|
|
msg.setFlowControl = 0xff;
|
|
|
|
msg.forwardingLength = 16;
|
|
|
|
msg.xonChar = 17;
|
|
|
|
msg.xoffChar = 19;
|
|
|
|
|
|
|
|
if (reset_port == 1) {
|
|
|
|
/* Opening port */
|
|
|
|
msg._txOn = 1;
|
|
|
|
msg._txOff = 0;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txBreak = 0;
|
|
|
|
msg.rxOn = 1;
|
|
|
|
msg.rxOff = 0;
|
|
|
|
msg.rxFlush = 1;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0xff;
|
|
|
|
} else if (reset_port == 2) {
|
|
|
|
/* Closing port */
|
|
|
|
msg._txOn = 0;
|
|
|
|
msg._txOff = 1;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txBreak = 0;
|
|
|
|
msg.rxOn = 0;
|
|
|
|
msg.rxOff = 1;
|
|
|
|
msg.rxFlush = 1;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0;
|
|
|
|
} else {
|
|
|
|
/* Sending intermediate configs */
|
2008-07-22 18:13:08 +08:00
|
|
|
msg._txOn = (!p_priv->break_on);
|
2007-05-19 03:10:41 +08:00
|
|
|
msg._txOff = 0;
|
|
|
|
msg.txFlush = 0;
|
|
|
|
msg.txBreak = (p_priv->break_on);
|
|
|
|
msg.rxOn = 0;
|
|
|
|
msg.rxOff = 0;
|
|
|
|
msg.rxFlush = 0;
|
|
|
|
msg.rxForward = 0;
|
|
|
|
msg.returnStatus = 0;
|
|
|
|
msg.resetDataToggle = 0x0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do handshaking outputs */
|
|
|
|
msg.setTxTriState_setRts = 0xff;
|
|
|
|
msg.txTriState_rts = p_priv->rts_state;
|
|
|
|
|
|
|
|
msg.setHskoa_setDtr = 0xff;
|
|
|
|
msg.hskoa_dtr = p_priv->dtr_state;
|
|
|
|
|
|
|
|
p_priv->resend_cont = 0;
|
|
|
|
|
|
|
|
memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
|
|
|
|
|
|
|
|
/* send the data out the device on control endpoint */
|
|
|
|
this_urb->transfer_buffer_length = sizeof(msg);
|
|
|
|
|
|
|
|
err = usb_submit_urb(this_urb, GFP_ATOMIC);
|
|
|
|
if (err != 0)
|
2012-09-15 07:30:23 +08:00
|
|
|
dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
|
2008-04-09 00:16:06 +08:00
|
|
|
return 0;
|
2007-05-19 03:10:41 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
|
|
|
|
{
|
|
|
|
struct usb_serial *serial = port->serial;
|
|
|
|
struct keyspan_serial_private *s_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
|
|
|
d_details = s_priv->device_details;
|
|
|
|
|
|
|
|
switch (d_details->msg_format) {
|
|
|
|
case msg_usa26:
|
|
|
|
keyspan_usa26_send_setup(serial, port, reset_port);
|
|
|
|
break;
|
|
|
|
case msg_usa28:
|
|
|
|
keyspan_usa28_send_setup(serial, port, reset_port);
|
|
|
|
break;
|
|
|
|
case msg_usa49:
|
|
|
|
keyspan_usa49_send_setup(serial, port, reset_port);
|
|
|
|
break;
|
|
|
|
case msg_usa90:
|
|
|
|
keyspan_usa90_send_setup(serial, port, reset_port);
|
|
|
|
break;
|
2007-05-19 03:10:41 +08:00
|
|
|
case msg_usa67:
|
|
|
|
keyspan_usa67_send_setup(serial, port, reset_port);
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Gets called by the "real" driver (ie once firmware is loaded
|
|
|
|
and renumeration has taken place. */
|
2008-07-22 18:13:08 +08:00
|
|
|
static int keyspan_startup(struct usb_serial *serial)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i, err;
|
|
|
|
struct keyspan_serial_private *s_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
|
|
|
|
for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i)
|
2008-07-22 18:13:08 +08:00
|
|
|
if (d_details->product_id ==
|
|
|
|
le16_to_cpu(serial->dev->descriptor.idProduct))
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
if (d_details == NULL) {
|
2008-07-22 18:13:08 +08:00
|
|
|
dev_err(&serial->dev->dev, "%s - unknown product id %x\n",
|
|
|
|
__func__, le16_to_cpu(serial->dev->descriptor.idProduct));
|
2013-08-13 19:27:35 +08:00
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup private data for serial driver */
|
2006-02-28 04:29:43 +08:00
|
|
|
s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
|
2013-12-30 02:22:56 +08:00
|
|
|
if (!s_priv)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2013-08-13 19:27:36 +08:00
|
|
|
s_priv->instat_buf = kzalloc(INSTAT_BUFLEN, GFP_KERNEL);
|
|
|
|
if (!s_priv->instat_buf)
|
|
|
|
goto err_instat_buf;
|
|
|
|
|
|
|
|
s_priv->indat_buf = kzalloc(INDAT49W_BUFLEN, GFP_KERNEL);
|
|
|
|
if (!s_priv->indat_buf)
|
|
|
|
goto err_indat_buf;
|
|
|
|
|
|
|
|
s_priv->glocont_buf = kzalloc(GLOCONT_BUFLEN, GFP_KERNEL);
|
|
|
|
if (!s_priv->glocont_buf)
|
|
|
|
goto err_glocont_buf;
|
|
|
|
|
|
|
|
s_priv->ctrl_buf = kzalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
|
|
|
|
if (!s_priv->ctrl_buf)
|
|
|
|
goto err_ctrl_buf;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
s_priv->device_details = d_details;
|
|
|
|
usb_set_serial_data(serial, s_priv);
|
|
|
|
|
|
|
|
keyspan_setup_urbs(serial);
|
|
|
|
|
2007-05-19 03:10:41 +08:00
|
|
|
if (s_priv->instat_urb != NULL) {
|
|
|
|
err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL);
|
|
|
|
if (err != 0)
|
2012-09-15 07:34:21 +08:00
|
|
|
dev_dbg(&serial->dev->dev, "%s - submit instat urb failed %d\n", __func__, err);
|
2007-05-19 03:10:41 +08:00
|
|
|
}
|
|
|
|
if (s_priv->indat_urb != NULL) {
|
|
|
|
err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL);
|
|
|
|
if (err != 0)
|
2012-09-15 07:34:21 +08:00
|
|
|
dev_dbg(&serial->dev->dev, "%s - submit indat urb failed %d\n", __func__, err);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-07-22 18:13:08 +08:00
|
|
|
|
2008-04-09 00:16:06 +08:00
|
|
|
return 0;
|
2013-08-13 19:27:36 +08:00
|
|
|
|
|
|
|
err_ctrl_buf:
|
|
|
|
kfree(s_priv->glocont_buf);
|
|
|
|
err_glocont_buf:
|
|
|
|
kfree(s_priv->indat_buf);
|
|
|
|
err_indat_buf:
|
|
|
|
kfree(s_priv->instat_buf);
|
|
|
|
err_instat_buf:
|
|
|
|
kfree(s_priv);
|
|
|
|
|
|
|
|
return -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-06-02 23:53:55 +08:00
|
|
|
static void keyspan_disconnect(struct usb_serial *serial)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2012-10-25 16:29:15 +08:00
|
|
|
struct keyspan_serial_private *s_priv;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
|
|
|
|
2016-05-09 02:07:59 +08:00
|
|
|
usb_kill_urb(s_priv->instat_urb);
|
|
|
|
usb_kill_urb(s_priv->glocont_urb);
|
|
|
|
usb_kill_urb(s_priv->indat_urb);
|
2012-10-25 16:29:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void keyspan_release(struct usb_serial *serial)
|
|
|
|
{
|
|
|
|
struct keyspan_serial_private *s_priv;
|
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-05-09 02:07:58 +08:00
|
|
|
/* Make sure to unlink the URBs submitted in attach. */
|
|
|
|
usb_kill_urb(s_priv->instat_urb);
|
|
|
|
usb_kill_urb(s_priv->indat_urb);
|
|
|
|
|
2006-11-08 22:36:34 +08:00
|
|
|
usb_free_urb(s_priv->instat_urb);
|
2007-05-19 03:10:41 +08:00
|
|
|
usb_free_urb(s_priv->indat_urb);
|
2006-11-08 22:36:34 +08:00
|
|
|
usb_free_urb(s_priv->glocont_urb);
|
2012-10-25 16:29:15 +08:00
|
|
|
|
2013-08-13 19:27:36 +08:00
|
|
|
kfree(s_priv->ctrl_buf);
|
|
|
|
kfree(s_priv->glocont_buf);
|
|
|
|
kfree(s_priv->indat_buf);
|
|
|
|
kfree(s_priv->instat_buf);
|
|
|
|
|
2012-10-25 16:29:15 +08:00
|
|
|
kfree(s_priv);
|
2009-06-02 23:53:55 +08:00
|
|
|
}
|
|
|
|
|
2012-10-25 16:29:15 +08:00
|
|
|
static int keyspan_port_probe(struct usb_serial_port *port)
|
2009-06-02 23:53:55 +08:00
|
|
|
{
|
2012-10-25 16:29:15 +08:00
|
|
|
struct usb_serial *serial = port->serial;
|
2012-11-10 17:13:42 +08:00
|
|
|
struct keyspan_serial_private *s_priv;
|
2012-10-25 16:29:15 +08:00
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
const struct keyspan_device_details *d_details;
|
|
|
|
struct callbacks *cback;
|
|
|
|
int endp;
|
|
|
|
int port_num;
|
|
|
|
int i;
|
2009-06-02 23:53:55 +08:00
|
|
|
|
|
|
|
s_priv = usb_get_serial_data(serial);
|
2012-10-25 16:29:15 +08:00
|
|
|
d_details = s_priv->device_details;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-10-25 16:29:15 +08:00
|
|
|
p_priv = kzalloc(sizeof(*p_priv), GFP_KERNEL);
|
|
|
|
if (!p_priv)
|
|
|
|
return -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-08-13 19:27:37 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i) {
|
|
|
|
p_priv->in_buffer[i] = kzalloc(IN_BUFLEN, GFP_KERNEL);
|
|
|
|
if (!p_priv->in_buffer[i])
|
|
|
|
goto err_in_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i) {
|
|
|
|
p_priv->out_buffer[i] = kzalloc(OUT_BUFLEN, GFP_KERNEL);
|
|
|
|
if (!p_priv->out_buffer[i])
|
|
|
|
goto err_out_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
p_priv->inack_buffer = kzalloc(INACK_BUFLEN, GFP_KERNEL);
|
|
|
|
if (!p_priv->inack_buffer)
|
|
|
|
goto err_inack_buffer;
|
|
|
|
|
|
|
|
p_priv->outcont_buffer = kzalloc(OUTCONT_BUFLEN, GFP_KERNEL);
|
|
|
|
if (!p_priv->outcont_buffer)
|
|
|
|
goto err_outcont_buffer;
|
|
|
|
|
2012-10-25 16:29:15 +08:00
|
|
|
p_priv->device_details = d_details;
|
|
|
|
|
|
|
|
/* Setup values for the various callback routines */
|
|
|
|
cback = &keyspan_callbacks[d_details->msg_format];
|
|
|
|
|
2013-06-07 01:32:00 +08:00
|
|
|
port_num = port->port_number;
|
2012-10-25 16:29:15 +08:00
|
|
|
|
|
|
|
/* Do indat endpoints first, once for each flip */
|
|
|
|
endp = d_details->indat_endpoints[port_num];
|
|
|
|
for (i = 0; i <= d_details->indat_endp_flip; ++i, ++endp) {
|
|
|
|
p_priv->in_urbs[i] = keyspan_setup_urb(serial, endp,
|
|
|
|
USB_DIR_IN, port,
|
2013-08-13 19:27:37 +08:00
|
|
|
p_priv->in_buffer[i],
|
|
|
|
IN_BUFLEN,
|
2012-10-25 16:29:15 +08:00
|
|
|
cback->indat_callback);
|
|
|
|
}
|
|
|
|
/* outdat endpoints also have flip */
|
|
|
|
endp = d_details->outdat_endpoints[port_num];
|
|
|
|
for (i = 0; i <= d_details->outdat_endp_flip; ++i, ++endp) {
|
|
|
|
p_priv->out_urbs[i] = keyspan_setup_urb(serial, endp,
|
|
|
|
USB_DIR_OUT, port,
|
2013-08-13 19:27:37 +08:00
|
|
|
p_priv->out_buffer[i],
|
|
|
|
OUT_BUFLEN,
|
2012-10-25 16:29:15 +08:00
|
|
|
cback->outdat_callback);
|
|
|
|
}
|
|
|
|
/* inack endpoint */
|
|
|
|
p_priv->inack_urb = keyspan_setup_urb(serial,
|
|
|
|
d_details->inack_endpoints[port_num],
|
|
|
|
USB_DIR_IN, port,
|
2013-08-13 19:27:37 +08:00
|
|
|
p_priv->inack_buffer,
|
|
|
|
INACK_BUFLEN,
|
2012-10-25 16:29:15 +08:00
|
|
|
cback->inack_callback);
|
|
|
|
/* outcont endpoint */
|
|
|
|
p_priv->outcont_urb = keyspan_setup_urb(serial,
|
|
|
|
d_details->outcont_endpoints[port_num],
|
|
|
|
USB_DIR_OUT, port,
|
2013-08-13 19:27:37 +08:00
|
|
|
p_priv->outcont_buffer,
|
|
|
|
OUTCONT_BUFLEN,
|
2012-10-25 16:29:15 +08:00
|
|
|
cback->outcont_callback);
|
|
|
|
|
|
|
|
usb_set_serial_port_data(port, p_priv);
|
|
|
|
|
|
|
|
return 0;
|
2013-08-13 19:27:37 +08:00
|
|
|
|
|
|
|
err_outcont_buffer:
|
|
|
|
kfree(p_priv->inack_buffer);
|
|
|
|
err_inack_buffer:
|
|
|
|
for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i)
|
|
|
|
kfree(p_priv->out_buffer[i]);
|
|
|
|
err_out_buffer:
|
|
|
|
for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i)
|
|
|
|
kfree(p_priv->in_buffer[i]);
|
|
|
|
err_in_buffer:
|
|
|
|
kfree(p_priv);
|
|
|
|
|
|
|
|
return -ENOMEM;
|
2012-10-25 16:29:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int keyspan_port_remove(struct usb_serial_port *port)
|
|
|
|
{
|
|
|
|
struct keyspan_port_private *p_priv;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
p_priv = usb_get_serial_port_data(port);
|
|
|
|
|
2016-05-09 02:07:59 +08:00
|
|
|
usb_kill_urb(p_priv->inack_urb);
|
|
|
|
usb_kill_urb(p_priv->outcont_urb);
|
2012-10-25 16:29:15 +08:00
|
|
|
for (i = 0; i < 2; i++) {
|
2016-05-09 02:07:59 +08:00
|
|
|
usb_kill_urb(p_priv->in_urbs[i]);
|
|
|
|
usb_kill_urb(p_priv->out_urbs[i]);
|
2012-10-25 16:29:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
usb_free_urb(p_priv->inack_urb);
|
|
|
|
usb_free_urb(p_priv->outcont_urb);
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
usb_free_urb(p_priv->in_urbs[i]);
|
|
|
|
usb_free_urb(p_priv->out_urbs[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2012-10-25 16:29:15 +08:00
|
|
|
|
2013-08-13 19:27:37 +08:00
|
|
|
kfree(p_priv->outcont_buffer);
|
|
|
|
kfree(p_priv->inack_buffer);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i)
|
|
|
|
kfree(p_priv->out_buffer[i]);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i)
|
|
|
|
kfree(p_priv->in_buffer[i]);
|
|
|
|
|
2012-10-25 16:29:15 +08:00
|
|
|
kfree(p_priv);
|
|
|
|
|
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2017-02-15 18:09:51 +08:00
|
|
|
/* Structs for the devices, pre and post renumeration. */
|
|
|
|
static struct usb_serial_driver keyspan_pre_device = {
|
|
|
|
.driver = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "keyspan_no_firm",
|
|
|
|
},
|
|
|
|
.description = "Keyspan - (without firmware)",
|
|
|
|
.id_table = keyspan_pre_ids,
|
|
|
|
.num_ports = 1,
|
|
|
|
.attach = keyspan_fake_startup,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct usb_serial_driver keyspan_1port_device = {
|
|
|
|
.driver = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "keyspan_1",
|
|
|
|
},
|
|
|
|
.description = "Keyspan 1 port adapter",
|
|
|
|
.id_table = keyspan_1port_ids,
|
|
|
|
.num_ports = 1,
|
|
|
|
.open = keyspan_open,
|
|
|
|
.close = keyspan_close,
|
|
|
|
.dtr_rts = keyspan_dtr_rts,
|
|
|
|
.write = keyspan_write,
|
|
|
|
.write_room = keyspan_write_room,
|
|
|
|
.set_termios = keyspan_set_termios,
|
|
|
|
.break_ctl = keyspan_break_ctl,
|
|
|
|
.tiocmget = keyspan_tiocmget,
|
|
|
|
.tiocmset = keyspan_tiocmset,
|
|
|
|
.attach = keyspan_startup,
|
|
|
|
.disconnect = keyspan_disconnect,
|
|
|
|
.release = keyspan_release,
|
|
|
|
.port_probe = keyspan_port_probe,
|
|
|
|
.port_remove = keyspan_port_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct usb_serial_driver keyspan_2port_device = {
|
|
|
|
.driver = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "keyspan_2",
|
|
|
|
},
|
|
|
|
.description = "Keyspan 2 port adapter",
|
|
|
|
.id_table = keyspan_2port_ids,
|
|
|
|
.num_ports = 2,
|
|
|
|
.open = keyspan_open,
|
|
|
|
.close = keyspan_close,
|
|
|
|
.dtr_rts = keyspan_dtr_rts,
|
|
|
|
.write = keyspan_write,
|
|
|
|
.write_room = keyspan_write_room,
|
|
|
|
.set_termios = keyspan_set_termios,
|
|
|
|
.break_ctl = keyspan_break_ctl,
|
|
|
|
.tiocmget = keyspan_tiocmget,
|
|
|
|
.tiocmset = keyspan_tiocmset,
|
|
|
|
.attach = keyspan_startup,
|
|
|
|
.disconnect = keyspan_disconnect,
|
|
|
|
.release = keyspan_release,
|
|
|
|
.port_probe = keyspan_port_probe,
|
|
|
|
.port_remove = keyspan_port_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct usb_serial_driver keyspan_4port_device = {
|
|
|
|
.driver = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "keyspan_4",
|
|
|
|
},
|
|
|
|
.description = "Keyspan 4 port adapter",
|
|
|
|
.id_table = keyspan_4port_ids,
|
|
|
|
.num_ports = 4,
|
|
|
|
.open = keyspan_open,
|
|
|
|
.close = keyspan_close,
|
|
|
|
.dtr_rts = keyspan_dtr_rts,
|
|
|
|
.write = keyspan_write,
|
|
|
|
.write_room = keyspan_write_room,
|
|
|
|
.set_termios = keyspan_set_termios,
|
|
|
|
.break_ctl = keyspan_break_ctl,
|
|
|
|
.tiocmget = keyspan_tiocmget,
|
|
|
|
.tiocmset = keyspan_tiocmset,
|
|
|
|
.attach = keyspan_startup,
|
|
|
|
.disconnect = keyspan_disconnect,
|
|
|
|
.release = keyspan_release,
|
|
|
|
.port_probe = keyspan_port_probe,
|
|
|
|
.port_remove = keyspan_port_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct usb_serial_driver * const serial_drivers[] = {
|
|
|
|
&keyspan_pre_device, &keyspan_1port_device,
|
|
|
|
&keyspan_2port_device, &keyspan_4port_device, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
module_usb_serial_driver(serial_drivers, keyspan_ids_combined);
|
|
|
|
|
2008-07-22 18:13:08 +08:00
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2008-05-30 19:04:03 +08:00
|
|
|
MODULE_FIRMWARE("keyspan/usa28.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa28x.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa28xa.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa28xb.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa19.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa19qi.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/mpr.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa19qw.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa18x.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa19w.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa49w.fw");
|
|
|
|
MODULE_FIRMWARE("keyspan/usa49wlc.fw");
|