blob: 4af55fb0dc1b451026188566aa6233add466198b [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
Duncan Lauriead8d9132013-12-10 07:41:33 -080015Device (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
Aaron Durbin4177db52014-02-05 14:55:26 -060031 /* Return charger performance states defined by mainboard */
32 Method (PPSS)
Duncan Lauriead8d9132013-12-10 07:41:33 -080033 {
Aaron Durbin4177db52014-02-05 14:55:26 -060034 Return (\_SB.CHPS)
35 }
Duncan Lauriead8d9132013-12-10 07:41:33 -080036
Aaron Durbin4177db52014-02-05 14:55:26 -060037 /* Return maximum charger current limit */
Duncan Lauriead8d9132013-12-10 07:41:33 -080038 Method (PPPC)
39 {
Aaron Durbin4177db52014-02-05 14:55:26 -060040 /* 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) */
45 If (LEqual (\PWRS, Zero)) {
46 /* Return last power state */
47 Return (Local0)
48 } Else {
49 /* Return highest power state */
50 Return (0)
51 }
52
Duncan Lauriead8d9132013-12-10 07:41:33 -080053 Return (0)
54 }
55
Aaron Durbin4177db52014-02-05 14:55:26 -060056 /* Set charger current limit */
57 Method (SPPC, 1)
Duncan Lauriead8d9132013-12-10 07:41:33 -080058 {
Aaron Durbin4177db52014-02-05 14:55:26 -060059 /* 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 ()
Duncan Lauriead8d9132013-12-10 07:41:33 -080072 }
73}