xref: /onnv-gate/usr/src/uts/common/sys/usb/hcd/openhci/ohci_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_OHCI_POLLED_H
270Sstevel@tonic-gate #define	_SYS_USB_OHCI_POLLED_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef __cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * Open Host Controller Driver (OHCI)
350Sstevel@tonic-gate  *
360Sstevel@tonic-gate  * The USB Open Host Controller driver is a software driver which interfaces
370Sstevel@tonic-gate  * to the Universal Serial Bus layer (USBA) and the USB Open Host Controller.
380Sstevel@tonic-gate  * The interface to USB Open Host Controller is defined by the OpenHCI  Host
390Sstevel@tonic-gate  * Controller Interface.
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * This header file describes the data structures required for the USB Open
420Sstevel@tonic-gate  * Host Controller Driver to work in POLLED mode which will be either OBP
430Sstevel@tonic-gate  * mode for Sparc 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 ohci_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 
630Sstevel@tonic-gate /*
640Sstevel@tonic-gate  * For ohci bandwidth of low speed interrupt devices limits,
650Sstevel@tonic-gate  * one host controller can support 6 keyboards only.
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate #define	MAX_NUM_FOR_KEYBOARD		0x6
680Sstevel@tonic-gate /*
690Sstevel@tonic-gate  * State structure for the POLLED switch off
700Sstevel@tonic-gate  */
710Sstevel@tonic-gate typedef struct ohci_polled {
720Sstevel@tonic-gate 	/*
730Sstevel@tonic-gate 	 * Pointer to the ohcip structure for the device that is to  be
740Sstevel@tonic-gate 	 * used as input in polled mode.
750Sstevel@tonic-gate 	 */
760Sstevel@tonic-gate 	ohci_state_t	*ohci_polled_ohcip;
770Sstevel@tonic-gate 
780Sstevel@tonic-gate 	/*
790Sstevel@tonic-gate 	 * Pipe handle for the pipe that is to be used as input device
800Sstevel@tonic-gate 	 * in POLLED mode.
810Sstevel@tonic-gate 	 */
820Sstevel@tonic-gate 	usba_pipe_handle_data_t  *ohci_polled_input_pipe_handle;
830Sstevel@tonic-gate 
840Sstevel@tonic-gate 	/* Dummy endpoint descriptor */
850Sstevel@tonic-gate 	ohci_ed_t	*ohci_polled_dummy_ed;
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	/* Interrupt Endpoint descriptor */
880Sstevel@tonic-gate 	ohci_ed_t	*ohci_polled_ed;	/* Interrupt endpoint */
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 	/*
910Sstevel@tonic-gate 	 * The buffer that the usb scancodes are copied into.
920Sstevel@tonic-gate 	 */
930Sstevel@tonic-gate 	uchar_t		*ohci_polled_buf;
940Sstevel@tonic-gate 
950Sstevel@tonic-gate 	/*
960Sstevel@tonic-gate 	 * This flag is used to determine if the state of the controller
970Sstevel@tonic-gate 	 * has already been saved (enter) or doesn't need to be restored
980Sstevel@tonic-gate 	 * yet (exit).
990Sstevel@tonic-gate 	 */
1000Sstevel@tonic-gate 	uint_t		ohci_polled_flags;
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 	/*
1030Sstevel@tonic-gate 	 * The read or write routines may take TD's of the done head that
1040Sstevel@tonic-gate 	 * are not intended for them.
1050Sstevel@tonic-gate 	 */
1060Sstevel@tonic-gate 	ohci_td_t	*ohci_polled_input_done_head;
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate 	/*
1090Sstevel@tonic-gate 	 * This is the tail for the above ohci_polled_input_done_head;
1100Sstevel@tonic-gate 	 */
1110Sstevel@tonic-gate 	ohci_td_t	*ohci_polled_input_done_tail;
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate 	/*
1140Sstevel@tonic-gate 	 * ohci_hcdi_polled_input_enter() may be called
1150Sstevel@tonic-gate 	 * multiple times before the ohci_hcdi_polled_input_exit() is called.
1160Sstevel@tonic-gate 	 * For example, the system may:
1170Sstevel@tonic-gate 	 *	- go down to kmdb (ohci_hcdi_polled_input_enter())
1180Sstevel@tonic-gate 	 *	- down to the ok prompt, $q (ohci_hcdi_polled_input_enter())
1190Sstevel@tonic-gate 	 *	- back to kmdb, "go" (ohci_hcdi_polled_input_exit())
1200Sstevel@tonic-gate 	 *	- back to the OS, :c at kmdb (ohci_hcdi_polled_input_exit())
1210Sstevel@tonic-gate 	 *
1220Sstevel@tonic-gate 	 * polled_entry keeps track of how  many times
1230Sstevel@tonic-gate 	 * ohci_polled_input_enter/ohci_polled_input_exit have been
1240Sstevel@tonic-gate 	 * called so that the host controller isn't switched back to OS mode
1250Sstevel@tonic-gate 	 * prematurely.
1260Sstevel@tonic-gate 	 */
1270Sstevel@tonic-gate 	uint_t		ohci_polled_entry;
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate 	/*
1300Sstevel@tonic-gate 	 * Save the pointer usb device structure and the endpoint number
1310Sstevel@tonic-gate 	 * during the polled initilization.
1320Sstevel@tonic-gate 	 */
1330Sstevel@tonic-gate 	usba_device_t	*ohci_polled_usb_dev;	/* USB device */
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate 	uint8_t		ohci_polled_ep_addr;
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate 	boolean_t	ohci_polled_no_sync_flag; /* For schizo bug */
1380Sstevel@tonic-gate } ohci_polled_t;
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
1410Sstevel@tonic-gate 	ohci_polled_t::ohci_polled_flags))
1420Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_polled_t::ohci_polled_ohcip))
1430Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
1440Sstevel@tonic-gate 	ohci_polled_t::ohci_polled_entry))
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate #ifdef __cplusplus
1480Sstevel@tonic-gate }
1490Sstevel@tonic-gate #endif
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate #endif	/* _SYS_USB_OHCI_POLLED_H */
152