18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *    Copyright IBM Corp. 2007
48c2ecf20Sopenharmony_ci *    Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef _ASM_S390_SCLP_H
88c2ecf20Sopenharmony_ci#define _ASM_S390_SCLP_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/types.h>
118c2ecf20Sopenharmony_ci#include <asm/chpid.h>
128c2ecf20Sopenharmony_ci#include <asm/cpu.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define SCLP_CHP_INFO_MASK_SIZE		32
158c2ecf20Sopenharmony_ci#define SCLP_MAX_CORES			256
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistruct sclp_chp_info {
188c2ecf20Sopenharmony_ci	u8 recognized[SCLP_CHP_INFO_MASK_SIZE];
198c2ecf20Sopenharmony_ci	u8 standby[SCLP_CHP_INFO_MASK_SIZE];
208c2ecf20Sopenharmony_ci	u8 configured[SCLP_CHP_INFO_MASK_SIZE];
218c2ecf20Sopenharmony_ci};
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define LOADPARM_LEN 8
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistruct sclp_ipl_info {
268c2ecf20Sopenharmony_ci	int is_valid;
278c2ecf20Sopenharmony_ci	int has_dump;
288c2ecf20Sopenharmony_ci	char loadparm[LOADPARM_LEN];
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistruct sclp_core_entry {
328c2ecf20Sopenharmony_ci	u8 core_id;
338c2ecf20Sopenharmony_ci	u8 reserved0;
348c2ecf20Sopenharmony_ci	u8 : 4;
358c2ecf20Sopenharmony_ci	u8 sief2 : 1;
368c2ecf20Sopenharmony_ci	u8 skey : 1;
378c2ecf20Sopenharmony_ci	u8 : 2;
388c2ecf20Sopenharmony_ci	u8 : 2;
398c2ecf20Sopenharmony_ci	u8 gpere : 1;
408c2ecf20Sopenharmony_ci	u8 siif : 1;
418c2ecf20Sopenharmony_ci	u8 sigpif : 1;
428c2ecf20Sopenharmony_ci	u8 : 3;
438c2ecf20Sopenharmony_ci	u8 reserved2[3];
448c2ecf20Sopenharmony_ci	u8 : 2;
458c2ecf20Sopenharmony_ci	u8 ib : 1;
468c2ecf20Sopenharmony_ci	u8 cei : 1;
478c2ecf20Sopenharmony_ci	u8 : 4;
488c2ecf20Sopenharmony_ci	u8 reserved3[6];
498c2ecf20Sopenharmony_ci	u8 type;
508c2ecf20Sopenharmony_ci	u8 reserved1;
518c2ecf20Sopenharmony_ci} __attribute__((packed));
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistruct sclp_core_info {
548c2ecf20Sopenharmony_ci	unsigned int configured;
558c2ecf20Sopenharmony_ci	unsigned int standby;
568c2ecf20Sopenharmony_ci	unsigned int combined;
578c2ecf20Sopenharmony_ci	struct sclp_core_entry core[SCLP_MAX_CORES];
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cistruct sclp_info {
618c2ecf20Sopenharmony_ci	unsigned char has_linemode : 1;
628c2ecf20Sopenharmony_ci	unsigned char has_vt220 : 1;
638c2ecf20Sopenharmony_ci	unsigned char has_siif : 1;
648c2ecf20Sopenharmony_ci	unsigned char has_sigpif : 1;
658c2ecf20Sopenharmony_ci	unsigned char has_core_type : 1;
668c2ecf20Sopenharmony_ci	unsigned char has_sprp : 1;
678c2ecf20Sopenharmony_ci	unsigned char has_hvs : 1;
688c2ecf20Sopenharmony_ci	unsigned char has_esca : 1;
698c2ecf20Sopenharmony_ci	unsigned char has_sief2 : 1;
708c2ecf20Sopenharmony_ci	unsigned char has_64bscao : 1;
718c2ecf20Sopenharmony_ci	unsigned char has_gpere : 1;
728c2ecf20Sopenharmony_ci	unsigned char has_cmma : 1;
738c2ecf20Sopenharmony_ci	unsigned char has_gsls : 1;
748c2ecf20Sopenharmony_ci	unsigned char has_ib : 1;
758c2ecf20Sopenharmony_ci	unsigned char has_cei : 1;
768c2ecf20Sopenharmony_ci	unsigned char has_pfmfi : 1;
778c2ecf20Sopenharmony_ci	unsigned char has_ibs : 1;
788c2ecf20Sopenharmony_ci	unsigned char has_skey : 1;
798c2ecf20Sopenharmony_ci	unsigned char has_kss : 1;
808c2ecf20Sopenharmony_ci	unsigned char has_gisaf : 1;
818c2ecf20Sopenharmony_ci	unsigned char has_diag318 : 1;
828c2ecf20Sopenharmony_ci	unsigned char has_sipl : 1;
838c2ecf20Sopenharmony_ci	unsigned char has_dirq : 1;
848c2ecf20Sopenharmony_ci	unsigned int ibc;
858c2ecf20Sopenharmony_ci	unsigned int mtid;
868c2ecf20Sopenharmony_ci	unsigned int mtid_cp;
878c2ecf20Sopenharmony_ci	unsigned int mtid_prev;
888c2ecf20Sopenharmony_ci	unsigned long rzm;
898c2ecf20Sopenharmony_ci	unsigned long rnmax;
908c2ecf20Sopenharmony_ci	unsigned long hamax;
918c2ecf20Sopenharmony_ci	unsigned int max_cores;
928c2ecf20Sopenharmony_ci	unsigned long hsa_size;
938c2ecf20Sopenharmony_ci	unsigned long facilities;
948c2ecf20Sopenharmony_ci	unsigned int hmfai;
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ciextern struct sclp_info sclp;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistruct zpci_report_error_header {
998c2ecf20Sopenharmony_ci	u8 version;	/* Interface version byte */
1008c2ecf20Sopenharmony_ci	u8 action;	/* Action qualifier byte
1018c2ecf20Sopenharmony_ci			 * 0: Adapter Reset Request
1028c2ecf20Sopenharmony_ci			 * 1: Deconfigure and repair action requested
1038c2ecf20Sopenharmony_ci			 *	(OpenCrypto Problem Call Home)
1048c2ecf20Sopenharmony_ci			 * 2: Informational Report
1058c2ecf20Sopenharmony_ci			 *	(OpenCrypto Successful Diagnostics Execution)
1068c2ecf20Sopenharmony_ci			 */
1078c2ecf20Sopenharmony_ci	u16 length;	/* Length of Subsequent Data (up to 4K – SCLP header */
1088c2ecf20Sopenharmony_ci	u8 data[0];	/* Subsequent Data passed verbatim to SCLP ET 24 */
1098c2ecf20Sopenharmony_ci} __packed;
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ciint sclp_early_read_info(void);
1128c2ecf20Sopenharmony_ciint sclp_early_read_storage_info(void);
1138c2ecf20Sopenharmony_ciint sclp_early_get_core_info(struct sclp_core_info *info);
1148c2ecf20Sopenharmony_civoid sclp_early_get_ipl_info(struct sclp_ipl_info *info);
1158c2ecf20Sopenharmony_civoid sclp_early_detect(void);
1168c2ecf20Sopenharmony_civoid sclp_early_printk(const char *s);
1178c2ecf20Sopenharmony_civoid __sclp_early_printk(const char *s, unsigned int len);
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ciint sclp_early_get_memsize(unsigned long *mem);
1208c2ecf20Sopenharmony_ciint sclp_early_get_hsa_size(unsigned long *hsa_size);
1218c2ecf20Sopenharmony_ciint _sclp_get_core_info(struct sclp_core_info *info);
1228c2ecf20Sopenharmony_ciint sclp_core_configure(u8 core);
1238c2ecf20Sopenharmony_ciint sclp_core_deconfigure(u8 core);
1248c2ecf20Sopenharmony_ciint sclp_sdias_blk_count(void);
1258c2ecf20Sopenharmony_ciint sclp_sdias_copy(void *dest, int blk_num, int nr_blks);
1268c2ecf20Sopenharmony_ciint sclp_chp_configure(struct chp_id chpid);
1278c2ecf20Sopenharmony_ciint sclp_chp_deconfigure(struct chp_id chpid);
1288c2ecf20Sopenharmony_ciint sclp_chp_read_info(struct sclp_chp_info *info);
1298c2ecf20Sopenharmony_ciint sclp_pci_configure(u32 fid);
1308c2ecf20Sopenharmony_ciint sclp_pci_deconfigure(u32 fid);
1318c2ecf20Sopenharmony_ciint sclp_ap_configure(u32 apid);
1328c2ecf20Sopenharmony_ciint sclp_ap_deconfigure(u32 apid);
1338c2ecf20Sopenharmony_ciint sclp_pci_report(struct zpci_report_error_header *report, u32 fh, u32 fid);
1348c2ecf20Sopenharmony_ciint memcpy_hsa_kernel(void *dest, unsigned long src, size_t count);
1358c2ecf20Sopenharmony_ciint memcpy_hsa_user(void __user *dest, unsigned long src, size_t count);
1368c2ecf20Sopenharmony_civoid sclp_ocf_cpc_name_copy(char *dst);
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cistatic inline int sclp_get_core_info(struct sclp_core_info *info, int early)
1398c2ecf20Sopenharmony_ci{
1408c2ecf20Sopenharmony_ci	if (early)
1418c2ecf20Sopenharmony_ci		return sclp_early_get_core_info(info);
1428c2ecf20Sopenharmony_ci	return _sclp_get_core_info(info);
1438c2ecf20Sopenharmony_ci}
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci#endif /* _ASM_S390_SCLP_H */
146