110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * CDDL HEADER START
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * The contents of this file are subject to the terms of the
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Common Development and Distribution License (the "License").
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * You may not use this file except in compliance with the License.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * See the License for the specific language governing permissions
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * and limitations under the License.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * When distributing Covered Code, include this CDDL HEADER in each
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * If applicable, add the following below this CDDL HEADER, with the
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * fields enclosed by brackets "[]" replaced with your own identifying
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * information: Portions Copyright [yyyy] [name of copyright owner]
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * CDDL HEADER END
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Use is subject to license terms.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#pragma ident "%Z%%M% %I% %E% SMI"
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz#define PCIE_ROOTNEX_COMPATIBLE_NAME "SUNW,sun4v-pci"
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * The following typedef is used to represent a
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * 1275 "reg" property of a PCI nexus.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * The following event and offset arrays is organized by grouping in major
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * order the fire_perfcnt_t register types, and in minor order the register
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * numbers within that type.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * This table maps the above order into the hypervisor interface register
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz/* Called by _init to determine if it is OK to install driver. */
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz if ((regstat = hsvc_register(&fpc_hsvc, &fpc_sup_minor)) == SUCCESS) {
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz/* Called during attach to do module-wide initialization. */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz DDI_PROP_DONTPASS, "compatible", &name) != DDI_PROP_SUCCESS)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz is_root_pcie_nexus = (strcmp(name, PCIE_ROOTNEX_COMPATIBLE_NAME) == 0);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz DDI_PROP_DONTPASS, "reg", (uchar_t **)&rp, ®len) !=
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Initilize device handle. The device handle uniquely
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * identifies a SUN4V device. It consists of the lower 28-bits
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * of the hi-cell of the first entry of the SUN4V device's
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * "reg" property as defined by the SUN4V Bus Binding to Open
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz * Firmware.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz dev_hdl = (devhandle_t)((rp->phys_addr >> 32) & DEVHDLE_MASK);
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * If this is the first time through here, negotiate with hypervisor
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * that it has the services needed to operate. Don't do this in _init
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * since we may want to modload the driver without attaching,
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * for debugging purposes.
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * Note that this is another way of weeding out unsupported platforms
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz regstat = hsvc_register(&fpc_hsvc, &fpc_sup_minor);
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * Fail silently since we don't want to print an error
0ad689d678ef901f32945172f48ddc7b16dde50dschwartz * on future platforms which don't support this driver.
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz /* See which register sets are usable from this node. */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz (fire_perfreg_handle_t)dev_hdl, jbc, &dummy_data, IS_READ) ==
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz (fire_perfreg_handle_t)dev_hdl, imu, &dummy_data, IS_READ) ==
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz /* Nothing usable at this node. */
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz ((index == 0) ? PCIE_A_REGS_AVAIL : PCIE_B_REGS_AVAIL);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz "fpc: JBUS regs available on device idx %d!\n",
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz (void) fpc_set_platform_data_by_number(index, (void *)dev_hdl);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return ((fire_perfreg_handle_t)platform_specific_data);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_free_counter_handle(fire_perfreg_handle_t handle)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_hv_perfreg_io(fire_perfreg_handle_t handle, uint64_t hv_if_index,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz rval = fpc_set_fire_perfreg(dev_hdl, hv_if_index, *reg_data);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz rval = fpc_get_fire_perfreg(dev_hdl, hv_if_index, reg_data);
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_event_io(fire_perfreg_handle_t handle, fire_perfcnt_t group,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint64_t hv_if_index = counter_select_index[group];
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz return (fpc_hv_perfreg_io(handle, hv_if_index, reg_data, is_write));
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz/*ARGSUSED*/
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartzfpc_counter_io(fire_perfreg_handle_t handle, fire_perfcnt_t group,
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz int counter_index, uint64_t *reg_data, boolean_t is_write)
110e73f9b5ccaa10e26a8f79807001a5da72604eschwartz uint64_t hv_if_index = counter_reg_index[counter_index];