firmware: qcom: scm: Peripheral Authentication Service
PATCH v3 1/1 firmware: qcom: scm: Peripheral Authentication Service
This adds the Peripheral Authentication Service (PAS) interface to the Qualcomm SCM interface. The API is used to authenticate and boot a range of external processors in various Qualcomm platforms.
---
Depends on Andy's platformization of the scm code.
Changes since v2:
- Attached the dma allocation in init_image to the scm dev
- Requesting scm clocks
- Fixed some more big endian stuff
- Added stubs for ARM64
Changes since v1:
- Big endian compatibility
drivers/firmware/qcom_scm-32.c | 82 +++++++++++++++++++++++++ drivers/firmware/qcom_scm-64.c | 25 ++++++++ drivers/firmware/qcom_scm.c | 136 +++++++++++++++++++++++++++++++++++++++++ drivers/firmware/qcom_scm.h | 12 ++++ include/linux/qcom_scm.h | 6 ++ 5 files changed, 261 insertions(+)
drivers/firmware/qcom_scm-32.c +82 -0
@@ -499,3 +499,85 @@ int __qcom_scm_hdcp_req(struct qcom_scm_hdcp_req *req, u32 req_cnt, u32 *resp)return qcom_scm_call (QCOM_SCM_SVC_HDCP ,QCOM_SCM_CMD_HDCP , req, req_cnt *sizeof (*req), resp,sizeof (*resp)); } + +bool __qcom_scm_pas_supported (u32 peripheral) +{ +__le32 out; +__le32 in; +int ret; + + in =cpu_to_le32 (peripheral); + ret =qcom_scm_call (QCOM_SCM_SVC_PIL ,QCOM_SCM_PAS_IS_SUPPORTED_CMD , + &in,sizeof (in), + &out,sizeof (out)); + +return ret ? false : !!out; +} + +int __qcom_scm_pas_init_image (u32 peripheral,dma_addr_t metadata_phys) +{ +__le32 scm_ret; +int ret; +struct { +__le32 proc; +__le32 image_addr; + } request; + + request.proc =cpu_to_le32 (peripheral); + request.image_addr =cpu_to_le32 (metadata_phys); + + ret =qcom_scm_call (QCOM_SCM_SVC_PIL ,QCOM_SCM_PAS_INIT_IMAGE_CMD , + &request,sizeof (request), + &scm_ret,sizeof (scm_ret)); + +return ret ? :le32_to_cpu (scm_ret); +} + +int __qcom_scm_pas_mem_setup (u32 peripheral,phys_addr_t addr,phys_addr_t size) +{ +__le32 scm_ret; +int ret; +struct { +__le32 proc; +__le32 addr; +__le32 len; + } request; + + request.proc =cpu_to_le32 (peripheral); + request.addr =cpu_to_le32 (addr); + request.len =cpu_to_le32 (size); + + ret =qcom_scm_call (QCOM_SCM_SVC_PIL ,QCOM_SCM_PAS_MEM_SETUP_CMD , + &request,sizeof (request), + &scm_ret,sizeof (scm_ret)); + +return ret ? :le32_to_cpu (scm_ret); +} + +int __qcom_scm_pas_auth_and_reset (u32 peripheral) +{ +__le32 out; +__le32 in; +int ret; + + in =cpu_to_le32 (peripheral); + ret =qcom_scm_call (QCOM_SCM_SVC_PIL ,QCOM_SCM_PAS_AUTH_AND_RESET_CMD , + &in,sizeof (in), + &out,sizeof (out)); + +return ret ? :le32_to_cpu (out); +} + +int __qcom_scm_pas_shutdown (u32 peripheral) +{ +__le32 out; +__le32 in; +int ret; + + in =cpu_to_le32 (peripheral); + ret =qcom_scm_call (QCOM_SCM_SVC_PIL ,QCOM_SCM_PAS_SHUTDOWN_CMD , + &in,sizeof (in), + &out,sizeof (out)); + +return ret ? :le32_to_cpu (out); +}
drivers/firmware/qcom_scm-64.c +25 -0
@@ -61,3 +61,28 @@ int __qcom_scm_hdcp_req(struct qcom_scm_hdcp_req *req, u32 req_cnt, u32 *resp) {return -ENOTSUPP ; } + +bool __qcom_scm_pas_supported (u32 peripheral) +{ +return false; +} + +int __qcom_scm_pas_init_image (u32 peripheral,dma_addr_t metadata_phys) +{ +return -ENOTSUPP ; +} + +int __qcom_scm_pas_mem_setup (u32 peripheral,phys_addr_t addr,phys_addr_t size) +{ +return -ENOTSUPP ; +} + +int __qcom_scm_pas_auth_and_reset (u32 peripheral) +{ +return -ENOTSUPP ; +} + +int __qcom_scm_pas_shutdown (u32 peripheral) +{ +return -ENOTSUPP ; +}
drivers/firmware/qcom_scm.c +136 -0
160 lines not on this page · raw message
drivers/firmware/qcom_scm.h +12 -0
@@ -36,6 +36,18 @@ extern int __qcom_scm_is_call_available(u32 svc_id, u32 cmd_id);extern int __qcom_scm_hdcp_req (struct qcom_scm_hdcp_req *req,u32 req_cnt,u32 *resp); +#define QCOM_SCM_SVC_PIL 0x2 +#define QCOM_SCM_PAS_INIT_IMAGE_CMD 0x1 +#define QCOM_SCM_PAS_MEM_SETUP_CMD 0x2 +#define QCOM_SCM_PAS_AUTH_AND_RESET_CMD 0x5 +#define QCOM_SCM_PAS_SHUTDOWN_CMD 0x6 +#define QCOM_SCM_PAS_IS_SUPPORTED_CMD 0x7 +extern bool __qcom_scm_pas_supported (u32 peripheral); +extern int __qcom_scm_pas_init_image (u32 peripheral,dma_addr_t metadata_phys); +extern int __qcom_scm_pas_mem_setup (u32 peripheral,phys_addr_t addr,phys_addr_t size); +extern int __qcom_scm_pas_auth_and_reset (u32 peripheral); +extern int __qcom_scm_pas_shutdown (u32 peripheral); +/* common error codes */ #define QCOM_SCM_ENOMEM -5#define QCOM_SCM_EOPNOTSUPP -4
include/linux/qcom_scm.h +6 -0
@@ -27,6 +27,12 @@ extern bool qcom_scm_hdcp_available(void);extern int qcom_scm_hdcp_req (struct qcom_scm_hdcp_req *req,u32 req_cnt,u32 *resp); +extern bool qcom_scm_pas_supported (u32 peripheral); +extern int qcom_scm_pas_init_image (u32 peripheral,const void *metadata,size_t size); +extern int qcom_scm_pas_mem_setup (u32 peripheral,phys_addr_t addr,phys_addr_t size); +extern int qcom_scm_pas_auth_and_reset (u32 peripheral); +extern int qcom_scm_pas_shutdown (u32 peripheral); +#define QCOM_SCM_CPU_PWR_DOWN_L2_ON 0x0#define QCOM_SCM_CPU_PWR_DOWN_L2_OFF 0x1
Signature · 1 line
1.8.2.2
Review
Quoted 2 lines · Bjorn Andersson
(quoted diff) +2
-0+ +int __qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size)
Maybe we should make addr and size u32s as well. Kumar requested we take the same approach for other scm calls.
Quoted 9 lines
drivers/firmware/qcom_scm-32.c +9
-0+{ +__le32 scm_ret; +int ret; +struct { +__le32 proc; +__le32 addr; +__le32 len; + } request; +
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 7 lines · Stephen Boyd
Review
Quoted 2 lines · Bjorn Andersson
(quoted diff) +2
-0+ +int __qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size)Maybe we should make addr and size u32s as well. Kumar requested we take the same approach for other scm calls.
So you're saying that on arm64 we're always going to load firmware in the lower 32 bits of memory?
Not sure what the benefit of doing this conversion higher up in the layers are, but sure we could do it...
Regards,
Bjorn