blob: 51c0e1df5bf82b082ff6fc717be4093f2eb7b90c [file] [log] [blame]
Martin Rothebabfad2016-04-10 11:09:16 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; version 2 of
7 * the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
Lee Leahy77ff0b12015-05-05 15:07:29 -070015Device (TCHG)
16{
17 Name (_HID, "INT3403")
18 Name (_UID, 0)
19 Name (PTYP, 0x0B)
20 Name (_STR, Unicode("Battery Charger"))
21
22 Method (_STA)
23 {
24 If (LEqual (\DPTE, One)) {
25 Return (0xF)
26 } Else {
27 Return (0x0)
28 }
29 }
30
31 /* Return charger performance states defined by mainboard */
32 Method (PPSS)
33 {
34 Return (\_SB.CHPS)
35 }
36
37 /* Return maximum charger current limit */
38 Method (PPPC)
39 {
40 /* Convert size of PPSS table to index */
41 Store (SizeOf (\_SB.CHPS), Local0)
42 Decrement (Local0)
43
44 /* Check if charging is disabled (AC removed) */
Jenny TC01be52e2015-07-24 15:04:06 +053045 If (LEqual (\_SB.PCI0.LPCB.EC0.ACEX, Zero)) {
Lee Leahy77ff0b12015-05-05 15:07:29 -070046 /* Return last power state */
47 Return (Local0)
48 } Else {
49 /* Return highest power state */
50 Return (0)
51 }
52
53 Return (0)
54 }
55
56 /* Set charger current limit */
57 Method (SPPC, 1)
58 {
59 /* Retrieve Control (index 4) for specified PPSS level */
60 Store (DeRefOf (Index (DeRefOf (Index
61 (\_SB.CHPS, ToInteger (Arg0))), 4)), Local0)
62
63 /* Pass Control value to EC to limit charging */
64 \_SB.PCI0.LPCB.EC0.CHGS (Local0)
65 }
66
67 /* Initialize charger participant */
68 Method (INIT)
69 {
70 /* Disable charge limit */
71 \_SB.PCI0.LPCB.EC0.CHGD ()
72 }
73}