xref: /titanic_50/usr/src/uts/sun4u/sunfire/io/central.c (revision 34f9b3eef6fdadbda0a846aa4d68691ac40eace5)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 
28 #include <sys/types.h>
29 #include <sys/conf.h>
30 #include <sys/ddi.h>
31 #include <sys/sunddi.h>
32 #include <sys/ddi_impldefs.h>
33 #include <sys/ddi_subrdefs.h>
34 #include <sys/obpdefs.h>
35 #include <sys/cmn_err.h>
36 #include <sys/errno.h>
37 #include <sys/kmem.h>
38 #include <sys/debug.h>
39 #include <sys/sysmacros.h>
40 #include <sys/autoconf.h>
41 #include <sys/modctl.h>
42 
43 /*
44  * module central.c
45  *
46  * This module is a nexus driver designed to support the fhc nexus driver
47  * and all children below it. This driver does not handle any of the
48  * DDI functions passed up to it by the fhc driver, but instead allows
49  * them to bubble up to the root node. A consequence of this is that
50  * the maintainer of this code must watch for changes in the sun4u
51  * rootnexus driver to make sure they do not break this driver or any
52  * of its children.
53  */
54 
55 /*
56  * Function Prototypes
57  */
58 static int
59 central_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
60 
61 static int
62 central_detach(dev_info_t *devi, ddi_detach_cmd_t cmd);
63 
64 /*
65  * Configuration Data Structures
66  */
67 static struct bus_ops central_bus_ops = {
68 	BUSO_REV,
69 	ddi_bus_map,		/* map */
70 	0,			/* get_intrspec */
71 	0,			/* add_intrspec */
72 	0,			/* remove_intrspec */
73 	i_ddi_map_fault,	/* map_fault */
74 	ddi_no_dma_map,		/* dma_map */
75 	ddi_no_dma_allochdl,
76 	ddi_no_dma_freehdl,
77 	ddi_no_dma_bindhdl,
78 	ddi_no_dma_unbindhdl,
79 	ddi_no_dma_flush,
80 	ddi_no_dma_win,
81 	ddi_dma_mctl,		/* dma_ctl */
82 	ddi_ctlops,		/* ctl */
83 	ddi_bus_prop_op,	/* prop_op */
84 	0,			/* (*bus_get_eventcookie)();	*/
85 	0,			/* (*bus_add_eventcall)();	*/
86 	0,			/* (*bus_remove_eventcall)();	*/
87 	0,			/* (*bus_post_event)();		*/
88 	0,			/* (*bus_intr_ctl)();		*/
89 	0,			/* (*bus_config)();		*/
90 	0,			/* (*bus_unconfig)();		*/
91 	0,			/* (*bus_fm_init)();		*/
92 	0,			/* (*bus_fm_fini)();		*/
93 	0,			/* (*bus_fm_access_enter)();	*/
94 	0,			/* (*bus_fm_access_exit)();	*/
95 	0,			/* (*bus_power)();		*/
96 	i_ddi_intr_ops		/* (*bus_intr_op)();		*/
97 };
98 
99 static struct dev_ops central_ops = {
100 	DEVO_REV,		/* rev */
101 	0,			/* refcnt */
102 	ddi_no_info,		/* getinfo */
103 	nulldev,		/* identify */
104 	nulldev,		/* probe */
105 	central_attach,		/* attach */
106 	central_detach,		/* detach */
107 	nulldev,		/* reset */
108 	(struct cb_ops *)0,	/* cb_ops */
109 	&central_bus_ops,	/* bus_ops */
110 	nulldev,		/* power */
111 	ddi_quiesce_not_needed,		/* quiesce */
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",	/* 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