17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*19397407SSherry Moore  * Common Development and Distribution License (the "License").
6*19397407SSherry Moore  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*19397407SSherry Moore  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * hci1394.c
297c478bd9Sstevel@tonic-gate  *    1394 (firewire) OpenHCI 1.0 HBA driver. This file contains the driver's
307c478bd9Sstevel@tonic-gate  *    _init(), _info(), and _fini().
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
347c478bd9Sstevel@tonic-gate #include <sys/conf.h>
357c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
367c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/1394/ieee1394.h>
397c478bd9Sstevel@tonic-gate #include <sys/1394/h1394.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include <sys/1394/adapters/hci1394.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /* HAL State Pointer */
457c478bd9Sstevel@tonic-gate void *hci1394_statep;
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate /* Character/Block Operations */
487c478bd9Sstevel@tonic-gate static struct cb_ops hci1394_cb_ops = {
497c478bd9Sstevel@tonic-gate 	hci1394_open,		/* open */
507c478bd9Sstevel@tonic-gate 	hci1394_close,		/* close */
517c478bd9Sstevel@tonic-gate 	nodev,			/* strategy (block) */
527c478bd9Sstevel@tonic-gate 	nodev,			/* print (block) */
537c478bd9Sstevel@tonic-gate 	nodev,			/* dump (block) */
547c478bd9Sstevel@tonic-gate 	nodev,			/* read */
557c478bd9Sstevel@tonic-gate 	nodev,			/* write */
567c478bd9Sstevel@tonic-gate 	hci1394_ioctl,		/* ioctl */
577c478bd9Sstevel@tonic-gate 	nodev,			/* devmap */
587c478bd9Sstevel@tonic-gate 	nodev,			/* mmap */
597c478bd9Sstevel@tonic-gate 	nodev,			/* segmap */
607c478bd9Sstevel@tonic-gate 	nochpoll,		/* chpoll */
617c478bd9Sstevel@tonic-gate 	ddi_prop_op,		/* prop_op */
627c478bd9Sstevel@tonic-gate 	NULL,			/* streams */
637c478bd9Sstevel@tonic-gate 	D_NEW | D_MP |
647c478bd9Sstevel@tonic-gate 	D_64BIT | D_HOTPLUG,	/* flags */
657c478bd9Sstevel@tonic-gate 	CB_REV			/* rev */
667c478bd9Sstevel@tonic-gate };
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /* Driver Operations */
697c478bd9Sstevel@tonic-gate static struct dev_ops hci1394_ops = {
707c478bd9Sstevel@tonic-gate 	DEVO_REV,		/* struct rev */
717c478bd9Sstevel@tonic-gate 	0,			/* refcnt */
727c478bd9Sstevel@tonic-gate 	hci1394_getinfo,	/* getinfo */
737c478bd9Sstevel@tonic-gate 	nulldev,		/* identify */
747c478bd9Sstevel@tonic-gate 	nulldev,		/* probe */
757c478bd9Sstevel@tonic-gate 	hci1394_attach,		/* attach */
767c478bd9Sstevel@tonic-gate 	hci1394_detach,		/* detach */
777c478bd9Sstevel@tonic-gate 	nodev,			/* reset */
787c478bd9Sstevel@tonic-gate 	&hci1394_cb_ops,	/* cb_ops */
797c478bd9Sstevel@tonic-gate 	NULL,			/* bus_ops */
80*19397407SSherry Moore 	NULL,			/* power */
81*19397407SSherry Moore 	hci1394_quiesce,	/* devo_quiesce */
827c478bd9Sstevel@tonic-gate };
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /* Module Driver Info */
857c478bd9Sstevel@tonic-gate static struct modldrv hci1394_modldrv = {
867c478bd9Sstevel@tonic-gate 	&mod_driverops,
87*19397407SSherry Moore 	"1394 OpenHCI HBA driver",
887c478bd9Sstevel@tonic-gate 	&hci1394_ops
897c478bd9Sstevel@tonic-gate };
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /* Module Linkage */
927c478bd9Sstevel@tonic-gate static struct modlinkage hci1394_modlinkage = {
937c478bd9Sstevel@tonic-gate 	MODREV_1,
947c478bd9Sstevel@tonic-gate 	&hci1394_modldrv,
957c478bd9Sstevel@tonic-gate 	NULL
967c478bd9Sstevel@tonic-gate };
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate int
_init()997c478bd9Sstevel@tonic-gate _init()
1007c478bd9Sstevel@tonic-gate {
1017c478bd9Sstevel@tonic-gate 	int status;
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	status = ddi_soft_state_init(&hci1394_statep, sizeof (hci1394_state_t),
1047c478bd9Sstevel@tonic-gate 	    (size_t)HCI1394_INITIAL_STATES);
1057c478bd9Sstevel@tonic-gate 	if (status != 0) {
1067c478bd9Sstevel@tonic-gate 		return (status);
1077c478bd9Sstevel@tonic-gate 	}
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 	/* Call into services layer to init bus-ops */
1107c478bd9Sstevel@tonic-gate 	status = h1394_init(&hci1394_modlinkage);
1117c478bd9Sstevel@tonic-gate 	if (status != 0) {
1127c478bd9Sstevel@tonic-gate 		return (status);
1137c478bd9Sstevel@tonic-gate 	}
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 	status = mod_install(&hci1394_modlinkage);
1167c478bd9Sstevel@tonic-gate 	if (status != 0) {
1177c478bd9Sstevel@tonic-gate 		ddi_soft_state_fini(&hci1394_statep);
1187c478bd9Sstevel@tonic-gate 		return (status);
1197c478bd9Sstevel@tonic-gate 	}
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 	return (status);
1227c478bd9Sstevel@tonic-gate }
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate int
_info(struct modinfo * modinfop)1267c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
1277c478bd9Sstevel@tonic-gate {
1287c478bd9Sstevel@tonic-gate 	int status;
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	status = mod_info(&hci1394_modlinkage, modinfop);
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate 	return (status);
1337c478bd9Sstevel@tonic-gate }
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate int
_fini()1377c478bd9Sstevel@tonic-gate _fini()
1387c478bd9Sstevel@tonic-gate {
1397c478bd9Sstevel@tonic-gate 	int status;
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate 	status = mod_remove(&hci1394_modlinkage);
1427c478bd9Sstevel@tonic-gate 	if (status != 0) {
1437c478bd9Sstevel@tonic-gate 		return (status);
1447c478bd9Sstevel@tonic-gate 	}
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate 	/* Call into services layer notify about _fini */
1477c478bd9Sstevel@tonic-gate 	h1394_fini(&hci1394_modlinkage);
1487c478bd9Sstevel@tonic-gate 	ddi_soft_state_fini(&hci1394_statep);
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate 	return (status);
1517c478bd9Sstevel@tonic-gate }
152