Angel Pons | ba38f37 | 2020-04-05 15:46:45 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Martin Roth | ebabfad | 2016-04-10 11:09:16 -0600 | [diff] [blame] | 3 | |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 4 | Device (TCHG) |
| 5 | { |
| 6 | Name (_HID, "INT3403") |
| 7 | Name (_UID, 0) |
| 8 | Name (PTYP, 0x0B) |
| 9 | Name (_STR, Unicode("Battery Charger")) |
| 10 | |
| 11 | Method (_STA) |
| 12 | { |
| 13 | If (LEqual (\DPTE, One)) { |
| 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 */ |
| 30 | Store (SizeOf (\_SB.CHPS), Local0) |
| 31 | Decrement (Local0) |
| 32 | |
| 33 | /* Check if charging is disabled (AC removed) */ |
Jenny TC | 01be52e | 2015-07-24 15:04:06 +0530 | [diff] [blame] | 34 | If (LEqual (\_SB.PCI0.LPCB.EC0.ACEX, Zero)) { |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -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 */ |
| 49 | Store (DeRefOf (Index (DeRefOf (Index |
| 50 | (\_SB.CHPS, ToInteger (Arg0))), 4)), Local0) |
| 51 | |
| 52 | /* Pass Control value to EC to limit charging */ |
| 53 | \_SB.PCI0.LPCB.EC0.CHGS (Local0) |
| 54 | } |
| 55 | |
| 56 | /* Initialize charger participant */ |
| 57 | Method (INIT) |
| 58 | { |
| 59 | /* Disable charge limit */ |
| 60 | \_SB.PCI0.LPCB.EC0.CHGD () |
| 61 | } |
| 62 | } |