Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * SCLP early driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright IBM Corp. 2013
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define KMSG_COMPONENT "sclp_early"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <asm/ctl_reg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <asm/sclp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <asm/ipl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "sclp_sdias.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "sclp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static struct sclp_ipl_info sclp_ipl_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) struct sclp_info sclp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) EXPORT_SYMBOL(sclp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) static void __init sclp_early_facilities_detect(struct read_info_sccb *sccb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct sclp_core_entry *cpue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	u16 boot_cpu_address, cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	if (sclp_early_get_info(sccb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	sclp.facilities = sccb->facilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	sclp.has_sprp = !!(sccb->fac84 & 0x02);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	sclp.has_core_type = !!(sccb->fac84 & 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	sclp.has_gsls = !!(sccb->fac85 & 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	sclp.has_64bscao = !!(sccb->fac116 & 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	sclp.has_cmma = !!(sccb->fac116 & 0x40);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	sclp.has_esca = !!(sccb->fac116 & 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	sclp.has_pfmfi = !!(sccb->fac117 & 0x40);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	sclp.has_ibs = !!(sccb->fac117 & 0x20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	sclp.has_gisaf = !!(sccb->fac118 & 0x08);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	sclp.has_hvs = !!(sccb->fac119 & 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	sclp.has_kss = !!(sccb->fac98 & 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	if (sccb->fac85 & 0x02)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	if (sccb->fac91 & 0x40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_GUEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	if (sccb->cpuoff > 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		sclp.has_diag318 = !!(sccb->byte_134 & 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	if (sccb->cpuoff > 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		sclp.has_sipl = !!(sccb->cbl & 0x4000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	sclp.rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	sclp.rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	sclp.rzm <<= 20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	sclp.ibc = sccb->ibc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (sccb->hamaxpow && sccb->hamaxpow < 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		sclp.hamax = (1UL << sccb->hamaxpow) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		sclp.hamax = U64_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	if (!sccb->hcpua) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		if (MACHINE_IS_VM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			sclp.max_cores = 64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 			sclp.max_cores = sccb->ncpurl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		sclp.max_cores = sccb->hcpua + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	boot_cpu_address = stap();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	cpue = (void *)sccb + sccb->cpuoff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	for (cpu = 0; cpu < sccb->ncpurl; cpue++, cpu++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		if (boot_cpu_address != cpue->core_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		sclp.has_siif = cpue->siif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		sclp.has_sigpif = cpue->sigpif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		sclp.has_sief2 = cpue->sief2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		sclp.has_gpere = cpue->gpere;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		sclp.has_ib = cpue->ib;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		sclp.has_cei = cpue->cei;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		sclp.has_skey = cpue->skey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/* Save IPL information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	sclp_ipl_info.is_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	if (sccb->fac91 & 0x2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		sclp_ipl_info.has_dump = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	memcpy(&sclp_ipl_info.loadparm, &sccb->loadparm, LOADPARM_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (sccb->hsa_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		sclp.hsa_size = (sccb->hsa_size - 1) * PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	sclp.mtid = (sccb->fac42 & 0x80) ? (sccb->fac42 & 31) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	sclp.mtid_cp = (sccb->fac42 & 0x80) ? (sccb->fac43 & 31) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	sclp.mtid_prev = (sccb->fac42 & 0x80) ? (sccb->fac66 & 31) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	sclp.hmfai = sccb->hmfai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	sclp.has_dirq = !!(sccb->cpudirq & 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  * This function will be called after sclp_early_facilities_detect(), which gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * called from early.c code. The sclp_early_facilities_detect() function retrieves
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * and saves the IPL information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) void __init sclp_early_get_ipl_info(struct sclp_ipl_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	*info = sclp_ipl_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static struct sclp_core_info sclp_early_core_info __initdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static int sclp_early_core_info_valid __initdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static void __init sclp_early_init_core_info(struct read_cpu_info_sccb *sccb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	if (!SCLP_HAS_CPU_INFO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	memset(sccb, 0, sizeof(*sccb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	sccb->header.length = sizeof(*sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	if (sclp_early_cmd(SCLP_CMDW_READ_CPU_INFO, sccb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	if (sccb->header.response_code != 0x0010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	sclp_fill_core_info(&sclp_early_core_info, sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	sclp_early_core_info_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int __init sclp_early_get_core_info(struct sclp_core_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	if (!sclp_early_core_info_valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	*info = sclp_early_core_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static void __init sclp_early_console_detect(struct init_sccb *sccb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	if (sccb->header.response_code != 0x20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	if (sclp_early_con_check_vt220(sccb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		sclp.has_vt220 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (sclp_early_con_check_linemode(sccb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		sclp.has_linemode = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) void __init sclp_early_detect(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	void *sccb = sclp_early_sccb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	sclp_early_facilities_detect(sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	sclp_early_init_core_info(sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	 * Turn off SCLP event notifications.  Also save remote masks in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	 * sccb.  These are sufficient to detect sclp console capabilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	sclp_early_set_event_mask(sccb, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	sclp_early_console_detect(sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }