1c42de6d020629af774dd9e9fc81be3f3ed9398egd * CDDL HEADER START
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * The contents of this file are subject to the terms of the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Common Development and Distribution License (the "License").
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * You may not use this file except in compliance with the License.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * See the License for the specific language governing permissions
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * and limitations under the License.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * When distributing Covered Code, include this CDDL HEADER in each
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * If applicable, add the following below this CDDL HEADER, with the
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * fields enclosed by brackets "[]" replaced with your own identifying
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * information: Portions Copyright [yyyy] [name of copyright owner]
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * CDDL HEADER END
88294e09b5c27cbb12b6735e2fb247a86b76666dRichard Bean * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Use is subject to license terms.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * CPU functions to the Safari Configurator (gptwo_cpu)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define GPTWO_DEBUG0(level, flag, s) if (gptwo_cpu_debug >= level) \
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define GPTWO_DEBUG1(level, flag, fmt, a1) if (gptwo_cpu_debug >= level) \
1c42de6d020629af774dd9e9fc81be3f3ed9398egd#define GPTWO_DEBUG2(level, flag, fmt, a1, a2) if (gptwo_cpu_debug >= level) \
1c42de6d020629af774dd9e9fc81be3f3ed9398egd debug(fmt, (uintptr_t)(a1), (uintptr_t)(a2), (uintptr_t)(a3), 0, 0);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Devinfo branch create arg
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic dev_info_t *gptwocfg_create_cpu_node(dev_info_t *, spcd_t *,
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic dev_info_t *gptwocfg_create_mc_node(dev_info_t *, spcd_t *, uint_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic dev_info_t *gptwocfg_create_cmp_node(dev_info_t *, spcd_t *, uint_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int gptwocfg_create_core_node(dev_info_t *, spcd_t *, uint_t, uint_t);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int set_mc_props(dev_info_t *new_child, void *arg, uint_t flags);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int set_cmp_props(dev_info_t *new_child, void *arg, uint_t flags);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int set_cpu_props(dev_info_t *new_child, void *arg, uint_t flags);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int set_cpu_common_props(dev_info_t *new_child, struct bca *bcp);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int set_cpu_us3_props(dev_info_t *new_child, struct bca *bcp);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic int set_cpu_us4_props(dev_info_t *new_child, struct bca *bcp);
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void get_new_child(dev_info_t *rdip, void *arg, uint_t flags);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Module linkage information for the kernel.
88294e09b5c27cbb12b6735e2fb247a86b76666dRichard Bean "gptwo->cpu configurator",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* register device with the configurator */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd gptwocfg_register_ops(SAFPTYPE_CPU, gptwocfg_configure_cpu, NULL);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "has been loaded.\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* cleanup/freeup structs with configurator */
1c42de6d020629af774dd9e9fc81be3f3ed9398egdgptwocfg_configure_cpu(dev_info_t *ap, spcd_t *pcd, uint_t portid)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd dev_info_t *cpu_node[AGENTS_PER_PORT], *mc_node[AGENTS_PER_PORT];
1c42de6d020629af774dd9e9fc81be3f3ed9398egd int i, j = 0;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd GPTWO_DEBUG2(1, CE_CONT, "gptwocfg_configure_cpu: portid=%x pcd=%lx\n",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < AGENTS_PER_PORT; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd implementation = (pcd->spcd_ver_reg >> 32) & 0x000000000000ffff;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd cmn_err(CE_WARN, "Unsupported cpu implementation=0x%x : "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (cmp_node = gptwocfg_create_cmp_node(ap, pcd, portid))
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < AGENTS_PER_PORT; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * If the CPU is a CMP, the entire branch is
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * manipulated using just the top node. Thus,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * the dips of the individual cores do not need
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * to be held or stored in the new node list.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd /* current implementations have 1 MC node per Safari port */
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < AGENTS_PER_PORT; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if ((cpu_node[i] != NULL) && (!CPU_IMPL_IS_CMP(implementation)))
1c42de6d020629af774dd9e9fc81be3f3ed9398egdgptwocfg_create_cmp_node(dev_info_t *ap, spcd_t *pcd, uint_t portid)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1c42de6d020629af774dd9e9fc81be3f3ed9398egdset_cmp_props(dev_info_t *new_child, void *arg, uint_t flags)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd GPTWO_DEBUG2(1, CE_CONT, "set_cmp_props: portid=%x pcd=%lx\n",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "create name property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "create portid property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd sizeof (gptwo_regspec_t) / sizeof (int)) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "create reg property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egdgptwocfg_create_cpu_node(dev_info_t *ap, spcd_t *pcd, uint_t portid,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1c42de6d020629af774dd9e9fc81be3f3ed9398egdset_cpu_props(dev_info_t *new_child, void *arg, uint_t flags)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (set_cpu_common_props(new_child, bcp) != DDI_WALK_CONTINUE)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (impl) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd return (rc);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Set properties common to cpu (non-CMP) and core (CMP) nodes.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * device_type
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * manufacturer#
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * implementation#
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * sparc-version
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * clock-frequency
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * #dtlb-entries
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * #itlb-entries
1c42de6d020629af774dd9e9fc81be3f3ed9398egdset_cpu_common_props(dev_info_t *new_child, struct bca *bcp)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd manufacturer = (pcd->spcd_ver_reg >> 48) & 0x000000000000ffff;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create cpuid property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create device_type property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (ndi_prop_update_int(DDI_DEV_T_NONE, new_child, "manufacturer#",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create manufacturer# property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (ndi_prop_update_int(DDI_DEV_T_NONE, new_child, "implementation#",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create implementation# property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd if (ndi_prop_update_int(DDI_DEV_T_NONE, new_child, "mask#",
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create mask# property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create sparc-version property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "clock-frequency", (pcd->spcd_afreq * 1000000)) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create clock-frequency property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create #dtlb-entries property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create #itlb-entries property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Set cpu node properties for Cheetah and Cheetah+.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * icache-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * icache-line-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * icache-associativity
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * dcache-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * dcache-line-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * dcache-associativity
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * ecache-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * ecache-line-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * ecache-associativity
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (impl) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Hard coding the ecache-associativity to 2 for Cheetah+.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * We probably should add this to the PCD.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create name property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create portid property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd sizeof (gptwo_regspec_t) / sizeof (int)) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create reg property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create icache-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create icache-line-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "icache-associativity", CH_ICACHE_NWAY) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create icache-associativity property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create dcache-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create dcache-line-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "dcache-associativity", CH_DCACHE_NWAY) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create dcache-associativity property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Get the External Cache Size from the Common PCD.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create ecache-line-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create ecache-line-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create ecache-associativity property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Create the ecache-dimm-label property.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (void) ndi_prop_update_string_array(DDI_DEV_T_NONE, new_child,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "ecache-dimm-label", (char **)pcd->sprd_ecache_dimm_label,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Set cmp core node properties for Jaguar and Panther.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * compatible
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l1-icache-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l1-icache-line-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l1-icache-associativity
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l1-dcache-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l1-dcache-line-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l1-dcache-associativity
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l2-cache-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l2-cache-line-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l2-cache-associativity
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l2-cache-sharing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l3-cache-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l3-cache-line-size
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l3-cache-associativity
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * l3-cache-sharing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd uint_t l2_cache_size, l2_cache_line_size, l2_cache_assoc;
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Get the External Cache Size from the Common PCD.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd switch (impl) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Jaguar has no logical sharing of L2 cache, so the sharing
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * bit-map will represent this core only.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Jaguar has a split ecache, so the total ecache must be
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * divided in half to get the ecache for the individual core.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * For Panther, the L2 and L3 caches are logically shared by
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * all enabled cores, so the sharing bit-map will represent
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * all enabled cores. Panther split-mode is still considered
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Check the PCD status to determine enabled cores.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd for (i = 0; i < AGENTS_PER_PORT; i++) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create name property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create compatible property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create reg property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create l1-icache-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "l1-icache-line-size", l1_icache_line_size) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create icache-line-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "l1-icache-associativity", CH_ICACHE_NWAY) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create l1-icache-associativity property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create l1-dcache-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "l1-dcache-line-size", CH_DCACHE_LSIZE) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create dcache-line-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "l1-dcache-associativity", CH_DCACHE_NWAY) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create l1-dcache-associativity property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create l2-cache-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "l2-cache-line-size", l2_cache_line_size) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create l2_cache-line-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "l2-cache-associativity", l2_cache_assoc) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create l2-cache-associativity property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create l2-cache-sharing property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Create the ecache-dimm-label property.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (void) ndi_prop_update_string_array(DDI_DEV_T_NONE, new_child,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "ecache-dimm-label", (char **)pcd->sprd_ecache_dimm_label,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "failed to create l3-cache-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "failed to create l3-cache-line-size property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "l3-cache-associativity", PN_ECACHE_NWAY) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "failed to create l3-cache-associativity "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "failed to create l3-cache-sharing property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egdgptwocfg_create_mc_node(dev_info_t *ap, spcd_t *pcd, uint_t portid)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1c42de6d020629af774dd9e9fc81be3f3ed9398egdset_mc_props(dev_info_t *new_child, void *arg, uint_t flags)
1c42de6d020629af774dd9e9fc81be3f3ed9398egd GPTWO_DEBUG3(1, CE_CONT, "set_mc_props: ap=0x%lx portid=0x%x "
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "cpuid=0x%x\n", ddi_get_parent(new_child), portid, cpuid);
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create name property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "compatible", "SUNW,UltraSPARC-III,mc") != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create compatible property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create device_type property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create portid property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create cpuid property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd sizeof (gptwo_regspec_t) / sizeof (int)) != DDI_SUCCESS) {
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create reg property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd new_child, "memory-layout", (uchar_t *)pcd->memory_layout,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd "to create memory-layout property\n");
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Create the bank-status property.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (void) ndi_prop_update_string_array(DDI_DEV_T_NONE, new_child,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd * Create the dimm-status property.
1c42de6d020629af774dd9e9fc81be3f3ed9398egd (void) ndi_prop_update_string_array(DDI_DEV_T_NONE, new_child,
1c42de6d020629af774dd9e9fc81be3f3ed9398egd/*ARGSUSED*/
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void
1c42de6d020629af774dd9e9fc81be3f3ed9398egdstatic void