Skip to content

Commit 5f2ea10

Browse files
Nikunj Kelasudeep-holla
authored andcommitted
firmware: arm_scmi: Augment SMC/HVC to allow optional parameters
This change adds support for passing shmem channel address as parameters in smc/hvc call. The address is split into 4KB-page and offset. This is useful when multiple scmi instances are using same smc-id and firmware needs to distinguish among the instances. Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Link: https://lore.kernel.org/r/20230506182428.25343-3-quic_nkela@quicinc.com Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
1 parent 8f9d530 commit 5f2ea10

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

drivers/firmware/arm_scmi/driver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,6 +2914,7 @@ static const struct of_device_id scmi_of_match[] = {
29142914
#endif
29152915
#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
29162916
{ .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
2917+
{ .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
29172918
#endif
29182919
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
29192920
{ .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},

drivers/firmware/arm_scmi/smc.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@
2020

2121
#include "common.h"
2222

23+
/*
24+
* The shmem address is split into 4K page and offset.
25+
* This is to make sure the parameters fit in 32bit arguments of the
26+
* smc/hvc call to keep it uniform across smc32/smc64 conventions.
27+
* This however limits the shmem address to 44 bit.
28+
*
29+
* These optional parameters can be used to distinguish among multiple
30+
* scmi instances that are using the same smc-id.
31+
* The page parameter is passed in r1/x1/w1 register and the offset parameter
32+
* is passed in r2/x2/w2 register.
33+
*/
34+
35+
#define SHMEM_SIZE (SZ_4K)
36+
#define SHMEM_SHIFT 12
37+
#define SHMEM_PAGE(x) (_UL((x) >> SHMEM_SHIFT))
38+
#define SHMEM_OFFSET(x) ((x) & (SHMEM_SIZE - 1))
39+
2340
/**
2441
* struct scmi_smc - Structure representing a SCMI smc transport
2542
*
@@ -30,6 +47,8 @@
3047
* @inflight: Atomic flag to protect access to Tx/Rx shared memory area.
3148
* Used when operating in atomic mode.
3249
* @func_id: smc/hvc call function id
50+
* @param_page: 4K page number of the shmem channel
51+
* @param_offset: Offset within the 4K page of the shmem channel
3352
*/
3453

3554
struct scmi_smc {
@@ -40,6 +59,8 @@ struct scmi_smc {
4059
#define INFLIGHT_NONE MSG_TOKEN_MAX
4160
atomic_t inflight;
4261
u32 func_id;
62+
u32 param_page;
63+
u32 param_offset;
4364
};
4465

4566
static irqreturn_t smc_msg_done_isr(int irq, void *data)
@@ -137,6 +158,10 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
137158
if (ret < 0)
138159
return ret;
139160

161+
if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
162+
scmi_info->param_page = SHMEM_PAGE(res.start);
163+
scmi_info->param_offset = SHMEM_OFFSET(res.start);
164+
}
140165
/*
141166
* If there is an interrupt named "a2p", then the service and
142167
* completion of a message is signaled by an interrupt rather than by
@@ -179,6 +204,8 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
179204
{
180205
struct scmi_smc *scmi_info = cinfo->transport_info;
181206
struct arm_smccc_res res;
207+
unsigned long page = scmi_info->param_page;
208+
unsigned long offset = scmi_info->param_offset;
182209

183210
/*
184211
* Channel will be released only once response has been
@@ -188,7 +215,8 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
188215

189216
shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
190217

191-
arm_smccc_1_1_invoke(scmi_info->func_id, 0, 0, 0, 0, 0, 0, 0, &res);
218+
arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0,
219+
&res);
192220

193221
/* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
194222
if (res.a0) {

0 commit comments

Comments
 (0)