xref: /titanic_51/usr/src/uts/sun4u/sunfire/io/central.c (revision 193974072f41a843678abf5f61979c748687e66b)
13db86aabSstevel /*
23db86aabSstevel  * CDDL HEADER START
33db86aabSstevel  *
43db86aabSstevel  * The contents of this file are subject to the terms of the
53db86aabSstevel  * Common Development and Distribution License (the "License").
63db86aabSstevel  * You may not use this file except in compliance with the License.
73db86aabSstevel  *
83db86aabSstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93db86aabSstevel  * or http://www.opensolaris.org/os/licensing.
103db86aabSstevel  * See the License for the specific language governing permissions
113db86aabSstevel  * and limitations under the License.
123db86aabSstevel  *
133db86aabSstevel  * When distributing Covered Code, include this CDDL HEADER in each
143db86aabSstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153db86aabSstevel  * If applicable, add the following below this CDDL HEADER, with the
163db86aabSstevel  * fields enclosed by brackets "[]" replaced with your own identifying
173db86aabSstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
183db86aabSstevel  *
193db86aabSstevel  * CDDL HEADER END
203db86aabSstevel  */
213db86aabSstevel 
223db86aabSstevel /*
23*19397407SSherry Moore  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
243db86aabSstevel  * Use is subject to license terms.
253db86aabSstevel  */
263db86aabSstevel 
273db86aabSstevel 
283db86aabSstevel #include <sys/types.h>
293db86aabSstevel #include <sys/conf.h>
303db86aabSstevel #include <sys/ddi.h>
313db86aabSstevel #include <sys/sunddi.h>
323db86aabSstevel #include <sys/ddi_impldefs.h>
333db86aabSstevel #include <sys/ddi_subrdefs.h>
343db86aabSstevel #include <sys/obpdefs.h>
353db86aabSstevel #include <sys/cmn_err.h>
363db86aabSstevel #include <sys/errno.h>
373db86aabSstevel #include <sys/kmem.h>
383db86aabSstevel #include <sys/debug.h>
393db86aabSstevel #include <sys/sysmacros.h>
403db86aabSstevel #include <sys/autoconf.h>
413db86aabSstevel #include <sys/modctl.h>
423db86aabSstevel 
433db86aabSstevel /*
443db86aabSstevel  * module central.c
453db86aabSstevel  *
463db86aabSstevel  * This module is a nexus driver designed to support the fhc nexus driver
473db86aabSstevel  * and all children below it. This driver does not handle any of the
483db86aabSstevel  * DDI functions passed up to it by the fhc driver, but instead allows
493db86aabSstevel  * them to bubble up to the root node. A consequence of this is that
503db86aabSstevel  * the maintainer of this code must watch for changes in the sun4u
513db86aabSstevel  * rootnexus driver to make sure they do not break this driver or any
523db86aabSstevel  * of its children.
533db86aabSstevel  */
543db86aabSstevel 
553db86aabSstevel /*
563db86aabSstevel  * Function Prototypes
573db86aabSstevel  */
583db86aabSstevel static int
593db86aabSstevel central_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
603db86aabSstevel 
613db86aabSstevel static int
623db86aabSstevel central_detach(dev_info_t *devi, ddi_detach_cmd_t cmd);
633db86aabSstevel 
643db86aabSstevel /*
653db86aabSstevel  * Configuration Data Structures
663db86aabSstevel  */
673db86aabSstevel static struct bus_ops central_bus_ops = {
683db86aabSstevel 	BUSO_REV,
693db86aabSstevel 	ddi_bus_map,		/* map */
703db86aabSstevel 	0,			/* get_intrspec */
713db86aabSstevel 	0,			/* add_intrspec */
723db86aabSstevel 	0,			/* remove_intrspec */
733db86aabSstevel 	i_ddi_map_fault,	/* map_fault */
743db86aabSstevel 	ddi_no_dma_map,		/* dma_map */
753db86aabSstevel 	ddi_no_dma_allochdl,
763db86aabSstevel 	ddi_no_dma_freehdl,
773db86aabSstevel 	ddi_no_dma_bindhdl,
783db86aabSstevel 	ddi_no_dma_unbindhdl,
793db86aabSstevel 	ddi_no_dma_flush,
803db86aabSstevel 	ddi_no_dma_win,
813db86aabSstevel 	ddi_dma_mctl,		/* dma_ctl */
823db86aabSstevel 	ddi_ctlops,		/* ctl */
833db86aabSstevel 	ddi_bus_prop_op,	/* prop_op */
843db86aabSstevel 	0,			/* (*bus_get_eventcookie)();	*/
853db86aabSstevel 	0,			/* (*bus_add_eventcall)();	*/
863db86aabSstevel 	0,			/* (*bus_remove_eventcall)();	*/
873db86aabSstevel 	0,			/* (*bus_post_event)();		*/
883db86aabSstevel 	0,			/* (*bus_intr_ctl)();		*/
893db86aabSstevel 	0,			/* (*bus_config)();		*/
903db86aabSstevel 	0,			/* (*bus_unconfig)();		*/
913db86aabSstevel 	0,			/* (*bus_fm_init)();		*/
923db86aabSstevel 	0,			/* (*bus_fm_fini)();		*/
933db86aabSstevel 	0,			/* (*bus_fm_access_enter)();	*/
943db86aabSstevel 	0,			/* (*bus_fm_access_exit)();	*/
953db86aabSstevel 	0,			/* (*bus_power)();		*/
963db86aabSstevel 	i_ddi_intr_ops		/* (*bus_intr_op)();		*/
973db86aabSstevel };
983db86aabSstevel 
993db86aabSstevel static struct dev_ops central_ops = {
1003db86aabSstevel 	DEVO_REV,		/* rev */
1013db86aabSstevel 	0,			/* refcnt */
1023db86aabSstevel 	ddi_no_info,		/* getinfo */
1033db86aabSstevel 	nulldev,		/* identify */
1043db86aabSstevel 	nulldev,		/* probe */
1053db86aabSstevel 	central_attach,		/* attach */
1063db86aabSstevel 	central_detach,		/* detach */
1073db86aabSstevel 	nulldev,		/* reset */
1083db86aabSstevel 	(struct cb_ops *)0,	/* cb_ops */
1093db86aabSstevel 	&central_bus_ops,	/* bus_ops */
110*19397407SSherry Moore 	nulldev,		/* power */
111*19397407SSherry Moore 	ddi_quiesce_not_needed,		/* quiesce */
1123db86aabSstevel };
1133db86aabSstevel 
1143db86aabSstevel extern struct mod_ops mod_driverops;
1153db86aabSstevel 
1163db86aabSstevel static struct modldrv modldrv = {
1173db86aabSstevel 	&mod_driverops,		/* Type of module.  This one is a driver */
118*19397407SSherry Moore 	"Central Nexus",	/* Name of module. */
1193db86aabSstevel 	&central_ops,		/* driver ops */
1203db86aabSstevel };
1213db86aabSstevel 
1223db86aabSstevel static struct modlinkage modlinkage = {
1233db86aabSstevel 	MODREV_1,		/* rev */
1243db86aabSstevel 	(void *)&modldrv,
1253db86aabSstevel 	NULL
1263db86aabSstevel };
1273db86aabSstevel 
1283db86aabSstevel /*
1293db86aabSstevel  * These are the module initialization routines.
1303db86aabSstevel  */
1313db86aabSstevel 
1323db86aabSstevel int
1333db86aabSstevel _init(void)
1343db86aabSstevel {
1353db86aabSstevel 	return (mod_install(&modlinkage));
1363db86aabSstevel }
1373db86aabSstevel 
1383db86aabSstevel int
1393db86aabSstevel _fini(void)
1403db86aabSstevel {
1413db86aabSstevel 	int error;
1423db86aabSstevel 
1433db86aabSstevel 	if ((error = mod_remove(&modlinkage)) != 0)
1443db86aabSstevel 		return (error);
1453db86aabSstevel 
1463db86aabSstevel 	return (0);
1473db86aabSstevel }
1483db86aabSstevel 
1493db86aabSstevel int
1503db86aabSstevel _info(struct modinfo *modinfop)
1513db86aabSstevel {
1523db86aabSstevel 	return (mod_info(&modlinkage, modinfop));
1533db86aabSstevel }
1543db86aabSstevel 
1553db86aabSstevel static int
1563db86aabSstevel central_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
1573db86aabSstevel {
1583db86aabSstevel 	switch (cmd) {
1593db86aabSstevel 	case DDI_ATTACH:
1603db86aabSstevel 		break;
1613db86aabSstevel 
1623db86aabSstevel 	case DDI_RESUME:
1633db86aabSstevel 		return (DDI_SUCCESS);
1643db86aabSstevel 
1653db86aabSstevel 	default:
1663db86aabSstevel 		return (DDI_FAILURE);
1673db86aabSstevel 	}
1683db86aabSstevel 
1693db86aabSstevel 	/* nothing to suspend/resume here */
1703db86aabSstevel 	(void) ddi_prop_update_string(DDI_DEV_T_NONE, devi,
1713db86aabSstevel 	    "pm-hardware-state", "no-suspend-resume");
1723db86aabSstevel 
1733db86aabSstevel 	ddi_report_dev(devi);
1743db86aabSstevel 	return (DDI_SUCCESS);
1753db86aabSstevel }
1763db86aabSstevel 
1773db86aabSstevel /* ARGSUSED */
1783db86aabSstevel static int
1793db86aabSstevel central_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
1803db86aabSstevel {
1813db86aabSstevel 	switch (cmd) {
1823db86aabSstevel 	case DDI_SUSPEND:
1833db86aabSstevel 	case DDI_DETACH:
1843db86aabSstevel 	default:
1853db86aabSstevel 		return (DDI_FAILURE);
1863db86aabSstevel 	}
1873db86aabSstevel }
188