10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52191Sszhou * Common Development and Distribution License (the "License"). 62191Sszhou * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*10061SRaymond.Chen@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_USB_USBSER_VAR_H 270Sstevel@tonic-gate #define _SYS_USB_USBSER_VAR_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate 300Sstevel@tonic-gate /* 310Sstevel@tonic-gate * USB-to-serial driver definitions 320Sstevel@tonic-gate */ 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <sys/tty.h> 350Sstevel@tonic-gate #include <sys/mkdev.h> 360Sstevel@tonic-gate #include <sys/sunddi.h> 370Sstevel@tonic-gate #include <sys/note.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #include <sys/usb/clients/usbser/usbser_dsdi.h> 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifdef __cplusplus 420Sstevel@tonic-gate extern "C" { 430Sstevel@tonic-gate #endif 440Sstevel@tonic-gate 450Sstevel@tonic-gate typedef struct usbser_state usbser_state_t; 460Sstevel@tonic-gate typedef struct usbser_port usbser_port_t; 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 490Sstevel@tonic-gate * because put() and srv() routines are not allowed to block, usbser 500Sstevel@tonic-gate * provides each port with two threads: for read and write processing 510Sstevel@tonic-gate * this structure describes the data associated with a usbser thread 520Sstevel@tonic-gate */ 530Sstevel@tonic-gate typedef struct usbser_thread { 540Sstevel@tonic-gate kcondvar_t thr_cv; /* cv for request wait */ 550Sstevel@tonic-gate uint_t thr_flags; /* state flags */ 560Sstevel@tonic-gate usbser_port_t *thr_port; /* port owner of this thread */ 570Sstevel@tonic-gate void (*thr_func)(void *); /* function to be run */ 580Sstevel@tonic-gate void *thr_arg; /* function argument */ 590Sstevel@tonic-gate } usbser_thread_t; 600Sstevel@tonic-gate 610Sstevel@tonic-gate /* 620Sstevel@tonic-gate * thr_flags 630Sstevel@tonic-gate */ 640Sstevel@tonic-gate enum { 650Sstevel@tonic-gate USBSER_THR_RUNNING = 0x01, /* thread is running */ 660Sstevel@tonic-gate USBSER_THR_WAKE = 0x02, /* wake requested */ 670Sstevel@tonic-gate USBSER_THR_EXITED = 0x04 /* thread exited */ 680Sstevel@tonic-gate }; 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* 710Sstevel@tonic-gate * additional device state 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate #define USBSER_DEV_INIT 0x80 /* device is being initialized */ 740Sstevel@tonic-gate 750Sstevel@tonic-gate /* 760Sstevel@tonic-gate * per instance data 770Sstevel@tonic-gate */ 780Sstevel@tonic-gate struct usbser_state { 792191Sszhou struct usbser_state *us_next; /* linked list */ 800Sstevel@tonic-gate dev_info_t *us_dip; /* device information */ 810Sstevel@tonic-gate kmutex_t us_mutex; /* structure lock */ 820Sstevel@tonic-gate void *us_statep; /* soft state anchor */ 830Sstevel@tonic-gate int us_instance; /* instance number */ 840Sstevel@tonic-gate ds_ops_t *us_ds_ops; /* DSD operations */ 850Sstevel@tonic-gate ds_hdl_t us_ds_hdl; /* DSD device handle */ 860Sstevel@tonic-gate uint_t us_port_cnt; /* port count */ 870Sstevel@tonic-gate usbser_port_t *us_ports; /* array of port structs */ 880Sstevel@tonic-gate uint_t us_dev_state; /* USB device state */ 890Sstevel@tonic-gate usb_log_handle_t us_lh; /* USB log handle */ 900Sstevel@tonic-gate ddi_taskq_t *us_taskq; /* taskq for command handling */ 910Sstevel@tonic-gate }; 920Sstevel@tonic-gate 930Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usbser_state::us_mutex, usbser_state::us_dev_state)) 940Sstevel@tonic-gate 950Sstevel@tonic-gate /* 960Sstevel@tonic-gate * per port data 970Sstevel@tonic-gate */ 980Sstevel@tonic-gate struct usbser_port { 990Sstevel@tonic-gate kmutex_t port_mutex; /* structure lock */ 1000Sstevel@tonic-gate usbser_state_t *port_usp; /* back pointer to state */ 1010Sstevel@tonic-gate char port_lh_name[16]; /* log handle name */ 1020Sstevel@tonic-gate usb_log_handle_t port_lh; /* log handle */ 1030Sstevel@tonic-gate ds_ops_t *port_ds_ops; /* copy from usbser_state */ 1040Sstevel@tonic-gate ds_hdl_t port_ds_hdl; /* copy from usbser_state */ 1050Sstevel@tonic-gate uint_t port_num; /* port number */ 1060Sstevel@tonic-gate uint_t port_state; /* port state */ 1070Sstevel@tonic-gate uint_t port_act; /* current activities on port */ 1080Sstevel@tonic-gate uint_t port_flags; /* port flags */ 1090Sstevel@tonic-gate kcondvar_t port_state_cv; /* port state cv */ 1100Sstevel@tonic-gate kcondvar_t port_act_cv; /* port activity cv */ 1110Sstevel@tonic-gate kcondvar_t port_car_cv; /* port carrier cv */ 1120Sstevel@tonic-gate uint_t port_wq_data_cnt; /* amount of unsent data */ 1130Sstevel@tonic-gate usbser_thread_t port_wq_thread; /* wq thread */ 1140Sstevel@tonic-gate usbser_thread_t port_rq_thread; /* rq thread */ 1150Sstevel@tonic-gate tty_common_t port_ttycommon; /* tty driver common data */ 1160Sstevel@tonic-gate uchar_t port_flowc; /* flow control char */ 1170Sstevel@tonic-gate timeout_id_t port_delay_id; /* delay/break timeout id */ 1180Sstevel@tonic-gate }; 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usbser_port::port_mutex, usbser_port)) 1210Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbser_port::{ 1220Sstevel@tonic-gate port_usp 1230Sstevel@tonic-gate port_lh 1240Sstevel@tonic-gate port_ds_ops 1250Sstevel@tonic-gate port_ds_hdl 1260Sstevel@tonic-gate port_num 1270Sstevel@tonic-gate port_ttycommon.t_{readq writeq} 1280Sstevel@tonic-gate })) 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate _NOTE(LOCK_ORDER(usbser_state::us_mutex usbser_port::port_mutex)) 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate /* 1330Sstevel@tonic-gate * port_state: 1340Sstevel@tonic-gate * 1350Sstevel@tonic-gate * USBSER_PORT_NOT_INIT 1360Sstevel@tonic-gate * | ^ 1370Sstevel@tonic-gate * | | 1380Sstevel@tonic-gate * attach detach 1390Sstevel@tonic-gate * | | 1400Sstevel@tonic-gate * | | +----open[1]----> USBSER_PORT_OPENING_TTY ------+ 1410Sstevel@tonic-gate * | | | | | | 1420Sstevel@tonic-gate * v | | | | | 1430Sstevel@tonic-gate * USBSER_PORT_CLOSED <---device error---< overtake[2] | 1440Sstevel@tonic-gate * | | | | v 1450Sstevel@tonic-gate * | | | v | 1460Sstevel@tonic-gate * | +----open[1]----> USBSER_PORT_OPENING_OUT | 1470Sstevel@tonic-gate * | | | 1480Sstevel@tonic-gate * | | +-------------------+ 1490Sstevel@tonic-gate * | | | 1500Sstevel@tonic-gate * | v v 1510Sstevel@tonic-gate * USBSER_PORT_CLOSING <-----close----- USBSER_PORT_OPEN <-----------+ 1520Sstevel@tonic-gate * ^ | ^ --------+ | 1530Sstevel@tonic-gate * | | | | | 1540Sstevel@tonic-gate * | | | | | 1550Sstevel@tonic-gate * | v | v | 1560Sstevel@tonic-gate * +------close----- USBSER_PORT_DISCONNECTED USBSER_PORT_SUSPENDED 1570Sstevel@tonic-gate * 1580Sstevel@tonic-gate * Notes: 1590Sstevel@tonic-gate * 1600Sstevel@tonic-gate * [1] for each physical port N two device nodes are created: 1610Sstevel@tonic-gate * 1620Sstevel@tonic-gate * /dev/term/N (tty mode) 1630Sstevel@tonic-gate * /dev/cua/N (dial-out mode) 1640Sstevel@tonic-gate * 1650Sstevel@tonic-gate * the port can only be opened in one of these modes at a time. 1660Sstevel@tonic-gate * difference between the two is that in tty mode the driver 1670Sstevel@tonic-gate * will block in open(9E) until the CD (Carrier Detect) pin comes up, 1680Sstevel@tonic-gate * while in dial-out mode CD is ignored. opening and closing states 1690Sstevel@tonic-gate * help to avoid race conditions between two threads trying to open/close 1700Sstevel@tonic-gate * one physical port in two different modes simultaneously. 1710Sstevel@tonic-gate * 1720Sstevel@tonic-gate * [2] tty mode open may be blocked waiting for carrier. 1730Sstevel@tonic-gate * if dial-out mode open happens at this time, it is allowed 1740Sstevel@tonic-gate * for it to overtake the port; from zs(7D) man page: 1750Sstevel@tonic-gate * 1760Sstevel@tonic-gate * This allows a modem to be attached to /dev/term/[n] 1770Sstevel@tonic-gate * and used for dial-in (by enabling the line for login in /etc/inittab) 1780Sstevel@tonic-gate * and also used for dial-out (by tip(1) or uucp(1C)) as /dev/cua/[n] 1790Sstevel@tonic-gate * when no one is logged in on the line. 1800Sstevel@tonic-gate */ 1810Sstevel@tonic-gate enum { 1820Sstevel@tonic-gate USBSER_PORT_NOT_INIT = 0, /* port not initialized */ 1830Sstevel@tonic-gate USBSER_PORT_CLOSED, /* port is closed */ 1840Sstevel@tonic-gate USBSER_PORT_OPENING_TTY, /* tty open in progress */ 1850Sstevel@tonic-gate USBSER_PORT_OPENING_OUT, /* dial-out open in progress */ 1860Sstevel@tonic-gate USBSER_PORT_OPEN, /* port is open */ 1870Sstevel@tonic-gate USBSER_PORT_SUSPENDED, /* port is suspended */ 1880Sstevel@tonic-gate USBSER_PORT_DISCONNECTED, /* port is disconnected */ 1890Sstevel@tonic-gate USBSER_PORT_CLOSING /* close() is in progress */ 1900Sstevel@tonic-gate }; 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate /* constants used by state machine implementation */ 1930Sstevel@tonic-gate enum { 1940Sstevel@tonic-gate USBSER_CONTINUE = -1, 1950Sstevel@tonic-gate USBSER_COMPLETE = 0 1960Sstevel@tonic-gate }; 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate /* 1990Sstevel@tonic-gate * port_act: current activities on the port. 2000Sstevel@tonic-gate * only one activity of each type is allowed at a time. 2010Sstevel@tonic-gate */ 2020Sstevel@tonic-gate enum { 2030Sstevel@tonic-gate USBSER_ACT_TX = 0x0001, /* transmitting data */ 2040Sstevel@tonic-gate USBSER_ACT_RX = 0x0002, /* receiving data */ 2050Sstevel@tonic-gate USBSER_ACT_CTL = 0x0004, /* controlling the device */ 2060Sstevel@tonic-gate USBSER_ACT_BREAK = 0x0010, /* doing break */ 2070Sstevel@tonic-gate USBSER_ACT_DELAY = 0x0020, /* doing delay */ 2080Sstevel@tonic-gate USBSER_ACT_ALL = 0xffff /* all actions (must be >0) */ 2090Sstevel@tonic-gate }; 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate /* 2120Sstevel@tonic-gate * port_flags 2130Sstevel@tonic-gate */ 2140Sstevel@tonic-gate enum { 2150Sstevel@tonic-gate USBSER_FL_OUT = 0x0001, /* dial-out */ 2160Sstevel@tonic-gate USBSER_FL_WOPEN = 0x0002, /* waiting in open() */ 2170Sstevel@tonic-gate USBSER_FL_CARR_ON = 0x0004, /* carrier is on */ 2180Sstevel@tonic-gate USBSER_FL_TX_STOPPED = 0x0008, /* output stopped */ 2190Sstevel@tonic-gate USBSER_FL_RX_STOPPED = 0x0010, /* input stopped */ 2200Sstevel@tonic-gate USBSER_FL_HUNGUP = 0x0020, /* stream is hung up */ 2210Sstevel@tonic-gate USBSER_FL_DSD_OPEN = 0x0040, /* DSD is open */ 2220Sstevel@tonic-gate USBSER_FL_STATUS_CB = 0x0080, /* status callback pending */ 2230Sstevel@tonic-gate USBSER_FL_IGNORE_CD = 0x0100, /* ignore carrier detect */ 2240Sstevel@tonic-gate USBSER_FL_PRESERVE = USBSER_FL_IGNORE_CD 2250Sstevel@tonic-gate /* flags that need to */ 2260Sstevel@tonic-gate /* be preserved across opens */ 2270Sstevel@tonic-gate }; 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate /* 2300Sstevel@tonic-gate * current sun compiler does not seem to inline static leaf routines at O3 2310Sstevel@tonic-gate * so we have to use preprocessor macros to make up for compiler disability 2320Sstevel@tonic-gate * 2330Sstevel@tonic-gate * can we access the port? 2340Sstevel@tonic-gate */ 2350Sstevel@tonic-gate #define USBSER_PORT_ACCESS_OK(pp) ((pp)->port_state == USBSER_PORT_OPEN) 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* 2380Sstevel@tonic-gate * is port doing something? 2390Sstevel@tonic-gate */ 2400Sstevel@tonic-gate #define USBSER_PORT_IS_BUSY(pp) ((pp)->port_act != 0) 2410Sstevel@tonic-gate 242*10061SRaymond.Chen@Sun.COM /* port is busy on TX, delay, break, ctrl */ 243*10061SRaymond.Chen@Sun.COM #define USBSER_PORT_IS_BUSY_NON_RX(pp) \ 244*10061SRaymond.Chen@Sun.COM (((pp)->port_act & (USBSER_ACT_DELAY | USBSER_ACT_CTL | \ 245*10061SRaymond.Chen@Sun.COM USBSER_ACT_BREAK | USBSER_ACT_TX)) != 0) 246*10061SRaymond.Chen@Sun.COM 2470Sstevel@tonic-gate /* 2480Sstevel@tonic-gate * is the port opening? 2490Sstevel@tonic-gate */ 2500Sstevel@tonic-gate #define USBSER_IS_OPENING(pp) \ 2510Sstevel@tonic-gate (((pp)->port_state == USBSER_PORT_OPENING_TTY) || \ 2520Sstevel@tonic-gate ((pp)->port_state == USBSER_PORT_OPENING_OUT)) 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate /* 2550Sstevel@tonic-gate * determine, while we are trying to open the port, 2560Sstevel@tonic-gate * whether it is currently being open in the opposite mode 2570Sstevel@tonic-gate */ 2580Sstevel@tonic-gate #define USBSER_NO_OTHER_OPEN(pp, minor) \ 2590Sstevel@tonic-gate ((((minor) & OUTLINE) && \ 2600Sstevel@tonic-gate ((pp)->port_state == USBSER_PORT_OPENING_OUT)) || \ 2610Sstevel@tonic-gate (!((minor) & OUTLINE) && ((pp)->port_state == USBSER_PORT_OPENING_TTY))) 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate /* 2640Sstevel@tonic-gate * determine, while we are trying to open the port, 2650Sstevel@tonic-gate * whether it is already open in the opposite mode 2660Sstevel@tonic-gate */ 2670Sstevel@tonic-gate #define USBSER_OPEN_IN_OTHER_MODE(pp, minor) \ 2680Sstevel@tonic-gate ((((minor) & OUTLINE) && !((pp)->port_flags & USBSER_FL_OUT)) || \ 2690Sstevel@tonic-gate (!((minor) & OUTLINE) && ((pp)->port_flags & USBSER_FL_OUT))) 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate /* 2720Sstevel@tonic-gate * minor number manipulation 2730Sstevel@tonic-gate */ 2740Sstevel@tonic-gate enum { 2750Sstevel@tonic-gate MAXPORTS_PER_DEVICE_SHIFT = 4, 2760Sstevel@tonic-gate MAXPORTS_PER_DEVICE = (1 << MAXPORTS_PER_DEVICE_SHIFT), 2770Sstevel@tonic-gate MAXPORTS_PER_DEVICE_MASK = (MAXPORTS_PER_DEVICE - 1), 2780Sstevel@tonic-gate OUTLINE = (1 << (NBITSMINOR32 - 1)) 2790Sstevel@tonic-gate }; 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate #define USBSER_MAKEMINOR(instance, port, outline) \ 2820Sstevel@tonic-gate ((port) | ((instance) << MAXPORTS_PER_DEVICE_SHIFT) | (outline)) 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate #define USBSER_MINOR2INST(minor) \ 2850Sstevel@tonic-gate (((minor) & ~(OUTLINE | MAXPORTS_PER_DEVICE_MASK)) \ 2860Sstevel@tonic-gate >> MAXPORTS_PER_DEVICE_SHIFT) 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate #define USBSER_MINOR2PORT(minor) ((minor) & MAXPORTS_PER_DEVICE_MASK) 2890Sstevel@tonic-gate 2900Sstevel@tonic-gate /* 2910Sstevel@tonic-gate * various tunables 2920Sstevel@tonic-gate * 2930Sstevel@tonic-gate * timeouts are in seconds 2940Sstevel@tonic-gate */ 2950Sstevel@tonic-gate enum { 2960Sstevel@tonic-gate USBSER_TX_FIFO_DRAIN_TIMEOUT = 5, /* tx fifo drain timeout */ 2970Sstevel@tonic-gate USBSER_WQ_DRAIN_TIMEOUT = 2, /* wq drain timeout */ 2980Sstevel@tonic-gate USBSER_SUSPEND_TIMEOUT = 10 /* cpr suspend timeout */ 2990Sstevel@tonic-gate }; 3000Sstevel@tonic-gate 3010Sstevel@tonic-gate /* 3020Sstevel@tonic-gate * debug printing masks 3030Sstevel@tonic-gate */ 3040Sstevel@tonic-gate #define DPRINT_ATTACH 0x00000001 3050Sstevel@tonic-gate #define DPRINT_DETACH 0x00000002 3060Sstevel@tonic-gate #define DPRINT_OPEN 0x00000004 3070Sstevel@tonic-gate #define DPRINT_CLOSE 0x00000008 3080Sstevel@tonic-gate #define DPRINT_WQ 0x00000010 3090Sstevel@tonic-gate #define DPRINT_RQ 0x00000020 3100Sstevel@tonic-gate #define DPRINT_IOCTL 0x00000040 3110Sstevel@tonic-gate #define DPRINT_RX_CB 0x00000100 3120Sstevel@tonic-gate #define DPRINT_TX_CB 0x00000200 3130Sstevel@tonic-gate #define DPRINT_STATUS_CB 0x00000400 3140Sstevel@tonic-gate #define DPRINT_EVENTS 0x00001000 3150Sstevel@tonic-gate #define DPRINT_CPR 0x00002000 3160Sstevel@tonic-gate #define DPRINT_MASK_ALL 0xFFFFFFFF 3170Sstevel@tonic-gate 3180Sstevel@tonic-gate /* 3190Sstevel@tonic-gate * misc macros 3200Sstevel@tonic-gate */ 3210Sstevel@tonic-gate #define NELEM(a) (sizeof (a) / sizeof (*(a))) 3220Sstevel@tonic-gate 3230Sstevel@tonic-gate /* 3240Sstevel@tonic-gate * shortcuts to DSD operations 3250Sstevel@tonic-gate */ 3260Sstevel@tonic-gate #define USBSER_DS_ATTACH(usp, aip) usp->us_ds_ops->ds_attach(aip) 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate #define USBSER_DS_DETACH(usp) usp->us_ds_ops->ds_detach(usp->us_ds_hdl) 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate #define USBSER_DS_OPEN_PORT(usp, port_num) \ 3310Sstevel@tonic-gate usp->us_ds_ops->ds_open_port(usp->us_ds_hdl, port_num) 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate #define USBSER_DS_CLOSE_PORT(usp, port_num) \ 3340Sstevel@tonic-gate usp->us_ds_ops->ds_close_port(usp->us_ds_hdl, port_num) 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate #define USBSER_DS_REGISTER_CB(usp, port_num, cb) \ 3370Sstevel@tonic-gate usp->us_ds_ops->ds_register_cb(usp->us_ds_hdl, port_num, cb) 3380Sstevel@tonic-gate 3390Sstevel@tonic-gate #define USBSER_DS_UNREGISTER_CB(usp, port_num) \ 3400Sstevel@tonic-gate usp->us_ds_ops->ds_unregister_cb(usp->us_ds_hdl, port_num) 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate /* power management */ 3430Sstevel@tonic-gate #define USBSER_DS_USB_POWER(usp, comp, level, new_statep) \ 3440Sstevel@tonic-gate usp->us_ds_ops->ds_usb_power(usp->us_ds_hdl, comp, level, new_statep) 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate #define USBSER_DS_SUSPEND(usp) usp->us_ds_ops->ds_suspend(usp->us_ds_hdl) 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate #define USBSER_DS_RESUME(usp) usp->us_ds_ops->ds_resume(usp->us_ds_hdl) 3490Sstevel@tonic-gate 3500Sstevel@tonic-gate #define USBSER_DS_DISCONNECT(usp) usp->us_ds_ops->ds_disconnect(usp->us_ds_hdl) 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate #define USBSER_DS_RECONNECT(usp) usp->us_ds_ops->ds_reconnect(usp->us_ds_hdl) 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate /* standard UART operations */ 3550Sstevel@tonic-gate #define USBSER_DS_SET_PORT_PARAMS(pp, params) \ 3560Sstevel@tonic-gate pp->port_ds_ops->ds_set_port_params(pp->port_ds_hdl, pp->port_num, \ 3570Sstevel@tonic-gate params) 3580Sstevel@tonic-gate 3590Sstevel@tonic-gate #define USBSER_DS_SET_MODEM_CTL(pp, mask, val) \ 3600Sstevel@tonic-gate pp->port_ds_ops->ds_set_modem_ctl(pp->port_ds_hdl, pp->port_num, mask, \ 3610Sstevel@tonic-gate val) 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate #define USBSER_DS_GET_MODEM_CTL(pp, mask, valp) \ 3640Sstevel@tonic-gate pp->port_ds_ops->ds_get_modem_ctl(pp->port_ds_hdl, pp->port_num, \ 3650Sstevel@tonic-gate mask, valp) 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate #define USBSER_DS_BREAK_CTL(pp, val) \ 3680Sstevel@tonic-gate pp->port_ds_ops->ds_break_ctl(pp->port_ds_hdl, pp->port_num, val) 3690Sstevel@tonic-gate 3700Sstevel@tonic-gate #define USBSER_DS_LOOPBACK(pp, val) \ 3710Sstevel@tonic-gate pp->port_ds_ops->ds_loopback(pp->port_ds_hdl, pp->port_num, val) 3720Sstevel@tonic-gate 3730Sstevel@tonic-gate /* data xfer */ 3740Sstevel@tonic-gate #define USBSER_DS_TX(pp, mp) \ 3750Sstevel@tonic-gate pp->port_ds_ops->ds_tx(pp->port_ds_hdl, pp->port_num, mp) 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate #define USBSER_DS_RX(pp) \ 3780Sstevel@tonic-gate pp->port_ds_ops->ds_rx(pp->port_ds_hdl, pp->port_num) 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate #define USBSER_DS_STOP(pp, dir) \ 3810Sstevel@tonic-gate pp->port_ds_ops->ds_stop(pp->port_ds_hdl, pp->port_num, dir) 3820Sstevel@tonic-gate 3830Sstevel@tonic-gate #define USBSER_DS_START(pp, dir) \ 3840Sstevel@tonic-gate pp->port_ds_ops->ds_start(pp->port_ds_hdl, pp->port_num, dir) 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate /* fifos */ 3870Sstevel@tonic-gate #define USBSER_DS_FIFO_FLUSH(pp, mask) \ 3880Sstevel@tonic-gate pp->port_ds_ops->ds_fifo_flush(pp->port_ds_hdl, pp->port_num, mask) 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate #define USBSER_DS_FIFO_DRAIN(pp, tmout) \ 3910Sstevel@tonic-gate pp->port_ds_ops->ds_fifo_drain(pp->port_ds_hdl, pp->port_num, tmout) 3920Sstevel@tonic-gate 3930Sstevel@tonic-gate 3940Sstevel@tonic-gate /* check for supported operations */ 3950Sstevel@tonic-gate #define USBSER_DS_LOOPBACK_SUPPORTED(pp) (pp->port_ds_ops->ds_loopback != 0) 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate #ifdef __cplusplus 3980Sstevel@tonic-gate } 3990Sstevel@tonic-gate #endif 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate #endif /* _SYS_USB_USBSER_VAR_H */ 402