blob: 44e40646b7416d38733c9d5dcecde1771266bb96 [file] [log] [blame]
Angel Ponsc3f58f62020-04-05 15:46:41 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Rothebabfad2016-04-10 11:09:16 -06002
Duncan Lauriead8d9132013-12-10 07:41:33 -08003Device (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) {
Duncan Lauriead8d9132013-12-10 07:41:33 -080013 Return (0xF)
14 } Else {
15 Return (0x0)
16 }
17 }
18
Aaron Durbin4177db52014-02-05 14:55:26 -060019 /* Return charger performance states defined by mainboard */
20 Method (PPSS)
Duncan Lauriead8d9132013-12-10 07:41:33 -080021 {
Aaron Durbin4177db52014-02-05 14:55:26 -060022 Return (\_SB.CHPS)
23 }
Duncan Lauriead8d9132013-12-10 07:41:33 -080024
Aaron Durbin4177db52014-02-05 14:55:26 -060025 /* Return maximum charger current limit */
Duncan Lauriead8d9132013-12-10 07:41:33 -080026 Method (PPPC)
27 {
Aaron Durbin4177db52014-02-05 14:55:26 -060028 /* Convert size of PPSS table to index */
Felix Singer476fe6a2022-12-12 07:30:07 +010029 Local0 = SizeOf (\_SB.CHPS)
Felix Singer43b57302022-12-11 21:46:42 +010030 Local0--
Aaron Durbin4177db52014-02-05 14:55:26 -060031
32 /* Check if charging is disabled (AC removed) */
Felix Singer9df60d32022-12-26 09:43:07 +010033 If (\PWRS == 0) {
Aaron Durbin4177db52014-02-05 14:55:26 -060034 /* Return last power state */
35 Return (Local0)
36 } Else {
37 /* Return highest power state */
38 Return (0)
39 }
40
Duncan Lauriead8d9132013-12-10 07:41:33 -080041 Return (0)
42 }
43
Aaron Durbin4177db52014-02-05 14:55:26 -060044 /* Set charger current limit */
45 Method (SPPC, 1)
Duncan Lauriead8d9132013-12-10 07:41:33 -080046 {
Aaron Durbin4177db52014-02-05 14:55:26 -060047 /* Retrieve Control (index 4) for specified PPSS level */
Elyes Haouasf451bfb2022-12-25 06:29:39 +010048 Local0 = DerefOf (DerefOf (\_SB.CHPS[ToInteger (Arg0)])[4])
Aaron Durbin4177db52014-02-05 14:55:26 -060049
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 ()
Duncan Lauriead8d9132013-12-10 07:41:33 -080059 }
60}