Commit a5a4e02d authored by Sibi Sankar's avatar Sibi Sankar Committed by Bjorn Andersson

remoteproc: qcom: Add support for parsing fw dt bindings

Add support for parsing "firmware-name" dt bindings which specifies
the relative paths of mba/modem/pas image as strings. Fallback to
the default paths for mba/modem/pas image on -EINVAL.
Signed-off-by: default avatarSibi Sankar <sibis@codeaurora.org>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 4107102d
...@@ -188,6 +188,7 @@ struct q6v5 { ...@@ -188,6 +188,7 @@ struct q6v5 {
bool has_alt_reset; bool has_alt_reset;
int mpss_perm; int mpss_perm;
int mba_perm; int mba_perm;
const char *hexagon_mdt_image;
int version; int version;
}; };
...@@ -860,17 +861,26 @@ static int q6v5_mpss_load(struct q6v5 *qproc) ...@@ -860,17 +861,26 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
phys_addr_t min_addr = PHYS_ADDR_MAX; phys_addr_t min_addr = PHYS_ADDR_MAX;
phys_addr_t max_addr = 0; phys_addr_t max_addr = 0;
bool relocate = false; bool relocate = false;
char seg_name[10]; char *fw_name;
size_t fw_name_len;
ssize_t offset; ssize_t offset;
size_t size = 0; size_t size = 0;
void *ptr; void *ptr;
int ret; int ret;
int i; int i;
ret = request_firmware(&fw, "modem.mdt", qproc->dev); fw_name_len = strlen(qproc->hexagon_mdt_image);
if (fw_name_len <= 4)
return -EINVAL;
fw_name = kstrdup(qproc->hexagon_mdt_image, GFP_KERNEL);
if (!fw_name)
return -ENOMEM;
ret = request_firmware(&fw, fw_name, qproc->dev);
if (ret < 0) { if (ret < 0) {
dev_err(qproc->dev, "unable to load modem.mdt\n"); dev_err(qproc->dev, "unable to load %s\n", fw_name);
return ret; goto out;
} }
/* Initialize the RMB validator */ /* Initialize the RMB validator */
...@@ -918,10 +928,11 @@ static int q6v5_mpss_load(struct q6v5 *qproc) ...@@ -918,10 +928,11 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
ptr = qproc->mpss_region + offset; ptr = qproc->mpss_region + offset;
if (phdr->p_filesz) { if (phdr->p_filesz) {
snprintf(seg_name, sizeof(seg_name), "modem.b%02d", i); /* Replace "xxx.xxx" with "xxx.bxx" */
ret = request_firmware(&seg_fw, seg_name, qproc->dev); sprintf(fw_name + fw_name_len - 3, "b%02d", i);
ret = request_firmware(&seg_fw, fw_name, qproc->dev);
if (ret) { if (ret) {
dev_err(qproc->dev, "failed to load %s\n", seg_name); dev_err(qproc->dev, "failed to load %s\n", fw_name);
goto release_firmware; goto release_firmware;
} }
...@@ -960,6 +971,8 @@ static int q6v5_mpss_load(struct q6v5 *qproc) ...@@ -960,6 +971,8 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
release_firmware: release_firmware:
release_firmware(fw); release_firmware(fw);
out:
kfree(fw_name);
return ret < 0 ? ret : 0; return ret < 0 ? ret : 0;
} }
...@@ -1075,9 +1088,10 @@ static int qcom_q6v5_register_dump_segments(struct rproc *rproc, ...@@ -1075,9 +1088,10 @@ static int qcom_q6v5_register_dump_segments(struct rproc *rproc,
unsigned long i; unsigned long i;
int ret; int ret;
ret = request_firmware(&fw, "modem.mdt", qproc->dev); ret = request_firmware(&fw, qproc->hexagon_mdt_image, qproc->dev);
if (ret < 0) { if (ret < 0) {
dev_err(qproc->dev, "unable to load modem.mdt\n"); dev_err(qproc->dev, "unable to load %s\n",
qproc->hexagon_mdt_image);
return ret; return ret;
} }
...@@ -1253,6 +1267,7 @@ static int q6v5_probe(struct platform_device *pdev) ...@@ -1253,6 +1267,7 @@ static int q6v5_probe(struct platform_device *pdev)
const struct rproc_hexagon_res *desc; const struct rproc_hexagon_res *desc;
struct q6v5 *qproc; struct q6v5 *qproc;
struct rproc *rproc; struct rproc *rproc;
const char *mba_image;
int ret; int ret;
desc = of_device_get_match_data(&pdev->dev); desc = of_device_get_match_data(&pdev->dev);
...@@ -1262,8 +1277,14 @@ static int q6v5_probe(struct platform_device *pdev) ...@@ -1262,8 +1277,14 @@ static int q6v5_probe(struct platform_device *pdev)
if (desc->need_mem_protection && !qcom_scm_is_available()) if (desc->need_mem_protection && !qcom_scm_is_available())
return -EPROBE_DEFER; return -EPROBE_DEFER;
mba_image = desc->hexagon_mba_image;
ret = of_property_read_string_index(pdev->dev.of_node, "firmware-name",
0, &mba_image);
if (ret < 0 && ret != -EINVAL)
return ret;
rproc = rproc_alloc(&pdev->dev, pdev->name, &q6v5_ops, rproc = rproc_alloc(&pdev->dev, pdev->name, &q6v5_ops,
desc->hexagon_mba_image, sizeof(*qproc)); mba_image, sizeof(*qproc));
if (!rproc) { if (!rproc) {
dev_err(&pdev->dev, "failed to allocate rproc\n"); dev_err(&pdev->dev, "failed to allocate rproc\n");
return -ENOMEM; return -ENOMEM;
...@@ -1274,6 +1295,12 @@ static int q6v5_probe(struct platform_device *pdev) ...@@ -1274,6 +1295,12 @@ static int q6v5_probe(struct platform_device *pdev)
qproc = (struct q6v5 *)rproc->priv; qproc = (struct q6v5 *)rproc->priv;
qproc->dev = &pdev->dev; qproc->dev = &pdev->dev;
qproc->rproc = rproc; qproc->rproc = rproc;
qproc->hexagon_mdt_image = "modem.mdt";
ret = of_property_read_string_index(pdev->dev.of_node, "firmware-name",
1, &qproc->hexagon_mdt_image);
if (ret < 0 && ret != -EINVAL)
return ret;
platform_set_drvdata(pdev, qproc); platform_set_drvdata(pdev, qproc);
ret = q6v5_init_mem(qproc, pdev); ret = q6v5_init_mem(qproc, pdev);
......
...@@ -258,6 +258,7 @@ static int adsp_probe(struct platform_device *pdev) ...@@ -258,6 +258,7 @@ static int adsp_probe(struct platform_device *pdev)
const struct adsp_data *desc; const struct adsp_data *desc;
struct qcom_adsp *adsp; struct qcom_adsp *adsp;
struct rproc *rproc; struct rproc *rproc;
const char *fw_name;
int ret; int ret;
desc = of_device_get_match_data(&pdev->dev); desc = of_device_get_match_data(&pdev->dev);
...@@ -267,8 +268,14 @@ static int adsp_probe(struct platform_device *pdev) ...@@ -267,8 +268,14 @@ static int adsp_probe(struct platform_device *pdev)
if (!qcom_scm_is_available()) if (!qcom_scm_is_available())
return -EPROBE_DEFER; return -EPROBE_DEFER;
fw_name = desc->firmware_name;
ret = of_property_read_string(pdev->dev.of_node, "firmware-name",
&fw_name);
if (ret < 0 && ret != -EINVAL)
return ret;
rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops, rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops,
desc->firmware_name, sizeof(*adsp)); fw_name, sizeof(*adsp));
if (!rproc) { if (!rproc) {
dev_err(&pdev->dev, "unable to allocate remoteproc\n"); dev_err(&pdev->dev, "unable to allocate remoteproc\n");
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment