summaryrefslogtreecommitdiffstats
path: root/src/mainboard/google/cyan/variants/terra/include/variant/acpi/charger.asl
blob: 98e7b7d09719db64ff2cbb2761ee91bdfac7da77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* SPDX-License-Identifier: GPL-2.0-only */

Device (TCHG)
{
	Name (_HID, "INT3403")
	Name (_UID, 0)
	Name (PTYP, 0x0B)
	Name (_STR, Unicode("Battery Charger"))

	Method (_STA)
	{
		If (LEqual (\DPTE, One)) {
			Return (0xF)
		} Else {
			Return (0x0)
		}
	}

	/* Return charger performance states defined by Terra2 or Terra3 mainboard */
	Method (PPSS)
	{
		If (LEqual (\_SB.GPID, TERRA2_PROJECT_ID))
		{
			Return (\_SB.CPT2)
		} Else {
			Return (\_SB.CPT3)
		}
	}

	/* Return maximum charger current limit */
	Method (PPPC)
	{
		/* Convert size of PPSS table to index */
		If (LEqual (\_SB.GPID, TERRA2_PROJECT_ID))
		{
			Store (SizeOf (\_SB.CPT2), Local0)
		} Else {
			Store (SizeOf (\_SB.CPT3), Local0)
		}

		Decrement (Local0)

		/* Check if charging is disabled (AC removed) */
		If (LEqual (\_SB.PCI0.LPCB.EC0.ACEX, Zero)) {
			/* Return last power state */
			Return (Local0)
		} Else {
			/* Return highest power state */
			Return (0)
		}

		Return (0)
	}

	/* Set charger current limit */
	Method (SPPC, 1)
	{
		/* Retrieve Control (index 4) for specified PPSS level */
		/* Convert size of PPSS table to index */
		If (LEqual (\_SB.GPID, TERRA2_PROJECT_ID))
		{
			Store (DeRefOf (Index (DeRefOf (Index
				(\_SB.CPT2, ToInteger (Arg0))), 4)), Local0)
		} Else {
			Store (DeRefOf (Index (DeRefOf (Index
				(\_SB.CPT3, ToInteger (Arg0))), 4)), Local0)
		}

		/* Pass Control value to EC to limit charging */
		\_SB.PCI0.LPCB.EC0.CHGS (Local0)
	}

	/* Initialize charger participant */
	Method (INIT)
	{
		/* Disable charge limit */
		\_SB.PCI0.LPCB.EC0.CHGD ()
	}
}