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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
28 * skeleton hub driver, the actual code is in hubdi.c
29 * as it is shared between the root hub and the other hub instances
32 #include <sys/usb/usba/usbai_version.h>
33 #include <sys/usb/usba.h>
34 #include <sys/usb/usba/hubdi.h>
35 #include <sys/usb/hubd/hub.h>
36 #include <sys/usb/hubd/hubdvar.h>
38 static int hubd_open(dev_t
*devp
, int flags
, int otyp
, cred_t
*credp
);
39 static int hubd_close(dev_t dev
, int flag
, int otyp
, cred_t
*credp
);
40 static int hubd_ioctl(dev_t dev
, int cmd
, intptr_t arg
, int mode
,
41 cred_t
*credp
, int *rvalp
);
42 static int hubd_info(dev_info_t
*dip
, ddi_info_cmd_t infocmd
,
43 void *arg
, void **result
);
44 extern int usba_hubdi_power(dev_info_t
*dip
, int comp
, int level
);
47 static struct cb_ops hubd_cb_ops
= {
49 hubd_close
, /* close */
55 hubd_ioctl
, /* ioctl */
60 ddi_prop_op
, /* cb_prop_op */
62 D_MP
/* Driver compatibility flag */
65 static struct dev_ops hubd_ops
= {
66 DEVO_REV
, /* devo_rev, */
69 nulldev
, /* identify */
71 usba_hubdi_attach
, /* attach */
72 usba_hubdi_detach
, /* detach */
74 &hubd_cb_ops
, /* driver operations */
75 &usba_hubdi_busops
, /* bus operations */
76 usba_hubdi_power
, /* power */
77 ddi_quiesce_not_needed
, /* quiesce */
80 static struct modldrv modldrv
= {
81 &mod_driverops
, /* Type of module. This one is a driver */
82 "USB Hub Driver", /* Name of the module. */
83 &hubd_ops
, /* driver ops */
86 static struct modlinkage modlinkage
= {
87 MODREV_1
, (void *)&modldrv
, NULL
91 extern void *hubd_statep
;
98 /* Initialize the soft state structures */
99 if ((rval
= ddi_soft_state_init(&hubd_statep
,
100 sizeof (hubd_t
), HUBD_INITIAL_SOFT_SPACE
)) != 0) {
104 if ((rval
= mod_install(&modlinkage
)) != 0) {
105 ddi_soft_state_fini(&hubd_statep
);
117 int rval
= mod_remove(&modlinkage
);
119 ddi_soft_state_fini(&hubd_statep
);
127 _info(struct modinfo
*modinfop
)
129 return (mod_info(&modlinkage
, modinfop
));
134 hubd_get_dip(dev_t dev
)
136 minor_t minor
= getminor(dev
);
137 int instance
= (int)minor
& ~HUBD_IS_ROOT_HUB
;
138 hubd_t
*hubd
= ddi_get_soft_state(hubd_statep
, instance
);
141 return (hubd
->h_dip
);
152 hubd_info(dev_info_t
*dip
, ddi_info_cmd_t infocmd
,
153 void *arg
, void **result
)
157 int error
= DDI_FAILURE
;
160 case DDI_INFO_DEVT2DEVINFO
:
161 *result
= (void *)hubd_get_dip((dev_t
)arg
);
162 if (*result
!= NULL
) {
166 case DDI_INFO_DEVT2INSTANCE
:
168 instance
= HUBD_UNIT(dev
);
169 *result
= (void *)(intptr_t)instance
;
179 hubd_open(dev_t
*devp
, int flags
, int otyp
, cred_t
*credp
)
181 dev_info_t
*dip
= hubd_get_dip(*devp
);
183 return (usba_hubdi_open(dip
, devp
, flags
, otyp
, credp
));
188 hubd_close(dev_t dev
, int flag
, int otyp
, cred_t
*credp
)
190 dev_info_t
*dip
= hubd_get_dip(dev
);
192 return (usba_hubdi_close(dip
, dev
, flag
, otyp
, credp
));
197 hubd_ioctl(dev_t dev
, int cmd
, intptr_t arg
, int mode
,
198 cred_t
*credp
, int *rvalp
)
200 dev_info_t
*dip
= hubd_get_dip(dev
);
202 return (usba_hubdi_ioctl(dip
, dev
, cmd
, arg
, mode
,