limit chargin of a lenovo ideapad

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
charroo
Level 5
Level 5
Posts: 507
Joined: Mon Aug 14, 2017 9:45 am
Location: ISRAEL!

limit chargin of a lenovo ideapad

Post by charroo »

i'm trying to follows this:
https://askubuntu.com/questions/34452/h ... 0-capacity

but when i'm entering this command i get-

Code: Select all

sudo modprobe tp_smapi
https://imgur.com/wGfSQED

what should i do?

thanks
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
i'm on Linux Mint 21.3 Cinnamon
User avatar
thx-1138
Level 8
Level 8
Posts: 2092
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: limit chargin of a lenovo ideapad

Post by thx-1138 »

...tp_smapi => Thinkpad(s), Thinkpad ≠ Ideapad
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: limit chargin of a lenovo ideapad

Post by rene »

The answer here may be useful: https://askubuntu.com/questions/385669/ ... tery-limit.

Only someone with the actual hardware can test (and following the "thanks to this thread" link for more information may need Google Translate when getting to more detailed information) so if the locations/values aren't exactly right for your model you'll need to experiment yourself. Looks like it'll do the trick though...

Note that you'll need apt install acpi-call and sudo modprobe acpi_call.
User avatar
thx-1138
Level 8
Level 8
Posts: 2092
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: limit chargin of a lenovo ideapad

Post by thx-1138 »

rene wrote: Mon Jan 21, 2019 3:50 am............................
...absolutely great find rene (as usually, thank you good sir) -
& of course i had to play around with it asap under my Ideapad 300-17ISK :)

apt install acpi-call-dkms
sudo modprobe acpi_call
cat /sys/class/power_supply/BAT*/capacity (currently 100%)
ls /sys/class/power_supply/ (returns BAT0 here...just to be certain, as the github script has BAT1 hardcoded)

Let's push the button & launch the photon torpedoes... :mrgreen:
sudo su && echo '\_SB.PCI0.LPCB.EC0.VPC0.SBMC 4' > /proc/acpi/call
cat /sys/class/power_supply/BAT0/capacity => 100
echo '\_SB.PCI0.LPCB.EC0.VPC0.SBMC 3' > /proc/acpi/call => 94 (bingo!)
echo '\_SB.PCI0.LPCB.EC0.VPC0.SBMC 2' > /proc/acpi/call => 94 again, hmmm...
echo '\_SB.PCI0.LPCB.EC0.VPC0.SBMC 1' > /proc/acpi/call => once again 94, damn... :|

Seems to be even more depended on what kind of Ideapad someone has at first glance...
Will try to further fiddle with it / read more in the russian forum.
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: limit chargin of a lenovo ideapad

Post by rene »

I should preferably furthermore stay out of this, not having the hardware to fiddle around with, but are you sure that that 94 should be changing there? Looks like a current charge, with the system simply not charging further than the percentage as set via \_SB.PCI0.LPCB.EC0.VPC0.SBMC 3. That is, would you not need to discharge, and then check if after echoing that percentage-value a recharge ever gets above said percentage?

Well. Anyways. Shall butt out; it's good that you can test...
User avatar
thx-1138
Level 8
Level 8
Posts: 2092
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: limit chargin of a lenovo ideapad

Post by thx-1138 »

Hmmm, not sure, still trying to figure it out.
I did find by googling that such should work on Ideapad 720s as well besides Yoga models.

However, there's no question that it is..."launch photon torpedoes" though :lol:
On the russian forums, they say:
SBMC 0 > Charging canceled.
SBMC 1 > Charging started.
SBMC 2 > Looks like no effect.
SBMC 3 > Again no effect.
SBMC 4 > Discharge.
SBMC 5 > Charging started.
SBMC 6 > No effect.

This battery here has 88.4% capacity when fully charged, lasts around 5h 20 mins with a few tweaks.
After the above (last command was SBMC 1), percentage started to...drop while still being plugged-in.
Approx merely an 1 hr later, and upower -i /org/freedesktop/UPower/devices/battery_BAT0 reports:
state: charging
percentage: 1%
capacity: 88,4295%
So it appears that a full cycle discharge (& recharge?) has been initiated?
'Reporting' has stayed at 1% for quite some time as well,
and dmesg did returned some ACPI errors after running such as well, which isn't exactly encouraging. :?
I certainly have to fiddle further with it, and if i don't figure it out, i'll just remove & reset the battery altogether.
Last edited by thx-1138 on Mon Jan 21, 2019 7:57 am, edited 1 time in total.
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: limit chargin of a lenovo ideapad

Post by rene »

Your link is 404 for me, but if we retreat to the original link for Ideapad U430, I believe you may want to try writing 5 now so as to get the thing recharging up to 100% again; according to it, 3 for 50-60%: https://askubuntu.com/questions/385669/ ... tery-limit
User avatar
thx-1138
Level 8
Level 8
Posts: 2092
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: limit chargin of a lenovo ideapad

Post by thx-1138 »

Thanks. And 720s link fixed (not that it says much though)...
User avatar
thx-1138
Level 8
Level 8
Posts: 2092
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: limit chargin of a lenovo ideapad

Post by thx-1138 »

...just stumbled upon this. And ideapad-laptop.c says:

Code: Select all

BMCMD_CONSERVATION_ON = 3,
BMCMD_CONSERVATION_OFF = 5,
...........................
ret = method_int1(priv->adev->handle, "SBMC", state ?
					      BMCMD_CONSERVATION_ON :
BMCMD_CONSERVATION_OFF);
Didn't fiddled with it (conservation_mode returns 0 here currently)...
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: limit chargin of a lenovo ideapad

Post by rene »

Ah, I see. To OP: seems then that you can invoke battery conservation mode simply with

Code: Select all

echo 1 >/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
and same with 0 to disable again. The VPC2004:00 string looks like it might be different for different systems, and you'll possibly need a sudo modprobe ideapad-laptop first if the module doesn't autoload for you (it probably does on an actual ideapad...)
User avatar
thx-1138
Level 8
Level 8
Posts: 2092
Joined: Fri Mar 10, 2017 12:15 pm
Location: Athens, Greece

Re: limit chargin of a lenovo ideapad

Post by thx-1138 »

Got it - working with the acpi_call method: in this 300-17ISK,
SBMC 0 set it to charge until exactly 60%, SBMC 1 (re-)set the capacity to 100%

It's certainly not the same value that does the trick under all Lenovos thereby -
should have figured the 0 & 1 values here out earlier, both from the reports in the russian forum,
and also since the github script guy above had got it working with 4 & 5 under Lenovo G580,
which is neither a Yoga neither an Ideapad variant...

What made it more complicated is the fact that the laptop was already 100% charged,
when i issued (multiple) calls to acpi in a short fraction of time - that was certainly not a good idea...
Ie. exactly as you said in the first place, "would you not need to discharge, and then check if after echoing"...
0 & 1 worked just fine after the battery had been discharged enough.
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: limit chargin of a lenovo ideapad

Post by rene »

Great. Given unknown expertise, summarising for OP:

Although the method itself seems same for multiple Lenovo models, exactly which values do what are apparently model specific. thx-1138 has just now on his Ideapad 300 tested that, after apt install acpi-call and sudo modprobe acpi_call,

Code: Select all

echo '\_SB.PCI0.LPCB.EC0.VPC0.SBMC 0' >/proc/acpi/call
and

Code: Select all

echo '\_SB.PCI0.LPCB.EC0.VPC0.SBMC 1' >/proc/acpi/call
works to set the charging limit to 60% respectively 100%. You need to test by draining the battery to under 60% and then seeing if a recharge ever gets above 60% after setting that limit.

For other models it seems that the values to echo are not 0 resp. 1 but 3 resp. 5; if the former pair doesn't work on your model, try latter. If that does work there's a somewhat more well-defined method available as (sudo modprobe ideapad-laptop if needed and)

Code: Select all

echo 1 >/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
and same with 0 to enable resp. disable the conservation mode, i.e., to set the 60% resp 100% charging limit. The VCP2004:00 part looks like it might be different per model (no idea... pad, haha); just check the /sys/bus/platform/drivers/ideapad_acpi directory.

Once you tested any of this to in fact be functional you/we can turn this into an alias or script -- although there may not be a pressing need if you always want conservation mode enabled.
Locked

Return to “Hardware Support”