4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
31 * Misc. HBA functions. These include getinfo, open, close, shutdown, and
32 * overall driver state control functions.
37 #include <sys/modctl.h>
38 #include <sys/sunddi.h>
39 #include <sys/types.h>
40 #include <sys/mkdev.h>
42 #include <sys/1394/adapters/hci1394.h>
43 #include <sys/1394/adapters/hci1394_extern.h>
49 hci1394_getinfo(dev_info_t
*dip
, ddi_info_cmd_t cmd
, void *arg
, void **result
)
52 hci1394_state_t
*soft_state
;
57 case DDI_INFO_DEVT2DEVINFO
:
59 instance
= getminor(dev
);
60 soft_state
= ddi_get_soft_state(hci1394_statep
, instance
);
61 if (soft_state
== NULL
) {
64 *result
= (void *)soft_state
->drvinfo
.di_dip
;
68 case DDI_INFO_DEVT2INSTANCE
:
70 instance
= getminor(dev
);
71 *result
= (void *)(uintptr_t)instance
;
85 hci1394_open(dev_t
*devp
, int flag
, int otyp
, cred_t
*credp
)
87 hci1394_state_t
*soft_state
;
89 soft_state
= ddi_get_soft_state(hci1394_statep
, getminor(*devp
));
90 if (soft_state
== NULL
) {
100 hci1394_close(dev_t dev
, int flag
, int otyp
, cred_t
*credp
)
108 * Shutdown the HW. Something bad that we cannot recover from happened.
111 hci1394_shutdown(dev_info_t
*dip
)
113 hci1394_state_t
*soft_state
;
117 * In the debug version of the driver, we want to do an assert here so
118 * that we don't reset the hardware and can look and see what happened
119 * to cause the shutdown.
121 #ifndef TEST_SHUTDOWN
125 soft_state
= ddi_get_soft_state(hci1394_statep
, ddi_get_instance(dip
));
126 if (soft_state
== NULL
) {
131 * Don't allow the HW to generate any more interrupts. Make sure we
132 * disable interrupts before setting the driver state to shutdown.
134 hci1394_ohci_intr_master_disable(soft_state
->ohci
);
136 /* don't accept anymore commands from services layer */
137 (void) hci1394_state_set(&soft_state
->drvinfo
, HCI1394_SHUTDOWN
);
139 /* Reset the OHCI HW */
140 (void) hci1394_ohci_soft_reset(soft_state
->ohci
);
142 /* Flush out async DMA Q's (cancels pendingQ timeouts too) */
143 hci1394_async_flush(soft_state
->async
);
149 * returns the current state of the driver
152 hci1394_state(hci1394_drvinfo_t
*drvinfo
)
154 hci1394_statevar_t hal_state
;
156 mutex_enter(&drvinfo
->di_drvstate
.ds_mutex
);
157 hal_state
= drvinfo
->di_drvstate
.ds_state
;
158 mutex_exit(&drvinfo
->di_drvstate
.ds_mutex
);
165 * hci1394_state_set()
166 * Set the current state of the driver. This routine will return failure
167 * if the driver state is currently set to HCI1394_SHUTDOWN. We do not
168 * allow a transition out of shutdown.
171 hci1394_state_set(hci1394_drvinfo_t
*drvinfo
, hci1394_statevar_t state
)
173 mutex_enter(&drvinfo
->di_drvstate
.ds_mutex
);
175 /* Do not allow a transition out of shutdown */
176 if (drvinfo
->di_drvstate
.ds_state
== HCI1394_SHUTDOWN
) {
177 mutex_exit(&drvinfo
->di_drvstate
.ds_mutex
);
178 return (DDI_FAILURE
);
181 drvinfo
->di_drvstate
.ds_state
= state
;
182 mutex_exit(&drvinfo
->di_drvstate
.ds_mutex
);
184 return (DDI_SUCCESS
);