4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * CPU functions to the Safari Configurator (gptwo_cpu)
30 #include <sys/types.h>
36 #include <sys/sunddi.h>
37 #include <sys/sunndi.h>
38 #include <sys/modctl.h>
40 #include <sys/param.h>
41 #include <sys/autoconf.h>
42 #include <sys/ksynch.h>
43 #include <sys/promif.h>
44 #include <sys/ndi_impldefs.h>
45 #include <sys/ddi_impldefs.h>
46 #include <sys/machsystm.h>
47 #include <sys/gp2cfg.h>
48 #include <sys/gptwo_cpu.h>
49 #include <sys/cheetahregs.h>
52 int gptwo_cpu_debug
= 0;
54 static void debug(char *, uintptr_t, uintptr_t,
55 uintptr_t, uintptr_t, uintptr_t);
57 #define GPTWO_DEBUG0(level, flag, s) if (gptwo_cpu_debug >= level) \
59 #define GPTWO_DEBUG1(level, flag, fmt, a1) if (gptwo_cpu_debug >= level) \
60 debug(fmt, (uintptr_t)(a1), 0, 0, 0, 0);
61 #define GPTWO_DEBUG2(level, flag, fmt, a1, a2) if (gptwo_cpu_debug >= level) \
62 debug(fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);
63 #define GPTWO_DEBUG3(level, flag, fmt, a1, a2, a3) \
64 if (gptwo_cpu_debug >= level) \
65 debug(fmt, (uintptr_t)(a1), (uintptr_t)(a2), (uintptr_t)(a3), 0, 0);
67 #define GPTWO_DEBUG0(level, flag, s)
68 #define GPTWO_DEBUG1(level, flag, fmt, a1)
69 #define GPTWO_DEBUG2(level, flag, fmt, a1, a2)
70 #define GPTWO_DEBUG3(level, flag, fmt, a1, a2, a3)
74 * Devinfo branch create arg
82 dev_info_t
*new_child
;
85 static dev_info_t
*gptwocfg_create_cpu_node(dev_info_t
*, spcd_t
*,
86 uint_t
, uint_t
, uint_t
, uint_t
);
87 static dev_info_t
*gptwocfg_create_mc_node(dev_info_t
*, spcd_t
*, uint_t
);
88 static dev_info_t
*gptwocfg_create_cmp_node(dev_info_t
*, spcd_t
*, uint_t
);
89 static int gptwocfg_create_core_node(dev_info_t
*, spcd_t
*, uint_t
, uint_t
);
90 static int set_mc_props(dev_info_t
*new_child
, void *arg
, uint_t flags
);
91 static int set_cmp_props(dev_info_t
*new_child
, void *arg
, uint_t flags
);
92 static int set_cpu_props(dev_info_t
*new_child
, void *arg
, uint_t flags
);
93 static int set_cpu_common_props(dev_info_t
*new_child
, struct bca
*bcp
);
94 static int set_cpu_us3_props(dev_info_t
*new_child
, struct bca
*bcp
);
95 static int set_cpu_us4_props(dev_info_t
*new_child
, struct bca
*bcp
);
96 static void get_new_child(dev_info_t
*rdip
, void *arg
, uint_t flags
);
100 * Module linkage information for the kernel.
103 extern struct mod_ops mod_miscops
;
105 static struct modlmisc modlmisc
= {
106 &mod_miscops
, /* Type of module */
107 "gptwo->cpu configurator",
110 static struct modlinkage modlinkage
= {
111 MODREV_1
, (void *)&modlmisc
, NULL
119 /* register device with the configurator */
120 gptwocfg_register_ops(SAFPTYPE_CPU
, gptwocfg_configure_cpu
, NULL
);
122 if ((err
= mod_install(&modlinkage
)) != 0) {
123 GPTWO_DEBUG1(1, CE_WARN
, "gptwo_cpu (CPU/MC Functions) "
124 "failed to load, error=%d\n", err
);
125 gptwocfg_unregister_ops(SAFPTYPE_CPU
);
127 GPTWO_DEBUG0(1, CE_WARN
, "gptwo_cpu (CPU/MC Functions) "
128 "has been loaded.\n");
136 /* cleanup/freeup structs with configurator */
137 gptwocfg_unregister_ops(SAFPTYPE_CPU
);
138 return (mod_remove(&modlinkage
));
142 _info(struct modinfo
*modinfop
)
144 return (mod_info(&modlinkage
, modinfop
));
148 gptwocfg_configure_cpu(dev_info_t
*ap
, spcd_t
*pcd
, uint_t portid
)
150 dev_info_t
*cpu_node
[AGENTS_PER_PORT
], *mc_node
[AGENTS_PER_PORT
];
151 dev_info_t
*cmp_node
= NULL
;
152 gptwo_new_nodes_t
*new_nodes
;
155 uint_t implementation
;
157 GPTWO_DEBUG2(1, CE_CONT
, "gptwocfg_configure_cpu: portid=%x pcd=%lx\n",
160 for (i
= 0; i
< AGENTS_PER_PORT
; i
++) {
165 implementation
= (pcd
->spcd_ver_reg
>> 32) & 0x000000000000ffff;
167 switch (implementation
) {
169 case CHEETAH_PLUS_IMPL
:
174 cmn_err(CE_WARN
, "Unsupported cpu implementation=0x%x : "
175 "skipping configure of portid=0x%x", implementation
,
181 if (CPU_IMPL_IS_CMP(implementation
)) {
182 if (cmp_node
= gptwocfg_create_cmp_node(ap
, pcd
, portid
))
188 for (i
= 0; i
< AGENTS_PER_PORT
; i
++) {
189 if (pcd
->spcd_agent
[i
] != SPCD_RSV_PASS
)
192 if (cpu_node
[i
] = gptwocfg_create_cpu_node(cmp_node
?
193 cmp_node
: ap
, pcd
, portid
, pcd
->spcd_cpuid
[i
], i
,
196 * If the CPU is a CMP, the entire branch is
197 * manipulated using just the top node. Thus,
198 * the dips of the individual cores do not need
199 * to be held or stored in the new node list.
202 e_ddi_branch_rele(cpu_node
[i
]);
209 /* current implementations have 1 MC node per Safari port */
210 if (pcd
->spcd_prsv
== SPCD_RSV_PASS
&&
211 (mc_node
[0] = gptwocfg_create_mc_node(ap
, pcd
, portid
)))
214 new_nodes
= gptwocfg_allocate_node_list(nodes
);
217 for (i
= 0; i
< AGENTS_PER_PORT
; i
++) {
218 if ((cpu_node
[i
] != NULL
) && (!CPU_IMPL_IS_CMP(implementation
)))
219 new_nodes
->gptwo_nodes
[j
++] = cpu_node
[i
];
220 if (mc_node
[i
] != NULL
)
221 new_nodes
->gptwo_nodes
[j
++] = mc_node
[i
];
225 new_nodes
->gptwo_nodes
[j
++] = cmp_node
;
232 gptwocfg_create_cmp_node(dev_info_t
*ap
, spcd_t
*pcd
, uint_t portid
)
241 arg
.new_child
= NULL
;
244 b
.type
= DEVI_BRANCH_SID
;
245 b
.create
.sid_branch_create
= set_cmp_props
;
246 b
.devi_branch_callback
= get_new_child
;
248 if (e_ddi_branch_create(ap
, &b
, NULL
, 0))
251 return (arg
.new_child
);
256 set_cmp_props(dev_info_t
*new_child
, void *arg
, uint_t flags
)
258 struct bca
*bap
= (struct bca
*)arg
;
264 portid
= bap
->portid
;
266 GPTWO_DEBUG2(1, CE_CONT
, "set_cmp_props: portid=%x pcd=%lx\n",
269 if (ndi_prop_update_string(DDI_DEV_T_NONE
, new_child
,
270 "name", "cmp") != DDI_SUCCESS
) {
271 GPTWO_DEBUG0(1, CE_CONT
, "set_cmp_props: failed to "
272 "create name property\n");
273 return (DDI_WALK_ERROR
);
276 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
277 "portid", portid
) != DDI_SUCCESS
) {
278 GPTWO_DEBUG0(1, CE_CONT
, "set_cmp_props: failed to "
279 "create portid property\n");
280 return (DDI_WALK_ERROR
);
283 reg
.gptwo_phys_hi
= 0x400 | (portid
>> 9);
284 reg
.gptwo_phys_low
= (portid
<< 23);
285 reg
.gptwo_size_hi
= 0;
286 reg
.gptwo_size_low
= 0x10000;
288 if (ndi_prop_update_int_array(DDI_DEV_T_NONE
,
289 new_child
, "reg", (int *)®
,
290 sizeof (gptwo_regspec_t
) / sizeof (int)) != DDI_SUCCESS
) {
291 GPTWO_DEBUG0(1, CE_CONT
, "set_cmp_props: failed to "
292 "create reg property\n");
293 return (DDI_WALK_ERROR
);
296 return (DDI_WALK_TERMINATE
);
300 gptwocfg_create_cpu_node(dev_info_t
*ap
, spcd_t
*pcd
, uint_t portid
,
301 uint_t cpuid
, uint_t coreid
, uint_t impl
)
304 devi_branch_t b
= {0};
311 arg
.new_child
= NULL
;
314 b
.type
= DEVI_BRANCH_SID
;
315 b
.create
.sid_branch_create
= set_cpu_props
;
316 b
.devi_branch_callback
= get_new_child
;
318 if (e_ddi_branch_create(ap
, &b
, NULL
, 0))
321 return (arg
.new_child
);
326 set_cpu_props(dev_info_t
*new_child
, void *arg
, uint_t flags
)
328 struct bca
*bcp
= arg
;
329 uint_t impl
= bcp
->impl
;
332 if (set_cpu_common_props(new_child
, bcp
) != DDI_WALK_CONTINUE
)
333 return (DDI_WALK_ERROR
);
337 case CHEETAH_PLUS_IMPL
:
338 rc
= set_cpu_us3_props(new_child
, bcp
);
342 rc
= set_cpu_us4_props(new_child
, bcp
);
346 return (DDI_WALK_ERROR
);
353 * Set properties common to cpu (non-CMP) and core (CMP) nodes.
366 set_cpu_common_props(dev_info_t
*new_child
, struct bca
*bcp
)
370 int mask
, manufacturer
;
376 mask
= (pcd
->spcd_ver_reg
>> 24) & 0x00000000000000ff;
377 manufacturer
= (pcd
->spcd_ver_reg
>> 48) & 0x000000000000ffff;
379 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
380 "cpuid", cpuid
) != DDI_SUCCESS
) {
381 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_common_props: failed "
382 "to create cpuid property\n");
383 return (DDI_WALK_ERROR
);
386 if (ndi_prop_update_string(DDI_DEV_T_NONE
, new_child
,
387 "device_type", "cpu") != DDI_SUCCESS
) {
388 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_common_props: failed "
389 "to create device_type property\n");
390 return (DDI_WALK_ERROR
);
393 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
, "manufacturer#",
394 manufacturer
) != DDI_SUCCESS
) {
395 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_common_props: failed "
396 "to create manufacturer# property\n");
397 return (DDI_WALK_ERROR
);
400 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
, "implementation#",
401 impl
) != DDI_SUCCESS
) {
402 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_common_props: failed "
403 "to create implementation# property\n");
404 return (DDI_WALK_ERROR
);
407 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
, "mask#",
408 mask
) != DDI_SUCCESS
) {
409 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_common_props: failed "
410 "to create mask# property\n");
411 return (DDI_WALK_ERROR
);
414 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
415 "sparc-version", 9) != DDI_SUCCESS
) {
416 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_common_props: failed "
417 "to create sparc-version property\n");
418 return (DDI_WALK_ERROR
);
421 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
422 "clock-frequency", (pcd
->spcd_afreq
* 1000000)) != DDI_SUCCESS
) {
423 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_common_props: failed "
424 "to create clock-frequency property\n");
425 return (DDI_WALK_ERROR
);
428 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
429 "#dtlb-entries", 0x10) != DDI_SUCCESS
) {
430 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_common_props: failed "
431 "to create #dtlb-entries property\n");
432 return (DDI_WALK_ERROR
);
435 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
436 "#itlb-entries", 0x10) != DDI_SUCCESS
) {
437 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_common_props: failed "
438 "to create #itlb-entries property\n");
439 return (DDI_WALK_ERROR
);
442 return (DDI_WALK_CONTINUE
);
446 * Set cpu node properties for Cheetah and Cheetah+.
453 * icache-associativity
456 * dcache-associativity
459 * ecache-associativity
462 set_cpu_us3_props(dev_info_t
*new_child
, struct bca
*bcp
)
466 int ecache_size
, ecache_line_size
;
467 int dimms
, ecache_assoc
;
472 portid
= bcp
->portid
;
475 ASSERT(IS_CHEETAH(impl
) || IS_CHEETAH_PLUS(impl
));
479 ecache_assoc
= CH_ECACHE_NWAY
;
480 node_name
= "SUNW,UltraSPARC-III";
482 case CHEETAH_PLUS_IMPL
:
484 * Hard coding the ecache-associativity to 2 for Cheetah+.
485 * We probably should add this to the PCD.
487 ecache_assoc
= CHP_ECACHE_NWAY
;
488 node_name
= "SUNW,UltraSPARC-III+";
491 GPTWO_DEBUG1(1, CE_CONT
, "set_cpu_us3_props: invalid "
492 "implementation=0x%x\n", impl
);
493 return (DDI_WALK_ERROR
);
496 if (ndi_prop_update_string(DDI_DEV_T_NONE
, new_child
,
497 "name", node_name
) != DDI_SUCCESS
) {
498 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
499 "to create name property\n");
500 return (DDI_WALK_ERROR
);
503 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
504 "portid", portid
) != DDI_SUCCESS
) {
505 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
506 "to create portid property\n");
507 return (DDI_WALK_ERROR
);
510 reg
.gptwo_phys_hi
= 0x400 | (portid
>> 9);
511 reg
.gptwo_phys_low
= (portid
<< 23);
512 reg
.gptwo_size_hi
= 0;
513 reg
.gptwo_size_low
= 0x10000;
515 if (ndi_prop_update_int_array(DDI_DEV_T_NONE
,
516 new_child
, "reg", (int *)®
,
517 sizeof (gptwo_regspec_t
) / sizeof (int)) != DDI_SUCCESS
) {
518 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
519 "to create reg property\n");
520 return (DDI_WALK_ERROR
);
523 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
524 "icache-size", CH_ICACHE_SIZE
) != DDI_SUCCESS
) {
525 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
526 "to create icache-size property\n");
527 return (DDI_WALK_ERROR
);
530 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
531 "icache-line-size", CH_ICACHE_LSIZE
) != DDI_SUCCESS
) {
532 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
533 "to create icache-line-size property\n");
534 return (DDI_WALK_ERROR
);
537 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
538 "icache-associativity", CH_ICACHE_NWAY
) != DDI_SUCCESS
) {
539 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
540 "to create icache-associativity property\n");
541 return (DDI_WALK_ERROR
);
544 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
545 "dcache-size", CH_DCACHE_SIZE
) != DDI_SUCCESS
) {
546 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
547 "to create dcache-size property\n");
548 return (DDI_WALK_ERROR
);
551 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
552 "dcache-line-size", CH_DCACHE_LSIZE
) != DDI_SUCCESS
) {
553 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
554 "to create dcache-line-size property\n");
555 return (DDI_WALK_ERROR
);
558 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
559 "dcache-associativity", CH_DCACHE_NWAY
) != DDI_SUCCESS
) {
560 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
561 "to create dcache-associativity property\n");
562 return (DDI_WALK_ERROR
);
566 * Get the External Cache Size from the Common PCD.
568 ecache_size
= pcd
->spcd_cache
* 0x100000;
570 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
571 "ecache-size", ecache_size
) != DDI_SUCCESS
) {
572 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
573 "to create ecache-line-size property\n");
574 return (DDI_WALK_ERROR
);
577 switch (ecache_size
) {
578 case CH_ECACHE_1M_SIZE
:
579 ecache_line_size
= 64;
581 case CH_ECACHE_4M_SIZE
:
582 ecache_line_size
= 256;
584 case CH_ECACHE_8M_SIZE
:
585 ecache_line_size
= 512;
588 GPTWO_DEBUG1(1, CE_CONT
, "set_cpu_us3_props: invalid "
589 "ecache-size 0x%x\b", ecache_size
);
590 return (DDI_WALK_ERROR
);
593 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
594 "ecache-line-size", ecache_line_size
) != DDI_SUCCESS
) {
595 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
596 "to create ecache-line-size property\n");
597 return (DDI_WALK_ERROR
);
600 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
601 "ecache-associativity", ecache_assoc
) != DDI_SUCCESS
) {
602 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us3_props: failed "
603 "to create ecache-associativity property\n");
604 return (DDI_WALK_ERROR
);
608 * Create the ecache-dimm-label property.
612 while ((pcd
->sprd_ecache_dimm_label
[dimms
] != NULL
) &&
613 (dimms
< MAX_DIMMS_PER_PORT
))
617 (void) ndi_prop_update_string_array(DDI_DEV_T_NONE
, new_child
,
618 "ecache-dimm-label", (char **)pcd
->sprd_ecache_dimm_label
,
622 return (DDI_WALK_TERMINATE
);
626 * Set cmp core node properties for Jaguar and Panther.
632 * l1-icache-line-size
633 * l1-icache-associativity
635 * l1-dcache-line-size
636 * l1-dcache-associativity
639 * l2-cache-associativity
643 * l3-cache-associativity
647 set_cpu_us4_props(dev_info_t
*new_child
, struct bca
*bcp
)
649 uint_t l1_icache_size
, l1_icache_line_size
;
650 uint_t l2_cache_size
, l2_cache_line_size
, l2_cache_assoc
;
651 uint_t l2_cache_share
;
652 uint_t pcd_cache_size
;
660 coreid
= bcp
->coreid
;
663 ASSERT(IS_JAGUAR(impl
) || IS_PANTHER(impl
));
666 * Get the External Cache Size from the Common PCD.
668 pcd_cache_size
= pcd
->spcd_cache
* 0x100000;
672 compatible
= "SUNW,UltraSPARC-IV";
673 l1_icache_size
= CH_ICACHE_SIZE
;
674 l1_icache_line_size
= CH_ICACHE_LSIZE
;
675 l2_cache_assoc
= CHP_ECACHE_NWAY
;
678 * Jaguar has no logical sharing of L2 cache, so the sharing
679 * bit-map will represent this core only.
681 l2_cache_share
= coreid
? 0x2 : 0x1;
684 * Jaguar has a split ecache, so the total ecache must be
685 * divided in half to get the ecache for the individual core.
687 l2_cache_size
= pcd_cache_size
/ 2;
689 switch (l2_cache_size
) {
690 case JG_ECACHE_4M_SIZE
:
691 l2_cache_line_size
= 64;
693 case JG_ECACHE_8M_SIZE
:
694 l2_cache_line_size
= 128;
697 GPTWO_DEBUG1(1, CE_CONT
, "set_cpu_us4_props: "
698 "invalid l2_cache-size 0x%x\n", l2_cache_size
);
699 return (DDI_WALK_ERROR
);
703 ASSERT(pcd_cache_size
== PN_L3_SIZE
);
704 compatible
= "SUNW,UltraSPARC-IV+";
705 l1_icache_size
= PN_ICACHE_SIZE
;
706 l1_icache_line_size
= PN_ICACHE_LSIZE
;
707 l2_cache_size
= PN_L2_SIZE
;
708 l2_cache_line_size
= PN_L2_LINESIZE
;
709 l2_cache_assoc
= PN_ECACHE_NWAY
;
712 * For Panther, the L2 and L3 caches are logically shared by
713 * all enabled cores, so the sharing bit-map will represent
714 * all enabled cores. Panther split-mode is still considered
717 * Check the PCD status to determine enabled cores.
719 ASSERT(pcd
->spcd_ptype
== SAFPTYPE_CPU
);
721 for (i
= 0; i
< AGENTS_PER_PORT
; i
++) {
722 if (pcd
->spcd_agent
[i
] == SPCD_RSV_PASS
) {
723 l2_cache_share
|= (1 << i
);
729 GPTWO_DEBUG1(1, CE_CONT
, "set_cpu_us4_props: invalid "
730 "implementation=0x%x\n", impl
);
731 return (DDI_WALK_ERROR
);
734 if (ndi_prop_update_string(DDI_DEV_T_NONE
, new_child
,
735 "name", "cpu") != DDI_SUCCESS
) {
736 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
737 "to create name property\n");
738 return (DDI_WALK_ERROR
);
741 if (ndi_prop_update_string(DDI_DEV_T_NONE
, new_child
,
742 "compatible", compatible
) != DDI_SUCCESS
) {
743 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
744 "to create compatible property\n");
745 return (DDI_WALK_ERROR
);
748 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
749 "reg", coreid
) != DDI_SUCCESS
) {
750 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
751 "to create reg property\n");
752 return (DDI_WALK_ERROR
);
755 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
756 "l1-icache-size", l1_icache_size
) != DDI_SUCCESS
) {
757 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
758 "to create l1-icache-size property\n");
759 return (DDI_WALK_ERROR
);
762 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
763 "l1-icache-line-size", l1_icache_line_size
) != DDI_SUCCESS
) {
764 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
765 "to create icache-line-size property\n");
766 return (DDI_WALK_ERROR
);
769 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
770 "l1-icache-associativity", CH_ICACHE_NWAY
) != DDI_SUCCESS
) {
771 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
772 "to create l1-icache-associativity property\n");
773 return (DDI_WALK_ERROR
);
776 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
777 "l1-dcache-size", CH_DCACHE_SIZE
) != DDI_SUCCESS
) {
778 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
779 "to create l1-dcache-size property\n");
780 return (DDI_WALK_ERROR
);
783 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
784 "l1-dcache-line-size", CH_DCACHE_LSIZE
) != DDI_SUCCESS
) {
785 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
786 "to create dcache-line-size property\n");
787 return (DDI_WALK_ERROR
);
790 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
791 "l1-dcache-associativity", CH_DCACHE_NWAY
) != DDI_SUCCESS
) {
792 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
793 "to create l1-dcache-associativity property\n");
794 return (DDI_WALK_ERROR
);
797 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
798 "l2-cache-size", l2_cache_size
) != DDI_SUCCESS
) {
799 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
800 "to create l2-cache-size property\n");
801 return (DDI_WALK_ERROR
);
804 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
805 "l2-cache-line-size", l2_cache_line_size
) != DDI_SUCCESS
) {
806 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
807 "to create l2_cache-line-size property\n");
808 return (DDI_WALK_ERROR
);
811 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
812 "l2-cache-associativity", l2_cache_assoc
) != DDI_SUCCESS
) {
813 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
814 "to create l2-cache-associativity property\n");
815 return (DDI_WALK_ERROR
);
818 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
819 "l2-cache-sharing", l2_cache_share
) != DDI_SUCCESS
) {
820 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: failed "
821 "to create l2-cache-sharing property\n");
822 return (DDI_WALK_ERROR
);
826 * Create the ecache-dimm-label property.
830 while ((pcd
->sprd_ecache_dimm_label
[dimms
] != NULL
) &&
831 (dimms
< MAX_DIMMS_PER_PORT
))
835 (void) ndi_prop_update_string_array(DDI_DEV_T_NONE
, new_child
,
836 "ecache-dimm-label", (char **)pcd
->sprd_ecache_dimm_label
,
840 if (IS_PANTHER(impl
)) {
841 int l3_cache_share
= l2_cache_share
;
843 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
844 "l3-cache-size", PN_L3_SIZE
) != DDI_SUCCESS
) {
845 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: "
846 "failed to create l3-cache-size property\n");
847 return (DDI_WALK_ERROR
);
850 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
851 "l3-cache-line-size", PN_L3_LINESIZE
) != DDI_SUCCESS
) {
852 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: "
853 "failed to create l3-cache-line-size property\n");
854 return (DDI_WALK_ERROR
);
857 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
858 "l3-cache-associativity", PN_ECACHE_NWAY
) != DDI_SUCCESS
) {
859 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: "
860 "failed to create l3-cache-associativity "
862 return (DDI_WALK_ERROR
);
865 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
866 "l3-cache-sharing", l3_cache_share
) != DDI_SUCCESS
) {
867 GPTWO_DEBUG0(1, CE_CONT
, "set_cpu_us4_props: "
868 "failed to create l3-cache-sharing property\n");
869 return (DDI_WALK_ERROR
);
873 return (DDI_WALK_TERMINATE
);
877 gptwocfg_create_mc_node(dev_info_t
*ap
, spcd_t
*pcd
, uint_t portid
)
880 devi_branch_t b
= {0};
885 arg
.new_child
= NULL
;
888 b
.type
= DEVI_BRANCH_SID
;
889 b
.create
.sid_branch_create
= set_mc_props
;
890 b
.devi_branch_callback
= get_new_child
;
892 if (e_ddi_branch_create(ap
, &b
, NULL
, 0))
895 return (arg
.new_child
);
900 set_mc_props(dev_info_t
*new_child
, void *arg
, uint_t flags
)
902 struct bca
*bcp
= arg
;
905 spcd_t
*pcd
= bcp
->pcd
;
906 uint_t portid
= bcp
->portid
;
907 uint_t cpuid
= bcp
->cpuid
;
909 GPTWO_DEBUG3(1, CE_CONT
, "set_mc_props: ap=0x%lx portid=0x%x "
910 "cpuid=0x%x\n", ddi_get_parent(new_child
), portid
, cpuid
);
912 if (ndi_prop_update_string(DDI_DEV_T_NONE
, new_child
,
913 "name", "memory-controller") != DDI_SUCCESS
) {
914 GPTWO_DEBUG0(1, CE_CONT
, "set_mc_props: failed "
915 "to create name property\n");
916 return (DDI_WALK_ERROR
);
919 if (ndi_prop_update_string(DDI_DEV_T_NONE
, new_child
,
920 "compatible", "SUNW,UltraSPARC-III,mc") != DDI_SUCCESS
) {
921 GPTWO_DEBUG0(1, CE_CONT
, "set_mc_props: failed "
922 "to create compatible property\n");
923 return (DDI_WALK_ERROR
);
926 if (ndi_prop_update_string(DDI_DEV_T_NONE
, new_child
,
927 "device_type", "memory-controller") != DDI_SUCCESS
) {
928 GPTWO_DEBUG0(1, CE_CONT
, "set_mc_props: failed "
929 "to create device_type property\n");
930 return (DDI_WALK_ERROR
);
933 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
934 "portid", portid
) != DDI_SUCCESS
) {
935 GPTWO_DEBUG0(1, CE_CONT
, "set_mc_props: failed "
936 "to create portid property\n");
937 return (DDI_WALK_ERROR
);
940 if (ndi_prop_update_int(DDI_DEV_T_NONE
, new_child
,
941 "cpuid", cpuid
) != DDI_SUCCESS
) {
942 GPTWO_DEBUG0(1, CE_CONT
, "set_mc_props: failed "
943 "to create cpuid property\n");
944 return (DDI_WALK_ERROR
);
947 reg
.gptwo_phys_hi
= 0x400 | (portid
>> 9);
948 reg
.gptwo_phys_low
= (portid
<< 23) | 0x400000;
949 reg
.gptwo_size_hi
= 0;
950 reg
.gptwo_size_low
= 0x48;
952 if (ndi_prop_update_int_array(DDI_DEV_T_NONE
,
953 new_child
, "reg", (int *)®
,
954 sizeof (gptwo_regspec_t
) / sizeof (int)) != DDI_SUCCESS
) {
955 GPTWO_DEBUG0(1, CE_CONT
, "set_mc_props: failed "
956 "to create reg property\n");
957 return (DDI_WALK_ERROR
);
960 if (pcd
->memory_layout
) {
961 if (ndi_prop_update_byte_array(DDI_DEV_T_NONE
,
962 new_child
, "memory-layout", (uchar_t
*)pcd
->memory_layout
,
963 pcd
->memory_layout_size
) != DDI_SUCCESS
) {
965 GPTWO_DEBUG0(1, CE_CONT
, "set_mc_props: failed "
966 "to create memory-layout property\n");
968 return (DDI_WALK_ERROR
);
973 * Create the bank-status property.
977 while ((pcd
->sprd_bank_rsv
[banks
] != NULL
) &&
978 (banks
< MAX_BANKS_PER_PORT
))
982 (void) ndi_prop_update_string_array(DDI_DEV_T_NONE
, new_child
,
983 "bank-status", (char **)pcd
->sprd_bank_rsv
, banks
);
987 * Create the dimm-status property.
991 while ((pcd
->sprd_dimm
[dimms
] != NULL
) &&
992 (dimms
< MAX_DIMMS_PER_PORT
))
996 (void) ndi_prop_update_string_array(DDI_DEV_T_NONE
, new_child
,
997 "dimm-status", (char **)pcd
->sprd_dimm
, dimms
);
1001 return (DDI_WALK_TERMINATE
);
1006 get_new_child(dev_info_t
*rdip
, void *arg
, uint_t flags
)
1008 struct bca
*bcp
= arg
;
1010 bcp
->new_child
= rdip
;
1016 debug(char *fmt
, uintptr_t a1
, uintptr_t a2
, uintptr_t a3
,
1017 uintptr_t a4
, uintptr_t a5
)
1019 cmn_err(CE_CONT
, fmt
, a1
, a2
, a3
, a4
, a5
);