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