Commit 0c6de4c2 authored by Bjorn Andersson's avatar Bjorn Andersson

remoteproc: qcom: qdsp6-adsp: Add support for QCS404 CDSP

Move the clock list to adsp_pil_data, make the pdc_reset optional and
make the driver directly enable the xo, sleep and core clocks.

The three clocks are previously toggled through the clock controller,
but that means the same hardware block needs to be mapped in both
drivers. Making the remoteproc driver enable the clocks is a nop when
using the clock controller, but allow us to remove the clocks from the
clock controller.
Reviewed-by: default avatarVinod Koul <vkoul@kernel.org>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 7ef5f7dd
...@@ -46,11 +46,9 @@ ...@@ -46,11 +46,9 @@
#define LPASS_PWR_ON_REG 0x10 #define LPASS_PWR_ON_REG 0x10
#define LPASS_HALTREQ_REG 0x0 #define LPASS_HALTREQ_REG 0x0
/* list of clocks required by ADSP PIL */ #define QDSP6SS_XO_CBCR 0x38
static const char * const adsp_clk_id[] = { #define QDSP6SS_CORE_CBCR 0x20
"sway_cbcr", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr", #define QDSP6SS_SLEEP_CBCR 0x3c
"qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core",
};
struct adsp_pil_data { struct adsp_pil_data {
int crash_reason_smem; int crash_reason_smem;
...@@ -59,6 +57,9 @@ struct adsp_pil_data { ...@@ -59,6 +57,9 @@ struct adsp_pil_data {
const char *ssr_name; const char *ssr_name;
const char *sysmon_name; const char *sysmon_name;
int ssctl_id; int ssctl_id;
const char **clk_ids;
int num_clks;
}; };
struct qcom_adsp { struct qcom_adsp {
...@@ -75,7 +76,7 @@ struct qcom_adsp { ...@@ -75,7 +76,7 @@ struct qcom_adsp {
void __iomem *qdsp6ss_base; void __iomem *qdsp6ss_base;
struct reset_control *pdc_sync_reset; struct reset_control *pdc_sync_reset;
struct reset_control *cc_lpass_restart; struct reset_control *restart;
struct regmap *halt_map; struct regmap *halt_map;
unsigned int halt_lpass; unsigned int halt_lpass;
...@@ -143,7 +144,7 @@ static int qcom_adsp_shutdown(struct qcom_adsp *adsp) ...@@ -143,7 +144,7 @@ static int qcom_adsp_shutdown(struct qcom_adsp *adsp)
/* Assert the LPASS PDC Reset */ /* Assert the LPASS PDC Reset */
reset_control_assert(adsp->pdc_sync_reset); reset_control_assert(adsp->pdc_sync_reset);
/* Place the LPASS processor into reset */ /* Place the LPASS processor into reset */
reset_control_assert(adsp->cc_lpass_restart); reset_control_assert(adsp->restart);
/* wait after asserting subsystem restart from AOSS */ /* wait after asserting subsystem restart from AOSS */
usleep_range(200, 300); usleep_range(200, 300);
...@@ -153,7 +154,7 @@ static int qcom_adsp_shutdown(struct qcom_adsp *adsp) ...@@ -153,7 +154,7 @@ static int qcom_adsp_shutdown(struct qcom_adsp *adsp)
/* De-assert the LPASS PDC Reset */ /* De-assert the LPASS PDC Reset */
reset_control_deassert(adsp->pdc_sync_reset); reset_control_deassert(adsp->pdc_sync_reset);
/* Remove the LPASS reset */ /* Remove the LPASS reset */
reset_control_deassert(adsp->cc_lpass_restart); reset_control_deassert(adsp->restart);
/* wait after de-asserting subsystem restart from AOSS */ /* wait after de-asserting subsystem restart from AOSS */
usleep_range(200, 300); usleep_range(200, 300);
...@@ -192,6 +193,15 @@ static int adsp_start(struct rproc *rproc) ...@@ -192,6 +193,15 @@ static int adsp_start(struct rproc *rproc)
goto disable_power_domain; goto disable_power_domain;
} }
/* Enable the XO clock */
writel(1, adsp->qdsp6ss_base + QDSP6SS_XO_CBCR);
/* Enable the QDSP6SS sleep clock */
writel(1, adsp->qdsp6ss_base + QDSP6SS_SLEEP_CBCR);
/* Enable the QDSP6 core clock */
writel(1, adsp->qdsp6ss_base + QDSP6SS_CORE_CBCR);
/* Program boot address */ /* Program boot address */
writel(adsp->mem_phys >> 4, adsp->qdsp6ss_base + RST_EVB_REG); writel(adsp->mem_phys >> 4, adsp->qdsp6ss_base + RST_EVB_REG);
...@@ -280,8 +290,9 @@ static const struct rproc_ops adsp_ops = { ...@@ -280,8 +290,9 @@ static const struct rproc_ops adsp_ops = {
.load = adsp_load, .load = adsp_load,
}; };
static int adsp_init_clock(struct qcom_adsp *adsp) static int adsp_init_clock(struct qcom_adsp *adsp, const char **clk_ids)
{ {
int num_clks = 0;
int i, ret; int i, ret;
adsp->xo = devm_clk_get(adsp->dev, "xo"); adsp->xo = devm_clk_get(adsp->dev, "xo");
...@@ -292,32 +303,39 @@ static int adsp_init_clock(struct qcom_adsp *adsp) ...@@ -292,32 +303,39 @@ static int adsp_init_clock(struct qcom_adsp *adsp)
return ret; return ret;
} }
adsp->num_clks = ARRAY_SIZE(adsp_clk_id); for (i = 0; clk_ids[i]; i++)
num_clks++;
adsp->num_clks = num_clks;
adsp->clks = devm_kcalloc(adsp->dev, adsp->num_clks, adsp->clks = devm_kcalloc(adsp->dev, adsp->num_clks,
sizeof(*adsp->clks), GFP_KERNEL); sizeof(*adsp->clks), GFP_KERNEL);
if (!adsp->clks) if (!adsp->clks)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < adsp->num_clks; i++) for (i = 0; i < adsp->num_clks; i++)
adsp->clks[i].id = adsp_clk_id[i]; adsp->clks[i].id = clk_ids[i];
return devm_clk_bulk_get(adsp->dev, adsp->num_clks, adsp->clks); return devm_clk_bulk_get(adsp->dev, adsp->num_clks, adsp->clks);
} }
static int adsp_init_reset(struct qcom_adsp *adsp) static int adsp_init_reset(struct qcom_adsp *adsp)
{ {
adsp->pdc_sync_reset = devm_reset_control_get_exclusive(adsp->dev, adsp->pdc_sync_reset = devm_reset_control_get_optional_exclusive(adsp->dev,
"pdc_sync"); "pdc_sync");
if (IS_ERR(adsp->pdc_sync_reset)) { if (IS_ERR(adsp->pdc_sync_reset)) {
dev_err(adsp->dev, "failed to acquire pdc_sync reset\n"); dev_err(adsp->dev, "failed to acquire pdc_sync reset\n");
return PTR_ERR(adsp->pdc_sync_reset); return PTR_ERR(adsp->pdc_sync_reset);
} }
adsp->cc_lpass_restart = devm_reset_control_get_exclusive(adsp->dev, adsp->restart = devm_reset_control_get_optional_exclusive(adsp->dev, "restart");
"cc_lpass");
if (IS_ERR(adsp->cc_lpass_restart)) { /* Fall back to the old "cc_lpass" if "restart" is absent */
dev_err(adsp->dev, "failed to acquire cc_lpass restart\n"); if (!adsp->restart)
return PTR_ERR(adsp->cc_lpass_restart); adsp->restart = devm_reset_control_get_exclusive(adsp->dev, "cc_lpass");
if (IS_ERR(adsp->restart)) {
dev_err(adsp->dev, "failed to acquire restart\n");
return PTR_ERR(adsp->restart);
} }
return 0; return 0;
...@@ -415,7 +433,7 @@ static int adsp_probe(struct platform_device *pdev) ...@@ -415,7 +433,7 @@ static int adsp_probe(struct platform_device *pdev)
if (ret) if (ret)
goto free_rproc; goto free_rproc;
ret = adsp_init_clock(adsp); ret = adsp_init_clock(adsp, desc->clk_ids);
if (ret) if (ret)
goto free_rproc; goto free_rproc;
...@@ -479,9 +497,28 @@ static const struct adsp_pil_data adsp_resource_init = { ...@@ -479,9 +497,28 @@ static const struct adsp_pil_data adsp_resource_init = {
.ssr_name = "lpass", .ssr_name = "lpass",
.sysmon_name = "adsp", .sysmon_name = "adsp",
.ssctl_id = 0x14, .ssctl_id = 0x14,
.clk_ids = (const char*[]) {
"sway_cbcr", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr",
"qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core", NULL
},
.num_clks = 7,
};
static const struct adsp_pil_data cdsp_resource_init = {
.crash_reason_smem = 601,
.firmware_name = "cdsp.mdt",
.ssr_name = "cdsp",
.sysmon_name = "cdsp",
.ssctl_id = 0x17,
.clk_ids = (const char*[]) {
"sway", "tbu", "bimc", "ahb_aon", "q6ss_slave", "q6ss_master",
"q6_axim", NULL
},
.num_clks = 7,
}; };
static const struct of_device_id adsp_of_match[] = { static const struct of_device_id adsp_of_match[] = {
{ .compatible = "qcom,qcs404-cdsp-pil", .data = &cdsp_resource_init },
{ .compatible = "qcom,sdm845-adsp-pil", .data = &adsp_resource_init }, { .compatible = "qcom,sdm845-adsp-pil", .data = &adsp_resource_init },
{ }, { },
}; };
......
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