px.c revision 13683ea2d517595c5ea2c90934fd074d24671646
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * CDDL HEADER START
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * The contents of this file are subject to the terms of the
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Common Development and Distribution License (the "License").
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * You may not use this file except in compliance with the License.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * See the License for the specific language governing permissions
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * and limitations under the License.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * When distributing Covered Code, include this CDDL HEADER in each
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * If applicable, add the following below this CDDL HEADER, with the
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * fields enclosed by brackets "[]" replaced with your own identifying
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * information: Portions Copyright [yyyy] [name of copyright owner]
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * CDDL HEADER END
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
62ecec3a82a8b838ee76c1f6610902d8fd7015cbmatthew_swift * Use is subject to license terms.
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma#pragma ident "%Z%%M% %I% %E% SMI"
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * PCI Express nexus driver interface
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/*LINTLIBRARY*/
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * function prototypes for dev ops routines:
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnstatic int px_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnstatic int px_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnstatic int px_info(dev_info_t *dip, ddi_info_cmd_t infocmd,
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * function prototypes for hotplug routines:
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbnstatic uint_t px_uninit_hotplug(dev_info_t *dip);
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * bus ops and dev ops structures:
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * module definitions:
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma/* driver soft state */
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * Initialize per-px bus soft state pointer.
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma e = ddi_soft_state_init(&px_state_p, sizeof (px_t), 1);
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma return (e);
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * Install the module.
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma return (e);
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * Remove the module.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Destroy pci_target_queue, and set it to NULL.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn /* Free px soft state */
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma/* ARGSUSED */
6df86604699d401d24863654538c078d3750963ashankar_mbnpx_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Allow hotplug to deal with ones it manages
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Hot Plug will be done later.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn if (px_p && (px_p->px_dev_caps & PX_HOTPLUG_CAPABLE))
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma /* non-hotplug or not attached */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn/* device driver entry points */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * attach entry point:
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma/*ARGSUSED*/
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Allocate and get the per-px soft state structure.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn mutex_init(&px_p->px_mutex, NULL, MUTEX_DRIVER, NULL);
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn (void) ddi_prop_update_string(DDI_DEV_T_NONE, dip,
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * Get key properties of the pci bridge node and
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * determine it's type (psycho, schizo, etc ...).
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn if (px_lib_dev_init(dip, &dev_hdl) != DDI_SUCCESS)
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma /* Initialize device handle */
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * Initialize interrupt block. Note that this
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * initialize error handling for the PEC as well.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * Start creating the modules.
a585e5e48b946aa1de0f69a97853291aa519b8c7ludo * Note that attach() routines should
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * register and enable their own interrupts.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn goto err_bad_dma; /* nothing to uninitialize on DMA */
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * All of the error handlers have been registered
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * by now so it's time to activate the interrupt.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn if ((ret = px_err_add_intr(&px_p->px_fault)) != DDI_SUCCESS)
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * Create the "devctl" node for hotplug and pcitool support.
9def8137e705ec92bc3a2881a8457795c860fdb1shankar_mbn * For non-hotplug bus, we still need ":devctl" to
b3d0736ce9ff54f95fc06741c7279172f961363fshankar_mbn * support DEVCTL_DEVICE_* and DEVCTL_BUS_* ioctls.
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * power management setup. Even if it fails, attach will
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * succeed as this is a optional feature. Since we are
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * always at full power, this is not critical.
f30ee734ac0ee8b792c77ab3bc42494fcddb1508hajma * add cpr callback
case DDI_RESUME:
return (ret);
int ret;
return (DDI_FAILURE);
switch (cmd) {
case DDI_DETACH:
return (DDI_FAILURE);
int len;
return (DDI_SUCCESS);
case DDI_SUSPEND:
return (DDI_FAILURE);
return (ret);
return (DDI_FAILURE);
return (DDI_FAILURE);
DDI_KERNEL_IOCTL)) {
return (DDI_FAILURE);
goto pwr_setup_err1;
goto px_pwrsetup_err_state;
return (DDI_SUCCESS);
return (DDI_FAILURE);
return (DDI_ME_UNIMPLEMENTED);
case DDI_MT_REGSPEC:
case DDI_MT_RNUMBER:
return (DDI_ME_RNUMBER_RANGE);
return (DDI_ME_RNUMBER_RANGE);
return (DDI_ME_INVAL);
return (DDI_ME_INVAL);
goto done;
goto done;
goto done;
done:
return (rval);
int ret;
return (DDI_DMA_NORESOURCES);
return (DDI_DMA_NOMAPPING);
goto freehandle;
goto freehandle;
goto freehandle;
goto freehandle;
goto freehandle;
case PX_DMAI_FLAGS_BYPASS:
return (ret);
int rval;
return (DDI_DMA_BADATTR);
return (DDI_DMA_NORESOURCES);
return (rval);
return (DDI_SUCCESS);
if (px_kmem_clid) {
return (DDI_SUCCESS);
int ret;
return (DDI_DMA_INUSE);
goto err;
goto err;
case PX_DMAI_FLAGS_DVMA:
goto map_err;
goto map_err;
case PX_DMAI_FLAGS_BYPASS:
case PX_DMAI_FLAGS_PTP:
goto map_err;
*cookiep =
err:
return (ret);
return (DDI_FAILURE);
case PX_DMAI_FLAGS_DVMA:
case PX_DMAI_FLAGS_BYPASS:
case PX_DMAI_FLAGS_PTP:
if (px_kmem_clid) {
return (DDI_SUCCESS);
int ret;
return (DDI_FAILURE);
case PX_DMAI_FLAGS_DVMA:
/* map_window sets dmai_mapping/size/offset */
return (ret);
if (cookiep)
if (ccountp)
case PX_DMAI_FLAGS_PTP:
case PX_DMAI_FLAGS_BYPASS: {
if (ccountp)
return (DDI_FAILURE);
if (cookiep)
if (offp)
if (lenp)
return (DDI_SUCCESS);
#ifdef DEBUG
static char *px_dmactl_str[] = {
#ifdef DEBUG
switch (cmd) {
case DDI_DMA_FREE:
return (DDI_SUCCESS);
case DDI_DMA_RESERVE: {
case DDI_DMA_RELEASE: {
case PX_DMAI_FLAGS_DVMA:
cache_flags));
case PX_DMAI_FLAGS_PTP:
case PX_DMAI_FLAGS_BYPASS:
cache_flags));
switch (op) {
case DDI_CTLOPS_INITCHILD:
case DDI_CTLOPS_UNINITCHILD:
case DDI_CTLOPS_ATTACH:
case DDI_PRE:
DDI_SUCCESS) {
return (DDI_SUCCESS);
case DDI_POST:
return (DDI_SUCCESS);
case DDI_CTLOPS_DETACH:
case DDI_POST:
return (DDI_SUCCESS);
case DDI_CTLOPS_REPORTDEV:
case DDI_CTLOPS_IOMIN:
return (DDI_SUCCESS);
case DDI_CTLOPS_REGSIZE:
case DDI_CTLOPS_NREGS:
return (DDI_SUCCESS);
case DDI_CTLOPS_DVMAPAGESIZE:
return (DDI_SUCCESS);
case DDI_CTLOPS_POWER:
DDI_INTR_TYPE_FIXED : 0;
return (ret);
case DDI_INTR_TYPE_FIXED:
case DDI_INTR_TYPE_MSI:
case DDI_INTR_TYPE_MSIX:
return (ret);
static uint_t
return (DDI_FAILURE);
#ifdef DEBUG
!= DDI_PROP_SUCCESS) {
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);
static uint_t
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);