blob: 0c9b3f51d2f0c96591072a470ae72fae529129fd [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 {
Felix Singer7b8ac002022-12-26 08:45:56 +010012 If (\DPTE == 1) {
Lee Leahy77ff0b12015-05-05 15:07:29 -070013 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 */
Felix Singer84e61232022-12-12 07:39:15 +010029 Local0 = SizeOf (\_SB.CHPS)
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) */
Felix Singer9df60d32022-12-26 09:43:07 +010033 If (\_SB.PCI0.LPCB.EC0.ACEX == 0) {
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 */
Elyes Haouasffc0d242022-12-25 06:01:09 +010048 Local0 = DerefOf (DerefOf (\_SB.CHPS[ToInteger (Arg0)])[4])
Lee Leahy77ff0b12015-05-05 15:07:29 -070049
50 /* Pass Control value to EC to limit charging */
51 \_SB.PCI0.LPCB.EC0.CHGS (Local0)
52 }
53
54 /* Initialize charger participant */
55 Method (INIT)
56 {
57 /* Disable charge limit */
58 \_SB.PCI0.LPCB.EC0.CHGD ()
59 }
60}