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.
Unified · Split
| @@ -15474,6 +15474,15 @@ M: Nicolas Pitre <nico@fluxnic.net> · 15473 unmodified lines | ||
| 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 |
| @@ -23,12 +23,13 @@ obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o · 22 unmodified lines | ||
| 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/ |
| @@ -46,25 +46,14 @@ · 45 unmodified lines | ||
| 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 | 55 | } |
| 54 | 56 | |
| 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 | −} | |
| 67 | − | |
| 68 | 57 | typedef unsigned long (psci_fn)(unsigned long, unsigned long, |
| 69 | 58 | unsigned long, unsigned long); |
| 70 | 59 | static psci_fn *invoke_psci_fn; |
| @@ -90,6 +79,7 @@ static u32 psci_function_id[PSCI_FN_MAX]; · 19 unmodified lines | ||
| 90 | 79 | |
| 91 | 80 | static u32 psci_cpu_suspend_feature; |
| 92 | 81 | static bool psci_system_reset2_supported; |
| 82 | +void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit); | |
| 93 | 83 | |
| 94 | 84 | static inline bool psci_has_ext_power_state(void) |
| 95 | 85 | { |
| @@ -242,7 +232,7 @@ static void set_conduit(enum arm_smccc_conduit conduit) · 146 unmodified lines | ||
| 242 | 232 | WARN(1, "Unexpected PSCI conduit %d\n", conduit); |
| 243 | 233 | } |
| 244 | 234 | |
| 245 | − psci_ops.conduit = conduit; | |
| 235 | + psci_conduit = conduit; | |
| 246 | 236 | } |
| 247 | 237 | |
| 248 | 238 | static int get_set_conduit_method(struct device_node *np) |
| @@ -412,7 +402,7 @@ static void __init psci_init_smccc(void) · 163 unmodified lines | ||
| 412 | 402 | u32 ret; |
| 413 | 403 | ret = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); |
| 414 | 404 | if (ret >= ARM_SMCCC_VERSION_1_1) { |
| 415 | − psci_ops.smccc_version = ret; | |
| 405 | + arm_smccc_version_init(ret, psci_conduit); | |
| 416 | 406 | ver = ret; |
| 417 | 407 | } |
| 418 | 408 | } |
| @@ -0,0 +1,3 @@ | ||
| 1 | +# SPDX-License-Identifier: GPL-2.0 | |
| 2 | +# | |
| 3 | +obj-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smccc.o | |
| @@ -0,0 +1,26 @@ | ||
| 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 | +} | |
| @@ -30,8 +30,6 @@ struct psci_operations { · 29 unmodified lines | ||
| 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; |