Home | History | Annotate | Line # | Download | only in arm32
cpu.c revision 1.85
      1  1.85      matt /*	$NetBSD: cpu.c,v 1.85 2012/08/29 17:44:25 matt Exp $	*/
      2   1.1      matt 
      3   1.1      matt /*
      4   1.1      matt  * Copyright (c) 1995 Mark Brinicombe.
      5   1.1      matt  * Copyright (c) 1995 Brini.
      6   1.1      matt  * All rights reserved.
      7   1.1      matt  *
      8   1.1      matt  * Redistribution and use in source and binary forms, with or without
      9   1.1      matt  * modification, are permitted provided that the following conditions
     10   1.1      matt  * are met:
     11   1.1      matt  * 1. Redistributions of source code must retain the above copyright
     12   1.1      matt  *    notice, this list of conditions and the following disclaimer.
     13   1.1      matt  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1      matt  *    notice, this list of conditions and the following disclaimer in the
     15   1.1      matt  *    documentation and/or other materials provided with the distribution.
     16   1.1      matt  * 3. All advertising materials mentioning features or use of this software
     17   1.1      matt  *    must display the following acknowledgement:
     18   1.1      matt  *	This product includes software developed by Brini.
     19   1.1      matt  * 4. The name of the company nor the name of the author may be used to
     20   1.1      matt  *    endorse or promote products derived from this software without specific
     21   1.1      matt  *    prior written permission.
     22   1.1      matt  *
     23   1.1      matt  * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
     24   1.1      matt  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     25   1.1      matt  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26   1.1      matt  * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     27   1.1      matt  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     28   1.1      matt  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     29   1.1      matt  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30   1.1      matt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31   1.1      matt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32   1.1      matt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33   1.1      matt  * SUCH DAMAGE.
     34   1.1      matt  *
     35   1.1      matt  * RiscBSD kernel project
     36   1.1      matt  *
     37   1.1      matt  * cpu.c
     38   1.1      matt  *
     39  1.55       wiz  * Probing and configuration for the master CPU
     40   1.1      matt  *
     41   1.1      matt  * Created      : 10/10/95
     42   1.1      matt  */
     43   1.1      matt 
     44   1.1      matt #include "opt_armfpe.h"
     45  1.51    martin #include "opt_multiprocessor.h"
     46   1.1      matt 
     47   1.1      matt #include <sys/param.h>
     48  1.20     bjh21 
     49  1.85      matt __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.85 2012/08/29 17:44:25 matt Exp $");
     50  1.20     bjh21 
     51   1.1      matt #include <sys/systm.h>
     52  1.85      matt #include <sys/conf.h>
     53  1.85      matt #include <sys/cpu.h>
     54   1.1      matt #include <sys/device.h>
     55  1.85      matt #include <sys/kmem.h>
     56   1.1      matt #include <sys/proc.h>
     57  1.85      matt 
     58   1.1      matt #include <uvm/uvm_extern.h>
     59  1.33   thorpej 
     60  1.33   thorpej #include <arm/cpuconf.h>
     61  1.10   thorpej #include <arm/undefined.h>
     62  1.10   thorpej 
     63   1.1      matt #ifdef ARMFPE
     64   1.1      matt #include <machine/bootconfig.h> /* For boot args */
     65  1.11   thorpej #include <arm/fpe-arm/armfpe.h>
     66  1.11   thorpej #endif
     67   1.1      matt 
     68  1.20     bjh21 char cpu_model[256];
     69   1.1      matt 
     70  1.85      matt #ifdef MULTIPROCESSOR
     71  1.85      matt volatile u_int arm_cpu_hatched = 0;
     72  1.85      matt u_int arm_cpu_max = 0;
     73  1.85      matt uint32_t arm_cpu_mbox __cacheline_aligned = 0;
     74  1.85      matt uint32_t arm_cpu_marker __cacheline_aligned = 1;
     75  1.85      matt #endif
     76  1.85      matt 
     77   1.1      matt /* Prototypes */
     78  1.84      matt void identify_arm_cpu(device_t dv, struct cpu_info *);
     79  1.85      matt void identify_cortex_caches(device_t dv);
     80  1.85      matt void identify_features(device_t dv);
     81   1.1      matt 
     82   1.1      matt /*
     83  1.25     bjh21  * Identify the master (boot) CPU
     84   1.1      matt  */
     85   1.1      matt 
     86   1.1      matt void
     87  1.85      matt cpu_attach(device_t dv, cpuid_t id)
     88   1.1      matt {
     89  1.85      matt 	struct cpu_info *ci;
     90  1.85      matt 
     91  1.85      matt 	if (id == 0) {
     92  1.85      matt 		ci = curcpu();
     93  1.27   reinoud 
     94  1.85      matt 		/* Get the CPU ID from coprocessor 15 */
     95  1.85      matt 
     96  1.85      matt 		ci->ci_arm_cpuid = cpu_id();
     97  1.85      matt 		ci->ci_arm_cputype = ci->ci_arm_cpuid & CPU_ID_CPU_MASK;
     98  1.85      matt 		ci->ci_arm_cpurev = ci->ci_arm_cpuid & CPU_ID_REVISION_MASK;
     99  1.85      matt 	} else {
    100  1.85      matt #ifdef MULTIPROCESSOR
    101  1.85      matt 		KASSERT(cpu_info[id] == NULL);
    102  1.85      matt 		ci = kmem_zalloc(sizeof(*ci), KM_SLEEP);
    103  1.85      matt 		KASSERT(ci != NULL);
    104  1.85      matt 		ci->ci_cpl = IPL_HIGH;
    105  1.85      matt 		ci->ci_cpuid = id;
    106  1.85      matt 		ci->ci_data.cpu_core_id = id;
    107  1.85      matt 		ci->ci_data.cpu_cc_freq = cpu_info_store.ci_data.cpu_cc_freq;
    108  1.85      matt 		ci->ci_arm_cpuid = cpu_info_store.ci_arm_cpuid;
    109  1.85      matt 		ci->ci_arm_cputype = cpu_info_store.ci_arm_cputype;
    110  1.85      matt 		ci->ci_arm_cpurev = cpu_info_store.ci_arm_cpurev;
    111  1.85      matt 		cpu_info[ci->ci_cpuid] = ci;
    112  1.85      matt 		if ((arm_cpu_hatched & (1 << id)) == 0) {
    113  1.85      matt 			ci->ci_dev = dv;
    114  1.85      matt 			dv->dv_private = ci;
    115  1.85      matt 			aprint_naive(": disabled\n");
    116  1.85      matt 			aprint_normal(": disabled (unresponsive)\n");
    117  1.85      matt 			return;
    118  1.85      matt 		}
    119  1.85      matt #else
    120  1.85      matt 		aprint_naive(": disabled\n");
    121  1.85      matt 		aprint_normal(": disabled (uniprocessor kernel)\n");
    122  1.85      matt 		return;
    123  1.85      matt #endif
    124  1.85      matt 	}
    125  1.23     bjh21 
    126  1.85      matt 	ci->ci_dev = dv;
    127  1.85      matt 	dv->dv_private = ci;
    128   1.1      matt 
    129  1.85      matt 	evcnt_attach_dynamic(&ci->ci_arm700bugcount, EVCNT_TYPE_MISC,
    130  1.85      matt 	    NULL, device_xname(dv), "arm700swibug");
    131   1.1      matt 
    132  1.85      matt #ifdef MULTIPROCESSOR
    133  1.85      matt 	/*
    134  1.85      matt 	 * and we are done if this is a secondary processor.
    135  1.85      matt 	 */
    136  1.85      matt 	if (!CPU_IS_PRIMARY(ci)) {
    137  1.85      matt 		aprint_naive(": %s\n", cpu_model);
    138  1.85      matt 		aprint_normal(": %s\n", cpu_model);
    139  1.85      matt 		mi_cpu_attach(ci);
    140  1.85      matt 		return;
    141  1.85      matt 	}
    142  1.85      matt #endif
    143   1.1      matt 
    144  1.85      matt 	identify_arm_cpu(dv, ci);
    145   1.1      matt 
    146  1.85      matt #ifdef CPU_STRONGARM
    147  1.85      matt 	if (ci->ci_arm_cputype == CPU_ID_SA110 &&
    148  1.85      matt 	    ci->ci_arm_cpurev < 3) {
    149  1.85      matt 		aprint_normal_dev(dv, "SA-110 with bugged STM^ instruction\n");
    150   1.1      matt 	}
    151  1.85      matt #endif
    152   1.1      matt 
    153   1.1      matt #ifdef CPU_ARM8
    154  1.85      matt 	if ((ci->ci_arm_cpuid & CPU_ID_CPU_MASK) == CPU_ID_ARM810) {
    155   1.1      matt 		int clock = arm8_clock_config(0, 0);
    156   1.1      matt 		char *fclk;
    157  1.85      matt 		aprint_normal_dev(dv, "ARM810 cp15=%02x", clock);
    158  1.49   thorpej 		aprint_normal(" clock:%s", (clock & 1) ? " dynamic" : "");
    159  1.49   thorpej 		aprint_normal("%s", (clock & 2) ? " sync" : "");
    160   1.1      matt 		switch ((clock >> 2) & 3) {
    161  1.15     bjh21 		case 0:
    162   1.1      matt 			fclk = "bus clock";
    163   1.1      matt 			break;
    164  1.15     bjh21 		case 1:
    165   1.1      matt 			fclk = "ref clock";
    166   1.1      matt 			break;
    167  1.15     bjh21 		case 3:
    168   1.1      matt 			fclk = "pll";
    169   1.1      matt 			break;
    170  1.15     bjh21 		default:
    171   1.1      matt 			fclk = "illegal";
    172   1.1      matt 			break;
    173   1.1      matt 		}
    174  1.49   thorpej 		aprint_normal(" fclk source=%s\n", fclk);
    175   1.1      matt  	}
    176   1.1      matt #endif
    177   1.1      matt 
    178  1.25     bjh21 #ifdef ARMFPE
    179   1.1      matt 	/*
    180   1.1      matt 	 * Ok now we test for an FPA
    181   1.1      matt 	 * At this point no floating point emulator has been installed.
    182   1.1      matt 	 * This means any FP instruction will cause undefined exception.
    183   1.1      matt 	 * We install a temporay coproc 1 handler which will modify
    184   1.1      matt 	 * undefined_test if it is called.
    185   1.1      matt 	 * We then try to read the FP status register. If undefined_test
    186   1.1      matt 	 * has been decremented then the instruction was not handled by
    187   1.1      matt 	 * an FPA so we know the FPA is missing. If undefined_test is
    188   1.1      matt 	 * still 1 then we know the instruction was handled by an FPA.
    189   1.1      matt 	 * We then remove our test handler and look at the
    190   1.1      matt 	 * FP status register for identification.
    191   1.1      matt 	 */
    192   1.1      matt 
    193  1.25     bjh21 	/*
    194  1.25     bjh21 	 * Ok if ARMFPE is defined and the boot options request the
    195  1.25     bjh21 	 * ARM FPE then it will be installed as the FPE.
    196  1.25     bjh21 	 * This is just while I work on integrating the new FPE.
    197  1.25     bjh21 	 * It means the new FPE gets installed if compiled int (ARMFPE
    198  1.25     bjh21 	 * defined) and also gives me a on/off option when I boot in
    199  1.25     bjh21 	 * case the new FPE is causing panics.
    200  1.25     bjh21 	 */
    201   1.1      matt 
    202   1.1      matt 
    203  1.85      matt 	int usearmfpe = 1;
    204  1.25     bjh21 	if (boot_args)
    205  1.25     bjh21 		get_bootconf_option(boot_args, "armfpe",
    206  1.25     bjh21 		    BOOTOPT_TYPE_BOOLEAN, &usearmfpe);
    207  1.25     bjh21 	if (usearmfpe)
    208  1.25     bjh21 		initialise_arm_fpe();
    209   1.1      matt #endif
    210  1.67  rearnsha 
    211  1.84      matt 	vfp_attach();		/* XXX SMP */
    212   1.1      matt }
    213   1.1      matt 
    214  1.19     bjh21 enum cpu_class {
    215  1.19     bjh21 	CPU_CLASS_NONE,
    216  1.19     bjh21 	CPU_CLASS_ARM2,
    217  1.19     bjh21 	CPU_CLASS_ARM2AS,
    218  1.19     bjh21 	CPU_CLASS_ARM3,
    219  1.19     bjh21 	CPU_CLASS_ARM6,
    220  1.19     bjh21 	CPU_CLASS_ARM7,
    221  1.19     bjh21 	CPU_CLASS_ARM7TDMI,
    222  1.19     bjh21 	CPU_CLASS_ARM8,
    223  1.19     bjh21 	CPU_CLASS_ARM9TDMI,
    224  1.19     bjh21 	CPU_CLASS_ARM9ES,
    225  1.64  christos 	CPU_CLASS_ARM9EJS,
    226  1.53  rearnsha 	CPU_CLASS_ARM10E,
    227  1.57  rearnsha 	CPU_CLASS_ARM10EJ,
    228  1.19     bjh21 	CPU_CLASS_SA1,
    229  1.58  rearnsha 	CPU_CLASS_XSCALE,
    230  1.70      matt 	CPU_CLASS_ARM11J,
    231  1.70      matt 	CPU_CLASS_ARMV4,
    232  1.74      matt 	CPU_CLASS_CORTEX,
    233  1.19     bjh21 };
    234  1.19     bjh21 
    235  1.42     bjh21 static const char * const generic_steppings[16] = {
    236  1.14     bjh21 	"rev 0",	"rev 1",	"rev 2",	"rev 3",
    237  1.14     bjh21 	"rev 4",	"rev 5",	"rev 6",	"rev 7",
    238  1.14     bjh21 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    239  1.14     bjh21 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    240  1.14     bjh21 };
    241  1.14     bjh21 
    242  1.68      matt static const char * const pN_steppings[16] = {
    243  1.68      matt 	"*p0",	"*p1",	"*p2",	"*p3",	"*p4",	"*p5",	"*p6",	"*p7",
    244  1.68      matt 	"*p8",	"*p9",	"*p10",	"*p11",	"*p12",	"*p13",	"*p14",	"*p15",
    245  1.68      matt };
    246  1.68      matt 
    247  1.42     bjh21 static const char * const sa110_steppings[16] = {
    248  1.14     bjh21 	"rev 0",	"step J",	"step K",	"step S",
    249  1.14     bjh21 	"step T",	"rev 5",	"rev 6",	"rev 7",
    250  1.14     bjh21 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    251  1.14     bjh21 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    252  1.14     bjh21 };
    253  1.14     bjh21 
    254  1.42     bjh21 static const char * const sa1100_steppings[16] = {
    255  1.14     bjh21 	"rev 0",	"step B",	"step C",	"rev 3",
    256  1.14     bjh21 	"rev 4",	"rev 5",	"rev 6",	"rev 7",
    257  1.14     bjh21 	"step D",	"step E",	"rev 10"	"step G",
    258  1.14     bjh21 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    259  1.14     bjh21 };
    260  1.14     bjh21 
    261  1.42     bjh21 static const char * const sa1110_steppings[16] = {
    262  1.14     bjh21 	"step A-0",	"rev 1",	"rev 2",	"rev 3",
    263  1.14     bjh21 	"step B-0",	"step B-1",	"step B-2",	"step B-3",
    264  1.14     bjh21 	"step B-4",	"step B-5",	"rev 10",	"rev 11",
    265  1.14     bjh21 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    266  1.13   thorpej };
    267  1.13   thorpej 
    268  1.42     bjh21 static const char * const ixp12x0_steppings[16] = {
    269  1.37    ichiro 	"(IXP1200 step A)",		"(IXP1200 step B)",
    270  1.37    ichiro 	"rev 2",			"(IXP1200 step C)",
    271  1.37    ichiro 	"(IXP1200 step D)",		"(IXP1240/1250 step A)",
    272  1.37    ichiro 	"(IXP1240 step B)",		"(IXP1250 step B)",
    273  1.36   thorpej 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    274  1.36   thorpej 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    275  1.36   thorpej };
    276  1.36   thorpej 
    277  1.42     bjh21 static const char * const xscale_steppings[16] = {
    278  1.14     bjh21 	"step A-0",	"step A-1",	"step B-0",	"step C-0",
    279  1.40    briggs 	"step D-0",	"rev 5",	"rev 6",	"rev 7",
    280  1.40    briggs 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    281  1.40    briggs 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    282  1.40    briggs };
    283  1.40    briggs 
    284  1.42     bjh21 static const char * const i80321_steppings[16] = {
    285  1.40    briggs 	"step A-0",	"step B-0",	"rev 2",	"rev 3",
    286  1.14     bjh21 	"rev 4",	"rev 5",	"rev 6",	"rev 7",
    287  1.14     bjh21 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    288  1.14     bjh21 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    289  1.13   thorpej };
    290  1.13   thorpej 
    291  1.60    nonaka static const char * const i80219_steppings[16] = {
    292  1.60    nonaka 	"step A-0",	"rev 1",	"rev 2",	"rev 3",
    293  1.60    nonaka 	"rev 4",	"rev 5",	"rev 6",	"rev 7",
    294  1.60    nonaka 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    295  1.60    nonaka 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    296  1.60    nonaka };
    297  1.60    nonaka 
    298  1.56       bsh /* Steppings for PXA2[15]0 */
    299  1.42     bjh21 static const char * const pxa2x0_steppings[16] = {
    300  1.35   thorpej 	"step A-0",	"step A-1",	"step B-0",	"step B-1",
    301  1.48       rjs 	"step B-2",	"step C-0",	"rev 6",	"rev 7",
    302  1.35   thorpej 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    303  1.35   thorpej 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    304  1.35   thorpej };
    305  1.35   thorpej 
    306  1.56       bsh /* Steppings for PXA255/26x.
    307  1.56       bsh  * rev 5: PXA26x B0, rev 6: PXA255 A0
    308  1.56       bsh  */
    309  1.56       bsh static const char * const pxa255_steppings[16] = {
    310  1.56       bsh 	"rev 0",	"rev 1",	"rev 2",	"step A-0",
    311  1.56       bsh 	"rev 4",	"step B-0",	"step A-0",	"rev 7",
    312  1.56       bsh 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    313  1.56       bsh 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    314  1.56       bsh };
    315  1.56       bsh 
    316  1.59       bsh /* Stepping for PXA27x */
    317  1.59       bsh static const char * const pxa27x_steppings[16] = {
    318  1.59       bsh 	"step A-0",	"step A-1",	"step B-0",	"step B-1",
    319  1.59       bsh 	"step C-0",	"rev 5",	"rev 6",	"rev 7",
    320  1.59       bsh 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    321  1.59       bsh 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    322  1.59       bsh };
    323  1.59       bsh 
    324  1.50    ichiro static const char * const ixp425_steppings[16] = {
    325  1.50    ichiro 	"step 0",	"rev 1",	"rev 2",	"rev 3",
    326  1.50    ichiro 	"rev 4",	"rev 5",	"rev 6",	"rev 7",
    327  1.50    ichiro 	"rev 8",	"rev 9",	"rev 10",	"rev 11",
    328  1.50    ichiro 	"rev 12",	"rev 13",	"rev 14",	"rev 15",
    329  1.50    ichiro };
    330  1.50    ichiro 
    331   1.1      matt struct cpuidtab {
    332   1.1      matt 	u_int32_t	cpuid;
    333   1.1      matt 	enum		cpu_class cpu_class;
    334  1.72       mrg 	const char	*cpu_classname;
    335  1.42     bjh21 	const char * const *cpu_steppings;
    336   1.1      matt };
    337   1.1      matt 
    338   1.1      matt const struct cpuidtab cpuids[] = {
    339  1.13   thorpej 	{ CPU_ID_ARM2,		CPU_CLASS_ARM2,		"ARM2",
    340  1.13   thorpej 	  generic_steppings },
    341  1.13   thorpej 	{ CPU_ID_ARM250,	CPU_CLASS_ARM2AS,	"ARM250",
    342  1.13   thorpej 	  generic_steppings },
    343  1.13   thorpej 
    344  1.13   thorpej 	{ CPU_ID_ARM3,		CPU_CLASS_ARM3,		"ARM3",
    345  1.13   thorpej 	  generic_steppings },
    346  1.13   thorpej 
    347  1.13   thorpej 	{ CPU_ID_ARM600,	CPU_CLASS_ARM6,		"ARM600",
    348  1.13   thorpej 	  generic_steppings },
    349  1.13   thorpej 	{ CPU_ID_ARM610,	CPU_CLASS_ARM6,		"ARM610",
    350  1.13   thorpej 	  generic_steppings },
    351  1.13   thorpej 	{ CPU_ID_ARM620,	CPU_CLASS_ARM6,		"ARM620",
    352  1.13   thorpej 	  generic_steppings },
    353  1.13   thorpej 
    354  1.13   thorpej 	{ CPU_ID_ARM700,	CPU_CLASS_ARM7,		"ARM700",
    355  1.13   thorpej 	  generic_steppings },
    356  1.13   thorpej 	{ CPU_ID_ARM710,	CPU_CLASS_ARM7,		"ARM710",
    357  1.13   thorpej 	  generic_steppings },
    358  1.13   thorpej 	{ CPU_ID_ARM7500,	CPU_CLASS_ARM7,		"ARM7500",
    359  1.13   thorpej 	  generic_steppings },
    360  1.13   thorpej 	{ CPU_ID_ARM710A,	CPU_CLASS_ARM7,		"ARM710a",
    361  1.13   thorpej 	  generic_steppings },
    362  1.13   thorpej 	{ CPU_ID_ARM7500FE,	CPU_CLASS_ARM7,		"ARM7500FE",
    363  1.13   thorpej 	  generic_steppings },
    364  1.13   thorpej 	{ CPU_ID_ARM710T,	CPU_CLASS_ARM7TDMI,	"ARM710T",
    365  1.13   thorpej 	  generic_steppings },
    366  1.13   thorpej 	{ CPU_ID_ARM720T,	CPU_CLASS_ARM7TDMI,	"ARM720T",
    367  1.13   thorpej 	  generic_steppings },
    368  1.13   thorpej 	{ CPU_ID_ARM740T8K,	CPU_CLASS_ARM7TDMI, "ARM740T (8 KB cache)",
    369  1.13   thorpej 	  generic_steppings },
    370  1.13   thorpej 	{ CPU_ID_ARM740T4K,	CPU_CLASS_ARM7TDMI, "ARM740T (4 KB cache)",
    371  1.13   thorpej 	  generic_steppings },
    372  1.13   thorpej 
    373  1.13   thorpej 	{ CPU_ID_ARM810,	CPU_CLASS_ARM8,		"ARM810",
    374  1.13   thorpej 	  generic_steppings },
    375  1.13   thorpej 
    376  1.13   thorpej 	{ CPU_ID_ARM920T,	CPU_CLASS_ARM9TDMI,	"ARM920T",
    377  1.13   thorpej 	  generic_steppings },
    378  1.13   thorpej 	{ CPU_ID_ARM922T,	CPU_CLASS_ARM9TDMI,	"ARM922T",
    379  1.13   thorpej 	  generic_steppings },
    380  1.64  christos 	{ CPU_ID_ARM926EJS,	CPU_CLASS_ARM9EJS,	"ARM926EJ-S",
    381  1.64  christos 	  generic_steppings },
    382  1.13   thorpej 	{ CPU_ID_ARM940T,	CPU_CLASS_ARM9TDMI,	"ARM940T",
    383  1.13   thorpej 	  generic_steppings },
    384  1.13   thorpej 	{ CPU_ID_ARM946ES,	CPU_CLASS_ARM9ES,	"ARM946E-S",
    385  1.13   thorpej 	  generic_steppings },
    386  1.13   thorpej 	{ CPU_ID_ARM966ES,	CPU_CLASS_ARM9ES,	"ARM966E-S",
    387  1.13   thorpej 	  generic_steppings },
    388  1.13   thorpej 	{ CPU_ID_ARM966ESR1,	CPU_CLASS_ARM9ES,	"ARM966E-S",
    389  1.52   mycroft 	  generic_steppings },
    390  1.52   mycroft 	{ CPU_ID_TI925T,	CPU_CLASS_ARM9TDMI,	"TI ARM925T",
    391  1.13   thorpej 	  generic_steppings },
    392  1.77  kiyohara 	{ CPU_ID_MV88SV131,	CPU_CLASS_ARM9ES,	"Sheeva 88SV131",
    393  1.77  kiyohara 	  generic_steppings },
    394  1.77  kiyohara 	{ CPU_ID_MV88FR571_VD,	CPU_CLASS_ARM9ES,	"Sheeva 88FR571-vd",
    395  1.77  kiyohara 	  generic_steppings },
    396  1.13   thorpej 
    397  1.53  rearnsha 	{ CPU_ID_ARM1020E,	CPU_CLASS_ARM10E,	"ARM1020E",
    398  1.53  rearnsha 	  generic_steppings },
    399  1.53  rearnsha 	{ CPU_ID_ARM1022ES,	CPU_CLASS_ARM10E,	"ARM1022E-S",
    400  1.53  rearnsha 	  generic_steppings },
    401  1.57  rearnsha 	{ CPU_ID_ARM1026EJS,	CPU_CLASS_ARM10EJ,	"ARM1026EJ-S",
    402  1.57  rearnsha 	  generic_steppings },
    403  1.53  rearnsha 
    404  1.13   thorpej 	{ CPU_ID_SA110,		CPU_CLASS_SA1,		"SA-110",
    405  1.14     bjh21 	  sa110_steppings },
    406  1.13   thorpej 	{ CPU_ID_SA1100,	CPU_CLASS_SA1,		"SA-1100",
    407  1.14     bjh21 	  sa1100_steppings },
    408  1.13   thorpej 	{ CPU_ID_SA1110,	CPU_CLASS_SA1,		"SA-1110",
    409  1.14     bjh21 	  sa1110_steppings },
    410  1.36   thorpej 
    411  1.36   thorpej 	{ CPU_ID_IXP1200,	CPU_CLASS_SA1,		"IXP1200",
    412  1.37    ichiro 	  ixp12x0_steppings },
    413  1.13   thorpej 
    414  1.32   thorpej 	{ CPU_ID_80200,		CPU_CLASS_XSCALE,	"i80200",
    415  1.32   thorpej 	  xscale_steppings },
    416  1.32   thorpej 
    417  1.38   thorpej 	{ CPU_ID_80321_400,	CPU_CLASS_XSCALE,	"i80321 400MHz",
    418  1.40    briggs 	  i80321_steppings },
    419  1.38   thorpej 	{ CPU_ID_80321_600,	CPU_CLASS_XSCALE,	"i80321 600MHz",
    420  1.40    briggs 	  i80321_steppings },
    421  1.40    briggs 	{ CPU_ID_80321_400_B0,	CPU_CLASS_XSCALE,	"i80321 400MHz",
    422  1.40    briggs 	  i80321_steppings },
    423  1.40    briggs 	{ CPU_ID_80321_600_B0,	CPU_CLASS_XSCALE,	"i80321 600MHz",
    424  1.40    briggs 	  i80321_steppings },
    425  1.13   thorpej 
    426  1.60    nonaka 	{ CPU_ID_80219_400,	CPU_CLASS_XSCALE,	"i80219 400MHz",
    427  1.60    nonaka 	  i80219_steppings },
    428  1.60    nonaka 	{ CPU_ID_80219_600,	CPU_CLASS_XSCALE,	"i80219 600MHz",
    429  1.60    nonaka 	  i80219_steppings },
    430  1.60    nonaka 
    431  1.59       bsh 	{ CPU_ID_PXA27X,	CPU_CLASS_XSCALE,	"PXA27x",
    432  1.59       bsh 	  pxa27x_steppings },
    433  1.48       rjs 	{ CPU_ID_PXA250A,	CPU_CLASS_XSCALE,	"PXA250",
    434  1.48       rjs 	  pxa2x0_steppings },
    435  1.48       rjs 	{ CPU_ID_PXA210A,	CPU_CLASS_XSCALE,	"PXA210",
    436  1.48       rjs 	  pxa2x0_steppings },
    437  1.48       rjs 	{ CPU_ID_PXA250B,	CPU_CLASS_XSCALE,	"PXA250",
    438  1.39    ichiro 	  pxa2x0_steppings },
    439  1.48       rjs 	{ CPU_ID_PXA210B,	CPU_CLASS_XSCALE,	"PXA210",
    440  1.39    ichiro 	  pxa2x0_steppings },
    441  1.56       bsh 	{ CPU_ID_PXA250C, 	CPU_CLASS_XSCALE,	"PXA255/26x",
    442  1.56       bsh 	  pxa255_steppings },
    443  1.48       rjs 	{ CPU_ID_PXA210C, 	CPU_CLASS_XSCALE,	"PXA210",
    444  1.35   thorpej 	  pxa2x0_steppings },
    445  1.35   thorpej 
    446  1.50    ichiro 	{ CPU_ID_IXP425_533,	CPU_CLASS_XSCALE,	"IXP425 533MHz",
    447  1.50    ichiro 	  ixp425_steppings },
    448  1.50    ichiro 	{ CPU_ID_IXP425_400,	CPU_CLASS_XSCALE,	"IXP425 400MHz",
    449  1.50    ichiro 	  ixp425_steppings },
    450  1.50    ichiro 	{ CPU_ID_IXP425_266,	CPU_CLASS_XSCALE,	"IXP425 266MHz",
    451  1.50    ichiro 	  ixp425_steppings },
    452  1.50    ichiro 
    453  1.68      matt 	{ CPU_ID_ARM1136JS,	CPU_CLASS_ARM11J,	"ARM1136J-S r0",
    454  1.68      matt 	  pN_steppings },
    455  1.68      matt 	{ CPU_ID_ARM1136JSR1,	CPU_CLASS_ARM11J,	"ARM1136J-S r1",
    456  1.68      matt 	  pN_steppings },
    457  1.81     skrll #if 0
    458  1.81     skrll 	/* The ARM1156T2-S only has a memory protection unit */
    459  1.80     skrll 	{ CPU_ID_ARM1156T2S,	CPU_CLASS_ARM11J,	"ARM1156T2-S r0",
    460  1.80     skrll 	  pN_steppings },
    461  1.81     skrll #endif
    462  1.79     skrll 	{ CPU_ID_ARM1176JZS,	CPU_CLASS_ARM11J,	"ARM1176JZ-S r0",
    463  1.68      matt 	  pN_steppings },
    464  1.74      matt 
    465  1.78       bsh 	{ CPU_ID_ARM11MPCORE,	CPU_CLASS_ARM11J, 	"ARM11 MPCore",
    466  1.78       bsh 	  generic_steppings },
    467  1.78       bsh 
    468  1.82      matt 	{ CPU_ID_CORTEXA5R0,	CPU_CLASS_CORTEX,	"Cortex-A5 r0",
    469  1.82      matt 	  pN_steppings },
    470  1.74      matt 	{ CPU_ID_CORTEXA8R1,	CPU_CLASS_CORTEX,	"Cortex-A8 r1",
    471  1.74      matt 	  pN_steppings },
    472  1.74      matt 	{ CPU_ID_CORTEXA8R2,	CPU_CLASS_CORTEX,	"Cortex-A8 r2",
    473  1.74      matt 	  pN_steppings },
    474  1.74      matt 	{ CPU_ID_CORTEXA8R3,	CPU_CLASS_CORTEX,	"Cortex-A8 r3",
    475  1.69      matt 	  pN_steppings },
    476  1.82      matt 	{ CPU_ID_CORTEXA9R2,	CPU_CLASS_CORTEX,	"Cortex-A9 r2",
    477  1.82      matt 	  pN_steppings },
    478  1.82      matt 	{ CPU_ID_CORTEXA9R3,	CPU_CLASS_CORTEX,	"Cortex-A9 r3",
    479  1.82      matt 	  pN_steppings },
    480  1.82      matt 	{ CPU_ID_CORTEXA9R4,	CPU_CLASS_CORTEX,	"Cortex-A9 r4",
    481  1.82      matt 	  pN_steppings },
    482  1.82      matt 	{ CPU_ID_CORTEXA15R2,	CPU_CLASS_CORTEX,	"Cortex-A15 r2",
    483  1.69      matt 	  pN_steppings },
    484  1.82      matt 	{ CPU_ID_CORTEXA15R3,	CPU_CLASS_CORTEX,	"Cortex-A15 r3",
    485  1.73  jmcneill 	  pN_steppings },
    486  1.58  rearnsha 
    487  1.70      matt 	{ CPU_ID_FA526,		CPU_CLASS_ARMV4,	"FA526",
    488  1.70      matt 	  generic_steppings },
    489  1.70      matt 
    490  1.13   thorpej 	{ 0, CPU_CLASS_NONE, NULL, NULL }
    491   1.1      matt };
    492   1.1      matt 
    493   1.1      matt struct cpu_classtab {
    494   1.9   thorpej 	const char	*class_name;
    495   1.9   thorpej 	const char	*class_option;
    496   1.1      matt };
    497   1.1      matt 
    498   1.1      matt const struct cpu_classtab cpu_classes[] = {
    499  1.74      matt 	[CPU_CLASS_NONE] =	{ "unknown",	NULL },
    500  1.74      matt 	[CPU_CLASS_ARM2] =	{ "ARM2",	"CPU_ARM2" },
    501  1.74      matt 	[CPU_CLASS_ARM2AS] =	{ "ARM2as",	"CPU_ARM250" },
    502  1.74      matt 	[CPU_CLASS_ARM3] =	{ "ARM3",	"CPU_ARM3" },
    503  1.74      matt 	[CPU_CLASS_ARM6] =	{ "ARM6",	"CPU_ARM6" },
    504  1.74      matt 	[CPU_CLASS_ARM7] =	{ "ARM7",	"CPU_ARM7" },
    505  1.74      matt 	[CPU_CLASS_ARM7TDMI] =	{ "ARM7TDMI",	"CPU_ARM7TDMI" },
    506  1.74      matt 	[CPU_CLASS_ARM8] =	{ "ARM8",	"CPU_ARM8" },
    507  1.74      matt 	[CPU_CLASS_ARM9TDMI] =	{ "ARM9TDMI",	NULL },
    508  1.74      matt 	[CPU_CLASS_ARM9ES] =	{ "ARM9E-S",	"CPU_ARM9E" },
    509  1.74      matt 	[CPU_CLASS_ARM9EJS] =	{ "ARM9EJ-S",	"CPU_ARM9E" },
    510  1.74      matt 	[CPU_CLASS_ARM10E] =	{ "ARM10E",	"CPU_ARM10" },
    511  1.74      matt 	[CPU_CLASS_ARM10EJ] =	{ "ARM10EJ",	"CPU_ARM10" },
    512  1.74      matt 	[CPU_CLASS_SA1] =	{ "SA-1",	"CPU_SA110" },
    513  1.74      matt 	[CPU_CLASS_XSCALE] =	{ "XScale",	"CPU_XSCALE_..." },
    514  1.74      matt 	[CPU_CLASS_ARM11J] =	{ "ARM11J",	"CPU_ARM11" },
    515  1.74      matt 	[CPU_CLASS_ARMV4] =	{ "ARMv4",	"CPU_ARMV4" },
    516  1.75      matt 	[CPU_CLASS_CORTEX] =	{ "Cortex",	"CPU_CORTEX" },
    517   1.1      matt };
    518   1.1      matt 
    519   1.1      matt /*
    520  1.47       wiz  * Report the type of the specified arm processor. This uses the generic and
    521  1.55       wiz  * arm specific information in the CPU structure to identify the processor.
    522  1.55       wiz  * The remaining fields in the CPU structure are filled in appropriately.
    523   1.1      matt  */
    524   1.1      matt 
    525  1.42     bjh21 static const char * const wtnames[] = {
    526  1.12   thorpej 	"write-through",
    527  1.12   thorpej 	"write-back",
    528  1.12   thorpej 	"write-back",
    529  1.12   thorpej 	"**unknown 3**",
    530  1.12   thorpej 	"**unknown 4**",
    531  1.12   thorpej 	"write-back-locking",		/* XXX XScale-specific? */
    532  1.12   thorpej 	"write-back-locking-A",
    533  1.12   thorpej 	"write-back-locking-B",
    534  1.12   thorpej 	"**unknown 8**",
    535  1.12   thorpej 	"**unknown 9**",
    536  1.12   thorpej 	"**unknown 10**",
    537  1.12   thorpej 	"**unknown 11**",
    538  1.12   thorpej 	"**unknown 12**",
    539  1.12   thorpej 	"**unknown 13**",
    540  1.57  rearnsha 	"write-back-locking-C",
    541  1.12   thorpej 	"**unknown 15**",
    542  1.12   thorpej };
    543  1.12   thorpej 
    544   1.1      matt void
    545  1.84      matt identify_arm_cpu(device_t dv, struct cpu_info *ci)
    546   1.1      matt {
    547  1.54     chris 	enum cpu_class cpu_class = CPU_CLASS_NONE;
    548  1.85      matt 	const u_int cpuid = ci->ci_arm_cpuid;
    549  1.85      matt 	const char * const xname = device_xname(dv);
    550  1.85      matt 	const char *steppingstr;
    551   1.1      matt 	int i;
    552   1.1      matt 
    553   1.1      matt 	if (cpuid == 0) {
    554  1.49   thorpej 		aprint_error("Processor failed probe - no CPU ID\n");
    555   1.1      matt 		return;
    556   1.1      matt 	}
    557   1.1      matt 
    558   1.1      matt 	for (i = 0; cpuids[i].cpuid != 0; i++)
    559   1.1      matt 		if (cpuids[i].cpuid == (cpuid & CPU_ID_CPU_MASK)) {
    560  1.19     bjh21 			cpu_class = cpuids[i].cpu_class;
    561  1.68      matt 			steppingstr = cpuids[i].cpu_steppings[cpuid &
    562  1.68      matt 			    CPU_ID_REVISION_MASK],
    563  1.68      matt 			sprintf(cpu_model, "%s%s%s (%s core)",
    564  1.72       mrg 			    cpuids[i].cpu_classname,
    565  1.68      matt 			    steppingstr[0] == '*' ? "" : " ",
    566  1.68      matt 			    &steppingstr[steppingstr[0] == '*'],
    567  1.19     bjh21 			    cpu_classes[cpu_class].class_name);
    568   1.1      matt 			break;
    569   1.1      matt 		}
    570   1.1      matt 
    571   1.1      matt 	if (cpuids[i].cpuid == 0)
    572  1.20     bjh21 		sprintf(cpu_model, "unknown CPU (ID = 0x%x)", cpuid);
    573   1.1      matt 
    574  1.85      matt 	if (ci->ci_data.cpu_cc_freq != 0) {
    575  1.85      matt 		char freqbuf[8];
    576  1.85      matt 		humanize_number(freqbuf, sizeof(freqbuf), ci->ci_data.cpu_cc_freq,
    577  1.85      matt 		    "Hz", 1000);
    578  1.85      matt 
    579  1.85      matt 		aprint_naive(": %s %s\n", freqbuf, cpu_model);
    580  1.85      matt 		aprint_normal(": %s %s\n", freqbuf, cpu_model);
    581  1.85      matt 	} else {
    582  1.85      matt 		aprint_naive(": %s\n", cpu_model);
    583  1.85      matt 		aprint_normal(": %s\n", cpu_model);
    584  1.85      matt 	}
    585  1.29     bjh21 
    586  1.85      matt 	aprint_normal("%s:", xname);
    587  1.29     bjh21 
    588  1.19     bjh21 	switch (cpu_class) {
    589   1.1      matt 	case CPU_CLASS_ARM6:
    590   1.1      matt 	case CPU_CLASS_ARM7:
    591   1.3     chris 	case CPU_CLASS_ARM7TDMI:
    592   1.1      matt 	case CPU_CLASS_ARM8:
    593  1.18     bjh21 		if ((ci->ci_ctrl & CPU_CONTROL_IDC_ENABLE) == 0)
    594  1.49   thorpej 			aprint_normal(" IDC disabled");
    595   1.1      matt 		else
    596  1.49   thorpej 			aprint_normal(" IDC enabled");
    597   1.1      matt 		break;
    598   1.6  rearnsha 	case CPU_CLASS_ARM9TDMI:
    599  1.64  christos 	case CPU_CLASS_ARM9ES:
    600  1.64  christos 	case CPU_CLASS_ARM9EJS:
    601  1.53  rearnsha 	case CPU_CLASS_ARM10E:
    602  1.57  rearnsha 	case CPU_CLASS_ARM10EJ:
    603   1.1      matt 	case CPU_CLASS_SA1:
    604   1.4      matt 	case CPU_CLASS_XSCALE:
    605  1.58  rearnsha 	case CPU_CLASS_ARM11J:
    606  1.71      matt 	case CPU_CLASS_ARMV4:
    607  1.74      matt 	case CPU_CLASS_CORTEX:
    608  1.18     bjh21 		if ((ci->ci_ctrl & CPU_CONTROL_DC_ENABLE) == 0)
    609  1.49   thorpej 			aprint_normal(" DC disabled");
    610   1.1      matt 		else
    611  1.49   thorpej 			aprint_normal(" DC enabled");
    612  1.18     bjh21 		if ((ci->ci_ctrl & CPU_CONTROL_IC_ENABLE) == 0)
    613  1.49   thorpej 			aprint_normal(" IC disabled");
    614   1.1      matt 		else
    615  1.49   thorpej 			aprint_normal(" IC enabled");
    616   1.1      matt 		break;
    617  1.19     bjh21 	default:
    618  1.19     bjh21 		break;
    619   1.1      matt 	}
    620  1.18     bjh21 	if ((ci->ci_ctrl & CPU_CONTROL_WBUF_ENABLE) == 0)
    621  1.49   thorpej 		aprint_normal(" WB disabled");
    622   1.1      matt 	else
    623  1.49   thorpej 		aprint_normal(" WB enabled");
    624   1.1      matt 
    625  1.18     bjh21 	if (ci->ci_ctrl & CPU_CONTROL_LABT_ENABLE)
    626  1.49   thorpej 		aprint_normal(" LABT");
    627   1.1      matt 	else
    628  1.49   thorpej 		aprint_normal(" EABT");
    629   1.1      matt 
    630  1.18     bjh21 	if (ci->ci_ctrl & CPU_CONTROL_BPRD_ENABLE)
    631  1.49   thorpej 		aprint_normal(" branch prediction enabled");
    632   1.1      matt 
    633  1.49   thorpej 	aprint_normal("\n");
    634   1.1      matt 
    635  1.85      matt #ifdef CPU_CORTEX
    636  1.85      matt 	if (CPU_ID_CORTEX_P(cpuid)) {
    637  1.85      matt 		identify_cortex_caches(dv);
    638  1.85      matt 		if (0)
    639  1.85      matt 			identify_features(dv);
    640  1.85      matt 	} else
    641  1.85      matt #endif
    642  1.12   thorpej 	/* Print cache info. */
    643  1.85      matt 	if (arm_picache_line_size != 0 || arm_pdcache_line_size != 0) {
    644  1.85      matt 
    645  1.85      matt 		if (arm_pcache_unified) {
    646  1.85      matt 			aprint_normal_dev(dv, "%dKB/%dB %d-way %s unified cache\n",
    647  1.85      matt 			    arm_pdcache_size / 1024,
    648  1.85      matt 			    arm_pdcache_line_size, arm_pdcache_ways,
    649  1.85      matt 			    wtnames[arm_pcache_type]);
    650  1.85      matt 		} else {
    651  1.85      matt 			aprint_normal_dev(dv, "%dKB/%dB %d-way Instruction cache\n",
    652  1.85      matt 			    arm_picache_size / 1024,
    653  1.85      matt 			    arm_picache_line_size, arm_picache_ways);
    654  1.85      matt 			aprint_normal_dev(dv, "%dKB/%dB %d-way %s Data cache\n",
    655  1.85      matt 			    arm_pdcache_size / 1024,
    656  1.85      matt 			    arm_pdcache_line_size, arm_pdcache_ways,
    657  1.85      matt 			    wtnames[arm_pcache_type]);
    658  1.85      matt 		}
    659  1.12   thorpej 
    660  1.12   thorpej 	}
    661  1.12   thorpej 
    662   1.1      matt 
    663  1.19     bjh21 	switch (cpu_class) {
    664   1.1      matt #ifdef CPU_ARM2
    665   1.1      matt 	case CPU_CLASS_ARM2:
    666   1.1      matt #endif
    667   1.1      matt #ifdef CPU_ARM250
    668   1.1      matt 	case CPU_CLASS_ARM2AS:
    669   1.1      matt #endif
    670   1.1      matt #ifdef CPU_ARM3
    671   1.1      matt 	case CPU_CLASS_ARM3:
    672   1.1      matt #endif
    673   1.1      matt #ifdef CPU_ARM6
    674   1.1      matt 	case CPU_CLASS_ARM6:
    675   1.1      matt #endif
    676   1.1      matt #ifdef CPU_ARM7
    677   1.1      matt 	case CPU_CLASS_ARM7:
    678   1.1      matt #endif
    679   1.3     chris #ifdef CPU_ARM7TDMI
    680   1.3     chris 	case CPU_CLASS_ARM7TDMI:
    681   1.3     chris #endif
    682   1.1      matt #ifdef CPU_ARM8
    683   1.1      matt 	case CPU_CLASS_ARM8:
    684   1.6  rearnsha #endif
    685   1.6  rearnsha #ifdef CPU_ARM9
    686   1.6  rearnsha 	case CPU_CLASS_ARM9TDMI:
    687  1.53  rearnsha #endif
    688  1.77  kiyohara #if defined(CPU_ARM9E) || defined(CPU_SHEEVA)
    689  1.64  christos 	case CPU_CLASS_ARM9ES:
    690  1.64  christos 	case CPU_CLASS_ARM9EJS:
    691  1.64  christos #endif
    692  1.53  rearnsha #ifdef CPU_ARM10
    693  1.53  rearnsha 	case CPU_CLASS_ARM10E:
    694  1.57  rearnsha 	case CPU_CLASS_ARM10EJ:
    695   1.1      matt #endif
    696  1.37    ichiro #if defined(CPU_SA110) || defined(CPU_SA1100) || \
    697  1.37    ichiro     defined(CPU_SA1110) || defined(CPU_IXP12X0)
    698   1.1      matt 	case CPU_CLASS_SA1:
    699   1.4      matt #endif
    700  1.35   thorpej #if defined(CPU_XSCALE_80200) || defined(CPU_XSCALE_80321) || \
    701  1.59       bsh     defined(__CPU_XSCALE_PXA2XX) || defined(CPU_XSCALE_IXP425)
    702   1.4      matt 	case CPU_CLASS_XSCALE:
    703   1.1      matt #endif
    704  1.68      matt #if defined(CPU_ARM11)
    705  1.58  rearnsha 	case CPU_CLASS_ARM11J:
    706  1.76      matt #endif
    707  1.76      matt #if defined(CPU_CORTEX)
    708  1.74      matt 	case CPU_CLASS_CORTEX:
    709  1.58  rearnsha #endif
    710  1.71      matt #if defined(CPU_FA526)
    711  1.71      matt 	case CPU_CLASS_ARMV4:
    712  1.71      matt #endif
    713   1.1      matt 		break;
    714   1.1      matt 	default:
    715  1.85      matt 		if (cpu_classes[cpu_class].class_option == NULL) {
    716  1.85      matt 			aprint_error_dev(dv, "%s does not fully support this CPU.\n",
    717  1.85      matt 			     ostype);
    718  1.85      matt 		} else {
    719  1.85      matt 			aprint_error_dev(dv, "This kernel does not fully support "
    720  1.85      matt 			       "this CPU.\n");
    721  1.85      matt 			aprint_normal_dev(dv, "Recompile with \"options %s\" to "
    722  1.85      matt 			       "correct this.\n", cpu_classes[cpu_class].class_option);
    723   1.1      matt 		}
    724   1.1      matt 		break;
    725   1.1      matt 	}
    726  1.43     bjh21 }
    727   1.1      matt 
    728  1.85      matt #ifdef CPU_CORTEX
    729  1.85      matt static void
    730  1.85      matt print_cortex_cache(device_t dv, u_int level, const char *desc)
    731  1.85      matt {
    732  1.85      matt 	uint32_t ccsidr = armreg_ccsidr_read();
    733  1.85      matt 	u_int linesize = 1 << ((ccsidr & 7) + 4);
    734  1.85      matt 	u_int nways = ((ccsidr >> 3) & 0x3ff) + 1;
    735  1.85      matt 	u_int nsets = ((ccsidr >> 13) & 0x7fff) + 1;
    736  1.85      matt 	u_int totalsize = linesize * nways * nsets;
    737  1.85      matt 	static const char * const wstrings[] = {
    738  1.85      matt 		"", " write-back", " write-through", ""
    739  1.85      matt 	};
    740  1.85      matt 	static const char * const astrings[] = {
    741  1.85      matt 		"",
    742  1.85      matt 		" with write allocate",
    743  1.85      matt 		" with read allocate",
    744  1.85      matt 		" with read and write allocate"
    745  1.85      matt 	};
    746  1.85      matt 
    747  1.85      matt 	//aprint_debug_dev(dv, "ccsidr=%#x\n", ccsidr);
    748  1.85      matt 
    749  1.85      matt 	u_int wtype = (ccsidr >> 30) & 3;
    750  1.85      matt 	u_int atype = (ccsidr >> 28) & 3;
    751  1.85      matt 
    752  1.85      matt 	aprint_normal_dev(dv, "%uKB/%uB %u-way%s L%u %s cache%s\n",
    753  1.85      matt 	    totalsize / 1024, linesize, nways, wstrings[wtype], level + 1,
    754  1.85      matt 	    desc, astrings[atype]);
    755  1.85      matt }
    756  1.85      matt 
    757  1.85      matt void
    758  1.85      matt identify_cortex_caches(device_t dv)
    759  1.85      matt {
    760  1.85      matt 	const uint32_t orig_csselr = armreg_csselr_read();
    761  1.85      matt 	uint32_t clidr = armreg_clidr_read();
    762  1.85      matt 	u_int level;
    763  1.85      matt 
    764  1.85      matt 	//aprint_debug_dev(dv, "clidr=%011o\n", clidr);
    765  1.85      matt 
    766  1.85      matt 	for (level = 0, clidr &= 077777777; clidr & 7; clidr >>= 3, level++) {
    767  1.85      matt 		if (clidr & 1) {
    768  1.85      matt 			armreg_csselr_write(2*level + 1);
    769  1.85      matt 			print_cortex_cache(dv, level, "Instruction");
    770  1.85      matt 		}
    771  1.85      matt 		if (clidr & 6) {
    772  1.85      matt 			armreg_csselr_write(2*level + 0);
    773  1.85      matt 			print_cortex_cache(dv, level,
    774  1.85      matt 			    (clidr & 4) ? "Unified" : "Data");
    775  1.85      matt 		}
    776  1.85      matt 	}
    777  1.85      matt 
    778  1.85      matt 	armreg_csselr_write(orig_csselr);
    779  1.85      matt 
    780  1.85      matt 
    781  1.85      matt }
    782  1.85      matt 
    783  1.85      matt void
    784  1.85      matt identify_features(device_t dv)
    785  1.85      matt {
    786  1.85      matt 	uint32_t isar0 = armreg_isar0_read();
    787  1.85      matt 	uint32_t isar1 = armreg_isar1_read();
    788  1.85      matt 	uint32_t isar2 = armreg_isar2_read();
    789  1.85      matt 	uint32_t isar3 = armreg_isar3_read();
    790  1.85      matt 	uint32_t isar4 = armreg_isar4_read();
    791  1.85      matt 	uint32_t isar5 = armreg_isar5_read();
    792  1.85      matt 
    793  1.85      matt 	uint32_t mmfr0 = armreg_mmfr0_read();
    794  1.85      matt 	uint32_t mmfr1 = armreg_mmfr1_read();
    795  1.85      matt 	uint32_t mmfr2 = armreg_mmfr2_read();
    796  1.85      matt 	uint32_t mmfr3 = armreg_mmfr3_read();
    797  1.85      matt 
    798  1.85      matt 	uint32_t pfr0 = armreg_pfr0_read();
    799  1.85      matt 	uint32_t pfr1 = armreg_pfr1_read();
    800  1.85      matt 
    801  1.85      matt 	aprint_normal_dev(dv,
    802  1.85      matt 	    "isar: [0]=%#x [1]=%#x [2]=%#x [3]=%#x, [4]=%#x, [5]=%#x\n",
    803  1.85      matt 	    isar0, isar1, isar2, isar3, isar4, isar5);
    804  1.85      matt 	aprint_normal_dev(dv,
    805  1.85      matt 	    "mmfr: [0]=%#x [1]=%#x [2]=%#x [3]=%#x\n",
    806  1.85      matt 	    mmfr0, mmfr1, mmfr2, mmfr3);
    807  1.85      matt 	aprint_normal_dev(dv,
    808  1.85      matt 	    "pfr: [0]=%#x [1]=%#x\n",
    809  1.85      matt 	    pfr0, pfr1);
    810  1.85      matt }
    811  1.85      matt #endif /* CPU_CORTEX */
    812