Angel Pons | c3f58f6 | 2020-04-05 15:46:41 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | ebabfad | 2016-04-10 11:09:16 -0600 | [diff] [blame] | 2 | |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 3 | Device (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 Singer | 7b8ac00 | 2022-12-26 08:45:56 +0100 | [diff] [blame] | 12 | If (\DPTE == 1) { |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 13 | Return (0xF) |
| 14 | } Else { |
| 15 | Return (0x0) |
| 16 | } |
| 17 | } |
| 18 | |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 19 | /* Return charger performance states defined by mainboard */ |
| 20 | Method (PPSS) |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 21 | { |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 22 | Return (\_SB.CHPS) |
| 23 | } |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 24 | |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 25 | /* Return maximum charger current limit */ |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 26 | Method (PPPC) |
| 27 | { |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 28 | /* Convert size of PPSS table to index */ |
Felix Singer | 476fe6a | 2022-12-12 07:30:07 +0100 | [diff] [blame] | 29 | Local0 = SizeOf (\_SB.CHPS) |
Felix Singer | 43b5730 | 2022-12-11 21:46:42 +0100 | [diff] [blame] | 30 | Local0-- |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 31 | |
| 32 | /* Check if charging is disabled (AC removed) */ |
Felix Singer | 26c7672 | 2022-12-11 21:15:05 +0100 | [diff] [blame] | 33 | If (\PWRS == Zero) { |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 34 | /* Return last power state */ |
| 35 | Return (Local0) |
| 36 | } Else { |
| 37 | /* Return highest power state */ |
| 38 | Return (0) |
| 39 | } |
| 40 | |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 41 | Return (0) |
| 42 | } |
| 43 | |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 44 | /* Set charger current limit */ |
| 45 | Method (SPPC, 1) |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 46 | { |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 47 | /* Retrieve Control (index 4) for specified PPSS level */ |
Elyes Haouas | f451bfb | 2022-12-25 06:29:39 +0100 | [diff] [blame] | 48 | Local0 = DerefOf (DerefOf (\_SB.CHPS[ToInteger (Arg0)])[4]) |
Aaron Durbin | 4177db5 | 2014-02-05 14:55:26 -0600 | [diff] [blame] | 49 | |
| 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 Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 59 | } |
| 60 | } |