linux/drivers/isdn/hardware/mISDN/hfcsusb.h

426 lines
12 KiB
C
Raw Normal View History

License cleanup: add SPDX GPL-2.0 license identifier to files with no license Many source files in the tree are missing licensing information, which makes it harder for compliance tools to determine the correct license. By default all files without license information are under the default license of the kernel, which is GPL version 2. Update the files which contain no license information with the 'GPL-2.0' SPDX license identifier. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This patch is based on work done by Thomas Gleixner and Kate Stewart and Philippe Ombredanne. How this work was done: Patches were generated and checked against linux-4.14-rc6 for a subset of the use cases: - file had no licensing information it it. - file was a */uapi/* one with no licensing information in it, - file was a */uapi/* one with existing licensing information, Further patches will be generated in subsequent months to fix up cases where non-standard license headers were used, and references to license had to be inferred by heuristics based on keywords. The analysis to determine which SPDX License Identifier to be applied to a file was done in a spreadsheet of side by side results from of the output of two independent scanners (ScanCode & Windriver) producing SPDX tag:value files created by Philippe Ombredanne. Philippe prepared the base worksheet, and did an initial spot review of a few 1000 files. The 4.13 kernel was the starting point of the analysis with 60,537 files assessed. Kate Stewart did a file by file comparison of the scanner results in the spreadsheet to determine which SPDX license identifier(s) to be applied to the file. She confirmed any determination that was not immediately clear with lawyers working with the Linux Foundation. Criteria used to select files for SPDX license identifier tagging was: - Files considered eligible had to be source code files. - Make and config files were included as candidates if they contained >5 lines of source - File already had some variant of a license header in it (even if <5 lines). All documentation files were explicitly excluded. The following heuristics were used to determine which SPDX license identifiers to apply. - when both scanners couldn't find any license traces, file was considered to have no license information in it, and the top level COPYING file license applied. For non */uapi/* files that summary was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 11139 and resulted in the first patch in this series. If that file was a */uapi/* path one, it was "GPL-2.0 WITH Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 WITH Linux-syscall-note 930 and resulted in the second patch in this series. - if a file had some form of licensing information in it, and was one of the */uapi/* ones, it was denoted with the Linux-syscall-note if any GPL family license was found in the file or had no licensing in it (per prior point). Results summary: SPDX license identifier # files ---------------------------------------------------|------ GPL-2.0 WITH Linux-syscall-note 270 GPL-2.0+ WITH Linux-syscall-note 169 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17 LGPL-2.1+ WITH Linux-syscall-note 15 GPL-1.0+ WITH Linux-syscall-note 14 ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5 LGPL-2.0+ WITH Linux-syscall-note 4 LGPL-2.1 WITH Linux-syscall-note 3 ((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3 ((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1 and that resulted in the third patch in this series. - when the two scanners agreed on the detected license(s), that became the concluded license(s). - when there was disagreement between the two scanners (one detected a license but the other didn't, or they both detected different licenses) a manual inspection of the file occurred. - In most cases a manual inspection of the information in the file resulted in a clear resolution of the license that should apply (and which scanner probably needed to revisit its heuristics). - When it was not immediately clear, the license identifier was confirmed with lawyers working with the Linux Foundation. - If there was any question as to the appropriate license identifier, the file was flagged for further research and to be revisited later in time. In total, over 70 hours of logged manual review was done on the spreadsheet to determine the SPDX license identifiers to apply to the source files by Kate, Philippe, Thomas and, in some cases, confirmation by lawyers working with the Linux Foundation. Kate also obtained a third independent scan of the 4.13 code base from FOSSology, and compared selected files where the other two scanners disagreed against that SPDX file, to see if there was new insights. The Windriver scanner is based on an older version of FOSSology in part, so they are related. Thomas did random spot checks in about 500 files from the spreadsheets for the uapi headers and agreed with SPDX license identifier in the files he inspected. For the non-uapi files Thomas did random spot checks in about 15000 files. In initial set of patches against 4.14-rc6, 3 files were found to have copy/paste license identifier errors, and have been fixed to reflect the correct identifier. Additionally Philippe spent 10 hours this week doing a detailed manual inspection and review of the 12,461 patched files from the initial patch version early this week with: - a full scancode scan run, collecting the matched texts, detected license ids and scores - reviewing anything where there was a license detected (about 500+ files) to ensure that the applied SPDX license was correct - reviewing anything where there was no detection but the patch license was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied SPDX license was correct This produced a worksheet with 20 files needing minor correction. This worksheet was then exported into 3 different .csv files for the different types of files to be modified. These .csv files were then reviewed by Greg. Thomas wrote a script to parse the csv files and add the proper SPDX tag to the file, in the format that the file expected. This script was further refined by Greg based on the output to detect more types of files automatically and to distinguish between header and source .c files (which need different comment types.) Finally Greg ran the script using the .csv files to generate the patches. Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
/* SPDX-License-Identifier: GPL-2.0 */
/*
* hfcsusb.h, HFC-S USB mISDN driver
*/
#ifndef __HFCSUSB_H__
#define __HFCSUSB_H__
#define DRIVER_NAME "HFC-S_USB"
#define DBG_HFC_CALL_TRACE 0x00010000
#define DBG_HFC_FIFO_VERBOSE 0x00020000
#define DBG_HFC_USB_VERBOSE 0x00100000
#define DBG_HFC_URB_INFO 0x00200000
#define DBG_HFC_URB_ERROR 0x00400000
#define DEFAULT_TRANSP_BURST_SZ 128
#define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */
#define CLKDEL_TE 0x0f /* CLKDEL in TE mode */
#define CLKDEL_NT 0x6c /* CLKDEL in NT mode */
/* hfcsusb Layer1 commands */
#define HFC_L1_ACTIVATE_TE 1
#define HFC_L1_ACTIVATE_NT 2
#define HFC_L1_DEACTIVATE_NT 3
#define HFC_L1_FORCE_DEACTIVATE_TE 4
/* cmd FLAGS in HFCUSB_STATES register */
#define HFCUSB_LOAD_STATE 0x10
#define HFCUSB_ACTIVATE 0x20
#define HFCUSB_DO_ACTION 0x40
#define HFCUSB_NT_G2_G3 0x80
/* timers */
#define NT_ACTIVATION_TIMER 0x01 /* enables NT mode activation Timer */
#define NT_T1_COUNT 10
#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */
#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */
#define HFCUSB_TX_THRESHOLD 96 /* threshold for fifo report bit tx */
#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */
#define HFCUSB_CIRM 0x00 /* cirm register index */
#define HFCUSB_USB_SIZE 0x07 /* int length register */
#define HFCUSB_USB_SIZE_I 0x06 /* iso length register */
#define HFCUSB_F_CROSS 0x0b /* bit order register */
#define HFCUSB_CLKDEL 0x37 /* bit delay register */
#define HFCUSB_CON_HDLC 0xfa /* channel connect register */
#define HFCUSB_HDLC_PAR 0xfb
#define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */
#define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */
#define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */
#define HFCUSB_F_THRES 0x0c /* threshold register */
#define HFCUSB_FIFO 0x0f /* fifo select register */
#define HFCUSB_F_USAGE 0x1a /* fifo usage register */
#define HFCUSB_MST_MODE0 0x14
#define HFCUSB_MST_MODE1 0x15
#define HFCUSB_P_DATA 0x1f
#define HFCUSB_INC_RES_F 0x0e
#define HFCUSB_B1_SSL 0x20
#define HFCUSB_B2_SSL 0x21
#define HFCUSB_B1_RSL 0x24
#define HFCUSB_B2_RSL 0x25
#define HFCUSB_STATES 0x30
#define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */
/* fifo registers */
#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */
#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */
#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */
#define HFCUSB_B2_TX 2
#define HFCUSB_B2_RX 3
#define HFCUSB_D_TX 4
#define HFCUSB_D_RX 5
#define HFCUSB_PCM_TX 6
#define HFCUSB_PCM_RX 7
#define USB_INT 0
#define USB_BULK 1
#define USB_ISOC 2
#define ISOC_PACKETS_D 8
#define ISOC_PACKETS_B 8
#define ISO_BUFFER_SIZE 128
/* defines how much ISO packets are handled in one URB */
static int iso_packets[8] =
{ ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B,
ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D
};
/* Fifo flow Control for TX ISO */
#define SINK_MAX 68
#define SINK_MIN 48
#define SINK_DMIN 12
#define SINK_DMAX 18
#define BITLINE_INF (-96 * 8)
/* HFC-S USB register access by Control-URSs */
#define write_reg_atomic(a, b, c) \
usb_control_msg((a)->dev, (a)->ctrl_out_pipe, 0, 0x40, (c), (b), \
0, 0, HFC_CTRL_TIMEOUT)
#define read_reg_atomic(a, b, c) \
usb_control_msg((a)->dev, (a)->ctrl_in_pipe, 1, 0xC0, 0, (b), (c), \
1, HFC_CTRL_TIMEOUT)
#define HFC_CTRL_BUFSIZE 64
struct ctrl_buf {
__u8 hfcs_reg; /* register number */
__u8 reg_val; /* value to be written (or read) */
};
/*
* URB error codes
* Used to represent a list of values and their respective symbolic names
*/
struct hfcusb_symbolic_list {
const int num;
const char *name;
};
static struct hfcusb_symbolic_list urb_errlist[] = {
{-ENOMEM, "No memory for allocation of internal structures"},
{-ENOSPC, "The host controller's bandwidth is already consumed"},
{-ENOENT, "URB was canceled by unlink_urb"},
{-EXDEV, "ISO transfer only partially completed"},
{-EAGAIN, "Too match scheduled for the future"},
{-ENXIO, "URB already queued"},
{-EFBIG, "Too much ISO frames requested"},
{-ENOSR, "Buffer error (overrun)"},
{-EPIPE, "Specified endpoint is stalled (device not responding)"},
{-EOVERFLOW, "Babble (bad cable?)"},
{-EPROTO, "Bit-stuff error (bad cable?)"},
{-EILSEQ, "CRC/Timeout"},
{-ETIMEDOUT, "NAK (device does not respond)"},
{-ESHUTDOWN, "Device unplugged"},
{-1, NULL}
};
static inline const char *
symbolic(struct hfcusb_symbolic_list list[], const int num)
{
int i;
for (i = 0; list[i].name != NULL; i++)
if (list[i].num == num)
return list[i].name;
return "<unknown USB Error>";
}
/* USB descriptor need to contain one of the following EndPoint combination: */
#define CNF_4INT3ISO 1 /* 4 INT IN, 3 ISO OUT */
#define CNF_3INT3ISO 2 /* 3 INT IN, 3 ISO OUT */
#define CNF_4ISO3ISO 3 /* 4 ISO IN, 3 ISO OUT */
#define CNF_3ISO3ISO 4 /* 3 ISO IN, 3 ISO OUT */
#define EP_NUL 1 /* Endpoint at this position not allowed */
#define EP_NOP 2 /* all type of endpoints allowed at this position */
#define EP_ISO 3 /* Isochron endpoint mandatory at this position */
#define EP_BLK 4 /* Bulk endpoint mandatory at this position */
#define EP_INT 5 /* Interrupt endpoint mandatory at this position */
#define HFC_CHAN_B1 0
#define HFC_CHAN_B2 1
#define HFC_CHAN_D 2
#define HFC_CHAN_E 3
/*
* List of all supported endpoint configuration sets, used to find the
* best matching endpoint configuration within a device's USB descriptor.
* We need at least 3 RX endpoints, and 3 TX endpoints, either
* INT-in and ISO-out, or ISO-in and ISO-out)
* with 4 RX endpoints even E-Channel logging is possible
*/
static int
validconf[][19] = {
/* INT in, ISO out config */
{EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT,
EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
CNF_4INT3ISO, 2, 1},
{EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_NUL,
EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
CNF_3INT3ISO, 2, 0},
/* ISO in, ISO out config */
{EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP,
EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NOP, EP_ISO,
CNF_4ISO3ISO, 2, 1},
{EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL,
EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NUL, EP_NUL,
CNF_3ISO3ISO, 2, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* EOL element */
};
/* string description of chosen config */
static char *conf_str[] = {
"4 Interrupt IN + 3 Isochron OUT",
"3 Interrupt IN + 3 Isochron OUT",
"4 Isochron IN + 3 Isochron OUT",
"3 Isochron IN + 3 Isochron OUT"
};
#define LED_OFF 0 /* no LED support */
#define LED_SCHEME1 1 /* LED standard scheme */
#define LED_SCHEME2 2 /* not used yet... */
#define LED_POWER_ON 1
#define LED_POWER_OFF 2
#define LED_S0_ON 3
#define LED_S0_OFF 4
#define LED_B1_ON 5
#define LED_B1_OFF 6
#define LED_B1_DATA 7
#define LED_B2_ON 8
#define LED_B2_OFF 9
#define LED_B2_DATA 10
#define LED_NORMAL 0 /* LEDs are normal */
#define LED_INVERTED 1 /* LEDs are inverted */
/* time in ms to perform a Flashing LED when B-Channel has traffic */
#define LED_TIME 250
struct hfcsusb;
struct usb_fifo;
/* structure defining input+output fifos (interrupt/bulk mode) */
struct iso_urb {
struct urb *urb;
__u8 buffer[ISO_BUFFER_SIZE]; /* buffer rx/tx USB URB data */
struct usb_fifo *owner_fifo; /* pointer to owner fifo */
__u8 indx; /* Fifos's ISO double buffer 0 or 1 ? */
#ifdef ISO_FRAME_START_DEBUG
int start_frames[ISO_FRAME_START_RING_COUNT];
__u8 iso_frm_strt_pos; /* index in start_frame[] */
#endif
};
struct usb_fifo {
int fifonum; /* fifo index attached to this structure */
int active; /* fifo is currently active */
struct hfcsusb *hw; /* pointer to main structure */
int pipe; /* address of endpoint */
__u8 usb_packet_maxlen; /* maximum length for usb transfer */
unsigned int max_size; /* maximum size of receive/send packet */
__u8 intervall; /* interrupt interval */
struct urb *urb; /* transfer structure for usb routines */
__u8 buffer[128]; /* buffer USB INT OUT URB data */
int bit_line; /* how much bits are in the fifo? */
__u8 usb_transfer_mode; /* switched between ISO and INT */
struct iso_urb iso[2]; /* two urbs to have one always
one pending */
struct dchannel *dch; /* link to hfcsusb_t->dch */
struct bchannel *bch; /* link to hfcsusb_t->bch */
struct dchannel *ech; /* link to hfcsusb_t->ech, TODO: E-CHANNEL */
int last_urblen; /* remember length of last packet */
__u8 stop_gracefull; /* stops URB retransmission */
};
struct hfcsusb {
struct list_head list;
struct dchannel dch;
struct bchannel bch[2];
struct dchannel ech; /* TODO : wait for struct echannel ;) */
struct usb_device *dev; /* our device */
struct usb_interface *intf; /* used interface */
int if_used; /* used interface number */
int alt_used; /* used alternate config */
int cfg_used; /* configuration index used */
int vend_idx; /* index in hfcsusb_idtab */
int packet_size;
int iso_packet_size;
struct usb_fifo fifos[HFCUSB_NUM_FIFOS];
/* control pipe background handling */
struct ctrl_buf ctrl_buff[HFC_CTRL_BUFSIZE];
int ctrl_in_idx, ctrl_out_idx, ctrl_cnt;
struct urb *ctrl_urb;
struct usb_ctrlrequest ctrl_write;
struct usb_ctrlrequest ctrl_read;
int ctrl_paksize;
int ctrl_in_pipe, ctrl_out_pipe;
spinlock_t ctrl_lock; /* lock for ctrl */
spinlock_t lock;
__u8 threshold_mask;
__u8 led_state;
__u8 protocol;
int nt_timer;
int open;
__u8 timers;
__u8 initdone;
char name[MISDN_MAX_IDLEN];
};
/* private vendor specific data */
struct hfcsusb_vdata {
__u8 led_scheme; /* led display scheme */
signed short led_bits[8]; /* array of 8 possible LED bitmask */
char *vend_name; /* device name */
};
#define HFC_MAX_TE_LAYER1_STATE 8
#define HFC_MAX_NT_LAYER1_STATE 4
static const char *HFC_TE_LAYER1_STATES[HFC_MAX_TE_LAYER1_STATE + 1] = {
"TE F0 - Reset",
"TE F1 - Reset",
"TE F2 - Sensing",
"TE F3 - Deactivated",
"TE F4 - Awaiting signal",
"TE F5 - Identifying input",
"TE F6 - Synchronized",
"TE F7 - Activated",
"TE F8 - Lost framing",
};
static const char *HFC_NT_LAYER1_STATES[HFC_MAX_NT_LAYER1_STATE + 1] = {
"NT G0 - Reset",
"NT G1 - Deactive",
"NT G2 - Pending activation",
"NT G3 - Active",
"NT G4 - Pending deactivation",
};
/* supported devices */
static const struct usb_device_id hfcsusb_idtab[] = {
{
USB_DEVICE(0x0959, 0x2bd0),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_OFF, {4, 0, 2, 1},
"ISDN USB TA (Cologne Chip HFC-S USB based)"}),
},
{
USB_DEVICE(0x0675, 0x1688),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {1, 2, 0, 0},
"DrayTek miniVigor 128 USB ISDN TA"}),
},
{
USB_DEVICE(0x07b0, 0x0007),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {0x80, -64, -32, -16},
"Billion tiny USB ISDN TA 128"}),
},
{
USB_DEVICE(0x0742, 0x2008),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {4, 0, 2, 1},
"Stollmann USB TA"}),
},
{
USB_DEVICE(0x0742, 0x2009),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {4, 0, 2, 1},
"Aceex USB ISDN TA"}),
},
{
USB_DEVICE(0x0742, 0x200A),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {4, 0, 2, 1},
"OEM USB ISDN TA"}),
},
{
USB_DEVICE(0x08e3, 0x0301),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {2, 0, 1, 4},
"Olitec USB RNIS"}),
},
{
USB_DEVICE(0x07fa, 0x0846),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {0x80, -64, -32, -16},
"Bewan Modem RNIS USB"}),
},
{
USB_DEVICE(0x07fa, 0x0847),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {0x80, -64, -32, -16},
"Djinn Numeris USB"}),
},
{
USB_DEVICE(0x07b0, 0x0006),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {0x80, -64, -32, -16},
"Twister ISDN TA"}),
},
{
USB_DEVICE(0x071d, 0x1005),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {0x02, 0, 0x01, 0x04},
"Eicon DIVA USB 4.0"}),
},
{
USB_DEVICE(0x0586, 0x0102),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {0x88, -64, -32, -16},
"ZyXEL OMNI.NET USB II"}),
},
{
USB_DEVICE(0x1ae7, 0x0525),
.driver_info = (unsigned long) &((struct hfcsusb_vdata)
{LED_SCHEME1, {0x88, -64, -32, -16},
"X-Tensions USB ISDN TA XC-525"}),
},
{ }
};
MODULE_DEVICE_TABLE(usb, hfcsusb_idtab);
#endif /* __HFCSUSB_H__ */