blob: 844f287afb5bee7ef1f44a6d52ac219259ca3517 [file] [log] [blame]
Angel Ponsba38f372020-04-05 15:46:45 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Martin Rothebabfad2016-04-10 11:09:16 -06003
Lee Leahy77ff0b12015-05-05 15:07:29 -07004Device (TCHG)
5{
6 Name (_HID, "INT3403")
7 Name (_UID, 0)
8 Name (PTYP, 0x0B)
9 Name (_STR, Unicode("Battery Charger"))
10
11 Method (_STA)
12 {
13 If (LEqual (\DPTE, One)) {
14 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 */
30 Store (SizeOf (\_SB.CHPS), Local0)
31 Decrement (Local0)
32
33 /* Check if charging is disabled (AC removed) */
Jenny TC01be52e2015-07-24 15:04:06 +053034 If (LEqual (\_SB.PCI0.LPCB.EC0.ACEX, Zero)) {
Lee Leahy77ff0b12015-05-05 15:07:29 -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 */
49 Store (DeRefOf (Index (DeRefOf (Index
50 (\_SB.CHPS, ToInteger (Arg0))), 4)), Local0)
51
52 /* Pass Control value to EC to limit charging */
53 \_SB.PCI0.LPCB.EC0.CHGS (Local0)
54 }
55
56 /* Initialize charger participant */
57 Method (INIT)
58 {
59 /* Disable charge limit */
60 \_SB.PCI0.LPCB.EC0.CHGD ()
61 }
62}