uhci.c revision a195726fa33097e56cf1c25c31feddb827e140f0
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * CDDL HEADER START
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Common Development and Distribution License, Version 1.0 only
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the "License"). You may not use this file except in compliance
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing permissions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL HEADER in each
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below this CDDL HEADER, with the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * fields enclosed by brackets "[]" replaced with your own identifying
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * information: Portions Copyright [yyyy] [name of copyright owner]
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * CDDL HEADER END
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Use is subject to license terms.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#pragma ident "%Z%%M% %I% %E% SMI"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Universal Host Controller Driver (UHCI)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The UHCI driver is a driver which interfaces to the Universal
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Serial Bus Architecture (USBA) and the Host Controller (HC). The interface to
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the Host Controller is defined by the Universal Host Controller Interface.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This file contains code for auto-configuration entry points and interrupt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Prototype Declarations for cb_ops and dev_ops
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic int uhci_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic int uhci_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic int uhci_open(dev_t *devp, int flags, int otyp, cred_t *credp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic int uhci_close(dev_t dev, int flag, int otyp, cred_t *credp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic int uhci_ioctl(dev_t dev, int cmd, intptr_t arg, int mode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic int uhci_reset(dev_info_t *dip, ddi_reset_cmd_t cmd);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic int uhci_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster 0, /* Refcnt */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster &mod_driverops, /* Type of module. This one is a driver */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "USB UHCI Controller Driver %I%", /* Name of the module. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterushort_t uhci_tree_bottom_nodes[NUM_FRAME_LST_ENTRIES];
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * tunable, delay during attach in seconds
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* function prototypes */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic void uhci_handle_intr_td_errors(uhci_state_t *uhcip, uhci_td_t *td,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster uhci_trans_wrapper_t *tw, uhci_pipe_private_t *pp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic void uhci_handle_one_xfer_completion(uhci_state_t *uhcip,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Initialize the soft state structures */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((error = ddi_soft_state_init(&uhci_statep, sizeof (uhci_state_t),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Install the loadable module */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Build the tree bottom shared by all instances
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster temp = kmem_zalloc(NUM_FRAME_LST_ENTRIES * 2, KM_SLEEP);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (i = 0; i < log_2(NUM_FRAME_LST_ENTRIES); i++) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (j = 0, k = 0; k < num_of_nodes; k++, j++) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster uhci_tree_bottom_nodes[j] = temp[k] + pow_2(i);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (k = 0; k < num_of_nodes; k++)
_fini(void)
int error;
if (error == 0) {
return (error);
int instance;
switch (cmd) {
case DDI_ATTACH:
case DDI_RESUME:
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
KM_SLEEP);
&actual, 0);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
#ifndef __sparc
goto fail;
goto fail;
return (DDI_SUCCESS);
fail:
return (DDI_FAILURE);
switch (cmd) {
case DDI_DETACH:
case DDI_SUSPEND:
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);
int instance;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
case DDI_INFO_DEVT2INSTANCE:
return (error);
return (USB_FAILURE);
return (USB_SUCCESS);
static uint_t
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_CLAIMED);
return (DDI_INTR_CLAIMED);
return (DDI_INTR_CLAIMED);
USB_SUCCESS) {
case USB_EP_ATTR_CONTROL:
case USB_EP_ATTR_INTR:
case USB_EP_ATTR_BULK:
case USB_EP_ATTR_ISOCH:
if (length) {
int rval;
case SETUP:
if (MaxPacketSize == 0) {
case DATA:
bytes_xfered = 0;
bytes_xfered++;
case STATUS:
return (USB_CR_OK);
if (!status) {
return (USB_CR_OK);
return (USB_CR_BITSTUFFING);
return (USB_CR_UNSPECIFIED_ERR);
return (USB_CR_STALL);
if (status) {
return (USB_CR_OK);
static dev_info_t *