18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_UV_BIOS_H 38c2ecf20Sopenharmony_ci#define _ASM_X86_UV_BIOS_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * UV BIOS layer definitions. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * (C) Copyright 2020 Hewlett Packard Enterprise Development LP 98c2ecf20Sopenharmony_ci * Copyright (C) 2007-2017 Silicon Graphics, Inc. All rights reserved. 108c2ecf20Sopenharmony_ci * Copyright (c) Russ Anderson <rja@sgi.com> 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/rtc.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* 168c2ecf20Sopenharmony_ci * Values for the BIOS calls. It is passed as the first * argument in the 178c2ecf20Sopenharmony_ci * BIOS call. Passing any other value in the first argument will result 188c2ecf20Sopenharmony_ci * in a BIOS_STATUS_UNIMPLEMENTED return status. 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_cienum uv_bios_cmd { 218c2ecf20Sopenharmony_ci UV_BIOS_COMMON, 228c2ecf20Sopenharmony_ci UV_BIOS_GET_SN_INFO, 238c2ecf20Sopenharmony_ci UV_BIOS_FREQ_BASE, 248c2ecf20Sopenharmony_ci UV_BIOS_WATCHLIST_ALLOC, 258c2ecf20Sopenharmony_ci UV_BIOS_WATCHLIST_FREE, 268c2ecf20Sopenharmony_ci UV_BIOS_MEMPROTECT, 278c2ecf20Sopenharmony_ci UV_BIOS_GET_PARTITION_ADDR, 288c2ecf20Sopenharmony_ci UV_BIOS_SET_LEGACY_VGA_TARGET 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* 328c2ecf20Sopenharmony_ci * Status values returned from a BIOS call. 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_cienum { 358c2ecf20Sopenharmony_ci BIOS_STATUS_MORE_PASSES = 1, 368c2ecf20Sopenharmony_ci BIOS_STATUS_SUCCESS = 0, 378c2ecf20Sopenharmony_ci BIOS_STATUS_UNIMPLEMENTED = -ENOSYS, 388c2ecf20Sopenharmony_ci BIOS_STATUS_EINVAL = -EINVAL, 398c2ecf20Sopenharmony_ci BIOS_STATUS_UNAVAIL = -EBUSY, 408c2ecf20Sopenharmony_ci BIOS_STATUS_ABORT = -EINTR, 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* Address map parameters */ 448c2ecf20Sopenharmony_cistruct uv_gam_parameters { 458c2ecf20Sopenharmony_ci u64 mmr_base; 468c2ecf20Sopenharmony_ci u64 gru_base; 478c2ecf20Sopenharmony_ci u8 mmr_shift; /* Convert PNode to MMR space offset */ 488c2ecf20Sopenharmony_ci u8 gru_shift; /* Convert PNode to GRU space offset */ 498c2ecf20Sopenharmony_ci u8 gpa_shift; /* Size of offset field in GRU phys addr */ 508c2ecf20Sopenharmony_ci u8 unused1; 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* UV_TABLE_GAM_RANGE_ENTRY values */ 548c2ecf20Sopenharmony_ci#define UV_GAM_RANGE_TYPE_UNUSED 0 /* End of table */ 558c2ecf20Sopenharmony_ci#define UV_GAM_RANGE_TYPE_RAM 1 /* Normal RAM */ 568c2ecf20Sopenharmony_ci#define UV_GAM_RANGE_TYPE_NVRAM 2 /* Non-volatile memory */ 578c2ecf20Sopenharmony_ci#define UV_GAM_RANGE_TYPE_NV_WINDOW 3 /* NVMDIMM block window */ 588c2ecf20Sopenharmony_ci#define UV_GAM_RANGE_TYPE_NV_MAILBOX 4 /* NVMDIMM mailbox */ 598c2ecf20Sopenharmony_ci#define UV_GAM_RANGE_TYPE_HOLE 5 /* Unused address range */ 608c2ecf20Sopenharmony_ci#define UV_GAM_RANGE_TYPE_MAX 6 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* The structure stores PA bits 56:26, for 64MB granularity */ 638c2ecf20Sopenharmony_ci#define UV_GAM_RANGE_SHFT 26 /* 64MB */ 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct uv_gam_range_entry { 668c2ecf20Sopenharmony_ci char type; /* Entry type: GAM_RANGE_TYPE_UNUSED, etc. */ 678c2ecf20Sopenharmony_ci char unused1; 688c2ecf20Sopenharmony_ci u16 nasid; /* HNasid */ 698c2ecf20Sopenharmony_ci u16 sockid; /* Socket ID, high bits of APIC ID */ 708c2ecf20Sopenharmony_ci u16 pnode; /* Index to MMR and GRU spaces */ 718c2ecf20Sopenharmony_ci u32 unused2; 728c2ecf20Sopenharmony_ci u32 limit; /* PA bits 56:26 (UV_GAM_RANGE_SHFT) */ 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define UV_AT_SIZE 8 /* 7 character arch type + NULL char */ 768c2ecf20Sopenharmony_cistruct uv_arch_type_entry { 778c2ecf20Sopenharmony_ci char archtype[UV_AT_SIZE]; 788c2ecf20Sopenharmony_ci}; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#define UV_SYSTAB_SIG "UVST" 818c2ecf20Sopenharmony_ci#define UV_SYSTAB_VERSION_1 1 /* UV2/3 BIOS version */ 828c2ecf20Sopenharmony_ci#define UV_SYSTAB_VERSION_UV4 0x400 /* UV4 BIOS base version */ 838c2ecf20Sopenharmony_ci#define UV_SYSTAB_VERSION_UV4_1 0x401 /* + gpa_shift */ 848c2ecf20Sopenharmony_ci#define UV_SYSTAB_VERSION_UV4_2 0x402 /* + TYPE_NVRAM/WINDOW/MBOX */ 858c2ecf20Sopenharmony_ci#define UV_SYSTAB_VERSION_UV4_3 0x403 /* - GAM Range PXM Value */ 868c2ecf20Sopenharmony_ci#define UV_SYSTAB_VERSION_UV4_LATEST UV_SYSTAB_VERSION_UV4_3 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define UV_SYSTAB_VERSION_UV5 0x500 /* UV5 GAM base version */ 898c2ecf20Sopenharmony_ci#define UV_SYSTAB_VERSION_UV5_LATEST UV_SYSTAB_VERSION_UV5 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define UV_SYSTAB_TYPE_UNUSED 0 /* End of table (offset == 0) */ 928c2ecf20Sopenharmony_ci#define UV_SYSTAB_TYPE_GAM_PARAMS 1 /* GAM PARAM conversions */ 938c2ecf20Sopenharmony_ci#define UV_SYSTAB_TYPE_GAM_RNG_TBL 2 /* GAM entry table */ 948c2ecf20Sopenharmony_ci#define UV_SYSTAB_TYPE_ARCH_TYPE 3 /* UV arch type */ 958c2ecf20Sopenharmony_ci#define UV_SYSTAB_TYPE_MAX 4 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci/* 988c2ecf20Sopenharmony_ci * The UV system table describes specific firmware 998c2ecf20Sopenharmony_ci * capabilities available to the Linux kernel at runtime. 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_cistruct uv_systab { 1028c2ecf20Sopenharmony_ci char signature[4]; /* must be UV_SYSTAB_SIG */ 1038c2ecf20Sopenharmony_ci u32 revision; /* distinguish different firmware revs */ 1048c2ecf20Sopenharmony_ci u64 function; /* BIOS runtime callback function ptr */ 1058c2ecf20Sopenharmony_ci u32 size; /* systab size (starting with _VERSION_UV4) */ 1068c2ecf20Sopenharmony_ci struct { 1078c2ecf20Sopenharmony_ci u32 type:8; /* type of entry */ 1088c2ecf20Sopenharmony_ci u32 offset:24; /* byte offset from struct start to entry */ 1098c2ecf20Sopenharmony_ci } entry[1]; /* additional entries follow */ 1108c2ecf20Sopenharmony_ci}; 1118c2ecf20Sopenharmony_ciextern struct uv_systab *uv_systab; 1128c2ecf20Sopenharmony_ci/* (... end of definitions from UV BIOS ...) */ 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cienum { 1158c2ecf20Sopenharmony_ci BIOS_FREQ_BASE_PLATFORM = 0, 1168c2ecf20Sopenharmony_ci BIOS_FREQ_BASE_INTERVAL_TIMER = 1, 1178c2ecf20Sopenharmony_ci BIOS_FREQ_BASE_REALTIME_CLOCK = 2 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ciunion partition_info_u { 1218c2ecf20Sopenharmony_ci u64 val; 1228c2ecf20Sopenharmony_ci struct { 1238c2ecf20Sopenharmony_ci u64 hub_version : 8, 1248c2ecf20Sopenharmony_ci partition_id : 16, 1258c2ecf20Sopenharmony_ci coherence_id : 16, 1268c2ecf20Sopenharmony_ci region_size : 24; 1278c2ecf20Sopenharmony_ci }; 1288c2ecf20Sopenharmony_ci}; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cienum uv_memprotect { 1318c2ecf20Sopenharmony_ci UV_MEMPROT_RESTRICT_ACCESS, 1328c2ecf20Sopenharmony_ci UV_MEMPROT_ALLOW_AMO, 1338c2ecf20Sopenharmony_ci UV_MEMPROT_ALLOW_RW 1348c2ecf20Sopenharmony_ci}; 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ciextern s64 uv_bios_get_sn_info(int, int *, long *, long *, long *, long *); 1378c2ecf20Sopenharmony_ciextern s64 uv_bios_freq_base(u64, u64 *); 1388c2ecf20Sopenharmony_ciextern int uv_bios_mq_watchlist_alloc(unsigned long, unsigned int, 1398c2ecf20Sopenharmony_ci unsigned long *); 1408c2ecf20Sopenharmony_ciextern int uv_bios_mq_watchlist_free(int, int); 1418c2ecf20Sopenharmony_ciextern s64 uv_bios_change_memprotect(u64, u64, enum uv_memprotect); 1428c2ecf20Sopenharmony_ciextern s64 uv_bios_reserved_page_pa(u64, u64 *, u64 *, u64 *); 1438c2ecf20Sopenharmony_ciextern int uv_bios_set_legacy_vga_target(bool decode, int domain, int bus); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ciextern int uv_bios_init(void); 1468c2ecf20Sopenharmony_ciextern unsigned long get_uv_systab_phys(bool msg); 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ciextern unsigned long sn_rtc_cycles_per_second; 1498c2ecf20Sopenharmony_ciextern int uv_type; 1508c2ecf20Sopenharmony_ciextern long sn_partition_id; 1518c2ecf20Sopenharmony_ciextern long sn_coherency_id; 1528c2ecf20Sopenharmony_ciextern long sn_region_size; 1538c2ecf20Sopenharmony_ciextern long system_serial_number; 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ciextern struct kobject *sgi_uv_kobj; /* /sys/firmware/sgi_uv */ 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci/* 1588c2ecf20Sopenharmony_ci * EFI runtime lock; cf. firmware/efi/runtime-wrappers.c for details 1598c2ecf20Sopenharmony_ci */ 1608c2ecf20Sopenharmony_ciextern struct semaphore __efi_uv_runtime_lock; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#endif /* _ASM_X86_UV_BIOS_H */ 163