pci_pci.c revision 69889278ff50c08a6682a39ce6b5d97c5f0c2387
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* PCI to PCI bus bridge nexus driver
*/
#include <sys/autoconf.h>
#include <sys/ddi_impldefs.h>
#include <sys/pci_intr_lib.h>
/*
* The variable controls the default setting of the command register
* for pci devices. See ppb_initchild() for details.
*/
void *, void *);
ddi_intr_handle_impl_t *, void *);
/*
* ppb_support_msi: Flag that controls MSI support across P2P Bridges.
* By default, MSI is not supported. Special case is AMD-8132 chipset.
*
* However, MSI support behavior can be patched on a system by changing
* the value of this flag as shown below:-
* 0 = default value, MSI is allowed only for special case (AMD-8132)
* 1 = MSI supported without any checks
* -1 = MSI not supported at all
*/
int ppb_support_msi = 0;
#define PCI_MSI_MAPPING_CAP_OFF 0xF4
#define PCI_MSI_MAPPING_CAP_MASK 0xFF01000F
#define PCI_MSI_MAPPING_ENABLE 0xA8010008
psm_intr_op_t, int *);
struct bus_ops ppb_bus_ops = {
0,
0,
0,
0, /* (*bus_get_eventcookie)(); */
0, /* (*bus_add_eventcall)(); */
0, /* (*bus_remove_eventcall)(); */
0, /* (*bus_post_event)(); */
0, /* (*bus_intr_ctl)(); */
0, /* (*bus_config)(); */
0, /* (*bus_unconfig)(); */
ppb_fm_init, /* (*bus_fm_init)(); */
NULL, /* (*bus_fm_fini)(); */
NULL, /* (*bus_fm_access_enter)(); */
NULL, /* (*bus_fm_access_exit)(); */
NULL, /* (*bus_power)(); */
ppb_intr_ops /* (*bus_intr_op)(); */
};
/*
* The goal here is to leverage off of the pcihp.c source without making
* changes to it. Call into it's cb_ops directly if needed.
*/
caddr_t, int *);
struct cb_ops ppb_cb_ops = {
ppb_open, /* open */
ppb_close, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
ppb_ioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ppb_prop_op, /* cb_prop_op */
NULL, /* streamtab */
CB_REV, /* rev */
nodev, /* int (*cb_aread)() */
nodev /* int (*cb_awrite)() */
};
static int ppb_probe(dev_info_t *);
DEVO_REV, /* devo_rev */
0, /* refcnt */
ppb_info, /* info */
nulldev, /* identify */
ppb_probe, /* probe */
ppb_attach, /* attach */
ppb_detach, /* detach */
nulldev, /* reset */
&ppb_cb_ops, /* driver operations */
&ppb_bus_ops /* bus operations */
};
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* Type of module */
"PCI to PCI bridge nexus driver %I%",
&ppb_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
(void *)&modldrv,
};
/*
* soft state pointer and structure template:
*/
static void *ppb_state;
typedef struct {
int ppb_fmcap;
/*
* cpr support:
*/
struct {
/*
* forward function declarations:
*/
static void ppb_removechild(dev_info_t *);
int
_init(void)
{
int e;
return (e);
}
int
_fini(void)
{
int e;
if ((e = mod_remove(&modlinkage)) == 0)
return (e);
}
int
{
}
/*ARGSUSED*/
static int
{
return (DDI_PROBE_SUCCESS);
}
/*ARGSUSED*/
static int
{
int instance;
switch (cmd) {
case DDI_ATTACH:
/*
* Make sure the "device_type" property exists.
*/
"device_type", "pci");
/*
* Allocate and get soft state structure.
*/
return (DDI_FAILURE);
/*
* don't enable ereports if immediate child of npe
*/
else
(void *)ppb->ppb_fm_ibc);
(void *)ppb->ppb_fm_ibc);
return (DDI_FAILURE);
}
/*
* Initialize hotplug support on this bus. At minimum
* (for non hotplug bus) this would create ":devctl" minor
* node to support DEVCTL_DEVICE_* and DEVCTL_BUS_* ioctls
* to this bus.
*/
return (DDI_SUCCESS);
case DDI_RESUME:
/*
* Get the soft state structure for the bridge.
*/
return (DDI_SUCCESS);
default:
break;
}
return (DDI_FAILURE);
}
/*ARGSUSED*/
static int
{
switch (cmd) {
case DDI_DETACH:
/*
* And finally free the per-pci soft state.
*/
/*
* Uninitialize hotplug support on this bus.
*/
(void) pcihp_uninit(devi);
return (DDI_SUCCESS);
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
break;
}
return (DDI_FAILURE);
}
/*ARGSUSED*/
static int
{
}
/*ARGSUSED*/
static int
{
int reglen;
int rn;
int totreg;
switch (ctlop) {
case DDI_CTLOPS_REPORTDEV:
if (rdip == (dev_info_t *)0)
return (DDI_FAILURE);
return (DDI_SUCCESS);
case DDI_CTLOPS_INITCHILD:
case DDI_CTLOPS_UNINITCHILD:
return (DDI_SUCCESS);
case DDI_CTLOPS_SIDDEV:
return (DDI_SUCCESS);
case DDI_CTLOPS_REGSIZE:
case DDI_CTLOPS_NREGS:
if (rdip == (dev_info_t *)0)
return (DDI_FAILURE);
break;
case DDI_CTLOPS_PEEK:
case DDI_CTLOPS_POKE:
&ppb->ppb_peek_poke_mutex));
default:
}
*(int *)result = 0;
return (DDI_FAILURE);
if (ctlop == DDI_CTLOPS_NREGS)
else if (ctlop == DDI_CTLOPS_REGSIZE) {
return (DDI_FAILURE);
}
}
return (DDI_SUCCESS);
}
static int
{
char **unit_addr;
uint_t n;
/*
* For .conf nodes, use unit-address property as name
*/
if (ndi_dev_is_persistent_node(child) == 0) {
"cannot find unit-address in %s.conf",
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
return (DDI_SUCCESS);
}
/* get child "reg" property */
return (DDI_FAILURE);
}
/* copy the device identifications */
if (func != 0)
else
return (DDI_SUCCESS);
}
static int
{
struct ddi_parent_private_data *pdptr;
char name[MAXNAMELEN];
return (DDI_FAILURE);
/*
* Pseudo nodes indicate a prototype node with per-instance
* properties to be merged into the real h/w device node.
* The interpretation of the unit-address is DD[,F]
* where DD is the device id and F is the function.
*/
if (ndi_dev_is_persistent_node(child) == 0) {
extern int pci_allow_pseudo_children;
/*
* Try to merge the properties from this prototype
* node into real h/w nodes.
*/
/*
* Merged ok - return failure to remove the node.
*/
return (DDI_FAILURE);
}
/* workaround for ddivs to run under PCI */
return (DDI_SUCCESS);
/*
* The child was not merged into a h/w node,
* but there's not much we can do with it other
* than return failure to cause the node to be removed.
*/
return (DDI_NOT_WELL_FORMED);
}
/* transfer select properties from PROM to kernel */
-1) != -1) {
} else
return (DDI_FAILURE);
/*
* Support for the "command-preserve" property.
*/
DDI_PROP_DONTPASS, "command-preserve", 0);
return (DDI_SUCCESS);
}
static void
{
struct ddi_parent_private_data *pdptr;
}
/*
* Strip the node to properly convert it back to prototype form
*/
}
/*
* ppb_save_config_regs
*
* This routine saves the state of the configuration registers of all
* the child nodes of each PBM.
*
* used by: ppb_detach() on suspends
*
* return value: none
*/
static void
{
int i;
continue;
}
}
ppb_p->config_state_index = i;
}
/*
* ppb_restore_config_regs
*
* This routine restores the state of the configuration registers of all
* the child nodes of each PBM.
*
* used by: ppb_attach() on resume
*
* return value: none
*/
static void
{
int i;
for (i = 0; i < ppb_p->config_state_index; i++) {
continue;
}
}
}
/*
* ppb_intr_ops
*/
static int
{
int types = 0;
if (intr_op != DDI_INTROP_SUPPORTED_TYPES)
"ppb_intr_ops: pdip 0x%p, rdip 0x%p, op %x handle 0x%p\n",
/* Fixed interrupt is supported by default */
*(int *)result = DDI_INTR_TYPE_FIXED;
/* MSI is not allowed */
"or MSI is not allowed\n"));
} else if (ppb_support_msi == 1) {
/* MSI is always allowed */
"ppb_intr_ops: MSI is always allowed\n"));
}
/*
* ppb_support_msi == 0 i.e. by default, MSI is disabled
* Check only for special case like AMD8132 which supports MSI
*/
PCI_CONF_DEVID) == PCI_DEVID_8132)) {
/* make sure MSI enable bit is on */
if ((msi_mapping & PCI_MSI_MAPPING_CAP_MASK) ==
/* MSI/X is enable */
"MSI is allowed for AMD8132\n"));
== DDI_SUCCESS) {
sizeof (ddi_intr_handle_impl_t));
}
}
}
}
"ppb_intr_ops: rdip 0x%p, returns supported types: 0x%x\n",
return (DDI_SUCCESS);
}
static int
{
}
static int
{
}
static int
{
rvalp));
}
static int
{
}
static int
{
}
/*ARGSUSED*/
static int
{
}
/*ARGSUSED*/
static int
{
return (derr->fme_status);
}