From patchwork Tue Aug 30 19:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 601610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A783AECAAD5 for ; Tue, 30 Aug 2022 19:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbiH3TXF (ORCPT ); Tue, 30 Aug 2022 15:23:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbiH3TWx (ORCPT ); Tue, 30 Aug 2022 15:22:53 -0400 Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53C0379A7E; Tue, 30 Aug 2022 12:22:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1661887362; x=1693423362; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U0VJcbOTM8ab3MiQEMGAYi1n6qUqXBDMxjPiRHK115k=; b=Lh0vawBdls/5T6rFmXcgDZCxiuJveGKDZrnaq3QOjJw5/aWwSHVdSx0/ /SeMtWrg8GpvclrrtvEjwZVBiksnNt6uGvaM0CZfA9NCnbqKj5Z+jW/KW /P8BgWy/XrrYqeeUjjavp0J0rZsrLCqJd5Zu+vJ60R4aO8r6ELDc30fMc A=; X-IronPort-AV: E=Sophos;i="5.93,275,1654560000"; d="scan'208";a="125055929" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-f771ae83.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 19:22:40 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1e-f771ae83.us-east-1.amazon.com (Postfix) with ESMTPS id 2DD74120072; Tue, 30 Aug 2022 19:22:39 +0000 (UTC) Received: from EX19D013UWA004.ant.amazon.com (10.13.138.207) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 30 Aug 2022 19:22:16 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX19D013UWA004.ant.amazon.com (10.13.138.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Tue, 30 Aug 2022 19:22:16 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 30 Aug 2022 19:22:15 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 6B5974D41; Tue, 30 Aug 2022 19:22:12 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v3 17/19] hwmon: (mr75203) parse temperature coefficients from device-tree Date: Tue, 30 Aug 2022 19:22:10 +0000 Message-ID: <20220830192212.28570-18-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220830192212.28570-1-farbere@amazon.com> References: <20220830192212.28570-1-farbere@amazon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Use thermal coefficients from the device tree if they exist. Otherwise, use default values according to the series (5 or 6). All coefficients can be used or only part of them. The coefficients shall be used for fine tuning the default values since coefficients can vary between product and product. Signed-off-by: Eliav Farber --- drivers/hwmon/mr75203.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 6a035fd115ca..d9fc5d225868 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -676,7 +676,8 @@ static int pvt_set_temp_coeff(struct device *dev, struct pvt_device *pvt) { struct temp_coeff *ts_coeff = &pvt->ts_coeff; const struct device_node *np = dev->of_node; - u32 series; + u32 series, coeff_h, coeff_g, coeff_cal5; + s32 coeff_j; int ret; /* Incase ts-series property is not defined, use default 5. */ @@ -702,6 +703,32 @@ static int pvt_set_temp_coeff(struct device *dev, struct pvt_device *pvt) dev_dbg(dev, "temperature sensor series = %u\n", series); + /* Override ts-coeff-h/g/j/cal5 if they are defined. */ + ret = of_property_read_u32(np, "moortec,ts-coeff-h", &coeff_h); + if (!ret) + ts_coeff->h = coeff_h; + + ret = of_property_read_u32(np, "moortec,ts-coeff-g", &coeff_g); + if (!ret) + ts_coeff->g = coeff_g; + + ret = of_property_read_s32(np, "moortec,ts-coeff-j", &coeff_j); + if (!ret) + ts_coeff->j = coeff_j; + + ret = of_property_read_u32(np, "moortec,ts-coeff-cal5", &coeff_cal5); + if (!ret) { + if (coeff_cal5 == 0) { + dev_err(dev, "moortec,ts-coeff-cal5 can't be 0\n"); + return -EINVAL; + } + + ts_coeff->cal5 = coeff_cal5; + } + + dev_dbg(dev, "ts-coeff: h = %u, g = %u, j = %d, cal5 = %u\n", + ts_coeff->h, ts_coeff->g, ts_coeff->j, ts_coeff->cal5); + return 0; }