Skip to content

Commit f2ae970

Browse files
sudeep-hollawilldeacon
authored andcommitted
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 <[email protected]> Tested-by: Etienne Carriere <[email protected]> Reviewed-by: Etienne Carriere <[email protected]> Acked-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent ad5a57d commit f2ae970

File tree

6 files changed

+45
-18
lines changed

6 files changed

+45
-18
lines changed

MAINTAINERS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15474,6 +15474,15 @@ M: Nicolas Pitre <[email protected]>
1547415474
S: Odd Fixes
1547515475
F: drivers/net/ethernet/smsc/smc91x.*
1547615476

15477+
SECURE MONITOR CALL(SMC) CALLING CONVENTION (SMCCC)
15478+
M: Mark Rutland <[email protected]>
15479+
M: Lorenzo Pieralisi <[email protected]>
15480+
M: Sudeep Holla <[email protected]>
15481+
15482+
S: Maintained
15483+
F: drivers/firmware/smccc/
15484+
F: include/linux/arm-smccc.h
15485+
1547715486
SMIA AND SMIA++ IMAGE SENSOR DRIVER
1547815487
M: Sakari Ailus <[email protected]>
1547915488

drivers/firmware/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o
2323
obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o
2424

2525
obj-$(CONFIG_ARM_SCMI_PROTOCOL) += arm_scmi/
26-
obj-y += psci/
2726
obj-y += broadcom/
2827
obj-y += meson/
2928
obj-$(CONFIG_GOOGLE_FIRMWARE) += google/
3029
obj-$(CONFIG_EFI) += efi/
3130
obj-$(CONFIG_UEFI_CPER) += efi/
3231
obj-y += imx/
32+
obj-y += psci/
33+
obj-y += smccc/
3334
obj-y += tegra/
3435
obj-y += xilinx/

drivers/firmware/psci/psci.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,14 @@
4646
* require cooperation with a Trusted OS driver.
4747
*/
4848
static int resident_cpu = -1;
49+
struct psci_operations psci_ops;
50+
static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE;
4951

5052
bool psci_tos_resident_on(int cpu)
5153
{
5254
return cpu == resident_cpu;
5355
}
5456

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-
6857
typedef unsigned long (psci_fn)(unsigned long, unsigned long,
6958
unsigned long, unsigned long);
7059
static psci_fn *invoke_psci_fn;
@@ -90,6 +79,7 @@ static u32 psci_function_id[PSCI_FN_MAX];
9079

9180
static u32 psci_cpu_suspend_feature;
9281
static bool psci_system_reset2_supported;
82+
void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit);
9383

9484
static inline bool psci_has_ext_power_state(void)
9585
{
@@ -242,7 +232,7 @@ static void set_conduit(enum arm_smccc_conduit conduit)
242232
WARN(1, "Unexpected PSCI conduit %d\n", conduit);
243233
}
244234

245-
psci_ops.conduit = conduit;
235+
psci_conduit = conduit;
246236
}
247237

248238
static int get_set_conduit_method(struct device_node *np)
@@ -412,7 +402,7 @@ static void __init psci_init_smccc(void)
412402
u32 ret;
413403
ret = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0);
414404
if (ret >= ARM_SMCCC_VERSION_1_1) {
415-
psci_ops.smccc_version = ret;
405+
arm_smccc_version_init(ret, psci_conduit);
416406
ver = ret;
417407
}
418408
}

drivers/firmware/smccc/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
obj-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smccc.o

drivers/firmware/smccc/smccc.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

include/linux/psci.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ struct psci_operations {
3030
int (*affinity_info)(unsigned long target_affinity,
3131
unsigned long lowest_affinity_level);
3232
int (*migrate_info_type)(void);
33-
enum arm_smccc_conduit conduit;
34-
u32 smccc_version;
3533
};
3634

3735
extern struct psci_operations psci_ops;

0 commit comments

Comments
 (0)