summaryrefslogtreecommitdiff
path: root/src/mainboard/google/brya/acpi/utility.asl
blob: 4fc03e83e12e22bf28e4c8d3891749e9c9293954 (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
/* SPDX-License-Identifier: GPL-2.0-or-later */

/*
 * Poll a GPIO until it goes to the specified state
 * Arg0 == GPIO #
 * Arg1 == state (0 or 1)
 * Arg2 == timeout in ms
 */
Method (GPPL, 3, Serialized)
{
	Local0 = GRXS (Arg0)
	Local7 = Arg2 * 10000
	Local7 = Timer + Local7
	While (Local0 != Arg1 && Timer < Local7)
	{
		Stall (10)
		Local0 = \_SB.PCI0.GRXS (Arg0)
	}
}

/* Convert from 32-bit integer to 4-byte buffer (little-endian) */
Method (ITOB, 1)
{
	Local0 = Buffer(4) { 0, 0, 0, 0 }
	Local0[0] = Arg0 & 0xFF
	Local0[1] = (Arg0 >> 8) & 0xFF
	Local0[2] = (Arg0 >> 16) & 0xFF
	Local0[3] = (Arg0 >> 24) & 0xFF
	Return (Local0)
}