18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * hfcsusb.h, HFC-S USB mISDN driver 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef __HFCSUSB_H__ 78c2ecf20Sopenharmony_ci#define __HFCSUSB_H__ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define DRIVER_NAME "HFC-S_USB" 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define DBG_HFC_CALL_TRACE 0x00010000 138c2ecf20Sopenharmony_ci#define DBG_HFC_FIFO_VERBOSE 0x00020000 148c2ecf20Sopenharmony_ci#define DBG_HFC_USB_VERBOSE 0x00100000 158c2ecf20Sopenharmony_ci#define DBG_HFC_URB_INFO 0x00200000 168c2ecf20Sopenharmony_ci#define DBG_HFC_URB_ERROR 0x00400000 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define DEFAULT_TRANSP_BURST_SZ 128 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */ 218c2ecf20Sopenharmony_ci#define CLKDEL_TE 0x0f /* CLKDEL in TE mode */ 228c2ecf20Sopenharmony_ci#define CLKDEL_NT 0x6c /* CLKDEL in NT mode */ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* hfcsusb Layer1 commands */ 258c2ecf20Sopenharmony_ci#define HFC_L1_ACTIVATE_TE 1 268c2ecf20Sopenharmony_ci#define HFC_L1_ACTIVATE_NT 2 278c2ecf20Sopenharmony_ci#define HFC_L1_DEACTIVATE_NT 3 288c2ecf20Sopenharmony_ci#define HFC_L1_FORCE_DEACTIVATE_TE 4 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* cmd FLAGS in HFCUSB_STATES register */ 318c2ecf20Sopenharmony_ci#define HFCUSB_LOAD_STATE 0x10 328c2ecf20Sopenharmony_ci#define HFCUSB_ACTIVATE 0x20 338c2ecf20Sopenharmony_ci#define HFCUSB_DO_ACTION 0x40 348c2ecf20Sopenharmony_ci#define HFCUSB_NT_G2_G3 0x80 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* timers */ 378c2ecf20Sopenharmony_ci#define NT_ACTIVATION_TIMER 0x01 /* enables NT mode activation Timer */ 388c2ecf20Sopenharmony_ci#define NT_T1_COUNT 10 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ 438c2ecf20Sopenharmony_ci#define HFCUSB_TX_THRESHOLD 96 /* threshold for fifo report bit tx */ 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ 468c2ecf20Sopenharmony_ci#define HFCUSB_CIRM 0x00 /* cirm register index */ 478c2ecf20Sopenharmony_ci#define HFCUSB_USB_SIZE 0x07 /* int length register */ 488c2ecf20Sopenharmony_ci#define HFCUSB_USB_SIZE_I 0x06 /* iso length register */ 498c2ecf20Sopenharmony_ci#define HFCUSB_F_CROSS 0x0b /* bit order register */ 508c2ecf20Sopenharmony_ci#define HFCUSB_CLKDEL 0x37 /* bit delay register */ 518c2ecf20Sopenharmony_ci#define HFCUSB_CON_HDLC 0xfa /* channel connect register */ 528c2ecf20Sopenharmony_ci#define HFCUSB_HDLC_PAR 0xfb 538c2ecf20Sopenharmony_ci#define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */ 548c2ecf20Sopenharmony_ci#define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */ 558c2ecf20Sopenharmony_ci#define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */ 568c2ecf20Sopenharmony_ci#define HFCUSB_F_THRES 0x0c /* threshold register */ 578c2ecf20Sopenharmony_ci#define HFCUSB_FIFO 0x0f /* fifo select register */ 588c2ecf20Sopenharmony_ci#define HFCUSB_F_USAGE 0x1a /* fifo usage register */ 598c2ecf20Sopenharmony_ci#define HFCUSB_MST_MODE0 0x14 608c2ecf20Sopenharmony_ci#define HFCUSB_MST_MODE1 0x15 618c2ecf20Sopenharmony_ci#define HFCUSB_P_DATA 0x1f 628c2ecf20Sopenharmony_ci#define HFCUSB_INC_RES_F 0x0e 638c2ecf20Sopenharmony_ci#define HFCUSB_B1_SSL 0x20 648c2ecf20Sopenharmony_ci#define HFCUSB_B2_SSL 0x21 658c2ecf20Sopenharmony_ci#define HFCUSB_B1_RSL 0x24 668c2ecf20Sopenharmony_ci#define HFCUSB_B2_RSL 0x25 678c2ecf20Sopenharmony_ci#define HFCUSB_STATES 0x30 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/* fifo registers */ 738c2ecf20Sopenharmony_ci#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ 748c2ecf20Sopenharmony_ci#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ 758c2ecf20Sopenharmony_ci#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ 768c2ecf20Sopenharmony_ci#define HFCUSB_B2_TX 2 778c2ecf20Sopenharmony_ci#define HFCUSB_B2_RX 3 788c2ecf20Sopenharmony_ci#define HFCUSB_D_TX 4 798c2ecf20Sopenharmony_ci#define HFCUSB_D_RX 5 808c2ecf20Sopenharmony_ci#define HFCUSB_PCM_TX 6 818c2ecf20Sopenharmony_ci#define HFCUSB_PCM_RX 7 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define USB_INT 0 858c2ecf20Sopenharmony_ci#define USB_BULK 1 868c2ecf20Sopenharmony_ci#define USB_ISOC 2 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define ISOC_PACKETS_D 8 898c2ecf20Sopenharmony_ci#define ISOC_PACKETS_B 8 908c2ecf20Sopenharmony_ci#define ISO_BUFFER_SIZE 128 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* defines how much ISO packets are handled in one URB */ 938c2ecf20Sopenharmony_cistatic int iso_packets[8] = 948c2ecf20Sopenharmony_ci{ ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, 958c2ecf20Sopenharmony_ci ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D 968c2ecf20Sopenharmony_ci}; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* Fifo flow Control for TX ISO */ 1008c2ecf20Sopenharmony_ci#define SINK_MAX 68 1018c2ecf20Sopenharmony_ci#define SINK_MIN 48 1028c2ecf20Sopenharmony_ci#define SINK_DMIN 12 1038c2ecf20Sopenharmony_ci#define SINK_DMAX 18 1048c2ecf20Sopenharmony_ci#define BITLINE_INF (-96 * 8) 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* HFC-S USB register access by Control-URSs */ 1078c2ecf20Sopenharmony_ci#define write_reg_atomic(a, b, c) \ 1088c2ecf20Sopenharmony_ci usb_control_msg((a)->dev, (a)->ctrl_out_pipe, 0, 0x40, (c), (b), \ 1098c2ecf20Sopenharmony_ci 0, 0, HFC_CTRL_TIMEOUT) 1108c2ecf20Sopenharmony_ci#define read_reg_atomic(a, b, c) \ 1118c2ecf20Sopenharmony_ci usb_control_msg((a)->dev, (a)->ctrl_in_pipe, 1, 0xC0, 0, (b), (c), \ 1128c2ecf20Sopenharmony_ci 1, HFC_CTRL_TIMEOUT) 1138c2ecf20Sopenharmony_ci#define HFC_CTRL_BUFSIZE 64 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistruct ctrl_buf { 1168c2ecf20Sopenharmony_ci __u8 hfcs_reg; /* register number */ 1178c2ecf20Sopenharmony_ci __u8 reg_val; /* value to be written (or read) */ 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci/* 1218c2ecf20Sopenharmony_ci * URB error codes 1228c2ecf20Sopenharmony_ci * Used to represent a list of values and their respective symbolic names 1238c2ecf20Sopenharmony_ci */ 1248c2ecf20Sopenharmony_cistruct hfcusb_symbolic_list { 1258c2ecf20Sopenharmony_ci const int num; 1268c2ecf20Sopenharmony_ci const char *name; 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cistatic struct hfcusb_symbolic_list urb_errlist[] = { 1308c2ecf20Sopenharmony_ci {-ENOMEM, "No memory for allocation of internal structures"}, 1318c2ecf20Sopenharmony_ci {-ENOSPC, "The host controller's bandwidth is already consumed"}, 1328c2ecf20Sopenharmony_ci {-ENOENT, "URB was canceled by unlink_urb"}, 1338c2ecf20Sopenharmony_ci {-EXDEV, "ISO transfer only partially completed"}, 1348c2ecf20Sopenharmony_ci {-EAGAIN, "Too match scheduled for the future"}, 1358c2ecf20Sopenharmony_ci {-ENXIO, "URB already queued"}, 1368c2ecf20Sopenharmony_ci {-EFBIG, "Too much ISO frames requested"}, 1378c2ecf20Sopenharmony_ci {-ENOSR, "Buffer error (overrun)"}, 1388c2ecf20Sopenharmony_ci {-EPIPE, "Specified endpoint is stalled (device not responding)"}, 1398c2ecf20Sopenharmony_ci {-EOVERFLOW, "Babble (bad cable?)"}, 1408c2ecf20Sopenharmony_ci {-EPROTO, "Bit-stuff error (bad cable?)"}, 1418c2ecf20Sopenharmony_ci {-EILSEQ, "CRC/Timeout"}, 1428c2ecf20Sopenharmony_ci {-ETIMEDOUT, "NAK (device does not respond)"}, 1438c2ecf20Sopenharmony_ci {-ESHUTDOWN, "Device unplugged"}, 1448c2ecf20Sopenharmony_ci {-1, NULL} 1458c2ecf20Sopenharmony_ci}; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistatic inline const char * 1488c2ecf20Sopenharmony_cisymbolic(struct hfcusb_symbolic_list list[], const int num) 1498c2ecf20Sopenharmony_ci{ 1508c2ecf20Sopenharmony_ci int i; 1518c2ecf20Sopenharmony_ci for (i = 0; list[i].name != NULL; i++) 1528c2ecf20Sopenharmony_ci if (list[i].num == num) 1538c2ecf20Sopenharmony_ci return list[i].name; 1548c2ecf20Sopenharmony_ci return "<unknown USB Error>"; 1558c2ecf20Sopenharmony_ci} 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci/* USB descriptor need to contain one of the following EndPoint combination: */ 1588c2ecf20Sopenharmony_ci#define CNF_4INT3ISO 1 /* 4 INT IN, 3 ISO OUT */ 1598c2ecf20Sopenharmony_ci#define CNF_3INT3ISO 2 /* 3 INT IN, 3 ISO OUT */ 1608c2ecf20Sopenharmony_ci#define CNF_4ISO3ISO 3 /* 4 ISO IN, 3 ISO OUT */ 1618c2ecf20Sopenharmony_ci#define CNF_3ISO3ISO 4 /* 3 ISO IN, 3 ISO OUT */ 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci#define EP_NUL 1 /* Endpoint at this position not allowed */ 1648c2ecf20Sopenharmony_ci#define EP_NOP 2 /* all type of endpoints allowed at this position */ 1658c2ecf20Sopenharmony_ci#define EP_ISO 3 /* Isochron endpoint mandatory at this position */ 1668c2ecf20Sopenharmony_ci#define EP_BLK 4 /* Bulk endpoint mandatory at this position */ 1678c2ecf20Sopenharmony_ci#define EP_INT 5 /* Interrupt endpoint mandatory at this position */ 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci#define HFC_CHAN_B1 0 1708c2ecf20Sopenharmony_ci#define HFC_CHAN_B2 1 1718c2ecf20Sopenharmony_ci#define HFC_CHAN_D 2 1728c2ecf20Sopenharmony_ci#define HFC_CHAN_E 3 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci/* 1768c2ecf20Sopenharmony_ci * List of all supported endpoint configuration sets, used to find the 1778c2ecf20Sopenharmony_ci * best matching endpoint configuration within a device's USB descriptor. 1788c2ecf20Sopenharmony_ci * We need at least 3 RX endpoints, and 3 TX endpoints, either 1798c2ecf20Sopenharmony_ci * INT-in and ISO-out, or ISO-in and ISO-out) 1808c2ecf20Sopenharmony_ci * with 4 RX endpoints even E-Channel logging is possible 1818c2ecf20Sopenharmony_ci */ 1828c2ecf20Sopenharmony_cistatic int 1838c2ecf20Sopenharmony_civalidconf[][19] = { 1848c2ecf20Sopenharmony_ci /* INT in, ISO out config */ 1858c2ecf20Sopenharmony_ci {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT, 1868c2ecf20Sopenharmony_ci EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL, 1878c2ecf20Sopenharmony_ci CNF_4INT3ISO, 2, 1}, 1888c2ecf20Sopenharmony_ci {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_NUL, 1898c2ecf20Sopenharmony_ci EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL, 1908c2ecf20Sopenharmony_ci CNF_3INT3ISO, 2, 0}, 1918c2ecf20Sopenharmony_ci /* ISO in, ISO out config */ 1928c2ecf20Sopenharmony_ci {EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, 1938c2ecf20Sopenharmony_ci EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NOP, EP_ISO, 1948c2ecf20Sopenharmony_ci CNF_4ISO3ISO, 2, 1}, 1958c2ecf20Sopenharmony_ci {EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, 1968c2ecf20Sopenharmony_ci EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NUL, EP_NUL, 1978c2ecf20Sopenharmony_ci CNF_3ISO3ISO, 2, 0}, 1988c2ecf20Sopenharmony_ci {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* EOL element */ 1998c2ecf20Sopenharmony_ci}; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci/* string description of chosen config */ 2028c2ecf20Sopenharmony_cistatic char *conf_str[] = { 2038c2ecf20Sopenharmony_ci "4 Interrupt IN + 3 Isochron OUT", 2048c2ecf20Sopenharmony_ci "3 Interrupt IN + 3 Isochron OUT", 2058c2ecf20Sopenharmony_ci "4 Isochron IN + 3 Isochron OUT", 2068c2ecf20Sopenharmony_ci "3 Isochron IN + 3 Isochron OUT" 2078c2ecf20Sopenharmony_ci}; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci#define LED_OFF 0 /* no LED support */ 2118c2ecf20Sopenharmony_ci#define LED_SCHEME1 1 /* LED standard scheme */ 2128c2ecf20Sopenharmony_ci#define LED_SCHEME2 2 /* not used yet... */ 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci#define LED_POWER_ON 1 2158c2ecf20Sopenharmony_ci#define LED_POWER_OFF 2 2168c2ecf20Sopenharmony_ci#define LED_S0_ON 3 2178c2ecf20Sopenharmony_ci#define LED_S0_OFF 4 2188c2ecf20Sopenharmony_ci#define LED_B1_ON 5 2198c2ecf20Sopenharmony_ci#define LED_B1_OFF 6 2208c2ecf20Sopenharmony_ci#define LED_B1_DATA 7 2218c2ecf20Sopenharmony_ci#define LED_B2_ON 8 2228c2ecf20Sopenharmony_ci#define LED_B2_OFF 9 2238c2ecf20Sopenharmony_ci#define LED_B2_DATA 10 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci#define LED_NORMAL 0 /* LEDs are normal */ 2268c2ecf20Sopenharmony_ci#define LED_INVERTED 1 /* LEDs are inverted */ 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci/* time in ms to perform a Flashing LED when B-Channel has traffic */ 2298c2ecf20Sopenharmony_ci#define LED_TIME 250 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_cistruct hfcsusb; 2348c2ecf20Sopenharmony_cistruct usb_fifo; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci/* structure defining input+output fifos (interrupt/bulk mode) */ 2378c2ecf20Sopenharmony_cistruct iso_urb { 2388c2ecf20Sopenharmony_ci struct urb *urb; 2398c2ecf20Sopenharmony_ci __u8 buffer[ISO_BUFFER_SIZE]; /* buffer rx/tx USB URB data */ 2408c2ecf20Sopenharmony_ci struct usb_fifo *owner_fifo; /* pointer to owner fifo */ 2418c2ecf20Sopenharmony_ci __u8 indx; /* Fifos's ISO double buffer 0 or 1 ? */ 2428c2ecf20Sopenharmony_ci#ifdef ISO_FRAME_START_DEBUG 2438c2ecf20Sopenharmony_ci int start_frames[ISO_FRAME_START_RING_COUNT]; 2448c2ecf20Sopenharmony_ci __u8 iso_frm_strt_pos; /* index in start_frame[] */ 2458c2ecf20Sopenharmony_ci#endif 2468c2ecf20Sopenharmony_ci}; 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_cistruct usb_fifo { 2498c2ecf20Sopenharmony_ci int fifonum; /* fifo index attached to this structure */ 2508c2ecf20Sopenharmony_ci int active; /* fifo is currently active */ 2518c2ecf20Sopenharmony_ci struct hfcsusb *hw; /* pointer to main structure */ 2528c2ecf20Sopenharmony_ci int pipe; /* address of endpoint */ 2538c2ecf20Sopenharmony_ci __u8 usb_packet_maxlen; /* maximum length for usb transfer */ 2548c2ecf20Sopenharmony_ci unsigned int max_size; /* maximum size of receive/send packet */ 2558c2ecf20Sopenharmony_ci __u8 intervall; /* interrupt interval */ 2568c2ecf20Sopenharmony_ci struct urb *urb; /* transfer structure for usb routines */ 2578c2ecf20Sopenharmony_ci __u8 buffer[128]; /* buffer USB INT OUT URB data */ 2588c2ecf20Sopenharmony_ci int bit_line; /* how much bits are in the fifo? */ 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci __u8 usb_transfer_mode; /* switched between ISO and INT */ 2618c2ecf20Sopenharmony_ci struct iso_urb iso[2]; /* two urbs to have one always 2628c2ecf20Sopenharmony_ci one pending */ 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci struct dchannel *dch; /* link to hfcsusb_t->dch */ 2658c2ecf20Sopenharmony_ci struct bchannel *bch; /* link to hfcsusb_t->bch */ 2668c2ecf20Sopenharmony_ci struct dchannel *ech; /* link to hfcsusb_t->ech, TODO: E-CHANNEL */ 2678c2ecf20Sopenharmony_ci int last_urblen; /* remember length of last packet */ 2688c2ecf20Sopenharmony_ci __u8 stop_gracefull; /* stops URB retransmission */ 2698c2ecf20Sopenharmony_ci}; 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_cistruct hfcsusb { 2728c2ecf20Sopenharmony_ci struct list_head list; 2738c2ecf20Sopenharmony_ci struct dchannel dch; 2748c2ecf20Sopenharmony_ci struct bchannel bch[2]; 2758c2ecf20Sopenharmony_ci struct dchannel ech; /* TODO : wait for struct echannel ;) */ 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci struct usb_device *dev; /* our device */ 2788c2ecf20Sopenharmony_ci struct usb_interface *intf; /* used interface */ 2798c2ecf20Sopenharmony_ci int if_used; /* used interface number */ 2808c2ecf20Sopenharmony_ci int alt_used; /* used alternate config */ 2818c2ecf20Sopenharmony_ci int cfg_used; /* configuration index used */ 2828c2ecf20Sopenharmony_ci int vend_idx; /* index in hfcsusb_idtab */ 2838c2ecf20Sopenharmony_ci int packet_size; 2848c2ecf20Sopenharmony_ci int iso_packet_size; 2858c2ecf20Sopenharmony_ci struct usb_fifo fifos[HFCUSB_NUM_FIFOS]; 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci /* control pipe background handling */ 2888c2ecf20Sopenharmony_ci struct ctrl_buf ctrl_buff[HFC_CTRL_BUFSIZE]; 2898c2ecf20Sopenharmony_ci int ctrl_in_idx, ctrl_out_idx, ctrl_cnt; 2908c2ecf20Sopenharmony_ci struct urb *ctrl_urb; 2918c2ecf20Sopenharmony_ci struct usb_ctrlrequest ctrl_write; 2928c2ecf20Sopenharmony_ci struct usb_ctrlrequest ctrl_read; 2938c2ecf20Sopenharmony_ci int ctrl_paksize; 2948c2ecf20Sopenharmony_ci int ctrl_in_pipe, ctrl_out_pipe; 2958c2ecf20Sopenharmony_ci spinlock_t ctrl_lock; /* lock for ctrl */ 2968c2ecf20Sopenharmony_ci spinlock_t lock; 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci __u8 threshold_mask; 2998c2ecf20Sopenharmony_ci __u8 led_state; 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci __u8 protocol; 3028c2ecf20Sopenharmony_ci int nt_timer; 3038c2ecf20Sopenharmony_ci int open; 3048c2ecf20Sopenharmony_ci __u8 timers; 3058c2ecf20Sopenharmony_ci __u8 initdone; 3068c2ecf20Sopenharmony_ci char name[MISDN_MAX_IDLEN]; 3078c2ecf20Sopenharmony_ci}; 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci/* private vendor specific data */ 3108c2ecf20Sopenharmony_cistruct hfcsusb_vdata { 3118c2ecf20Sopenharmony_ci __u8 led_scheme; /* led display scheme */ 3128c2ecf20Sopenharmony_ci signed short led_bits[8]; /* array of 8 possible LED bitmask */ 3138c2ecf20Sopenharmony_ci char *vend_name; /* device name */ 3148c2ecf20Sopenharmony_ci}; 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci#define HFC_MAX_TE_LAYER1_STATE 8 3188c2ecf20Sopenharmony_ci#define HFC_MAX_NT_LAYER1_STATE 4 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_cistatic const char *HFC_TE_LAYER1_STATES[HFC_MAX_TE_LAYER1_STATE + 1] = { 3218c2ecf20Sopenharmony_ci "TE F0 - Reset", 3228c2ecf20Sopenharmony_ci "TE F1 - Reset", 3238c2ecf20Sopenharmony_ci "TE F2 - Sensing", 3248c2ecf20Sopenharmony_ci "TE F3 - Deactivated", 3258c2ecf20Sopenharmony_ci "TE F4 - Awaiting signal", 3268c2ecf20Sopenharmony_ci "TE F5 - Identifying input", 3278c2ecf20Sopenharmony_ci "TE F6 - Synchronized", 3288c2ecf20Sopenharmony_ci "TE F7 - Activated", 3298c2ecf20Sopenharmony_ci "TE F8 - Lost framing", 3308c2ecf20Sopenharmony_ci}; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cistatic const char *HFC_NT_LAYER1_STATES[HFC_MAX_NT_LAYER1_STATE + 1] = { 3338c2ecf20Sopenharmony_ci "NT G0 - Reset", 3348c2ecf20Sopenharmony_ci "NT G1 - Deactive", 3358c2ecf20Sopenharmony_ci "NT G2 - Pending activation", 3368c2ecf20Sopenharmony_ci "NT G3 - Active", 3378c2ecf20Sopenharmony_ci "NT G4 - Pending deactivation", 3388c2ecf20Sopenharmony_ci}; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci/* supported devices */ 3418c2ecf20Sopenharmony_cistatic const struct usb_device_id hfcsusb_idtab[] = { 3428c2ecf20Sopenharmony_ci { 3438c2ecf20Sopenharmony_ci USB_DEVICE(0x0959, 0x2bd0), 3448c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3458c2ecf20Sopenharmony_ci {LED_OFF, {4, 0, 2, 1}, 3468c2ecf20Sopenharmony_ci "ISDN USB TA (Cologne Chip HFC-S USB based)"}), 3478c2ecf20Sopenharmony_ci }, 3488c2ecf20Sopenharmony_ci { 3498c2ecf20Sopenharmony_ci USB_DEVICE(0x0675, 0x1688), 3508c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3518c2ecf20Sopenharmony_ci {LED_SCHEME1, {1, 2, 0, 0}, 3528c2ecf20Sopenharmony_ci "DrayTek miniVigor 128 USB ISDN TA"}), 3538c2ecf20Sopenharmony_ci }, 3548c2ecf20Sopenharmony_ci { 3558c2ecf20Sopenharmony_ci USB_DEVICE(0x07b0, 0x0007), 3568c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3578c2ecf20Sopenharmony_ci {LED_SCHEME1, {0x80, -64, -32, -16}, 3588c2ecf20Sopenharmony_ci "Billion tiny USB ISDN TA 128"}), 3598c2ecf20Sopenharmony_ci }, 3608c2ecf20Sopenharmony_ci { 3618c2ecf20Sopenharmony_ci USB_DEVICE(0x0742, 0x2008), 3628c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3638c2ecf20Sopenharmony_ci {LED_SCHEME1, {4, 0, 2, 1}, 3648c2ecf20Sopenharmony_ci "Stollmann USB TA"}), 3658c2ecf20Sopenharmony_ci }, 3668c2ecf20Sopenharmony_ci { 3678c2ecf20Sopenharmony_ci USB_DEVICE(0x0742, 0x2009), 3688c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3698c2ecf20Sopenharmony_ci {LED_SCHEME1, {4, 0, 2, 1}, 3708c2ecf20Sopenharmony_ci "Aceex USB ISDN TA"}), 3718c2ecf20Sopenharmony_ci }, 3728c2ecf20Sopenharmony_ci { 3738c2ecf20Sopenharmony_ci USB_DEVICE(0x0742, 0x200A), 3748c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3758c2ecf20Sopenharmony_ci {LED_SCHEME1, {4, 0, 2, 1}, 3768c2ecf20Sopenharmony_ci "OEM USB ISDN TA"}), 3778c2ecf20Sopenharmony_ci }, 3788c2ecf20Sopenharmony_ci { 3798c2ecf20Sopenharmony_ci USB_DEVICE(0x08e3, 0x0301), 3808c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3818c2ecf20Sopenharmony_ci {LED_SCHEME1, {2, 0, 1, 4}, 3828c2ecf20Sopenharmony_ci "Olitec USB RNIS"}), 3838c2ecf20Sopenharmony_ci }, 3848c2ecf20Sopenharmony_ci { 3858c2ecf20Sopenharmony_ci USB_DEVICE(0x07fa, 0x0846), 3868c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3878c2ecf20Sopenharmony_ci {LED_SCHEME1, {0x80, -64, -32, -16}, 3888c2ecf20Sopenharmony_ci "Bewan Modem RNIS USB"}), 3898c2ecf20Sopenharmony_ci }, 3908c2ecf20Sopenharmony_ci { 3918c2ecf20Sopenharmony_ci USB_DEVICE(0x07fa, 0x0847), 3928c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3938c2ecf20Sopenharmony_ci {LED_SCHEME1, {0x80, -64, -32, -16}, 3948c2ecf20Sopenharmony_ci "Djinn Numeris USB"}), 3958c2ecf20Sopenharmony_ci }, 3968c2ecf20Sopenharmony_ci { 3978c2ecf20Sopenharmony_ci USB_DEVICE(0x07b0, 0x0006), 3988c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 3998c2ecf20Sopenharmony_ci {LED_SCHEME1, {0x80, -64, -32, -16}, 4008c2ecf20Sopenharmony_ci "Twister ISDN TA"}), 4018c2ecf20Sopenharmony_ci }, 4028c2ecf20Sopenharmony_ci { 4038c2ecf20Sopenharmony_ci USB_DEVICE(0x071d, 0x1005), 4048c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 4058c2ecf20Sopenharmony_ci {LED_SCHEME1, {0x02, 0, 0x01, 0x04}, 4068c2ecf20Sopenharmony_ci "Eicon DIVA USB 4.0"}), 4078c2ecf20Sopenharmony_ci }, 4088c2ecf20Sopenharmony_ci { 4098c2ecf20Sopenharmony_ci USB_DEVICE(0x0586, 0x0102), 4108c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 4118c2ecf20Sopenharmony_ci {LED_SCHEME1, {0x88, -64, -32, -16}, 4128c2ecf20Sopenharmony_ci "ZyXEL OMNI.NET USB II"}), 4138c2ecf20Sopenharmony_ci }, 4148c2ecf20Sopenharmony_ci { 4158c2ecf20Sopenharmony_ci USB_DEVICE(0x1ae7, 0x0525), 4168c2ecf20Sopenharmony_ci .driver_info = (unsigned long) &((struct hfcsusb_vdata) 4178c2ecf20Sopenharmony_ci {LED_SCHEME1, {0x88, -64, -32, -16}, 4188c2ecf20Sopenharmony_ci "X-Tensions USB ISDN TA XC-525"}), 4198c2ecf20Sopenharmony_ci }, 4208c2ecf20Sopenharmony_ci { } 4218c2ecf20Sopenharmony_ci}; 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(usb, hfcsusb_idtab); 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci#endif /* __HFCSUSB_H__ */ 426