blob: 175338390d0cc1005fe75d43dc1ac7f197ef1169 [file] [log] [blame]
Angel Pons0612b272020-04-05 15:46:56 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Shaunak Saha44887c32016-06-07 00:05:00 -07002
3Device (TCHG)
4{
Sumeet R Pawnikar5e53bd52020-06-01 17:40:08 +05305 Name (_HID, DPTF_GEN_DEVICE)
6
Shaunak Saha44887c32016-06-07 00:05:00 -07007 Name (_UID, 0)
8 Name (PTYP, 0x0B)
9 Name (_STR, Unicode("Battery Charger"))
10
11 Method (_STA)
12 {
Felix Singer7b8ac002022-12-26 08:45:56 +010013 If (\DPTE == 1) {
Shaunak Saha44887c32016-06-07 00:05:00 -070014 Return (0xF)
15 } Else {
16 Return (0x0)
17 }
18 }
19
20 /* Return charger performance states defined by mainboard */
21 Method (PPSS)
22 {
23 Return (\_SB.CHPS)
24 }
25
26 /* Return maximum charger current limit */
27 Method (PPPC)
28 {
29 /* Convert size of PPSS table to index */
Alexey Buyanov03248032020-06-01 21:41:14 -070030 Local0 = SizeOf (\_SB.CHPS)
31 Local0--
Shaunak Saha44887c32016-06-07 00:05:00 -070032
33 /* Check if charging is disabled (AC removed) */
Alexey Buyanov03248032020-06-01 21:41:14 -070034 If (\_SB.PCI0.LPCB.EC0.ACEX == 0) {
Shaunak Saha44887c32016-06-07 00:05:00 -070035 /* Return last power state */
36 Return (Local0)
37 } Else {
38 /* Return highest power state */
39 Return (0)
40 }
41
42 Return (0)
43 }
44
45 /* Set charger current limit */
46 Method (SPPC, 1)
47 {
48 /* Retrieve Control (index 4) for specified PPSS level */
Alexey Buyanov03248032020-06-01 21:41:14 -070049 Local0 = DeRefOf (DeRefOf (\_SB.CHPS[ToInteger (Arg0)])[4])
Shaunak Saha44887c32016-06-07 00:05:00 -070050
51 /* Pass Control value to EC to limit charging */
52 \_SB.PCI0.LPCB.EC0.CHGS (Local0)
53 }
54
55 /* Initialize charger participant */
56 Method (INIT)
57 {
58 /* Disable charge limit */
59 \_SB.PCI0.LPCB.EC0.CHGD ()
60 }
61}