summaryrefslogtreecommitdiff
path: root/src/mainboard/lenovo/t400/acpi/graphics.asl
blob: 5559bfcfa727952b2b5a501a9b4bc3481a79f19e (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
80
81
82
83
/* SPDX-License-Identifier: GPL-2.0-only */

/* WARNING
 * Switchable graphics not yet tested!
 */

/* Hybrid graphics enable/disable GPIO bitfields */
Name (HYG1, 0x004A0000)
Name (HYG2, 0x00020000)

/* GPIO control port */
Name (GPCP, DEFAULT_GPIOBASE)

/* GPIO control map */
OperationRegion (GPCM, SystemIO, GPCP, 0x3F)
Field (GPCM, ByteAcc, NoLock, Preserve) {
	GPUS, 32,
	GPIS, 32,
	Offset (0x0C),
	GPLV, 32,
	Offset (0x30),
	GQUS, 32,
	GQIS, 32,
	GQLV, 32
}

Method(SHYB, 1) {
	/* Switch hybrid graphics */
	if (Arg0 == One)
	{
		/* Discrete graphics requested */
		GPLV |= HYG1
		GQLV |= HYG2
	}
	else
	{
		/* Integrated graphics requested */
		Local0 = HYG1 ^ 0xFFFFFFFF
		GPLV &= Local0
		Local0 = HYG2 ^ 0xFFFFFFFF
		GQLV &= Local0
	}
}

Method (ATPX, 2, Serialized) {
	/* Create local variables */
	Name (ATPR, Buffer (0x08) {
		0x0, 0x0, 0x0, 0x0,
		0x0, 0x0, 0x0, 0x0
	})
	CreateWordField (ATPR, 0x00, SIZE)
	CreateWordField (ATPR, 0x02, VERS)
	CreateDWordField (ATPR, 0x04, FUNC)

	/* Version request */
	if (Arg0 == 0x0)
	{
		/* Assemble and return version information */
		SIZE = 0x08	/* Response length */
		VERS = 0x01	/* Version number */
		FUNC = 0x0F	/* Supported functions? */
		Return (ATPR)
	}

	/* Mux select */
	if (Arg0 == 0x2)
	{
		CreateByteField (Arg1, 0x02, PWST)
		Local0 = PWST
		Local0 &= 0x01
		If (Local0)
		{
			/* Enable discrete graphics */
			SHYB(0x01)
		}
		else
		{
			/* Enable integrated graphics */
			SHYB(0x00)
		}
	}
	Return(Zero)
}