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)  * s390 crypto adapter related sclp functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright IBM Corp. 2020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #define KMSG_COMPONENT "sclp_cmd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/sclp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "sclp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define SCLP_CMDW_CONFIGURE_AP			0x001f0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define SCLP_CMDW_DECONFIGURE_AP		0x001e0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct ap_cfg_sccb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	struct sccb_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static int do_ap_configure(sclp_cmdw_t cmd, u32 apid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	struct ap_cfg_sccb *sccb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	if (!SCLP_HAS_AP_RECONFIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	sccb = (struct ap_cfg_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	if (!sccb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	sccb->header.length = PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	cmd |= (apid & 0xFF) << 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	rc = sclp_sync_request(cmd, sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	switch (sccb->header.response_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	case 0x0020: case 0x0120: case 0x0440: case 0x0450:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		pr_warn("configure AP adapter %u failed: cmd=0x%08x response=0x%04x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 			apid, cmd, sccb->header.response_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		rc = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	free_page((unsigned long) sccb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int sclp_ap_configure(u32 apid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	return do_ap_configure(SCLP_CMDW_CONFIGURE_AP, apid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) EXPORT_SYMBOL(sclp_ap_configure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int sclp_ap_deconfigure(u32 apid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	return do_ap_configure(SCLP_CMDW_DECONFIGURE_AP, apid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) EXPORT_SYMBOL(sclp_ap_deconfigure);