1*aec6f0cfSskrll /* $NetBSD: rmixl_cpunode.c,v 1.6 2022/09/29 07:00:47 skrll Exp $ */
23e67b512Smatt
33e67b512Smatt /*
43e67b512Smatt * Copyright (c) 1994,1995 Mark Brinicombe.
53e67b512Smatt * Copyright (c) 1994 Brini.
63e67b512Smatt * All rights reserved.
73e67b512Smatt *
83e67b512Smatt * Redistribution and use in source and binary forms, with or without
93e67b512Smatt * modification, are permitted provided that the following conditions
103e67b512Smatt * are met:
113e67b512Smatt * 1. Redistributions of source code must retain the above copyright
123e67b512Smatt * notice, this list of conditions and the following disclaimer.
133e67b512Smatt * 2. Redistributions in binary form must reproduce the above copyright
143e67b512Smatt * notice, this list of conditions and the following disclaimer in the
153e67b512Smatt * documentation and/or other materials provided with the distribution.
163e67b512Smatt * 3. All advertising materials mentioning features or use of this software
173e67b512Smatt * must display the following acknowledgement:
183e67b512Smatt * This product includes software developed by Brini.
193e67b512Smatt * 4. The name of the company nor the name of the author may be used to
203e67b512Smatt * endorse or promote products derived from this software without specific
213e67b512Smatt * prior written permission.
223e67b512Smatt *
233e67b512Smatt * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
243e67b512Smatt * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
253e67b512Smatt * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
263e67b512Smatt * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
273e67b512Smatt * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
283e67b512Smatt * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
293e67b512Smatt * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
303e67b512Smatt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
313e67b512Smatt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
323e67b512Smatt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
333e67b512Smatt * SUCH DAMAGE.
343e67b512Smatt *
353e67b512Smatt * RiscBSD kernel project
363e67b512Smatt *
373e67b512Smatt * mainbus.c
383e67b512Smatt *
393e67b512Smatt * cpunode configuration
403e67b512Smatt *
413e67b512Smatt * Created : 15/12/94
423e67b512Smatt */
433e67b512Smatt
443e67b512Smatt #include <sys/cdefs.h>
45*aec6f0cfSskrll __KERNEL_RCSID(0, "$NetBSD: rmixl_cpunode.c,v 1.6 2022/09/29 07:00:47 skrll Exp $");
463e67b512Smatt
473e67b512Smatt #include <sys/param.h>
483e67b512Smatt #include <sys/systm.h>
493e67b512Smatt #include <sys/kernel.h>
503e67b512Smatt #include <sys/conf.h>
513e67b512Smatt #include <sys/device.h>
523e67b512Smatt
533e67b512Smatt #include <evbmips/rmixl/autoconf.h>
543e67b512Smatt
553e67b512Smatt #include <mips/rmi/rmixlvar.h>
563e67b512Smatt #include <mips/rmi/rmixl_cpunodevar.h>
573e67b512Smatt
58cf10107dSdyoung #include <sys/bus.h>
593e67b512Smatt #include "locators.h"
603e67b512Smatt
613e67b512Smatt static int cpunode_rmixl_match(device_t, cfdata_t, void *);
623e67b512Smatt static void cpunode_rmixl_attach(device_t, device_t, void *);
633e67b512Smatt static int cpunode_rmixl_print(void *, const char *);
643e67b512Smatt
653e67b512Smatt CFATTACH_DECL_NEW(cpunode_rmixl, sizeof(struct cpunode_softc),
663e67b512Smatt cpunode_rmixl_match, cpunode_rmixl_attach, NULL, NULL);
673e67b512Smatt
683e67b512Smatt static int
cpunode_rmixl_match(device_t parent,cfdata_t cf,void * aux)693e67b512Smatt cpunode_rmixl_match(device_t parent, cfdata_t cf, void *aux)
703e67b512Smatt {
713e67b512Smatt struct mainbus_attach_args *ma = aux;
723e67b512Smatt
733e67b512Smatt if (!cpu_rmixl(mips_options.mips_cpu))
743e67b512Smatt return 0;
753e67b512Smatt
763e67b512Smatt /* XXX for now attach one node only */
773e67b512Smatt if (ma->ma_node != 0)
783e67b512Smatt return 0;
793e67b512Smatt
803e67b512Smatt return 1;
813e67b512Smatt }
823e67b512Smatt
833e67b512Smatt static void
cpunode_rmixl_attach(device_t parent,device_t self,void * aux)843e67b512Smatt cpunode_rmixl_attach(device_t parent, device_t self, void *aux)
853e67b512Smatt {
863e67b512Smatt u_int sz;
873e67b512Smatt u_int ncores;
883e67b512Smatt struct cpunode_softc *sc = device_private(self);
893e67b512Smatt struct mainbus_attach_args *ma = aux;
903e67b512Smatt struct cpunode_attach_args na;
913e67b512Smatt const u_int cpu_cidflags = mips_options.mips_cpu->cpu_cidflags;
923e67b512Smatt
933e67b512Smatt aprint_naive("\n");
943e67b512Smatt aprint_normal("\n");
953e67b512Smatt
963e67b512Smatt sc->sc_dev = self;
973e67b512Smatt sc->sc_node = ma->ma_node;
983e67b512Smatt sc->sc_attached = 1;
993e67b512Smatt
1003e67b512Smatt switch (cpu_cidflags & MIPS_CIDFL_RMI_TYPE) {
1013e67b512Smatt case CIDFL_RMI_TYPE_XLR:
1023e67b512Smatt case CIDFL_RMI_TYPE_XLS:
1033e67b512Smatt /*
1043e67b512Smatt * L2 is unified on XLR, XLS
1053e67b512Smatt */
1063e67b512Smatt sz = (size_t)MIPS_CIDFL_RMI_L2SZ(cpu_cidflags);
1073e67b512Smatt aprint_normal("%s: %dKB/32B %d-banked 8-way set associative"
1083e67b512Smatt " unified L2 cache\n", device_xname(self),
1093e67b512Smatt sz/1024, sz/(256 * 1024));
1103e67b512Smatt break;
1113e67b512Smatt case CIDFL_RMI_TYPE_XLP:
1123e67b512Smatt /* TBD */
1133e67b512Smatt break;
1143e67b512Smatt }
1153e67b512Smatt
1163e67b512Smatt ncores = MIPS_CIDFL_RMI_NCORES(cpu_cidflags);
1173e67b512Smatt aprint_normal("%s: %d %s on node\n", device_xname(self), ncores,
1183e67b512Smatt ncores == 1 ? "core" : "cores");
1193e67b512Smatt
1203e67b512Smatt /*
1213e67b512Smatt * Attach cpu (RMI thread) devices
1223e67b512Smatt */
1233e67b512Smatt for (int i=0; i < ncores; i++) {
1243e67b512Smatt na.na_name = "cpucore";
1253e67b512Smatt na.na_node = ma->ma_node;
1263e67b512Smatt na.na_core = i;
127c7fb772bSthorpej config_found(self, &na, cpunode_rmixl_print, CFARGS_NONE);
1283e67b512Smatt }
1293e67b512Smatt
1303e67b512Smatt /*
1313e67b512Smatt * Attach obio
1323e67b512Smatt */
1333e67b512Smatt na.na_name = "obio";
134c7fb772bSthorpej config_found(self, &na, NULL, CFARGS_NONE);
1353e67b512Smatt }
1363e67b512Smatt
1373e67b512Smatt static int
cpunode_rmixl_print(void * aux,const char * pnp)1383e67b512Smatt cpunode_rmixl_print(void *aux, const char *pnp)
1393e67b512Smatt {
1403e67b512Smatt struct cpunode_attach_args *na = aux;
1413e67b512Smatt
1423e67b512Smatt if (pnp != NULL)
1433e67b512Smatt aprint_normal("%s:", pnp);
1443e67b512Smatt aprint_normal(" core %d", na->na_core);
1453e67b512Smatt
1463e67b512Smatt return (UNCONF);
1473e67b512Smatt }
148