Angel Pons | 0612b27 | 2020-04-05 15:46:56 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Shaunak Saha | 44887c3 | 2016-06-07 00:05:00 -0700 | [diff] [blame] | 2 | |
| 3 | Device (TCHG) |
| 4 | { |
Sumeet R Pawnikar | 5e53bd5 | 2020-06-01 17:40:08 +0530 | [diff] [blame] | 5 | Name (_HID, DPTF_GEN_DEVICE) |
| 6 | |
Shaunak Saha | 44887c3 | 2016-06-07 00:05:00 -0700 | [diff] [blame] | 7 | Name (_UID, 0) |
| 8 | Name (PTYP, 0x0B) |
| 9 | Name (_STR, Unicode("Battery Charger")) |
| 10 | |
| 11 | Method (_STA) |
| 12 | { |
Felix Singer | 7b8ac00 | 2022-12-26 08:45:56 +0100 | [diff] [blame^] | 13 | If (\DPTE == 1) { |
Shaunak Saha | 44887c3 | 2016-06-07 00:05:00 -0700 | [diff] [blame] | 14 | Return (0xF) |
| 15 | } Else { |
| 16 | Return (0x0) |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | /* Return charger performance states defined by mainboard */ |
| 21 | Method (PPSS) |
| 22 | { |
| 23 | Return (\_SB.CHPS) |
| 24 | } |
| 25 | |
| 26 | /* Return maximum charger current limit */ |
| 27 | Method (PPPC) |
| 28 | { |
| 29 | /* Convert size of PPSS table to index */ |
Alexey Buyanov | 0324803 | 2020-06-01 21:41:14 -0700 | [diff] [blame] | 30 | Local0 = SizeOf (\_SB.CHPS) |
| 31 | Local0-- |
Shaunak Saha | 44887c3 | 2016-06-07 00:05:00 -0700 | [diff] [blame] | 32 | |
| 33 | /* Check if charging is disabled (AC removed) */ |
Alexey Buyanov | 0324803 | 2020-06-01 21:41:14 -0700 | [diff] [blame] | 34 | If (\_SB.PCI0.LPCB.EC0.ACEX == 0) { |
Shaunak Saha | 44887c3 | 2016-06-07 00:05:00 -0700 | [diff] [blame] | 35 | /* Return last power state */ |
| 36 | Return (Local0) |
| 37 | } Else { |
| 38 | /* Return highest power state */ |
| 39 | Return (0) |
| 40 | } |
| 41 | |
| 42 | Return (0) |
| 43 | } |
| 44 | |
| 45 | /* Set charger current limit */ |
| 46 | Method (SPPC, 1) |
| 47 | { |
| 48 | /* Retrieve Control (index 4) for specified PPSS level */ |
Alexey Buyanov | 0324803 | 2020-06-01 21:41:14 -0700 | [diff] [blame] | 49 | Local0 = DeRefOf (DeRefOf (\_SB.CHPS[ToInteger (Arg0)])[4]) |
Shaunak Saha | 44887c3 | 2016-06-07 00:05:00 -0700 | [diff] [blame] | 50 | |
| 51 | /* Pass Control value to EC to limit charging */ |
| 52 | \_SB.PCI0.LPCB.EC0.CHGS (Local0) |
| 53 | } |
| 54 | |
| 55 | /* Initialize charger participant */ |
| 56 | Method (INIT) |
| 57 | { |
| 58 | /* Disable charge limit */ |
| 59 | \_SB.PCI0.LPCB.EC0.CHGD () |
| 60 | } |
| 61 | } |