xref: /onnv-gate/usr/src/uts/common/sys/usb/hcd/ehci/ehci_polled.h (revision 9095:ef4ae1685182)
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
57492SZhigang.Lu@Sun.COM  * Common Development and Distribution License (the "License").
67492SZhigang.Lu@Sun.COM  * 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*9095SZhigang.Lu@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_EHCI_POLLED_H
270Sstevel@tonic-gate #define	_SYS_USB_EHCI_POLLED_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifdef __cplusplus
310Sstevel@tonic-gate extern "C" {
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate 
340Sstevel@tonic-gate /*
350Sstevel@tonic-gate  * Enchanced Host Controller Driver (EHCI)
360Sstevel@tonic-gate  *
370Sstevel@tonic-gate  * The EHCI driver is a software driver which interfaces to the Universal
380Sstevel@tonic-gate  * Serial Bus layer (USBA) and the Host Controller (HC). The interface to
390Sstevel@tonic-gate  * the Host Controller is defined by the EHCI Host Controller Interface.
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * This header file describes the data structures required for the EHCI
420Sstevel@tonic-gate  * Driver to work in POLLED mode which will be  either OBP mode for Sparc
430Sstevel@tonic-gate  * architecture or PC PROM mode for X86 architecture
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #define	POLLED_RAW_BUF_SIZE	8
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * These two  flags are used to determine if this structure is already
500Sstevel@tonic-gate  * in use.
510Sstevel@tonic-gate  */
520Sstevel@tonic-gate #define	POLLED_INPUT_MODE		0x01
53*9095SZhigang.Lu@Sun.COM #define	POLLED_OUTPUT_MODE		0x10
540Sstevel@tonic-gate 
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate  * These two flags are used to determine if this structure is already in
570Sstevel@tonic-gate  * use. We should only save off the controller state information once,
580Sstevel@tonic-gate  * restore it once.  These flags are used for the ehci_polled_flags below.
590Sstevel@tonic-gate  */
600Sstevel@tonic-gate #define	POLLED_INPUT_MODE_INUSE		0x04
61*9095SZhigang.Lu@Sun.COM #define	POLLED_OUTPUT_MODE_INUSE	0x40
620Sstevel@tonic-gate #define	MAX_NUM_FOR_KEYBOARD		0x8
630Sstevel@tonic-gate /*
640Sstevel@tonic-gate  * State structure for the POLLED switch off
650Sstevel@tonic-gate  */
660Sstevel@tonic-gate typedef struct ehci_polled {
670Sstevel@tonic-gate 	/*
680Sstevel@tonic-gate 	 * Pointer to the ehcip structure for the device that is to  be
690Sstevel@tonic-gate 	 * used as input in polled mode.
700Sstevel@tonic-gate 	 */
710Sstevel@tonic-gate 	ehci_state_t	*ehci_polled_ehcip;
720Sstevel@tonic-gate 
730Sstevel@tonic-gate 	/*
740Sstevel@tonic-gate 	 * Pipe handle for the pipe that is to be used as input device
750Sstevel@tonic-gate 	 * in POLLED mode.
760Sstevel@tonic-gate 	 */
770Sstevel@tonic-gate 	usba_pipe_handle_data_t  *ehci_polled_input_pipe_handle;
780Sstevel@tonic-gate 
790Sstevel@tonic-gate 	/* Dummy endpoint descriptor */
800Sstevel@tonic-gate 	ehci_qh_t	*ehci_polled_dummy_qh;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 	/* Interrupt Endpoint descriptor */
830Sstevel@tonic-gate 	ehci_qh_t	*ehci_polled_qh;	/* Interrupt endpoint */
840Sstevel@tonic-gate 
850Sstevel@tonic-gate 	/*
860Sstevel@tonic-gate 	 * The buffer that the usb scancodes are copied into.
870Sstevel@tonic-gate 	 */
880Sstevel@tonic-gate 	uchar_t		*ehci_polled_buf;
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 	/*
910Sstevel@tonic-gate 	 * This flag is used to determine if the state of the controller
920Sstevel@tonic-gate 	 * has already been saved (enter) or doesn't need to be restored
930Sstevel@tonic-gate 	 * yet (exit).
940Sstevel@tonic-gate 	 */
950Sstevel@tonic-gate 	uint_t		ehci_polled_flags;
960Sstevel@tonic-gate 
970Sstevel@tonic-gate 	/*
980Sstevel@tonic-gate 	 * List of QTD inserted into polled mode periodic schedule list.
990Sstevel@tonic-gate 	 */
1000Sstevel@tonic-gate 	ehci_qtd_t	*ehci_polled_active_intr_qtd_list;
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 	/*
1030Sstevel@tonic-gate 	 * ehci_hcdi_polled_input_enter() may be called
1040Sstevel@tonic-gate 	 * multiple times before the ehci_hcdi_polled_input_exit() is called.
1050Sstevel@tonic-gate 	 * For example, the system may:
1060Sstevel@tonic-gate 	 *	- go down to kmdb (ehci_hcdi_polled_input_enter())
1070Sstevel@tonic-gate 	 *	- down to the ok prompt, $q (ehci_hcdi_polled_input_enter())
1080Sstevel@tonic-gate 	 *	- back to kmdb, "go" (ehci_hcdi_polled_input_exit())
1090Sstevel@tonic-gate 	 *	- back to the OS, :c at kmdb (ehci_hcdi_polled_input_exit())
1100Sstevel@tonic-gate 	 *
1110Sstevel@tonic-gate 	 * polled_entry keeps track of how  many times
1120Sstevel@tonic-gate 	 * ehci_polled_input_enter/ehci_polled_input_exit have been
1130Sstevel@tonic-gate 	 * called so that the host controller isn't switched back to OS mode
1140Sstevel@tonic-gate 	 * prematurely.
1150Sstevel@tonic-gate 	 */
1160Sstevel@tonic-gate 	uint_t		ehci_polled_entry;
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate 	/*
1190Sstevel@tonic-gate 	 * Save the pointer usb device structure and the endpoint number
1200Sstevel@tonic-gate 	 * during the polled initilization.
1210Sstevel@tonic-gate 	 */
1220Sstevel@tonic-gate 	usba_device_t	*ehci_polled_usb_dev;	/* USB device */
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate 	uint8_t		ehci_polled_ep_addr;
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate 	boolean_t	ehci_polled_no_sync_flag; /* For schizo bug */
1270Sstevel@tonic-gate } ehci_polled_t;
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
1300Sstevel@tonic-gate 	ehci_polled_t::ehci_polled_flags))
1310Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ehci_polled_t::ehci_polled_ehcip))
1320Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
1330Sstevel@tonic-gate 	ehci_polled_t::ehci_polled_entry))
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate /*
1360Sstevel@tonic-gate  * Time waits for the different EHCI specific polled operations.
1370Sstevel@tonic-gate  * These timeout values are specified in terms of microseconds.
1380Sstevel@tonic-gate  */
1390Sstevel@tonic-gate #define	EHCI_POLLED_TIMEWAIT	2000	/* General polled time wait */
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate #ifdef __cplusplus
1430Sstevel@tonic-gate }
1440Sstevel@tonic-gate #endif
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate #endif	/* _SYS_USB_EHCI_POLLED_H */
147