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 | S: Odd Fixes | 15474 | S: Odd Fixes |
| 15475 | F: drivers/net/ethernet/smsc/smc91x.* | 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 | SMIA AND SMIA++ IMAGE SENSOR DRIVER | 15486 | SMIA AND SMIA++ IMAGE SENSOR DRIVER |
| 15478 | M: Sakari Ailus <sakari.ailus@linux.intel.com> | 15487 | M: Sakari Ailus <sakari.ailus@linux.intel.com> |
| 15479 | L: linux-media@vger.kernel.org | 15488 | L: linux-media@vger.kernel.org |
| @@ -23,12 +23,13 @@ obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o · 22 unmodified lines | |||
| 23 | obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o | 23 | obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o |
| 24 | 24 | ||
| 25 | obj-$(CONFIG_ARM_SCMI_PROTOCOL) += arm_scmi/ | 25 | obj-$(CONFIG_ARM_SCMI_PROTOCOL) += arm_scmi/ |
| 26 | obj-y += psci/ | ||
| 27 | obj-y += broadcom/ | 26 | obj-y += broadcom/ |
| 28 | obj-y += meson/ | 27 | obj-y += meson/ |
| 29 | obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ | 28 | obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ |
| 30 | obj-$(CONFIG_EFI) += efi/ | 29 | obj-$(CONFIG_EFI) += efi/ |
| 31 | obj-$(CONFIG_UEFI_CPER) += efi/ | 30 | obj-$(CONFIG_UEFI_CPER) += efi/ |
| 32 | obj-y += imx/ | 31 | obj-y += imx/ |
| 32 | obj-y += psci/ | ||
| 33 | obj-y += smccc/ | ||
| 33 | obj-y += tegra/ | 34 | obj-y += tegra/ |
| 34 | obj-y += xilinx/ | 35 | obj-y += xilinx/ |
| @@ -46,25 +46,14 @@ · 45 unmodified lines | |||
| 46 | * require cooperation with a Trusted OS driver. | 46 | * require cooperation with a Trusted OS driver. |
| 47 | */ | 47 | */ |
| 48 | static int resident_cpu = -1; | 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 | bool psci_tos_resident_on(int cpu) | 52 | bool psci_tos_resident_on(int cpu) |
| 51 | { | 53 | { |
| 52 | return cpu == resident_cpu; | 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 | typedef unsigned long (psci_fn)(unsigned long, unsigned long, | 57 | typedef unsigned long (psci_fn)(unsigned long, unsigned long, |
| 69 | unsigned long, unsigned long); | 58 | unsigned long, unsigned long); |
| 70 | static psci_fn *invoke_psci_fn; | 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 | static u32 psci_cpu_suspend_feature; | 80 | static u32 psci_cpu_suspend_feature; |
| 92 | static bool psci_system_reset2_supported; | 81 | static bool psci_system_reset2_supported; |
| 82 | void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit); | ||
| 93 | 83 | ||
| 94 | static inline bool psci_has_ext_power_state(void) | 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 | WARN(1, "Unexpected PSCI conduit %d\n", conduit); | 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 | static int get_set_conduit_method(struct device_node *np) | 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 | u32 ret; | 402 | u32 ret; |
| 413 | ret = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); | 403 | ret = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); |
| 414 | if (ret >= ARM_SMCCC_VERSION_1_1) { | 404 | if (ret >= ARM_SMCCC_VERSION_1_1) { |
| 415 | psci_ops.smccc_version = ret; | 405 | arm_smccc_version_init(ret, psci_conduit); |
| 416 | ver = ret; | 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 | int (*affinity_info)(unsigned long target_affinity, | 30 | int (*affinity_info)(unsigned long target_affinity, |
| 31 | unsigned long lowest_affinity_level); | 31 | unsigned long lowest_affinity_level); |
| 32 | int (*migrate_info_type)(void); | 32 | int (*migrate_info_type)(void); |
| 33 | enum arm_smccc_conduit conduit; | ||
| 34 | u32 smccc_version; | ||
| 35 | }; | 33 | }; |
| 36 | 34 | ||
| 37 | extern struct psci_operations psci_ops; | 35 | extern struct psci_operations psci_ops; |