Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firmware: smccc: Refactor SMCCC specific bits into separate file

In order to add newer SMCCC v1.1+ functionality and to avoid cluttering
PSCI firmware driver with SMCCC bits, let us move the SMCCC specific
details under drivers/firmware/smccc/smccc.c

We can also drop conduit and smccc_version from psci_operations structure
as SMCCC was the sole user and now it maintains those.

No functionality change in this patch though.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Etienne Carriere <etienne.carriere@st.com>
Reviewed-by: Etienne Carriere <etienne.carriere@st.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20200518091222.27467-6-sudeep.holla@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Sudeep Holla and committed by
Will Deacon
f2ae9706 ad5a57df

+45 -18
+9
MAINTAINERS
··· 15474 15474 S: Odd Fixes 15475 15475 F: drivers/net/ethernet/smsc/smc91x.* 15476 15476 15477 + SECURE MONITOR CALL(SMC) CALLING CONVENTION (SMCCC) 15478 + M: Mark Rutland <mark.rutland@arm.com> 15479 + M: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> 15480 + M: Sudeep Holla <sudeep.holla@arm.com> 15481 + L: linux-arm-kernel@lists.infradead.org 15482 + S: Maintained 15483 + F: drivers/firmware/smccc/ 15484 + F: include/linux/arm-smccc.h 15485 + 15477 15486 SMIA AND SMIA++ IMAGE SENSOR DRIVER 15478 15487 M: Sakari Ailus <sakari.ailus@linux.intel.com> 15479 15488 L: linux-media@vger.kernel.org
+2 -1
drivers/firmware/Makefile
··· 23 23 obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o 24 24 25 25 obj-$(CONFIG_ARM_SCMI_PROTOCOL) += arm_scmi/ 26 - obj-y += psci/ 27 26 obj-y += broadcom/ 28 27 obj-y += meson/ 29 28 obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ 30 29 obj-$(CONFIG_EFI) += efi/ 31 30 obj-$(CONFIG_UEFI_CPER) += efi/ 32 31 obj-y += imx/ 32 + obj-y += psci/ 33 + obj-y += smccc/ 33 34 obj-y += tegra/ 34 35 obj-y += xilinx/
+5 -15
drivers/firmware/psci/psci.c
··· 46 46 * require cooperation with a Trusted OS driver. 47 47 */ 48 48 static int resident_cpu = -1; 49 + struct psci_operations psci_ops; 50 + static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE; 49 51 50 52 bool psci_tos_resident_on(int cpu) 51 53 { 52 54 return cpu == resident_cpu; 53 - } 54 - 55 - struct psci_operations psci_ops = { 56 - .conduit = SMCCC_CONDUIT_NONE, 57 - .smccc_version = ARM_SMCCC_VERSION_1_0, 58 - }; 59 - 60 - enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void) 61 - { 62 - if (psci_ops.smccc_version < ARM_SMCCC_VERSION_1_1) 63 - return SMCCC_CONDUIT_NONE; 64 - 65 - return psci_ops.conduit; 66 55 } 67 56 68 57 typedef unsigned long (psci_fn)(unsigned long, unsigned long, ··· 79 90 80 91 static u32 psci_cpu_suspend_feature; 81 92 static bool psci_system_reset2_supported; 93 + void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit); 82 94 83 95 static inline bool psci_has_ext_power_state(void) 84 96 { ··· 232 242 WARN(1, "Unexpected PSCI conduit %d\n", conduit); 233 243 } 234 244 235 - psci_ops.conduit = conduit; 245 + psci_conduit = conduit; 236 246 } 237 247 238 248 static int get_set_conduit_method(struct device_node *np) ··· 402 412 u32 ret; 403 413 ret = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); 404 414 if (ret >= ARM_SMCCC_VERSION_1_1) { 405 - psci_ops.smccc_version = ret; 415 + arm_smccc_version_init(ret, psci_conduit); 406 416 ver = ret; 407 417 } 408 418 }
+3
drivers/firmware/smccc/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # 3 + obj-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smccc.o
+26
drivers/firmware/smccc/smccc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (C) 2020 Arm Limited 4 + */ 5 + 6 + #define pr_fmt(fmt) "smccc: " fmt 7 + 8 + #include <linux/init.h> 9 + #include <linux/arm-smccc.h> 10 + 11 + static u32 smccc_version = ARM_SMCCC_VERSION_1_0; 12 + static enum arm_smccc_conduit smccc_conduit = SMCCC_CONDUIT_NONE; 13 + 14 + void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit) 15 + { 16 + smccc_version = version; 17 + smccc_conduit = conduit; 18 + } 19 + 20 + enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void) 21 + { 22 + if (smccc_version < ARM_SMCCC_VERSION_1_1) 23 + return SMCCC_CONDUIT_NONE; 24 + 25 + return smccc_conduit; 26 + }
-2
include/linux/psci.h
··· 30 30 int (*affinity_info)(unsigned long target_affinity, 31 31 unsigned long lowest_affinity_level); 32 32 int (*migrate_info_type)(void); 33 - enum arm_smccc_conduit conduit; 34 - u32 smccc_version; 35 33 }; 36 34 37 35 extern struct psci_operations psci_ops;