cardbus.c revision 0d282d1376eb7ba06504448622a6d65726e4bd3e
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * CDDL HEADER START
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * The contents of this file are subject to the terms of the
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Common Development and Distribution License (the "License").
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * You may not use this file except in compliance with the License.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * See the License for the specific language governing permissions
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * and limitations under the License.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * When distributing Covered Code, include this CDDL HEADER in each
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * If applicable, add the following below this CDDL HEADER, with the
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * fields enclosed by brackets "[]" replaced with your own identifying
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * information: Portions Copyright [yyyy] [name of copyright owner]
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * CDDL HEADER END
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Use is subject to license terms.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Copyright (c) * Copyright (c) 2001 Tadpole Technology plc
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * All rights reserved.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * From "@(#)pcicfg.c 1.31 99/06/18 SMI"
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#pragma ident "%Z%%M% %I% %E% SMI"
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Cardbus module
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_command_default = PCI_COMM_SERR_ENABLE |
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_count = 0;
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_bus_map(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ddi_map_req_t *mp, off_t offset, off_t len, caddr_t *vaddrp);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic void pcirp2rp(const pci_regspec_t *pci_rp, struct regspec *rp);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic void cardbus_init_child_regs(dev_info_t *child);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_initchild(dev_info_t *, dev_info_t *,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_name_child(dev_info_t *, char *, int);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_dma_allochdl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_dma_flush(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_dma_win(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_dma_map(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_prop_op(dev_t dev, dev_info_t *dip, dev_info_t *ch_dip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_get_eventcookie(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ddi_eventcookie_t cookie, void (*callback)(dev_info_t *dip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ddi_eventcookie_t cookie, void *arg, void *bus_impldata),
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_remove_eventcall(dev_info_t *dip, ddi_callback_id_t cb_id);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_post_event(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_intr_ops(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic char *find_token(char **cp, int *l, char *endc);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int token_to_hex(char *token, unsigned *val, int len);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int token_to_dec(char *token, unsigned *val, int len);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic void cardbus_add_prop(struct cb_deviceset_props *cdsp, int type,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic void cardbus_add_stringprop(struct cb_deviceset_props *cdsp,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic void cardbus_devprops_free(struct cb_deviceset_props *cbdp);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_parse_devprop(cbus_t *cbp, char *cp);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_convert_properties(dev_info_t *dip);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic void cardbus_revert_properties(dev_info_t *dip);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * driver global data
3db86aab554edbb4244c8d1a1c90f152eee768afstevelkmutex_t cardbus_list_mutex; /* Protects the probe handle list */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Module linkage information for the kernel.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "Cardbus Configurator support %I%",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel error = ddi_soft_state_init(&cardbus_state, sizeof (cbus_t), 0);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel mutex_init(&cardbus_list_mutex, NULL, MUTEX_DRIVER, NULL);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_get_eventcookie, /* (*bus_get_eventcookie)(); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_remove_eventcall, /* (*bus_remove_eventcall)(); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel { CB_EVENT_TAG_INSERT, DDI_DEVI_INSERT_EVENT, EPL_INTERRUPT, 0 },
3db86aab554edbb4244c8d1a1c90f152eee768afstevel { CB_EVENT_TAG_REMOVE, DDI_DEVI_REMOVE_EVENT, EPL_INTERRUPT, 0 }
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (sizeof (cb_ndi_event_defs) / sizeof (cb_ndi_event_defs[0]))
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* check if this is a PCI bus node */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_prop_op(DDI_DEV_T_ANY, dip, PROP_LEN_AND_VAL_BUF,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "device_type",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (0); /* (DDI_WALK_PRUNECHILD); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (strcmp(bus_type, "pciex") != 0)) /* it is not a pci bus type */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (0); /* (DDI_WALK_PRUNECHILD); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* look for the bus-range property */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_getlongprop_buf(DDI_DEV_T_NONE, dip, DDI_PROP_DONTPASS,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "bus-range", (caddr_t)&pci_bus_range, &len) == DDI_SUCCESS) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(dip, 1, "cardbus_claim_pci_busnum: %u -> %u \n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_claim_pci_busnum: claim %u -> %u \n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* claim the bus range from the bus resource map */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (0); /* (DDI_WALK_PRUNECHILD); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * never Error return.
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic void cardbus_fix_hostbridge_busrange(dev_info_t *dip)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(dip, 1, "cardbus_fix_hostbridge_busrange\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) ndi_ra_map_destroy(dip, NDI_RA_TYPE_PCI_BUSNUM);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(dip, 1, "cardbus_fix_hostbridge_busrange "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "NDI_RA_TYPE_PCI_BUSNUM setup fail\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel DDI_PROP_DONTPASS, "bus-range", (caddr_t)&bus_range, &len);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_walk_node_child(dip, cardbus_claim_pci_busnum,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(dip, 1, "cardbus_fix_hostbridge_busrange "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_walk_node_child fails\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, dip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(dip, 1, "cardbus_fix_hostbridge_busrange "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#endif /* sparc */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Attach a device to the cardbus infrastructure.
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_attach(dev_info_t *dip, cb_nexus_cb_t *nex_ops)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Make sure that it is not already initialized.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "%s%d: cardbus instance already initialized!\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * initialize soft state structure for the bus instance.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_soft_state_zalloc(cardbus_state, cb_instance) != DDI_SUCCESS) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cmn_err(CE_WARN, "%s%d: can't allocate cardbus soft state\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp = (cbus_t *)ddi_get_soft_state(cardbus_state, cb_instance);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel mutex_init(&cbp->cb_mutex, NULL, MUTEX_DRIVER, NULL);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Save the instance number of the soft state structure for
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * this bus as a devinfo property.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "%s%d: failed to add the property 'cbus-instance'",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * TODO - Should probably be some sort of locking on the devinfo here.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ndi_event_alloc_hdl(dip, *anp->an_iblock, &cbp->cb_ndi_event_hdl,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp->cb_ndi_events.ndi_events_version = NDI_EVENTS_REV1;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp->cb_ndi_events.ndi_event_defs = cb_ndi_event_defs;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_attach: ndi_event_bind_set failed\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Check for device initialization property.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* a hack to fix the bus-range problem on pci root nodes */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* get the instance number for the cardbus soft state data */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (DDI_FAILURE); /* no instance is setup for this bus */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp = (cbus_t *)ddi_get_soft_state(cardbus_state, cb_instance);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Unregister the bus with the HPS.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * (Note: It is assumed that the HPS framework uninstalls
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * event handlers for all the hot plug slots on this bus.)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_free(cbp->nexus_path, strlen(cbp->nexus_path) + 1);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* remove the 'cbus-instance' property from the devinfo node */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) ddi_prop_remove(DDI_DEV_T_ANY, dip, "cbus-instance");
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_load_cardbus(dev_info_t *dip, uint_t socket, uint32_t pc_base)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp = (cbus_t *)ddi_get_soft_state(cardbus_state, cb_instance);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * The child of the dip is the cardbus dip. The child of the
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * cardbus dip is the device itself
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(dip, 8, "cardbus_load_cardbus: calling cbus_configure\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ddi_walk_devs(ddi_get_child(dip), cbus_configure, (void *)&ctrl);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_load_cardbus (%s%d): failed to attach (%d)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Returning error here will cause the pcic_load_cardbus() call
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * to fail. This will invoke pcic_unload_cardbus() which calls
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * cardbus_unload_cardbus() below.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(dip, 7, "cardbus_load_cardbus: returning TRUE\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Unload the cardbus module
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp = (cbus_t *)ddi_get_soft_state(cardbus_state, cb_instance);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_unload_cardbus: calling cardbus_unconfigure_node\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel rval = cardbus_unconfigure_node(dip, prim_bus, B_TRUE);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_unload_cardbus: "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_unconfigure_node failed\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus(%s%d): Failed to remove device tree: "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "Slot disabled",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Inform the lower drivers that the card has been removed
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ndi_event_retrieve_cookie(cbp->cb_ndi_event_hdl, dip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) ndi_event_run_callbacks(cbp->cb_ndi_event_hdl,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp = (cbus_t *)ddi_get_soft_state(cardbus_state, cb_instance);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "failed to update #address-cells property\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "failed to update #size-cells property\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_getlongprop(DDI_DEV_T_NONE, dip, DDI_PROP_DONTPASS, "available",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (caddr_t)&pcic_avail_p, &avail_len) != DDI_PROP_SUCCESS) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "no available property for pcmcia\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel avail_entries = avail_len / sizeof (struct pcm_regs);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cb_avail_p = kmem_alloc(sizeof (pci_regspec_t) * avail_entries,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel for (i = 0; i < avail_entries;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, dip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "available",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (sizeof (pci_regspec_t) * avail_entries)/sizeof (int));
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_free(cb_avail_p, sizeof (pci_regspec_t) * avail_entries);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_getlongprop(DDI_DEV_T_NONE, dip, DDI_PROP_DONTPASS, "ranges",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (caddr_t)&pcic_range_p, &range_len) != DDI_PROP_SUCCESS) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "no ranges property for pcmcia\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel for (i = 0; i < range_entries;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, dip, "ranges",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (sizeof (cardbus_range_t) * range_entries)/sizeof (int));
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_free(cb_range_p, sizeof (cardbus_range_t) * range_entries);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) ndi_prop_remove(DDI_DEV_T_NONE, dip, "#address-cells");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) ndi_prop_remove(DDI_DEV_T_NONE, dip, "#size-cells");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) ndi_prop_remove(DDI_DEV_T_NONE, dip, "available");
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_prop_op(dev_t dev, dev_info_t *dip, dev_info_t *ch_dip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_prop_op(%s) (dip=0x%p, op=%d, name=%s)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ddi_driver_name(ch_dip), (void *) dip, prop_op, name);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (impl_ddi_bus_prop_op(dev, dip, ch_dip, prop_op,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_ctlops(%p, %p, %d, %p, %p)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *)dip, (void *)rdip, ctlop, (void *)arg, (void *)result);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Do Nothing
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_ctlops: Unsupported DDI_CTLOP %d\n", ctlop);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel case DDI_CTLOPS_SLAVEONLY: /* see ddi_slaveonly(9F) */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel *(int *)result = 0;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * If we are using the streaming cache, align at
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * least on a cache line boundary. Otherwise use
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * whatever alignment is passed in.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (cardbus_initchild(rdip, dip, (dev_info_t *)arg,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_ctlops: PCCard socket %d at %s@%s\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "Bus %3d Device %2d Function %2d",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel const char *name;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel *(int *)result = 0;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_ctlops, returning REGSIZE(%d) = %d\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Map the child configuration space to for initialization.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Set the latency-timer register to values appropriate
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * for the devices on the bus (based on other devices
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * MIN_GNT and MAX_LAT registers.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Set the fast back-to-back enable bit in the command
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * register if it's supported and all devices on the bus
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * have the capability.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (pci_config_setup(child, &config_handle) != DDI_SUCCESS)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(child, 6, "cardbus_init_child_regs()\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Determine the configuration header type.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel header_type = pci_config_get8(config_handle, PCI_CONF_HEADER);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Support for "command-preserve" property. Note that we
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * add PCI_COMM_BACK2BACK_ENAB to the bits to be preserved
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * since the obp will set this if the device supports and
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * all targets on the same bus support it. Since psycho
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * doesn't support PCI_COMM_BACK2BACK_ENAB, it will never
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * be set. This is just here in case future revs do support
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * PCI_COMM_BACK2BACK_ENAB.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel command_preserve = ddi_prop_get_int(DDI_DEV_T_ANY, child,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "command-preserve", 0);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel command = pci_config_get16(config_handle, PCI_CONF_COMM);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel command &= (command_preserve | PCI_COMM_BACK2BACK_ENAB);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel command |= (cardbus_command_default & ~command_preserve);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel pci_config_put16(config_handle, PCI_CONF_COMM, command);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel command = pci_config_get16(config_handle, PCI_CONF_COMM);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * If the device has a bus control register then program it
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * based on the settings in the command register.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if ((header_type & PCI_HEADER_TYPE_M) == PCI_HEADER_ONE) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel bcr = pci_config_get8(config_handle, PCI_BCNF_BCNTRL);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (cardbus_command_default & PCI_COMM_PARITY_DETECT)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel pci_config_put8(config_handle, PCI_BCNF_BCNTRL, bcr);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Initialize cache-line-size configuration register if needed.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_getprop(DDI_DEV_T_ANY, child, DDI_PROP_DONTPASS,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cache-line-size", 0) == 0) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel pci_config_put8(config_handle, PCI_CONF_CACHE_LINESZ,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel n = pci_config_get8(config_handle, PCI_CONF_CACHE_LINESZ);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (n != 0)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cache-line-size", n);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Initialize latency timer registers if needed.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_getprop(DDI_DEV_T_ANY, child, DDI_PROP_DONTPASS,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "latency-timer", 0) == 0) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if ((header_type & PCI_HEADER_TYPE_M) == PCI_HEADER_ONE) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel pci_config_put8(config_handle, PCI_BCNF_LATENCY_TIMER,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Cardbus os only 33Mhz
3db86aab554edbb4244c8d1a1c90f152eee768afstevel pci_config_put8(config_handle, PCI_CONF_LATENCY_TIMER,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel n = pci_config_get8(config_handle, PCI_CONF_LATENCY_TIMER);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (n != 0)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "latency-timer", n);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_initchild(dev_info_t *rdip, dev_info_t *dip, dev_info_t *child,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Name the child
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (cardbus_name_child(child, name, MAXNAMELEN) != DDI_SUCCESS)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Try to merge the properties from this prototype
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * node into real h/w nodes.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ndi_merge_node(child, cardbus_name_child) == DDI_SUCCESS) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Merged ok - return failure to remove the node.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * The child was not merged into a h/w node,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * but there's not much we can do with it other
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * than return failure to cause the node to be removed.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cmn_err(CE_WARN, "!%s@%s: %s.conf properties not merged",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if ((cop == NULL) || (!(cop->cb_flag & D_HOTPLUG))) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cmn_err(CE_WARN, "%s: driver doesn't support HOTPLUG\n", dname);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Create ppd if needed.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_zalloc(sizeof (struct cardbus_parent_private_data),
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_zalloc(sizeof (struct cardbus_parent_private_data)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (ppd->ppd.par_intr)->intrspec_func = (uint_t (*)()) 0;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_getprop(DDI_DEV_T_NONE, child, DDI_PROP_DONTPASS,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_initchild: Creating empty ppd\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_name_child(dev_info_t *child, char *name, int namelen)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Pseudo nodes indicate a prototype node with per-instance
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * properties to be merged into the real h/w device node.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * The interpretation of the unit-address is DD[,F]
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * where DD is the device id and F is the function.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_prop_lookup_string_array(DDI_DEV_T_ANY, child,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "unit-address", &unit_addr, &n) != DDI_PROP_SUCCESS) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (n != 1 || *unit_addr == NULL || **unit_addr == 0) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Get the address portion of the node name based on
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * the function and device number.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, child, DDI_PROP_DONTPASS,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void) snprintf(name, namelen, "%x,%x", device, func);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_name_child: system init done [%x][%x][%x]"
3db86aab554edbb4244c8d1a1c90f152eee768afstevel " for %s [%s] nodeid: %x @%s\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ppd = (struct cardbus_parent_private_data *)ddi_get_parent_data(dip);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_free(ppd, sizeof (struct cardbus_parent_private_data));
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_free(ppd, sizeof (struct cardbus_parent_private_data) +
3db86aab554edbb4244c8d1a1c90f152eee768afstevel sizeof (struct intrspec));
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_removechild: ddi_set_parent_data(NULL)\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic cb_props_parse_tree_t cb_props_parse_tree[] = {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (token[0] == '0' && token[2] && (token[1] == 'x' || token[1] ==
3db86aab554edbb4244c8d1a1c90f152eee768afstevel while (c = *token++) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic char *
3db86aab554edbb4244c8d1a1c90f152eee768afstevel int k = sizeof (cb_props_parse_tree) /
3db86aab554edbb4244c8d1a1c90f152eee768afstevel while (k--) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (token[0] == '0' && (token[1] == 'x' || token[1] == 'X')) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (1);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (0);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (c >= 'A')
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (1);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (1);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (0);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (1);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_add_prop(struct cb_deviceset_props *cdsp, int type, char *name,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel propp = (ddi_prop_t *)kmem_zalloc(sizeof (ddi_prop_t), KM_SLEEP);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel propp->prop_name = (char *)kmem_alloc(pnlen, KM_SLEEP);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_add_stringprop(struct cb_deviceset_props *cdsp, char *name,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_add_prop(cdsp, DDI_PROP_TYPE_STRING, name, (caddr_t)nstr,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_free(propp->prop_name, strlen(propp->prop_name) + 1);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_devprops_free(struct cb_deviceset_props *cbdp)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_free(cbdp->nodename, strlen(cbdp->nodename) + 1);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmem_free(cbdp->binding_name, strlen(cbdp->binding_name) +
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Format of "cb-device-init-props" property:
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Anything before the semi-colon is an identifying equate, anything
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * after the semi-colon is a setting equate.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * "binding_name=xXxXxX VendorID=NNNN DeviceID=NNNN; nodename=NewName
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Prop=PropVal"
3db86aab554edbb4244c8d1a1c90f152eee768afstevel int state = PT_STATE_TOKEN, qm = 0, em = 0, smc = 0, l = 0;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cdsp = (struct cb_deviceset_props *)kmem_zalloc(sizeof (*cdsp),
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Check for escaped characters
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "escape not allowed outside "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel } /* if (!qm) */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel } /* PARSE_ESCAPE */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Check for quoted strings
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_parse_devprop: "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "unexpected string [%s] after "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel } /* if (qm) */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel } /* PARSE_QUOTE */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Check for tokens
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_parse_devprop: "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "unknown token [%s]\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel } /* switch (parse_token) */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel sizeof (int)*tl,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel sizeof (int)*tl);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel sizeof (int)*tl,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel sizeof (int)*tl);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "unknown state machine state = %d\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel } /* switch (state) */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel } /* while (*cp) */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cmn_err(CE_CONT, "cb_props_parse_line: unterminated "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cmn_err(CE_CONT, "cardbus_parse_devprop: token [%s] "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "requires VendorID and DeviceID\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_prop_lookup_string_array(DDI_DEV_T_ANY, cbp->cb_dip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel for (i = 0; i < n; i++)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#define BUSTYPE_TO_PFN(btype, pfn) (((btype) << 19) | ((pfn) & 0x7FFFF))
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_rootnex_map_regspec(ddi_map_req_t *mp, caddr_t *vaddrp,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* base addr */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel base = (ulong_t)rp->regspec_addr & (~MMU_PAGEOFFSET);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Take the bustype and the physical page base within the
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * bus space and turn it into a 28 bit page frame number.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel pfn = BUSTYPE_TO_PFN(rp->regspec_bustype, mmu_btop(base));
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Do a quick sanity check to make sure we are in I/O space.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_rootnex_map_regspec: zero regspec_size\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel pgoffset = (ulong_t)rp->regspec_addr & MMU_PAGEOFFSET;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_rootnex_map_regspec: "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "Mapping %lu pages physical %x.%lx ",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kaddr = vmem_alloc(heap_arena, ptob(npages), VM_NOSLEEP);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Now map in the pages we've allocated...
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_rootnex_map_regspec: at virtual %p\n", (void *)*vaddrp);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (0);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_rootnex_unmap_regspec(ddi_map_req_t *mp, caddr_t *vaddrp)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (0);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_rootnex_unmap_regspec: zero regspec_size\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel hat_unload(kas.a_hat, base, ptob(npages), HAT_UNLOAD_UNLOCK);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Destroy the pointer - the mapping has logically gone
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (0);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Set up the hat_flags for the mapping.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel hp->ah_pfn = mmu_btop((ulong_t)rp->regspec_addr & (~MMU_PAGEOFFSET));
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_rootnex_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ddi_map_req_t mr = *mp; /* Get private copy of request */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_rootnex_map: unimplemented map op %d.",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_rootnex_map: unimplemented map type: user.");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * First, if given an rnumber, convert it to a regspec...
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * (Presumably, this is on behalf of a child of the root node)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_rootnex_map: Out of "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "range rnumber <%d>, device <%s>",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Convert the given ddi_map_req_t from rnumber to regspec...
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Adjust offset and length correspnding to called values...
3db86aab554edbb4244c8d1a1c90f152eee768afstevel tmp_reg = *(mp->map_obj.rp); /* Preserve underlying data */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel rp = mp->map_obj.rp = &tmp_reg; /* Use tmp_reg in request */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Apply any parent ranges at this level, if applicable.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * (This is where nexus specific regspec translation takes place.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Use of this function is implicit agreement that translation is
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * provided via ddi_apply_range.)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_rootnex_map: applying range of parent "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "<%s> to child <%s>...\n", ddi_get_name(dip), ddi_get_name(rdip));
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if ((error = i_ddi_apply_range(dip, rdip, mp->map_obj.rp)) != 0)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Set up the locked down kernel mapping to the regspec...
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * If we were passed an access handle we need to determine
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * the "endian-ness" of the mapping and fill in the handle.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Set up the mapping.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel error = cardbus_rootnex_map_regspec(mp, vaddrp, mapping_attr);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Fill in the access handle if needed.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Release mapping...
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * dip an ancestor of rdip. Allocate space on dip for rdip
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel register dev_info_t *pdip = (dev_info_t *)DEVI(dip)->devi_parent;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_bus_map(dip=0x%p, rdip=0x%p)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* A child has asked us to set something up */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_bus_map(%s) calling %s - 0x%p, "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "offset 0x%x, len 0x%x\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *) DEVI(pdip)->devi_ops->devo_bus_ops->bus_map,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* rc = ddi_map(dip, mp, offset, len, vaddrp); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(rdip, 8, "cardbus_bus_map failed, rc = %d\n", rc);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * I think this is bogus. You will never get a length of
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * zero if the lookup succeeds.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (length == 0) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* cardbus_dump_reg(rdip, pci_rp, length); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* config space should have mapped in OK earlier */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* use as offset into assigned-addresses not reg */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "regspec: bustype 0x%x, addr 0x%x, size 0x%x\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel rc = cardbus_rootnex_map(dip, rdip, &p_map_request, 0, 0,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_bus_map(regspec): ddi_map failed, "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_bus_map(regspec): ddi_map OK\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevelpcirp2rp(const pci_regspec_t *pci_rp, struct regspec *rp)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* bus = PCI_REG_BUS_G(pci_rp->pci_phys_hi); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* memory */
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_allochdl(dip=0x%p, rdip=0x%p)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_allochdl calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *) DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_allochdl);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (ddi_dma_allochdl(dip, rdip, attr, waitfp, arg, handlep));
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_freehdl(dip=0x%p, rdip=0x%p)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_freehdl calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *) DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_freehdl);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_bindhdl(dip=0x%p, rdip=0x%p)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_bindhdl calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *) DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_bindhdl);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_bindhdl(pdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_unbindhdl(dip=0x%p, rdip=0x%p)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_unbindhdl calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *) DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_unbindhdl);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_unbindhdl(pdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_flush(dip=0x%p, rdip=0x%p)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_flush calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *) DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_flush);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_flush(pdip, rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_win(dip=0x%p, rdip=0x%p)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_win calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *) DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_win);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_win(pdip, rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_map(dip=0x%p, rdip=0x%p)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_dma_map calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *) DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_map);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (DEVI(pdip)->devi_ops->devo_bus_ops->bus_dma_map(pdip, rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_get_eventcookie(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * get the soft state structure for the bus instance.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp = (cbus_t *)ddi_get_soft_state(cardbus_state, cb_instance);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(dip, 6, "cardbus_get_eventcookie %s\n", eventname);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * We can't handle up (probably called at the attachment
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * point) so pass it on up
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_get_eventcookie calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel DEVI(pdip)->devi_ops->devo_bus_ops->bus_get_eventcookie);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel bus_get_eventcookie(pdip, rdip, eventname, cookiep));
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_get_eventcookie calling ndi_event_retrieve_cookie\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel rc = ndi_event_retrieve_cookie(cbp->cb_ndi_event_hdl, rdip, eventname,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_get_eventcookie rc %d cookie %p\n", rc, (void *)*cookiep);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_add_eventcall(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ddi_eventcookie_t cookie, void (*callback)(dev_info_t *dip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ddi_eventcookie_t cookie, void *arg, void *bus_impldata),
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * get the soft state structure for the bus instance.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp = (cbus_t *)ddi_get_soft_state(cardbus_state, cb_instance);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * We can't handle up (probably called at the attachment
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * point) so pass it on up
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_add_eventcall calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel DEVI(pdip)->devi_ops->devo_bus_ops->bus_add_eventcall);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_add_eventcall calling ndi_event_add_callback\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel rc = ndi_event_add_callback(cbp->cb_ndi_event_hdl, rdip, cookie,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_add_eventcall rc %d cookie %p\n", rc, (void *)cookie);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_remove_eventcall(dev_info_t *dip, ddi_callback_id_t cb_id)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * get the soft state structure for the bus instance.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbp = (cbus_t *)ddi_get_soft_state(cardbus_state, cb_instance);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * We can't handle up (probably called at the attachment
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * point) so pass it on up
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_remove_eventcall calling %s - 0x%p\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel DEVI(pdip)->devi_ops->devo_bus_ops->bus_remove_eventcall);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel return (ndi_event_remove_callback(cbp->cb_ndi_event_hdl, cb_id));
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_remove_intr_impl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_add_intr_impl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_enable_intr_impl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_disable_intr_impl(dev_info_t *dip, dev_info_t *rdip,
0d282d1376eb7ba06504448622a6d65726e4bd3erw return ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t intr_op,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cardbus_err(dip, 8, "cardbus_intr_ops() intr_op=%d\n", (int)intr_op);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_enable_intr_impl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* with one socket per function */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_enable_intr_impl, intr=0x%p, arg1=0x%p, arg2=0x%p"
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "rdip=0x%p(%s)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if ((*anp->an_if->pcif_set_interrupt)(dip, &sih) != SUCCESS)
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_disable_intr_impl(dev_info_t *dip, dev_info_t *rdip,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint_t socket = 0; /* We only support devices with 1 socket per */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* function. */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus_disable_intr_impl, intr=0x%p, arg1=0x%p, arg2=0x%p"
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "rdip=0x%p(%s%d)\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel (void *) rdip, ddi_driver_name(rdip), ddi_get_instance(rdip));
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if ((*anp->an_if->pcif_clr_interrupt)(dip, &cih) != SUCCESS)
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_do_pprintf = 0;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel/*PRINTFLIKE3*/
3db86aab554edbb4244c8d1a1c90f152eee768afstevelcardbus_err(dev_info_t *dip, int level, const char *fmt, ...)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel const char *name;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* name = ddi_binding_name(dip); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* vcmn_err(ce, fmt, adx); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* vprintf(fmt, adx); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* prom_vprintf(fmt, adx); */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (ddi_getlongprop(DDI_DEV_T_ANY, pdip, DDI_PROP_DONTPASS, "bus-range",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "fail to allocate bus number\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "fail to update bus-range property\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel if (pci_config_setup(pdip, &handle) != DDI_SUCCESS) {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "fail to pci_config_setup\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel pci_config_put8(handle, PCI_BCNF_SECBUS, bus_range->lo);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel pci_config_put8(handle, PCI_BCNF_SUBBUS, bus_range->hi);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "parent dip %u -> %u\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "fail to ndi_ra_map_setup of bus number\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "cardbus dip base %u length %d\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "fail to allocate bus number of length %d "
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "from parent\n",
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "fail to ndi_ra_map_setup of bus numbers\n");
3db86aab554edbb4244c8d1a1c90f152eee768afstevel "parent dip doesn't have busrange prop\n");