Commit c7715e47 authored by Avaneesh Kumar Dwivedi's avatar Avaneesh Kumar Dwivedi Committed by Bjorn Andersson

remoteproc: qcom: Compatible string based resource initialization.

This patch initialize certain driver related data based on compatible
string. This enable driver to handle more than one similar device in
by differentiating in probe their private data.
Signed-off-by: default avatarAvaneesh Kumar Dwivedi <akdwived@codeaurora.org>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent c008fad2
...@@ -32,9 +32,11 @@ ...@@ -32,9 +32,11 @@
#include "qcom_mdt_loader.h" #include "qcom_mdt_loader.h"
#include "remoteproc_internal.h" #include "remoteproc_internal.h"
#define ADSP_CRASH_REASON_SMEM 423 struct adsp_data {
#define ADSP_FIRMWARE_NAME "adsp.mdt" int crash_reason_smem;
#define ADSP_PAS_ID 1 const char *firmware_name;
int pas_id;
};
struct qcom_adsp { struct qcom_adsp {
struct device *dev; struct device *dev;
...@@ -53,6 +55,9 @@ struct qcom_adsp { ...@@ -53,6 +55,9 @@ struct qcom_adsp {
struct regulator *cx_supply; struct regulator *cx_supply;
int pas_id;
int crash_reason_smem;
struct completion start_done; struct completion start_done;
struct completion stop_done; struct completion stop_done;
...@@ -70,7 +75,7 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) ...@@ -70,7 +75,7 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw)
bool relocate; bool relocate;
int ret; int ret;
ret = qcom_scm_pas_init_image(ADSP_PAS_ID, fw->data, fw->size); ret = qcom_scm_pas_init_image(adsp->pas_id, fw->data, fw->size);
if (ret) { if (ret) {
dev_err(&rproc->dev, "invalid firmware metadata\n"); dev_err(&rproc->dev, "invalid firmware metadata\n");
return ret; return ret;
...@@ -85,7 +90,8 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) ...@@ -85,7 +90,8 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw)
if (relocate) { if (relocate) {
adsp->mem_reloc = fw_addr; adsp->mem_reloc = fw_addr;
ret = qcom_scm_pas_mem_setup(ADSP_PAS_ID, adsp->mem_phys, fw_size); ret = qcom_scm_pas_mem_setup(adsp->pas_id,
adsp->mem_phys, fw_size);
if (ret) { if (ret) {
dev_err(&rproc->dev, "unable to setup memory for image\n"); dev_err(&rproc->dev, "unable to setup memory for image\n");
return ret; return ret;
...@@ -113,7 +119,7 @@ static int adsp_start(struct rproc *rproc) ...@@ -113,7 +119,7 @@ static int adsp_start(struct rproc *rproc)
if (ret) if (ret)
goto disable_clocks; goto disable_clocks;
ret = qcom_scm_pas_auth_and_reset(ADSP_PAS_ID); ret = qcom_scm_pas_auth_and_reset(adsp->pas_id);
if (ret) { if (ret) {
dev_err(adsp->dev, dev_err(adsp->dev,
"failed to authenticate image and release reset\n"); "failed to authenticate image and release reset\n");
...@@ -124,7 +130,7 @@ static int adsp_start(struct rproc *rproc) ...@@ -124,7 +130,7 @@ static int adsp_start(struct rproc *rproc)
msecs_to_jiffies(5000)); msecs_to_jiffies(5000));
if (!ret) { if (!ret) {
dev_err(adsp->dev, "start timed out\n"); dev_err(adsp->dev, "start timed out\n");
qcom_scm_pas_shutdown(ADSP_PAS_ID); qcom_scm_pas_shutdown(adsp->pas_id);
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
goto disable_regulators; goto disable_regulators;
} }
...@@ -157,7 +163,7 @@ static int adsp_stop(struct rproc *rproc) ...@@ -157,7 +163,7 @@ static int adsp_stop(struct rproc *rproc)
BIT(adsp->stop_bit), BIT(adsp->stop_bit),
0); 0);
ret = qcom_scm_pas_shutdown(ADSP_PAS_ID); ret = qcom_scm_pas_shutdown(adsp->pas_id);
if (ret) if (ret)
dev_err(adsp->dev, "failed to shutdown: %d\n", ret); dev_err(adsp->dev, "failed to shutdown: %d\n", ret);
...@@ -197,7 +203,7 @@ static irqreturn_t adsp_fatal_interrupt(int irq, void *dev) ...@@ -197,7 +203,7 @@ static irqreturn_t adsp_fatal_interrupt(int irq, void *dev)
size_t len; size_t len;
char *msg; char *msg;
msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, ADSP_CRASH_REASON_SMEM, &len); msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, adsp->crash_reason_smem, &len);
if (!IS_ERR(msg) && len > 0 && msg[0]) if (!IS_ERR(msg) && len > 0 && msg[0])
dev_err(adsp->dev, "fatal error received: %s\n", msg); dev_err(adsp->dev, "fatal error received: %s\n", msg);
...@@ -311,20 +317,25 @@ static int adsp_alloc_memory_region(struct qcom_adsp *adsp) ...@@ -311,20 +317,25 @@ static int adsp_alloc_memory_region(struct qcom_adsp *adsp)
static int adsp_probe(struct platform_device *pdev) static int adsp_probe(struct platform_device *pdev)
{ {
const struct adsp_data *desc;
struct qcom_adsp *adsp; struct qcom_adsp *adsp;
struct rproc *rproc; struct rproc *rproc;
int ret; int ret;
desc = of_device_get_match_data(&pdev->dev);
if (!desc)
return -EINVAL;
if (!qcom_scm_is_available()) if (!qcom_scm_is_available())
return -EPROBE_DEFER; return -EPROBE_DEFER;
if (!qcom_scm_pas_supported(ADSP_PAS_ID)) { if (!qcom_scm_pas_supported(desc->pas_id)) {
dev_err(&pdev->dev, "PAS is not available for ADSP\n"); dev_err(&pdev->dev, "PAS is not available for subsystem\n");
return -ENXIO; return -ENXIO;
} }
rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops, rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops,
ADSP_FIRMWARE_NAME, sizeof(*adsp)); desc->firmware_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;
...@@ -335,6 +346,8 @@ static int adsp_probe(struct platform_device *pdev) ...@@ -335,6 +346,8 @@ static int adsp_probe(struct platform_device *pdev)
adsp = (struct qcom_adsp *)rproc->priv; adsp = (struct qcom_adsp *)rproc->priv;
adsp->dev = &pdev->dev; adsp->dev = &pdev->dev;
adsp->rproc = rproc; adsp->rproc = rproc;
adsp->pas_id = desc->pas_id;
adsp->crash_reason_smem = desc->crash_reason_smem;
platform_set_drvdata(pdev, adsp); platform_set_drvdata(pdev, adsp);
init_completion(&adsp->start_done); init_completion(&adsp->start_done);
...@@ -407,9 +420,15 @@ static int adsp_remove(struct platform_device *pdev) ...@@ -407,9 +420,15 @@ static int adsp_remove(struct platform_device *pdev)
return 0; return 0;
} }
static const struct adsp_data adsp_resource_init = {
.crash_reason_smem = 423,
.firmware_name = "adsp.mdt",
.pas_id = 1,
};
static const struct of_device_id adsp_of_match[] = { static const struct of_device_id adsp_of_match[] = {
{ .compatible = "qcom,msm8974-adsp-pil" }, { .compatible = "qcom,msm8974-adsp-pil", .data = &adsp_resource_init},
{ .compatible = "qcom,msm8996-adsp-pil" }, { .compatible = "qcom,msm8996-adsp-pil", .data = &adsp_resource_init},
{ }, { },
}; };
MODULE_DEVICE_TABLE(of, adsp_of_match); MODULE_DEVICE_TABLE(of, adsp_of_match);
......
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