Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / uts / common / io / 1394 / adapters / hci1394.c
blob1c447cdd7c868374ae5c8ef1027cfa3a05667295
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
28 * hci1394.c
29 * 1394 (firewire) OpenHCI 1.0 HBA driver. This file contains the driver's
30 * _init(), _info(), and _fini().
33 #include <sys/modctl.h>
34 #include <sys/conf.h>
35 #include <sys/ddi.h>
36 #include <sys/sunddi.h>
38 #include <sys/1394/ieee1394.h>
39 #include <sys/1394/h1394.h>
41 #include <sys/1394/adapters/hci1394.h>
44 /* HAL State Pointer */
45 void *hci1394_statep;
47 /* Character/Block Operations */
48 static struct cb_ops hci1394_cb_ops = {
49 hci1394_open, /* open */
50 hci1394_close, /* close */
51 nodev, /* strategy (block) */
52 nodev, /* print (block) */
53 nodev, /* dump (block) */
54 nodev, /* read */
55 nodev, /* write */
56 hci1394_ioctl, /* ioctl */
57 nodev, /* devmap */
58 nodev, /* mmap */
59 nodev, /* segmap */
60 nochpoll, /* chpoll */
61 ddi_prop_op, /* prop_op */
62 NULL, /* streams */
63 D_NEW | D_MP |
64 D_64BIT | D_HOTPLUG, /* flags */
65 CB_REV /* rev */
68 /* Driver Operations */
69 static struct dev_ops hci1394_ops = {
70 DEVO_REV, /* struct rev */
71 0, /* refcnt */
72 hci1394_getinfo, /* getinfo */
73 nulldev, /* identify */
74 nulldev, /* probe */
75 hci1394_attach, /* attach */
76 hci1394_detach, /* detach */
77 nodev, /* reset */
78 &hci1394_cb_ops, /* cb_ops */
79 NULL, /* bus_ops */
80 NULL, /* power */
81 hci1394_quiesce, /* devo_quiesce */
84 /* Module Driver Info */
85 static struct modldrv hci1394_modldrv = {
86 &mod_driverops,
87 "1394 OpenHCI HBA driver",
88 &hci1394_ops
91 /* Module Linkage */
92 static struct modlinkage hci1394_modlinkage = {
93 MODREV_1,
94 &hci1394_modldrv,
95 NULL
98 #ifndef NPROBE
99 extern int tnf_mod_load(void);
100 extern int tnf_mod_unload(struct modlinkage *mlp);
101 #endif
104 _init()
106 int status;
109 #ifndef NPROBE
110 (void) tnf_mod_load();
111 #endif
113 status = ddi_soft_state_init(&hci1394_statep, sizeof (hci1394_state_t),
114 (size_t)HCI1394_INITIAL_STATES);
115 if (status != 0) {
116 #ifndef NPROBE
117 (void) tnf_mod_unload(&hci1394_modlinkage);
118 #endif
119 return (status);
122 /* Call into services layer to init bus-ops */
123 status = h1394_init(&hci1394_modlinkage);
124 if (status != 0) {
125 #ifndef NPROBE
126 (void) tnf_mod_unload(&hci1394_modlinkage);
127 #endif
128 return (status);
131 status = mod_install(&hci1394_modlinkage);
132 if (status != 0) {
133 ddi_soft_state_fini(&hci1394_statep);
134 #ifndef NPROBE
135 (void) tnf_mod_unload(&hci1394_modlinkage);
136 #endif
137 return (status);
140 return (status);
145 _info(struct modinfo *modinfop)
147 int status;
149 status = mod_info(&hci1394_modlinkage, modinfop);
151 return (status);
156 _fini()
158 int status;
160 status = mod_remove(&hci1394_modlinkage);
161 if (status != 0) {
162 return (status);
165 /* Call into services layer notify about _fini */
166 h1394_fini(&hci1394_modlinkage);
167 ddi_soft_state_fini(&hci1394_statep);
169 #ifndef NPROBE
170 (void) tnf_mod_unload(&hci1394_modlinkage);
171 #endif
173 return (status);