mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
firmware: arm_scmi: Add qcom smc/hvc transport support
This change adds the support for SCMI message exchange on Qualcomm virtual platforms. The hypervisor associates an object-id also known as capability-id with each smc/hvc doorbell object. The capability-id is used to identify the doorbell from the VM's capability namespace, similar to a file-descriptor. The hypervisor, in addition to the function-id, expects the capability-id to be passed in x1 register when SMC/HVC call is invoked. The capability-id is allocated by the hypervisor on bootup and is stored in the shmem region by the firmware before starting Linux. Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com> Reviewed-by: Brian Masney <bmasney@redhat.com> Link: https://lore.kernel.org/r/20231009191437.27926-3-quic_nkela@quicinc.com Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
parent
6979f88f5a
commit
da405477e7
2 changed files with 26 additions and 2 deletions
|
@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
|
||||||
#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
|
#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
|
||||||
{ .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
|
{ .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
|
||||||
{ .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
|
{ .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
|
||||||
|
{ .compatible = "qcom,scmi-smc", .data = &scmi_smc_desc},
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
|
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
|
||||||
{ .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
|
{ .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_address.h>
|
#include <linux/of_address.h>
|
||||||
#include <linux/of_irq.h>
|
#include <linux/of_irq.h>
|
||||||
|
#include <linux/limits.h>
|
||||||
#include <linux/processor.h>
|
#include <linux/processor.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
|
||||||
|
@ -50,6 +51,8 @@
|
||||||
* @func_id: smc/hvc call function id
|
* @func_id: smc/hvc call function id
|
||||||
* @param_page: 4K page number of the shmem channel
|
* @param_page: 4K page number of the shmem channel
|
||||||
* @param_offset: Offset within the 4K page of the shmem channel
|
* @param_offset: Offset within the 4K page of the shmem channel
|
||||||
|
* @cap_id: smc/hvc doorbell's capability id to be used on Qualcomm virtual
|
||||||
|
* platforms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct scmi_smc {
|
struct scmi_smc {
|
||||||
|
@ -63,6 +66,7 @@ struct scmi_smc {
|
||||||
unsigned long func_id;
|
unsigned long func_id;
|
||||||
unsigned long param_page;
|
unsigned long param_page;
|
||||||
unsigned long param_offset;
|
unsigned long param_offset;
|
||||||
|
unsigned long cap_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
static irqreturn_t smc_msg_done_isr(int irq, void *data)
|
static irqreturn_t smc_msg_done_isr(int irq, void *data)
|
||||||
|
@ -124,6 +128,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
|
||||||
bool tx)
|
bool tx)
|
||||||
{
|
{
|
||||||
struct device *cdev = cinfo->dev;
|
struct device *cdev = cinfo->dev;
|
||||||
|
unsigned long cap_id = ULONG_MAX;
|
||||||
struct scmi_smc *scmi_info;
|
struct scmi_smc *scmi_info;
|
||||||
resource_size_t size;
|
resource_size_t size;
|
||||||
struct resource res;
|
struct resource res;
|
||||||
|
@ -162,6 +167,18 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (of_device_is_compatible(dev->of_node, "qcom,scmi-smc")) {
|
||||||
|
void __iomem *ptr = (void __iomem *)scmi_info->shmem + size - 8;
|
||||||
|
/* The capability-id is kept in last 8 bytes of shmem.
|
||||||
|
* +-------+ <-- 0
|
||||||
|
* | shmem |
|
||||||
|
* +-------+ <-- size - 8
|
||||||
|
* | capId |
|
||||||
|
* +-------+ <-- size
|
||||||
|
*/
|
||||||
|
memcpy_fromio(&cap_id, ptr, sizeof(cap_id));
|
||||||
|
}
|
||||||
|
|
||||||
if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
|
if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
|
||||||
scmi_info->param_page = SHMEM_PAGE(res.start);
|
scmi_info->param_page = SHMEM_PAGE(res.start);
|
||||||
scmi_info->param_offset = SHMEM_OFFSET(res.start);
|
scmi_info->param_offset = SHMEM_OFFSET(res.start);
|
||||||
|
@ -184,6 +201,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
scmi_info->func_id = func_id;
|
scmi_info->func_id = func_id;
|
||||||
|
scmi_info->cap_id = cap_id;
|
||||||
scmi_info->cinfo = cinfo;
|
scmi_info->cinfo = cinfo;
|
||||||
smc_channel_lock_init(scmi_info);
|
smc_channel_lock_init(scmi_info);
|
||||||
cinfo->transport_info = scmi_info;
|
cinfo->transport_info = scmi_info;
|
||||||
|
@ -220,8 +238,13 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
|
||||||
|
|
||||||
shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
|
shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
|
||||||
|
|
||||||
|
if (scmi_info->cap_id != ULONG_MAX)
|
||||||
|
arm_smccc_1_1_invoke(scmi_info->func_id, scmi_info->cap_id, 0,
|
||||||
|
0, 0, 0, 0, 0, &res);
|
||||||
|
else
|
||||||
arm_smccc_1_1_invoke(scmi_info->func_id, scmi_info->param_page,
|
arm_smccc_1_1_invoke(scmi_info->func_id, scmi_info->param_page,
|
||||||
scmi_info->param_offset, 0, 0, 0, 0, 0, &res);
|
scmi_info->param_offset, 0, 0, 0, 0, 0,
|
||||||
|
&res);
|
||||||
|
|
||||||
/* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
|
/* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
|
||||||
if (res.a0) {
|
if (res.a0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue