xref: /titanic_50/usr/src/uts/sun4u/sunfire/io/central.c (revision 142c9f13e148d687426ed2d4e8bd93717eeaebbc)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/types.h>
30 #include <sys/conf.h>
31 #include <sys/ddi.h>
32 #include <sys/sunddi.h>
33 #include <sys/ddi_impldefs.h>
34 #include <sys/ddi_subrdefs.h>
35 #include <sys/obpdefs.h>
36 #include <sys/cmn_err.h>
37 #include <sys/errno.h>
38 #include <sys/kmem.h>
39 #include <sys/debug.h>
40 #include <sys/sysmacros.h>
41 #include <sys/autoconf.h>
42 #include <sys/modctl.h>
43 
44 /*
45  * module central.c
46  *
47  * This module is a nexus driver designed to support the fhc nexus driver
48  * and all children below it. This driver does not handle any of the
49  * DDI functions passed up to it by the fhc driver, but instead allows
50  * them to bubble up to the root node. A consequence of this is that
51  * the maintainer of this code must watch for changes in the sun4u
52  * rootnexus driver to make sure they do not break this driver or any
53  * of its children.
54  */
55 
56 /*
57  * Function Prototypes
58  */
59 static int
60 central_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
61 
62 static int
63 central_detach(dev_info_t *devi, ddi_detach_cmd_t cmd);
64 
65 /*
66  * Configuration Data Structures
67  */
68 static struct bus_ops central_bus_ops = {
69 	BUSO_REV,
70 	ddi_bus_map,		/* map */
71 	0,			/* get_intrspec */
72 	0,			/* add_intrspec */
73 	0,			/* remove_intrspec */
74 	i_ddi_map_fault,	/* map_fault */
75 	ddi_no_dma_map,		/* dma_map */
76 	ddi_no_dma_allochdl,
77 	ddi_no_dma_freehdl,
78 	ddi_no_dma_bindhdl,
79 	ddi_no_dma_unbindhdl,
80 	ddi_no_dma_flush,
81 	ddi_no_dma_win,
82 	ddi_dma_mctl,		/* dma_ctl */
83 	ddi_ctlops,		/* ctl */
84 	ddi_bus_prop_op,	/* prop_op */
85 	0,			/* (*bus_get_eventcookie)();	*/
86 	0,			/* (*bus_add_eventcall)();	*/
87 	0,			/* (*bus_remove_eventcall)();	*/
88 	0,			/* (*bus_post_event)();		*/
89 	0,			/* (*bus_intr_ctl)();		*/
90 	0,			/* (*bus_config)();		*/
91 	0,			/* (*bus_unconfig)();		*/
92 	0,			/* (*bus_fm_init)();		*/
93 	0,			/* (*bus_fm_fini)();		*/
94 	0,			/* (*bus_fm_access_enter)();	*/
95 	0,			/* (*bus_fm_access_exit)();	*/
96 	0,			/* (*bus_power)();		*/
97 	i_ddi_intr_ops		/* (*bus_intr_op)();		*/
98 };
99 
100 static struct dev_ops central_ops = {
101 	DEVO_REV,		/* rev */
102 	0,			/* refcnt */
103 	ddi_no_info,		/* getinfo */
104 	nulldev,		/* identify */
105 	nulldev,		/* probe */
106 	central_attach,		/* attach */
107 	central_detach,		/* detach */
108 	nulldev,		/* reset */
109 	(struct cb_ops *)0,	/* cb_ops */
110 	&central_bus_ops,	/* bus_ops */
111 	nulldev			/* power */
112 };
113 
114 extern struct mod_ops mod_driverops;
115 
116 static struct modldrv modldrv = {
117 	&mod_driverops,		/* Type of module.  This one is a driver */
118 	"Central Nexus %I%",	/* Name of module. */
119 	&central_ops,		/* driver ops */
120 };
121 
122 static struct modlinkage modlinkage = {
123 	MODREV_1,		/* rev */
124 	(void *)&modldrv,
125 	NULL
126 };
127 
128 /*
129  * These are the module initialization routines.
130  */
131 
132 int
133 _init(void)
134 {
135 	return (mod_install(&modlinkage));
136 }
137 
138 int
139 _fini(void)
140 {
141 	int error;
142 
143 	if ((error = mod_remove(&modlinkage)) != 0)
144 		return (error);
145 
146 	return (0);
147 }
148 
149 int
150 _info(struct modinfo *modinfop)
151 {
152 	return (mod_info(&modlinkage, modinfop));
153 }
154 
155 static int
156 central_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
157 {
158 	switch (cmd) {
159 	case DDI_ATTACH:
160 		break;
161 
162 	case DDI_RESUME:
163 		return (DDI_SUCCESS);
164 
165 	default:
166 		return (DDI_FAILURE);
167 	}
168 
169 	/* nothing to suspend/resume here */
170 	(void) ddi_prop_update_string(DDI_DEV_T_NONE, devi,
171 		"pm-hardware-state", "no-suspend-resume");
172 
173 	ddi_report_dev(devi);
174 	return (DDI_SUCCESS);
175 }
176 
177 /* ARGSUSED */
178 static int
179 central_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
180 {
181 	switch (cmd) {
182 	case DDI_SUSPEND:
183 	case DDI_DETACH:
184 	default:
185 		return (DDI_FAILURE);
186 	}
187 }
188