From f7fece8238e32d65c19e82f43e42f22ec652d5da Mon Sep 17 00:00:00 2001 From: Veera Sundaram Sankaran Date: Tue, 9 Jun 2020 18:35:42 -0700 Subject: [PATCH] disp: msm: parse SPMI registers and append to IO lend list Parse the display peripheral related SPMI SID/Peripheral mask from device-tree and get the dynamic register range of these peripherals using the SPMI API. These registers are appended to the list of display IO ranges that is lent from HLOS to trusted VM during trusted UI. This would help in adding restrictions for SPMI registers on HLOS during the trusted UI use case along with validation of the register ranges in trusted VM. Change-Id: I7077dac7962466e845d061e9ccd205f1bc0ce3ea Signed-off-by: Veera Sundaram Sankaran --- include/linux/sde_io_util.h | 2 ++ msm/sde/sde_kms.c | 6 +++++ msm/sde_io_util.c | 50 +++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/include/linux/sde_io_util.h b/include/linux/sde_io_util.h index 312488fce5..e9b257c774 100644 --- a/include/linux/sde_io_util.h +++ b/include/linux/sde_io_util.h @@ -88,6 +88,8 @@ void msm_dss_iounmap(struct dss_io_data *io_data); int msm_dss_get_io_mem(struct platform_device *pdev, struct list_head *mem_list); void msm_dss_clean_io_mem(struct list_head *mem_list); +int msm_dss_get_pmic_io_mem(struct platform_device *pdev, + struct list_head *mem_list); int msm_dss_get_io_irq(struct platform_device *pdev, struct list_head *irq_list, u32 label); void msm_dss_clean_io_irq(struct list_head *irq_list); diff --git a/msm/sde/sde_kms.c b/msm/sde/sde_kms.c index a47b043d56..1f88ee2418 100644 --- a/msm/sde/sde_kms.c +++ b/msm/sde/sde_kms.c @@ -4127,6 +4127,12 @@ int sde_kms_get_io_resources(struct sde_kms *sde_kms, struct msm_io_res *io_res) return rc; } + rc = msm_dss_get_pmic_io_mem(pdev, &io_res->mem); + if (rc) { + SDE_ERROR("failed to get io mem for pmic, rc:%d\n", rc); + return rc; + } + rc = msm_dss_get_io_irq(pdev, &io_res->irq, HH_IRQ_LABEL_SDE); if (rc) { SDE_ERROR("failed to get io irq for KMS"); diff --git a/msm/sde_io_util.c b/msm/sde_io_util.c index d86bcacfdb..0d1ec68332 100644 --- a/msm/sde_io_util.c +++ b/msm/sde_io_util.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -130,6 +131,55 @@ void msm_dss_iounmap(struct dss_io_data *io_data) } /* msm_dss_iounmap */ EXPORT_SYMBOL(msm_dss_iounmap); +int msm_dss_get_pmic_io_mem(struct platform_device *pdev, + struct list_head *mem_list) +{ + struct list_head temp_head; + struct msm_io_mem_entry *io_mem; + struct resource *res = NULL; + struct property *prop; + const __be32 *cur; + int rc = 0; + u32 val; + + INIT_LIST_HEAD(&temp_head); + + res = kzalloc(sizeof(struct resource), GFP_KERNEL); + if (!res) + return -ENOMEM; + + of_property_for_each_u32(pdev->dev.of_node, "qcom,pmic-arb-address", + prop, cur, val) { + rc = spmi_pmic_arb_map_address(&pdev->dev, val, res); + if (rc < 0) { + DEV_ERR("%pS - failed to map pmic address, rc:%d\n", + __func__, rc); + goto parse_fail; + } + + io_mem = kzalloc(sizeof(struct msm_io_mem_entry), GFP_KERNEL); + if (!io_mem) { + rc = -ENOMEM; + goto parse_fail; + } + + io_mem->base = res->start; + io_mem->size = resource_size(res); + + list_add(&io_mem->list, &temp_head); + } + + list_splice(&temp_head, mem_list); + goto end; + +parse_fail: + msm_dss_clean_io_mem(&temp_head); +end: + kzfree(res); + return rc; +} +EXPORT_SYMBOL(msm_dss_get_pmic_io_mem); + int msm_dss_get_io_mem(struct platform_device *pdev, struct list_head *mem_list) { struct list_head temp_head;