190f05028Syq /* 290f05028Syq * CDDL HEADER START 390f05028Syq * 490f05028Syq * The contents of this file are subject to the terms of the 590f05028Syq * Common Development and Distribution License (the "License"). 690f05028Syq * You may not use this file except in compliance with the License. 790f05028Syq * 890f05028Syq * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 990f05028Syq * or http://www.opensolaris.org/os/licensing. 1090f05028Syq * See the License for the specific language governing permissions 1190f05028Syq * and limitations under the License. 1290f05028Syq * 1390f05028Syq * When distributing Covered Code, include this CDDL HEADER in each 1490f05028Syq * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1590f05028Syq * If applicable, add the following below this CDDL HEADER, with the 1690f05028Syq * fields enclosed by brackets "[]" replaced with your own identifying 1790f05028Syq * information: Portions Copyright [yyyy] [name of copyright owner] 1890f05028Syq * 1990f05028Syq * CDDL HEADER END 2090f05028Syq */ 2190f05028Syq /* 22*d29f5a71Szhigang lu - Sun Microsystems - Beijing China * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2390f05028Syq * Use is subject to license terms. 2490f05028Syq */ 2590f05028Syq 2690f05028Syq #ifndef _SYS_USB_USBSACM_H 2790f05028Syq #define _SYS_USB_USBSACM_H 2890f05028Syq 2990f05028Syq 3090f05028Syq #include <sys/types.h> 3190f05028Syq #include <sys/dditypes.h> 3290f05028Syq #include <sys/note.h> 3390f05028Syq 3490f05028Syq #include <sys/usb/clients/usbser/usbser_dsdi.h> 3590f05028Syq 3690f05028Syq #ifdef __cplusplus 3790f05028Syq extern "C" { 3890f05028Syq #endif 3990f05028Syq 4090f05028Syq 4190f05028Syq typedef struct usbsacm_port usbsacm_port_t; 4290f05028Syq typedef struct usbsacm_state usbsacm_state_t; 4390f05028Syq 4490f05028Syq 4590f05028Syq /* 4690f05028Syq * PM support 4790f05028Syq */ 4890f05028Syq typedef struct usbsacm_power { 4990f05028Syq uint8_t pm_wakeup_enabled; /* remote wakeup enabled */ 5090f05028Syq uint8_t pm_pwr_states; /* bit mask of power states */ 5190f05028Syq boolean_t pm_raise_power; /* driver is about to raise power */ 5290f05028Syq uint8_t pm_cur_power; /* current power level */ 5390f05028Syq uint_t pm_busy_cnt; /* number of set_busy requests */ 5490f05028Syq } usbsacm_pm_t; 5590f05028Syq 5690f05028Syq 5790f05028Syq /* 5890f05028Syq * per bulk in/out structure 5990f05028Syq */ 6090f05028Syq struct usbsacm_port { 6190f05028Syq kmutex_t acm_port_mutex; /* structure lock */ 6290f05028Syq usbsacm_state_t *acm_device; /* back pointer */ 6390f05028Syq usb_pipe_handle_t acm_bulkin_ph; /* in pipe hdl */ 6490f05028Syq int acm_bulkin_state; /* in pipe state */ 6590f05028Syq usb_pipe_handle_t acm_bulkout_ph; /* out pipe hdl */ 6690f05028Syq int acm_bulkout_state; /* out pipe state */ 6790f05028Syq usb_pipe_handle_t acm_intr_ph; /* intr pipe hdl */ 6890f05028Syq int acm_intr_state; /* intr pipe state */ 6990f05028Syq usb_ep_descr_t acm_intr_ep_descr; /* ep descriptor */ 7090f05028Syq int acm_ctrl_if_no; /* control interface */ 7190f05028Syq int acm_data_if_no; /* data interface */ 7290f05028Syq int acm_data_port_no; /* which data port */ 7390f05028Syq ds_cb_t acm_cb; /* DSD callbacks */ 7490f05028Syq mblk_t *acm_rx_mp; /* rx data */ 7590f05028Syq mblk_t *acm_tx_mp; /* tx data */ 7690f05028Syq kcondvar_t acm_tx_cv; /* tx completion */ 7790f05028Syq uint8_t acm_mctlout; /* controls out */ 7890f05028Syq uint8_t acm_mctlin; /* controls in */ 7990f05028Syq int acm_cap; /* port capabilities */ 8090f05028Syq usb_cdc_line_coding_t acm_line_coding; /* port line coding */ 8190f05028Syq int acm_port_state; /* port state */ 8290f05028Syq size_t acm_bulkin_size; /* bulkin xfer size */ 8390f05028Syq }; 8490f05028Syq 8590f05028Syq _NOTE(MUTEX_PROTECTS_DATA(usbsacm_port::acm_port_mutex, usbsacm_port)) 8690f05028Syq _NOTE(DATA_READABLE_WITHOUT_LOCK(usbsacm_port::{ 8790f05028Syq acm_device 8890f05028Syq acm_cb.cb_rx 8990f05028Syq acm_cb.cb_tx 9090f05028Syq acm_cb.cb_arg 9190f05028Syq acm_bulkin_ph 9290f05028Syq acm_bulkout_ph 9390f05028Syq acm_intr_ph 9490f05028Syq acm_ctrl_if_no 9590f05028Syq acm_data_if_no 9690f05028Syq acm_data_port_no 9790f05028Syq acm_port_state 9890f05028Syq })) 9990f05028Syq 10090f05028Syq struct usbsacm_state { 10190f05028Syq kmutex_t acm_mutex; /* structure lock */ 10290f05028Syq dev_info_t *acm_dip; /* device info */ 10390f05028Syq usb_client_dev_data_t *acm_dev_data; /* registration data */ 10490f05028Syq usb_event_t *acm_usb_events; /* usb events */ 10590f05028Syq usb_pipe_handle_t acm_def_ph; /* default pipe hdl */ 10690f05028Syq usb_log_handle_t acm_lh; /* USBA log handle */ 10790f05028Syq int acm_dev_state; /* USB device state */ 10890f05028Syq size_t acm_xfer_sz; /* bulk xfer size */ 10990f05028Syq boolean_t acm_compatibility; /* if conform to spec */ 11090f05028Syq usbsacm_port_t *acm_ports; /* per port structs */ 11190f05028Syq int acm_port_cnt; /* port number */ 11290f05028Syq usbsacm_pm_t *acm_pm; /* PM support */ 11390f05028Syq }; 11490f05028Syq 11590f05028Syq _NOTE(MUTEX_PROTECTS_DATA(usbsacm_state::acm_mutex, usbsacm_state)) 11690f05028Syq _NOTE(DATA_READABLE_WITHOUT_LOCK(usbsacm_state::{ 11790f05028Syq acm_dip 11890f05028Syq acm_dev_data 11990f05028Syq acm_usb_events 12090f05028Syq acm_def_ph 12190f05028Syq acm_lh 12290f05028Syq acm_dev_state 12390f05028Syq acm_xfer_sz 12490f05028Syq acm_compatibility 12590f05028Syq acm_ports 12690f05028Syq acm_port_cnt 12790f05028Syq acm_pm 12890f05028Syq })) 12990f05028Syq 13090f05028Syq /* port state */ 13190f05028Syq enum { 13290f05028Syq USBSACM_PORT_CLOSED, /* port is closed */ 13390f05028Syq USBSACM_PORT_OPEN, /* port is open */ 13490f05028Syq USBSACM_PORT_CLOSING 13590f05028Syq }; 13690f05028Syq 13790f05028Syq /* pipe state */ 13890f05028Syq enum { 13990f05028Syq USBSACM_PIPE_CLOSED, /* pipe is closed */ 14090f05028Syq USBSACM_PIPE_IDLE, /* open but no requests */ 14190f05028Syq USBSACM_PIPE_BUSY, /* servicing request */ 14290f05028Syq USBSACM_PIPE_CLOSING /* pipe is closing */ 14390f05028Syq }; 14490f05028Syq 14590f05028Syq /* various tunables */ 14690f05028Syq enum { 14790f05028Syq USBSACM_BULKOUT_TIMEOUT = 15, /* bulkout timeout */ 14890f05028Syq USBSACM_BULKIN_TIMEOUT = 0 /* bulkin timeout */ 14990f05028Syq }; 15090f05028Syq 15190f05028Syq /* hardware definitions */ 15290f05028Syq enum { 15390f05028Syq USBSACM_REQ_OUT = USB_DEV_REQ_TYPE_CLASS| USB_DEV_REQ_HOST_TO_DEV, 15490f05028Syq USBSACM_REQ_IN = USB_DEV_REQ_TYPE_CLASS | USB_DEV_REQ_DEV_TO_HOST, 15590f05028Syq USBSACM_REQ_WRITE_IF = USBSACM_REQ_OUT | USB_DEV_REQ_RCPT_IF, 15690f05028Syq USBSACM_REQ_READ_IF = USBSACM_REQ_IN | USB_DEV_REQ_RCPT_IF 15790f05028Syq }; 15890f05028Syq 15990f05028Syq #define PRINT_MASK_ATTA 0x00000001 16090f05028Syq #define PRINT_MASK_CLOSE 0x00000002 16190f05028Syq #define PRINT_MASK_OPEN 0x00000004 16290f05028Syq #define PRINT_MASK_EVENTS 0x00000008 16390f05028Syq #define PRINT_MASK_PM 0x00000010 16490f05028Syq #define PRINT_MASK_CB 0x00000020 16590f05028Syq #define PRINT_MASK_ALL 0xFFFFFFFF 16690f05028Syq 16790f05028Syq 16890f05028Syq #define NELEM(a) (sizeof (a) / sizeof (*(a))) 16990f05028Syq 17090f05028Syq 17190f05028Syq #ifdef __cplusplus 17290f05028Syq } 17390f05028Syq #endif 17490f05028Syq 17590f05028Syq #endif /* _SYS_USB_USBSACM_H */ 176