aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel/tigerlake/acpi/camera_clock_ctl.asl
blob: ab1097e274a7717501b661e3c7cc34489dba9d92 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2020 Intel Corp.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#define R_ICLK_PCR_CAMERA1	0x8000
#define B_ICLK_PCR_FREQUENCY	0x1
#define B_ICLK_PCR_REQUEST	0x2

Scope (\_SB.PCI0) {
	/* IsCLK PCH register for clock settings */
	OperationRegion (ICLK, SystemMemory, PCRB (PID_ISCLK) + R_ICLK_PCR_CAMERA1, 0x40)
	Field (ICLK, AnyAcc, Lock, Preserve)
	{
		CLK1, 8,
		Offset(0x0C),
		CLK2, 8,
		Offset(0x18),
		CLK3, 8,
		Offset(0x24),
		CLK4, 8,
		Offset(0x30),
		CLK5, 8,
		Offset(0x3C),
		CLK6, 8,
	}

	/*
	 * Helper function for Read And OR Write
	 * Arg0 : source and destination
	 * Arg1 : And data
	 * Arg2 : Or data
	 */
	Method (RAOW, 0x3, NotSerialized)
	{
		Local0 = Arg0
		Arg0 = Local0 & Arg1 | Arg2
	}

	/*
	 * Clock Control
	 * Arg0 - Clock number (0:IMGCLKOUT_0, etc)
	 * Arg1 - Desired state (0:Disable, 1:Enable)
	 */
	Method(CLKC, 0x2, NotSerialized)
	{

		Switch (ToInteger (Arg0))
		{
			Case (0)
			{
				RAOW (CLK1, ~B_ICLK_PCR_REQUEST, Arg1 << 1)
			}
			Case (1)
			{
				RAOW (CLK2, ~B_ICLK_PCR_REQUEST, Arg1 << 1)
			}
			Case (2)
			{
				RAOW (CLK3, ~B_ICLK_PCR_REQUEST, Arg1 << 1)
			}
			Case (3)
			{
				RAOW (CLK4, ~B_ICLK_PCR_REQUEST, Arg1 << 1)
			}
			Case (4)
			{
				RAOW (CLK5, ~B_ICLK_PCR_REQUEST, Arg1 << 1)
			}
			Case (5)
			{
				RAOW (CLK6, ~B_ICLK_PCR_REQUEST, Arg1 << 1)
			}
		}
	}

	/*
	 * Clock Frequency
	 * Arg0 - Clock number (0:IMGCLKOUT_0, etc)
	 * Arg1 - Clock frequency (0:24MHz, 1:19.2MHz)
	 */
	Method (CLKF, 0x2, NotSerialized)
	{
		Switch (ToInteger (Arg0))
		{
			Case (0)
			{
				RAOW (CLK1, ~B_ICLK_PCR_FREQUENCY, Arg1)
			}
			Case (1)
			{
				RAOW (CLK2, ~B_ICLK_PCR_FREQUENCY, Arg1)
			}
			Case (2)
			{
				RAOW (CLK3, ~B_ICLK_PCR_FREQUENCY, Arg1)
			}
			Case (3)
			{
				RAOW (CLK4, ~B_ICLK_PCR_FREQUENCY, Arg1)
			}
			Case (4)
			{
				RAOW (CLK5, ~B_ICLK_PCR_FREQUENCY, Arg1)
			}
			Case (5)
			{
				RAOW (CLK6, ~B_ICLK_PCR_FREQUENCY, Arg1)
			}
		}
	}

	/*
	 * Clock control Method
	 * Arg0: Clock source select(0: IMGCLKOUT_0, 1: IMGCLKOUT_1, 2: IMGCLKOUT_2, 3: IMGCLKOUT_3,
	 *                           4: IMGCLKOUT_4, 5: IMGCLKOUT_5)
	 * Arg1: Clock Enable / Disable (0: Disable, 1: Enable)
	 * Arg2: Select 24MHz / 19.2 MHz (0: 24MHz, 1: 19.2MHz)
	 */
	Method (MCCT, 0x3, NotSerialized)
	{
		CLKF (Arg0, Arg2)
		CLKC (Arg0, Arg1)
	}
}