Commit 6d7c70d1 authored by Bjorn Andersson's avatar Bjorn Andersson Committed by Eduardo Valentin

thermal: qcom: tsens: Allow number of sensors to come from DT

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: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: default avatarAmit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
parent cc50ba5e
...@@ -8,6 +8,7 @@ Required properties: ...@@ -8,6 +8,7 @@ Required properties:
- reg: Address range of the thermal registers - reg: Address range of the thermal registers
- #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description. - #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 - Refer to Documentation/devicetree/bindings/nvmem/nvmem.txt to know how to specify
nvmem cells nvmem cells
......
...@@ -116,6 +116,7 @@ static int tsens_probe(struct platform_device *pdev) ...@@ -116,6 +116,7 @@ static int tsens_probe(struct platform_device *pdev)
struct tsens_device *tmdev; struct tsens_device *tmdev;
const struct tsens_data *data; const struct tsens_data *data;
const struct of_device_id *id; const struct of_device_id *id;
u32 num_sensors;
if (pdev->dev.of_node) if (pdev->dev.of_node)
dev = &pdev->dev; dev = &pdev->dev;
...@@ -130,18 +131,23 @@ static int tsens_probe(struct platform_device *pdev) ...@@ -130,18 +131,23 @@ static int tsens_probe(struct platform_device *pdev)
else else
data = &data_8960; 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"); dev_err(dev, "invalid number of sensors\n");
return -EINVAL; return -EINVAL;
} }
tmdev = devm_kzalloc(dev, sizeof(*tmdev) + tmdev = devm_kzalloc(dev, sizeof(*tmdev) +
data->num_sensors * sizeof(*s), GFP_KERNEL); num_sensors * sizeof(*s), GFP_KERNEL);
if (!tmdev) if (!tmdev)
return -ENOMEM; return -ENOMEM;
tmdev->dev = dev; tmdev->dev = dev;
tmdev->num_sensors = data->num_sensors; tmdev->num_sensors = num_sensors;
tmdev->ops = data->ops; tmdev->ops = data->ops;
for (i = 0; i < tmdev->num_sensors; i++) { for (i = 0; i < tmdev->num_sensors; i++) {
if (data->hw_ids) if (data->hw_ids)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment