Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4987945yba; Mon, 13 May 2019 03:27:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrZK6qAmsk1lRRY1eXmbbKxiSB5FfUa2TRsEhwQZKMhRml+HaKKnVcHlgHJNyAEQ/ah7Gj X-Received: by 2002:a62:6582:: with SMTP id z124mr33023538pfb.0.1557743268623; Mon, 13 May 2019 03:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557743268; cv=none; d=google.com; s=arc-20160816; b=LjPvEZtF7nBIbW5x7H4Q+dHxFXbv5Yx01wHHVTqDTg/pZmCVbDO6u5/vb9b+MeSN+1 6SUztero2ljNbpTV/Rhr2Tq+QdhnS3oH6SOeYfpVzpWaeHuw8meHulG5LXptc0fQ3L4J 9ggryWbkVPS4uDMjhIy+U69O6wBft1Y1zvkx8zhYRyKJ3QLeWeD7g2xooE9vh/rTntIF KMqjRKiqWq2D8hfTNiUx2rHlNX/G/+blfYIEyzxFcQ6FDyZ49f0HjEA5nV1/XSOVV8hk 7oaeTGgjFu4B40bbd+kPm0mffB9CIrMG+gRD1RIsCeDkAPrN6q6Ic/EepTJaFQ8D44jV uCWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=KO4CJ3obTcLAGpksPn3CBaK26ppQBgEPx1vQe4/M5Mw=; b=a+e989ZadjuS6EQKQIC8zaaBBDUx0PR4Jev/gD4ZFHeN3BuMK+Xy/Bwpe6OCzdDoPv 0S6Q5k2jaV5GX02qb1QdE/BYmxKGCz/msud+7axcbunOaqi1p+wFvGMp0rDREUG51Wpt CL71a5mtZgQoxYJtDAfhj1IO2y/M9ocsjo+oHWpWL9S064X9thTlof16dOVZICDDb9v+ nbVPyudVvsgDIuQtPRGpa2utKVNsP4APjbj8wwvDplNh7EvJdTPQ/Q8LnJsFQd8F8SBD XF4Y57oChNaBvbddSuk1OrHSAhaBU4fubCdaSzGjt0Jwj5qgVU17DJ/Li7zJj8ppHxyj HFEQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b188si2477528pga.223.2019.05.13.03.27.32; Mon, 13 May 2019 03:27:48 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728780AbfEMKCB convert rfc822-to-8bit (ORCPT + 99 others); Mon, 13 May 2019 06:02:01 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:33309 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728113AbfEMKCA (ORCPT ); Mon, 13 May 2019 06:02:00 -0400 X-Originating-IP: 80.215.106.0 Received: from localhost (unknown [80.215.106.0]) (Authenticated sender: maxime.ripard@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 9B95724000F; Mon, 13 May 2019 10:01:50 +0000 (UTC) Date: Mon, 13 May 2019 12:01:49 +0200 From: Maxime Ripard To: Yangtao Li , rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, catalin.marinas@arm.com, will.deacon@arm.com, davem@davemloft.net, mchehab+samsung@kernel.org, gregkh@linuxfoundation.org, Jonathan.Cameron@huawei.com, nicolas.ferre@microchip.com, paulmck@linux.ibm.com, andy.gross@linaro.org, olof@lixom.net, bjorn.andersson@linaro.org, jagan@amarulasolutions.com, marc.w.gonzalez@free.fr, stefan.wahren@i2se.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: Re: [PATCH 2/3] thermal: sun50i: add thermal driver for h6 Message-ID: <20190513100149.w3uvpnuqql4eqwid@flea> References: <20190512082614.9045-1-tiny.windzz@gmail.com> <20190512082614.9045-3-tiny.windzz@gmail.com> <20190512223955.6lhclj6jr2akmsdx@core.my.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <20190512223955.6lhclj6jr2akmsdx@core.my.home> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 13, 2019 at 12:39:55AM +0200, Ondřej Jirman wrote: > > + /* > > + * clkin = 24MHz > > + * T acquire = clkin / (SUN50I_THS_CTRL0_T_ACQ + 1) > > + * = 20us > > + */ > > + regmap_write(tmdev->regmap, SUN50I_THS_CTRL0, > > + SUN50I_THS_CTRL0_T_ACQ(479)); > > + /* average over 4 samples */ > > + regmap_write(tmdev->regmap, SUN50I_H6_THS_MFC, > > + SUN50I_THS_FILTER_EN | > > + SUN50I_THS_FILTER_TYPE(1)); > > + /* period = (SUN50I_H6_THS_PC_TEMP_PERIOD + 1) * 4096 / clkin; ~10ms */ > > + regmap_write(tmdev->regmap, SUN50I_H6_THS_PC, > > + SUN50I_H6_THS_PC_TEMP_PERIOD(58)); > > Also this math is not all that clear: > > period = (SUN50I_H6_THS_PC_TEMP_PERIOD + 1) * 4096 / clkin; ~10ms > > SUN50I_H6_THS_PC_TEMP_PERIOD is a macro with an argument. So how does > this work? > > Also, related to this, I've noticed that you removed the interrupt > processing from the original driver. Without that you have to make sure > that OF contains non-zero polling-delay and polling-delay-passive. > > Nonzero values are necessary for enabling polling mode of the tz core, > otherwise tz core will not read values periodically from your driver. > > You should documment it in the DT bindings, too. Or keep the interrupt > handling for THS. If there's interrupts for this in the H6, yeah we should use them over polling. Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com