18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * mbus.h:  Various defines for MBUS modules.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _SPARC_MBUS_H
98c2ecf20Sopenharmony_ci#define _SPARC_MBUS_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <asm/ross.h>    /* HyperSparc stuff */
128c2ecf20Sopenharmony_ci#include <asm/viking.h>  /* Ugh, bug city... */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cienum mbus_module {
158c2ecf20Sopenharmony_ci	HyperSparc        = 0,
168c2ecf20Sopenharmony_ci	Swift_ok          = 4,
178c2ecf20Sopenharmony_ci	Swift_bad_c       = 5,
188c2ecf20Sopenharmony_ci	Swift_lots_o_bugs = 6,
198c2ecf20Sopenharmony_ci	Tsunami           = 7,
208c2ecf20Sopenharmony_ci	Viking_12         = 8,
218c2ecf20Sopenharmony_ci	Viking_2x         = 9,
228c2ecf20Sopenharmony_ci	Viking_30         = 10,
238c2ecf20Sopenharmony_ci	Viking_35         = 11,
248c2ecf20Sopenharmony_ci	Viking_new        = 12,
258c2ecf20Sopenharmony_ci	TurboSparc	  = 13,
268c2ecf20Sopenharmony_ci	SRMMU_INVAL_MOD   = 14,
278c2ecf20Sopenharmony_ci};
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ciextern enum mbus_module srmmu_modtype;
308c2ecf20Sopenharmony_ciextern unsigned int viking_rev, swift_rev, cypress_rev;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* HW Mbus module bugs we have to deal with */
338c2ecf20Sopenharmony_ci#define HWBUG_COPYBACK_BROKEN        0x00000001
348c2ecf20Sopenharmony_ci#define HWBUG_ASIFLUSH_BROKEN        0x00000002
358c2ecf20Sopenharmony_ci#define HWBUG_VACFLUSH_BITROT        0x00000004
368c2ecf20Sopenharmony_ci#define HWBUG_KERN_ACCBROKEN         0x00000008
378c2ecf20Sopenharmony_ci#define HWBUG_KERN_CBITBROKEN        0x00000010
388c2ecf20Sopenharmony_ci#define HWBUG_MODIFIED_BITROT        0x00000020
398c2ecf20Sopenharmony_ci#define HWBUG_PC_BADFAULT_ADDR       0x00000040
408c2ecf20Sopenharmony_ci#define HWBUG_SUPERSCALAR_BAD        0x00000080
418c2ecf20Sopenharmony_ci#define HWBUG_PACINIT_BITROT         0x00000100
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* First the module type values. To find out which you have, just load
448c2ecf20Sopenharmony_ci * the mmu control register from ASI_M_MMUREG alternate address space and
458c2ecf20Sopenharmony_ci * shift the value right 28 bits.
468c2ecf20Sopenharmony_ci */
478c2ecf20Sopenharmony_ci/* IMPL field means the company which produced the chip. */
488c2ecf20Sopenharmony_ci#define MBUS_VIKING        0x4   /* bleech, Texas Instruments Module */
498c2ecf20Sopenharmony_ci#define MBUS_LSI           0x3   /* LSI Logics */
508c2ecf20Sopenharmony_ci#define MBUS_ROSS          0x1   /* Ross is nice */
518c2ecf20Sopenharmony_ci#define MBUS_FMI           0x0   /* Fujitsu Microelectronics/Swift */
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/* Ross Module versions */
548c2ecf20Sopenharmony_ci#define ROSS_604_REV_CDE        0x0   /* revisions c, d, and e */
558c2ecf20Sopenharmony_ci#define ROSS_604_REV_F          0x1   /* revision f */
568c2ecf20Sopenharmony_ci#define ROSS_605                0xf   /* revision a, a.1, and a.2 */
578c2ecf20Sopenharmony_ci#define ROSS_605_REV_B          0xe   /* revision b */
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* TI Viking Module versions */
608c2ecf20Sopenharmony_ci#define VIKING_REV_12           0x1   /* Version 1.2 or SPARCclassic's CPU */
618c2ecf20Sopenharmony_ci#define VIKING_REV_2            0x2   /* Version 2.1, 2.2, 2.3, and 2.4 */
628c2ecf20Sopenharmony_ci#define VIKING_REV_30           0x3   /* Version 3.0 */
638c2ecf20Sopenharmony_ci#define VIKING_REV_35           0x4   /* Version 3.5 */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/* LSI Logics. */
668c2ecf20Sopenharmony_ci#define LSI_L64815		0x0
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/* Fujitsu */
698c2ecf20Sopenharmony_ci#define FMI_AURORA		0x4   /* MB8690x, a Swift module... */
708c2ecf20Sopenharmony_ci#define FMI_TURBO		0x5   /* MB86907, a TurboSparc module... */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* For multiprocessor support we need to be able to obtain the CPU id and
738c2ecf20Sopenharmony_ci * the MBUS Module id.
748c2ecf20Sopenharmony_ci */
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/* The CPU ID is encoded in the trap base register, 20 bits to the left of
778c2ecf20Sopenharmony_ci * bit zero, with 2 bits being significant.
788c2ecf20Sopenharmony_ci */
798c2ecf20Sopenharmony_ci#define TBR_ID_SHIFT            20
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistatic inline int get_cpuid(void)
828c2ecf20Sopenharmony_ci{
838c2ecf20Sopenharmony_ci	register int retval;
848c2ecf20Sopenharmony_ci	__asm__ __volatile__("rd %%tbr, %0\n\t"
858c2ecf20Sopenharmony_ci			     "srl %0, %1, %0\n\t" :
868c2ecf20Sopenharmony_ci			     "=r" (retval) :
878c2ecf20Sopenharmony_ci			     "i" (TBR_ID_SHIFT));
888c2ecf20Sopenharmony_ci	return (retval & 3);
898c2ecf20Sopenharmony_ci}
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_cistatic inline int get_modid(void)
928c2ecf20Sopenharmony_ci{
938c2ecf20Sopenharmony_ci	return (get_cpuid() | 0x8);
948c2ecf20Sopenharmony_ci}
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#endif /* !(_SPARC_MBUS_H) */
98