LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT
@ 2018-05-07 23:53 Bjorn Andersson
2018-05-14 14:45 ` Amit Kucheria
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Bjorn Andersson @ 2018-05-07 23:53 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin, Rob Herring, Mark Rutland, Rajendra Nayak
Cc: linux-pm, devicetree, linux-kernel, linux-arm-msm
For platforms that has multiple copies of the TSENS hardware block it's
necessary to be able to specify the number of sensors per block in DeviceTree.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
.../devicetree/bindings/thermal/qcom-tsens.txt | 1 +
drivers/thermal/qcom/tsens.c | 12 +++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
index 292ed89d900b..06195e8f35e2 100644
--- a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
+++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
@@ -8,6 +8,7 @@ Required properties:
- reg: Address range of the thermal registers
- #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
+- #qcom,sensors: Number of sensors in tsens block
- Refer to Documentation/devicetree/bindings/nvmem/nvmem.txt to know how to specify
nvmem cells
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 3f9fe6aa51cc..20f3b87d7667 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -116,6 +116,7 @@ static int tsens_probe(struct platform_device *pdev)
struct tsens_device *tmdev;
const struct tsens_data *data;
const struct of_device_id *id;
+ u32 num_sensors;
if (pdev->dev.of_node)
dev = &pdev->dev;
@@ -130,18 +131,23 @@ static int tsens_probe(struct platform_device *pdev)
else
data = &data_8960;
- if (data->num_sensors <= 0) {
+ num_sensors = data->num_sensors;
+
+ if (np)
+ of_property_read_u32(np, "#qcom,sensors", &num_sensors);
+
+ if (num_sensors <= 0) {
dev_err(dev, "invalid number of sensors\n");
return -EINVAL;
}
tmdev = devm_kzalloc(dev, sizeof(*tmdev) +
- data->num_sensors * sizeof(*s), GFP_KERNEL);
+ num_sensors * sizeof(*s), GFP_KERNEL);
if (!tmdev)
return -ENOMEM;
tmdev->dev = dev;
- tmdev->num_sensors = data->num_sensors;
+ tmdev->num_sensors = num_sensors;
tmdev->ops = data->ops;
for (i = 0; i < tmdev->num_sensors; i++) {
if (data->hw_ids)
--
2.17.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT
2018-05-07 23:53 [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT Bjorn Andersson
@ 2018-05-14 14:45 ` Amit Kucheria
2018-05-14 17:46 ` Bjorn Andersson
2018-05-15 6:57 ` Amit Kucheria
2018-05-22 20:14 ` Rob Herring
2 siblings, 1 reply; 5+ messages in thread
From: Amit Kucheria @ 2018-05-14 14:45 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Zhang Rui, Eduardo Valentin, Rob Herring, Mark Rutland,
Rajendra Nayak, Linux PM list, devicetree, LKML, linux-arm-msm
On Tue, May 8, 2018 at 2:53 AM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> For platforms that has multiple copies of the TSENS hardware block it's
> necessary to be able to specify the number of sensors per block in DeviceTree.
I assume you want to replace the hardcoded num_sensors values in the
tsens-xxxx.c files with values in device tree atleast on platforms
that use devicetree?
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
> .../devicetree/bindings/thermal/qcom-tsens.txt | 1 +
> drivers/thermal/qcom/tsens.c | 12 +++++++++---
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
> index 292ed89d900b..06195e8f35e2 100644
> --- a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
> +++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
> @@ -8,6 +8,7 @@ Required properties:
>
> - reg: Address range of the thermal registers
> - #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
> +- #qcom,sensors: Number of sensors in tsens block
> - Refer to Documentation/devicetree/bindings/nvmem/nvmem.txt to know how to specify
> nvmem cells
>
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 3f9fe6aa51cc..20f3b87d7667 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -116,6 +116,7 @@ static int tsens_probe(struct platform_device *pdev)
> struct tsens_device *tmdev;
> const struct tsens_data *data;
> const struct of_device_id *id;
> + u32 num_sensors;
>
> if (pdev->dev.of_node)
> dev = &pdev->dev;
> @@ -130,18 +131,23 @@ static int tsens_probe(struct platform_device *pdev)
> else
> data = &data_8960;
>
> - if (data->num_sensors <= 0) {
> + num_sensors = data->num_sensors;
> +
> + if (np)
> + of_property_read_u32(np, "#qcom,sensors", &num_sensors);
> +
> + if (num_sensors <= 0) {
> dev_err(dev, "invalid number of sensors\n");
> return -EINVAL;
> }
>
> tmdev = devm_kzalloc(dev, sizeof(*tmdev) +
> - data->num_sensors * sizeof(*s), GFP_KERNEL);
> + num_sensors * sizeof(*s), GFP_KERNEL);
> if (!tmdev)
> return -ENOMEM;
>
> tmdev->dev = dev;
> - tmdev->num_sensors = data->num_sensors;
> + tmdev->num_sensors = num_sensors;
> tmdev->ops = data->ops;
> for (i = 0; i < tmdev->num_sensors; i++) {
> if (data->hw_ids)
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT
2018-05-14 14:45 ` Amit Kucheria
@ 2018-05-14 17:46 ` Bjorn Andersson
0 siblings, 0 replies; 5+ messages in thread
From: Bjorn Andersson @ 2018-05-14 17:46 UTC (permalink / raw)
To: Amit Kucheria
Cc: Zhang Rui, Eduardo Valentin, Rob Herring, Mark Rutland,
Rajendra Nayak, Linux PM list, devicetree, LKML, linux-arm-msm
On Mon 14 May 07:45 PDT 2018, Amit Kucheria wrote:
> On Tue, May 8, 2018 at 2:53 AM, Bjorn Andersson
> <bjorn.andersson@linaro.org> wrote:
> > For platforms that has multiple copies of the TSENS hardware block it's
> > necessary to be able to specify the number of sensors per block in DeviceTree.
>
> I assume you want to replace the hardcoded num_sensors values in the
> tsens-xxxx.c files with values in device tree atleast on platforms
> that use devicetree?
>
Right, e.g. in msm8998 we have two blocks with 12 and 8 sensors
respectively. With the patch we will overwrite the num_sensors with a
value from DT, iff specified.
As probe will fail if num_sensors is 0 we can reuse ops_8996 and just
not provide num_sensors for 8998, hence requiring it to be specified in
DT.
PS. Looking at the register spec 8996 too seems to have two tsens
blocks, so in order to access sensors off the second bank this patch
would be needed (and would work and be backwards compatible).
Regards,
Bjorn
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT
2018-05-07 23:53 [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT Bjorn Andersson
2018-05-14 14:45 ` Amit Kucheria
@ 2018-05-15 6:57 ` Amit Kucheria
2018-05-22 20:14 ` Rob Herring
2 siblings, 0 replies; 5+ messages in thread
From: Amit Kucheria @ 2018-05-15 6:57 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Zhang Rui, Eduardo Valentin, Rob Herring, Mark Rutland,
Rajendra Nayak, Linux PM list, devicetree, LKML, linux-arm-msm
On Tue, May 8, 2018 at 2:53 AM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> For platforms that has multiple copies of the TSENS hardware block it's
> necessary to be able to specify the number of sensors per block in DeviceTree.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Just one comment below, otherwise,
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
> ---
> .../devicetree/bindings/thermal/qcom-tsens.txt | 1 +
> drivers/thermal/qcom/tsens.c | 12 +++++++++---
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
> index 292ed89d900b..06195e8f35e2 100644
> --- a/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
> +++ b/Documentation/devicetree/bindings/thermal/qcom-tsens.txt
> @@ -8,6 +8,7 @@ Required properties:
>
> - reg: Address range of the thermal registers
> - #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
> +- #qcom,sensors: Number of sensors in tsens block
> - Refer to Documentation/devicetree/bindings/nvmem/nvmem.txt to know how to specify
> nvmem cells
>
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 3f9fe6aa51cc..20f3b87d7667 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -116,6 +116,7 @@ static int tsens_probe(struct platform_device *pdev)
> struct tsens_device *tmdev;
> const struct tsens_data *data;
> const struct of_device_id *id;
> + u32 num_sensors;
>
> if (pdev->dev.of_node)
> dev = &pdev->dev;
> @@ -130,18 +131,23 @@ static int tsens_probe(struct platform_device *pdev)
> else
> data = &data_8960;
>
> - if (data->num_sensors <= 0) {
> + num_sensors = data->num_sensors;
> +
Probably worth adding a comment that we're overriding the num_sensors
from DT if available here.
> + if (np)
> + of_property_read_u32(np, "#qcom,sensors", &num_sensors);
> +
> + if (num_sensors <= 0) {
> dev_err(dev, "invalid number of sensors\n");
> return -EINVAL;
> }
>
> tmdev = devm_kzalloc(dev, sizeof(*tmdev) +
> - data->num_sensors * sizeof(*s), GFP_KERNEL);
> + num_sensors * sizeof(*s), GFP_KERNEL);
> if (!tmdev)
> return -ENOMEM;
>
> tmdev->dev = dev;
> - tmdev->num_sensors = data->num_sensors;
> + tmdev->num_sensors = num_sensors;
> tmdev->ops = data->ops;
> for (i = 0; i < tmdev->num_sensors; i++) {
> if (data->hw_ids)
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT
2018-05-07 23:53 [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT Bjorn Andersson
2018-05-14 14:45 ` Amit Kucheria
2018-05-15 6:57 ` Amit Kucheria
@ 2018-05-22 20:14 ` Rob Herring
2 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2018-05-22 20:14 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Zhang Rui, Eduardo Valentin, Mark Rutland, Rajendra Nayak,
linux-pm, devicetree, linux-kernel, linux-arm-msm
On Mon, May 07, 2018 at 04:53:39PM -0700, Bjorn Andersson wrote:
> For platforms that has multiple copies of the TSENS hardware block it's
> necessary to be able to specify the number of sensors per block in DeviceTree.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
> .../devicetree/bindings/thermal/qcom-tsens.txt | 1 +
Reviewed-by: Rob Herring <robh@kernel.org>
> drivers/thermal/qcom/tsens.c | 12 +++++++++---
> 2 files changed, 10 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-22 20:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-07 23:53 [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT Bjorn Andersson
2018-05-14 14:45 ` Amit Kucheria
2018-05-14 17:46 ` Bjorn Andersson
2018-05-15 6:57 ` Amit Kucheria
2018-05-22 20:14 ` Rob Herring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).