blob: 6fe8badfd5f0e6ad1cd321446ad551202e471dc0 [file] [log] [blame]
Angel Ponsba38f372020-04-05 15:46:45 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Rothebabfad2016-04-10 11:09:16 -06002
Lee Leahy77ff0b12015-05-05 15:07:29 -07003Device (TCHG)
4{
5 Name (_HID, "INT3403")
6 Name (_UID, 0)
7 Name (PTYP, 0x0B)
8 Name (_STR, Unicode("Battery Charger"))
9
10 Method (_STA)
11 {
12 If (LEqual (\DPTE, One)) {
13 Return (0xF)
14 } Else {
15 Return (0x0)
16 }
17 }
18
19 /* Return charger performance states defined by mainboard */
20 Method (PPSS)
21 {
22 Return (\_SB.CHPS)
23 }
24
25 /* Return maximum charger current limit */
26 Method (PPPC)
27 {
28 /* Convert size of PPSS table to index */
29 Store (SizeOf (\_SB.CHPS), Local0)
Felix Singer43b57302022-12-11 21:46:42 +010030 Local0--
Lee Leahy77ff0b12015-05-05 15:07:29 -070031
32 /* Check if charging is disabled (AC removed) */
Jenny TC01be52e2015-07-24 15:04:06 +053033 If (LEqual (\_SB.PCI0.LPCB.EC0.ACEX, Zero)) {
Lee Leahy77ff0b12015-05-05 15:07:29 -070034 /* Return last power state */
35 Return (Local0)
36 } Else {
37 /* Return highest power state */
38 Return (0)
39 }
40
41 Return (0)
42 }
43
44 /* Set charger current limit */
45 Method (SPPC, 1)
46 {
47 /* Retrieve Control (index 4) for specified PPSS level */
48 Store (DeRefOf (Index (DeRefOf (Index
49 (\_SB.CHPS, ToInteger (Arg0))), 4)), Local0)
50
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}