remoteproc: qcom: Add support to hexagon v56 1.5.0 in qcom hexagon rproc driver
Subsystems (5)
v4 cover remoteproc: qcom: Add support to hexagon v56 1.5.0 in qcom hexagon rproc driver
This is patchset v4 having modifications as per comment on patchset v3. Major changes w.r.t. patchset v3 are as below.
1- clean up of resource struct initialization.
2- breaking up all changes into more number of logical patches. 3- handling of clock through array of clock pointers. 4- single place handling of proxy and active regulators. 5- use of reset control framework for MSS reset
5- Addressing Other comments on last patches.
Avaneesh Kumar Dwivedi (7):
remoteproc: qcom: Add and initialize private data for hexagon dsp.
remoteproc: qcom: Initialize proxy and active clock's and regulator's
remoteproc: qcom: Modify regulator enable and disable interface
remoteproc: qcom: Modify clock enable and disable routine
remoteproc: qcom: Modify reset sequence for hexagon to support v56
1.5.0
remoteproc: qcom: Modify stop routine to limit MX current for v56 1.5
clk: qcom: Add GCC_MSS_RESET support to reset MSS in v56 1.5.0
.../devicetree/bindings/remoteproc/qcom,q6v5.txt | 2 + drivers/clk/qcom/gcc-msm8996.c | 1 + drivers/remoteproc/qcom_q6v5_pil.c | 544 ++++++++++++++++----- include/dt-bindings/clock/qcom,gcc-msm8996.h | 1 + 4 files changed, 436 insertions(+), 112 deletions(-)
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH RESEND v4 1/7 remoteproc: qcom: Add and initialize private data for hexagon dsp.
Resource string's specific to version of hexagon chip are initialized to be passed to probe for various resource init purpose. Also compatible string introduced are added to documentation.
--- .../devicetree/bindings/remoteproc/qcom,q6v5.txt | 2 + drivers/remoteproc/qcom_q6v5_pil.c | 61 +++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt +2 -0
@@ -8,6 +8,8 @@ on the Qualcomm Hexagon core. Value type: <string> Definition: must be one of: "qcom,q6v5-pil" + "qcom,q6v5-5-1-1-pil" + "qcom,q6v56-1-5-0-pil" - reg: Usage: required
drivers/remoteproc/qcom_q6v5_pil.c +60 -1
86 lines not on this page · raw message
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 1/7] remoteproc: qcom: Add and initialize private data for hexagon dsp.
Quoted 4 lines · Avaneesh Kumar Dwivedi
Resource string's specific to version of hexagon chip are initialized to be passed to probe for various resource init purpose. Also compatible string introduced are added to documentation.
Overall I think the series looks good now, will comment on individual things of each patch, but I'm generally happy about how things look.
I would however like to see a slight restructuring between the patches.
Rather than adding regulators, clocks and version to the res-struct in patch 1 and then add the code using these later I would like you to introduce the smallest possible struct here and then add each part in the relevant patch. And finish off with adding the msm8996 compatible, once all the pieces are in place.
So in this first patch I would suggest that you add the msm8974 and msm8916 compatibles, a res-struct containing only hexagon_mba_image and the change from patch 2 where you change rproc_alloc() to use the hexagon_mba_image.
Then in the regulator patch add the regulators for msm8974 and msm8916, same with clocks in the clock patch and then add the hexagon_ver, the associated changes and the msm8996 compatible in one patch.
That way each patch add a single consistent chunk of the changes.
Quoted 11 lines
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- .../devicetree/bindings/remoteproc/qcom,q6v5.txt | 2 + drivers/remoteproc/qcom_q6v5_pil.c | 61 +++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt +0
-0
Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt on the Qualcomm Hexagon core. · line 12
Quoted 5 lines
Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt +2
-0@@ -8,6 +8,8 @@ on the Qualcomm Hexagon core. Value type: <string> Definition: must be one of: "qcom,q6v5-pil" + "qcom,q6v5-5-1-1-pil" + "qcom,q6v56-1-5-0-pil"
The more I look at these numbers and what's used downstream the more confused I get and perhaps more important, I can't find any documentation mentioning these numbers.
As far as I can see these numbers are 1:1 with specific platforms, which we use as part of other bindings. So I think we should follow the naming scheme we use for e.g. the ADSP PIL.
And let's replace the q6v5 part with "mss", as e.g. msm8974 adsp also is a "q6v5".
So please add:
"qcom,msm8916-mss-pil",
"qcom,msm8974-mss-pil",
"qcom,msm8996-mss-pil"
The compatible "qcom,q6v5-pil" is already introduced in the msm8916.dtsi, so make that compatible be equivalent to "qcom,msm8916-mss-pil" (but let's have both for clarity).
Quoted 16 lines
Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt +0
-0- reg: Usage: requireddrivers/remoteproc/qcom_q6v5_pil.c +1
-0@@ -30,6 +30,7 @@#include <linux/reset.h> #include <linux/soc/qcom/smem.h> #include <linux/soc/qcom/smem_state.h> +#include <linux/of_device.h> #include "remoteproc_internal.h" #include "qcom_mdt_loader.h"
drivers/remoteproc/qcom_q6v5_pil.c line 98
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-0@@ -93,6 +94,22 @@#define QDSS_BHS_ON BIT(21)#define QDSS_LDO_BYP BIT(22) +struct rproc_hexagon_res { +char *hexagon_mba_image;
const
drivers/remoteproc/qcom_q6v5_pil.c line 102
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+char **proxy_reg_string; +char **active_reg_string; +int proxy_uV_uA[3 ][2 ]; +int active_uV_uA[1 ][2 ];
Let's group these into a:
struct qcom_mss_reg_res {
const char *supply;
int uA;
int uV;
};Then the res definitions below becomes:
satic const struct rproc_hexagon_res msm8916_res = {
.proxy_regs = (struct qcom_mss_reg_res[]) {
{
.supply = "mx",
},
{
.supply = "cx",
.uA = 100000,
},
{
.supply = "pll",
.uA = 100000,
},
{ NULL }
},
...
};Quoted 14 lines
drivers/remoteproc/qcom_q6v5_pil.c +10
-0+char **proxy_clk_string; +char **active_clk_string; +int hexagon_ver; +}; + +struct reg_info { +struct regulator *reg; +int uV; +int uA; +};struct q6v5 {struct device *dev;struct rproc *rproc;
drivers/remoteproc/qcom_q6v5_pil.c struct q6v5 { · line 153
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0@@ -131,6 +148,12 @@ struct q6v5 { };enum { +Q6V5_5_0_0 ,/*hexagon on msm8916*/ +Q6V5_5_1_1 ,/*hexagon on msm8974*/ +Q5V56_1_5_0 ,/*hexagon on msm8996*/
As I said above, this turns out to be confusing. Name them based on platform instead. Something like Q6V5_MSM8916
drivers/remoteproc/qcom_q6v5_pil.c struct q6v5 { · line 155
Quoted 2 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-0+}; +
Regards,
Bjorn
Re: [RESEND PATCH v4 1/7] remoteproc: qcom: Add and initialize private data for hexagon dsp.
Quoted 8 lines · Bjorn Andersson
Quoted 4 lines · Avaneesh Kumar Dwivedi
Resource string's specific to version of hexagon chip are initialized to be passed to probe for various resource init purpose. Also compatible string introduced are added to documentation.
Overall I think the series looks good now, will comment on individual things of each patch, but I'm generally happy about how things look.
Thanks Bjorn for reviewing,
Quoted 3 lines
I would however like to see a slight restructuring between the patches.
ok, sure.
Quoted 6 lines
Rather than adding regulators, clocks and version to the res-struct in patch 1 and then add the code using these later I would like you to introduce the smallest possible struct here and then add each part in the relevant patch. And finish off with adding the msm8996 compatible, once all the pieces are in place.
ok.
Quoted 5 lines
So in this first patch I would suggest that you add the msm8974 and msm8916 compatibles, a res-struct containing only
hexagon_mba_imageand the change from patch 2 where you changerproc_alloc()to use thehexagon_mba_image.
ok. so i am going to add additional compatible string while also keeping existing compatible
as below. Also compatible string i have changed but is it OK to keep resource instance named as "qdsp6v5_5_0_0_res" as below?
+static const struct rproc_hexagon_res qdsp6v5_5_0_0_res = {
+ .hexagon_mba_image = "mba.mbn",
+};
+static const struct rproc_hexagon_res qdsp6v5_5_1_1_res = {
+ .hexagon_mba_image = "mba.b00",
+};
static const struct of_device_id q6v5_of_match[] = {
- { .compatible = "qcom,q6v5-pil", },
+ { .compatible = "qcom,q6v5-pil", .data = &qdsp6v5_5_0_0_res},
+ { .compatible = "qcom,msm8916-mss-pil", .data = &qdsp6v5_5_0_0_res},
+ { .compatible = "qcom,msm8974-mss-pil", .data = &qdsp6v5_5_1_1_res},
{ },};
Quoted 4 lines
Then in the regulator patch add the regulators for msm8974 and msm8916, same with clocks in the clock patch and then add the
hexagon_ver, the associated changes and the msm8996 compatible in one patch.
Ok.
Quoted 2 lines
That way each patch add a single consistent chunk of the changes.
Sure.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- .../devicetree/bindings/remoteproc/qcom,q6v5.txt | 2 + drivers/remoteproc/qcom_q6v5_pil.c | 61 +++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)
Quoted 13 lines
Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt on the Qualcomm Hexagon core. · line 12
Quoted 10 lines
Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt +2
-0@@ -8,6 +8,8 @@ on the Qualcomm Hexagon core. Value type: <string> Definition: must be one of: "qcom,q6v5-pil" + "qcom,q6v5-5-1-1-pil" + "qcom,q6v56-1-5-0-pil"The more I look at these numbers and what's used downstream the more confused I get and perhaps more important, I can't find any documentation mentioning these numbers.
These versions which i adopted here are as per HPG documents.
There was some inconsistency in using the exact version of hexagon chip for compatible string purpose in downstream.
If one look documentation in downstream similar naming convention is adopted to indicate version though compatible string is still not in conformance.
for example
Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt:- qcom,qdsp6v56-1-3: Boolean- Present if the qdsp version is v56 1.3====> applicable for mdm9640 platform Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt:- qcom,qdsp6v56-1-5: Boolean- Present if the qdsp version is v56 1.5 ===> applicable for msm8996 platform Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt:- qcom,qdsp6v56-1-8: Boolean- Present if the qdsp version is v56 1.8 ===> applicable for msm8952 and msm8940 platforms. Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt:- qcom,qdsp6v56-1-10: Boolean- Present if the qdsp version is v56 1.10===>applicable for msm8953 platform Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt:- qcom,qdsp6v61-1-1: Boolean- Present if the qdsp version is v61 1.1 Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt:- qcom,qdsp6v62-1-2: Boolean- Present if the qdsp version is v62 1.2====>applicable for msm8998 Documentation/devicetree/bindings/pil/pil-q6v5-mss.txt:- qcom,qdsp6v62-1-5: Boolean- Present if the qdsp version is v62 1.5
Quoted 4 lines
As far as I can see these numbers are 1:1 with specific platforms, which we use as part of other bindings. So I think we should follow the naming scheme we use for e.g. the ADSP PIL.
In very few cases same hexagon chip is used in more than one msm platform i.e. one-to-many
example q6v56 1.8 is used on msm8952 as well as on msm8940, but generally it is one to one mapping with msm platform.
Quoted 8 lines
And let's replace the q6v5 part with "mss", as e.g. msm8974 adsp also is a "q6v5".
So please add:
"qcom,msm8916-mss-pil",
"qcom,msm8974-mss-pil",
"qcom,msm8996-mss-pil"
OK.
Quoted 4 lines
The compatible "qcom,q6v5-pil" is already introduced in the
msm8916.dtsi, so make that compatible be equivalent to "qcom,msm8916-mss-pil" (but let's have both for clarity).
so i will keep "qcom,msm8916-mss-pil" as well as "qcom,q6v5-pil" both in code.
Quoted 20 lines
Quoted 20 lines
Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt +0
-0- reg: Usage: requireddrivers/remoteproc/qcom_q6v5_pil.c +1
-0@@ -30,6 +30,7 @@#include <linux/reset.h> #include <linux/soc/qcom/smem.h> #include <linux/soc/qcom/smem_state.h> +#include <linux/of_device.h> #include "remoteproc_internal.h" #include "qcom_mdt_loader.h" @@ -93,6 +94,22 @@#define QDSS_BHS_ON BIT(21)#define QDSS_LDO_BYP BIT(22)
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c line 98
Quoted 2 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-0+struct rproc_hexagon_res { +char *hexagon_mba_image;const
OK.
Quoted 24 lines
drivers/remoteproc/qcom_q6v5_pil.c line 102
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+char **proxy_reg_string; +char **active_reg_string; +int proxy_uV_uA[3 ][2 ]; +int active_uV_uA[1 ][2 ];Let's group these into a:
struct qcom_mss_reg_res { const char *supply; int uA; int uV; };Then the res definitions below becomes:
satic const struct rproc_hexagon_res msm8916_res = { .proxy_regs = (struct qcom_mss_reg_res[]) { { .supply = "mx", }, { .supply = "cx", .uA = 100000, },
Quoted 8 lines
{
.supply = "pll",
.uA = 100000,
},
{ NULL }
},
...
};Ok, Sure.
Quoted 17 lines
Quoted 17 lines
drivers/remoteproc/qcom_q6v5_pil.c +10
-0+char **proxy_clk_string; +char **active_clk_string; +int hexagon_ver; +}; + +struct reg_info { +struct regulator *reg; +int uV; +int uA; +};struct q6v5 {struct device *dev;struct rproc *rproc;@@ -131,6 +148,12 @@ struct q6v5 { };
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c struct q6v5 { · line 153
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0enum { +Q6V5_5_0_0 ,/*hexagon on msm8916*/ +Q6V5_5_1_1 ,/*hexagon on msm8974*/ +Q5V56_1_5_0 ,/*hexagon on msm8996*/ As I said above, this turns out to be confusing. Name them based on platform instead. Something like
Q6V5_MSM8916
Sure.
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c struct q6v5 { · line 155
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-0+}; +Regards,
Bjorn
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 1/7] remoteproc: qcom: Add and initialize private data for hexagon dsp.
Quoted 6 lines · Avaneesh Kumar (avani)
Quoted 4 lines
So in this first patch I would suggest that you add the msm8974 and msm8916 compatibles, a res-struct containing only
hexagon_mba_imageand the change from patch 2 where you changerproc_alloc()to use thehexagon_mba_image.ok. so i am going to add additional compatible string while also keeping existing compatible as below.
Yes, we need to keep the qcom,q6v5-pil and your change below looks to get it right.
Quoted 3 lines
Also compatible string i have changed but is it OK to keep resource instance named as "
qdsp6v5_5_0_0_res" as below?
Please update their naming based on the platform name as well, it will cause less confusion in the future.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_remove(struct platform_device *pdev) · line 926
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+static const struct rproc_hexagon_res qdsp6v5_5_0_0_res = { + .hexagon_mba_image ="mba.mbn" , +};
A single empty line between each struct makes things easier to read.
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +6
-1+static const struct rproc_hexagon_res qdsp6v5_5_1_1_res = { + .hexagon_mba_image ="mba.b00" , +};static const struct of_device_id q6v5_of_match[] = { - { .compatible ="qcom,q6v5-pil" , }, + { .compatible ="qcom,q6v5-pil" , .data = &qdsp6v5_5_0_0_res}, + { .compatible ="qcom,msm8916-mss-pil" , .data = &qdsp6v5_5_0_0_res}, + { .compatible ="qcom,msm8974-mss-pil" , .data = &qdsp6v5_5_1_1_res}, { }, };
[..]
Quoted 7 lines
Quoted 3 lines
As far as I can see these numbers are 1:1 with specific platforms, which we use as part of other bindings. So I think we should follow the naming scheme we use for e.g. the ADSP PIL.
In very few cases same hexagon chip is used in more than one msm platform i.e. one-to-many
example q6v56 1.8 is used on msm8952 as well as on msm8940, but generally it is one to one mapping with msm platform.
Okay, thanks for the summary.
In these rare cases we can have two compatibles referencing the same struct.
Quoted 8 lines
Quoted 8 lines
And let's replace the q6v5 part with "mss", as e.g. msm8974 adsp also is a "q6v5".
So please add:
"qcom,msm8916-mss-pil",
"qcom,msm8974-mss-pil",
"qcom,msm8996-mss-pil"
Quoted 7 lines
OK.
Quoted 4 lines
The compatible "qcom,q6v5-pil" is already introduced in the
msm8916.dtsi, so make that compatible be equivalent to "qcom,msm8916-mss-pil" (but let's have both for clarity).so i will keep "qcom,msm8916-mss-pil" as well as "qcom,q6v5-pil" both in code.
Sound good.
Regards,
Bjorn
PATCH RESEND v4 2/7 remoteproc: qcom: Initialize proxy and active clock's and regulator's
In reply to Avaneesh Kumar DwivediCertain regulators and clocks need voting by rproc on behalf of hexagon only during restart operation but certain clocks and voltage need to be voted till hexagon is up, these regulators and clocks are identified as proxy and active resource whose handle is being obtained by supplying private proxy and active regulator and clock string.
--- drivers/remoteproc/qcom_q6v5_pil.c | 148 +++++++++++++++++++++++++++---------- 1 file changed, 107 insertions(+), 41 deletions(-)
drivers/remoteproc/qcom_q6v5_pil.c +107 -41
@@ -37,7 +37,6 @@#include <linux/qcom_scm.h> -#define MBA_FIRMWARE_NAME "mba.b00"#define MPSS_FIRMWARE_NAME "modem.mdt"#define MPSS_CRASH_REASON_SMEM 421
@@ -132,6 +131,14 @@ struct q6v5 {struct clk *ahb_clk;struct clk *axi_clk;struct clk *rom_clk; +struct clk *active_clks[8 ]; +struct clk *proxy_clks[4 ]; +struct reg_info active_regs[1 ]; +struct reg_info proxy_regs[3 ]; +int active_reg_count; +int proxy_reg_count; +int active_clk_count; +int proxy_clk_count;struct completion start_done;struct completion stop_done;
@@ -160,27 +167,43 @@ enum { Q6V5_SUPPLY_PLL, }; -static int q6v5_regulator_init (struct q6v5 *qproc) +static int q6v5_regulator_init (struct device *dev, +struct reg_info *regs,char **reg_str,int volatage_load[][2 ]) { -int ret; +int reg_count =0 , i; - qproc->supply[Q6V5_SUPPLY_CX ].supply ="cx" ; - qproc->supply[Q6V5_SUPPLY_MX ].supply ="mx" ; - qproc->supply[Q6V5_SUPPLY_MSS ].supply ="mss" ; - qproc->supply[Q6V5_SUPPLY_PLL ].supply ="pll" ; +if (!reg_str) +return 0 ; - ret =devm_regulator_bulk_get (qproc->dev, -ARRAY_SIZE (qproc->supply), qproc->supply); -if (ret <0 ) { -dev_err (qproc->dev,"failed to get supplies\n" ); -return ret; - } +while (reg_str[reg_count] !=NULL ) + reg_count++; -regulator_set_load (qproc->supply[Q6V5_SUPPLY_CX ].consumer,100000 ); -regulator_set_load (qproc->supply[Q6V5_SUPPLY_MSS ].consumer,100000 ); -regulator_set_load (qproc->supply[Q6V5_SUPPLY_PLL ].consumer,10000 ); +if (!reg_count) +return reg_count; -return 0 ; +if (!regs) +return -ENOMEM ; + +for (i =0 ; i < reg_count; i++) { +const char *reg_name; + + reg_name = reg_str[i]; + regs[i].reg =devm_regulator_get (dev, reg_name); +if (IS_ERR (regs[i].reg)) { + +int rc =PTR_ERR (regs[i].reg); + +if (rc != -EPROBE_DEFER ) +dev_err (dev,"Failed to get %s\n regulator" , + reg_name); +return rc; + } + + regs[i].uV = volatage_load[i][0 ]; + regs[i].uA = volatage_load[i][1 ]; + } + +return reg_count; }static int q6v5_regulator_enable (struct q6v5 *qproc)
@@ -725,27 +748,41 @@ static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev)return 0 ; } -static int q6v5_init_clocks (struct q6v5 *qproc) +static int q6v5_init_clocks (struct device *dev,struct clk **clks, +char **clk_str) { - qproc->ahb_clk =devm_clk_get (qproc->dev,"iface" ); -if (IS_ERR (qproc->ahb_clk)) { -dev_err (qproc->dev,"failed to get iface clock\n" ); -return PTR_ERR (qproc->ahb_clk); - } +int clk_count =0 , i; - qproc->axi_clk =devm_clk_get (qproc->dev,"bus" ); -if (IS_ERR (qproc->axi_clk)) { -dev_err (qproc->dev,"failed to get bus clock\n" ); -return PTR_ERR (qproc->axi_clk); - } +if (!clk_str) +return 0 ; + +while (clk_str[clk_count] !=NULL ) + clk_count++; + +if (!clk_count) +return clk_count; + +if (!clks) +return -ENOMEM ; + +for (i =0 ; i < clk_count; i++) { +const char *clock_name; + + clock_name = clk_str[i]; + clks[i] =devm_clk_get (dev, clock_name); +if (IS_ERR (clks[i])) { + +int rc =PTR_ERR (clks[i]); + +if (rc != -EPROBE_DEFER ) +dev_err (dev,"Failed to get %s clock\n" , + clock_name); +return rc; + } - qproc->rom_clk =devm_clk_get (qproc->dev,"mem" ); -if (IS_ERR (qproc->rom_clk)) { -dev_err (qproc->dev,"failed to get mem clock\n" ); -return PTR_ERR (qproc->rom_clk); } -return 0 ; +return clk_count; }static int q6v5_init_reset (struct q6v5 *qproc)
@@ -830,10 +867,15 @@ static int q6v5_probe(struct platform_device *pdev) {struct q6v5 *qproc;struct rproc *rproc; -int ret; +const struct rproc_hexagon_res *desc; +int ret, count; + + desc =of_device_get_match_data (&pdev->dev); +if (!desc) +return -EINVAL ; rproc =rproc_alloc (&pdev->dev, pdev->name, &q6v5_ops, -MBA_FIRMWARE_NAME ,sizeof (*qproc)); + desc->hexagon_mba_image,sizeof (*qproc));if (!rproc) {dev_err (&pdev->dev,"failed to allocate rproc\n" );return -ENOMEM ;
@@ -857,18 +899,42 @@ static int q6v5_probe(struct platform_device *pdev)if (ret) goto free_rproc; - ret =q6v5_init_clocks (qproc); -if (ret) - goto free_rproc; + count =q6v5_init_clocks (&pdev->dev, qproc->proxy_clks, + desc->proxy_clk_string); +if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup proxy clocks.\n" ); +return count; + } + qproc->proxy_clk_count = count; - ret =q6v5_regulator_init (qproc); -if (ret) - goto free_rproc; + count =q6v5_init_clocks (&pdev->dev, qproc->active_clks, + desc->active_clk_string); +if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup active clocks.\n" ); +return count; + } + qproc->active_clk_count = count; ret =q6v5_init_reset (qproc);if (ret) goto free_rproc; + count =q6v5_regulator_init (&pdev->dev, qproc->proxy_regs, + desc->proxy_reg_string, (int (*)[2 ])desc->proxy_uV_uA); +if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup active regulators.\n" ); +return count; + } + qproc->proxy_reg_count = count; + + count =q6v5_regulator_init (&pdev->dev, qproc->active_regs, + desc->active_reg_string, (int (*)[2 ])desc->active_uV_uA); +if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup proxy regulators.\n" ); +return count; + } + qproc->active_reg_count = count; + ret =q6v5_request_irq (qproc, pdev,"wdog" , q6v5_wdog_interrupt);if (ret <0 ) goto free_rproc;
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 2/7] remoteproc: qcom: Initialize proxy and active clock's and regulator's
Quoted 6 lines · Avaneesh Kumar Dwivedi
Certain regulators and clocks need voting by rproc on behalf of hexagon only during restart operation but certain clocks and voltage need to be voted till hexagon is up, these regulators and clocks are identified as proxy and active resource whose handle is being obtained by supplying private proxy and active regulator and clock string.
Please split this patch out into the regulator and clock patches respectively, making each a clear functional change.
Quoted 10 lines
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 148 +++++++++++++++++++++++++++---------- 1 file changed, 107 insertions(+), 41 deletions(-)drivers/remoteproc/qcom_q6v5_pil.c +0
-0
drivers/remoteproc/qcom_q6v5_pil.c line 40
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-1@@ -37,7 +37,6 @@#include <linux/qcom_scm.h> -#define MBA_FIRMWARE_NAME "mba.b00"
Please move this to patch 1.
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-0#define MPSS_FIRMWARE_NAME "modem.mdt"#define MPSS_CRASH_REASON_SMEM 421@@ -132,6 +131,14 @@ struct q6v5 {struct clk *ahb_clk;
drivers/remoteproc/qcom_q6v5_pil.c struct q6v5 { · line 141
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +8
-0struct clk *axi_clk;struct clk *rom_clk; +struct clk *active_clks[8 ]; +struct clk *proxy_clks[4 ]; +struct reg_info active_regs[1 ]; +struct reg_info proxy_regs[3 ]; +int active_reg_count; +int proxy_reg_count; +int active_clk_count; +int proxy_clk_count;
Group clocks members together and regulators together.
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 173
Quoted 13 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-2struct completion start_done;struct completion stop_done;@@ -160,27 +167,43 @@ enum { Q6V5_SUPPLY_PLL, }; -static int q6v5_regulator_init (struct q6v5 *qproc) +static int q6v5_regulator_init (struct device *dev, +struct reg_info *regs,char **reg_str,int volatage_load[][2 ]) { -int ret; +int reg_count =0 , i;
Please, one variable per line, sorted (descending) by line length.
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-4- qproc->supply[Q6V5_SUPPLY_CX ].supply ="cx" ; - qproc->supply[Q6V5_SUPPLY_MX ].supply ="mx" ; - qproc->supply[Q6V5_SUPPLY_MSS ].supply ="mss" ; - qproc->supply[Q6V5_SUPPLY_PLL ].supply ="pll" ;
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 178
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-6+if (!reg_str) +return 0 ; - ret =devm_regulator_bulk_get (qproc->dev, -ARRAY_SIZE (qproc->supply), qproc->supply); -if (ret <0 ) { -dev_err (qproc->dev,"failed to get supplies\n" ); -return ret; - } +while (reg_str[reg_count] !=NULL )
Drop "!= NULL" from your condition.
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 182
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-3+ reg_count++; -regulator_set_load (qproc->supply[Q6V5_SUPPLY_CX ].consumer,100000 ); -regulator_set_load (qproc->supply[Q6V5_SUPPLY_MSS ].consumer,100000 ); -regulator_set_load (qproc->supply[Q6V5_SUPPLY_PLL ].consumer,10000 ); +if (!reg_count) +return reg_count;
You can omit this check, as the for loop below will iterate 0 times and we will then return 0.
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 185
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-1-return 0 ; +if (!regs) +return -ENOMEM ;
This will not happen, please drop.
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 188
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ +for (i =0 ; i < reg_count; i++) { +const char *reg_name;
Please keep local variables at the top of the function.
And generally try to use short but clear variable names; in line with my suggestion in patch 1 name it "supply" (or in this case where the original variable is quite short just use it directly).
Quoted 25 lines
drivers/remoteproc/qcom_q6v5_pil.c +18
-0+ + reg_name = reg_str[i]; + regs[i].reg =devm_regulator_get (dev, reg_name); +if (IS_ERR (regs[i].reg)) { + +int rc =PTR_ERR (regs[i].reg); + +if (rc != -EPROBE_DEFER ) +dev_err (dev,"Failed to get %s\n regulator" , + reg_name); +return rc; + } + + regs[i].uV = volatage_load[i][0 ]; + regs[i].uA = volatage_load[i][1 ]; + } + +return reg_count; }static int q6v5_regulator_enable (struct q6v5 *qproc)@@ -725,27 +748,41 @@ static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev)return 0 ; }
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) · line 754
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-6-static int q6v5_init_clocks (struct q6v5 *qproc) +static int q6v5_init_clocks (struct device *dev,struct clk **clks, +char **clk_str) { - qproc->ahb_clk =devm_clk_get (qproc->dev,"iface" ); -if (IS_ERR (qproc->ahb_clk)) { -dev_err (qproc->dev,"failed to get iface clock\n" ); -return PTR_ERR (qproc->ahb_clk); - } +int clk_count =0 , i;
One variable per line, please. And "count" is unambiguous enough.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) · line 759
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-5- qproc->axi_clk =devm_clk_get (qproc->dev,"bus" ); -if (IS_ERR (qproc->axi_clk)) { -dev_err (qproc->dev,"failed to get bus clock\n" ); -return PTR_ERR (qproc->axi_clk); - } +if (!clk_str) +return 0 ; + +while (clk_str[clk_count] !=NULL )
Drop "!= NULL" part
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) · line 763
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+ clk_count++; + +if (!clk_count) +return clk_count;
This is not needed.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) · line 766
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ +if (!clks) +return -ENOMEM ;
This can't happen.
Quoted 28 lines
drivers/remoteproc/qcom_q6v5_pil.c +16
-5+ +for (i =0 ; i < clk_count; i++) { +const char *clock_name; + + clock_name = clk_str[i]; + clks[i] =devm_clk_get (dev, clock_name); +if (IS_ERR (clks[i])) { + +int rc =PTR_ERR (clks[i]); + +if (rc != -EPROBE_DEFER ) +dev_err (dev,"Failed to get %s clock\n" , + clock_name); +return rc; + } - qproc->rom_clk =devm_clk_get (qproc->dev,"mem" ); -if (IS_ERR (qproc->rom_clk)) { -dev_err (qproc->dev,"failed to get mem clock\n" ); -return PTR_ERR (qproc->rom_clk); } -return 0 ; +return clk_count; }static int q6v5_init_reset (struct q6v5 *qproc)
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 871
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-1@@ -830,10 +867,15 @@ static int q6v5_probe(struct platform_device *pdev) {struct q6v5 *qproc;struct rproc *rproc; -int ret; +const struct rproc_hexagon_res *desc; +int ret, count;
One variable per line please, and sort (descending) on line length.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 878
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c +5
-1+ + desc =of_device_get_match_data (&pdev->dev); +if (!desc) +return -EINVAL ; rproc =rproc_alloc (&pdev->dev, pdev->name, &q6v5_ops, -MBA_FIRMWARE_NAME ,sizeof (*qproc)); + desc->hexagon_mba_image,sizeof (*qproc));
Please move this to patch 1.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 903
Quoted 11 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-2if (!rproc) {dev_err (&pdev->dev,"failed to allocate rproc\n" );return -ENOMEM ;@@ -857,18 +899,42 @@ static int q6v5_probe(struct platform_device *pdev)if (ret) goto free_rproc; -if (ret) - goto free_rproc; + count =q6v5_init_clocks (&pdev->dev, qproc->proxy_clks, + desc->proxy_clk_string);
Your "count" serves the same purpose as "ret", so just use "ret". And align broken lines with the parenthesis.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 906
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup proxy clocks.\n" ); +return count;
And using "ret" instead of "count" makes it easy to goto free_rproc, which you must do after calling rproc_alloc().
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +6
-3+ } + qproc->proxy_clk_count = count; - ret =q6v5_regulator_init (qproc); -if (ret) - goto free_rproc; + count =q6v5_init_clocks (&pdev->dev, qproc->active_clks, + desc->active_clk_string); +if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup active clocks.\n" );
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 923
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +5
-0+return count; + } + qproc->active_clk_count = count; ret =q6v5_init_reset (qproc);if (ret) goto free_rproc; + count =q6v5_regulator_init (&pdev->dev, qproc->proxy_regs, + desc->proxy_reg_string, (int (*)[2 ])desc->proxy_uV_uA);
Moving proxy_reg_string and proxy_uV_uA into a struct (as suggested in patch 1) will make this cleaner and we get rid of that typecast.
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c +7
-0+if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup active regulators.\n" ); +return count; + } + qproc->proxy_reg_count = count; + + count = q6v5_regulator_init(&pdev->dev, qproc->active_regs,
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 940
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +7
-0+ desc->active_reg_string, (int (*)[2])desc->active_uV_uA); +if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup proxy regulators.\n" ); +return count; + } + qproc->active_reg_count = count; + ret =q6v5_request_irq (qproc, pdev,"wdog" , q6v5_wdog_interrupt);if (ret <0 ) goto free_rproc;
Regards,
Bjorn
Re: [RESEND PATCH v4 2/7] remoteproc: qcom: Initialize proxy and active clock's and regulator's
Quoted 10 lines · Bjorn Andersson
Quoted 6 lines · Avaneesh Kumar Dwivedi
Certain regulators and clocks need voting by rproc on behalf of hexagon only during restart operation but certain clocks and voltage need to be voted till hexagon is up, these regulators and clocks are identified as proxy and active resource whose handle is being obtained by supplying private proxy and active regulator and clock string.
Please split this patch out into the regulator and clock patches respectively, making each a clear functional change.
OK.
Quoted 12 lines
Quoted 12 lines
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 148 +++++++++++++++++++++++++++---------- 1 file changed, 107 insertions(+), 41 deletions(-)drivers/remoteproc/qcom_q6v5_pil.c +0
-0@@ -37,7 +37,6 @@
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c line 40
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-1#include <linux/qcom_scm.h> -#define MBA_FIRMWARE_NAME "mba.b00"Please move this to patch 1.
OK.
Quoted 17 lines
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-0#define MPSS_FIRMWARE_NAME "modem.mdt"#define MPSS_CRASH_REASON_SMEM 421@@ -132,6 +131,14 @@ struct q6v5 {struct clk *ahb_clk;drivers/remoteproc/qcom_q6v5_pil.c struct q6v5 { · line 141
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +8
-0struct clk *axi_clk;struct clk *rom_clk; +struct clk *active_clks[8 ]; +struct clk *proxy_clks[4 ]; +struct reg_info active_regs[1 ]; +struct reg_info proxy_regs[3 ]; +int active_reg_count; +int proxy_reg_count; +int active_clk_count; +int proxy_clk_count;Group clocks members together and regulators together.
OK.
Quoted 8 lines
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-0struct completion start_done;struct completion stop_done;@@ -160,27 +167,43 @@ enum { Q6V5_SUPPLY_PLL, };
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 173
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-2-static int q6v5_regulator_init (struct q6v5 *qproc) +static int q6v5_regulator_init (struct device *dev, +struct reg_info *regs,char **reg_str,int volatage_load[][2 ]) { -int ret; +int reg_count =0 , i;Please, one variable per line, sorted (descending) by line length.
OK.
Quoted 9 lines
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-4- qproc->supply[Q6V5_SUPPLY_CX ].supply ="cx" ; - qproc->supply[Q6V5_SUPPLY_MX ].supply ="mx" ; - qproc->supply[Q6V5_SUPPLY_MSS ].supply ="mss" ; - qproc->supply[Q6V5_SUPPLY_PLL ].supply ="pll" ; +if (!reg_str) +return 0 ;
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 178
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-6- ret =devm_regulator_bulk_get (qproc->dev, -ARRAY_SIZE (qproc->supply), qproc->supply); -if (ret <0 ) { -dev_err (qproc->dev,"failed to get supplies\n" ); -return ret; - } +while (reg_str[reg_count] !=NULL )Drop "!= NULL" from your condition.
OK.
Quoted 17 lines
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 182
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-3+ reg_count++; -regulator_set_load (qproc->supply[Q6V5_SUPPLY_CX ].consumer,100000 ); -regulator_set_load (qproc->supply[Q6V5_SUPPLY_MSS ].consumer,100000 ); -regulator_set_load (qproc->supply[Q6V5_SUPPLY_PLL ].consumer,10000 ); +if (!reg_count) +return reg_count;You can omit this check, as the for loop below will iterate 0 times and we will then return 0.
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 185
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-1-return 0 ; +if (!regs) +return -ENOMEM ;This will not happen, please drop.
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c enum { · line 188
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ +for (i =0 ; i < reg_count; i++) { +const char *reg_name;Please keep local variables at the top of the function.
And generally try to use short but clear variable names; in line with my suggestion in patch 1 name it "supply" (or in this case where the original variable is quite short just use it directly).
OK
Quoted 26 lines
Quoted 26 lines
drivers/remoteproc/qcom_q6v5_pil.c +18
-0+ + reg_name = reg_str[i]; + regs[i].reg =devm_regulator_get (dev, reg_name); +if (IS_ERR (regs[i].reg)) { + +int rc =PTR_ERR (regs[i].reg); + +if (rc != -EPROBE_DEFER ) +dev_err (dev,"Failed to get %s\n regulator" , + reg_name); +return rc; + } + + regs[i].uV = volatage_load[i][0 ]; + regs[i].uA = volatage_load[i][1 ]; + } + +return reg_count; }static int q6v5_regulator_enable (struct q6v5 *qproc)@@ -725,27 +748,41 @@ static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev)return 0 ; }
Quoted 11 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) · line 754
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-6-static int q6v5_init_clocks (struct q6v5 *qproc) +static int q6v5_init_clocks (struct device *dev,struct clk **clks, +char **clk_str) { - qproc->ahb_clk =devm_clk_get (qproc->dev,"iface" ); -if (IS_ERR (qproc->ahb_clk)) { -dev_err (qproc->dev,"failed to get iface clock\n" ); -return PTR_ERR (qproc->ahb_clk); - } +int clk_count =0 , i;One variable per line, please. And "count" is unambiguous enough.
OK.
Quoted 12 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) · line 759
Quoted 11 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-5- qproc->axi_clk =devm_clk_get (qproc->dev,"bus" ); -if (IS_ERR (qproc->axi_clk)) { -dev_err (qproc->dev,"failed to get bus clock\n" ); -return PTR_ERR (qproc->axi_clk); - } +if (!clk_str) +return 0 ; + +while (clk_str[clk_count] !=NULL )Drop "!= NULL" part
OK.
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) · line 763
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+ clk_count++; + +if (!clk_count) +return clk_count;This is not needed.
Yes.
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) · line 766
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ +if (!clks) +return -ENOMEM ;This can't happen.
YES.
Quoted 27 lines
Quoted 27 lines
drivers/remoteproc/qcom_q6v5_pil.c +16
-5+ +for (i =0 ; i < clk_count; i++) { +const char *clock_name; + + clock_name = clk_str[i]; + clks[i] =devm_clk_get (dev, clock_name); +if (IS_ERR (clks[i])) { + +int rc =PTR_ERR (clks[i]); + +if (rc != -EPROBE_DEFER ) +dev_err (dev,"Failed to get %s clock\n" , + clock_name); +return rc; + } - qproc->rom_clk =devm_clk_get (qproc->dev,"mem" ); -if (IS_ERR (qproc->rom_clk)) { -dev_err (qproc->dev,"failed to get mem clock\n" ); -return PTR_ERR (qproc->rom_clk); } -return 0 ; +return clk_count; }
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 871
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-1static int q6v5_init_reset (struct q6v5 *qproc)@@ -830,10 +867,15 @@ static int q6v5_probe(struct platform_device *pdev) {struct q6v5 *qproc;struct rproc *rproc; -int ret; +const struct rproc_hexagon_res *desc; +int ret, count;One variable per line please, and sort (descending) on line length.
ok,
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 878
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_pil.c +5
-1+ + desc =of_device_get_match_data (&pdev->dev); +if (!desc) +return -EINVAL ; rproc =rproc_alloc (&pdev->dev, pdev->name, &q6v5_ops, -MBA_FIRMWARE_NAME ,sizeof (*qproc)); + desc->hexagon_mba_image,sizeof (*qproc));Please move this to patch 1.
OK,
Quoted 8 lines
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-0if (!rproc) {dev_err (&pdev->dev,"failed to allocate rproc\n" );return -ENOMEM ;@@ -857,18 +899,42 @@ static int q6v5_probe(struct platform_device *pdev)if (ret) goto free_rproc;
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 903
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-2-if (ret) - goto free_rproc; + count =q6v5_init_clocks (&pdev->dev, qproc->proxy_clks, + desc->proxy_clk_string);Your "count" serves the same purpose as "ret", so just use "ret". And align broken lines with the parenthesis.
OK.
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 906
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup proxy clocks.\n" ); +return count;And using "ret" instead of "count" makes it easy to goto
free_rproc, which you must do after callingrproc_alloc().
OK.
Quoted 15 lines
Quoted 15 lines
drivers/remoteproc/qcom_q6v5_pil.c +9
-3+ } + qproc->proxy_clk_count = count; - ret =q6v5_regulator_init (qproc); -if (ret) - goto free_rproc; + count =q6v5_init_clocks (&pdev->dev, qproc->active_clks, + desc->active_clk_string); +if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup active clocks.\n" ); +return count; + } + qproc->active_clk_count = count;
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 923
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-0ret =q6v5_init_reset (qproc);if (ret) goto free_rproc; + count =q6v5_regulator_init (&pdev->dev, qproc->proxy_regs, + desc->proxy_reg_string, (int (*)[2 ])desc->proxy_uV_uA);Moving
proxy_reg_stringandproxy_uV_uAinto a struct (as suggested in patch 1) will make this cleaner and we get rid of that typecast.
OK.
Quoted 24 lines
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c +7
-0+if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup active regulators.\n" ); +return count; + } + qproc->proxy_reg_count = count; + + count = q6v5_regulator_init(&pdev->dev, qproc->active_regs,drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_probe(struct platform_device *pdev) · line 940
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +7
-0+ desc->active_reg_string, (int (*)[2])desc->active_uV_uA); +if (count <0 ) { +dev_err (&pdev->dev,"Failed to setup proxy regulators.\n" ); +return count; + } + qproc->active_reg_count = count; + ret =q6v5_request_irq (qproc, pdev,"wdog" , q6v5_wdog_interrupt);if (ret <0 ) goto free_rproc;Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH RESEND v4 3/7 remoteproc: qcom: Modify regulator enable and disable interface
In reply to Avaneesh Kumar DwivediRegulator enable routine will get additional input parameter of regulator info and count, It will read regulator info and will do appropriate voltage and load configuration before turning them up. Also separate out disable interface into proxy and active disable so that on arrival of handover interrupt proxy regulators alone could be voted out.
--- drivers/remoteproc/qcom_q6v5_pil.c | 113 ++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 27 deletions(-)
drivers/remoteproc/qcom_q6v5_pil.c +86 -27
@@ -126,7 +126,6 @@ struct q6v5 {struct qcom_smem_state *state;unsigned stop_bit; -struct regulator_bulk_data supply[4 ];struct clk *ahb_clk;struct clk *axi_clk;
@@ -160,13 +159,6 @@ enum { Q5V56_1_5_0, /*hexagon on msm8996*/ }; -enum { -Q6V5_SUPPLY_CX , -Q6V5_SUPPLY_MX , -Q6V5_SUPPLY_MSS , -Q6V5_SUPPLY_PLL , -}; -static int q6v5_regulator_init (struct device *dev,struct reg_info *regs,char **reg_str,int volatage_load[][2 ]) {
@@ -206,35 +198,93 @@ static int q6v5_regulator_init(struct device *dev,return reg_count; } -static int q6v5_regulator_enable (struct q6v5 *qproc) +static int q6v5_regulator_enable (struct q6v5 *qproc, +struct reg_info *regs,int count) { -struct regulator *mss = qproc->supply[Q6V5_SUPPLY_MSS ].consumer; -struct regulator *mx = qproc->supply[Q6V5_SUPPLY_MX ].consumer; -int ret; +int i, rc =0 ; + +for (i =0 ; i < count; i++) { +if (regs[i].uV >0 ) { + rc =regulator_set_voltage (regs[i].reg, + regs[i].uV,INT_MAX ); +if (rc) { +dev_err (qproc->dev, +"Failed to request voltage for %d.\n" , + i); + goto err; + } + } -/* TODO: Q6V5_SUPPLY_CX is supposed to be set to super-turbo here */ +if (regs[i].uA >0 ) { + rc =regulator_set_load (regs[i].reg, + regs[i].uA); +if (rc <0 ) { +dev_err (qproc->dev,"Failed to set regulator mode\n" ); + goto err; + } + } - ret =regulator_set_voltage (mx,1050000 ,INT_MAX ); -if (ret) -return ret; + rc =regulator_enable (regs[i].reg); +if (rc) { +dev_err (qproc->dev,"Regulator enable failed\n" ); + goto err; + } + } + +return 0 ; +err: +for (; i >=0 ; i--) { +if (regs[i].uV >0 ) +regulator_set_voltage (regs[i].reg,0 ,INT_MAX ); -regulator_set_voltage (mss,1000000 ,1150000 ); +if (regs[i].uA >0 ) +regulator_set_load (regs[i].reg,0 ); + +regulator_disable (regs[i].reg); + } -return regulator_bulk_enable (ARRAY_SIZE (qproc->supply), qproc->supply); +return rc; } -static void q6v5_regulator_disable (struct q6v5 *qproc) +static void q6v5_proxy_regulator_disable (struct q6v5 *qproc) { -struct regulator *mss = qproc->supply[Q6V5_SUPPLY_MSS ].consumer; -struct regulator *mx = qproc->supply[Q6V5_SUPPLY_MX ].consumer; +int i; +struct reg_info *regs = qproc->proxy_regs; -/* TODO: Q6V5_SUPPLY_CX corner votes should be released */ +for (i =0 ; i < qproc->proxy_reg_count; i++) { +if (regs[i].uV >0 ) +regulator_set_voltage (regs[i].reg,0 ,INT_MAX ); -regulator_bulk_disable (ARRAY_SIZE (qproc->supply), qproc->supply); -regulator_set_voltage (mx,0 ,INT_MAX ); -regulator_set_voltage (mss,0 ,1150000 ); +if (regs[i].uA >0 ) +regulator_set_load (regs[i].reg,0 ); + +regulator_disable (regs[i].reg); + } } +static void q6v5_active_regulator_disable (struct q6v5 *qproc) +{ +int i; +struct reg_info *regs = qproc->active_regs; + +for (i =0 ; i < qproc->active_reg_count; i++) { +if (regs[i].uV >0 ) +regulator_set_voltage (regs[i].reg,0 ,INT_MAX ); + +if (regs[i].uA >0 ) +regulator_set_load (regs[i].reg,0 ); + +regulator_disable (regs[i].reg); + } +} + +static void q6v5_regulator_disable (struct q6v5 *qproc) +{ +q6v5_proxy_regulator_disable (qproc); +q6v5_active_regulator_disable (qproc); +} + +static int q6v5_load (struct rproc *rproc,const struct firmware *fw) {struct q6v5 *qproc = rproc->priv;
@@ -524,12 +574,19 @@ static int q6v5_start(struct rproc *rproc)struct q6v5 *qproc = (struct q6v5 *)rproc->priv;int ret; - ret =q6v5_regulator_enable (qproc); + ret =q6v5_regulator_enable (qproc, qproc->proxy_regs, + qproc->proxy_reg_count);if (ret) { -dev_err (qproc->dev,"failed to enable supplies\n" ); +dev_err (qproc->dev,"failed to enable proxy supplies\n" );return ret; } + ret =q6v5_regulator_enable (qproc, qproc->active_regs, + qproc->active_reg_count); +if (ret) { +dev_err (qproc->dev,"failed to enable supplies\n" ); + goto disable_proxy_reg; + } ret =reset_control_deassert (qproc->mss_restart);if (ret) {dev_err (qproc->dev,"failed to deassert mss restart\n" );
@@ -600,6 +657,8 @@ static int q6v5_start(struct rproc *rproc) disable_vdd:q6v5_regulator_disable (qproc); +disable_proxy_reg: +q6v5_proxy_regulator_disable (qproc);return ret; }
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 3/7] remoteproc: qcom: Modify regulator enable and disable interface
Quoted 40 lines · Avaneesh Kumar Dwivedi
Regulator enable routine will get additional input parameter of regulator info and count, It will read regulator info and will do appropriate voltage and load configuration before turning them up. Also separate out disable interface into proxy and active disable so that on arrival of handover interrupt proxy regulators alone could be voted out.
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 113 ++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 27 deletions(-)drivers/remoteproc/qcom_q6v5_pil.c +0
-8@@ -126,7 +126,6 @@ struct q6v5 {struct qcom_smem_state *state;unsigned stop_bit; -struct regulator_bulk_data supply[4 ];struct clk *ahb_clk;struct clk *axi_clk;@@ -160,13 +159,6 @@ enum { Q5V56_1_5_0, /*hexagon on msm8996*/ }; -enum { -Q6V5_SUPPLY_CX , -Q6V5_SUPPLY_MX , -Q6V5_SUPPLY_MSS , -Q6V5_SUPPLY_PLL , -}; -static int q6v5_regulator_init (struct device *dev,struct reg_info *regs,char **reg_str,int volatage_load[][2 ]) {@@ -206,35 +198,93 @@ static int q6v5_regulator_init(struct device *dev,return reg_count;
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_regulator_init(struct device *dev, · line 204
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-4} -static int q6v5_regulator_enable (struct q6v5 *qproc) +static int q6v5_regulator_enable (struct q6v5 *qproc, +struct reg_info *regs,int count) { -struct regulator *mss = qproc->supply[Q6V5_SUPPLY_MSS ].consumer; -struct regulator *mx = qproc->supply[Q6V5_SUPPLY_MX ].consumer; -int ret; +int i, rc =0 ;
One variable per line, no need to replace "ret" with "rc" and no need to initialize it to 0 as it won't be read before written in any code path.
Quoted 42 lines
drivers/remoteproc/qcom_q6v5_pil.c +34
-5+ +for (i =0 ; i < count; i++) { +if (regs[i].uV >0 ) { + rc =regulator_set_voltage (regs[i].reg, + regs[i].uV,INT_MAX ); +if (rc) { +dev_err (qproc->dev, +"Failed to request voltage for %d.\n" , + i); + goto err; + } + } -/* TODO: Q6V5_SUPPLY_CX is supposed to be set to super-turbo here */ +if (regs[i].uA >0 ) { + rc =regulator_set_load (regs[i].reg, + regs[i].uA); +if (rc <0 ) { +dev_err (qproc->dev,"Failed to set regulator mode\n" ); + goto err; + } + } - ret =regulator_set_voltage (mx,1050000 ,INT_MAX ); -if (ret) -return ret; + rc =regulator_enable (regs[i].reg); +if (rc) { +dev_err (qproc->dev,"Regulator enable failed\n" ); + goto err; + } + } + +return 0 ; +err: +for (; i >=0 ; i--) { +if (regs[i].uV >0 ) +regulator_set_voltage (regs[i].reg,0 ,INT_MAX ); -regulator_set_voltage (mss,1000000 ,1150000 ); +if (regs[i].uA >0 ) +regulator_set_load (regs[i].reg,0 );
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_regulator_init(struct device *dev, · line 249
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +5
-2+ +regulator_disable (regs[i].reg); + } -return regulator_bulk_enable (ARRAY_SIZE (qproc->supply), qproc->supply); +return rc; } -static void q6v5_regulator_disable (struct q6v5 *qproc) +static void q6v5_proxy_regulator_disable (struct q6v5 *qproc)
Please have follow the same scheme as for enable, with a function taking the list of regulators and count.
Quoted 48 lines
drivers/remoteproc/qcom_q6v5_pil.c +33
-6{ -struct regulator *mss = qproc->supply[Q6V5_SUPPLY_MSS ].consumer; -struct regulator *mx = qproc->supply[Q6V5_SUPPLY_MX ].consumer; +int i; +struct reg_info *regs = qproc->proxy_regs; -/* TODO: Q6V5_SUPPLY_CX corner votes should be released */ +for (i =0 ; i < qproc->proxy_reg_count; i++) { +if (regs[i].uV >0 ) +regulator_set_voltage (regs[i].reg,0 ,INT_MAX ); -regulator_bulk_disable (ARRAY_SIZE (qproc->supply), qproc->supply); -regulator_set_voltage (mx,0 ,INT_MAX ); -regulator_set_voltage (mss,0 ,1150000 ); +if (regs[i].uA >0 ) +regulator_set_load (regs[i].reg,0 ); + +regulator_disable (regs[i].reg); + } } +static void q6v5_active_regulator_disable (struct q6v5 *qproc) +{ +int i; +struct reg_info *regs = qproc->active_regs; + +for (i =0 ; i < qproc->active_reg_count; i++) { +if (regs[i].uV >0 ) +regulator_set_voltage (regs[i].reg,0 ,INT_MAX ); + +if (regs[i].uA >0 ) +regulator_set_load (regs[i].reg,0 ); + +regulator_disable (regs[i].reg); + } +} + +static void q6v5_regulator_disable (struct q6v5 *qproc) +{ +q6v5_proxy_regulator_disable (qproc); +q6v5_active_regulator_disable (qproc); +} + +static int q6v5_load (struct rproc *rproc,const struct firmware *fw) {struct q6v5 *qproc = rproc->priv;
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 578
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-1@@ -524,12 +574,19 @@ static int q6v5_start(struct rproc *rproc)struct q6v5 *qproc = (struct q6v5 *)rproc->priv;int ret; - ret =q6v5_regulator_enable (qproc); + ret =q6v5_regulator_enable (qproc, qproc->proxy_regs, + qproc->proxy_reg_count);
Align indentation with parenthesis on previous line.
Quoted 16 lines
drivers/remoteproc/qcom_q6v5_pil.c +7
-1if (ret) { -dev_err (qproc->dev,"failed to enable supplies\n" ); +dev_err (qproc->dev,"failed to enable proxy supplies\n" );return ret; } + ret =q6v5_regulator_enable (qproc, qproc->active_regs, + qproc->active_reg_count); +if (ret) { +dev_err (qproc->dev,"failed to enable supplies\n" ); + goto disable_proxy_reg; + } ret =reset_control_deassert (qproc->mss_restart);if (ret) {dev_err (qproc->dev,"failed to deassert mss restart\n" );
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 658
Quoted 2 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-0@@ -600,6 +657,8 @@ static int q6v5_start(struct rproc *rproc) disable_vdd:q6v5_regulator_disable (qproc);
Here you disable both active and proxy regulators, then you call through...
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 661
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-0+disable_proxy_reg: +q6v5_proxy_regulator_disable (qproc);
...and once again disable proxy regulators.
Remove q6v5_regulator_disable() and just call the active and proxy disable functions directly.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 583
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-0return ret; }
Regards,
Bjorn
Re: [RESEND PATCH v4 3/7] remoteproc: qcom: Modify regulator enable and disable interface
Quoted 44 lines · Bjorn Andersson
Quoted 42 lines · Avaneesh Kumar Dwivedi
Regulator enable routine will get additional input parameter of regulator info and count, It will read regulator info and will do appropriate voltage and load configuration before turning them up. Also separate out disable interface into proxy and active disable so that on arrival of handover interrupt proxy regulators alone could be voted out.
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 113 ++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 27 deletions(-)drivers/remoteproc/qcom_q6v5_pil.c +0
-8@@ -126,7 +126,6 @@ struct q6v5 {struct qcom_smem_state *state;unsigned stop_bit; -struct regulator_bulk_data supply[4 ];struct clk *ahb_clk;struct clk *axi_clk;@@ -160,13 +159,6 @@ enum { Q5V56_1_5_0, /*hexagon on msm8996*/ }; -enum { -Q6V5_SUPPLY_CX , -Q6V5_SUPPLY_MX , -Q6V5_SUPPLY_MSS , -Q6V5_SUPPLY_PLL , -}; -static int q6v5_regulator_init (struct device *dev,struct reg_info *regs,char **reg_str,int volatage_load[][2 ]) {@@ -206,35 +198,93 @@ static int q6v5_regulator_init(struct device *dev,return reg_count; }
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_regulator_init(struct device *dev, · line 204
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-4-static int q6v5_regulator_enable (struct q6v5 *qproc) +static int q6v5_regulator_enable (struct q6v5 *qproc, +struct reg_info *regs,int count) { -struct regulator *mss = qproc->supply[Q6V5_SUPPLY_MSS ].consumer; -struct regulator *mx = qproc->supply[Q6V5_SUPPLY_MX ].consumer; -int ret; +int i, rc =0 ;One variable per line, no need to replace "ret" with "rc" and no need to initialize it to 0 as it won't be read before written in any code path.
OK.
Quoted 47 lines
Quoted 47 lines
drivers/remoteproc/qcom_q6v5_pil.c +37
-5+ +for (i =0 ; i < count; i++) { +if (regs[i].uV >0 ) { + rc =regulator_set_voltage (regs[i].reg, + regs[i].uV,INT_MAX ); +if (rc) { +dev_err (qproc->dev, +"Failed to request voltage for %d.\n" , + i); + goto err; + } + } -/* TODO: Q6V5_SUPPLY_CX is supposed to be set to super-turbo here */ +if (regs[i].uA >0 ) { + rc =regulator_set_load (regs[i].reg, + regs[i].uA); +if (rc <0 ) { +dev_err (qproc->dev,"Failed to set regulator mode\n" ); + goto err; + } + } - ret =regulator_set_voltage (mx,1050000 ,INT_MAX ); -if (ret) -return ret; + rc =regulator_enable (regs[i].reg); +if (rc) { +dev_err (qproc->dev,"Regulator enable failed\n" ); + goto err; + } + } + +return 0 ; +err: +for (; i >=0 ; i--) { +if (regs[i].uV >0 ) +regulator_set_voltage (regs[i].reg,0 ,INT_MAX ); -regulator_set_voltage (mss,1000000 ,1150000 ); +if (regs[i].uA >0 ) +regulator_set_load (regs[i].reg,0 ); + +regulator_disable (regs[i].reg); + }
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_regulator_init(struct device *dev, · line 249
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-2-return regulator_bulk_enable (ARRAY_SIZE (qproc->supply), qproc->supply); +return rc; } -static void q6v5_regulator_disable (struct q6v5 *qproc) +static void q6v5_proxy_regulator_disable (struct q6v5 *qproc)Please have follow the same scheme as for enable, with a function taking the list of regulators and count.
Ok.
Quoted 52 lines
Quoted 52 lines
drivers/remoteproc/qcom_q6v5_pil.c +33
-6{ -struct regulator *mss = qproc->supply[Q6V5_SUPPLY_MSS ].consumer; -struct regulator *mx = qproc->supply[Q6V5_SUPPLY_MX ].consumer; +int i; +struct reg_info *regs = qproc->proxy_regs; -/* TODO: Q6V5_SUPPLY_CX corner votes should be released */ +for (i =0 ; i < qproc->proxy_reg_count; i++) { +if (regs[i].uV >0 ) +regulator_set_voltage (regs[i].reg,0 ,INT_MAX ); -regulator_bulk_disable (ARRAY_SIZE (qproc->supply), qproc->supply); -regulator_set_voltage (mx,0 ,INT_MAX ); -regulator_set_voltage (mss,0 ,1150000 ); +if (regs[i].uA >0 ) +regulator_set_load (regs[i].reg,0 ); + +regulator_disable (regs[i].reg); + } } +static void q6v5_active_regulator_disable (struct q6v5 *qproc) +{ +int i; +struct reg_info *regs = qproc->active_regs; + +for (i =0 ; i < qproc->active_reg_count; i++) { +if (regs[i].uV >0 ) +regulator_set_voltage (regs[i].reg,0 ,INT_MAX ); + +if (regs[i].uA >0 ) +regulator_set_load (regs[i].reg,0 ); + +regulator_disable (regs[i].reg); + } +} + +static void q6v5_regulator_disable (struct q6v5 *qproc) +{ +q6v5_proxy_regulator_disable (qproc); +q6v5_active_regulator_disable (qproc); +} + +static int q6v5_load (struct rproc *rproc,const struct firmware *fw) {struct q6v5 *qproc = rproc->priv;@@ -524,12 +574,19 @@ static int q6v5_start(struct rproc *rproc)struct q6v5 *qproc = (struct q6v5 *)rproc->priv;int ret;
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 578
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-1- ret =q6v5_regulator_enable (qproc); + ret =q6v5_regulator_enable (qproc, qproc->proxy_regs, + qproc->proxy_reg_count);Align indentation with parenthesis on previous line.
Ok.
Quoted 7 lines
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-1if (ret) { -dev_err (qproc->dev,"failed to enable supplies\n" ); +dev_err (qproc->dev,"failed to enable proxy supplies\n" );return ret; }
Quoted 14 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 658
Quoted 12 lines
drivers/remoteproc/qcom_q6v5_pil.c +6
-0+ ret =q6v5_regulator_enable (qproc, qproc->active_regs, + qproc->active_reg_count); +if (ret) { +dev_err (qproc->dev,"failed to enable supplies\n" ); + goto disable_proxy_reg; + } ret =reset_control_deassert (qproc->mss_restart);if (ret) {dev_err (qproc->dev,"failed to deassert mss restart\n" );@@ -600,6 +657,8 @@ static int q6v5_start(struct rproc *rproc) disable_vdd:q6v5_regulator_disable (qproc);Here you disable both active and proxy regulators, then you call through...
Ok.
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 661
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-0+disable_proxy_reg: +q6v5_proxy_regulator_disable (qproc);...and once again disable proxy regulators.
Remove
q6v5_regulator_disable()and just call the active and proxy disable functions directly.
Ok. Using single function to disable regulator but passing proxy or active regulator info as necessary.
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 583
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-0return ret; }Regards,
Bjorn
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH RESEND v4 4/7 remoteproc: qcom: Modify clock enable and disable routine
In reply to Avaneesh Kumar DwivediClock handling is made generic than earlier way to add new clock every time when required to support new hexagon version. Also clock disable interface is separated out into two separate routine to unvote proxy clock alone when handover interrupt is arrived.
--- drivers/remoteproc/qcom_q6v5_pil.c | 93 ++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 28 deletions(-)
drivers/remoteproc/qcom_q6v5_pil.c +65 -28
@@ -126,10 +126,6 @@ struct q6v5 {struct qcom_smem_state *state;unsigned stop_bit; - -struct clk *ahb_clk; -struct clk *axi_clk; -struct clk *rom_clk;struct clk *active_clks[8 ];struct clk *proxy_clks[4 ];struct reg_info active_regs[1 ];
@@ -284,6 +280,51 @@ static void q6v5_regulator_disable(struct q6v5 *qproc)q6v5_active_regulator_disable (qproc); } +static int q6v5_clk_enable (struct device *dev,struct clk **clks, +int clk_count) +{ +int rc =0 ; +int i; + +for (i =0 ; i < clk_count; i++) { + rc =clk_prepare_enable (clks[i]); +if (rc) { +dev_err (dev,"Clock enable failed\n" ); + goto err; + } + } + +return 0 ; +err: +for (i--; i >=0 ; i--) +clk_disable_unprepare (clks[i]); + +return rc; +} + +static void q6v5_proxy_clk_disable (struct q6v5 *qproc) +{ +int i; +struct clk **clks = qproc->proxy_clks; + +for (i =0 ; i < qproc->proxy_clk_count; i++) +clk_disable_unprepare (clks[i]); +} + +static void q6v5_active_clk_disable (struct q6v5 *qproc) +{ +int i; +struct clk **clks = qproc->proxy_clks; + +for (i =0 ; i < qproc->proxy_clk_count; i++) +clk_disable_unprepare (clks[i]); +} + +static void q6v5_clk_disable (struct q6v5 *qproc) +{ +q6v5_proxy_clk_disable (qproc); +q6v5_active_clk_disable (qproc); +}static int q6v5_load (struct rproc *rproc,const struct firmware *fw) {
@@ -581,11 +622,18 @@ static int q6v5_start(struct rproc *rproc)return ret; } + ret =q6v5_clk_enable (qproc->dev, qproc->proxy_clks, + qproc->proxy_clk_count); +if (ret) { +dev_err (qproc->dev,"failed to enable proxy clocks\n" ); + goto disable_proxy_reg; + } + ret =q6v5_regulator_enable (qproc, qproc->active_regs, qproc->active_reg_count);if (ret) {dev_err (qproc->dev,"failed to enable supplies\n" ); - goto disable_proxy_reg; + goto disable_proxy_clk; } ret =reset_control_deassert (qproc->mss_restart);if (ret) {
@@ -593,17 +641,12 @@ static int q6v5_start(struct rproc *rproc) goto disable_vdd; } - ret =clk_prepare_enable (qproc->ahb_clk); -if (ret) + ret =q6v5_clk_enable (qproc->dev, qproc->active_clks, + qproc->active_clk_count); +if (ret) { +dev_err (qproc->dev,"failed to enable clocks\n" ); goto assert_reset; - - ret =clk_prepare_enable (qproc->axi_clk); -if (ret) - goto disable_ahb_clk; - - ret =clk_prepare_enable (qproc->rom_clk); -if (ret) - goto disable_axi_clk; + }writel (qproc->mba_phys, qproc->rmb_base +RMB_MBA_IMAGE_REG );
@@ -638,25 +681,21 @@ static int q6v5_start(struct rproc *rproc) qproc->running = true; -/* TODO: All done, release the handover resources */ - +q6v5_proxy_clk_disable (qproc); +q6v5_proxy_regulator_disable (qproc);return 0 ; halt_axi_ports:q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_q6);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); - -clk_disable_unprepare (qproc->rom_clk); -disable_axi_clk: -clk_disable_unprepare (qproc->axi_clk); -disable_ahb_clk: -clk_disable_unprepare (qproc->ahb_clk); +q6v5_active_clk_disable (qproc); assert_reset:reset_control_assert (qproc->mss_restart); disable_vdd: -q6v5_regulator_disable (qproc); - +q6v5_active_regulator_disable (qproc); +disable_proxy_clk: +q6v5_proxy_clk_disable (qproc); disable_proxy_reg:q6v5_proxy_regulator_disable (qproc);return ret;
@@ -684,9 +723,7 @@ static int q6v5_stop(struct rproc *rproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc);reset_control_assert (qproc->mss_restart); -clk_disable_unprepare (qproc->rom_clk); -clk_disable_unprepare (qproc->axi_clk); -clk_disable_unprepare (qproc->ahb_clk); +q6v5_clk_disable (qproc);q6v5_regulator_disable (qproc);return 0 ;
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 4/7] remoteproc: qcom: Modify clock enable and disable routine
Quoted 26 lines · Avaneesh Kumar Dwivedi
Clock handling is made generic than earlier way to add new clock every time when required to support new hexagon version. Also clock disable interface is separated out into two separate routine to unvote proxy clock alone when handover interrupt is arrived.
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 93 ++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 28 deletions(-)drivers/remoteproc/qcom_q6v5_pil.c +0
-4@@ -126,10 +126,6 @@ struct q6v5 {struct qcom_smem_state *state;unsigned stop_bit; - -struct clk *ahb_clk; -struct clk *axi_clk; -struct clk *rom_clk;struct clk *active_clks[8 ];struct clk *proxy_clks[4 ];struct reg_info active_regs[1 ];
drivers/remoteproc/qcom_q6v5_pil.c static void q6v5_regulator_disable(struct q6v5 *qproc) · line 286
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0@@ -284,6 +280,51 @@ static void q6v5_regulator_disable(struct q6v5 *qproc)q6v5_active_regulator_disable (qproc); } +static int q6v5_clk_enable (struct device *dev,struct clk **clks, +int clk_count) +{ +int rc =0 ;
No need to initialize to 0.
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_pil.c +9
-0+int i; + +for (i =0 ; i < clk_count; i++) { + rc =clk_prepare_enable (clks[i]); +if (rc) { +dev_err (dev,"Clock enable failed\n" ); + goto err; + } + }
drivers/remoteproc/qcom_q6v5_pil.c static void q6v5_regulator_disable(struct q6v5 *qproc) · line 305
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +10
-0+ +return 0 ; +err: +for (i--; i >=0 ; i--) +clk_disable_unprepare (clks[i]); + +return rc; +} + +static void q6v5_proxy_clk_disable (struct q6v5 *qproc)
Please make these follow the enable case, by taking the clock list and size as parameters.
Quoted 12 lines
drivers/remoteproc/qcom_q6v5_pil.c +12
-0+{ +int i; +struct clk **clks = qproc->proxy_clks; + +for (i =0 ; i < qproc->proxy_clk_count; i++) +clk_disable_unprepare (clks[i]); +} + +static void q6v5_active_clk_disable (struct q6v5 *qproc) +{ +int i; +struct clk **clks = qproc->proxy_clks;
drivers/remoteproc/qcom_q6v5_pil.c static void q6v5_regulator_disable(struct q6v5 *qproc) · line 327
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +10
-0+ +for (i =0 ; i < qproc->proxy_clk_count; i++) +clk_disable_unprepare (clks[i]); +} + +static void q6v5_clk_disable (struct q6v5 *qproc) +{ +q6v5_proxy_clk_disable (qproc); +q6v5_active_clk_disable (qproc); +}
Just inline the two disable calls where you need them, rather than having this wrapper.
Regards,
Bjorn
Re: [RESEND PATCH v4 4/7] remoteproc: qcom: Modify clock enable and disable routine
Quoted 31 lines · Bjorn Andersson
Quoted 29 lines · Avaneesh Kumar Dwivedi
Clock handling is made generic than earlier way to add new clock every time when required to support new hexagon version. Also clock disable interface is separated out into two separate routine to unvote proxy clock alone when handover interrupt is arrived.
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 93 ++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 28 deletions(-)drivers/remoteproc/qcom_q6v5_pil.c +0
-4@@ -126,10 +126,6 @@ struct q6v5 {struct qcom_smem_state *state;unsigned stop_bit; - -struct clk *ahb_clk; -struct clk *axi_clk; -struct clk *rom_clk;struct clk *active_clks[8 ];struct clk *proxy_clks[4 ];struct reg_info active_regs[1 ];@@ -284,6 +280,51 @@ static void q6v5_regulator_disable(struct q6v5 *qproc)q6v5_active_regulator_disable (qproc); }
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c static void q6v5_regulator_disable(struct q6v5 *qproc) · line 286
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+static int q6v5_clk_enable (struct device *dev,struct clk **clks, +int clk_count) +{ +int rc =0 ;No need to initialize to 0.
OK.
Quoted 14 lines
Quoted 14 lines
drivers/remoteproc/qcom_q6v5_pil.c +13
-0+int i; + +for (i =0 ; i < clk_count; i++) { + rc =clk_prepare_enable (clks[i]); +if (rc) { +dev_err (dev,"Clock enable failed\n" ); + goto err; + } + } + +return 0 ; +err: +for (i--; i >=0 ; i--)
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c static void q6v5_regulator_disable(struct q6v5 *qproc) · line 305
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +6
-0+clk_disable_unprepare (clks[i]); + +return rc; +} + +static void q6v5_proxy_clk_disable (struct q6v5 *qproc)Please make these follow the enable case, by taking the clock list and size as parameters.
OK.
Quoted 17 lines
Quoted 17 lines
drivers/remoteproc/qcom_q6v5_pil.c +16
-0+{ +int i; +struct clk **clks = qproc->proxy_clks; + +for (i =0 ; i < qproc->proxy_clk_count; i++) +clk_disable_unprepare (clks[i]); +} + +static void q6v5_active_clk_disable (struct q6v5 *qproc) +{ +int i; +struct clk **clks = qproc->proxy_clks; + +for (i =0 ; i < qproc->proxy_clk_count; i++) +clk_disable_unprepare (clks[i]); +}
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c static void q6v5_regulator_disable(struct q6v5 *qproc) · line 327
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +6
-0+ +static void q6v5_clk_disable (struct q6v5 *qproc) +{ +q6v5_proxy_clk_disable (qproc); +q6v5_active_clk_disable (qproc); +}Just inline the two disable calls where you need them, rather than having this wrapper.
OK.
Quoted 3 lines
Regards,
Bjorn
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH RESEND v4 5/7 remoteproc: qcom: Modify reset sequence for hexagon to support v56 1.5.0
In reply to Avaneesh Kumar DwivediThis change introduces appropriate additional steps in reset sequence so that hexagon v56 1.5.0 is brough out of reset.
--- drivers/remoteproc/qcom_q6v5_pil.c | 125 ++++++++++++++++++++++++++++++------- 1 file changed, 104 insertions(+), 21 deletions(-)
drivers/remoteproc/qcom_q6v5_pil.c +104 -21
@@ -65,6 +65,8 @@#define QDSP6SS_RESET_REG 0x014#define QDSP6SS_GFMUX_CTL_REG 0x020#define QDSP6SS_PWR_CTL_REG 0x030 +#define QDSP6SS_MEM_PWR_CTL 0x0B0 +#define QDSP6SS_STRAP_ACC 0x110/* AXI Halt Register Offsets */ #define AXI_HALTREQ_REG 0x0
@@ -93,6 +95,15 @@#define QDSS_BHS_ON BIT(21)#define QDSS_LDO_BYP BIT(22) +/* QDSP6v56 parameters */ +#define QDSP6v56_LDO_BYP BIT(25) +#define QDSP6v56_BHS_ON BIT(24) +#define QDSP6v56_CLAMP_WL BIT(21) +#define QDSP6v56_CLAMP_QMC_MEM BIT(22) +#define HALT_CHECK_MAX_LOOPS (200) +#define QDSP6SS_XO_CBCR (0x0038) +#define QDSP6SS_ACC_OVERRIDE_VAL 0x20 +struct rproc_hexagon_res {char *hexagon_mba_image;char **proxy_reg_string;
@@ -147,6 +158,8 @@ struct q6v5 {phys_addr_t mpss_reloc;void *mpss_region;size_t mpss_size; + +int hexagon_ver; };enum {
@@ -388,35 +401,103 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)static int q6v5proc_reset (struct q6v5 *qproc) { -u32 val; -int ret; +u64 val; +int ret, i, count; + +/* Override the ACC value if required */ +if (qproc->hexagon_ver &0x2 ) +writel_relaxed (QDSP6SS_ACC_OVERRIDE_VAL , + qproc->reg_base +QDSP6SS_STRAP_ACC );/* Assert resets, stop core */ val =readl (qproc->reg_base +QDSP6SS_RESET_REG ); val |= (Q6SS_CORE_ARES |Q6SS_BUS_ARES_ENABLE |Q6SS_STOP_CORE );writel (val, qproc->reg_base +QDSP6SS_RESET_REG ); +/* BHS require xo cbcr to be enabled */ +if (qproc->hexagon_ver &0x2 ) { + val =readl_relaxed (qproc->reg_base +QDSP6SS_XO_CBCR ); + val |=0x1 ; +writel_relaxed (val, qproc->reg_base +QDSP6SS_XO_CBCR ); +for (count =HALT_CHECK_MAX_LOOPS ; count >0 ; count--) { + val =readl_relaxed (qproc->reg_base +QDSP6SS_XO_CBCR ); +if (!(val &BIT (31 ))) +break ; +udelay (1 ); + } + + val =readl_relaxed (qproc->reg_base +QDSP6SS_XO_CBCR ); +if ((val &BIT (31 ))) +dev_err (qproc->dev,"Failed to enable xo branch clock.\n" ); + } + +if (qproc->hexagon_ver &0x2 ) {/* Enable power block headswitch, and wait for it to stabilize */ - val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=QDSS_BHS_ON |QDSS_LDO_BYP ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); -udelay (1 ); - -/* -* Turn on memories. L2 banks should be done individually -* to minimize inrush current. -*/ - val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_SLP_RET_N |Q6SS_L2TAG_SLP_NRET_N | -Q6SS_ETB_SLP_NRET_N |Q6SS_L2DATA_STBY_N ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_L2DATA_SLP_NRET_N_2 ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_L2DATA_SLP_NRET_N_1 ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_L2DATA_SLP_NRET_N_0 ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val =readl_relaxed (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |= QDSP6v56_BHS_ON; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); +udelay (1 ); +/* Put LDO in bypass mode */ + val |= QDSP6v56_LDO_BYP; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + + }else { +/* +* Enable power block headswitch, +* and wait for it to stabilize +*/ + val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=QDSS_BHS_ON |QDSS_LDO_BYP ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); +udelay (1 ); + } + +if (qproc->hexagon_ver &0x2 ) { +/* +* Deassert QDSP6 compiler memory clamp +*/ + val =readl_relaxed (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val &= ~QDSP6v56_CLAMP_QMC_MEM; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + +/* Deassert memory peripheral sleep and L2 memory standby */ + val |= (Q6SS_L2DATA_STBY_N |Q6SS_SLP_RET_N ); +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + +/* Turn on L1, L2, ETB and JU memories 1 at a time */ + val =readl_relaxed (qproc->reg_base +QDSP6SS_MEM_PWR_CTL ); +for (i =19 ; i >=0 ; i--) { + val |=BIT (i); +writel_relaxed (val, qproc->reg_base + +QDSP6SS_MEM_PWR_CTL ); +/* +* Wait for 1us for both memory peripheral and +* data array to turn on. +*/ +mb (); +udelay (1 ); + } +/* Remove word line clamp */ + val =readl_relaxed (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val &= ~QDSP6v56_CLAMP_WL; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + }else { +/* +* Turn on memories. L2 banks should be done individually +* to minimize inrush current. +*/ + val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_SLP_RET_N |Q6SS_L2TAG_SLP_NRET_N | +Q6SS_ETB_SLP_NRET_N |Q6SS_L2DATA_STBY_N ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_L2DATA_SLP_NRET_N_2 ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_L2DATA_SLP_NRET_N_1 ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_L2DATA_SLP_NRET_N_0 ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + }/* Remove IO clamp */ val &= ~Q6SS_CLAMP_IO ;writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG );
@@ -1031,6 +1112,8 @@ static int q6v5_probe(struct platform_device *pdev) } qproc->active_reg_count = count; + qproc->hexagon_ver = desc->hexagon_ver; + ret =q6v5_request_irq (qproc, pdev,"wdog" , q6v5_wdog_interrupt);if (ret <0 ) goto free_rproc;
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 5/7] remoteproc: qcom: Modify reset sequence for hexagon to support v56 1.5.0
Quoted 3 lines · Avaneesh Kumar Dwivedi
This change introduces appropriate additional steps in reset sequence so that hexagon v56 1.5.0 is brough out of reset.
You should use the non-_relaxed version throughout this patch, unless you have good reason not to.
Quoted 19 lines
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 125 ++++++++++++++++++++++++++++++------- 1 file changed, 104 insertions(+), 21 deletions(-)drivers/remoteproc/qcom_q6v5_pil.c +2
-0@@ -65,6 +65,8 @@#define QDSP6SS_RESET_REG 0x014#define QDSP6SS_GFMUX_CTL_REG 0x020#define QDSP6SS_PWR_CTL_REG 0x030 +#define QDSP6SS_MEM_PWR_CTL 0x0B0 +#define QDSP6SS_STRAP_ACC 0x110/* AXI Halt Register Offsets */ #define AXI_HALTREQ_REG 0x0
drivers/remoteproc/qcom_q6v5_pil.c line 104
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +7
-0@@ -93,6 +95,15 @@#define QDSS_BHS_ON BIT(21)#define QDSS_LDO_BYP BIT(22) +/* QDSP6v56 parameters */ +#define QDSP6v56_LDO_BYP BIT(25) +#define QDSP6v56_BHS_ON BIT(24) +#define QDSP6v56_CLAMP_WL BIT(21) +#define QDSP6v56_CLAMP_QMC_MEM BIT(22) +#define HALT_CHECK_MAX_LOOPS (200) +#define QDSP6SS_XO_CBCR (0x0038)
Please drop these parenthesis.
Quoted 15 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+#define QDSP6SS_ACC_OVERRIDE_VAL 0x20 +struct rproc_hexagon_res {char *hexagon_mba_image;char **proxy_reg_string;@@ -147,6 +158,8 @@ struct q6v5 {phys_addr_t mpss_reloc;void *mpss_region;size_t mpss_size; + +int hexagon_ver; };enum {
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 405
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-2@@ -388,35 +401,103 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)static int q6v5proc_reset (struct q6v5 *qproc) { -u32 val; -int ret; +u64 val; +int ret, i, count;
One variable per line, sorted descending by length, please.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 408
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ +/* Override the ACC value if required */ +if (qproc->hexagon_ver &0x2 )
This will break when we reach the 6th version, compare (==) with the related enum.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 417
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+writel_relaxed (QDSP6SS_ACC_OVERRIDE_VAL , + qproc->reg_base +QDSP6SS_STRAP_ACC );/* Assert resets, stop core */ val =readl (qproc->reg_base +QDSP6SS_RESET_REG ); val |= (Q6SS_CORE_ARES |Q6SS_BUS_ARES_ENABLE |Q6SS_STOP_CORE );writel (val, qproc->reg_base +QDSP6SS_RESET_REG ); +/* BHS require xo cbcr to be enabled */
This comment goes inside the if-statement.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 418
Quoted 1 line
drivers/remoteproc/qcom_q6v5_pil.c +1
-0+if (qproc->hexagon_ver &0x2 ) {
==
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 421
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ val =readl_relaxed (qproc->reg_base +QDSP6SS_XO_CBCR ); + val |=0x1 ; +writel_relaxed (val, qproc->reg_base +QDSP6SS_XO_CBCR );
Replace the rest of this block with:
ret = readl_poll_timeout(qproc->reg_base + QDSP6SS_XO_CBCR,
val, !(val & BIT(31)), 1, 200);
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 434
Quoted 13 lines
drivers/remoteproc/qcom_q6v5_pil.c +13
-0+for (count =HALT_CHECK_MAX_LOOPS ; count >0 ; count--) { + val =readl_relaxed (qproc->reg_base +QDSP6SS_XO_CBCR ); +if (!(val &BIT (31 ))) +break ; +udelay (1 ); + } + + val =readl_relaxed (qproc->reg_base +QDSP6SS_XO_CBCR ); +if ((val &BIT (31 ))) +dev_err (qproc->dev,"Failed to enable xo branch clock.\n" ); + } + +if (qproc->hexagon_ver &0x2 ) {
==
Quoted 11 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-10/* Enable power block headswitch, and wait for it to stabilize */ - val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=QDSS_BHS_ON |QDSS_LDO_BYP ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); -udelay (1 ); - -/* -* Turn on memories. L2 banks should be done individually -* to minimize inrush current. -*/ - val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG );
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 436
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-9- val |=Q6SS_SLP_RET_N |Q6SS_L2TAG_SLP_NRET_N | -Q6SS_ETB_SLP_NRET_N |Q6SS_L2DATA_STBY_N ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_L2DATA_SLP_NRET_N_2 ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_L2DATA_SLP_NRET_N_1 ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_L2DATA_SLP_NRET_N_0 ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val =readl_relaxed (qproc->reg_base +QDSP6SS_PWR_CTL_REG );
Use non-relaxed version of readl and writel, please.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 439
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ val |= QDSP6v56_BHS_ON; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); +udelay (1 );
Please add a short comment on why this delay is needed.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 444
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+/* Put LDO in bypass mode */ + val |= QDSP6v56_LDO_BYP; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); +
Remove empty line
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 456
Quoted 12 lines
drivers/remoteproc/qcom_q6v5_pil.c +12
-0+ }else { +/* +* Enable power block headswitch, +* and wait for it to stabilize +*/ + val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=QDSS_BHS_ON |QDSS_LDO_BYP ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); +udelay (1 ); + } + +if (qproc->hexagon_ver &0x2 ) {
Why do you have:
if (ver == 2) {
...
}if (ver == 2) {
...
} else {
...
}if (ver == 2) {
...
} else {
...
}As far as I can see you should be able to merge those into one if/else.
Quoted 12 lines
drivers/remoteproc/qcom_q6v5_pil.c +12
-0+/* +* Deassert QDSP6 compiler memory clamp +*/ + val =readl_relaxed (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val &= ~QDSP6v56_CLAMP_QMC_MEM; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + +/* Deassert memory peripheral sleep and L2 memory standby */ + val |= (Q6SS_L2DATA_STBY_N |Q6SS_SLP_RET_N ); +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + +/* Turn on L1, L2, ETB and JU memories 1 at a time */
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 478
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +10
-0+ val =readl_relaxed (qproc->reg_base +QDSP6SS_MEM_PWR_CTL ); +for (i =19 ; i >=0 ; i--) { + val |=BIT (i); +writel_relaxed (val, qproc->reg_base + +QDSP6SS_MEM_PWR_CTL ); +/* +* Wait for 1us for both memory peripheral and +* data array to turn on. +*/ +mb ();
mb() ensures that your writes are ordered, it does not ensure that the write is done before the sleep. What is the actual requirement here?
Quoted 15 lines
drivers/remoteproc/qcom_q6v5_pil.c +15
-0+udelay (1 ); + } +/* Remove word line clamp */ + val =readl_relaxed (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val &= ~QDSP6v56_CLAMP_WL; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + }else { +/* +* Turn on memories. L2 banks should be done individually +* to minimize inrush current. +*/ + val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_SLP_RET_N |Q6SS_L2TAG_SLP_NRET_N | +Q6SS_ETB_SLP_NRET_N |Q6SS_L2DATA_STBY_N ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG );
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 503
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +7
-0+ val |=Q6SS_L2DATA_SLP_NRET_N_2 ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_L2DATA_SLP_NRET_N_1 ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_L2DATA_SLP_NRET_N_0 ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + }/* Remove IO clamp */ val &= ~Q6SS_CLAMP_IO ;writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG );
Regards,
Bjorn
Re: [RESEND PATCH v4 5/7] remoteproc: qcom: Modify reset sequence for hexagon to support v56 1.5.0
Quoted 7 lines · Bjorn Andersson
Quoted 3 lines · Avaneesh Kumar Dwivedi
This change introduces appropriate additional steps in reset sequence so that hexagon v56 1.5.0 is brough out of reset.
You should use the non-_relaxed version throughout this patch, unless you have good reason not to.
OK.
Quoted 23 lines
Quoted 23 lines
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 125 ++++++++++++++++++++++++++++++------- 1 file changed, 104 insertions(+), 21 deletions(-)drivers/remoteproc/qcom_q6v5_pil.c +2
-0@@ -65,6 +65,8 @@#define QDSP6SS_RESET_REG 0x014#define QDSP6SS_GFMUX_CTL_REG 0x020#define QDSP6SS_PWR_CTL_REG 0x030 +#define QDSP6SS_MEM_PWR_CTL 0x0B0 +#define QDSP6SS_STRAP_ACC 0x110/* AXI Halt Register Offsets */ #define AXI_HALTREQ_REG 0x0@@ -93,6 +95,15 @@#define QDSS_BHS_ON BIT(21)#define QDSS_LDO_BYP BIT(22)
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c line 104
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c +7
-0+/* QDSP6v56 parameters */ +#define QDSP6v56_LDO_BYP BIT(25) +#define QDSP6v56_BHS_ON BIT(24) +#define QDSP6v56_CLAMP_WL BIT(21) +#define QDSP6v56_CLAMP_QMC_MEM BIT(22) +#define HALT_CHECK_MAX_LOOPS (200) +#define QDSP6SS_XO_CBCR (0x0038)Please drop these parenthesis.
OK.
Quoted 17 lines
Quoted 17 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+#define QDSP6SS_ACC_OVERRIDE_VAL 0x20 +struct rproc_hexagon_res {char *hexagon_mba_image;char **proxy_reg_string;@@ -147,6 +158,8 @@ struct q6v5 {phys_addr_t mpss_reloc;void *mpss_region;size_t mpss_size; + +int hexagon_ver; };enum {@@ -388,35 +401,103 @@ static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms)
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 405
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-2static int q6v5proc_reset (struct q6v5 *qproc) { -u32 val; -int ret; +u64 val; +int ret, i, count;One variable per line, sorted descending by length, please.
OK.
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 408
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ +/* Override the ACC value if required */ +if (qproc->hexagon_ver &0x2 )This will break when we reach the 6th version, compare (==) with the related enum.
OK.
Quoted 11 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 417
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+writel_relaxed (QDSP6SS_ACC_OVERRIDE_VAL , + qproc->reg_base +QDSP6SS_STRAP_ACC );/* Assert resets, stop core */ val =readl (qproc->reg_base +QDSP6SS_RESET_REG ); val |= (Q6SS_CORE_ARES |Q6SS_BUS_ARES_ENABLE |Q6SS_STOP_CORE );writel (val, qproc->reg_base +QDSP6SS_RESET_REG ); +/* BHS require xo cbcr to be enabled */ This comment goes inside the if-statement.
OK.
Quoted 11 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 418
Quoted 2 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-0+if (qproc->hexagon_ver &0x2 ) {==
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 421
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ val =readl_relaxed (qproc->reg_base +QDSP6SS_XO_CBCR ); + val |=0x1 ; +writel_relaxed (val, qproc->reg_base +QDSP6SS_XO_CBCR );Replace the rest of this block with:
ret = readl_poll_timeout(qproc->reg_base +
QDSP6SS_XO_CBCR,val, !(val & BIT(31)), 1, 200);
OK.
Quoted 30 lines
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+for (count =HALT_CHECK_MAX_LOOPS ; count >0 ; count--) { + val =readl_relaxed (qproc->reg_base +QDSP6SS_XO_CBCR ); +if (!(val &BIT (31 )))drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 434
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +10
-0+break ; +udelay (1 ); + } + + val =readl_relaxed (qproc->reg_base +QDSP6SS_XO_CBCR ); +if ((val &BIT (31 ))) +dev_err (qproc->dev,"Failed to enable xo branch clock.\n" ); + } + +if (qproc->hexagon_ver &0x2 ) {==
Quoted 14 lines
drivers/remoteproc/qcom_q6v5_pil.c +0
-13/* Enable power block headswitch, and wait for it to stabilize */ - val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=QDSS_BHS_ON |QDSS_LDO_BYP ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); -udelay (1 ); - -/* -* Turn on memories. L2 banks should be done individually -* to minimize inrush current. -*/ - val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_SLP_RET_N |Q6SS_L2TAG_SLP_NRET_N | -Q6SS_ETB_SLP_NRET_N |Q6SS_L2DATA_STBY_N ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG );
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 436
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-6- val |=Q6SS_L2DATA_SLP_NRET_N_2 ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_L2DATA_SLP_NRET_N_1 ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); - val |=Q6SS_L2DATA_SLP_NRET_N_0 ; -writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val =readl_relaxed (qproc->reg_base +QDSP6SS_PWR_CTL_REG );Use non-relaxed version of readl and writel, please.
OK.
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 439
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+ val |= QDSP6v56_BHS_ON; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); +udelay (1 );Please add a short comment on why this delay is needed.
I think there is a comment that
/* Enable power block headswitch, and wait for it to stabilize */
so block head switch need stabilization after enabling so 1 us delay, before LDO being put in bypass mode.
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 444
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+/* Put LDO in bypass mode */ + val |= QDSP6v56_LDO_BYP; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); +Remove empty line
ok.
Quoted 25 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 456
Quoted 13 lines
drivers/remoteproc/qcom_q6v5_pil.c +12
-0+ }else { +/* +* Enable power block headswitch, +* and wait for it to stabilize +*/ + val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=QDSS_BHS_ON |QDSS_LDO_BYP ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); +udelay (1 ); + } + +if (qproc->hexagon_ver &0x2 ) {Why do you have:
if (ver == 2) { ... }if (ver == 2) { ... } else { ... }
Quoted 7 lines
if (ver == 2) { ... } else { ... }As far as I can see you should be able to merge those into one if/else.
wanted to utilize little piece of common code so put different if block. OK will combine them.
Quoted 17 lines
Quoted 17 lines
drivers/remoteproc/qcom_q6v5_pil.c +16
-0+/* +* Deassert QDSP6 compiler memory clamp +*/ + val =readl_relaxed (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val &= ~QDSP6v56_CLAMP_QMC_MEM; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + +/* Deassert memory peripheral sleep and L2 memory standby */ + val |= (Q6SS_L2DATA_STBY_N |Q6SS_SLP_RET_N ); +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + +/* Turn on L1, L2, ETB and JU memories 1 at a time */ + val =readl_relaxed (qproc->reg_base +QDSP6SS_MEM_PWR_CTL ); +for (i =19 ; i >=0 ; i--) { + val |=BIT (i); + writel_relaxed(val, qproc->reg_base +
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 478
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +6
-0+ QDSP6SS_MEM_PWR_CTL); +/* +* Wait for 1us for both memory peripheral and +* data array to turn on. +*/ +mb ();
mb()ensures that your writes are ordered, it does not ensure that the write is done before the sleep. What is the actual requirement here?
As in comment, order of turning need to be serialized so this memory barrier. Do u think its not required?
Quoted 27 lines
Quoted 15 lines
drivers/remoteproc/qcom_q6v5_pil.c +15
-0+udelay (1 ); + } +/* Remove word line clamp */ + val =readl_relaxed (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val &= ~QDSP6v56_CLAMP_WL; +writel_relaxed (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + }else { +/* +* Turn on memories. L2 banks should be done individually +* to minimize inrush current. +*/ + val =readl (qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_SLP_RET_N |Q6SS_L2TAG_SLP_NRET_N | +Q6SS_ETB_SLP_NRET_N |Q6SS_L2DATA_STBY_N ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG );drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 503
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +7
-0+ val |=Q6SS_L2DATA_SLP_NRET_N_2 ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_L2DATA_SLP_NRET_N_1 ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |=Q6SS_L2DATA_SLP_NRET_N_0 ; +writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + }/* Remove IO clamp */ val &= ~Q6SS_CLAMP_IO ;writel (val, qproc->reg_base +QDSP6SS_PWR_CTL_REG );Regards,
Bjorn
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 5/7] remoteproc: qcom: Modify reset sequence for hexagon to support v56 1.5.0
Quoted 2 lines · Avaneesh Kumar (avani)
Quoted 1 line · Bjorn Andersson
On Thu 24 Nov 02:00 PST 2016, Avaneesh Kumar Dwivedi wrote:
[..]
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +6
-0+ +/* Turn on L1, L2, ETB and JU memories 1 at a time */ + val =readl_relaxed (qproc->reg_base +QDSP6SS_MEM_PWR_CTL ); +for (i =19 ; i >=0 ; i--) { + val |=BIT (i); + writel_relaxed(val, qproc->reg_base +Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 478
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +6
-0+ QDSP6SS_MEM_PWR_CTL); +/* +* Wait for 1us for both memory peripheral and +* data array to turn on. +*/ +mb ();
mb()ensures that your writes are ordered, it does not ensure that the write is done before the sleep. What is the actual requirement here?
Quoted 3 lines
As in comment, order of turning need to be serialized so this memory barrier.
Do u think its not required?
The problem is that mb() don't actually wait for the write to finish, it simply makes sure that any subsequent writes will come after this one.
If we want to make sure the write actually hits the hardware before the delay we should read the register back after the write - as that would stall execution until the write is available.
Either way, using the non-_relaxed version of writel() will be equivalent to what you have now.
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ udelay(1); + }
Regards,
Bjorn
Re: [RESEND PATCH v4 5/7] remoteproc: qcom: Modify reset sequence for hexagon to support v56 1.5.0
Quoted 18 lines · Bjorn Andersson
Quoted 2 lines · Avaneesh Kumar (avani)
Quoted 1 line · Bjorn Andersson
On Thu 24 Nov 02:00 PST 2016, Avaneesh Kumar Dwivedi wrote:
[..]
Quoted 14 lines
Quoted 14 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_rmb_mba_wait(struct q6v5 *qproc, u32 status, int ms) · line 478
Quoted 12 lines
drivers/remoteproc/qcom_q6v5_pil.c +12
-0+ +/* Turn on L1, L2, ETB and JU memories 1 at a time */ + val =readl_relaxed (qproc->reg_base +QDSP6SS_MEM_PWR_CTL ); +for (i =19 ; i >=0 ; i--) { + val |=BIT (i); +writel_relaxed (val, qproc->reg_base + +QDSP6SS_MEM_PWR_CTL ); +/* +* Wait for 1us for both memory peripheral and +* data array to turn on. +*/ +mb ();
mb()ensures that your writes are ordered, it does not ensure that the write is done before the sleep. What is the actual requirement here?
Quoted 5 lines
Quoted 3 lines
As in comment, order of turning need to be serialized so this memory barrier.
Do u think its not required?The problem is that
mb()don't actually wait for the write to finish, it simply makes sure that any subsequent writes will come after this one.
mb() is for below comment
/* Turn on L1, L2, ETB and JU memories 1 at a time */
While delay corresponding to
/*
+ * Wait for 1us for both memory peripheral and
+ * data array to turn on.
+ */
Quoted 7 lines
If we want to make sure the write actually hits the hardware before the delay we should read the register back after the write - as that would stall execution until the write is available.
Either way, using the non-_relaxed version of
writel()will be equivalent to what you have now.
Do you mean if writel is used , udelay() should be removed? i understand writel will not return before register write operation is actually done. udelay() is to give enough time so that after writel , there is some time available to turn on mem peripheral and data array.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ udelay(1); + }Regards,
Bjorn
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 5/7] remoteproc: qcom: Modify reset sequence for hexagon to support v56 1.5.0
Quoted 1 line · Avaneesh Kumar (avani)
On 12/13/2016 11:39 PM, Bjorn Andersson wrote:
[..]
Quoted 3 lines
Quoted 2 lines
Either way, using the non-_relaxed version of
writel()will be equivalent to what you have now.Do you mean if writel is used ,
udelay()should be removed?
No, I mean that looping writel_relaxed() + wmb() is roughly equivalent to writel(). So with the overall comment of you replacing readl_relaxed() and writel_relaxed() with their plain readl/writel counterparts takes care of the wmb().
Quoted 4 lines
i understand
writel will not return before register write operation is actually done.udelay()is to give enough time so that after writel , there is some time available to turn on mem peripheral and data array.
As far as I understand, wmb() will ensure that any cache coherent or write-back buffered writes are committed before any subsequent writes. But that this is not the same as the write has finished.
As far as I can see, the downstream code (msm-3.18) do:
for (i = 19; i >= 0; i--) {
val |= BIT(i);
writel_relaxed(val, MEM_PWR_CTL);
val |= readl_relaxed(MEM_PWR_CTL);
udelay(1);
}I.e. for this particular version it actually does read back the value, which will cause a wait for the write to be propagated. But I'm not sure why this is the only version doing this.
Regards,
Bjorn
Re: [RESEND PATCH v4 5/7] remoteproc: qcom: Modify reset sequence for hexagon to support v56 1.5.0
Quoted 10 lines · Bjorn Andersson
Quoted 1 line · Avaneesh Kumar (avani)
On 12/13/2016 11:39 PM, Bjorn Andersson wrote:
[..]
Quoted 3 lines
Quoted 2 lines
Either way, using the non-_relaxed version of
writel()will be equivalent to what you have now.Do you mean if writel is used ,
udelay()should be removed?No, I mean that looping
writel_relaxed()+wmb()is roughly equivalent towritel(). So with the overall comment of you replacingreadl_relaxed()andwritel_relaxed()with their plain readl/writel counterparts takes care of thewmb().
Thanks got it, yes my requirement was to get write done before control reaches udelay(), so i will add readl() before udelay and remove mb() I hope after this change i can submit next set of patches?
Quoted 24 lines
Quoted 5 lines
i understand
writel will not return before register write operation is actually done.udelay()is to give enough time so that after writel , there is some time available to turn on mem peripheral and data array.As far as I understand,
wmb()will ensure that any cache coherent or write-back buffered writes are committed before any subsequent writes. But that this is not the same as the write has finished.As far as I can see, the downstream code (msm-3.18) do:
for (i = 19; i >= 0; i--) { val |= BIT(i); writel_relaxed(val, MEM_PWR_CTL); val |= readl_relaxed(MEM_PWR_CTL); udelay(1); }I.e. for this particular version it actually does read back the value, which will cause a wait for the write to be propagated. But I'm not sure why this is the only version doing this.
Regards,
Bjorn
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 5/7] remoteproc: qcom: Modify reset sequence for hexagon to support v56 1.5.0
Quoted 8 lines · Avaneesh Kumar (avani)
Quoted 5 lines · Bjorn Andersson
Quoted 1 line · Avaneesh Kumar (avani)
On 12/13/2016 11:39 PM, Bjorn Andersson wrote:
[..]
Quoted 2 lines
Quoted 2 lines
Either way, using the non-_relaxed version of
writel()will be equivalent to what you have now.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Do you mean if writel is used ,
udelay()should be removed?No, I mean that looping
writel_relaxed()+wmb()is roughly equivalent towritel(). So with the overall comment of you replacingreadl_relaxed()andwritel_relaxed()with their plain readl/writel counterparts takes care of thewmb().Thanks got it, yes my requirement was to get write done before control reaches
udelay(), so i will addreadl()before udelay and removemb()
Sounds good.
Quoted 1 line
I hope after this change i can submit next set of patches?
Yes, please do.
Regards,
Bjorn
PATCH RESEND v4 6/7 remoteproc: qcom: Modify stop routine to limit MX current for v56 1.5
In reply to Avaneesh Kumar DwivediFor v56 1.5.0 Mx current need to be limited during restart.
--- drivers/remoteproc/qcom_q6v5_pil.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/remoteproc/qcom_q6v5_pil.c +17 -1
@@ -785,7 +785,7 @@ static int q6v5_start(struct rproc *rproc)static int q6v5_stop (struct rproc *rproc) {struct q6v5 *qproc = (struct q6v5 *)rproc->priv; -int ret; +int ret, val; qproc->running = false;
@@ -803,6 +803,22 @@ static int q6v5_stop(struct rproc *rproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); +if (qproc->hexagon_ver &0x2 ) { +/* +* Assert QDSP6 I/O clamp, memory wordline clamp, and compiler +* memory clamp as a software workaround to avoid high MX +* current during LPASS/MSS restart. +*/ + ret =clk_prepare_enable (devm_clk_get (qproc->dev,"iface" )); +if (!ret) { + val =readl_relaxed ( + qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + val |= (Q6SS_CLAMP_IO | QDSP6v56_CLAMP_WL | + QDSP6v56_CLAMP_QMC_MEM); +writel_relaxed (val, + qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + } + }reset_control_assert (qproc->mss_restart);q6v5_clk_disable (qproc);q6v5_regulator_disable (qproc);
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 6/7] remoteproc: qcom: Modify stop routine to limit MX current for v56 1.5
Quoted 12 lines · Avaneesh Kumar Dwivedi
For v56 1.5.0 Mx current need to be limited during restart.
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)drivers/remoteproc/qcom_q6v5_pil.c +0
-0
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 788
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-1@@ -785,7 +785,7 @@ static int q6v5_start(struct rproc *rproc)static int q6v5_stop (struct rproc *rproc) {struct q6v5 *qproc = (struct q6v5 *)rproc->priv; -int ret; +int ret, val;
One variable per line, please.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 806
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-0qproc->running = false;@@ -803,6 +803,22 @@ static int q6v5_stop(struct rproc *rproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); +if (qproc->hexagon_ver &0x2 ) {
Compare with == and use the enum.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 811
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c +5
-0+/* +* Assert QDSP6 I/O clamp, memory wordline clamp, and compiler +* memory clamp as a software workaround to avoid high MX +* current during LPASS/MSS restart. +*/
I'm not sure if you answered this (or if I forgot to ask), is this something we only want to do on the latest version?
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 812
Quoted 1 line
drivers/remoteproc/qcom_q6v5_pil.c +1
-0+ ret =clk_prepare_enable (devm_clk_get (qproc->dev,"iface" ));
"iface" is part of your active set, so it should still be enabled.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 815
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+if (!ret) { + val =readl_relaxed ( + qproc->reg_base +QDSP6SS_PWR_CTL_REG );
Please use non-_relaxed versions.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 817
Quoted 2 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-0+ val |= (Q6SS_CLAMP_IO | QDSP6v56_CLAMP_WL | + QDSP6v56_CLAMP_QMC_MEM);
No need for the parenthesis around this expression.
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 821
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+writel_relaxed (val, + qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + } + }
Regards,
Bjorn
Re: [RESEND PATCH v4 6/7] remoteproc: qcom: Modify stop routine to limit MX current for v56 1.5
Quoted 9 lines · Bjorn Andersson
Quoted 7 lines · Avaneesh Kumar Dwivedi
For v56 1.5.0 Mx current need to be limited during restart.
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>--- drivers/remoteproc/qcom_q6v5_pil.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
Quoted 11 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_start(struct rproc *rproc) · line 788
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-1@@ -785,7 +785,7 @@ static int q6v5_start(struct rproc *rproc)static int q6v5_stop (struct rproc *rproc) {struct q6v5 *qproc = (struct q6v5 *)rproc->priv; -int ret; +int ret, val;One variable per line, please.
OK,
Quoted 10 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 806
Quoted 9 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-0qproc->running = false;@@ -803,6 +803,22 @@ static int q6v5_stop(struct rproc *rproc)q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_modem);q6v5proc_halt_axi_port (qproc, qproc->halt_map, qproc->halt_nc); +if (qproc->hexagon_ver &0x2 ) {Compare with == and use the enum.
Ok,
Quoted 8 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 811
Quoted 6 lines
drivers/remoteproc/qcom_q6v5_pil.c +5
-0+/* +* Assert QDSP6 I/O clamp, memory wordline clamp, and compiler +* memory clamp as a software workaround to avoid high MX +* current during LPASS/MSS restart. +*/ I'm not sure if you answered this (or if I forgot to ask), is this something we only want to do on the latest version?
Yes applicable only to hexagon on msm8996.
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 812
Quoted 2 lines
drivers/remoteproc/qcom_q6v5_pil.c +1
-0+ ret =clk_prepare_enable (devm_clk_get (qproc->dev,"iface" ));"iface" is part of your active set, so it should still be enabled.
Right, thanks for pointing this out.
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 815
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c +3
-0+if (!ret) { + val =readl_relaxed ( + qproc->reg_base +QDSP6SS_PWR_CTL_REG );Please use non-_relaxed versions.
OK.
Quoted 4 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 817
Quoted 3 lines
drivers/remoteproc/qcom_q6v5_pil.c +2
-0+ val |= (Q6SS_CLAMP_IO | QDSP6v56_CLAMP_WL | + QDSP6v56_CLAMP_QMC_MEM);No need for the parenthesis around this expression.
OK.
Quoted 7 lines
drivers/remoteproc/qcom_q6v5_pil.c static int q6v5_stop(struct rproc *rproc) · line 821
Quoted 5 lines
drivers/remoteproc/qcom_q6v5_pil.c +4
-0+writel_relaxed (val, + qproc->reg_base +QDSP6SS_PWR_CTL_REG ); + } + }Regards,
Bjorn
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH RESEND v4 7/7 clk: qcom: Add GCC_MSS_RESET support to reset MSS in v56 1.5.0
In reply to Avaneesh Kumar DwivediAdd support to use reset control framework for resetting MSS on v56 1.5.0.
--- drivers/clk/qcom/gcc-msm8996.c | 1 + include/dt-bindings/clock/qcom,gcc-msm8996.h | 1 + 2 files changed, 2 insertions(+)
drivers/clk/qcom/gcc-msm8996.c +1 -0
@@ -3423,6 +3423,7 @@ enum { [GCC_MSMPU_BCR] = { 0x8d000 }, [GCC_MSS_Q6_BCR] = { 0x8e000 }, [GCC_QREFS_VBG_CAL_BCR] = { 0x88020 }, + [GCC_MSS_RESTART] = { 0x8f008 }, };static const struct regmap_config gcc_msm8996_regmap_config = {
include/dt-bindings/clock/qcom,gcc-msm8996.h +1 -0
@@ -339,6 +339,7 @@#define GCC_PCIE_PHY_COM_NOCSR_BCR 102#define GCC_USB3_PHY_BCR 103#define GCC_USB3PHY_PHY_BCR 104 +#define GCC_MSS_RESTART 105/* Indexes for GDSCs */
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 7/7] clk: qcom: Add GCC_MSS_RESET support to reset MSS in v56 1.5.0
Quoted 4 lines · Avaneesh Kumar Dwivedi
Add support to use reset control framework for resetting MSS on v56 1.5.0.
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>
You should try (really hard) to limit your subject line to 50 characters and then use the body to describe your change - rather than just typing the same thing twice. E.g. a subject of "clk: gcc-msm8996: Add MSS_RESET" is short and to the point.
Please update the subject and add:
Regards,
Bjorn
Quoted 33 lines
--- drivers/clk/qcom/gcc-msm8996.c | 1 + include/dt-bindings/clock/qcom,gcc-msm8996.h | 1 + 2 files changed, 2 insertions(+)drivers/clk/qcom/gcc-msm8996.c +1
-0@@ -3423,6 +3423,7 @@ enum { [GCC_MSMPU_BCR] = { 0x8d000 }, [GCC_MSS_Q6_BCR] = { 0x8e000 }, [GCC_QREFS_VBG_CAL_BCR] = { 0x88020 }, + [GCC_MSS_RESTART] = { 0x8f008 }, };static const struct regmap_config gcc_msm8996_regmap_config = {include/dt-bindings/clock/qcom,gcc-msm8996.h +1
-0@@ -339,6 +339,7 @@#define GCC_PCIE_PHY_COM_NOCSR_BCR 102#define GCC_USB3_PHY_BCR 103#define GCC_USB3PHY_PHY_BCR 104 +#define GCC_MSS_RESTART 105/* Indexes for GDSCs */ Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [RESEND PATCH v4 7/7] clk: qcom: Add GCC_MSS_RESET support to reset MSS in v56 1.5.0
Quoted 10 lines · Bjorn Andersson
Quoted 4 lines · Avaneesh Kumar Dwivedi
Add support to use reset control framework for resetting MSS on v56 1.5.0.
Signed-off-by Avaneesh Kumar Dwivedi <[email protected]>You should try (really hard) to limit your subject line to 50 characters and then use the body to describe your change - rather than just typing the same thing twice. E.g. a subject of "clk: gcc-msm8996: Add
MSS_RESET" is short and to the point.
Ok, Sure :(
Quoted 41 lines
Please update the subject and add:
Reviewed-by Bjorn Andersson <[email protected]>Regards,
BjornQuoted 33 lines
--- drivers/clk/qcom/gcc-msm8996.c | 1 + include/dt-bindings/clock/qcom,gcc-msm8996.h | 1 + 2 files changed, 2 insertions(+)drivers/clk/qcom/gcc-msm8996.c +1
-0@@ -3423,6 +3423,7 @@ enum { [GCC_MSMPU_BCR] = { 0x8d000 }, [GCC_MSS_Q6_BCR] = { 0x8e000 }, [GCC_QREFS_VBG_CAL_BCR] = { 0x88020 }, + [GCC_MSS_RESTART] = { 0x8f008 }, };static const struct regmap_config gcc_msm8996_regmap_config = {include/dt-bindings/clock/qcom,gcc-msm8996.h +1
-0@@ -339,6 +339,7 @@#define GCC_PCIE_PHY_COM_NOCSR_BCR 102#define GCC_USB3_PHY_BCR 103#define GCC_USB3PHY_PHY_BCR 104 +#define GCC_MSS_RESTART 105/* Indexes for GDSCs */ Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.