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
5*7391SBarry.Harding@Sun.COM * Common Development and Distribution License (the "License").
6*7391SBarry.Harding@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*7391SBarry.Harding@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate /*
270Sstevel@tonic-gate * hci1394_isr.c
280Sstevel@tonic-gate * Contains the core interrupt handling logic for the hci1394 driver.
290Sstevel@tonic-gate * It also contains the routine which sets up the initial interrupt
300Sstevel@tonic-gate * mask during HW init.
310Sstevel@tonic-gate */
320Sstevel@tonic-gate
330Sstevel@tonic-gate #include <sys/conf.h>
340Sstevel@tonic-gate #include <sys/ddi.h>
350Sstevel@tonic-gate #include <sys/modctl.h>
360Sstevel@tonic-gate #include <sys/stat.h>
370Sstevel@tonic-gate #include <sys/sunddi.h>
380Sstevel@tonic-gate #include <sys/cmn_err.h>
390Sstevel@tonic-gate
400Sstevel@tonic-gate #include <sys/1394/h1394.h>
410Sstevel@tonic-gate #include <sys/1394/adapters/hci1394.h>
420Sstevel@tonic-gate
430Sstevel@tonic-gate
440Sstevel@tonic-gate static uint_t hci1394_isr(caddr_t parm);
450Sstevel@tonic-gate static void hci1394_isr_bus_reset(hci1394_state_t *soft_state);
460Sstevel@tonic-gate static void hci1394_isr_self_id(hci1394_state_t *soft_state);
470Sstevel@tonic-gate static void hci1394_isr_isoch_ir(hci1394_state_t *soft_state);
480Sstevel@tonic-gate static void hci1394_isr_isoch_it(hci1394_state_t *soft_state);
490Sstevel@tonic-gate static void hci1394_isr_atreq_complete(hci1394_state_t *soft_state);
500Sstevel@tonic-gate static void hci1394_isr_arresp(hci1394_state_t *soft_state);
510Sstevel@tonic-gate static void hci1394_isr_arreq(hci1394_state_t *soft_state);
520Sstevel@tonic-gate static void hci1394_isr_atresp_complete(hci1394_state_t *soft_state);
530Sstevel@tonic-gate
540Sstevel@tonic-gate
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate * hci1394_isr_init()
570Sstevel@tonic-gate * Get the iblock_cookie, make sure we are not using a high level interrupt,
580Sstevel@tonic-gate * register our interrupt service routine.
590Sstevel@tonic-gate */
600Sstevel@tonic-gate int
hci1394_isr_init(hci1394_state_t * soft_state)610Sstevel@tonic-gate hci1394_isr_init(hci1394_state_t *soft_state)
620Sstevel@tonic-gate {
630Sstevel@tonic-gate int status;
640Sstevel@tonic-gate
650Sstevel@tonic-gate
660Sstevel@tonic-gate ASSERT(soft_state != NULL);
670Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_init_enter, HCI1394_TNF_HAL_STACK, "");
680Sstevel@tonic-gate
690Sstevel@tonic-gate /* This driver does not support running at a high level interrupt */
700Sstevel@tonic-gate status = ddi_intr_hilevel(soft_state->drvinfo.di_dip, 0);
710Sstevel@tonic-gate if (status != 0) {
720Sstevel@tonic-gate TNF_PROBE_1(hci1394_isr_init_hli_fail,
730Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "", tnf_string, errmsg,
740Sstevel@tonic-gate "High Level interrupts not supported");
750Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_init_exit,
760Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
770Sstevel@tonic-gate return (DDI_FAILURE);
780Sstevel@tonic-gate }
790Sstevel@tonic-gate
800Sstevel@tonic-gate /* There should only be 1 1394 interrupt for an OpenHCI adapter */
810Sstevel@tonic-gate status = ddi_get_iblock_cookie(soft_state->drvinfo.di_dip, 0,
820Sstevel@tonic-gate &soft_state->drvinfo.di_iblock_cookie);
830Sstevel@tonic-gate if (status != DDI_SUCCESS) {
840Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_init_gic_fail,
850Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "");
860Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_init_exit,
870Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
880Sstevel@tonic-gate return (DDI_FAILURE);
890Sstevel@tonic-gate }
900Sstevel@tonic-gate
910Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_init_exit, HCI1394_TNF_HAL_STACK, "");
920Sstevel@tonic-gate
930Sstevel@tonic-gate return (DDI_SUCCESS);
940Sstevel@tonic-gate }
950Sstevel@tonic-gate
960Sstevel@tonic-gate
970Sstevel@tonic-gate /*
980Sstevel@tonic-gate * hci1394_isr_fini()
990Sstevel@tonic-gate * un-register our interrupt service routine.
1000Sstevel@tonic-gate */
1010Sstevel@tonic-gate /* ARGSUSED */
1020Sstevel@tonic-gate void
hci1394_isr_fini(hci1394_state_t * soft_state)1030Sstevel@tonic-gate hci1394_isr_fini(hci1394_state_t *soft_state)
1040Sstevel@tonic-gate {
1050Sstevel@tonic-gate ASSERT(soft_state != NULL);
1060Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_fini_enter, HCI1394_TNF_HAL_STACK, "");
1070Sstevel@tonic-gate
1080Sstevel@tonic-gate /* nothing to do right now */
1090Sstevel@tonic-gate
1100Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_fini_exit, HCI1394_TNF_HAL_STACK, "");
1110Sstevel@tonic-gate }
1120Sstevel@tonic-gate
1130Sstevel@tonic-gate
1140Sstevel@tonic-gate /*
1150Sstevel@tonic-gate * hci1394_isr_handler_init()
1160Sstevel@tonic-gate * register our interrupt service routine.
1170Sstevel@tonic-gate */
1180Sstevel@tonic-gate int
hci1394_isr_handler_init(hci1394_state_t * soft_state)1190Sstevel@tonic-gate hci1394_isr_handler_init(hci1394_state_t *soft_state)
1200Sstevel@tonic-gate {
1210Sstevel@tonic-gate int status;
1220Sstevel@tonic-gate
1230Sstevel@tonic-gate ASSERT(soft_state != NULL);
1240Sstevel@tonic-gate
1250Sstevel@tonic-gate /* Initialize interrupt handler */
1260Sstevel@tonic-gate status = ddi_add_intr(soft_state->drvinfo.di_dip, 0, NULL, NULL,
1270Sstevel@tonic-gate hci1394_isr, (caddr_t)soft_state);
1280Sstevel@tonic-gate if (status != DDI_SUCCESS) {
1290Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_handler_init_fail,
1300Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "");
1310Sstevel@tonic-gate return (DDI_FAILURE);
1320Sstevel@tonic-gate }
1330Sstevel@tonic-gate
1340Sstevel@tonic-gate return (DDI_SUCCESS);
1350Sstevel@tonic-gate }
1360Sstevel@tonic-gate
1370Sstevel@tonic-gate
1380Sstevel@tonic-gate /*
1390Sstevel@tonic-gate * hci1394_isr_handler_fini()
1400Sstevel@tonic-gate * un-register our interrupt service routine.
1410Sstevel@tonic-gate */
1420Sstevel@tonic-gate void
hci1394_isr_handler_fini(hci1394_state_t * soft_state)1430Sstevel@tonic-gate hci1394_isr_handler_fini(hci1394_state_t *soft_state)
1440Sstevel@tonic-gate {
1450Sstevel@tonic-gate ASSERT(soft_state != NULL);
1460Sstevel@tonic-gate
1470Sstevel@tonic-gate /* Remove interrupt handler */
1480Sstevel@tonic-gate ddi_remove_intr(soft_state->drvinfo.di_dip, 0,
1490Sstevel@tonic-gate soft_state->drvinfo.di_iblock_cookie);
1500Sstevel@tonic-gate }
1510Sstevel@tonic-gate
1520Sstevel@tonic-gate
1530Sstevel@tonic-gate /*
1540Sstevel@tonic-gate * hci1394_isr_mask_setup()
1550Sstevel@tonic-gate * Setup the initial interrupt mask for OpenHCI. These are the interrupts
1560Sstevel@tonic-gate * that our interrupt handler is expected to handle.
1570Sstevel@tonic-gate */
1580Sstevel@tonic-gate void
hci1394_isr_mask_setup(hci1394_state_t * soft_state)1590Sstevel@tonic-gate hci1394_isr_mask_setup(hci1394_state_t *soft_state)
1600Sstevel@tonic-gate {
1610Sstevel@tonic-gate ASSERT(soft_state != NULL);
1620Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_mask_setup_enter, HCI1394_TNF_HAL_STACK,
1630Sstevel@tonic-gate "");
1640Sstevel@tonic-gate
1650Sstevel@tonic-gate /* start off with all interrupts cleared/disabled */
1660Sstevel@tonic-gate hci1394_ohci_ir_intr_disable(soft_state->ohci, 0xFFFFFFFF);
1670Sstevel@tonic-gate hci1394_ohci_ir_intr_clear(soft_state->ohci, 0xFFFFFFFF);
1680Sstevel@tonic-gate hci1394_ohci_it_intr_disable(soft_state->ohci, 0xFFFFFFFF);
1690Sstevel@tonic-gate hci1394_ohci_it_intr_clear(soft_state->ohci, 0xFFFFFFFF);
1700Sstevel@tonic-gate hci1394_ohci_intr_disable(soft_state->ohci, 0xFFFFFFFF);
1710Sstevel@tonic-gate hci1394_ohci_intr_clear(soft_state->ohci, 0xFFFFFFFF);
1720Sstevel@tonic-gate
1730Sstevel@tonic-gate /* Setup Interrupt Mask Register */
1740Sstevel@tonic-gate hci1394_ohci_intr_enable(soft_state->ohci,
1750Sstevel@tonic-gate (OHCI_INTR_UNRECOVERABLE_ERR | OHCI_INTR_CYC_TOO_LONG |
1760Sstevel@tonic-gate OHCI_INTR_BUS_RESET | OHCI_INTR_SELFID_CMPLT |
1770Sstevel@tonic-gate OHCI_INTR_REQ_TX_CMPLT | OHCI_INTR_RESP_TX_CMPLT |
1780Sstevel@tonic-gate OHCI_INTR_RQPKT | OHCI_INTR_RSPKT | OHCI_INTR_ISOCH_TX |
1790Sstevel@tonic-gate OHCI_INTR_ISOCH_RX | OHCI_INTR_POST_WR_ERR | OHCI_INTR_PHY |
1800Sstevel@tonic-gate OHCI_INTR_LOCK_RESP_ERR));
1810Sstevel@tonic-gate
1820Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_mask_setup_exit, HCI1394_TNF_HAL_STACK,
1830Sstevel@tonic-gate "");
1840Sstevel@tonic-gate }
1850Sstevel@tonic-gate
1860Sstevel@tonic-gate
1870Sstevel@tonic-gate /*
1880Sstevel@tonic-gate * hci1394_isr()
1890Sstevel@tonic-gate * Core interrupt handler. Every interrupt enabled in
1900Sstevel@tonic-gate * hci1394_isr_mask_setup() should be covered here. There may be other
1910Sstevel@tonic-gate * interrupts supported in here even if they are not initially enabled
1920Sstevel@tonic-gate * (like OHCI_INTR_CYC_64_SECS) since they may be enabled later (i.e. due to
1930Sstevel@tonic-gate * CSR register write)
1940Sstevel@tonic-gate */
1950Sstevel@tonic-gate static uint_t
hci1394_isr(caddr_t parm)1960Sstevel@tonic-gate hci1394_isr(caddr_t parm)
1970Sstevel@tonic-gate {
1980Sstevel@tonic-gate hci1394_state_t *soft_state;
1990Sstevel@tonic-gate h1394_posted_wr_err_t posted_wr_err;
2000Sstevel@tonic-gate uint32_t interrupt_event;
2010Sstevel@tonic-gate uint_t status;
2020Sstevel@tonic-gate
2030Sstevel@tonic-gate
2040Sstevel@tonic-gate status = DDI_INTR_UNCLAIMED;
2050Sstevel@tonic-gate soft_state = (hci1394_state_t *)parm;
2060Sstevel@tonic-gate
2070Sstevel@tonic-gate ASSERT(soft_state != NULL);
2080Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_enter, HCI1394_TNF_HAL_STACK, "");
2090Sstevel@tonic-gate
210*7391SBarry.Harding@Sun.COM if (hci1394_state(&soft_state->drvinfo) == HCI1394_SHUTDOWN)
211*7391SBarry.Harding@Sun.COM return (DDI_INTR_UNCLAIMED);
212*7391SBarry.Harding@Sun.COM
2130Sstevel@tonic-gate /*
2140Sstevel@tonic-gate * Get all of the enabled 1394 interrupts which are currently
2150Sstevel@tonic-gate * asserted.
2160Sstevel@tonic-gate */
2170Sstevel@tonic-gate interrupt_event = hci1394_ohci_intr_asserted(soft_state->ohci);
2180Sstevel@tonic-gate do {
2190Sstevel@tonic-gate /* handle the asserted interrupts */
2200Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_BUS_RESET) {
2210Sstevel@tonic-gate hci1394_isr_bus_reset(soft_state);
2220Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2230Sstevel@tonic-gate }
2240Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_SELFID_CMPLT) {
2250Sstevel@tonic-gate hci1394_isr_self_id(soft_state);
2260Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2270Sstevel@tonic-gate }
2280Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_ISOCH_TX) {
2290Sstevel@tonic-gate hci1394_isr_isoch_it(soft_state);
2300Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2310Sstevel@tonic-gate }
2320Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_ISOCH_RX) {
2330Sstevel@tonic-gate hci1394_isr_isoch_ir(soft_state);
2340Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2350Sstevel@tonic-gate }
2360Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_REQ_TX_CMPLT) {
2370Sstevel@tonic-gate hci1394_isr_atreq_complete(soft_state);
2380Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2390Sstevel@tonic-gate }
2400Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_RSPKT) {
2410Sstevel@tonic-gate hci1394_isr_arresp(soft_state);
2420Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2430Sstevel@tonic-gate }
2440Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_RQPKT) {
2450Sstevel@tonic-gate hci1394_isr_arreq(soft_state);
2460Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2470Sstevel@tonic-gate }
2480Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_RESP_TX_CMPLT) {
2490Sstevel@tonic-gate hci1394_isr_atresp_complete(soft_state);
2500Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2510Sstevel@tonic-gate }
2520Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_CYC_64_SECS) {
2530Sstevel@tonic-gate hci1394_ohci_isr_cycle64seconds(soft_state->ohci);
2540Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2550Sstevel@tonic-gate }
2560Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_UNRECOVERABLE_ERR) {
2570Sstevel@tonic-gate h1394_error_detected(soft_state->drvinfo.di_sl_private,
2580Sstevel@tonic-gate H1394_SELF_INITIATED_SHUTDOWN, NULL);
2590Sstevel@tonic-gate cmn_err(CE_WARN, "hci1394(%d): driver shutdown: "
2600Sstevel@tonic-gate "unrecoverable error interrupt detected",
2610Sstevel@tonic-gate soft_state->drvinfo.di_instance);
2620Sstevel@tonic-gate hci1394_shutdown(soft_state->drvinfo.di_dip);
2630Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2640Sstevel@tonic-gate }
2650Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_CYC_LOST) {
2660Sstevel@tonic-gate hci1394_isoch_cycle_lost(soft_state);
2670Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2680Sstevel@tonic-gate }
2690Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_CYC_INCONSISTENT) {
2700Sstevel@tonic-gate hci1394_isoch_cycle_inconsistent(soft_state);
2710Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2720Sstevel@tonic-gate }
2730Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_CYC_TOO_LONG) {
2740Sstevel@tonic-gate hci1394_ohci_intr_clear(soft_state->ohci,
2750Sstevel@tonic-gate OHCI_INTR_CYC_TOO_LONG);
2760Sstevel@tonic-gate /* clear cycle master bit in csr state register */
2770Sstevel@tonic-gate hci1394_csr_state_bclr(soft_state->csr,
2780Sstevel@tonic-gate IEEE1394_CSR_STATE_CMSTR);
2790Sstevel@tonic-gate h1394_error_detected(soft_state->drvinfo.di_sl_private,
2800Sstevel@tonic-gate H1394_CYCLE_TOO_LONG, NULL);
2810Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2820Sstevel@tonic-gate }
2830Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_POST_WR_ERR) {
2840Sstevel@tonic-gate hci1394_ohci_postwr_addr(soft_state->ohci,
2850Sstevel@tonic-gate &posted_wr_err.addr);
2860Sstevel@tonic-gate h1394_error_detected(soft_state->drvinfo.di_sl_private,
2870Sstevel@tonic-gate H1394_POSTED_WR_ERR, &posted_wr_err);
2880Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2890Sstevel@tonic-gate }
2900Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_PHY) {
2910Sstevel@tonic-gate hci1394_ohci_isr_phy(soft_state->ohci);
2920Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
2930Sstevel@tonic-gate }
2940Sstevel@tonic-gate if (interrupt_event & OHCI_INTR_LOCK_RESP_ERR) {
2950Sstevel@tonic-gate hci1394_ohci_intr_clear(soft_state->ohci,
2960Sstevel@tonic-gate OHCI_INTR_LOCK_RESP_ERR);
2970Sstevel@tonic-gate h1394_error_detected(soft_state->drvinfo.di_sl_private,
2980Sstevel@tonic-gate H1394_LOCK_RESP_ERR, NULL);
2990Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
3000Sstevel@tonic-gate }
3010Sstevel@tonic-gate
3020Sstevel@tonic-gate /*
3030Sstevel@tonic-gate * Check for self-id-complete interrupt disappearing. There is
3040Sstevel@tonic-gate * a chance in OpenHCI where it will assert the selfid
3050Sstevel@tonic-gate * interrupt and then take it away. We will look for this case
3060Sstevel@tonic-gate * and claim it just in case. We could possibly claim an
3070Sstevel@tonic-gate * interrupt that's not ours. We would have to be in the
3080Sstevel@tonic-gate * middle of a bus reset and a bunch of other weird stuff
3090Sstevel@tonic-gate * would have to align. It should not hurt anything if we do.
3100Sstevel@tonic-gate *
3110Sstevel@tonic-gate * This will very very rarely happen, if ever. We still have
3120Sstevel@tonic-gate * to handle the case, just in case. OpenHCI 1.1 should fix
3130Sstevel@tonic-gate * this problem.
3140Sstevel@tonic-gate */
3150Sstevel@tonic-gate if ((status == DDI_INTR_UNCLAIMED) &&
3160Sstevel@tonic-gate (hci1394_state(&soft_state->drvinfo) ==
3170Sstevel@tonic-gate HCI1394_BUS_RESET)) {
3180Sstevel@tonic-gate if (soft_state->drvinfo.di_gencnt !=
3190Sstevel@tonic-gate hci1394_ohci_current_busgen(soft_state->ohci)) {
3200Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_busgen_claim,
3210Sstevel@tonic-gate HCI1394_TNF_HAL, "");
3220Sstevel@tonic-gate status = DDI_INTR_CLAIMED;
3230Sstevel@tonic-gate }
3240Sstevel@tonic-gate }
3250Sstevel@tonic-gate
3260Sstevel@tonic-gate /*
3270Sstevel@tonic-gate * See if any of the enabled 1394 interrupts have been asserted
3280Sstevel@tonic-gate * since we first checked.
3290Sstevel@tonic-gate */
3300Sstevel@tonic-gate interrupt_event = hci1394_ohci_intr_asserted(
3310Sstevel@tonic-gate soft_state->ohci);
3320Sstevel@tonic-gate } while (interrupt_event != 0);
3330Sstevel@tonic-gate
3340Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_exit, HCI1394_TNF_HAL_STACK, "");
3350Sstevel@tonic-gate
3360Sstevel@tonic-gate return (status);
3370Sstevel@tonic-gate }
3380Sstevel@tonic-gate
3390Sstevel@tonic-gate
3400Sstevel@tonic-gate /*
3410Sstevel@tonic-gate * hci1394_isr_bus_reset()
3420Sstevel@tonic-gate * Process a 1394 bus reset. This signifies that a bus reset has started.
3430Sstevel@tonic-gate * A bus reset will not be complete until a selfid complete interrupt
3440Sstevel@tonic-gate * comes in.
3450Sstevel@tonic-gate */
3460Sstevel@tonic-gate static void
hci1394_isr_bus_reset(hci1394_state_t * soft_state)3470Sstevel@tonic-gate hci1394_isr_bus_reset(hci1394_state_t *soft_state)
3480Sstevel@tonic-gate {
3490Sstevel@tonic-gate int status;
3500Sstevel@tonic-gate
3510Sstevel@tonic-gate
3520Sstevel@tonic-gate ASSERT(soft_state != NULL);
3530Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_bus_reset_enter,
3540Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
3550Sstevel@tonic-gate
3560Sstevel@tonic-gate /*
3570Sstevel@tonic-gate * Set the driver state to reset. If we cannot, we have been shutdown.
3580Sstevel@tonic-gate * The only way we can get in this code is if we have a multi-processor
3590Sstevel@tonic-gate * machine and the HAL is shutdown by one processor running in base
3600Sstevel@tonic-gate * context while this interrupt handler runs in another processor.
3610Sstevel@tonic-gate * We will disable all interrupts and just return. We shouldn't have
3620Sstevel@tonic-gate * to disable the interrupts, but we will just in case.
3630Sstevel@tonic-gate */
3640Sstevel@tonic-gate status = hci1394_state_set(&soft_state->drvinfo, HCI1394_BUS_RESET);
3650Sstevel@tonic-gate if (status != DDI_SUCCESS) {
3660Sstevel@tonic-gate hci1394_ohci_intr_master_disable(soft_state->ohci);
3670Sstevel@tonic-gate return;
3680Sstevel@tonic-gate }
3690Sstevel@tonic-gate
3700Sstevel@tonic-gate /*
3710Sstevel@tonic-gate * Save away reset generation count so we can detect self-id-compete
3720Sstevel@tonic-gate * interrupt which disappears in event register. This is discussed in
3730Sstevel@tonic-gate * more detail in hci1394_isr()
3740Sstevel@tonic-gate */
3750Sstevel@tonic-gate soft_state->drvinfo.di_gencnt =
3760Sstevel@tonic-gate hci1394_ohci_current_busgen(soft_state->ohci);
3770Sstevel@tonic-gate
3780Sstevel@tonic-gate soft_state->drvinfo.di_stats.st_bus_reset_count++;
3790Sstevel@tonic-gate
3800Sstevel@tonic-gate /*
3810Sstevel@tonic-gate * Mask off busReset until SelfIdComplete comes in. The bus reset
3820Sstevel@tonic-gate * interrupt will be asserted until the SelfIdComplete interrupt
3830Sstevel@tonic-gate * comes in (i.e. you cannot clear the interrupt until a SelfIdComplete
3840Sstevel@tonic-gate * interrupt). Therefore, we disable the interrupt via its mask so we
3850Sstevel@tonic-gate * don't get stuck in the ISR indefinitely.
3860Sstevel@tonic-gate */
3870Sstevel@tonic-gate hci1394_ohci_intr_disable(soft_state->ohci, OHCI_INTR_BUS_RESET);
3880Sstevel@tonic-gate
3890Sstevel@tonic-gate /* Reset the ATREQ and ATRESP Q's */
3900Sstevel@tonic-gate hci1394_async_atreq_reset(soft_state->async);
3910Sstevel@tonic-gate hci1394_async_atresp_reset(soft_state->async);
3920Sstevel@tonic-gate
3930Sstevel@tonic-gate /* Inform Services Layer about Bus Reset */
3940Sstevel@tonic-gate h1394_bus_reset(soft_state->drvinfo.di_sl_private,
3950Sstevel@tonic-gate (void **)&soft_state->sl_selfid_buf);
3960Sstevel@tonic-gate
3970Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_bus_reset_exit,
3980Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
3990Sstevel@tonic-gate }
4000Sstevel@tonic-gate
4010Sstevel@tonic-gate
4020Sstevel@tonic-gate /*
4030Sstevel@tonic-gate * hci1394_isr_self_id()
4040Sstevel@tonic-gate * Process the selfid complete interrupt. The bus reset has completed
4050Sstevel@tonic-gate * and the 1394 HW has finished it's bus enumeration. The SW needs to
4060Sstevel@tonic-gate * see what's changed and handle any hotplug conditions.
4070Sstevel@tonic-gate */
4080Sstevel@tonic-gate static void
hci1394_isr_self_id(hci1394_state_t * soft_state)4090Sstevel@tonic-gate hci1394_isr_self_id(hci1394_state_t *soft_state)
4100Sstevel@tonic-gate {
4110Sstevel@tonic-gate int status;
4120Sstevel@tonic-gate uint_t node_id;
4130Sstevel@tonic-gate uint_t selfid_size;
4140Sstevel@tonic-gate uint_t quadlet_count;
4150Sstevel@tonic-gate uint_t index;
4160Sstevel@tonic-gate uint32_t *selfid_buf_p;
4170Sstevel@tonic-gate boolean_t selfid_error;
4180Sstevel@tonic-gate boolean_t nodeid_error;
4190Sstevel@tonic-gate boolean_t saw_error = B_FALSE;
4200Sstevel@tonic-gate uint_t phy_status;
4210Sstevel@tonic-gate
4220Sstevel@tonic-gate
4230Sstevel@tonic-gate ASSERT(soft_state != NULL);
4240Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_self_id_enter, HCI1394_TNF_HAL_STACK, "");
4250Sstevel@tonic-gate
4260Sstevel@tonic-gate soft_state->drvinfo.di_stats.st_selfid_count++;
4270Sstevel@tonic-gate
4280Sstevel@tonic-gate /*
4290Sstevel@tonic-gate * check for the bizarre case that we got both a bus reset and self id
4300Sstevel@tonic-gate * complete after checking for a bus reset
4310Sstevel@tonic-gate */
4320Sstevel@tonic-gate if (hci1394_state(&soft_state->drvinfo) != HCI1394_BUS_RESET) {
4330Sstevel@tonic-gate hci1394_isr_bus_reset(soft_state);
4340Sstevel@tonic-gate }
4350Sstevel@tonic-gate
4360Sstevel@tonic-gate /*
4370Sstevel@tonic-gate * Clear any set PHY error status bits set. The PHY status bits
4380Sstevel@tonic-gate * may always be set (i.e. we removed cable power) so we do not want
4390Sstevel@tonic-gate * to clear them when we handle the interrupt. We will clear them
4400Sstevel@tonic-gate * every selfid complete interrupt so worst case we will get 1 PHY event
4410Sstevel@tonic-gate * interrupt every bus reset.
4420Sstevel@tonic-gate */
4430Sstevel@tonic-gate status = hci1394_ohci_phy_read(soft_state->ohci, 5, &phy_status);
4440Sstevel@tonic-gate if (status != DDI_SUCCESS) {
4450Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_self_id_pr_fail,
4460Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "");
4470Sstevel@tonic-gate } else {
4480Sstevel@tonic-gate phy_status |= OHCI_PHY_LOOP_ERR | OHCI_PHY_PWRFAIL_ERR |
4490Sstevel@tonic-gate OHCI_PHY_TIMEOUT_ERR | OHCI_PHY_PORTEVT_ERR;
4500Sstevel@tonic-gate status = hci1394_ohci_phy_write(soft_state->ohci, 5,
4510Sstevel@tonic-gate phy_status);
4520Sstevel@tonic-gate if (status != DDI_SUCCESS) {
4530Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_self_id_pw_fail,
4540Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "");
4550Sstevel@tonic-gate } else {
4560Sstevel@tonic-gate /*
4570Sstevel@tonic-gate * Re-enable PHY interrupt. We disable the PHY interrupt
4580Sstevel@tonic-gate * when we get one so that we do not get stuck in the
4590Sstevel@tonic-gate * ISR.
4600Sstevel@tonic-gate */
4610Sstevel@tonic-gate hci1394_ohci_intr_enable(soft_state->ohci,
4620Sstevel@tonic-gate OHCI_INTR_PHY);
4630Sstevel@tonic-gate }
4640Sstevel@tonic-gate }
4650Sstevel@tonic-gate
4660Sstevel@tonic-gate /* See if either AT active bit is set */
4670Sstevel@tonic-gate if (hci1394_ohci_at_active(soft_state->ohci) == B_TRUE) {
4680Sstevel@tonic-gate TNF_PROBE_1(hci1394_isr_self_id_as_fail, HCI1394_TNF_HAL_ERROR,
4690Sstevel@tonic-gate "", tnf_string, errmsg, "AT ACTIVE still set");
4700Sstevel@tonic-gate saw_error = B_TRUE;
4710Sstevel@tonic-gate }
4720Sstevel@tonic-gate
4730Sstevel@tonic-gate /* Clear busReset and selfIdComplete interrupts */
4740Sstevel@tonic-gate hci1394_ohci_intr_clear(soft_state->ohci, (OHCI_INTR_BUS_RESET |
4750Sstevel@tonic-gate OHCI_INTR_SELFID_CMPLT));
4760Sstevel@tonic-gate
4770Sstevel@tonic-gate /* Read node info and test for Invalid Node ID */
4780Sstevel@tonic-gate hci1394_ohci_nodeid_info(soft_state->ohci, &node_id, &nodeid_error);
4790Sstevel@tonic-gate if (nodeid_error == B_TRUE) {
4800Sstevel@tonic-gate TNF_PROBE_1(hci1394_isr_self_id_ni_fail, HCI1394_TNF_HAL_ERROR,
4810Sstevel@tonic-gate "", tnf_string, errmsg, "saw invalid NodeID");
4820Sstevel@tonic-gate saw_error = B_TRUE;
4830Sstevel@tonic-gate }
4840Sstevel@tonic-gate
4850Sstevel@tonic-gate /* Sync Selfid Buffer */
4860Sstevel@tonic-gate hci1394_ohci_selfid_sync(soft_state->ohci);
4870Sstevel@tonic-gate
4880Sstevel@tonic-gate /* store away selfid info */
4890Sstevel@tonic-gate hci1394_ohci_selfid_info(soft_state->ohci,
4900Sstevel@tonic-gate &soft_state->drvinfo.di_gencnt, &selfid_size, &selfid_error);
4910Sstevel@tonic-gate
4920Sstevel@tonic-gate /* Test for selfid error */
4930Sstevel@tonic-gate if (selfid_error == B_TRUE) {
4940Sstevel@tonic-gate TNF_PROBE_1(hci1394_isr_self_id_si_fail, HCI1394_TNF_HAL_ERROR,
4950Sstevel@tonic-gate "", tnf_string, errmsg, "saw invalid SelfID");
4960Sstevel@tonic-gate saw_error = B_TRUE;
4970Sstevel@tonic-gate }
4980Sstevel@tonic-gate
4990Sstevel@tonic-gate /*
5000Sstevel@tonic-gate * selfid size could be 0 if a bus reset has occurred. If this occurs,
5010Sstevel@tonic-gate * we should have another selfid int coming later.
5020Sstevel@tonic-gate */
5030Sstevel@tonic-gate if ((saw_error == B_FALSE) && (selfid_size == 0)) {
5040Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_self_id_exit,
5050Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
5060Sstevel@tonic-gate return;
5070Sstevel@tonic-gate }
5080Sstevel@tonic-gate
5090Sstevel@tonic-gate /*
5100Sstevel@tonic-gate * make sure generation count in buffer matches generation
5110Sstevel@tonic-gate * count in register.
5120Sstevel@tonic-gate */
5130Sstevel@tonic-gate if (hci1394_ohci_selfid_buf_current(soft_state->ohci) == B_FALSE) {
5140Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_self_id_exit,
5150Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
5160Sstevel@tonic-gate return;
5170Sstevel@tonic-gate }
5180Sstevel@tonic-gate
5190Sstevel@tonic-gate /*
5200Sstevel@tonic-gate * Skip over first quadlet in selfid buffer, this is OpenHCI specific
5210Sstevel@tonic-gate * data.
5220Sstevel@tonic-gate */
5230Sstevel@tonic-gate selfid_size = selfid_size - IEEE1394_QUADLET;
5240Sstevel@tonic-gate quadlet_count = selfid_size >> 2;
5250Sstevel@tonic-gate
5260Sstevel@tonic-gate /* Copy selfid buffer to Services Layer buffer */
5270Sstevel@tonic-gate for (index = 0; index < quadlet_count; index++) {
5280Sstevel@tonic-gate hci1394_ohci_selfid_read(soft_state->ohci, index + 1,
5290Sstevel@tonic-gate &soft_state->sl_selfid_buf[index]);
5300Sstevel@tonic-gate }
5310Sstevel@tonic-gate
5320Sstevel@tonic-gate /*
5330Sstevel@tonic-gate * Put our selfID info into the Services Layer's selfid buffer if we
5340Sstevel@tonic-gate * have a 1394-1995 PHY.
5350Sstevel@tonic-gate */
5360Sstevel@tonic-gate if (soft_state->halinfo.phy == H1394_PHY_1995) {
5370Sstevel@tonic-gate selfid_buf_p = (uint32_t *)(
5380Sstevel@tonic-gate (uintptr_t)soft_state->sl_selfid_buf +
5390Sstevel@tonic-gate (uintptr_t)selfid_size);
5400Sstevel@tonic-gate status = hci1394_ohci_phy_info(soft_state->ohci,
5410Sstevel@tonic-gate &selfid_buf_p[0]);
5420Sstevel@tonic-gate if (status != DDI_SUCCESS) {
5430Sstevel@tonic-gate /*
5440Sstevel@tonic-gate * If we fail reading from PHY, put invalid data into
5450Sstevel@tonic-gate * the selfid buffer so the SL will reset the bus again.
5460Sstevel@tonic-gate */
5470Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_self_id_pi_fail,
5480Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "");
5490Sstevel@tonic-gate selfid_buf_p[0] = 0xFFFFFFFF;
5500Sstevel@tonic-gate selfid_buf_p[1] = 0xFFFFFFFF;
5510Sstevel@tonic-gate } else {
5520Sstevel@tonic-gate selfid_buf_p[1] = ~selfid_buf_p[0];
5530Sstevel@tonic-gate }
5540Sstevel@tonic-gate selfid_size = selfid_size + 8;
5550Sstevel@tonic-gate }
5560Sstevel@tonic-gate
5570Sstevel@tonic-gate /* Flush out async DMA Q's */
5580Sstevel@tonic-gate hci1394_async_flush(soft_state->async);
5590Sstevel@tonic-gate
5600Sstevel@tonic-gate /*
5610Sstevel@tonic-gate * Make sure generation count is still valid. i.e. we have not gotten
5620Sstevel@tonic-gate * another bus reset since the last time we checked. If we have gotten
5630Sstevel@tonic-gate * another bus reset, we should have another selfid interrupt coming.
5640Sstevel@tonic-gate */
5650Sstevel@tonic-gate if (soft_state->drvinfo.di_gencnt !=
5660Sstevel@tonic-gate hci1394_ohci_current_busgen(soft_state->ohci)) {
5670Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_self_id_exit,
5680Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
5690Sstevel@tonic-gate return;
5700Sstevel@tonic-gate }
5710Sstevel@tonic-gate
5720Sstevel@tonic-gate /*
5730Sstevel@tonic-gate * do whatever CSR register processing that needs to be done.
5740Sstevel@tonic-gate */
5750Sstevel@tonic-gate hci1394_csr_bus_reset(soft_state->csr);
5760Sstevel@tonic-gate
5770Sstevel@tonic-gate /*
5780Sstevel@tonic-gate * do whatever management may be necessary for the CYCLE_LOST and
5790Sstevel@tonic-gate * CYCLE_INCONSISTENT interrupts.
5800Sstevel@tonic-gate */
5810Sstevel@tonic-gate hci1394_isoch_error_ints_enable(soft_state);
5820Sstevel@tonic-gate
5830Sstevel@tonic-gate /*
5840Sstevel@tonic-gate * See if we saw an error. If we did, tell the services layer that we
5850Sstevel@tonic-gate * finished selfid processing and give them an illegal selfid buffer
5860Sstevel@tonic-gate * size of 0. The Services Layer will try to reset the bus again to
5870Sstevel@tonic-gate * see if we can recover from this problem. It will threshold after
5880Sstevel@tonic-gate * a finite number of errors.
5890Sstevel@tonic-gate */
5900Sstevel@tonic-gate if (saw_error == B_TRUE) {
5910Sstevel@tonic-gate h1394_self_ids(soft_state->drvinfo.di_sl_private,
5920Sstevel@tonic-gate soft_state->sl_selfid_buf, 0, node_id,
5930Sstevel@tonic-gate soft_state->drvinfo.di_gencnt);
5940Sstevel@tonic-gate
5950Sstevel@tonic-gate /*
5960Sstevel@tonic-gate * Take ourself out of Bus Reset processing mode
5970Sstevel@tonic-gate *
5980Sstevel@tonic-gate * Set the driver state to normal. If we cannot, we have been
5990Sstevel@tonic-gate * shutdown. The only way we can get in this code is if we have
6000Sstevel@tonic-gate * a multi-processor machine and the HAL is shutdown by one
6010Sstevel@tonic-gate * processor running in base context while this interrupt
6020Sstevel@tonic-gate * handler runs in another processor. We will disable all
6030Sstevel@tonic-gate * interrupts and just return. We shouldn't have to disable
6040Sstevel@tonic-gate * the interrupts, but we will just in case.
6050Sstevel@tonic-gate */
6060Sstevel@tonic-gate status = hci1394_state_set(&soft_state->drvinfo,
6070Sstevel@tonic-gate HCI1394_NORMAL);
6080Sstevel@tonic-gate if (status != DDI_SUCCESS) {
6090Sstevel@tonic-gate hci1394_ohci_intr_master_disable(soft_state->ohci);
6100Sstevel@tonic-gate return;
6110Sstevel@tonic-gate }
6120Sstevel@tonic-gate } else if (IEEE1394_NODE_NUM(node_id) != 63) {
6130Sstevel@tonic-gate /*
6140Sstevel@tonic-gate * Notify services layer about self-id-complete. Don't notify
6150Sstevel@tonic-gate * the services layer if there are too many devices on the bus.
6160Sstevel@tonic-gate */
6170Sstevel@tonic-gate h1394_self_ids(soft_state->drvinfo.di_sl_private,
6180Sstevel@tonic-gate soft_state->sl_selfid_buf, selfid_size,
6190Sstevel@tonic-gate node_id, soft_state->drvinfo.di_gencnt);
6200Sstevel@tonic-gate
6210Sstevel@tonic-gate /*
6220Sstevel@tonic-gate * Take ourself out of Bus Reset processing mode
6230Sstevel@tonic-gate *
6240Sstevel@tonic-gate * Set the driver state to normal. If we cannot, we have been
6250Sstevel@tonic-gate * shutdown. The only way we can get in this code is if we have
6260Sstevel@tonic-gate * a multi-processor machine and the HAL is shutdown by one
6270Sstevel@tonic-gate * processor running in base context while this interrupt
6280Sstevel@tonic-gate * handler runs in another processor. We will disable all
6290Sstevel@tonic-gate * interrupts and just return. We shouldn't have to disable
6300Sstevel@tonic-gate * the interrupts, but we will just in case.
6310Sstevel@tonic-gate */
6320Sstevel@tonic-gate status = hci1394_state_set(&soft_state->drvinfo,
6330Sstevel@tonic-gate HCI1394_NORMAL);
6340Sstevel@tonic-gate if (status != DDI_SUCCESS) {
6350Sstevel@tonic-gate hci1394_ohci_intr_master_disable(soft_state->ohci);
6360Sstevel@tonic-gate return;
6370Sstevel@tonic-gate }
6380Sstevel@tonic-gate } else {
6390Sstevel@tonic-gate cmn_err(CE_NOTE, "hci1394(%d): Too many devices on the 1394 "
6400Sstevel@tonic-gate "bus", soft_state->drvinfo.di_instance);
6410Sstevel@tonic-gate }
6420Sstevel@tonic-gate
6430Sstevel@tonic-gate /* enable bus reset interrupt */
6440Sstevel@tonic-gate hci1394_ohci_intr_enable(soft_state->ohci, OHCI_INTR_BUS_RESET);
6450Sstevel@tonic-gate
6460Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_self_id_exit, HCI1394_TNF_HAL_STACK, "");
6470Sstevel@tonic-gate }
6480Sstevel@tonic-gate
6490Sstevel@tonic-gate
6500Sstevel@tonic-gate /*
6510Sstevel@tonic-gate * hci1394_isr_isoch_ir()
6520Sstevel@tonic-gate * Process each isoch recv context which has its interrupt asserted. The
6530Sstevel@tonic-gate * interrupt will be asserted when an isoch recv descriptor with the
6540Sstevel@tonic-gate * interrupt bits enabled have finished being processed.
6550Sstevel@tonic-gate */
6560Sstevel@tonic-gate static void
hci1394_isr_isoch_ir(hci1394_state_t * soft_state)6570Sstevel@tonic-gate hci1394_isr_isoch_ir(hci1394_state_t *soft_state)
6580Sstevel@tonic-gate {
6590Sstevel@tonic-gate uint32_t i;
6600Sstevel@tonic-gate uint32_t mask = 0x00000001;
6610Sstevel@tonic-gate uint32_t ev;
6620Sstevel@tonic-gate int num_ir_contexts;
6630Sstevel@tonic-gate hci1394_iso_ctxt_t *ctxtp;
6640Sstevel@tonic-gate
6650Sstevel@tonic-gate
6660Sstevel@tonic-gate ASSERT(soft_state != NULL);
6670Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_isoch_ir_enter,
6680Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
6690Sstevel@tonic-gate
6700Sstevel@tonic-gate num_ir_contexts = hci1394_isoch_recv_count_get(soft_state->isoch);
6710Sstevel@tonic-gate
6720Sstevel@tonic-gate /*
6730Sstevel@tonic-gate * Main isochRx int is not clearable. it is automatically
6740Sstevel@tonic-gate * cleared by the hw when the ir_intr_event is cleared
6750Sstevel@tonic-gate */
6760Sstevel@tonic-gate /* loop until no more IR events */
6770Sstevel@tonic-gate while ((ev = hci1394_ohci_ir_intr_asserted(soft_state->ohci)) != 0) {
6780Sstevel@tonic-gate
6790Sstevel@tonic-gate /* clear the events we just learned about */
6800Sstevel@tonic-gate hci1394_ohci_ir_intr_clear(soft_state->ohci, ev);
6810Sstevel@tonic-gate
6820Sstevel@tonic-gate /* for each interrupting IR context, process the interrupt */
6830Sstevel@tonic-gate for (i = 0; i < num_ir_contexts; i++) {
6840Sstevel@tonic-gate /*
6850Sstevel@tonic-gate * if the intr bit is on for a context,
6860Sstevel@tonic-gate * call xmit/recv common processing code
6870Sstevel@tonic-gate */
6880Sstevel@tonic-gate if (ev & mask) {
6890Sstevel@tonic-gate ctxtp = hci1394_isoch_recv_ctxt_get(
690*7391SBarry.Harding@Sun.COM soft_state->isoch, i);
6910Sstevel@tonic-gate hci1394_ixl_interrupt(soft_state, ctxtp,
6920Sstevel@tonic-gate B_FALSE);
6930Sstevel@tonic-gate }
6940Sstevel@tonic-gate mask <<= 1;
6950Sstevel@tonic-gate }
6960Sstevel@tonic-gate }
6970Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_isoch_ir_exit, HCI1394_TNF_HAL_STACK, "");
6980Sstevel@tonic-gate }
6990Sstevel@tonic-gate
7000Sstevel@tonic-gate
7010Sstevel@tonic-gate /*
7020Sstevel@tonic-gate * hci1394_isr_isoch_it()
7030Sstevel@tonic-gate * Process each isoch transmit context which has its interrupt asserted. The
7040Sstevel@tonic-gate * interrupt will be asserted when an isoch transmit descriptor with the
7050Sstevel@tonic-gate * interrupt bit is finished being processed.
7060Sstevel@tonic-gate */
7070Sstevel@tonic-gate static void
hci1394_isr_isoch_it(hci1394_state_t * soft_state)7080Sstevel@tonic-gate hci1394_isr_isoch_it(hci1394_state_t *soft_state)
7090Sstevel@tonic-gate {
7100Sstevel@tonic-gate uint32_t i;
7110Sstevel@tonic-gate uint32_t mask = 0x00000001;
7120Sstevel@tonic-gate uint32_t ev;
7130Sstevel@tonic-gate int num_it_contexts;
7140Sstevel@tonic-gate hci1394_iso_ctxt_t *ctxtp;
7150Sstevel@tonic-gate
7160Sstevel@tonic-gate
7170Sstevel@tonic-gate ASSERT(soft_state != NULL);
7180Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_isoch_it_enter,
7190Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
7200Sstevel@tonic-gate
7210Sstevel@tonic-gate num_it_contexts = hci1394_isoch_xmit_count_get(soft_state->isoch);
7220Sstevel@tonic-gate
7230Sstevel@tonic-gate /*
7240Sstevel@tonic-gate * Main isochTx int is not clearable. it is automatically
7250Sstevel@tonic-gate * cleared by the hw when the it_intr_event is cleared.
7260Sstevel@tonic-gate */
7270Sstevel@tonic-gate
7280Sstevel@tonic-gate /* loop until no more IT events */
7290Sstevel@tonic-gate while ((ev = hci1394_ohci_it_intr_asserted(soft_state->ohci)) != 0) {
7300Sstevel@tonic-gate
7310Sstevel@tonic-gate /* clear the events we just learned about */
7320Sstevel@tonic-gate hci1394_ohci_it_intr_clear(soft_state->ohci, ev);
7330Sstevel@tonic-gate
7340Sstevel@tonic-gate /* for each interrupting IR context, process the interrupt */
7350Sstevel@tonic-gate for (i = 0; i < num_it_contexts; i++) {
7360Sstevel@tonic-gate /*
7370Sstevel@tonic-gate * if the intr bit is on for a context,
7380Sstevel@tonic-gate * call xmit/recv common processing code
7390Sstevel@tonic-gate */
7400Sstevel@tonic-gate if (ev & mask) {
7410Sstevel@tonic-gate ctxtp = hci1394_isoch_xmit_ctxt_get(
742*7391SBarry.Harding@Sun.COM soft_state->isoch, i);
7430Sstevel@tonic-gate hci1394_ixl_interrupt(soft_state, ctxtp,
7440Sstevel@tonic-gate B_FALSE);
7450Sstevel@tonic-gate }
7460Sstevel@tonic-gate mask <<= 1;
7470Sstevel@tonic-gate }
7480Sstevel@tonic-gate }
7490Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_isoch_it_exit, HCI1394_TNF_HAL_STACK, "");
7500Sstevel@tonic-gate }
7510Sstevel@tonic-gate
7520Sstevel@tonic-gate
7530Sstevel@tonic-gate /*
7540Sstevel@tonic-gate * hci1394_isr_atreq_complete()
7550Sstevel@tonic-gate * Process all completed requests that we have sent out (i.e. HW gave us
7560Sstevel@tonic-gate * an ack).
7570Sstevel@tonic-gate */
7580Sstevel@tonic-gate static void
hci1394_isr_atreq_complete(hci1394_state_t * soft_state)7590Sstevel@tonic-gate hci1394_isr_atreq_complete(hci1394_state_t *soft_state)
7600Sstevel@tonic-gate {
7610Sstevel@tonic-gate boolean_t request_available;
7620Sstevel@tonic-gate int status;
7630Sstevel@tonic-gate
7640Sstevel@tonic-gate
7650Sstevel@tonic-gate ASSERT(soft_state != NULL);
7660Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_atreq_complete_enter,
7670Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
7680Sstevel@tonic-gate
7690Sstevel@tonic-gate hci1394_ohci_intr_clear(soft_state->ohci, OHCI_INTR_REQ_TX_CMPLT);
7700Sstevel@tonic-gate
7710Sstevel@tonic-gate /*
7720Sstevel@tonic-gate * Processes all ack'd AT requests. If the request is pended, it is
7730Sstevel@tonic-gate * considered complete relative the the atreq engine. AR response
7740Sstevel@tonic-gate * processing will make sure we track the response.
7750Sstevel@tonic-gate */
7760Sstevel@tonic-gate do {
7770Sstevel@tonic-gate /*
7780Sstevel@tonic-gate * Process a single request. Do not flush Q. That is only
7790Sstevel@tonic-gate * done during bus reset processing.
7800Sstevel@tonic-gate */
7810Sstevel@tonic-gate status = hci1394_async_atreq_process(soft_state->async, B_FALSE,
7820Sstevel@tonic-gate &request_available);
7830Sstevel@tonic-gate if (status != DDI_SUCCESS) {
7840Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_atreq_complete_pr_fail,
7850Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "");
7860Sstevel@tonic-gate }
7870Sstevel@tonic-gate } while (request_available == B_TRUE);
7880Sstevel@tonic-gate
7890Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_atreq_complete_exit,
7900Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
7910Sstevel@tonic-gate }
7920Sstevel@tonic-gate
7930Sstevel@tonic-gate
7940Sstevel@tonic-gate /*
7950Sstevel@tonic-gate * hci1394_isr_arresp()
7960Sstevel@tonic-gate * Process all responses that have come in off the bus and send then up to
7970Sstevel@tonic-gate * the services layer. We send out a request on the bus (atreq) and some time
7980Sstevel@tonic-gate * later a response comes in. We send this response up to the services
7990Sstevel@tonic-gate * layer.
8000Sstevel@tonic-gate */
8010Sstevel@tonic-gate static void
hci1394_isr_arresp(hci1394_state_t * soft_state)8020Sstevel@tonic-gate hci1394_isr_arresp(hci1394_state_t *soft_state)
8030Sstevel@tonic-gate {
8040Sstevel@tonic-gate boolean_t response_available;
8050Sstevel@tonic-gate int status;
8060Sstevel@tonic-gate
8070Sstevel@tonic-gate
8080Sstevel@tonic-gate ASSERT(soft_state != NULL);
8090Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_arresp_enter, HCI1394_TNF_HAL_STACK, "");
8100Sstevel@tonic-gate
8110Sstevel@tonic-gate hci1394_ohci_intr_clear(soft_state->ohci, OHCI_INTR_RSPKT);
8120Sstevel@tonic-gate
8130Sstevel@tonic-gate /*
8140Sstevel@tonic-gate * Process all responses that have been received. If more responses
8150Sstevel@tonic-gate * come in we will stay in interrupt handler and re-run this routine.
8160Sstevel@tonic-gate * It is possible that we will call hci1394_async_arresp_process()
8170Sstevel@tonic-gate * even though there are no more AR responses to process. This would
8180Sstevel@tonic-gate * be because we have processed them earlier on. (i.e. we cleared
8190Sstevel@tonic-gate * interrupt, then got another response and processed it. The interrupt
8200Sstevel@tonic-gate * would still be pending.
8210Sstevel@tonic-gate */
8220Sstevel@tonic-gate do {
8230Sstevel@tonic-gate status = hci1394_async_arresp_process(soft_state->async,
8240Sstevel@tonic-gate &response_available);
8250Sstevel@tonic-gate if (status != DDI_SUCCESS) {
8260Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_arresp_pr_fail,
8270Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "");
8280Sstevel@tonic-gate }
8290Sstevel@tonic-gate } while (response_available == B_TRUE);
8300Sstevel@tonic-gate
8310Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_arresp_exit, HCI1394_TNF_HAL_STACK, "");
8320Sstevel@tonic-gate }
8330Sstevel@tonic-gate
8340Sstevel@tonic-gate
8350Sstevel@tonic-gate /*
8360Sstevel@tonic-gate * hci1394_isr_arreq()
8370Sstevel@tonic-gate * Process all requests that have come in off the bus and send then up to
8380Sstevel@tonic-gate * the services layer.
8390Sstevel@tonic-gate */
8400Sstevel@tonic-gate static void
hci1394_isr_arreq(hci1394_state_t * soft_state)8410Sstevel@tonic-gate hci1394_isr_arreq(hci1394_state_t *soft_state)
8420Sstevel@tonic-gate {
8430Sstevel@tonic-gate boolean_t request_available;
8440Sstevel@tonic-gate int status;
8450Sstevel@tonic-gate
8460Sstevel@tonic-gate
8470Sstevel@tonic-gate ASSERT(soft_state != NULL);
8480Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_arreq_enter, HCI1394_TNF_HAL_STACK, "");
8490Sstevel@tonic-gate
8500Sstevel@tonic-gate hci1394_ohci_intr_clear(soft_state->ohci, OHCI_INTR_RQPKT);
8510Sstevel@tonic-gate
8520Sstevel@tonic-gate /*
8530Sstevel@tonic-gate * Process all requests that have been received. It is possible that we
8540Sstevel@tonic-gate * will call hci1394_async_arreq_process() even though there are no
8550Sstevel@tonic-gate * more requests to process. This would be because we have processed
8560Sstevel@tonic-gate * them earlier on. (i.e. we cleared interrupt, got another request
8570Sstevel@tonic-gate * and processed it. The interrupt would still be pending.
8580Sstevel@tonic-gate */
8590Sstevel@tonic-gate do {
8600Sstevel@tonic-gate status = hci1394_async_arreq_process(soft_state->async,
8610Sstevel@tonic-gate &request_available);
8620Sstevel@tonic-gate if (status != DDI_SUCCESS) {
8630Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_arreq_pr_fail,
8640Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "");
8650Sstevel@tonic-gate }
8660Sstevel@tonic-gate } while (request_available == B_TRUE);
8670Sstevel@tonic-gate
8680Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_arreq_exit, HCI1394_TNF_HAL_STACK, "");
8690Sstevel@tonic-gate }
8700Sstevel@tonic-gate
8710Sstevel@tonic-gate
8720Sstevel@tonic-gate /*
8730Sstevel@tonic-gate * hci1394_isr_atresp_complete()
8740Sstevel@tonic-gate * Process all completed responses that we have sent out (i.e. HW gave us
8750Sstevel@tonic-gate * an ack). We get in a request off the bus (arreq) and send it up to the
8760Sstevel@tonic-gate * services layer, they send down a response to that request some time
8770Sstevel@tonic-gate * later. This interrupt signifies that the HW is done with the response.
8780Sstevel@tonic-gate * (i.e. it sent it out or failed it)
8790Sstevel@tonic-gate */
8800Sstevel@tonic-gate static void
hci1394_isr_atresp_complete(hci1394_state_t * soft_state)8810Sstevel@tonic-gate hci1394_isr_atresp_complete(hci1394_state_t *soft_state)
8820Sstevel@tonic-gate {
8830Sstevel@tonic-gate boolean_t response_available;
8840Sstevel@tonic-gate int status;
8850Sstevel@tonic-gate
8860Sstevel@tonic-gate
8870Sstevel@tonic-gate ASSERT(soft_state != NULL);
8880Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_atresp_complete_enter,
8890Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
8900Sstevel@tonic-gate
8910Sstevel@tonic-gate hci1394_ohci_intr_clear(soft_state->ohci, OHCI_INTR_RESP_TX_CMPLT);
8920Sstevel@tonic-gate
8930Sstevel@tonic-gate /*
8940Sstevel@tonic-gate * Processes all ack'd AT responses It is possible that we will call
8950Sstevel@tonic-gate * hci1394_async_atresp_process() even thought there are no more
8960Sstevel@tonic-gate * responses to process. This would be because we have processed
8970Sstevel@tonic-gate * them earlier on. (i.e. we cleared interrupt, then got another
8980Sstevel@tonic-gate * response and processed it. The interrupt would still be pending.
8990Sstevel@tonic-gate */
9000Sstevel@tonic-gate do {
9010Sstevel@tonic-gate /*
9020Sstevel@tonic-gate * Process a single response. Do not flush Q. That is only
9030Sstevel@tonic-gate * done during bus reset processing.
9040Sstevel@tonic-gate */
9050Sstevel@tonic-gate status = hci1394_async_atresp_process(soft_state->async,
9060Sstevel@tonic-gate B_FALSE, &response_available);
9070Sstevel@tonic-gate if (status != DDI_SUCCESS) {
9080Sstevel@tonic-gate TNF_PROBE_0(hci1394_isr_atresp_complete_pr_fail,
9090Sstevel@tonic-gate HCI1394_TNF_HAL_ERROR, "");
9100Sstevel@tonic-gate }
9110Sstevel@tonic-gate } while (response_available == B_TRUE);
9120Sstevel@tonic-gate
9130Sstevel@tonic-gate TNF_PROBE_0_DEBUG(hci1394_isr_atresp_complete_exit,
9140Sstevel@tonic-gate HCI1394_TNF_HAL_STACK, "");
9150Sstevel@tonic-gate }
916