linux/drivers/isdn/hisax/hfc_usb.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * hfc_usb.h
   4 *
   5 * $Id: hfc_usb.h,v 1.1.2.5 2007/08/20 14:36:03 mbachem Exp $
   6 */
   7
   8#ifndef __HFC_USB_H__
   9#define __HFC_USB_H__
  10
  11#define DRIVER_AUTHOR   "Peter Sprenger (sprenger@moving-byters.de)"
  12#define DRIVER_DESC     "HFC-S USB based HiSAX ISDN driver"
  13
  14
  15#define HFC_CTRL_TIMEOUT        20      /* 5ms timeout writing/reading regs */
  16#define HFC_TIMER_T3            8000    /* timeout for l1 activation timer */
  17#define HFC_TIMER_T4            500     /* time for state change interval */
  18
  19#define HFCUSB_L1_STATECHANGE   0       /* L1 state changed */
  20#define HFCUSB_L1_DRX           1       /* D-frame received */
  21#define HFCUSB_L1_ERX           2       /* E-frame received */
  22#define HFCUSB_L1_DTX           4       /* D-frames completed */
  23
  24#define MAX_BCH_SIZE            2048    /* allowed B-channel packet size */
  25
  26#define HFCUSB_RX_THRESHOLD     64      /* threshold for fifo report bit rx */
  27#define HFCUSB_TX_THRESHOLD     64      /* threshold for fifo report bit tx */
  28
  29#define HFCUSB_CHIP_ID          0x16    /* Chip ID register index */
  30#define HFCUSB_CIRM             0x00    /* cirm register index */
  31#define HFCUSB_USB_SIZE         0x07    /* int length register */
  32#define HFCUSB_USB_SIZE_I       0x06    /* iso length register */
  33#define HFCUSB_F_CROSS          0x0b    /* bit order register */
  34#define HFCUSB_CLKDEL           0x37    /* bit delay register */
  35#define HFCUSB_CON_HDLC         0xfa    /* channel connect register */
  36#define HFCUSB_HDLC_PAR         0xfb
  37#define HFCUSB_SCTRL            0x31    /* S-bus control register (tx) */
  38#define HFCUSB_SCTRL_E          0x32    /* same for E and special funcs */
  39#define HFCUSB_SCTRL_R          0x33    /* S-bus control register (rx) */
  40#define HFCUSB_F_THRES          0x0c    /* threshold register */
  41#define HFCUSB_FIFO             0x0f    /* fifo select register */
  42#define HFCUSB_F_USAGE          0x1a    /* fifo usage register */
  43#define HFCUSB_MST_MODE0        0x14
  44#define HFCUSB_MST_MODE1        0x15
  45#define HFCUSB_P_DATA           0x1f
  46#define HFCUSB_INC_RES_F        0x0e
  47#define HFCUSB_STATES           0x30
  48
  49#define HFCUSB_CHIPID           0x40    /* ID value of HFC-S USB */
  50
  51
  52/* fifo registers */
  53#define HFCUSB_NUM_FIFOS        8       /* maximum number of fifos */
  54#define HFCUSB_B1_TX            0       /* index for B1 transmit bulk/int */
  55#define HFCUSB_B1_RX            1       /* index for B1 receive bulk/int */
  56#define HFCUSB_B2_TX            2
  57#define HFCUSB_B2_RX            3
  58#define HFCUSB_D_TX             4
  59#define HFCUSB_D_RX             5
  60#define HFCUSB_PCM_TX           6
  61#define HFCUSB_PCM_RX           7
  62
  63/*
  64 * used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just
  65 * supports ISO out, while the Cologne Chip EVAL TA just supports BULK out
  66 */
  67#define USB_INT         0
  68#define USB_BULK        1
  69#define USB_ISOC        2
  70
  71#define ISOC_PACKETS_D  8
  72#define ISOC_PACKETS_B  8
  73#define ISO_BUFFER_SIZE 128
  74
  75/* Fifo flow Control for TX ISO */
  76#define SINK_MAX        68
  77#define SINK_MIN        48
  78#define SINK_DMIN       12
  79#define SINK_DMAX       18
  80#define BITLINE_INF     (-64 * 8)
  81
  82/* HFC-S USB register access by Control-URSs */
  83#define write_usb(a, b, c) usb_control_msg((a)->dev, (a)->ctrl_out_pipe, 0, 0x40, (c), (b), NULL, 0, HFC_CTRL_TIMEOUT)
  84#define read_usb(a, b, c) usb_control_msg((a)->dev, (a)->ctrl_in_pipe, 1, 0xC0, 0, (b), (c), 1, HFC_CTRL_TIMEOUT)
  85#define HFC_CTRL_BUFSIZE 32
  86
  87/* entry and size of output/input control buffer */
  88typedef struct {
  89        __u8 hfc_reg;           /* register number */
  90        __u8 reg_val;           /* value to be written (or read) */
  91        int action;             /* data for action handler */
  92} ctrl_buft;
  93
  94/* Debugging Flags */
  95#define HFCUSB_DBG_INIT         0x0001
  96#define HFCUSB_DBG_STATES       0x0002
  97#define HFCUSB_DBG_DCHANNEL     0x0080
  98#define HFCUSB_DBG_FIFO_ERR     0x4000
  99#define HFCUSB_DBG_VERBOSE_USB  0x8000
 100
 101/*
 102 * URB error codes:
 103 * Used to represent a list of values and their respective symbolic names
 104 */
 105struct hfcusb_symbolic_list {
 106        const int num;
 107        const char *name;
 108};
 109
 110static struct hfcusb_symbolic_list urb_errlist[] = {
 111        {-ENOMEM, "No memory for allocation of internal structures"},
 112        {-ENOSPC, "The host controller's bandwidth is already consumed"},
 113        {-ENOENT, "URB was canceled by unlink_urb"},
 114        {-EXDEV, "ISO transfer only partially completed"},
 115        {-EAGAIN, "Too match scheduled for the future"},
 116        {-ENXIO, "URB already queued"},
 117        {-EFBIG, "Too much ISO frames requested"},
 118        {-ENOSR, "Buffer error (overrun)"},
 119        {-EPIPE, "Specified endpoint is stalled (device not responding)"},
 120        {-EOVERFLOW, "Babble (bad cable?)"},
 121        {-EPROTO, "Bit-stuff error (bad cable?)"},
 122        {-EILSEQ, "CRC/Timeout"},
 123        {-ETIMEDOUT, "NAK (device does not respond)"},
 124        {-ESHUTDOWN, "Device unplugged"},
 125        {-1, NULL}
 126};
 127
 128
 129/*
 130 * device dependent information to support different
 131 * ISDN Ta's using the HFC-S USB chip
 132 */
 133
 134/* USB descriptor need to contain one of the following EndPoint combination: */
 135#define CNF_4INT3ISO    1       // 4 INT IN, 3 ISO OUT
 136#define CNF_3INT3ISO    2       // 3 INT IN, 3 ISO OUT
 137#define CNF_4ISO3ISO    3       // 4 ISO IN, 3 ISO OUT
 138#define CNF_3ISO3ISO    4       // 3 ISO IN, 3 ISO OUT
 139
 140#define EP_NUL  1       // Endpoint at this position not allowed
 141#define EP_NOP  2       // all type of endpoints allowed at this position
 142#define EP_ISO  3       // Isochron endpoint mandatory at this position
 143#define EP_BLK  4       // Bulk endpoint mandatory at this position
 144#define EP_INT  5       // Interrupt endpoint mandatory at this position
 145
 146/*
 147 * List of all supported endpoint configuration sets, used to find the
 148 * best matching endpoint configuration within a devices' USB descriptor.
 149 * We need at least 3 RX endpoints, and 3 TX endpoints, either
 150 * INT-in and ISO-out, or ISO-in and ISO-out)
 151 * with 4 RX endpoints even E-Channel logging is possible
 152 */
 153static int validconf[][19] = {
 154        // INT in, ISO out config
 155        {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT,
 156         EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
 157         CNF_4INT3ISO, 2, 1},
 158        {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_NUL,
 159         EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
 160         CNF_3INT3ISO, 2, 0},
 161        // ISO in, ISO out config
 162        {EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL,
 163         EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NOP, EP_ISO,
 164         CNF_4ISO3ISO, 2, 1},
 165        {EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL,
 166         EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NUL, EP_NUL,
 167         CNF_3ISO3ISO, 2, 0},
 168        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}        // EOL element
 169};
 170
 171#ifdef CONFIG_HISAX_DEBUG
 172// string description of chosen config
 173static char *conf_str[] = {
 174        "4 Interrupt IN + 3 Isochron OUT",
 175        "3 Interrupt IN + 3 Isochron OUT",
 176        "4 Isochron IN + 3 Isochron OUT",
 177        "3 Isochron IN + 3 Isochron OUT"
 178};
 179#endif
 180
 181typedef struct {
 182        int vendor;             // vendor id
 183        int prod_id;            // product id
 184        char *vend_name;        // vendor string
 185        __u8 led_scheme;        // led display scheme
 186        signed short led_bits[8];       // array of 8 possible LED bitmask settings
 187} vendor_data;
 188
 189#define LED_OFF         0       // no LED support
 190#define LED_SCHEME1     1       // LED standard scheme
 191#define LED_SCHEME2     2       // not used yet...
 192
 193#define LED_POWER_ON    1
 194#define LED_POWER_OFF   2
 195#define LED_S0_ON       3
 196#define LED_S0_OFF      4
 197#define LED_B1_ON       5
 198#define LED_B1_OFF      6
 199#define LED_B1_DATA     7
 200#define LED_B2_ON       8
 201#define LED_B2_OFF      9
 202#define LED_B2_DATA     10
 203
 204#define LED_NORMAL      0       // LEDs are normal
 205#define LED_INVERTED    1       // LEDs are inverted
 206
 207
 208#endif  // __HFC_USB_H__
 209