From patchwork Mon May 7 23:53:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 10384981 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D493D60236 for ; Mon, 7 May 2018 23:54:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2ACE28BA7 for ; Mon, 7 May 2018 23:54:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6F1528BAD; Mon, 7 May 2018 23:54:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3820B28BA7 for ; Mon, 7 May 2018 23:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753569AbeEGXx5 (ORCPT ); Mon, 7 May 2018 19:53:57 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:38348 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753547AbeEGXxm (ORCPT ); Mon, 7 May 2018 19:53:42 -0400 Received: by mail-pl0-f68.google.com with SMTP id c11-v6so1075067plr.5 for ; Mon, 07 May 2018 16:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=snwJmaUHYckrcQq2GSiPTJUbAsv9VzZH9Cn0DvCECZ0=; b=Mdq5BlrEShn3c/WYlyk98dUOXM2SCkCmoG/4BRkrmdz3cPlLKrMXwTZAPLKaqolHtj aw4xpbGJPxeK5jX+w0+4XMwreBqblnP+SfV1J2uAglPbMe35rB/2TKG4k9X+CYa7P+uK YhjJZFstozNDerfiUZeAE8DRfXx7pmJPn6tmY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=snwJmaUHYckrcQq2GSiPTJUbAsv9VzZH9Cn0DvCECZ0=; b=Na1LJJwY+UUqiUTmYsGtShcdgdrdt+zZ8lNBKPN/i4WNn9MURK3Sg0ZPHjIktXSmc/ pVy3W3UyK3G3EfoE7w62qLfOfM6d3ETG422DZq1GBG/RbwM6r1d77ju8QQpXFt3fZJc1 6AfN4XiRUKE6MyQWElnHG8hOsWB59UWmeQT05e6ihYb+fQkL+l20jYO/qm/zXiRYfXuY tz8OEcA2QQw2lavD/9OYOqFBR7ltMr+LcqkdMf1BZQ+hWZ6fXZ+W3pXl6+DyoIqfkoID 4vYdecOJ1ffET5KIKo/Cn3yladjyvCNk2mniFMdytKW8dO4ogkYkrRSaJjKoyW3K6oG8 xioA== X-Gm-Message-State: ALQs6tAmsp1ujxuL1goddlqmM53NSraULfgdTVb6wRw6Rq7ucAFkJCbv MNBsndXD5Ev+gVkvnPumN/EHkQtq0po= X-Google-Smtp-Source: AB8JxZrb/2zS3FpVrr0JzwuaeQY9KnzhRV4K8+9QOEEL/qMK3mRE0a8+LTIc3yNyzkXgJuDW0Mk4CA== X-Received: by 2002:a17:902:6b09:: with SMTP id o9-v6mr40120364plk.256.1525737222173; Mon, 07 May 2018 16:53:42 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id i127sm43891680pfc.154.2018.05.07.16.53.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 16:53:41 -0700 (PDT) From: Bjorn Andersson To: Zhang Rui , Eduardo Valentin , Rob Herring , Mark Rutland , Rajendra Nayak Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH] thermal: qcom: tsens: Allow number of sensors to come from DT Date: Mon, 7 May 2018 16:53:39 -0700 Message-Id: <20180507235339.8836-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Amit Kucheria Reviewed-by: Rob Herring --- .../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)