gptwo_pci.c revision f500b19684bd0346ac05bec02a50af07f369da1a
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
*/
#include <sys/autoconf.h>
#include <sys/ndi_impldefs.h>
#include <sys/ddi_impldefs.h>
#include <sys/machsystm.h>
#include <sys/gptwo_pci.h>
#ifdef DEBUG
int gptwo_pci_debug = 0;
if (gptwo_pci_debug >= level) \
#else
#endif
void gptwocfg_devi_attach_to_parent(dev_info_t *);
static char *gptwo_get_probe_string(spcd_t *, int);
extern caddr_t efcode_vaddr;
extern int efcode_size;
/*
* Module linkage information for the kernel.
*/
extern struct mod_ops mod_miscops;
&mod_miscops, /* Type of module */
"gptwo->pci configurator",
};
static struct modlinkage modlinkage = {
};
int
_init(void)
{
int err = 0;
/*
* Create a resource map for the contigous memory allocated
* at start-of-day in startup.c
*/
== NDI_FAILURE) {
"Can not setup resource map - gptwo-contigousmem\n");
return (1);
}
/*
* Put the allocated memory into the pool.
*/
/* register devices with the configurator */
"failed to load, error=%d\n", err);
} else {
"has been loaded.\n");
}
return (err);
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
int
{
}
/*ARGSUSED*/
static int
{
return (DDI_WALK_ERROR);
}
return (DDI_WALK_TERMINATE);
}
/*ARGSUSED*/
static void
{
}
{
char unit_address[64];
char *probe_string;
devi_branch_t b = {0};
i = IOBUS_PER_PORT;
while (i) {
i--;
"leaf %d - Can not be probed\n", id, i);
continue;
}
/*
* Ideally, fcode would be run from the "sid_branch_create"
* callback (that is the primary purpose of that callback).
* However, the fcode interpreter was written with the
* assumption that the "new_child" was linked into the
* device tree. The callback is invoked with the devinfo node
* in the DS_PROTO state. More investigation is needed before
* we can invoke the interpreter from the callback. For now,
* we create the "new_child" in the BOUND state, invoke the
* fcode interpreter and then rebind the dip to use any
* compatible properties created by fcode.
*/
b.type = DEVI_BRANCH_SID;
/*
* Prevent any changes to new_child
* until we have bound it to the correct driver.
*/
"No nodes configured - "
"removing new_nodes\n");
}
return (new_nodes);
}
/*
* The platform DR interfaces created the dip in
* bound state. Bring devinfo node down to linked
* state and hold it there until compatible
* properties are created.
*/
/*
* Drop the busy-hold on parent before calling
* fcode_interpreter to prevent potential deadlocks
*/
/*
* Build the probe string from the PCD that will be passed
* in to the interpreter as my-args. This will tell the
* fcode what pci devices to probe after the pci node has
* been probed.
*/
"interpreter ap=%lx new_child=%lx unit_address=%s\n",
if (probe_string)
"probe string=%s\n", probe_string);
"gptwocfg: Calling Fcode Interpeter...\n");
"gptwo_configure_pci: fcode_interpreter "
" returned %x\n", error);
if (error) {
"%s\n", unit_address);
} else {
/*
* Compatible properties (if any) have been created,
* so bind driver.
*/
if (ndi_devi_bind_driver(new_child, 0) !=
DDI_SUCCESS) {
" new pci child at dip=0x%p\n",
}
/*
* If POST provided a frequency, the clock-frequency
* property needs to be updated.
*/
if (pcd->spcd_afreq) {
/*
* The upper byte is for leaf B and the lower
* byte is for leaf A.
*/
if (i)
else
(void) ndi_prop_update_int(DDI_DEV_T_NONE,
new_child, "clock-frequency",
}
}
}
"No nodes configured - removing new_nodes\n");
}
"Returning new_nodes=%p\n", new_nodes);
return (new_nodes);
}
{
if (fco_handle != NULL) {
/*
* If there is a handle, there may be resources
* that need to be freed from when the
* devices's fcode ran.
*/
}
return (NULL);
}
static void
{
int i = 0;
/*
* We are walking child list of ap, so hold it busy
*/
if (i < IOBUS_PER_PORT) {
"gptwo_find_nodes - "
"Found %d %p\n", i, saf_dev);
found = 0;
for (j = 0; j < IOBUS_PER_PORT; j++) {
if (new_nodes->gptwo_nodes[j] ==
saf_dev) {
found = 1;
}
}
if (!found) {
/*
* Branch rooted at saf-dev was
* held earlier.
*/
i++;
}
} else {
"gptwo_find_nodes - "
"No room in new_nodes\n");
}
}
}
}
static char *
{
int i, str_size;
char temp[64];
char num[8];
char *probe;
for (i = 0; i < IOCARD_PER_BUS; i++) {
"card status %x %x\n",
else
}
}
if (bus_number == 0)
else
if (str_size == 0)
return (NULL);
probe);
return (probe);
}
#ifdef DEBUG
static void
{
}
#endif