From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.50187.1597691009424868660 for ; Mon, 17 Aug 2020 12:03:29 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: jeremy.linton@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 C343830E; Mon, 17 Aug 2020 12:03:28 -0700 (PDT) Received: from [192.168.122.166] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 863D03F6CF; Mon, 17 Aug 2020 12:03:28 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH 0/3] Platform/RasberryPi: Thermal zone To: devel@edk2.groups.io, ard.biesheuvel@arm.com Cc: Leif Lindholm , Pete Batard , Andrei Warkentin , Samer El-Haj-Mahmoud References: <20200813230056.40526-1-jeremy.linton@arm.com> <7dcba3be-778e-b3d5-20f5-ae0b205dd826@arm.com> From: "Jeremy Linton" Message-ID: Date: Mon, 17 Aug 2020 14:03:28 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <7dcba3be-778e-b3d5-20f5-ae0b205dd826@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi, On 8/17/20 9:31 AM, Ard Biesheuvel via groups.io wrote: > On 8/14/20 1:00 AM, Jeremy Linton wrote: >> This set creates a basic thermal zone, which reads the >> SOC temp via a direct register read in AML. It also >> adds an active cooling policy using a GPIO pin for fan >> control that can optionally be enabled/disabled by the >> user from the BDS. >> >> With the fan enabled it should be possible to see the >> soc temp like: ^ That should have read something like: "Even without the fan enabled it is possible to see the SOC temp like:" >> >> # sensors >> acpitz-acpi-0 >> Adapter: ACPI interface >> temp1:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 +57.6C=C2=A0 (crit =3D= +90.0C) >> >> and the fan state may be read/cycled with: >> >> /sys/bus/acpi/devices/PNP0C06:00/PNP0C0B:00/physical_node/thermal_cooli= ng/cur_state=20 >> >> >> Cc: Leif Lindholm >> Cc: Pete Batard >> Cc: Andrei Warkentin >> Cc: Ard Biesheuvel >> Cc: Samer El-Haj-Mahmoud >> >> Jeremy Linton (3): >> =C2=A0=C2=A0 Platform/RaspberryPi4: Add a basic thermal zone >> =C2=A0=C2=A0 Platform/RaspberryPi4: Create ACPI fan object >> =C2=A0=C2=A0 Platform/RaspberryPi: Add entry for user fan control >> >=20 > I like this code a lot. It is very helpful to have working sample AML=20 > code that implements a thermal zone. Could you elaborate on the=20 > additional components that are needed for this? Is this a standard cape= =20 > (or whatever rpi calls it)? I assume the fan just switches between 0 and= = =20 > max rpm depending on the actual temp wrt the trip point? I've got something similar to this circuit:=20 https://www.raspberrypi.org/forums/viewtopic.php?t=3D194621#p1220502 wired= = =20 up. There are a number of variations on the web=20 (https://www.instructables.com/id/PWM-Regulated-Fan-Based-on-CPU-Temperatu= re-for-Ras/),=20 frequently including python control scripts, which are unnecessary given= =20 this AML/patch. Most of the variation is simply matching an appropriate=20 resistor between the GPIO and transistor base for the given transistor's= =20 gain. A board which implements a similar circuit can be purchased here:=20 https://shop.pimoroni.com/products/fan-shim Most of these circuits are designed for simple On/Off control. So as it=20 stands, the kernel calls the ON() method, when it polls the zone temp,=20 and discovers that it exceeds the active cooling threshold. Or the OFF()= =20 if the temp falls below. The slow polling and large heatsink on my rpi=20 tends to keep it from excessive hunting/cycling since the kernel doesn't= =20 implement much in the way of hysteresis control. The GPIO pin I selected also (AFAIK) has a PWM function that could be=20 leveraged in the future for variable speed control. That said, most of=20 these little 5V fans seem to be basically silent (well the ones I have,=20 or they are 12V already running at low voltage), so there is little=20 advantage to slowing them down. The big variation is which GPIO controls the fan. This patch at the=20 moment has a #define setting the pin, but the general plan was to add=20 some additional user controllable options for board/GPIO pin selection.=20 Originally I was planning on just compiling the ASL multiple times for=20 each GPIO and then picking one at runtime, but now I'm thinking=20 dynamically editing the binary AML before calling InstallTable() on it=20 might be a better choice to reduce bloat. A few of the fan boards/cases implement their own fan controllers with=20 programmable thermal profiles over I2C. This patch won't support those=20 boards. (yet! :) >=20 >=20 >=20 >> =C2=A0 Platform/RaspberryPi/AcpiTables/Dsdt.asl=C2=A0=C2=A0=C2=A0=C2=A0= = =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 31 ++++++++ >> =C2=A0 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 55 ++++++++= ++++++ >> =C2=A0 .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf=C2=A0=C2=A0=C2= =A0 |=C2=A0 3 + >> =C2=A0 .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |=C2=A0 5 ++ >> =C2=A0 .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 17 +++++ >> =C2=A0 .../RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl=C2=A0 | 83=20 >> ++++++++++++++++++++++ >> =C2=A0 Platform/RaspberryPi/Include/ConfigVars.h=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 4 ++ >> =C2=A0 Platform/RaspberryPi/RPi3/RPi3.dsc=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= = =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0= 5 ++ >> =C2=A0 Platform/RaspberryPi/RPi4/RPi4.dsc=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= = =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0= 8 +++ >> =C2=A0 Platform/RaspberryPi/RaspberryPi.dec=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 1 + >> =C2=A0 .../Bcm27xx/Include/IndustryStandard/Bcm2711.h=C2=A0=C2=A0=C2=A0= = =C2=A0 |=C2=A0 2 + >> =C2=A0 11 files changed, 214 insertions(+) >> =C2=A0 create mode 100644=20 >> Platform/RaspberryPi/Drivers/ConfigDxe/SsdtThermal.asl >> >=20 >=20 >=20 >=20