xref: /openbmc/linux/arch/x86/include/asm/uv/bios.h (revision f331e766)
105e4d316SH. Peter Anvin #ifndef _ASM_X86_UV_BIOS_H
205e4d316SH. Peter Anvin #define _ASM_X86_UV_BIOS_H
3bb898558SAl Viro 
4bb898558SAl Viro /*
5bb898558SAl Viro  * UV BIOS layer definitions.
6bb898558SAl Viro  *
7bb898558SAl Viro  *  This program is free software; you can redistribute it and/or modify
8bb898558SAl Viro  *  it under the terms of the GNU General Public License as published by
9bb898558SAl Viro  *  the Free Software Foundation; either version 2 of the License, or
10bb898558SAl Viro  *  (at your option) any later version.
11bb898558SAl Viro  *
12bb898558SAl Viro  *  This program is distributed in the hope that it will be useful,
13bb898558SAl Viro  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14bb898558SAl Viro  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15bb898558SAl Viro  *  GNU General Public License for more details.
16bb898558SAl Viro  *
17bb898558SAl Viro  *  You should have received a copy of the GNU General Public License
18bb898558SAl Viro  *  along with this program; if not, write to the Free Software
19bb898558SAl Viro  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20bb898558SAl Viro  *
21b76365a1SRuss Anderson  *  Copyright (c) 2008-2009 Silicon Graphics, Inc.  All Rights Reserved.
22b76365a1SRuss Anderson  *  Copyright (c) Russ Anderson <rja@sgi.com>
23bb898558SAl Viro  */
24bb898558SAl Viro 
25bb898558SAl Viro #include <linux/rtc.h>
26bb898558SAl Viro 
27bb898558SAl Viro /*
28bb898558SAl Viro  * Values for the BIOS calls.  It is passed as the first * argument in the
29bb898558SAl Viro  * BIOS call.  Passing any other value in the first argument will result
30bb898558SAl Viro  * in a BIOS_STATUS_UNIMPLEMENTED return status.
31bb898558SAl Viro  */
32bb898558SAl Viro enum uv_bios_cmd {
33bb898558SAl Viro 	UV_BIOS_COMMON,
34bb898558SAl Viro 	UV_BIOS_GET_SN_INFO,
3564ccf2f9SRuss Anderson 	UV_BIOS_FREQ_BASE,
3664ccf2f9SRuss Anderson 	UV_BIOS_WATCHLIST_ALLOC,
37e8929c8aSRuss Anderson 	UV_BIOS_WATCHLIST_FREE,
3823c35700SRuss Anderson 	UV_BIOS_MEMPROTECT,
39841582eaSMike Travis 	UV_BIOS_GET_PARTITION_ADDR,
40841582eaSMike Travis 	UV_BIOS_SET_LEGACY_VGA_TARGET
41bb898558SAl Viro };
42bb898558SAl Viro 
43bb898558SAl Viro /*
44bb898558SAl Viro  * Status values returned from a BIOS call.
45bb898558SAl Viro  */
46bb898558SAl Viro enum {
4723c35700SRuss Anderson 	BIOS_STATUS_MORE_PASSES		=  1,
48bb898558SAl Viro 	BIOS_STATUS_SUCCESS		=  0,
49bb898558SAl Viro 	BIOS_STATUS_UNIMPLEMENTED	= -ENOSYS,
50bb898558SAl Viro 	BIOS_STATUS_EINVAL		= -EINVAL,
51f331e766SHedi Berriche 	BIOS_STATUS_UNAVAIL		= -EBUSY,
52f331e766SHedi Berriche 	BIOS_STATUS_ABORT		= -EINTR,
53bb898558SAl Viro };
54bb898558SAl Viro 
55ef93bf80SMike Travis /* Address map parameters */
56ef93bf80SMike Travis struct uv_gam_parameters {
57ef93bf80SMike Travis 	u64	mmr_base;
58ef93bf80SMike Travis 	u64	gru_base;
59ef93bf80SMike Travis 	u8	mmr_shift;	/* Convert PNode to MMR space offset */
60ef93bf80SMike Travis 	u8	gru_shift;	/* Convert PNode to GRU space offset */
61ef93bf80SMike Travis 	u8	gpa_shift;	/* Size of offset field in GRU phys addr */
62ef93bf80SMike Travis 	u8	unused1;
63ef93bf80SMike Travis };
64ef93bf80SMike Travis 
65ef93bf80SMike Travis /* UV_TABLE_GAM_RANGE_ENTRY values */
66ef93bf80SMike Travis #define UV_GAM_RANGE_TYPE_UNUSED	0 /* End of table */
67ef93bf80SMike Travis #define UV_GAM_RANGE_TYPE_RAM		1 /* Normal RAM */
68ef93bf80SMike Travis #define UV_GAM_RANGE_TYPE_NVRAM		2 /* Non-volatile memory */
69ef93bf80SMike Travis #define UV_GAM_RANGE_TYPE_NV_WINDOW	3 /* NVMDIMM block window */
70ef93bf80SMike Travis #define UV_GAM_RANGE_TYPE_NV_MAILBOX	4 /* NVMDIMM mailbox */
71ef93bf80SMike Travis #define UV_GAM_RANGE_TYPE_HOLE		5 /* Unused address range */
72ef93bf80SMike Travis #define UV_GAM_RANGE_TYPE_MAX		6
73ef93bf80SMike Travis 
74ef93bf80SMike Travis /* The structure stores PA bits 56:26, for 64MB granularity */
75ef93bf80SMike Travis #define UV_GAM_RANGE_SHFT		26		/* 64MB */
76ef93bf80SMike Travis 
77ef93bf80SMike Travis struct uv_gam_range_entry {
78ef93bf80SMike Travis 	char	type;		/* Entry type: GAM_RANGE_TYPE_UNUSED, etc. */
79ef93bf80SMike Travis 	char	unused1;
80ef93bf80SMike Travis 	u16	nasid;		/* HNasid */
81ef93bf80SMike Travis 	u16	sockid;		/* Socket ID, high bits of APIC ID */
82ef93bf80SMike Travis 	u16	pnode;		/* Index to MMR and GRU spaces */
8322ac2bcaSMike Travis 	u32	unused2;
84ef93bf80SMike Travis 	u32	limit;		/* PA bits 56:26 (UV_GAM_RANGE_SHFT) */
85ef93bf80SMike Travis };
86ef93bf80SMike Travis 
87ef93bf80SMike Travis #define	UV_SYSTAB_SIG			"UVST"
88ef93bf80SMike Travis #define	UV_SYSTAB_VERSION_1		1	/* UV1/2/3 BIOS version */
89ef93bf80SMike Travis #define	UV_SYSTAB_VERSION_UV4		0x400	/* UV4 BIOS base version */
90ef93bf80SMike Travis #define	UV_SYSTAB_VERSION_UV4_1		0x401	/* + gpa_shift */
91ef93bf80SMike Travis #define	UV_SYSTAB_VERSION_UV4_2		0x402	/* + TYPE_NVRAM/WINDOW/MBOX */
9222ac2bcaSMike Travis #define	UV_SYSTAB_VERSION_UV4_3		0x403	/* - GAM Range PXM Value */
9322ac2bcaSMike Travis #define	UV_SYSTAB_VERSION_UV4_LATEST	UV_SYSTAB_VERSION_UV4_3
94ef93bf80SMike Travis 
95ef93bf80SMike Travis #define	UV_SYSTAB_TYPE_UNUSED		0	/* End of table (offset == 0) */
96ef93bf80SMike Travis #define	UV_SYSTAB_TYPE_GAM_PARAMS	1	/* GAM PARAM conversions */
97ef93bf80SMike Travis #define	UV_SYSTAB_TYPE_GAM_RNG_TBL	2	/* GAM entry table */
98ef93bf80SMike Travis #define	UV_SYSTAB_TYPE_MAX		3
99ef93bf80SMike Travis 
100bb898558SAl Viro /*
101bb898558SAl Viro  * The UV system table describes specific firmware
102bb898558SAl Viro  * capabilities available to the Linux kernel at runtime.
103bb898558SAl Viro  */
104bb898558SAl Viro struct uv_systab {
105ef93bf80SMike Travis 	char signature[4];	/* must be UV_SYSTAB_SIG */
106bb898558SAl Viro 	u32 revision;		/* distinguish different firmware revs */
107bb898558SAl Viro 	u64 function;		/* BIOS runtime callback function ptr */
108ef93bf80SMike Travis 	u32 size;		/* systab size (starting with _VERSION_UV4) */
109ef93bf80SMike Travis 	struct {
110ef93bf80SMike Travis 		u32 type:8;	/* type of entry */
111ef93bf80SMike Travis 		u32 offset:24;	/* byte offset from struct start to entry */
112ef93bf80SMike Travis 	} entry[1];		/* additional entries follow */
113bb898558SAl Viro };
114ef93bf80SMike Travis extern struct uv_systab *uv_systab;
115ef93bf80SMike Travis /* (... end of definitions from UV BIOS ...) */
116bb898558SAl Viro 
117bb898558SAl Viro enum {
118bb898558SAl Viro 	BIOS_FREQ_BASE_PLATFORM = 0,
119bb898558SAl Viro 	BIOS_FREQ_BASE_INTERVAL_TIMER = 1,
120bb898558SAl Viro 	BIOS_FREQ_BASE_REALTIME_CLOCK = 2
121bb898558SAl Viro };
122bb898558SAl Viro 
123bb898558SAl Viro union partition_info_u {
124bb898558SAl Viro 	u64	val;
125bb898558SAl Viro 	struct {
126bb898558SAl Viro 		u64	hub_version	:  8,
127bb898558SAl Viro 			partition_id	: 16,
128bb898558SAl Viro 			coherence_id	: 16,
129bb898558SAl Viro 			region_size	: 24;
130bb898558SAl Viro 	};
131bb898558SAl Viro };
132bb898558SAl Viro 
133e8929c8aSRuss Anderson enum uv_memprotect {
134e8929c8aSRuss Anderson 	UV_MEMPROT_RESTRICT_ACCESS,
135e8929c8aSRuss Anderson 	UV_MEMPROT_ALLOW_AMO,
136e8929c8aSRuss Anderson 	UV_MEMPROT_ALLOW_RW
137e8929c8aSRuss Anderson };
138e8929c8aSRuss Anderson 
139bb898558SAl Viro /*
140bb898558SAl Viro  * bios calls have 6 parameters
141bb898558SAl Viro  */
142bb898558SAl Viro extern s64 uv_bios_call(enum uv_bios_cmd, u64, u64, u64, u64, u64);
143bb898558SAl Viro extern s64 uv_bios_call_irqsave(enum uv_bios_cmd, u64, u64, u64, u64, u64);
144bb898558SAl Viro extern s64 uv_bios_call_reentrant(enum uv_bios_cmd, u64, u64, u64, u64, u64);
145bb898558SAl Viro 
146b76365a1SRuss Anderson extern s64 uv_bios_get_sn_info(int, int *, long *, long *, long *, long *);
147bb898558SAl Viro extern s64 uv_bios_freq_base(u64, u64 *);
148c2c9f115SRobin Holt extern int uv_bios_mq_watchlist_alloc(unsigned long, unsigned int,
14964ccf2f9SRuss Anderson 					unsigned long *);
15064ccf2f9SRuss Anderson extern int uv_bios_mq_watchlist_free(int, int);
151e8929c8aSRuss Anderson extern s64 uv_bios_change_memprotect(u64, u64, enum uv_memprotect);
15223c35700SRuss Anderson extern s64 uv_bios_reserved_page_pa(u64, u64 *, u64 *, u64 *);
153841582eaSMike Travis extern int uv_bios_set_legacy_vga_target(bool decode, int domain, int bus);
154bb898558SAl Viro 
155ef93bf80SMike Travis #ifdef CONFIG_EFI
156bb898558SAl Viro extern void uv_bios_init(void);
157ef93bf80SMike Travis #else
158ef93bf80SMike Travis void uv_bios_init(void) { }
159ef93bf80SMike Travis #endif
160bb898558SAl Viro 
16164ccf2f9SRuss Anderson extern unsigned long sn_rtc_cycles_per_second;
162bb898558SAl Viro extern int uv_type;
163bb898558SAl Viro extern long sn_partition_id;
1645292ae11SIngo Molnar extern long sn_coherency_id;
1655292ae11SIngo Molnar extern long sn_region_size;
166b76365a1SRuss Anderson extern long system_serial_number;
167ef93bf80SMike Travis #define uv_partition_coherence_id()	(sn_coherency_id)
168bb898558SAl Viro 
169bb898558SAl Viro extern struct kobject *sgi_uv_kobj;	/* /sys/firmware/sgi_uv */
170bb898558SAl Viro 
171f331e766SHedi Berriche /*
172f331e766SHedi Berriche  * EFI runtime lock; cf. firmware/efi/runtime-wrappers.c for details
173f331e766SHedi Berriche  */
174f331e766SHedi Berriche extern struct semaphore __efi_uv_runtime_lock;
175f331e766SHedi Berriche 
17605e4d316SH. Peter Anvin #endif /* _ASM_X86_UV_BIOS_H */
177