10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * sun4u root nexus driver 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate #include <sys/conf.h> 330Sstevel@tonic-gate #include <sys/cpuvar.h> 340Sstevel@tonic-gate #include <sys/sysiosbus.h> 350Sstevel@tonic-gate #include <sys/intreg.h> 360Sstevel@tonic-gate #include <sys/ddi_subrdefs.h> 370Sstevel@tonic-gate #include <sys/sunndi.h> 380Sstevel@tonic-gate #include <sys/async.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate /* Useful debugging Stuff */ 410Sstevel@tonic-gate #include <sys/nexusdebug.h> 420Sstevel@tonic-gate #define ROOTNEX_MAP_DEBUG 0x1 430Sstevel@tonic-gate #define ROOTNEX_INTR_DEBUG 0x2 440Sstevel@tonic-gate 450Sstevel@tonic-gate /* 460Sstevel@tonic-gate * Extern declarations 470Sstevel@tonic-gate */ 480Sstevel@tonic-gate extern uint_t root_phys_addr_lo_mask; 490Sstevel@tonic-gate extern int rootnex_name_child(dev_info_t *child, char *name, int namelen); 500Sstevel@tonic-gate extern int rootnex_ctl_uninitchild(dev_info_t *dip); 510Sstevel@tonic-gate 520Sstevel@tonic-gate uint_t root_phys_addr_hi_mask = 0xffffffff; 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* 550Sstevel@tonic-gate * config information 560Sstevel@tonic-gate */ 570Sstevel@tonic-gate int 580Sstevel@tonic-gate rootnex_add_intr_impl(dev_info_t *dip, dev_info_t *rdip, 590Sstevel@tonic-gate ddi_intr_handle_impl_t *hdlp); 600Sstevel@tonic-gate 610Sstevel@tonic-gate int 620Sstevel@tonic-gate rootnex_remove_intr_impl(dev_info_t *dip, dev_info_t *rdip, 630Sstevel@tonic-gate ddi_intr_handle_impl_t *hdlp); 640Sstevel@tonic-gate 65*693Sgovinda int 660Sstevel@tonic-gate rootnex_get_intr_pri(dev_info_t *dip, dev_info_t *rdip, 670Sstevel@tonic-gate ddi_intr_handle_impl_t *hdlp); 680Sstevel@tonic-gate 690Sstevel@tonic-gate ddi_iblock_cookie_t rootnex_err_ibc; 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* 720Sstevel@tonic-gate * rootnex_add_intr_impl: 730Sstevel@tonic-gate */ 740Sstevel@tonic-gate /*ARGSUSED*/ 750Sstevel@tonic-gate int 760Sstevel@tonic-gate rootnex_add_intr_impl(dev_info_t *dip, dev_info_t *rdip, 770Sstevel@tonic-gate ddi_intr_handle_impl_t *hdlp) 780Sstevel@tonic-gate { 790Sstevel@tonic-gate volatile uint64_t *intr_mapping_reg; 800Sstevel@tonic-gate volatile uint64_t mondo_vector; 810Sstevel@tonic-gate int32_t r_upaid = -1; 820Sstevel@tonic-gate int32_t slave = 0; 830Sstevel@tonic-gate int32_t upa_portid; 840Sstevel@tonic-gate int len, ret; 850Sstevel@tonic-gate 860Sstevel@tonic-gate if ((upa_portid = ddi_prop_get_int(DDI_DEV_T_ANY, rdip, 870Sstevel@tonic-gate DDI_PROP_DONTPASS, "upa-portid", -1)) != -1) { 880Sstevel@tonic-gate if (ddi_getprop(DDI_DEV_T_ANY, rdip, DDI_PROP_DONTPASS, 890Sstevel@tonic-gate "upa-interrupt-slave", 0) != 0) { 900Sstevel@tonic-gate 910Sstevel@tonic-gate /* Give slave devices pri of 5. e.g. fb's */ 92*693Sgovinda hdlp->ih_pri = 5; 930Sstevel@tonic-gate } 940Sstevel@tonic-gate 950Sstevel@tonic-gate /* 960Sstevel@tonic-gate * Translate the interrupt property by stuffing in the 970Sstevel@tonic-gate * portid for those devices which have a upa-portid. 980Sstevel@tonic-gate */ 99*693Sgovinda hdlp->ih_vector |= (UPAID_TO_IGN(upa_portid) << 6); 1000Sstevel@tonic-gate } 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* 1030Sstevel@tonic-gate * Hack to support the UPA slave devices before the 1275 1040Sstevel@tonic-gate * support for imap was introduced. 1050Sstevel@tonic-gate */ 1060Sstevel@tonic-gate if (ddi_getproplen(DDI_DEV_T_ANY, dip, NULL, "interrupt-map", 1070Sstevel@tonic-gate &len) != DDI_PROP_SUCCESS && ddi_getprop(DDI_DEV_T_ANY, 1080Sstevel@tonic-gate rdip, DDI_PROP_DONTPASS, "upa-interrupt-slave", 0) != 0 && 1090Sstevel@tonic-gate ddi_get_parent(rdip) == dip) { 1100Sstevel@tonic-gate slave = 1; 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate if ((r_upaid = ddi_prop_get_int(DDI_DEV_T_ANY, rdip, 1130Sstevel@tonic-gate DDI_PROP_DONTPASS, "upa-portid", -1)) != -1) { 1140Sstevel@tonic-gate extern uint64_t *get_intr_mapping_reg(int, int); 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate if ((intr_mapping_reg = get_intr_mapping_reg( 1170Sstevel@tonic-gate r_upaid, 1)) == NULL) 1180Sstevel@tonic-gate return (DDI_FAILURE); 1190Sstevel@tonic-gate } else 1200Sstevel@tonic-gate return (DDI_FAILURE); 1210Sstevel@tonic-gate } 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate if ((ret = i_ddi_add_ivintr(hdlp)) != DDI_SUCCESS) 1240Sstevel@tonic-gate return (ret); 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate /* 1270Sstevel@tonic-gate * Hack to support the UPA slave devices before the 1275 1280Sstevel@tonic-gate * support for imap was introduced. 1290Sstevel@tonic-gate */ 1300Sstevel@tonic-gate if (slave) { 1310Sstevel@tonic-gate /* 1320Sstevel@tonic-gate * Program the interrupt mapping register. 1330Sstevel@tonic-gate * Interrupts from the slave UPA devices are 1340Sstevel@tonic-gate * directed at the boot CPU until it is known 1350Sstevel@tonic-gate * that they can be safely redirected while 1360Sstevel@tonic-gate * running under load. 1370Sstevel@tonic-gate */ 1380Sstevel@tonic-gate mondo_vector = cpu0.cpu_id << IMR_TID_SHIFT; 139*693Sgovinda mondo_vector |= (IMR_VALID | (uint64_t)hdlp->ih_vector); 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* Set the mapping register */ 1420Sstevel@tonic-gate *intr_mapping_reg = mondo_vector; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate /* Flush write buffers */ 1450Sstevel@tonic-gate mondo_vector = *intr_mapping_reg; 1460Sstevel@tonic-gate } 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate return (ret); 1490Sstevel@tonic-gate } 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * rootnex_remove_intr_impl: 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate /*ARGSUSED*/ 1550Sstevel@tonic-gate int 1560Sstevel@tonic-gate rootnex_remove_intr_impl(dev_info_t *dip, dev_info_t *rdip, 1570Sstevel@tonic-gate ddi_intr_handle_impl_t *hdlp) 1580Sstevel@tonic-gate { 1590Sstevel@tonic-gate int32_t upa_portid; 1600Sstevel@tonic-gate int len; 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate if ((upa_portid = ddi_prop_get_int(DDI_DEV_T_ANY, rdip, 1630Sstevel@tonic-gate DDI_PROP_DONTPASS, "upa-portid", -1)) != -1) { 1640Sstevel@tonic-gate /* 1650Sstevel@tonic-gate * Translate the interrupt property by stuffing in the 1660Sstevel@tonic-gate * portid for those devices which have a upa-portid. 1670Sstevel@tonic-gate */ 168*693Sgovinda hdlp->ih_vector |= (UPAID_TO_IGN(upa_portid) << 6); 1690Sstevel@tonic-gate } 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate /* 1720Sstevel@tonic-gate * Hack to support the UPA slave devices before the 1275 1730Sstevel@tonic-gate * support for imap was introduced. 1740Sstevel@tonic-gate */ 1750Sstevel@tonic-gate if (ddi_getproplen(DDI_DEV_T_ANY, dip, NULL, "interrupt-map", 1760Sstevel@tonic-gate &len) != DDI_PROP_SUCCESS && ddi_getprop(DDI_DEV_T_ANY, 1770Sstevel@tonic-gate rdip, DDI_PROP_DONTPASS, "upa-interrupt-slave", 0) != 0) { 1780Sstevel@tonic-gate int32_t r_upaid = -1; 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate if ((r_upaid = ddi_prop_get_int(DDI_DEV_T_ANY, rdip, 1810Sstevel@tonic-gate DDI_PROP_DONTPASS, "upa-portid", -1)) != -1 && 1820Sstevel@tonic-gate ddi_get_parent(rdip) == dip) { 1830Sstevel@tonic-gate volatile uint64_t *intr_mapping_reg; 1840Sstevel@tonic-gate volatile uint64_t flush_data; 1850Sstevel@tonic-gate extern uint64_t *get_intr_mapping_reg(int, int); 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate if ((intr_mapping_reg = get_intr_mapping_reg( 1880Sstevel@tonic-gate r_upaid, 1)) == NULL) 1890Sstevel@tonic-gate return (DDI_SUCCESS); 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate /* Clear the mapping register */ 1920Sstevel@tonic-gate *intr_mapping_reg = 0x0ull; 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate /* Flush write buffers */ 1950Sstevel@tonic-gate flush_data = *intr_mapping_reg; 1960Sstevel@tonic-gate #ifdef lint 1970Sstevel@tonic-gate flush_data = flush_data; 1980Sstevel@tonic-gate #endif /* lint */ 1990Sstevel@tonic-gate } 2000Sstevel@tonic-gate } 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate i_ddi_rem_ivintr(hdlp); 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate return (DDI_SUCCESS); 2050Sstevel@tonic-gate } 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate /* 2080Sstevel@tonic-gate * rootnex_get_intr_pri: 2090Sstevel@tonic-gate */ 2100Sstevel@tonic-gate /*ARGSUSED*/ 211*693Sgovinda int 2120Sstevel@tonic-gate rootnex_get_intr_pri(dev_info_t *dip, dev_info_t *rdip, 2130Sstevel@tonic-gate ddi_intr_handle_impl_t *hdlp) 2140Sstevel@tonic-gate { 215*693Sgovinda int pri = hdlp->ih_pri; 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate if (ddi_prop_get_int(DDI_DEV_T_ANY, rdip, DDI_PROP_DONTPASS, 2180Sstevel@tonic-gate "upa-portid", -1) != -1) { 2190Sstevel@tonic-gate if (ddi_getprop(DDI_DEV_T_ANY, rdip, DDI_PROP_DONTPASS, 2200Sstevel@tonic-gate "upa-interrupt-slave", 0) != 0) { 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate /* Give slave devices pri of 5. e.g. fb's */ 223*693Sgovinda pri = 5; 2240Sstevel@tonic-gate } 2250Sstevel@tonic-gate } 226*693Sgovinda 227*693Sgovinda return (pri); 2280Sstevel@tonic-gate } 2290Sstevel@tonic-gate 2300Sstevel@tonic-gate int 2310Sstevel@tonic-gate rootnex_ctl_reportdev_impl(dev_info_t *dev) 2320Sstevel@tonic-gate { 2330Sstevel@tonic-gate struct regspec *rp; 2340Sstevel@tonic-gate char buf[80]; 2350Sstevel@tonic-gate char *p = buf; 2360Sstevel@tonic-gate register int n; 2370Sstevel@tonic-gate int portid; 2380Sstevel@tonic-gate int nodeid; 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate (void) sprintf(p, "%s%d at root", ddi_driver_name(dev), 2410Sstevel@tonic-gate ddi_get_instance(dev)); 2420Sstevel@tonic-gate p += strlen(p); 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate if ((n = sparc_pd_getnreg(dev)) > 0) { 2450Sstevel@tonic-gate rp = sparc_pd_getreg(dev, 0); 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate (void) strcpy(p, ": "); 2480Sstevel@tonic-gate p += strlen(p); 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate /* 2510Sstevel@tonic-gate * This stuff needs to be fixed correctly for the FFB 2520Sstevel@tonic-gate * devices and the UPA add-on devices. 2530Sstevel@tonic-gate */ 2540Sstevel@tonic-gate portid = ddi_prop_get_int(DDI_DEV_T_ANY, dev, 2550Sstevel@tonic-gate DDI_PROP_DONTPASS, "upa-portid", -1); 2560Sstevel@tonic-gate if (portid != -1) 2570Sstevel@tonic-gate (void) sprintf(p, "UPA 0x%x 0x%x%s", 2580Sstevel@tonic-gate portid, 2590Sstevel@tonic-gate rp->regspec_addr, (n > 1 ? "" : " ...")); 2600Sstevel@tonic-gate else { 2610Sstevel@tonic-gate portid = ddi_prop_get_int(DDI_DEV_T_ANY, dev, 2620Sstevel@tonic-gate DDI_PROP_DONTPASS, "portid", -1); 2630Sstevel@tonic-gate nodeid = ddi_prop_get_int(DDI_DEV_T_ANY, dev, 2640Sstevel@tonic-gate DDI_PROP_DONTPASS, "nodeid", -1); 2650Sstevel@tonic-gate if (portid == -1 && nodeid == -1) 2660Sstevel@tonic-gate printf("could not find portid " 2670Sstevel@tonic-gate "or nodeid property in %s\n", 2680Sstevel@tonic-gate DEVI(dev)->devi_node_name); 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate if (portid != -1) 2710Sstevel@tonic-gate (void) sprintf(p, "SAFARI 0x%x 0x%x%s", 2720Sstevel@tonic-gate portid, 2730Sstevel@tonic-gate rp->regspec_addr & 2740Sstevel@tonic-gate root_phys_addr_lo_mask, 2750Sstevel@tonic-gate (n > 1 ? "" : " ...")); 2760Sstevel@tonic-gate if (nodeid != -1) 2770Sstevel@tonic-gate (void) sprintf(p, "SSM Node %d", nodeid); 2780Sstevel@tonic-gate } 2790Sstevel@tonic-gate p += strlen(p); 2800Sstevel@tonic-gate } 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate /* 2830Sstevel@tonic-gate * This is where we need to print out the interrupt specifications 2840Sstevel@tonic-gate * for the FFB device and any UPA add-on devices. Not sure how to 2850Sstevel@tonic-gate * do this yet? 2860Sstevel@tonic-gate */ 2870Sstevel@tonic-gate cmn_err(CE_CONT, "?%s\n", buf); 2880Sstevel@tonic-gate return (DDI_SUCCESS); 2890Sstevel@tonic-gate } 2900Sstevel@tonic-gate 2910Sstevel@tonic-gate int 2920Sstevel@tonic-gate rootnex_name_child_impl(dev_info_t *child, char *name, int namelen) 2930Sstevel@tonic-gate { 2940Sstevel@tonic-gate struct ddi_parent_private_data *pdptr; 2950Sstevel@tonic-gate int portid, nodeid; 2960Sstevel@tonic-gate char *node_name; 2970Sstevel@tonic-gate struct regspec *rp; 2980Sstevel@tonic-gate 2990Sstevel@tonic-gate extern uint_t root_phys_addr_lo_mask; 3000Sstevel@tonic-gate extern void make_ddi_ppd( 3010Sstevel@tonic-gate dev_info_t *, struct ddi_parent_private_data **); 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate /* 3040Sstevel@tonic-gate * Fill in parent-private data and this function returns to us 3050Sstevel@tonic-gate * an indication if it used "registers" to fill in the data. 3060Sstevel@tonic-gate */ 3070Sstevel@tonic-gate if (ddi_get_parent_data(child) == NULL) { 3080Sstevel@tonic-gate make_ddi_ppd(child, &pdptr); 3090Sstevel@tonic-gate ddi_set_parent_data(child, pdptr); 3100Sstevel@tonic-gate } 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate /* 3130Sstevel@tonic-gate * No reg property, return null string as address (e.g. pseudo) 3140Sstevel@tonic-gate */ 3150Sstevel@tonic-gate name[0] = '\0'; 3160Sstevel@tonic-gate if (sparc_pd_getnreg(child) == 0) { 3170Sstevel@tonic-gate return (DDI_SUCCESS); 3180Sstevel@tonic-gate } 3190Sstevel@tonic-gate rp = sparc_pd_getreg(child, 0); 3200Sstevel@tonic-gate ASSERT(rp != NULL); 3210Sstevel@tonic-gate 3220Sstevel@tonic-gate /* 3230Sstevel@tonic-gate * Create portid property for fhc node under root(/fhc). 3240Sstevel@tonic-gate */ 3250Sstevel@tonic-gate node_name = ddi_node_name(child); 3260Sstevel@tonic-gate if ((strcmp(node_name, "fhc") == 0) || 3270Sstevel@tonic-gate (strcmp(node_name, "mem-unit") == 0) || 3280Sstevel@tonic-gate (strcmp(node_name, "central") == 0)) { 3290Sstevel@tonic-gate #ifdef _STARFIRE 3300Sstevel@tonic-gate portid = ((((rp->regspec_bustype) & 0x6) >> 1) | 3310Sstevel@tonic-gate (((rp->regspec_bustype) & 0xF0) >> 2) | 3320Sstevel@tonic-gate (((rp->regspec_bustype) & 0x8) << 3)); 3330Sstevel@tonic-gate #else 3340Sstevel@tonic-gate portid = (rp->regspec_bustype >> 1) & 0x1f; 3350Sstevel@tonic-gate #endif 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate /* 3380Sstevel@tonic-gate * The port-id must go on the hardware property list, 3390Sstevel@tonic-gate * otherwise, initchild may fail. 3400Sstevel@tonic-gate */ 3410Sstevel@tonic-gate if (ndi_prop_update_int(DDI_DEV_T_NONE, child, "upa-portid", 3420Sstevel@tonic-gate portid) != DDI_SUCCESS) 3430Sstevel@tonic-gate cmn_err(CE_WARN, 3440Sstevel@tonic-gate "Error in creating upa-portid property for fhc.\n"); 3450Sstevel@tonic-gate } 3460Sstevel@tonic-gate 3470Sstevel@tonic-gate /* 3480Sstevel@tonic-gate * Name node on behalf of child nexus. 3490Sstevel@tonic-gate */ 3500Sstevel@tonic-gate if (ddi_get_parent(child) != ddi_root_node()) { 3510Sstevel@tonic-gate (void) snprintf(name, namelen, "%x,%x", 3520Sstevel@tonic-gate rp->regspec_bustype, rp->regspec_addr); 3530Sstevel@tonic-gate return (DDI_SUCCESS); 3540Sstevel@tonic-gate } 3550Sstevel@tonic-gate 3560Sstevel@tonic-gate /* 3570Sstevel@tonic-gate * On sun4u, the 'name' of children of the root node 3580Sstevel@tonic-gate * is foo@<upa-mid>,<offset>, which is derived from, 3590Sstevel@tonic-gate * but not identical to the physical address. 3600Sstevel@tonic-gate */ 3610Sstevel@tonic-gate portid = ddi_prop_get_int(DDI_DEV_T_ANY, child, 3620Sstevel@tonic-gate DDI_PROP_DONTPASS, "upa-portid", -1); 3630Sstevel@tonic-gate if (portid == -1) 3640Sstevel@tonic-gate portid = ddi_prop_get_int(DDI_DEV_T_ANY, child, 3650Sstevel@tonic-gate DDI_PROP_DONTPASS, "portid", -1); 3660Sstevel@tonic-gate nodeid = ddi_prop_get_int(DDI_DEV_T_ANY, child, 3670Sstevel@tonic-gate DDI_PROP_DONTPASS, "nodeid", -1); 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate /* 3700Sstevel@tonic-gate * Do not log message, to handle cases where OBP version 3710Sstevel@tonic-gate * does not have "portid" property for the root i2c node. 3720Sstevel@tonic-gate * 3730Sstevel@tonic-gate * Platforms supporting root i2c node (potentially without 3740Sstevel@tonic-gate * "portid" property) are : 3750Sstevel@tonic-gate * SunBlade 1500, SunBlade 2500, V240, V250 3760Sstevel@tonic-gate */ 3770Sstevel@tonic-gate if (portid == -1 && nodeid == -1 && 3780Sstevel@tonic-gate strncmp(node_name, "i2c", strlen("i2c")) != 0) 3790Sstevel@tonic-gate cmn_err(CE_WARN, 3800Sstevel@tonic-gate "could not find portid or nodeid property in %s\n", 3810Sstevel@tonic-gate DEVI(child)->devi_node_name); 3820Sstevel@tonic-gate if (nodeid != -1) 3830Sstevel@tonic-gate (void) snprintf(name, namelen, "%x,0", nodeid); 3840Sstevel@tonic-gate else 3850Sstevel@tonic-gate (void) snprintf(name, namelen, "%x,%x", portid, 3860Sstevel@tonic-gate rp->regspec_addr & root_phys_addr_lo_mask); 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate return (DDI_SUCCESS); 3890Sstevel@tonic-gate } 3900Sstevel@tonic-gate 3910Sstevel@tonic-gate int 3920Sstevel@tonic-gate rootnex_ctl_initchild_impl(dev_info_t *dip) 3930Sstevel@tonic-gate { 3940Sstevel@tonic-gate struct regspec *rp; 3950Sstevel@tonic-gate struct ddi_parent_private_data *pd; 3960Sstevel@tonic-gate char name[MAXNAMELEN]; 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate extern struct ddi_parent_private_data *init_regspec_64(dev_info_t *dip); 3990Sstevel@tonic-gate 4000Sstevel@tonic-gate /* Name the child */ 4010Sstevel@tonic-gate (void) rootnex_name_child(dip, name, MAXNAMELEN); 4020Sstevel@tonic-gate ddi_set_name_addr(dip, name); 4030Sstevel@tonic-gate 4040Sstevel@tonic-gate /* 4050Sstevel@tonic-gate * Try to merge .conf node. If merge is successful, return 4060Sstevel@tonic-gate * DDI_FAILURE to allow caller to remove this node. 4070Sstevel@tonic-gate */ 4080Sstevel@tonic-gate if (ndi_dev_is_persistent_node(dip) == 0 && 4090Sstevel@tonic-gate (ndi_merge_node(dip, rootnex_name_child) == DDI_SUCCESS)) { 4100Sstevel@tonic-gate (void) rootnex_ctl_uninitchild(dip); 4110Sstevel@tonic-gate return (DDI_FAILURE); 4120Sstevel@tonic-gate } 4130Sstevel@tonic-gate 4140Sstevel@tonic-gate /* 4150Sstevel@tonic-gate * If there are no "reg"s in the child node, return. 4160Sstevel@tonic-gate */ 4170Sstevel@tonic-gate pd = init_regspec_64(dip); 4180Sstevel@tonic-gate if ((pd == NULL) || (pd->par_nreg == 0)) 4190Sstevel@tonic-gate return (DDI_SUCCESS); 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate /* 4220Sstevel@tonic-gate * If this is a slave device sitting on the UPA, we assume that 4230Sstevel@tonic-gate * This device can accept DMA accesses from other devices. We need 4240Sstevel@tonic-gate * to register this fact with the system by using the highest 4250Sstevel@tonic-gate * and lowest physical pfns of the devices register space. This 4260Sstevel@tonic-gate * will then represent a physical block of addresses that are valid 4270Sstevel@tonic-gate * for DMA accesses. 4280Sstevel@tonic-gate */ 4290Sstevel@tonic-gate if ((ddi_getprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "upa-portid", 4300Sstevel@tonic-gate -1) != -1) && ddi_getprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, 4310Sstevel@tonic-gate "upa-interrupt-slave", 0)) { 4320Sstevel@tonic-gate pfn_t lopfn = (pfn_t)-1; 4330Sstevel@tonic-gate pfn_t hipfn = 0; 4340Sstevel@tonic-gate int i; 4350Sstevel@tonic-gate extern void pf_set_dmacapable(pfn_t, pfn_t); 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate /* Scan the devices highest and lowest physical pfns */ 4380Sstevel@tonic-gate for (i = 0, rp = pd->par_reg; i < pd->par_nreg; i++, rp++) { 4390Sstevel@tonic-gate uint64_t addr; 4400Sstevel@tonic-gate pfn_t tmphipfn, tmplopfn; 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate addr = (unsigned long long)((unsigned long long) 4430Sstevel@tonic-gate rp->regspec_bustype << 32); 4440Sstevel@tonic-gate addr |= (uint64_t)rp->regspec_addr; 4450Sstevel@tonic-gate tmplopfn = (pfn_t)(addr >> MMU_PAGESHIFT); 4460Sstevel@tonic-gate addr += (uint64_t)(rp->regspec_size - 1); 4470Sstevel@tonic-gate tmphipfn = (pfn_t)(addr >> MMU_PAGESHIFT); 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate hipfn = (tmphipfn > hipfn) ? tmphipfn : hipfn; 4500Sstevel@tonic-gate lopfn = (tmplopfn < lopfn) ? tmplopfn : lopfn; 4510Sstevel@tonic-gate } 4520Sstevel@tonic-gate pf_set_dmacapable(hipfn, lopfn); 4530Sstevel@tonic-gate } 4540Sstevel@tonic-gate 4550Sstevel@tonic-gate return (DDI_SUCCESS); 4560Sstevel@tonic-gate } 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate void 4590Sstevel@tonic-gate rootnex_ctl_uninitchild_impl(dev_info_t *dip) 4600Sstevel@tonic-gate { 4610Sstevel@tonic-gate if ((ddi_getprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "upa-portid", 4620Sstevel@tonic-gate -1) != -1) && (ddi_getprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, 4630Sstevel@tonic-gate "upa-interrupt-slave", 0))) { 4640Sstevel@tonic-gate struct regspec *rp; 4650Sstevel@tonic-gate extern void pf_unset_dmacapable(pfn_t); 4660Sstevel@tonic-gate unsigned long long addr; 4670Sstevel@tonic-gate pfn_t pfn; 4680Sstevel@tonic-gate struct ddi_parent_private_data *pd; 4690Sstevel@tonic-gate 4700Sstevel@tonic-gate pd = ddi_get_parent_data(dip); 4710Sstevel@tonic-gate ASSERT(pd != NULL); 4720Sstevel@tonic-gate rp = pd->par_reg; 4730Sstevel@tonic-gate addr = (unsigned long long) ((unsigned long long) 4740Sstevel@tonic-gate rp->regspec_bustype << 32); 4750Sstevel@tonic-gate addr |= (unsigned long long) rp->regspec_addr; 4760Sstevel@tonic-gate pfn = (pfn_t)(addr >> MMU_PAGESHIFT); 4770Sstevel@tonic-gate 4780Sstevel@tonic-gate pf_unset_dmacapable(pfn); 4790Sstevel@tonic-gate } 4800Sstevel@tonic-gate } 481