Angel Pons | ba38f37 | 2020-04-05 15:46:45 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | ebabfad | 2016-04-10 11:09:16 -0600 | [diff] [blame] | 2 | |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [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) { |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 13 | 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 Singer | 84e6123 | 2022-12-12 07:39:15 +0100 | [diff] [blame] | 29 | Local0 = SizeOf (\_SB.CHPS) |
Felix Singer | 43b5730 | 2022-12-11 21:46:42 +0100 | [diff] [blame] | 30 | Local0-- |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 31 | |
| 32 | /* Check if charging is disabled (AC removed) */ |
Felix Singer | 9df60d3 | 2022-12-26 09:43:07 +0100 | [diff] [blame^] | 33 | If (\_SB.PCI0.LPCB.EC0.ACEX == 0) { |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 34 | /* 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 Haouas | ffc0d24 | 2022-12-25 06:01:09 +0100 | [diff] [blame] | 48 | Local0 = DerefOf (DerefOf (\_SB.CHPS[ToInteger (Arg0)])[4]) |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [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 () |
| 59 | } |
| 60 | } |