xref: /onnv-gate/usr/src/uts/sun4u/sunfire/io/central.c (revision 7656:2621e50fdf4a)
12305Sstevel /*
22305Sstevel  * CDDL HEADER START
32305Sstevel  *
42305Sstevel  * The contents of this file are subject to the terms of the
52305Sstevel  * Common Development and Distribution License (the "License").
62305Sstevel  * You may not use this file except in compliance with the License.
72305Sstevel  *
82305Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92305Sstevel  * or http://www.opensolaris.org/os/licensing.
102305Sstevel  * See the License for the specific language governing permissions
112305Sstevel  * and limitations under the License.
122305Sstevel  *
132305Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
142305Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152305Sstevel  * If applicable, add the following below this CDDL HEADER, with the
162305Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
172305Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
182305Sstevel  *
192305Sstevel  * CDDL HEADER END
202305Sstevel  */
212305Sstevel 
222305Sstevel /*
23*7656SSherry.Moore@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
242305Sstevel  * Use is subject to license terms.
252305Sstevel  */
262305Sstevel 
272305Sstevel 
282305Sstevel #include <sys/types.h>
292305Sstevel #include <sys/conf.h>
302305Sstevel #include <sys/ddi.h>
312305Sstevel #include <sys/sunddi.h>
322305Sstevel #include <sys/ddi_impldefs.h>
332305Sstevel #include <sys/ddi_subrdefs.h>
342305Sstevel #include <sys/obpdefs.h>
352305Sstevel #include <sys/cmn_err.h>
362305Sstevel #include <sys/errno.h>
372305Sstevel #include <sys/kmem.h>
382305Sstevel #include <sys/debug.h>
392305Sstevel #include <sys/sysmacros.h>
402305Sstevel #include <sys/autoconf.h>
412305Sstevel #include <sys/modctl.h>
422305Sstevel 
432305Sstevel /*
442305Sstevel  * module central.c
452305Sstevel  *
462305Sstevel  * This module is a nexus driver designed to support the fhc nexus driver
472305Sstevel  * and all children below it. This driver does not handle any of the
482305Sstevel  * DDI functions passed up to it by the fhc driver, but instead allows
492305Sstevel  * them to bubble up to the root node. A consequence of this is that
502305Sstevel  * the maintainer of this code must watch for changes in the sun4u
512305Sstevel  * rootnexus driver to make sure they do not break this driver or any
522305Sstevel  * of its children.
532305Sstevel  */
542305Sstevel 
552305Sstevel /*
562305Sstevel  * Function Prototypes
572305Sstevel  */
582305Sstevel static int
592305Sstevel central_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
602305Sstevel 
612305Sstevel static int
622305Sstevel central_detach(dev_info_t *devi, ddi_detach_cmd_t cmd);
632305Sstevel 
642305Sstevel /*
652305Sstevel  * Configuration Data Structures
662305Sstevel  */
672305Sstevel static struct bus_ops central_bus_ops = {
682305Sstevel 	BUSO_REV,
692305Sstevel 	ddi_bus_map,		/* map */
702305Sstevel 	0,			/* get_intrspec */
712305Sstevel 	0,			/* add_intrspec */
722305Sstevel 	0,			/* remove_intrspec */
732305Sstevel 	i_ddi_map_fault,	/* map_fault */
742305Sstevel 	ddi_no_dma_map,		/* dma_map */
752305Sstevel 	ddi_no_dma_allochdl,
762305Sstevel 	ddi_no_dma_freehdl,
772305Sstevel 	ddi_no_dma_bindhdl,
782305Sstevel 	ddi_no_dma_unbindhdl,
792305Sstevel 	ddi_no_dma_flush,
802305Sstevel 	ddi_no_dma_win,
812305Sstevel 	ddi_dma_mctl,		/* dma_ctl */
822305Sstevel 	ddi_ctlops,		/* ctl */
832305Sstevel 	ddi_bus_prop_op,	/* prop_op */
842305Sstevel 	0,			/* (*bus_get_eventcookie)();	*/
852305Sstevel 	0,			/* (*bus_add_eventcall)();	*/
862305Sstevel 	0,			/* (*bus_remove_eventcall)();	*/
872305Sstevel 	0,			/* (*bus_post_event)();		*/
882305Sstevel 	0,			/* (*bus_intr_ctl)();		*/
892305Sstevel 	0,			/* (*bus_config)();		*/
902305Sstevel 	0,			/* (*bus_unconfig)();		*/
912305Sstevel 	0,			/* (*bus_fm_init)();		*/
922305Sstevel 	0,			/* (*bus_fm_fini)();		*/
932305Sstevel 	0,			/* (*bus_fm_access_enter)();	*/
942305Sstevel 	0,			/* (*bus_fm_access_exit)();	*/
952305Sstevel 	0,			/* (*bus_power)();		*/
962305Sstevel 	i_ddi_intr_ops		/* (*bus_intr_op)();		*/
972305Sstevel };
982305Sstevel 
992305Sstevel static struct dev_ops central_ops = {
1002305Sstevel 	DEVO_REV,		/* rev */
1012305Sstevel 	0,			/* refcnt */
1022305Sstevel 	ddi_no_info,		/* getinfo */
1032305Sstevel 	nulldev,		/* identify */
1042305Sstevel 	nulldev,		/* probe */
1052305Sstevel 	central_attach,		/* attach */
1062305Sstevel 	central_detach,		/* detach */
1072305Sstevel 	nulldev,		/* reset */
1082305Sstevel 	(struct cb_ops *)0,	/* cb_ops */
1092305Sstevel 	&central_bus_ops,	/* bus_ops */
110*7656SSherry.Moore@Sun.COM 	nulldev,		/* power */
111*7656SSherry.Moore@Sun.COM 	ddi_quiesce_not_needed,		/* quiesce */
1122305Sstevel };
1132305Sstevel 
1142305Sstevel extern struct mod_ops mod_driverops;
1152305Sstevel 
1162305Sstevel static struct modldrv modldrv = {
1172305Sstevel 	&mod_driverops,		/* Type of module.  This one is a driver */
118*7656SSherry.Moore@Sun.COM 	"Central Nexus",	/* Name of module. */
1192305Sstevel 	&central_ops,		/* driver ops */
1202305Sstevel };
1212305Sstevel 
1222305Sstevel static struct modlinkage modlinkage = {
1232305Sstevel 	MODREV_1,		/* rev */
1242305Sstevel 	(void *)&modldrv,
1252305Sstevel 	NULL
1262305Sstevel };
1272305Sstevel 
1282305Sstevel /*
1292305Sstevel  * These are the module initialization routines.
1302305Sstevel  */
1312305Sstevel 
1322305Sstevel int
_init(void)1332305Sstevel _init(void)
1342305Sstevel {
1352305Sstevel 	return (mod_install(&modlinkage));
1362305Sstevel }
1372305Sstevel 
1382305Sstevel int
_fini(void)1392305Sstevel _fini(void)
1402305Sstevel {
1412305Sstevel 	int error;
1422305Sstevel 
1432305Sstevel 	if ((error = mod_remove(&modlinkage)) != 0)
1442305Sstevel 		return (error);
1452305Sstevel 
1462305Sstevel 	return (0);
1472305Sstevel }
1482305Sstevel 
1492305Sstevel int
_info(struct modinfo * modinfop)1502305Sstevel _info(struct modinfo *modinfop)
1512305Sstevel {
1522305Sstevel 	return (mod_info(&modlinkage, modinfop));
1532305Sstevel }
1542305Sstevel 
1552305Sstevel static int
central_attach(dev_info_t * devi,ddi_attach_cmd_t cmd)1562305Sstevel central_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
1572305Sstevel {
1582305Sstevel 	switch (cmd) {
1592305Sstevel 	case DDI_ATTACH:
1602305Sstevel 		break;
1612305Sstevel 
1622305Sstevel 	case DDI_RESUME:
1632305Sstevel 		return (DDI_SUCCESS);
1642305Sstevel 
1652305Sstevel 	default:
1662305Sstevel 		return (DDI_FAILURE);
1672305Sstevel 	}
1682305Sstevel 
1692305Sstevel 	/* nothing to suspend/resume here */
1702305Sstevel 	(void) ddi_prop_update_string(DDI_DEV_T_NONE, devi,
171*7656SSherry.Moore@Sun.COM 	    "pm-hardware-state", "no-suspend-resume");
1722305Sstevel 
1732305Sstevel 	ddi_report_dev(devi);
1742305Sstevel 	return (DDI_SUCCESS);
1752305Sstevel }
1762305Sstevel 
1772305Sstevel /* ARGSUSED */
1782305Sstevel static int
central_detach(dev_info_t * devi,ddi_detach_cmd_t cmd)1792305Sstevel central_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
1802305Sstevel {
1812305Sstevel 	switch (cmd) {
1822305Sstevel 	case DDI_SUSPEND:
1832305Sstevel 	case DDI_DETACH:
1842305Sstevel 	default:
1852305Sstevel 		return (DDI_FAILURE);
1862305Sstevel 	}
1872305Sstevel }
188