1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2016 Intel Corporation.
4 * Copyright (C) 2016 Google Inc.
5 *
6 */
7
8/* Audio Controller - Device 14, Function 0 */
9
10Device (HDAS)
11{
12	Name (_ADR, 0x000E0000)
13	Name (_DDN, "Audio Controller")
14	Name (UUID, ToUUID("A69F886E-6CEB-4594-A41F-7B5DCE24C553"))
15
16	/* Device is D3 wake capable */
17	Name (_S0W, 3)
18
19	/* NHLT Table Address populated from GNVS values */
20	Name (NBUF, ResourceTemplate() {
21		QWordMemory (ResourceConsumer, PosDecode, MinFixed,
22			MaxFixed, Cacheable, ReadOnly,
23			0, 0, 0, 0, 1,,, NHLT, AddressRangeACPI)
24		}
25	)
26
27	/* can wake up from S3 state */
28	Name (_PRW, Package() { GPE0A_AVS_PME_STS, 3 })
29
30	/*
31	 * Device Specific Method
32	 * Arg0 - UUID
33	 * Arg1 - Revision
34	 * Arg2 - Function Index
35	*/
36	Method (_DSM, 4) {
37		If (LEqual (Arg0, ^UUID)) {
38			/*
39			 * Function 0: Function Support Query
40			 * Returns a bitmask of functions supported.
41			 */
42			If (LEqual (Arg2, Zero)) {
43				/*
44				 * NHLT Query only supported for revision 1 and
45				 * if NHLT address and length are set in NVS.
46				 */
47				If (LAnd (LEqual (Arg1, One),
48					LAnd (LNotEqual (NHLA, Zero),
49					     LNotEqual (NHLL, Zero)))) {
50					Return (Buffer (One) { 0x03 })
51				}
52				Else {
53					Return (Buffer (One) { 0x01 })
54				}
55			}
56
57			/*
58			 * Function 1: Query NHLT memory address used by
59			 * Intel Offload Engine Driver to discover any non-HDA
60			 * devices that are supported by the DSP.
61			 *
62			 * Returns a pointer to NHLT table in memory.
63			 */
64			If (LEqual (Arg2, One)) {
65				CreateQWordField (NBUF, ^NHLT._MIN, NBAS)
66				CreateQWordField (NBUF, ^NHLT._MAX, NMAS)
67				CreateQWordField (NBUF, ^NHLT._LEN, NLEN)
68				Store (NHLA, NBAS)
69				Store (NHLA, NMAS)
70				Store (NHLL, NLEN)
71				Return (NBUF)
72			}
73		}
74
75		Return (Buffer (One) { 0x00 })
76	}
77}
78