From patchwork Wed Dec 11 20:31:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 11286257 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6906414B7 for ; Wed, 11 Dec 2019 20:32:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 434052077B for ; Wed, 11 Dec 2019 20:32:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MDOyvW6W"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ru6rpApk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 434052077B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Mh4Cct/c1sx10UmSy5d0FCItaRvvXWHAR+JBpSayZ6c=; b=MDOyvW6W2zB+m1WcqlnfaeuL6B 9UV5jKZlfXDUmLc/A+VNsN+rd+2LsSI7O1tmH/Zk086ifrWbxNcpIr5moPE++ugt6UCBb4/gM2cdq 30FObNr3sgWXvWiXVRsyD1dCH2rug/J4C094aXfwCkjOzTDZ9tDdXFzQxDJye2QGW49C+jXDFy6ae 9cet5v0m4mRb77M4KRwHeGR4/aUwWVjG2EES/SCoDMLlVL0B5884jDEsyXdTcIrICjwrCEc8wDRbY JfdcNk/ZqICnTuybce9YClMPgNhMchIi04CmJBrEclWPDYIV53frpA6qdb688CE8jt6xXwKRdELGx Cnv0/IAA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8ee-0008Sk-1t; Wed, 11 Dec 2019 20:32:16 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8eM-0008Es-EI for linux-arm-kernel@lists.infradead.org; Wed, 11 Dec 2019 20:31:59 +0000 Received: by mail-pg1-x542.google.com with SMTP id 6so11313556pgk.0 for ; Wed, 11 Dec 2019 12:31:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bUI3dxAJmLbR2verpuQbHht/NnNgFc4Xm8emQetKLeY=; b=ru6rpApkxWfLsDVpgRwLBm4hAo2TQvM8KsODhFgI3HwZBxEcNZ5tUFLlmKttn5uwFM 2BnIPYTi5ylFrBcB8s09BZOmdUoYAJ7SQzUX7QqXg/iBpnqnloIPazKEXMdqVc4bujlN Kq08lbQl1wloiSnT8//5Ag0zpIfIBzeqVEgLpz1nNeQTUIRLw3+D+S+CKMEDBPezdokE wXLoS6KpgtIHgCaFUTTsBCmQ91mSWrWmkDuIQZR733e6sYdfmrrN10bGqqEW7+OAdsJ1 ZzuGjMwRMEJfX9r8syaV0xN1yskgFxDejnGZ80dv7+agP88A7BjgumoMFyKNc9Fi3nvt pH9g== 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:in-reply-to :references; bh=bUI3dxAJmLbR2verpuQbHht/NnNgFc4Xm8emQetKLeY=; b=mXyuRsaqhzFnm7a+/8T3D7riVZr8/ZFKwAd/9597X+D8X4L2I0daSSF+S2X0KGmsIo XsLqYFRLPsrxXUUiLkQSVaHEYbY7Y0zs1mS5sEvvQWdvXJbIyMnnWOxaGAUb7m/lhZ+U B+GyKDmAYXdhbMNiWB9R5s3dsRYSaa8KeUwhqhz/pciruA2EjDDgXU/ErYRCMu6neBTZ BBimY1GRFDEoXXg+QhVaVHM+9n+vih6hTFHk7GkeM2EagG0+QmEv1Znl+IPP+6H3TxFA +soNxUeOw6sOz2HUKiyRElQ/xyzIGh+ImwlXGuPy26IzhAxbm9kOxDUMs0nR87HIm4fn r14A== X-Gm-Message-State: APjAAAWcHoLY1tzUw5ljQNi4/XyPlfhV/20GjBMMFM1UkrKPWqIOcH7p Se/sDB6PKQkNGp7WMk7ybFYzZDXR X-Google-Smtp-Source: APXvYqyQ8PN4Yo0D5f0TxdtgaqutssAvFXy5lB6UXK07VypUBLW+9PLuwlCGTEr6LBLosXGwZ9rWLA== X-Received: by 2002:a63:214e:: with SMTP id s14mr6207807pgm.428.1576096317292; Wed, 11 Dec 2019 12:31:57 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a19sm917570pju.11.2019.12.11.12.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 12:31:56 -0800 (PST) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org, daniel.lezcano@linaro.org Subject: [PATCH v2 1/6] thermal: brcmstb_thermal: Do not use DT coefficients Date: Wed, 11 Dec 2019 12:31:38 -0800 Message-Id: <20191211203143.2952-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211203143.2952-1-f.fainelli@gmail.com> References: <20191211203143.2952-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_123158_480579_CD1F83D2 X-CRM114-Status: GOOD ( 18.69 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:542 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (f.fainelli[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Amit Kucheria , Florian Fainelli , "open list:BROADCOM STB AVS TMON DRIVER" , open list , Eduardo Valentin , Rob Herring , "maintainer:BROADCOM STB AVS TMON DRIVER" , Markus Mayer , Zhang Rui MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org At the time the brcmstb_thermal driver and its binding were merged, the DT binding did not make the coefficients properties a mandatory one, therefore all users of the brcmstb_thermal driver out there have a non functional implementation with zero coefficients. Even if these properties were provided, the formula used for computation is incorrect. The coefficients are entirely process specific (right now, only 28nm is supported) and not board or SoC specific, it is therefore appropriate to hard code them in the driver given the compatibility string we are probed with which has to be updated whenever a new process is introduced. We remove the existing coefficients definition since subsequent patches are going to add support for a new process and will introduce new coefficients as well. Fixes: 9e03cf1b2dd5 ("thermal: add brcmstb AVS TMON driver") Signed-off-by: Florian Fainelli --- drivers/thermal/broadcom/brcmstb_thermal.c | 31 +++++++--------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c index 5825ac581f56..680f1a070606 100644 --- a/drivers/thermal/broadcom/brcmstb_thermal.c +++ b/drivers/thermal/broadcom/brcmstb_thermal.c @@ -49,7 +49,7 @@ #define AVS_TMON_TP_TEST_ENABLE 0x20 /* Default coefficients */ -#define AVS_TMON_TEMP_SLOPE -487 +#define AVS_TMON_TEMP_SLOPE 487 #define AVS_TMON_TEMP_OFFSET 410040 /* HW related temperature constants */ @@ -108,23 +108,12 @@ struct brcmstb_thermal_priv { struct thermal_zone_device *thermal; }; -static void avs_tmon_get_coeffs(struct thermal_zone_device *tz, int *slope, - int *offset) -{ - *slope = thermal_zone_get_slope(tz); - *offset = thermal_zone_get_offset(tz); -} - /* Convert a HW code to a temperature reading (millidegree celsius) */ static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz, u32 code) { - const int val = code & AVS_TMON_TEMP_MASK; - int slope, offset; - - avs_tmon_get_coeffs(tz, &slope, &offset); - - return slope * val + offset; + return (AVS_TMON_TEMP_OFFSET - + (int)((code & AVS_TMON_TEMP_MAX) * AVS_TMON_TEMP_SLOPE)); } /* @@ -136,20 +125,18 @@ static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz, static inline u32 avs_tmon_temp_to_code(struct thermal_zone_device *tz, int temp, bool low) { - int slope, offset; - if (temp < AVS_TMON_TEMP_MIN) - return AVS_TMON_TEMP_MAX; /* Maximum code value */ - - avs_tmon_get_coeffs(tz, &slope, &offset); + return AVS_TMON_TEMP_MAX; /* Maximum code value */ - if (temp >= offset) + if (temp >= AVS_TMON_TEMP_OFFSET) return 0; /* Minimum code value */ if (low) - return (u32)(DIV_ROUND_UP(offset - temp, abs(slope))); + return (u32)(DIV_ROUND_UP(AVS_TMON_TEMP_OFFSET - temp, + AVS_TMON_TEMP_SLOPE)); else - return (u32)((offset - temp) / abs(slope)); + return (u32)((AVS_TMON_TEMP_OFFSET - temp) / + AVS_TMON_TEMP_SLOPE); } static int brcmstb_get_temp(void *data, int *temp) From patchwork Wed Dec 11 20:31:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 11286269 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 747376C1 for ; Wed, 11 Dec 2019 20:32:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B334214AF for ; Wed, 11 Dec 2019 20:32:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JCYrJE3N"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B+s5PbZT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B334214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=yXcc2z5OpfYgN9oAypQ6a6Q4GMgXysglb5VDQlYEjTc=; b=JCYrJE3NXaROkRMxRggiOU8zoQ vbdBw7V+1kNIT61h0fb4JrPcXHYlYKc4/bRC/2xghheMJsdTdymqPRFjzGbs2+J4FiNLhpNlgpEMJ 41IY8aA7GRM3d7Sp67vjM1r/8wit76mgvL/e0RCWxraogDXXHlHLQbGUNc3Bn6OE0GfvD2S+0ipnB juJJx4pqGSMLnvnakOymth9rS9vl8tlc9g8wbZTkyPuaMoAOOZH3levlgGfA5j3cctAoZhN9F/y+7 r4iZWr6LAJOCykxRMLR44SkKpw+NSh5ExvnY4txTanOX6P2so6QD/K7sugnkOUsbNosHeBnN30IqO 2b7Aauag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8eq-0000Ed-NZ; Wed, 11 Dec 2019 20:32:28 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8eN-0008FD-NE for linux-arm-kernel@lists.infradead.org; Wed, 11 Dec 2019 20:32:01 +0000 Received: by mail-pg1-x544.google.com with SMTP id b137so11305516pga.6 for ; Wed, 11 Dec 2019 12:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nAMyfH4P60dFRDU7m+hosqMx6pv601HbAJ1pQGyNcMg=; b=B+s5PbZT4Zv9XI0AjaTATaBNhgYdHqBe7Fe7Fgk6Gne3AfcV6tuqSt2zTuOKkdpzGC dWt4Srz4rqMCpUQHt1SNCub76Jw4jI1uspbhQmdK19gtgOt8aLASF+eY4XxtuJ/D9cEF bigPSiDXbdFkXCZU9wq2ctSA4B3zePmC56PxF8jVdbfEsZ/e9xzLnSkYdpNBCWQ8FkEU c9l2+prZDlmxmUpMzrCUGeVxqvGBVNy2f4BESOpRxkOhb0iGulRPcnqXSTGp3yRw5IYm GoEtJlKtZR6oLs6rUesOmwDWLxwy0yk6zmH6Vw8dp/nCpSLBUpJ7kMKCdl+85uanBSvv Emxg== 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:in-reply-to :references; bh=nAMyfH4P60dFRDU7m+hosqMx6pv601HbAJ1pQGyNcMg=; b=EyC4iQhUyxcFFsuM2HvM9ljmMCfpel7BHBJXrvzMqkCUc9Uo/QDQmWFmqb4Rf4kiSL r/wPUiA4Fc4NvY/zq7n/Z4EuuXDTZ3FcEbFn4jYM6/DZ21fNTe4BNxVkDzuLn4J0A9AW 6r/+Q/Lu/z6XlKmycICMXFjcgFKVuHVIOrhsyrOC3Z4oicMkHSpUkH0eVriL6oBkk280 6+eZA3NQXWqA8DnfXmKrpxhrTVHiVSQy3pdInyhrdJTshntyvTLdcIsRbprhUdkV0NB2 APNWfjG09TY9IX6wXGq3rwETmc1UkCKlDpJfS8DJc70aaK21M7kjPKamWSmfdbgyCr4v x+Nw== X-Gm-Message-State: APjAAAXLRxurnLFZKY3AtNe6OgXETkmDQjNprBT4xaALqxX4mpp7VvPW YRTEvzF8QNNYWdMkkHvpy5QvGkmd X-Google-Smtp-Source: APXvYqw905t0OmMYtvu4Tzun1VIheUVmOA2Ss2518GBDlhcYIjEyhuan6FZ4Ec2WugUBJLN5NY8CXg== X-Received: by 2002:a63:5b0a:: with SMTP id p10mr6243248pgb.228.1576096318549; Wed, 11 Dec 2019 12:31:58 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a19sm917570pju.11.2019.12.11.12.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 12:31:57 -0800 (PST) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org, daniel.lezcano@linaro.org Subject: [PATCH v2 2/6] thermal: brcmstb_thermal: Prepare to support a different process Date: Wed, 11 Dec 2019 12:31:39 -0800 Message-Id: <20191211203143.2952-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211203143.2952-1-f.fainelli@gmail.com> References: <20191211203143.2952-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_123159_758377_4E61D571 X-CRM114-Status: GOOD ( 18.64 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:544 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (f.fainelli[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Amit Kucheria , Florian Fainelli , "open list:BROADCOM STB AVS TMON DRIVER" , open list , Eduardo Valentin , Rob Herring , "maintainer:BROADCOM STB AVS TMON DRIVER" , Markus Mayer , Zhang Rui MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The driver is currently assuming that it is operating with a 28nm process chip, which has a specific formula to convert temperature to a code and vice versa. Update the code to support providing two key values: offset and multiplier to derive the correct formulas. Signed-off-by: Florian Fainelli --- drivers/thermal/broadcom/brcmstb_thermal.c | 54 ++++++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c index 680f1a070606..68f89f7c7e7f 100644 --- a/drivers/thermal/broadcom/brcmstb_thermal.c +++ b/drivers/thermal/broadcom/brcmstb_thermal.c @@ -102,18 +102,27 @@ static struct avs_tmon_trip avs_tmon_trips[] = { }, }; +struct brcmstb_thermal_params { + unsigned int offset; + unsigned int mult; +}; + struct brcmstb_thermal_priv { void __iomem *tmon_base; struct device *dev; struct thermal_zone_device *thermal; + /* Process specific thermal parameters used for calculations */ + struct brcmstb_thermal_params temp_params; }; /* Convert a HW code to a temperature reading (millidegree celsius) */ -static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz, +static inline int avs_tmon_code_to_temp(struct brcmstb_thermal_priv *priv, u32 code) { - return (AVS_TMON_TEMP_OFFSET - - (int)((code & AVS_TMON_TEMP_MAX) * AVS_TMON_TEMP_SLOPE)); + int offset = priv->temp_params.offset; + int mult = priv->temp_params.mult; + + return (offset - (int)((code & AVS_TMON_TEMP_MASK) * mult)); } /* @@ -122,21 +131,22 @@ static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz, * @temp: temperature to convert * @low: if true, round toward the low side */ -static inline u32 avs_tmon_temp_to_code(struct thermal_zone_device *tz, +static inline u32 avs_tmon_temp_to_code(struct brcmstb_thermal_priv *priv, int temp, bool low) { + int offset = priv->temp_params.offset; + int mult = priv->temp_params.mult; + if (temp < AVS_TMON_TEMP_MIN) - return AVS_TMON_TEMP_MAX; /* Maximum code value */ + return AVS_TMON_TEMP_MASK; /* Maximum code value */ - if (temp >= AVS_TMON_TEMP_OFFSET) + if (temp >= offset) return 0; /* Minimum code value */ if (low) - return (u32)(DIV_ROUND_UP(AVS_TMON_TEMP_OFFSET - temp, - AVS_TMON_TEMP_SLOPE)); + return (u32)(DIV_ROUND_UP(offset - temp, mult)); else - return (u32)((AVS_TMON_TEMP_OFFSET - temp) / - AVS_TMON_TEMP_SLOPE); + return (u32)((offset - temp) / mult); } static int brcmstb_get_temp(void *data, int *temp) @@ -154,7 +164,7 @@ static int brcmstb_get_temp(void *data, int *temp) val = (val & AVS_TMON_STATUS_data_msk) >> AVS_TMON_STATUS_data_shift; - t = avs_tmon_code_to_temp(priv->thermal, val); + t = avs_tmon_code_to_temp(priv, val); if (t < 0) *temp = 0; else @@ -188,7 +198,7 @@ static int avs_tmon_get_trip_temp(struct brcmstb_thermal_priv *priv, val &= trip->reg_msk; val >>= trip->reg_shift; - return avs_tmon_code_to_temp(priv->thermal, val); + return avs_tmon_code_to_temp(priv, val); } static void avs_tmon_set_trip_temp(struct brcmstb_thermal_priv *priv, @@ -201,7 +211,7 @@ static void avs_tmon_set_trip_temp(struct brcmstb_thermal_priv *priv, dev_dbg(priv->dev, "set temp %d to %d\n", type, temp); /* round toward low temp for the low interrupt */ - val = avs_tmon_temp_to_code(priv->thermal, temp, + val = avs_tmon_temp_to_code(priv, temp, type == TMON_TRIP_TYPE_LOW); val <<= trip->reg_shift; @@ -218,7 +228,7 @@ static int avs_tmon_get_intr_temp(struct brcmstb_thermal_priv *priv) u32 val; val = __raw_readl(priv->tmon_base + AVS_TMON_TEMP_INT_CODE); - return avs_tmon_code_to_temp(priv->thermal, val); + return avs_tmon_code_to_temp(priv, val); } static irqreturn_t brcmstb_tmon_irq_thread(int irq, void *data) @@ -282,19 +292,32 @@ static const struct thermal_zone_of_device_ops of_ops = { .set_trips = brcmstb_set_trips, }; +static const struct brcmstb_thermal_params brcmstb_28nm_params = { + .offset = 410040, + .mult = 487, +}; + static const struct of_device_id brcmstb_thermal_id_table[] = { - { .compatible = "brcm,avs-tmon" }, + { .compatible = "brcm,avs-tmon", .data = &brcmstb_28nm_params }, {}, }; MODULE_DEVICE_TABLE(of, brcmstb_thermal_id_table); static int brcmstb_thermal_probe(struct platform_device *pdev) { + const struct brcmstb_thermal_params *params; + const struct of_device_id *of_id = NULL; struct thermal_zone_device *thermal; struct brcmstb_thermal_priv *priv; struct resource *res; int irq, ret; + of_id = of_match_node(brcmstb_thermal_id_table, pdev->dev.of_node); + if (!of_id || !of_id->data) + return -EINVAL; + + params = of_id->data; + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -304,6 +327,7 @@ static int brcmstb_thermal_probe(struct platform_device *pdev) if (IS_ERR(priv->tmon_base)) return PTR_ERR(priv->tmon_base); + memcpy(&priv->temp_params, params, sizeof(priv->temp_params)); priv->dev = &pdev->dev; platform_set_drvdata(pdev, priv); From patchwork Wed Dec 11 20:31:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 11286271 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D35316C1 for ; Wed, 11 Dec 2019 20:32:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E66A21556 for ; Wed, 11 Dec 2019 20:32:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="L0XLuRv8"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b7yOoaL4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E66A21556 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=l5J8+otcrXd1oNEUWIF+btEMw/JMNGVTgETYm0woWTA=; b=L0XLuRv8xJVNlb2BzfLP4iHMLj 97t+c1pYcH+5eXzR+GxZeROHoSRpuYSn52EQP4SyuZfdmTFysfyaWoSUZBC6sVnpf770QTOv9GAuT yd+P4w5KECuWfR28hDabzdqrxMSmr41mlrS2HpABdeOZxv8ar8xiX3F4rzNcqOyGorAmrW2Mo0pPz G+kkGaZR3npZXR+wGLTTVoU5kl4fZDPwiWmOkhSIv9KY++fwYB9z77NLbOi/+7vB1N/EpAryeMUgJ wiuDU3jqSCZU+dTE3BI4Ntv8QZzLEK5RJZxcZaNUIUPB4Z5nxK152MjUcGdJeP+DEzqirTrZGYZ5d nkduNMrw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8f4-0000Ti-EJ; Wed, 11 Dec 2019 20:32:42 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8eO-0008G0-VR for linux-arm-kernel@lists.infradead.org; Wed, 11 Dec 2019 20:32:02 +0000 Received: by mail-pj1-x1042.google.com with SMTP id ep17so40772pjb.4 for ; Wed, 11 Dec 2019 12:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/SGLTAdZJn5EJy2JzHgzjK5/AJ+qkCVgDvB3ahQxnHQ=; b=b7yOoaL4G/ALvz/vNUlr2OeqNIasR8tlfumfduHUCFAHMOnxwtwF3SoUwldWsEaQ4R LvW812GkycQioVyIoAeViSehBhLN1Q1fYMklkMS1CLAqfAfhQa7oJFT7DMvMrZaKAb7j NmDSJEeyjRRMw6m2gmWMK31DqM0KmM1u85/KojBSQKtdXCVhFcQZgfC3jqKuJ9EC8KLf eG1TR6a96w3YAz3FtgejTRo7Cs4j71tlDnUpbI3criKCOOGkRDoPZfN/+hysMy4D7IAw CMLHltGp9hLhs0O75keqJ074R+i9CYm6esB68cymsYt+Q3mKtu4NS5r/EJ7VPoC6ETh0 o+og== 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:in-reply-to :references; bh=/SGLTAdZJn5EJy2JzHgzjK5/AJ+qkCVgDvB3ahQxnHQ=; b=b8bDrVh35MA/ZlrZtMau29wFLipPTqWj7jgNMkkIWJTkYCjO9yZscTKJE4Yves8URu kXERdVa3m0BiwwHqWpNlRSUeujGZ0S/UIN3GseST6l0TPnyJ8380bVtT1FnCms+iv9kS O2eW388C4WJrRcZggSNaESeM1TIzh4Y0sQttH98hE7JDvEQ70RwZeXTOp4mxgR3wnBcK jaVCIpDceYiBRm9I/p83aekEOER86JbluhqNu3WBFUxY374bQ5b7Usia5HXWXNbFtyRD OUUdaLzXqlbp0Mgxlb/LonjwYcXVqfxUbkiKdET4wL8JXTtX3UNoKOVpXDsDXBq7bQoQ nydQ== X-Gm-Message-State: APjAAAWa5DUvclsnV6PQSLoNhrCB0L4WWF6pt393kLnDwh7hPTtPuLsI J4qsp9XEZwTUDfWCLAQ2PbUHvZ9r X-Google-Smtp-Source: APXvYqx/G7SPF+0fLJkFR2jINi/QVILifYW6VvhXLrfs0TC+JDl93K7sIkMmJpc9bSFgNrKj/zRX8g== X-Received: by 2002:a17:90a:7bc3:: with SMTP id d3mr5804634pjl.86.1576096319788; Wed, 11 Dec 2019 12:31:59 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a19sm917570pju.11.2019.12.11.12.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 12:31:59 -0800 (PST) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org, daniel.lezcano@linaro.org Subject: [PATCH v2 3/6] dt-bindings: thermal: Define BCM7216 thermal sensor compatible Date: Wed, 11 Dec 2019 12:31:40 -0800 Message-Id: <20191211203143.2952-4-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211203143.2952-1-f.fainelli@gmail.com> References: <20191211203143.2952-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_123201_069662_53D58300 X-CRM114-Status: GOOD ( 11.15 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (f.fainelli[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Amit Kucheria , Florian Fainelli , "open list:BROADCOM STB AVS TMON DRIVER" , open list , Eduardo Valentin , Rob Herring , "maintainer:BROADCOM STB AVS TMON DRIVER" , Markus Mayer , Zhang Rui MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org BCM7216 is a 16nm process STB chip, which requires a different compatible string to differentiate different temperature formulas. Reviewed-by: Rob Herring Signed-off-by: Florian Fainelli --- .../devicetree/bindings/thermal/brcm,avs-tmon.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/brcm,avs-tmon.txt b/Documentation/devicetree/bindings/thermal/brcm,avs-tmon.txt index 43a9ed545944..74a9ef09db8b 100644 --- a/Documentation/devicetree/bindings/thermal/brcm,avs-tmon.txt +++ b/Documentation/devicetree/bindings/thermal/brcm,avs-tmon.txt @@ -3,9 +3,13 @@ Thermal management core, provided by the AVS TMON hardware block. Required properties: -- compatible: must be "brcm,avs-tmon" and/or "brcm,avs-tmon-bcm7445" +- compatible: must be one of: + "brcm,avs-tmon-bcm7216" + "brcm,avs-tmon-bcm7445" + "brcm,avs-tmon" - reg: address range for the AVS TMON registers -- interrupts: temperature monitor interrupt, for high/low threshold triggers +- interrupts: temperature monitor interrupt, for high/low threshold triggers, + required except for "brcm,avs-tmon-bcm7216" - interrupt-names: should be "tmon" Example: From patchwork Wed Dec 11 20:31:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 11286273 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF0B66C1 for ; Wed, 11 Dec 2019 20:32:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F6CE21556 for ; Wed, 11 Dec 2019 20:32:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qDA/ICAp"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d3b4d/7L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F6CE21556 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wa0xY/rSwxEQpv9t5wXyEnNYpd6A0gCJTr2FoWoyv4Y=; b=qDA/ICApJ3hUcrKgwJs3VvBctm 87+tiyHpuYgr9eyN/LcZYfNF/DbqUeoyIP+B+2DpBSyQOIeckCubnxjekmOpkLwmOGUcd46uYXNl0 I1QT+pucO5BQuSNG4PViQBJci9suzQE+GHPtlE9ItNW9V79tgCRz6XAon4zn/8ZdNaDUw+Dgv8GoB lDJjWO3nNIjZWX7DfhS6N/9fm1swAGGtHo+AJ8dUZ1trw6ZiyIgQloshTNhVvwNIBt2cJkOFl3KLA AtO+KBsXiqjh6Zd1VzkjsOl9NG3/uOvmfG8Vz9roRYecEqCKxWchwJY8iurAZTuLZO+GIM/lUHy/M 5ROzkj4g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8fJ-0000jY-8V; Wed, 11 Dec 2019 20:32:57 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8eP-0008HL-VM for linux-arm-kernel@lists.infradead.org; Wed, 11 Dec 2019 20:32:03 +0000 Received: by mail-pl1-x644.google.com with SMTP id a17so39181pls.5 for ; Wed, 11 Dec 2019 12:32:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0+ZNbiTOOC7n+yoMJbbexSm1sD8dYoDxAphQh0Gx9Wk=; b=d3b4d/7L2CRwAcKwGLpCgZrLZuRldlGySqCDYcmTnmibFchSRNNwAe7x7V6NddqiPJ 5NFe62AAv65r+m12799xKg1D3Mh1FE8rlX4zHOv20aiXeTHZY/+33M1hdRr2WOaty65b qG/302JAWhNiUoRLmvPzejIC/SGjfeTnftDEdJ9BRtM20rdVBgdoa1DBS3rozw64+JXa pfkfOB7g4AeaG3GkIwCswaU2qGHUQDzfe374bAtDVaTfsRQeE68qBUYVKjvyvy/VzRC2 EdiqMeu8hGJXgENSI31l/9Ihsh05XnY6GJ8GF8C4xaNoVqIE2S+r3H06obBppYHud4G+ nTtg== 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:in-reply-to :references; bh=0+ZNbiTOOC7n+yoMJbbexSm1sD8dYoDxAphQh0Gx9Wk=; b=H++OPvPz45ZdG91xxxd0WdlQofvyu2Tw+zqIBqiXAu/KUe7qU1GeVPNJ+6HfmzqAjp GpyUaldwP0qF2SMVkU6bzC9Rc0uC2avUda83sajmvE2FyWmBODVDHSOr56dMp3R9cPsu zK9M03KB+/DkyAz1ylO1+/ruE/opnIV/U6+BDIOStA5OZ3GSz+McDj+taRlnb4fJOz/i 9km1bE/gJ+QgNiFMBiWVEybv89xitzlQpxptlNi2JMpZpms7xtCWD+WA4N3cHXUxdD+I h3vgc7zpQ95cSAlLP1ktDGM4hhE2dlQn3FevatjZ80W/yUXuxyEaf8yK1BydXI6QbBq7 3Log== X-Gm-Message-State: APjAAAVUBrauXjB+5REPmscvCAAzBLBwcNr0ADHxIk187IBfQ3Cjgiwk YOaoCtpPSaXB6jQYaZ9U7Aq051+E X-Google-Smtp-Source: APXvYqwoG0SV8AaTyS0uTCKYn3q7bdAhdrRAzF28+g5XNW0W8G5/JNPvA8EVwJ6sRjadcY5I6QQaSA== X-Received: by 2002:a17:902:222:: with SMTP id 31mr5308114plc.117.1576096321068; Wed, 11 Dec 2019 12:32:01 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a19sm917570pju.11.2019.12.11.12.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 12:32:00 -0800 (PST) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org, daniel.lezcano@linaro.org Subject: [PATCH v2 4/6] thermal: brcmstb_thermal: Add 16nm process thermal parameters Date: Wed, 11 Dec 2019 12:31:41 -0800 Message-Id: <20191211203143.2952-5-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211203143.2952-1-f.fainelli@gmail.com> References: <20191211203143.2952-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_123202_075517_980DB60F X-CRM114-Status: GOOD ( 11.10 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:644 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (f.fainelli[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Amit Kucheria , Florian Fainelli , "open list:BROADCOM STB AVS TMON DRIVER" , open list , Eduardo Valentin , Rob Herring , "maintainer:BROADCOM STB AVS TMON DRIVER" , Markus Mayer , Zhang Rui MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Match the 7216 compatible string in order to derive the correct 16nm process thermal parameters to obtain correct readings. Reviewed-by: Amit Kucheria Signed-off-by: Florian Fainelli --- drivers/thermal/broadcom/brcmstb_thermal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c index 68f89f7c7e7f..74d94f01b1b9 100644 --- a/drivers/thermal/broadcom/brcmstb_thermal.c +++ b/drivers/thermal/broadcom/brcmstb_thermal.c @@ -292,12 +292,18 @@ static const struct thermal_zone_of_device_ops of_ops = { .set_trips = brcmstb_set_trips, }; +static const struct brcmstb_thermal_params brcmstb_16nm_params = { + .offset = 457829, + .mult = 557, +}; + static const struct brcmstb_thermal_params brcmstb_28nm_params = { .offset = 410040, .mult = 487, }; static const struct of_device_id brcmstb_thermal_id_table[] = { + { .compatible = "brcm,avs-tmon-bcm7216", .data = &brcmstb_16nm_params }, { .compatible = "brcm,avs-tmon", .data = &brcmstb_28nm_params }, {}, }; From patchwork Wed Dec 11 20:31:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 11286275 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AB026C1 for ; Wed, 11 Dec 2019 20:33:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD0062077B for ; Wed, 11 Dec 2019 20:33:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UiOy/dHT"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WQFmipXr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD0062077B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=eSR055A7S1GUf/hRAcatlCVey6eaNHIWVCcqpHHEMnQ=; b=UiOy/dHTitmce3I0IZqCbsIIPW Iu/HUaWdQytegw63sM0+EhbWrwhVcdyrojucuMQ9d4Athbh9qsenyVIwegMWyRm2IE1K9tCS1iNYt ph7TxlYRKMdgihmEIpL90z96rFKbf7fHCKSvj5fDeUeqjKC6KO9BqFtgaRvuFoJVzroWls4f/UVzM gH7ioNLZQI995QxDu3dJcY8RtGipWhemyu/Z74gNs6JXbrkDFpX/e0UhTxD82kZ0uJrPM2vWFnIFJ BgEHPbD6tJaCDJJWwFRM12llwEJrZuDQATIUA/INaBX5WAXX5GsYp12gtVE7n1f3XlX78pdjcQTTE 37gyzz+Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8fc-00013e-W7; Wed, 11 Dec 2019 20:33:17 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8eR-0008IZ-Pc for linux-arm-kernel@lists.infradead.org; Wed, 11 Dec 2019 20:32:05 +0000 Received: by mail-pl1-x642.google.com with SMTP id g6so35056plp.7 for ; Wed, 11 Dec 2019 12:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=afURWFdN1dU/KLmm8O/X/Jsvd7WfBwUp3PbxBXxbEO8=; b=WQFmipXruI1fTRuJSFGA+UtCvg+t0311Lztvvzz25V1GaOT4jVXqbMxAyysv9OySUw +9/7WI7+1RxSFI33RYHQoPAqQh5XAaPGfMu3YtTBLXVGRu7k8WQ4COQ06ahaIoVgih8/ vz/1vVaDWE/4sgwwZZfbXOoBD1eYiG15pgQJzhG29xp3jbQrfrj86j8okGfVlpyuayaf DfGm7gN6BOebb9VuiwqOzjDCIb1TUmsUkLZZReSofeOeD7z7UVyI+mNOj9fXp9rO2wz/ jwkW1lQx5uNhpKixZxW499CvK54iXIorUAuS2+PaBbNf4yB3J28mq3eVxcJIBlUN+HHu butA== 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:in-reply-to :references; bh=afURWFdN1dU/KLmm8O/X/Jsvd7WfBwUp3PbxBXxbEO8=; b=bEATI4lXMqYec04GrjjisktO9+C1wWLbs0662OGTDlbz+bkRABEPHikLaHH1hPUfNK pO8ieamhmW37dEKHQw5JPrZi7xXH2WoSBXL5ltp4Oa12AE7Gm/wBdSezjBm+XaJiBP4C g05QV80mvcolI6sKkrDh3scCgPic2v/abTt+/G7x2X3nJ6OgZ5/zY71jXcW9dX6nfMdq 0eoEwMZj2tUf1yL8ExZUtB26PevLoWfVlAk5oiq1LDiJ36kha4MwkwNZe/JZlSqagg0I QnuzujiMtJMTHmG8Ka4cHC+g49ZQKJmhPLseiJeqDMzMDlyu0I2mYJAvprCJQDoUdoVw lhaQ== X-Gm-Message-State: APjAAAW1KozIXV5ZKKgAHkZ98PQB3NA1p/vUc8x/YR/Pjf985cEiQlmS 0yF0le7eZvzJGyusajeFvgtuTnrU X-Google-Smtp-Source: APXvYqxGSB+7FmWepthU7M3pDNil4kYRJ30rzs2NUAnzV5QbV9rl9uHOAx0+aLP5WZBmSwJeGCpilA== X-Received: by 2002:a17:90a:b301:: with SMTP id d1mr5568198pjr.20.1576096322353; Wed, 11 Dec 2019 12:32:02 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a19sm917570pju.11.2019.12.11.12.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 12:32:01 -0800 (PST) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org, daniel.lezcano@linaro.org Subject: [PATCH v2 5/6] thermal: brcmstb_thermal: Restructure interrupt registration Date: Wed, 11 Dec 2019 12:31:42 -0800 Message-Id: <20191211203143.2952-6-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211203143.2952-1-f.fainelli@gmail.com> References: <20191211203143.2952-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_123203_918798_9F50AE6C X-CRM114-Status: GOOD ( 14.38 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (f.fainelli[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Amit Kucheria , Florian Fainelli , "open list:BROADCOM STB AVS TMON DRIVER" , open list , Eduardo Valentin , Rob Herring , "maintainer:BROADCOM STB AVS TMON DRIVER" , Markus Mayer , Zhang Rui MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If we are successful grabbing the interrupt resource, then register an interrupt handler, this makes it easier to support the interrupt as being optional, which is it for 7216. Reviewed-by: Amit Kucheria Signed-off-by: Florian Fainelli --- drivers/thermal/broadcom/brcmstb_thermal.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c index 74d94f01b1b9..47b622f33900 100644 --- a/drivers/thermal/broadcom/brcmstb_thermal.c +++ b/drivers/thermal/broadcom/brcmstb_thermal.c @@ -348,16 +348,15 @@ static int brcmstb_thermal_probe(struct platform_device *pdev) priv->thermal = thermal; irq = platform_get_irq(pdev, 0); - if (irq < 0) { - dev_err(&pdev->dev, "could not get IRQ\n"); - return irq; - } - ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, - brcmstb_tmon_irq_thread, IRQF_ONESHOT, - DRV_NAME, priv); - if (ret < 0) { - dev_err(&pdev->dev, "could not request IRQ: %d\n", ret); - return ret; + if (irq >= 0) { + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + brcmstb_tmon_irq_thread, + IRQF_ONESHOT, + DRV_NAME, priv); + if (ret < 0) { + dev_err(&pdev->dev, "could not request IRQ: %d\n", ret); + return ret; + } } dev_info(&pdev->dev, "registered AVS TMON of-sensor driver\n"); From patchwork Wed Dec 11 20:31:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 11286277 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C89514B7 for ; Wed, 11 Dec 2019 20:33:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 78FDF2077B for ; Wed, 11 Dec 2019 20:33:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O5aUkTeB"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Lf3l10Nj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 78FDF2077B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ldw3ZcOBPsAxoVIIOnG+FAedGuCKV0a/ZWxoB0Hra/U=; b=O5aUkTeBbtgSlNbZN5Ciy7HveK csygDd3TapUkYmnJTxL4zzTCS73p9sXhOjsNg/GCv07ntSMmIuOOUzcoNhjtpqc4paUZt2hwLEVEn NS7cARHJG5s6BcST3bzqvx9xBRd7WL5/Eku6YlJeQoLlKoR6bf1bFHo7JOJBPpQ8eonYQiYGiR4DI diM8Bl9QNkUfgXzlmyaUurYnFC3lPfDbden1sLUcXEBt+19nzqf/2KO3/l7+7+AezaGSFYR8NkPPy 8oYc4YPnfyuAhO1PaDcxSBdmnFzo6jbGONtJZPx6DugAgfy/K7rluYZ+K0uUKuV+2Hbu6MzXCvj/l 9u+jMrsg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8fo-0001H0-L6; Wed, 11 Dec 2019 20:33:28 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1if8eT-0008KM-1J for linux-arm-kernel@lists.infradead.org; Wed, 11 Dec 2019 20:32:06 +0000 Received: by mail-pf1-x443.google.com with SMTP id 4so2357735pfz.9 for ; Wed, 11 Dec 2019 12:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g7cIIA2fUKT3XoPncLJ8inchwLvzx7zJ6yCBfGCD0Kk=; b=Lf3l10NjokJTOzULJqrys4crSiRGGaVRpF7yZSm4XkNOqQe3ZXMy/OBLaU2AkIzQBz L1GSLt1JIzu38qUN8fPnPaCBzk5AgHB4zYdBaDOVdrzbI86OJfV6S4rX2VcS300Jj+DI psuofx1zEr4mAmM4/Lvsp6WseLe6l2f7gvIE86l1btmXTpcHiDrUgo0iGE5ekdnUjHwm i1NKzWzJMEM+C1Ar0EEAWSA5wKfkE/fNNnX/oL8MMgB/DIxnpCwvaASxofXFd8m5WiFv fNKjhV0ECWLPHiP/hfNOrr/Y6R6KJiemIrt2BuwGfXMFGPrQuFnlU02QJsBcR2KY+c+2 iOHQ== 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:in-reply-to :references; bh=g7cIIA2fUKT3XoPncLJ8inchwLvzx7zJ6yCBfGCD0Kk=; b=QcxexvpAYmwEWXVRsO2mzoF/OULUyuqWrYEmoU/3n1tlnmPvUBJ621zF5UHFT7tggh iRMd4qEeoMBLLZ0ZqfkU5uDAfZdX6JhmLIOflMCehFksAQMt+1296s4ZRFS9UiCA7WuP 6pYz9EPciiS/rhhZ7wCi1e0qPQVniSA1Fm2I2tsQnUiFbVLf8kAqBtZuBb2vKNOFpN18 JVBl08uZXLwpTXpU5TQuSNhI6cGEgPHpLN9tZv8kTteoZpLJ9XaxxbCVAJ4/gjIKpmVR rs/L/a9I9Sq+CJCBjsmK6Wpiyn9gj7YjiXJIKYPD00+8dd/8yA/+FvTt5bPorYrBdeAw knLA== X-Gm-Message-State: APjAAAX90GOx0jeFnPJUKo17pLCobgqy4tl5Sx/wvPpuUdipd0572lmE AabgluVk8Z9T+cC1cLnyXPyHppSs X-Google-Smtp-Source: APXvYqwprBE2vLChSP+ukiV9PRJ5kqS/aFkDnKefJvtf8znhGjt+UG4gh9WbCvcxO9Ut62p6AUXuvw== X-Received: by 2002:a63:5801:: with SMTP id m1mr6150099pgb.139.1576096323582; Wed, 11 Dec 2019 12:32:03 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a19sm917570pju.11.2019.12.11.12.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 12:32:02 -0800 (PST) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org, daniel.lezcano@linaro.org Subject: [PATCH v2 6/6] thermal: brcmstb_thermal: Register different ops per process Date: Wed, 11 Dec 2019 12:31:43 -0800 Message-Id: <20191211203143.2952-7-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211203143.2952-1-f.fainelli@gmail.com> References: <20191211203143.2952-1-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_123205_128387_040755E9 X-CRM114-Status: GOOD ( 14.38 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (f.fainelli[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Amit Kucheria , Florian Fainelli , "open list:BROADCOM STB AVS TMON DRIVER" , open list , Eduardo Valentin , Rob Herring , "maintainer:BROADCOM STB AVS TMON DRIVER" , Markus Mayer , Zhang Rui MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Since we do not have interrupts on BCM7216, we cannot have trip point crossing, the thermal subsystem expects us to provide a NULL set_trips operation in that case, so make it possible to provide per-process thermal_zone_of_device_ops Reviewed-by: Amit Kucheria Signed-off-by: Florian Fainelli --- drivers/thermal/broadcom/brcmstb_thermal.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c index 47b622f33900..8170ea1b8227 100644 --- a/drivers/thermal/broadcom/brcmstb_thermal.c +++ b/drivers/thermal/broadcom/brcmstb_thermal.c @@ -105,6 +105,7 @@ static struct avs_tmon_trip avs_tmon_trips[] = { struct brcmstb_thermal_params { unsigned int offset; unsigned int mult; + const struct thermal_zone_of_device_ops *of_ops; }; struct brcmstb_thermal_priv { @@ -287,19 +288,25 @@ static int brcmstb_set_trips(void *data, int low, int high) return 0; } -static const struct thermal_zone_of_device_ops of_ops = { +static const struct thermal_zone_of_device_ops brcmstb_16nm_of_ops = { .get_temp = brcmstb_get_temp, - .set_trips = brcmstb_set_trips, }; static const struct brcmstb_thermal_params brcmstb_16nm_params = { .offset = 457829, .mult = 557, + .of_ops = &brcmstb_16nm_of_ops, +}; + +static const struct thermal_zone_of_device_ops brcmstb_28nm_of_ops = { + .get_temp = brcmstb_get_temp, + .set_trips = brcmstb_set_trips, }; static const struct brcmstb_thermal_params brcmstb_28nm_params = { .offset = 410040, .mult = 487, + .of_ops = &brcmstb_28nm_of_ops, }; static const struct of_device_id brcmstb_thermal_id_table[] = { @@ -338,7 +345,7 @@ static int brcmstb_thermal_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); thermal = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, priv, - &of_ops); + priv->temp_params.of_ops); if (IS_ERR(thermal)) { ret = PTR_ERR(thermal); dev_err(&pdev->dev, "could not register sensor: %d\n", ret);