X86 platform drivers
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: John Martens <john.martens4@proton.me>,
	"platform-driver-x86@vger.kernel.org" 
	<platform-driver-x86@vger.kernel.org>,
	"ike.pan@canonical.com" <ike.pan@canonical.com>
Subject: Re: New Lenovo Legion Fan, Temperature, Power Mode Driver
Date: Thu, 12 Jan 2023 20:07:50 +0100	[thread overview]
Message-ID: <a41ebfef-e589-dbff-c93c-eb7c197d28f0@redhat.com> (raw)
In-Reply-To: <cchW8yA1BnN-yMnXp0EY8oKubzPC721jNMylHVzSVuf5C0YAhC7gYkSjhxIpZMv7K9hMw4ezLbxGEtEd7Gs_bAIoDizRSQG2V3Ql5nl5G_0=@proton.me>

Hi John,

On 1/10/23 14:26, John Martens wrote:
> Dear Kernel devs, Mr. Hans de Goede, Mr. Ike Panhc,
> 
> I am currently working on a driver for fan control, fan speed, temperature sensors, and power mode (platform profile) for Lenovo Legion Laptops. Switching iGPU/dGPU could also be possible. It is a port of the closed and open tools in Windows LenovoLegionToolkit, Vantage, LegionFanControl. I am testing it on different laptops with the help of a forum/chat and its working quite good.

Thank you for reaching out. I'm currently catching up with
quite a big patch/bug backlog after being on holiday for
2 weeks. I'll get back to you on this, but please give
me some time.

If you have not heard back from me in 2 weeks, feel free
to ping me about this.

Regards,

Hans

 


> 
> There is a README (https://github.com/johnfanv2/LenovoLegionLinux) and code (https://github.com/johnfanv2/LenovoLegionLinux/blob/main/kernel_module/legion-laptop.c).
> 
> I would be interested to get your opinion.
> 
> Questions
> 
> Should this extend ideapad_laptop.c or a new file?
>     - pro:
>         - both access parts of the same hardware
>     - con:
>         - both files are already quite large
>         - it only works on Lenovo Legion laptops that have this 
>           custom control firmware in the embedded controller (EC)
>         - there is almost no reuse of code
> 
> Which method do you prefer writing to EC memory for older models? With ioremap or outb? 
>     - To use ioremap one needs to get the start address. It is
>       different on Intel vs AMD. It is the same as a OperationRegion
>       in the ACPI tables, e.g. "OperationRegion (ERAX, SystemMemory,  
>       0xFE00D400, 0xFF)". However, I have found no kernel functions  
>       to get the address (here 0xFE00D400) of a  OperationRegion.  
>       One could also hardcode it for each model/firmware.
>     - alternative (which I am currently using) is sending commands    
>       to IO ports 0x4E/0x4F (Super IO controller). 
> 
> Background
> 
> The laptops come with an embedded controller (EC) from ITE. These usually come with a 3 point fan curve in ROM, but also can be flashed with a small additional custom program. Lenovo implemented implemented a 10 point fan curve. The program is also shipped with each EFI update.
> 
> The fan curve can be edited by writing to some memory locations in the EC. These locations are
> 
> The driver works by:
> - directly writing/reading embedded controller memory
>     - older models (2020-2021): there are two possibilities
>         - the EC memory is already memory mapped, so one can 
>           use ioremap
>         - one can use outb/inb and write sequenc of commands to 
>           port 0x43, 0x4F (super IO ports)
>         - ideapad_laptop.c writes to some parts of EC memory 
>           with ACPI methods VPCR, VPCW. However, these do not seem  
>           to work in the memory region with the fan curve.
>     - newer models (2022): these provide ACPI/WMI methods  
>       setFanCurve/getFanCurve to write to these regions. However, I  
>       have implemented that and have no models for testing
> 
> The driver works for the models 2020-2022. The code layout is heavily inspired by the ideapad_laptop driver.
> 
> Best regards,
> 
> John Martens
> 


  reply	other threads:[~2023-01-12 19:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 13:26 New Lenovo Legion Fan, Temperature, Power Mode Driver John Martens
2023-01-12 19:07 ` Hans de Goede [this message]
2023-01-30 14:35   ` john.martens.linux
2023-02-02 14:44 ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a41ebfef-e589-dbff-c93c-eb7c197d28f0@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=ike.pan@canonical.com \
    --cc=john.martens4@proton.me \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox