xref: /onnv-gate/usr/src/uts/sun4u/starcat/io/gptwo_pci.c (revision 11311:639e7bc0b42f)
11708Sstevel /*
21708Sstevel  * CDDL HEADER START
31708Sstevel  *
41708Sstevel  * The contents of this file are subject to the terms of the
51708Sstevel  * Common Development and Distribution License (the "License").
61708Sstevel  * You may not use this file except in compliance with the License.
71708Sstevel  *
81708Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91708Sstevel  * or http://www.opensolaris.org/os/licensing.
101708Sstevel  * See the License for the specific language governing permissions
111708Sstevel  * and limitations under the License.
121708Sstevel  *
131708Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
141708Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151708Sstevel  * If applicable, add the following below this CDDL HEADER, with the
161708Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
171708Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
181708Sstevel  *
191708Sstevel  * CDDL HEADER END
201708Sstevel  */
211708Sstevel 
221708Sstevel /*
23*11311SSurya.Prakki@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
241708Sstevel  * Use is subject to license terms.
251708Sstevel  */
261708Sstevel 
271708Sstevel /*
281708Sstevel  * Schizo/PCI Functions to the Safari Configurator
291708Sstevel  *
301708Sstevel  */
311708Sstevel 
321708Sstevel #include <sys/types.h>
331708Sstevel #include <sys/cred.h>
341708Sstevel #include <sys/mman.h>
351708Sstevel #include <sys/kmem.h>
361708Sstevel #include <sys/conf.h>
371708Sstevel #include <sys/ddi.h>
381708Sstevel #include <sys/sunddi.h>
391708Sstevel #include <sys/sunndi.h>
401708Sstevel #include <sys/modctl.h>
411708Sstevel #include <sys/stat.h>
421708Sstevel #include <sys/param.h>
431708Sstevel #include <sys/autoconf.h>
441708Sstevel #include <sys/ksynch.h>
451708Sstevel #include <sys/promif.h>
461708Sstevel #include <sys/ndi_impldefs.h>
471708Sstevel #include <sys/ddi_impldefs.h>
481708Sstevel #include <sys/machsystm.h>
491708Sstevel #include <sys/gp2cfg.h>
501708Sstevel #include <sys/gptwo_pci.h>
511708Sstevel 
521708Sstevel #ifdef DEBUG
531708Sstevel int gptwo_pci_debug = 0;
541708Sstevel 
551708Sstevel static void debug(char *, uintptr_t, uintptr_t,
561708Sstevel     uintptr_t, uintptr_t, uintptr_t);
571708Sstevel 
581708Sstevel #define	GPTWO_DEBUG0(level, flag, s) if (gptwo_pci_debug >= level) \
591708Sstevel     cmn_err(flag, s)
601708Sstevel #define	GPTWO_DEBUG1(level, flag, fmt, a1) if (gptwo_pci_debug >= level) \
611708Sstevel     debug(fmt, (uintptr_t)(a1), 0, 0, 0, 0);
621708Sstevel #define	GPTWO_DEBUG2(level, flag, fmt, a1, a2) if (gptwo_pci_debug >= level) \
631708Sstevel     debug(fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);
641708Sstevel #define	GPTWO_DEBUG3(level, flag, fmt, a1, a2, a3) \
651708Sstevel     if (gptwo_pci_debug >= level) \
661708Sstevel     debug(fmt, (uintptr_t)(a1), (uintptr_t)(a2), (uintptr_t)(a3), 0, 0);
671708Sstevel #else
681708Sstevel #define	GPTWO_DEBUG0(level, flag, s)
691708Sstevel #define	GPTWO_DEBUG1(level, flag, fmt, a1)
701708Sstevel #define	GPTWO_DEBUG2(level, flag, fmt, a1, a2)
711708Sstevel #define	GPTWO_DEBUG3(level, flag, fmt, a1, a2, a3)
721708Sstevel #endif
731708Sstevel 
741708Sstevel void gptwocfg_devi_attach_to_parent(dev_info_t *);
751708Sstevel static char *gptwo_get_probe_string(spcd_t *, int);
761708Sstevel static void gptwo_find_nodes(dev_info_t *, int, gptwo_new_nodes_t *);
771708Sstevel 
781708Sstevel extern caddr_t efcode_vaddr;
791708Sstevel extern int efcode_size;
801708Sstevel 
811708Sstevel /*
821708Sstevel  * Module linkage information for the kernel.
831708Sstevel  */
841708Sstevel 
851708Sstevel extern struct mod_ops mod_miscops;
861708Sstevel 
871708Sstevel static struct modlmisc modlmisc = {
881708Sstevel 	&mod_miscops, /* Type of module */
897799SRichard.Bean@Sun.COM 	"gptwo->pci configurator",
901708Sstevel };
911708Sstevel 
921708Sstevel static struct modlinkage modlinkage = {
931708Sstevel 	MODREV_1, (void *)&modlmisc, NULL
941708Sstevel };
951708Sstevel 
961708Sstevel int
_init(void)971708Sstevel _init(void)
981708Sstevel {
991708Sstevel 	int err = 0;
1001708Sstevel 
1011708Sstevel 	/*
1021708Sstevel 	 * Create a resource map for the contigous memory allocated
1031708Sstevel 	 * at start-of-day in startup.c
1041708Sstevel 	 */
1051708Sstevel 	if (ndi_ra_map_setup(ddi_root_node(), "gptwo-contigousmem")
1061708Sstevel 	    == NDI_FAILURE) {
1071708Sstevel 		GPTWO_DEBUG0(1, CE_WARN,
1081708Sstevel 		    "Can not setup resource map - gptwo-contigousmem\n");
1091708Sstevel 		return (1);
1101708Sstevel 	}
1111708Sstevel 
1121708Sstevel 	/*
1131708Sstevel 	 * Put the allocated memory into the pool.
1141708Sstevel 	 */
1151708Sstevel 	(void) ndi_ra_free(ddi_root_node(), (uint64_t)efcode_vaddr,
1161708Sstevel 	    (uint64_t)efcode_size, "gptwo-contigousmem", 0);
1171708Sstevel 
1181708Sstevel 	/* register devices with the configurator */
1191708Sstevel 	gptwocfg_register_ops(SAFPTYPE_sPCI, gptwo_configure_pci,
1207799SRichard.Bean@Sun.COM 	    gptwo_unconfigure_pci);
1211708Sstevel 	gptwocfg_register_ops(SAFPTYPE_cPCI, gptwo_configure_pci,
1227799SRichard.Bean@Sun.COM 	    gptwo_unconfigure_pci);
1231708Sstevel 	gptwocfg_register_ops(SAFPTYPE_PCIX, gptwo_configure_pci,
1247799SRichard.Bean@Sun.COM 	    gptwo_unconfigure_pci);
1251708Sstevel 
1261708Sstevel 	if ((err = mod_install(&modlinkage)) != 0) {
1271708Sstevel 		GPTWO_DEBUG1(1, CE_WARN, "gptwo_pci (PCI Functions) "
1281708Sstevel 		"failed to load, error=%d\n", err);
1291708Sstevel 		gptwocfg_unregister_ops(SAFPTYPE_sPCI);
1301708Sstevel 		gptwocfg_unregister_ops(SAFPTYPE_cPCI);
1311708Sstevel 		gptwocfg_unregister_ops(SAFPTYPE_PCIX);
1321708Sstevel 	} else {
1331708Sstevel 		GPTWO_DEBUG0(1, CE_WARN, "gptwo_pci (PCI Functions) "
1341708Sstevel 		"has been loaded.\n");
1351708Sstevel 	}
1361708Sstevel 	return (err);
1371708Sstevel }
1381708Sstevel 
1391708Sstevel int
_fini(void)1401708Sstevel _fini(void)
1411708Sstevel {
1421708Sstevel 	gptwocfg_unregister_ops(SAFPTYPE_sPCI);
1431708Sstevel 	gptwocfg_unregister_ops(SAFPTYPE_cPCI);
1441708Sstevel 	gptwocfg_unregister_ops(SAFPTYPE_PCIX);
1451708Sstevel 	return (mod_remove(&modlinkage));
1461708Sstevel }
1471708Sstevel 
1481708Sstevel int
_info(modinfop)1491708Sstevel _info(modinfop)
1501708Sstevel struct modinfo *modinfop;
1511708Sstevel {
1521708Sstevel 	return (mod_info(&modlinkage, modinfop));
1531708Sstevel }
1541708Sstevel 
1551708Sstevel /*ARGSUSED*/
1561708Sstevel static int
set_name_prop(dev_info_t * dip,void * arg,uint_t flags)1571708Sstevel set_name_prop(dev_info_t *dip, void *arg, uint_t flags)
1581708Sstevel {
1591708Sstevel 	if (ndi_prop_update_string(DDI_DEV_T_NONE, dip,
1601708Sstevel 	    "name", "pci") != DDI_SUCCESS) {
1611708Sstevel 		return (DDI_WALK_ERROR);
1621708Sstevel 	}
1631708Sstevel 
1641708Sstevel 	return (DDI_WALK_TERMINATE);
1651708Sstevel }
1661708Sstevel 
1671708Sstevel /*ARGSUSED*/
1681708Sstevel static void
get_new_child(dev_info_t * rdip,void * arg,uint_t flags)1691708Sstevel get_new_child(dev_info_t *rdip, void *arg, uint_t flags)
1701708Sstevel {
1711708Sstevel 	dev_info_t **dipp = (dev_info_t **)arg;
1721708Sstevel 
1731708Sstevel 	ASSERT(dipp && (*dipp == NULL));
1741708Sstevel 
1751708Sstevel 	*dipp = rdip;
1761708Sstevel }
1771708Sstevel 
1781708Sstevel gptwo_new_nodes_t *
gptwo_configure_pci(dev_info_t * ap,spcd_t * pcd,uint_t id)1791708Sstevel gptwo_configure_pci(dev_info_t *ap, spcd_t *pcd, uint_t id)
1801708Sstevel {
1811708Sstevel 	fco_handle_t fco_handle;
1821708Sstevel 	int error, i, circ, freq;
1831708Sstevel 	dev_info_t *new_child;
1841708Sstevel 	char unit_address[64];
1851708Sstevel 	gptwo_new_nodes_t *new_nodes;
1861708Sstevel 	char *probe_string;
1871708Sstevel 	devi_branch_t b = {0};
1881708Sstevel 
1891708Sstevel 	GPTWO_DEBUG2(1, CE_CONT, "gptwo_configure_pci: id=%x pcd=%lx\n",
1901708Sstevel 	    id, pcd);
1911708Sstevel 
1921708Sstevel 	new_nodes = gptwocfg_allocate_node_list(IOBUS_PER_PORT);
1931708Sstevel 
1941708Sstevel 	i = IOBUS_PER_PORT;
1951708Sstevel 
1961708Sstevel 	while (i) {
1971708Sstevel 		i--;
1981708Sstevel 
1991708Sstevel 		if (pcd->spcd_iobus_rsv[i] != SPCD_RSV_PASS) {
2001708Sstevel 
2011708Sstevel 			cmn_err(CE_WARN, "gptwo_configure_pci: saf id=0x%x "
2021708Sstevel 			    "leaf %d - Can not be probed\n", id, i);
2031708Sstevel 
2041708Sstevel 			continue;
2051708Sstevel 		}
2061708Sstevel 
2071708Sstevel 		/*
2081708Sstevel 		 * Ideally, fcode would be run from the "sid_branch_create"
2091708Sstevel 		 * callback (that is the primary purpose of that callback).
2101708Sstevel 		 * However, the fcode interpreter was written with the
2111708Sstevel 		 * assumption that the "new_child" was linked into the
2121708Sstevel 		 * device tree. The callback is invoked with the devinfo node
2131708Sstevel 		 * in the DS_PROTO state. More investigation is needed before
2141708Sstevel 		 * we can invoke the interpreter from the callback. For now,
2151708Sstevel 		 * we create the "new_child" in the BOUND state, invoke the
2161708Sstevel 		 * fcode interpreter and then rebind the dip to use any
2171708Sstevel 		 * compatible properties created by fcode.
2181708Sstevel 		 */
2191708Sstevel 
2201708Sstevel 		new_child = NULL;
2211708Sstevel 
2221708Sstevel 		b.arg = &new_child;
2231708Sstevel 		b.type = DEVI_BRANCH_SID;
2241708Sstevel 		b.create.sid_branch_create = set_name_prop;
2251708Sstevel 		b.devi_branch_callback = get_new_child;
2261708Sstevel 
2271708Sstevel 		/*
2281708Sstevel 		 * Prevent any changes to new_child
2291708Sstevel 		 * until we have bound it to the correct driver.
2301708Sstevel 		 */
2311708Sstevel 		ndi_devi_enter(ap, &circ);
2321708Sstevel 		if (e_ddi_branch_create(ap, &b, NULL, 0)) {
2331708Sstevel 			ASSERT(new_child == NULL);
2341708Sstevel 
2351708Sstevel 			if (new_nodes->gptwo_nodes[0] == NULL) {
2361708Sstevel 				GPTWO_DEBUG0(1, CE_CONT, "gptwo_configure_pci: "
2371708Sstevel 				    "No nodes configured - "
2381708Sstevel 				    "removing new_nodes\n");
2391708Sstevel 				gptwocfg_free_node_list(new_nodes);
2401708Sstevel 				new_nodes = NULL;
2411708Sstevel 			}
2421708Sstevel 
2431708Sstevel 			ndi_devi_exit(ap, circ);
2441708Sstevel 
2451708Sstevel 			return (new_nodes);
2461708Sstevel 		}
2471708Sstevel 
2481708Sstevel 		/*
2491708Sstevel 		 * The platform DR interfaces created the dip in
2501708Sstevel 		 * bound state. Bring devinfo node down to linked
2511708Sstevel 		 * state and hold it there until compatible
2521708Sstevel 		 * properties are created.
2531708Sstevel 		 */
2541708Sstevel 		e_ddi_branch_rele(new_child);
2551708Sstevel 		(void) i_ndi_unconfig_node(new_child, DS_LINKED, 0);
2561708Sstevel 		ASSERT(i_ddi_node_state(new_child) == DS_LINKED);
2571708Sstevel 		e_ddi_branch_hold(new_child);
2581708Sstevel 
2591708Sstevel 		mutex_enter(&DEVI(new_child)->devi_lock);
2601708Sstevel 		DEVI(new_child)->devi_flags |= DEVI_NO_BIND;
2611708Sstevel 		mutex_exit(&DEVI(new_child)->devi_lock);
2621708Sstevel 
2631708Sstevel 		/*
2641708Sstevel 		 * Drop the busy-hold on parent before calling
2651708Sstevel 		 * fcode_interpreter to prevent potential deadlocks
2661708Sstevel 		 */
2671708Sstevel 		ndi_devi_exit(ap, circ);
2681708Sstevel 
2691708Sstevel 		(void) sprintf(unit_address, "%x", id);
2701708Sstevel 
2711708Sstevel 		/*
2721708Sstevel 		 * Build the probe string from the PCD that will be passed
2731708Sstevel 		 * in to the interpreter as my-args.  This will tell the
2741708Sstevel 		 * fcode what pci devices to probe after the pci node has
2751708Sstevel 		 * been probed.
2761708Sstevel 		 */
2771708Sstevel 		probe_string = gptwo_get_probe_string(pcd, i);
2781708Sstevel 
2791708Sstevel 		GPTWO_DEBUG3(1, CE_CONT, "gptwo_configure_pci: args to "
2801708Sstevel 		    "interpreter ap=%lx new_child=%lx unit_address=%s\n",
2811708Sstevel 		    ap, new_child, unit_address);
2821708Sstevel 
2831708Sstevel 		if (probe_string)
2841708Sstevel 			GPTWO_DEBUG1(1, CE_CONT, "gptwo_configure_pci: "
2851708Sstevel 			    "probe string=%s\n", probe_string);
2861708Sstevel 
2871708Sstevel 		fco_handle = gp2_fc_ops_alloc_handle(ap, new_child, NULL, NULL,
2881708Sstevel 		    unit_address, probe_string);
2891708Sstevel 
2901708Sstevel 		GPTWO_DEBUG0(1, CE_CONT,
2911708Sstevel 		    "gptwocfg: Calling Fcode Interpeter...\n");
2921708Sstevel 
2931708Sstevel 		error = fcode_interpreter(ap, &gp2_fc_ops, fco_handle);
2941708Sstevel 
2951708Sstevel 		GPTWO_DEBUG1(1, CE_CONT,
2961708Sstevel 		    "gptwo_configure_pci: fcode_interpreter "
2971708Sstevel 		    " returned %x\n", error);
2981708Sstevel 
2991708Sstevel 		if (error) {
3001708Sstevel 			cmn_err(CE_WARN, "gptwo_pci: Unable to probe pci leaf "
3011708Sstevel 			    "%s\n", unit_address);
3021708Sstevel 
3031708Sstevel 			gp2_fc_ops_free_handle(fco_handle);
3041708Sstevel 
3051708Sstevel 			(void) e_ddi_branch_destroy(new_child, NULL, 0);
3061708Sstevel 		} else {
3071708Sstevel 			gptwocfg_save_handle(new_child, fco_handle);
3081708Sstevel 
3091708Sstevel 			/*
3101708Sstevel 			 * Compatible properties (if any) have been created,
3111708Sstevel 			 * so bind driver.
3121708Sstevel 			 */
3131708Sstevel 			ndi_devi_enter(ap, &circ);
3141708Sstevel 			ASSERT(i_ddi_node_state(new_child) <= DS_LINKED);
3151708Sstevel 
3161708Sstevel 			mutex_enter(&DEVI(new_child)->devi_lock);
3171708Sstevel 			DEVI(new_child)->devi_flags &= ~DEVI_NO_BIND;
3181708Sstevel 			mutex_exit(&DEVI(new_child)->devi_lock);
3191708Sstevel 
3201708Sstevel 			ndi_devi_exit(ap, circ);
3211708Sstevel 
3221708Sstevel 			if (ndi_devi_bind_driver(new_child, 0) !=
3237799SRichard.Bean@Sun.COM 			    DDI_SUCCESS) {
3241708Sstevel 				cmn_err(CE_WARN, "gptwo_pci: Unable to bind"
3251708Sstevel 				    " new pci child at dip=0x%p\n",
326*11311SSurya.Prakki@Sun.COM 				    (void *)new_child);
3271708Sstevel 			}
3281708Sstevel 
3291708Sstevel 			/*
3301708Sstevel 			 * If POST provided a frequency, the clock-frequency
3311708Sstevel 			 * property needs to be updated.
3321708Sstevel 			 */
3331708Sstevel 			if (pcd->spcd_afreq) {
3341708Sstevel 
3351708Sstevel 				/*
3361708Sstevel 				 * The upper byte is for leaf B and the lower
3371708Sstevel 				 * byte is for leaf A.
3381708Sstevel 				 */
3391708Sstevel 				if (i)
3401708Sstevel 					freq = pcd->spcd_afreq >> 8;
3411708Sstevel 				else
3421708Sstevel 					freq = pcd->spcd_afreq & 0x00ff;
3431708Sstevel 
3441708Sstevel 				(void) ndi_prop_update_int(DDI_DEV_T_NONE,
3451708Sstevel 				    new_child, "clock-frequency",
3461708Sstevel 				    (freq * 1000 * 1000));
3471708Sstevel 			}
3481708Sstevel 		}
3491708Sstevel 	}
3501708Sstevel 
3511708Sstevel 	gptwo_find_nodes(ap, id, new_nodes);
3521708Sstevel 
3531708Sstevel 	if (new_nodes->gptwo_nodes[0] == NULL) {
3541708Sstevel 		GPTWO_DEBUG0(1, CE_CONT, "gptwo_configure_pci: "
3551708Sstevel 		    "No nodes configured - removing new_nodes\n");
3561708Sstevel 		gptwocfg_free_node_list(new_nodes);
3571708Sstevel 		new_nodes = NULL;
3581708Sstevel 	}
3591708Sstevel 
3601708Sstevel 	GPTWO_DEBUG1(1, CE_CONT, "gptwo_configure_pci: "
3611708Sstevel 	    "Returning new_nodes=%p\n", new_nodes);
3621708Sstevel 
3631708Sstevel 	return (new_nodes);
3641708Sstevel }
3651708Sstevel 
3661708Sstevel dev_info_t *
gptwo_unconfigure_pci(dev_info_t * dip)3671708Sstevel gptwo_unconfigure_pci(dev_info_t *dip)
3681708Sstevel {
3691708Sstevel 	fco_handle_t fco_handle;
3701708Sstevel 
3711708Sstevel 	fco_handle = gptwocfg_get_handle(dip);
3721708Sstevel 
3731708Sstevel 	if (fco_handle != NULL) {
3741708Sstevel 		/*
3751708Sstevel 		 * If there is a handle, there may be resources
3761708Sstevel 		 * that need to be freed from when the
3771708Sstevel 		 * devices's fcode ran.
3781708Sstevel 		 */
3791708Sstevel 		GPTWO_DEBUG1(1, CE_CONT, "fco_handle=%lx\n", fco_handle);
3801708Sstevel 		gp2_fc_ops_free_handle(fco_handle);
3811708Sstevel 	}
3821708Sstevel 	return (NULL);
3831708Sstevel }
3841708Sstevel 
3851708Sstevel static void
gptwo_find_nodes(dev_info_t * ap,int id,gptwo_new_nodes_t * new_nodes)3861708Sstevel gptwo_find_nodes(dev_info_t *ap, int id, gptwo_new_nodes_t *new_nodes)
3871708Sstevel {
3881708Sstevel 	dev_info_t *saf_dev;
3891708Sstevel 	int found, j, circ;
3901708Sstevel 	int i = 0;
3911708Sstevel 
3921708Sstevel 	GPTWO_DEBUG1(1, CE_CONT, "gptwo_find_nodes - id=%x\n", id);
3931708Sstevel 
3941708Sstevel 	/*
3951708Sstevel 	 * We are walking child list of ap, so hold it busy
3961708Sstevel 	 */
3971708Sstevel 	ndi_devi_enter(ap, &circ);
3981708Sstevel 
3991708Sstevel 	saf_dev = ddi_get_child(ap);
4001708Sstevel 	while (saf_dev != NULL) {
4011708Sstevel 		if (ddi_getprop(DDI_DEV_T_ANY, saf_dev,
4021708Sstevel 		    DDI_PROP_DONTPASS, "portid", -1) == id) {
4031708Sstevel 			if (i < IOBUS_PER_PORT) {
4041708Sstevel 
4051708Sstevel 				GPTWO_DEBUG2(1, CE_CONT,
4061708Sstevel 				    "gptwo_find_nodes - "
4071708Sstevel 				    "Found %d %p\n", i, saf_dev);
4081708Sstevel 
4091708Sstevel 				found = 0;
4101708Sstevel 				for (j = 0; j < IOBUS_PER_PORT; j++) {
4111708Sstevel 					if (new_nodes->gptwo_nodes[j] ==
4121708Sstevel 					    saf_dev) {
4131708Sstevel 						found = 1;
4141708Sstevel 					}
4151708Sstevel 				}
4161708Sstevel 				if (!found) {
4171708Sstevel 					/*
4181708Sstevel 					 * Branch rooted at saf-dev was
4191708Sstevel 					 * held earlier.
4201708Sstevel 					 */
4211708Sstevel 					ASSERT(e_ddi_branch_held(saf_dev));
4221708Sstevel 					new_nodes->gptwo_nodes[i] = saf_dev;
4231708Sstevel 					i++;
4241708Sstevel 				}
4251708Sstevel 			} else {
4261708Sstevel 				GPTWO_DEBUG0(1, CE_CONT,
4271708Sstevel 				    "gptwo_find_nodes - "
4281708Sstevel 				    "No room in new_nodes\n");
4291708Sstevel 			}
4301708Sstevel 		}
4311708Sstevel 		saf_dev = ddi_get_next_sibling(saf_dev);
4321708Sstevel 	}
4331708Sstevel 
4341708Sstevel 	ndi_devi_exit(ap, circ);
4351708Sstevel }
4361708Sstevel 
4371708Sstevel static char *
gptwo_get_probe_string(spcd_t * pcd,int bus_number)4381708Sstevel gptwo_get_probe_string(spcd_t *pcd, int bus_number)
4391708Sstevel {
4401708Sstevel 	int i, str_size;
4411708Sstevel 	char temp[64];
4421708Sstevel 	char num[8];
4431708Sstevel 	char *probe;
4441708Sstevel 
4451708Sstevel 	GPTWO_DEBUG2(1, CE_CONT, "gptwo_get_probe_string - %p %x\n", pcd,
4461708Sstevel 	    bus_number);
4471708Sstevel 
4481708Sstevel 	temp[0] = NULL;
4491708Sstevel 
4501708Sstevel 	for (i = 0; i < IOCARD_PER_BUS; i++) {
4511708Sstevel 
4521708Sstevel 		GPTWO_DEBUG2(1, CE_CONT, "gptwo_get_probe_string - "
4531708Sstevel 		    "card status %x %x\n",
4541708Sstevel 		    i, pcd->spcd_iocard_rsv[bus_number][i]);
4551708Sstevel 
4561708Sstevel 		if (pcd->spcd_iocard_rsv[bus_number][i] == SPCD_RSV_PASS) {
4571708Sstevel 			numtos(i, num);
4581708Sstevel 			if (temp[0] == NULL)
4591708Sstevel 				(void) sprintf(temp, "%s", num);
4601708Sstevel 			else
4611708Sstevel 				(void) sprintf(temp, "%s,%s", temp, num);
4621708Sstevel 		}
4631708Sstevel 	}
4641708Sstevel 
4651708Sstevel 	if (bus_number == 0)
4661708Sstevel 		(void) sprintf(temp, "%sa", temp); /* Append a 'a' for leaf A */
4671708Sstevel 	else
4681708Sstevel 		(void) sprintf(temp, "%sb", temp); /* Append a 'b' for leaf B */
4691708Sstevel 
4701708Sstevel 	str_size = strlen(temp);
4711708Sstevel 
4721708Sstevel 	if (str_size == 0)
4731708Sstevel 		return (NULL);
4741708Sstevel 
4751708Sstevel 	probe = kmem_zalloc(str_size + 1, KM_SLEEP);
4761708Sstevel 
4771708Sstevel 	(void) strcpy(probe, temp);
4781708Sstevel 
4791708Sstevel 	GPTWO_DEBUG1(1, CE_CONT, "gptwo_get_probe_string - Returning %s\n",
4801708Sstevel 	    probe);
4811708Sstevel 
4821708Sstevel 	return (probe);
4831708Sstevel }
4841708Sstevel 
4851708Sstevel #ifdef DEBUG
4861708Sstevel static void
debug(char * fmt,uintptr_t a1,uintptr_t a2,uintptr_t a3,uintptr_t a4,uintptr_t a5)4871708Sstevel debug(char *fmt, uintptr_t a1, uintptr_t a2, uintptr_t a3,
4881708Sstevel 	uintptr_t a4, uintptr_t a5)
4891708Sstevel {
4901708Sstevel 	cmn_err(CE_CONT, fmt, a1, a2, a3, a4, a5);
4911708Sstevel }
4921708Sstevel #endif
493