Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp22872rdh; Mon, 18 Dec 2023 03:14:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEA6dDgyyZJMhc7hNNEDoIk3svrpMxs+6zdHXKwskiy4IpKsM1k7d9gDra5bPVekP0KSNKR X-Received: by 2002:a17:902:8301:b0:1d0:6ffd:837e with SMTP id bd1-20020a170902830100b001d06ffd837emr5972408plb.137.1702898071321; Mon, 18 Dec 2023 03:14:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702898071; cv=none; d=google.com; s=arc-20160816; b=OWS34XOajoSCnsgP5hH3uRbFx2Eq3OMzCcolW37McGUKOgY2RQOXDjs5yFAAqze7bz F7S1NvAg8YuGFb2TUmoNHfjaPssvfSJjI86VltENIm7/GxnmaltoP1rs5xcjdzgfAd7G 3jwEmtM5mUaCqWp/F5El5xWYjztSGKxfI3LfidIUv5ktp9K1HMwPMLFKJ1um2Q9HI8Sm c6qJkLxm2czJltBsngrKz+p4BZxlW1pViushTtrIcTglbB0FkEmnxQ1gAi7PuuY+nm7T 53bxoB5rRZdJ4kkoGUWXrDVwizzlAbR3dcnYGJIyDMj1TwhFyV03Nbn9cRnE/CH0z1H2 HurQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=PmKpxHItuqmQbSonFHSJnsbU8qD23rtkdKOJPz+LstM=; fh=lLR5MlvJ+wSPJCZ2URo/+BnpxBp1Fh92uoD5hYD3XUo=; b=IJRam/TD17GO4p4ajXvNgGofhAU9hHjzF7CUskSC9H1NZGFU17kjDB6YluRBckTlk3 xV5pII3nYfEE+l5dLhgdHLhwIhT0k+QyOC84QBBAta4qJuPbpzUE0VvsbPHctA3nv/ia uEo2MduXR46G0wWQYYLZXT8uA4shBrp/xcUrv/1LSWDlFeHwq88G2385Ej78+YWYnji4 qf4VF6HUdFdXRq6p5x/qfTHhdP0JXUcL5spVtGKtOWkFXTietQeS7iIjzBlOFCMFqwyw W4CbfUrLt2ZPkqTRxh1FDmAMnP5aDODOiS9H47wWzYxlIDKceehPhIlmRczFAMsHiJm0 3eYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e3-20020a170902744300b001d3a491ae3asi3411119plt.538.2023.12.18.03.14.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 03:14:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AB919283E85 for ; Mon, 18 Dec 2023 11:14:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 013E11946B; Mon, 18 Dec 2023 11:14:11 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2492D18E2D; Mon, 18 Dec 2023 11:14:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 11C991FB; Mon, 18 Dec 2023 03:14:53 -0800 (PST) Received: from donnerap.manchester.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AFCA53F738; Mon, 18 Dec 2023 03:14:06 -0800 (PST) Date: Mon, 18 Dec 2023 11:14:04 +0000 From: Andre Przywara To: Maksim Kiselev Cc: Martin Botka , Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-pm@vger.kernel.org (open list:ALLWINNER THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Allwinner sunXi SoC support), linux-sunxi@lists.linux.dev (open list:ARM/Allwinner sunXi SoC support), linux-kernel@vger.kernel.org (open list) Subject: Re: [PATCH v1] thermal: sun8i: extend H6 calibration function to support 4 sensors Message-ID: <20231218111404.5f08a4c4@donnerap.manchester.arm.com> In-Reply-To: <20231217133637.54773-1-bigunclemax@gmail.com> References: <20231217133637.54773-1-bigunclemax@gmail.com> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 17 Dec 2023 16:36:36 +0300 Maksim Kiselev wrote: Hi Maksim, many thanks for sending this! > The H616 SoC resembles the H6 thermal sensor controller, with a few > changes like four sensors. > > Extend sun50i_h6_ths_calibrate() function to support calibration of > these sensors. Oh wow, I didn't expect that, but it's indeed that simple: we just need to cater for the 4th sensor's data to be cramped into the other bits, the rest is exactly the same! Well spotted! > Signed-off-by: Martin Botka > Signed-off-by: Andre Przywara I don't think the Signed-off-by:s are accurate here. Please replace those two with just: Co-developed-by: Martin Botka (I didn't really do anything in those parts) > Signed-off-by: Maksim Kiselev I compared the two routines and came to the same solution as you, so: Reviewed-by: Andre Przywara I will incorporate this patch into the next submission of the H616 THS series, so there is no need to merge this patch as is. Cheers, Andre > --- > drivers/thermal/sun8i_thermal.c | 28 ++++++++++++++++++++-------- > 1 file changed, 20 insertions(+), 8 deletions(-) > > diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c > index f989b55a8aa8..9af95b4785be 100644 > --- a/drivers/thermal/sun8i_thermal.c > +++ b/drivers/thermal/sun8i_thermal.c > @@ -221,16 +221,21 @@ static int sun50i_h6_ths_calibrate(struct ths_device *tmdev, > struct device *dev = tmdev->dev; > int i, ft_temp; > > - if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num) > + if (!caldata[0]) > return -EINVAL; > > /* > * efuse layout: > * > - * 0 11 16 32 > - * +-------+-------+-------+ > - * |temp| |sensor0|sensor1| > - * +-------+-------+-------+ > + * 0 11 16 27 32 43 48 57 > + * +----------+-----------+-----------+-----------+ > + * | temp | |sensor0| |sensor1| |sensor2| | > + * +----------+-----------+-----------+-----------+ > + * ^ ^ ^ > + * | | | > + * | | sensor3[11:8] > + * | sensor3[7:4] > + * sensor3[3:0] > * > * The calibration data on the H6 is the ambient temperature and > * sensor values that are filled during the factory test stage. > @@ -243,9 +248,16 @@ static int sun50i_h6_ths_calibrate(struct ths_device *tmdev, > ft_temp = (caldata[0] & FT_TEMP_MASK) * 100; > > for (i = 0; i < tmdev->chip->sensor_num; i++) { > - int sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK; > - int cdata, offset; > - int sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg); > + int sensor_reg, sensor_temp, cdata, offset; > + > + if (i == 3) > + sensor_reg = (caldata[1] >> 12) > + | ((caldata[2] >> 12) << 4) > + | ((caldata[3] >> 12) << 8); > + else > + sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK; > + > + sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg); > > /* > * Calibration data is CALIBRATE_DEFAULT - (calculated