blob: 7f4a7ecd36ef80406951d20bba9ad93968807d14 [file] [log] [blame]
Simon Glassca75c3f2020-09-22 12:44:49 -06001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2014 Google Inc.
4 * Copyright (C) 2016 Intel Corporation.
5 */
6
7Device (TCHG)
8{
9 Name (_HID, "INT3403")
10 Name (_UID, 0)
11 Name (PTYP, 0x0B)
12 Name (_STR, Unicode("Battery Charger"))
13
14 Method (_STA)
15 {
16 If (LEqual (\DPTE, One)) {
17 Return (0xF)
18 } Else {
19 Return (0x0)
20 }
21 }
22
23 /* Return charger performance states defined by mainboard */
24 Method (PPSS)
25 {
26 Return (\_SB.CHPS)
27 }
28
29 /* Return maximum charger current limit */
30 Method (PPPC)
31 {
32 /* Convert size of PPSS table to index */
33 Store (SizeOf (\_SB.CHPS), Local0)
34 Decrement (Local0)
35
36 /* Check if charging is disabled (AC removed) */
37 If (LEqual (\_SB.PCI0.LPCB.EC0.ACEX, Zero)) {
38 /* Return last power state */
39 Return (Local0)
40 } Else {
41 /* Return highest power state */
42 Return (0)
43 }
44
45 Return (0)
46 }
47
48 /* Set charger current limit */
49 Method (SPPC, 1)
50 {
51 /* Retrieve Control (index 4) for specified PPSS level */
52 Store (DeRefOf (Index (DeRefOf (Index
53 (\_SB.CHPS, ToInteger (Arg0))), 4)), Local0)
54
55 /* Pass Control value to EC to limit charging */
56 \_SB.PCI0.LPCB.EC0.CHGS (Local0)
57 }
58
59 /* Initialize charger participant */
60 Method (INIT)
61 {
62 /* Disable charge limit */
63 \_SB.PCI0.LPCB.EC0.CHGD ()
64 }
65}