Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp114043ybx; Wed, 30 Oct 2019 12:10:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXToVD2wjxTczbbO+CfAZTBNCkfctAvX1fAmaOC1DzTM/1QuZrAUBYNZbzaHv1x8O4jC6J X-Received: by 2002:a50:f306:: with SMTP id p6mr1495781edm.284.1572462652942; Wed, 30 Oct 2019 12:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572462652; cv=none; d=google.com; s=arc-20160816; b=BIwXFyutaKSLLa51Nyp4qLU4UTSc/tM47GsxSVmY/6mTPkcpV1oJxgiSVVBDyqpvpU 8cXpqf8P4sdsBSieEPFotmPh6KvuVDP3z/Kg3cn/YFalNJGzKH+WnCUaTZaWKWjO5EWP CrabmvTSrFKqCEieSoZ7tmpmlp2Ea9CBc3IOTVbE1SM2BI2WCjg8SmMmMPn3E9eUhTWo OxIftJUJHYEkG3ZjTVhYUf2oP2+iHXX1Dqc7q2z5GzHtWWpbCWiD9HQQOsuiEI8JGr6O OoysB4sSEMLVYH1rvfciNHP6rsymWjAH1bUgs/2RTMVX9HX0mXLvMej8V6PXQfLZYrlh gb0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=I6P5H/5uV7JacgxYkaFeE2k/FEa8xgvahkSEI1tPpC4=; b=b+8SsxtYQFk7iWQ8YDXV3atEtcs7yta1ebHmMmH03RL3SCudeewGZlV78NifVJokuP xJ5OUd2h/JJvilu/V7ylQQT4h4g3jS+lo0v7U07vsTTv3LH0SZuroazw7rD7ojP/UZQO 2lPZqR1p3aJ3NzizWKbGRgSzAOqL6VhU4J7bU+gqfiqSVaCtXU5aJgkAa+uYXLCiAToh gzwA5lxXvuYePGYHBhhpWkSgyLlyRJ0JU/lhW17IEi2Dl6C6pKAVICBNFGnCemyqsr3s f1n3K27qrheKSQRZq+JdLm7ISeZiqSg3GDA1m4rBUtECxIPZnY3ViRZOJjqq/EWirUUO EyyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AJmJh+mW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id la4si1957577ejb.145.2019.10.30.12.10.28; Wed, 30 Oct 2019 12:10:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AJmJh+mW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727922AbfJ3SVw (ORCPT + 99 others); Wed, 30 Oct 2019 14:21:52 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39362 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726184AbfJ3SVv (ORCPT ); Wed, 30 Oct 2019 14:21:51 -0400 Received: by mail-pg1-f195.google.com with SMTP id p12so2010511pgn.6; Wed, 30 Oct 2019 11:21:51 -0700 (PDT) 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=I6P5H/5uV7JacgxYkaFeE2k/FEa8xgvahkSEI1tPpC4=; b=AJmJh+mWDb0JsKw8h0qqyPLlnyvhhllDzfwONbL/lWjh03d2I/+24d6dCsaPEnkWel 6n8KRJYnHfGrE+9DyTj7Y/Za63OHx7Pg9gg3rx7JlrAUCmLQSixoYvnXB5Ksv5j1zgEM /GgskK1TI4aXZs/B79FXMWWANtjAxwGekTHXlSmt8PamTkLU/2UCKeI2X+wZVRluBsnT oez67NfdmkJ6UHYoDiI/EJsRALrPV/7asy6s+OPN/9+4NsqO8KdseLSjYjfPFPH4rBhd KNqmoHJZZ6DxhSN9B4z+3x0jjqLDEv0X9Hs162pRRx51bc0SM3+UjmMaNbM5h4kRLF1J KI9w== 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=I6P5H/5uV7JacgxYkaFeE2k/FEa8xgvahkSEI1tPpC4=; b=QRmzCFpjS5p8G+CBGLA5MBucFDpwQLHc+I4pbfiCB/nVvGW8PlgaAQd3Z5jK9l/F+S sIaqRGsX96BQYaATmDdKAwaNI7mZ6zIRfZTschpwkxB0X1pj/zC9273WM+pZEgh48fze Vr/WxlLpBhNfTrxR1FBfFUeNoewdkxaKOjqmNGohrnPjZ4wkpxsrI9jQfWaUDh/31k1h Rgxc95UsSs+4To25A0ZqIlrJBBvk4X6KwLId8ZuG71bpaPRdfI5mdjXyt+E1YvUsiPRf j3tYtofY218osgnzehSeOt0pKxU36yYI20o2VNcn+Zexucm4V2SxiQPF1WMXgl9D8DJI YBVg== X-Gm-Message-State: APjAAAWh3pTfEyxxZyVaIZXBOf9FvEWyVfleXqTykYgaXPgl6Fz0RIAD CRpfLFrkibxxvgbXOU50GwEfRNeI X-Received: by 2002:a62:4d04:: with SMTP id a4mr764111pfb.60.1572459710934; Wed, 30 Oct 2019 11:21:50 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id z5sm521637pgi.19.2019.10.30.11.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2019 11:21:50 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: Florian Fainelli , Markus Mayer , bcm-kernel-feedback-list@broadcom.com (maintainer:BROADCOM STB AVS TMON DRIVER), Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Rob Herring , Mark Rutland , linux-pm@vger.kernel.org (open list:BROADCOM STB AVS TMON DRIVER), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE) Subject: [PATCH 1/6] thermal: brcmstb_thermal: Do not use DT coefficients Date: Wed, 30 Oct 2019 11:21:27 -0700 Message-Id: <20191030182132.25763-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191030182132.25763-1-f.fainelli@gmail.com> References: <20191030182132.25763-1-f.fainelli@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 | 37 ++++------------------ 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/drivers/thermal/broadcom/brcmstb_thermal.c b/drivers/thermal/broadcom/brcmstb_thermal.c index 5825ac581f56..42482af0422e 100644 --- a/drivers/thermal/broadcom/brcmstb_thermal.c +++ b/drivers/thermal/broadcom/brcmstb_thermal.c @@ -48,15 +48,6 @@ #define AVS_TMON_TEMP_INT_CODE 0x1c #define AVS_TMON_TP_TEST_ENABLE 0x20 -/* Default coefficients */ -#define AVS_TMON_TEMP_SLOPE -487 -#define AVS_TMON_TEMP_OFFSET 410040 - -/* HW related temperature constants */ -#define AVS_TMON_TEMP_MAX 0x3ff -#define AVS_TMON_TEMP_MIN -88161 -#define AVS_TMON_TEMP_MASK AVS_TMON_TEMP_MAX - enum avs_tmon_trip_type { TMON_TRIP_TYPE_LOW = 0, TMON_TRIP_TYPE_HIGH, @@ -108,23 +99,11 @@ 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 (410040 - (int)((code & 0x3FF) * 487)); } /* @@ -136,20 +115,16 @@ 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); + if (temp < -88161) + return 0x3FF; /* Maximum code value */ - if (temp >= offset) + if (temp >= 410040) return 0; /* Minimum code value */ if (low) - return (u32)(DIV_ROUND_UP(offset - temp, abs(slope))); + return (u32)(DIV_ROUND_UP(410040 - temp, 487)); else - return (u32)((offset - temp) / abs(slope)); + return (u32)((410040 - temp) / 487); } static int brcmstb_get_temp(void *data, int *temp) -- 2.17.1