1/* SPDX-License-Identifier: GPL-2.0-only */
2
3Scope (\_SB.PCI0.IPU0)
4{
5	Name (_DSD, Package (0x02)  /* _DSD: Device-Specific Data */
6	{
7		ToUUID ("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
8		Package (0x02)
9		{
10			Package (0x02)
11			{
12				"port0",
13				"PRT0"
14			},
15			Package (0x02)
16			{
17				"port1",
18				"PRT1"
19			}
20		}
21	})
22
23	Name (PRT0, Package (0x04)
24	{
25		ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
26		Package (0x01)
27		{
28			Package (0x02)
29			{
30				"port",
31				5
32			}
33		},
34		ToUUID ("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
35		Package (0x01)
36		{
37			Package (0x02)
38			{
39				"endpoint0",
40				"EP00"
41			}
42		}
43	})
44
45	Name (PRT1, Package (0x04)
46	{
47		ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
48		Package (0x01)
49		{
50			Package (0x02)
51			{
52				"port",
53				1
54			}
55		},
56
57		ToUUID ("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
58		Package (0x01)
59		{
60			Package (0x02)
61			{
62				"endpoint0",
63				"EP10"
64			}
65		}
66	})
67}
68
69Scope (\_SB.PCI0.IPU0)
70{
71	Name (EP00, Package (0x02)
72	{
73		ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
74		Package (0x04)
75		{
76			Package (0x02)
77			{
78				"endpoint",
79				0
80			},
81			Package (0x02)
82			{
83				"clock-lanes",
84				0
85			},
86			Package (0x02)
87			{
88				"data-lanes",
89				Package (0x04)
90				{
91					1,
92					0x02,
93					0x03,
94					0x04
95				}
96			},
97			Package (0x02)
98			{
99				"remote-endpoint",
100				Package (0x03)
101				{
102					^I2C3.CAM0,
103					0,
104					0
105				}
106			}
107		}
108	})
109	Name (EP10, Package (0x02)
110	{
111		ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
112		Package (0x04)
113		{
114			Package (0x02)
115			{
116				"endpoint",
117				0
118			},
119			Package (0x02)
120			{
121				"clock-lanes",
122				0
123			},
124			Package (0x02)
125			{
126				"data-lanes",
127				Package (0x02)
128				{
129					1,
130					0x02
131				}
132			},
133			Package (0x02)
134			{
135				"remote-endpoint",
136				Package (0x03)
137				{
138					^I2C2.CAM1,
139					0,
140					0
141				}
142			}
143		}
144	})
145}
146
147Scope (\_SB.PCI0.I2C3)
148{
149	/* Reference counter to track power control by RCAM and VCM */
150	Name (REFC, 0)
151	PowerResource (RCPR, 0x00, 0x0000)
152	{
153		Name (STA, 0)
154		Method (_ON, 0, Serialized)  /* Rear camera_ON_: Power On */
155		{
156			/* Enable IMG_CLK */
157			MCON(3,1) /* Clock 3, 19.2MHz */
158
159			/* Pull RST low */
160			CTXS(GPP_F15)
161
162			/* Pull SNRPWR_EN high */
163			STXS(GPP_H14)
164
165			If (REFC == 0)
166			{
167				/* Pull PWREN high */
168				STXS(GPP_H20)
169			}
170			Sleep(2) /* reset pulse width */
171
172			REFC++
173
174			/* Pull RST high */
175			STXS(GPP_F15)
176
177			Sleep(1) /* t2 */
178
179			STA = 1
180		}
181		Method (_OFF, 0, Serialized)  /* Rear camera _OFF: Power Off */
182		{
183			/* Disable IMG_CLK */
184			Sleep(1) /* t0+t1 */
185			MCOF(3) /* Clock 3 */
186
187			/* Pull RST low */
188			CTXS(GPP_F15)
189
190			If (REFC == 1)
191			{
192				/* Pull PWREN low */
193				CTXS(GPP_H20)
194			}
195			REFC--
196
197			/* Pull SNRPWR_EN low */
198			CTXS(GPP_H14)
199
200			STA = 0
201		}
202		Method (_STA, 0, NotSerialized)
203		{
204			Return (STA)
205		}
206	}
207
208	Device (CAM0)
209	{
210		Name (_HID, "OVTI8856")
211		Name (_UID, 0)
212		Name (_DDN, "Ov 8856 Camera")  /* _DDN: DOS Device Name */
213		Method (_STA, 0, NotSerialized)
214		{
215			Return (0x0F)
216		}
217		Name (_CRS, ResourceTemplate ()  /* _CRS: Current Resource Settings */
218		{
219			I2cSerialBus (0x0010, ControllerInitiated, 0x00061A80,
220				AddressingMode7Bit, "\\_SB.PCI0.I2C3",
221				0x00, ResourceConsumer, ,
222			)
223		})
224		Name (_PR0, Package (0x01)  /* _PR0: Power Resources for D0 */
225		{
226			RCPR
227		})
228		Name (_PR3, Package (0x01)  /* _PR3: Power Resources for D3hot */
229		{
230			RCPR
231		})
232		Name (_DSD, Package (0x04)  /* _DSD: Device-Specific Data */
233		{
234			ToUUID ("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
235			Package (0x01)
236			{
237				Package (0x02)
238				{
239					"port0",
240					"PRT0"
241				}
242			},
243			ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
244			Package (0x03)
245			{
246				Package (0x02)
247				{
248					"clock-frequency",
249					0x0124F800
250				},
251				Package (0x02)
252				{
253					"lens-focus",
254					Package (0x01)
255					{
256						VCM0
257					}
258				},
259				Package (0x02)
260				{
261					"i2c-allow-low-power-probe",
262					0x01
263				}
264			}
265		})
266		Name (PRT0, Package (0x04)
267		{
268			ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
269			Package (0x01)
270			{
271				Package (0x02)
272				{
273					"port",
274					0
275				}
276			},
277			ToUUID ("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
278			Package (0x01)
279			{
280				Package (0x02)
281				{
282					"endpoint0",
283					"EP00"
284				}
285			}
286		})
287		Name (EP00, Package (0x02)
288		{
289			ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
290			Package (0x05)
291			{
292				Package (0x02)
293				{
294					"endpoint",
295					0
296				},
297				Package (0x02)
298				{
299					"clock-lanes",
300					0
301				},
302				Package (0x02)
303				{
304					"data-lanes",
305					Package (0x04)
306					{
307						1,
308						0x02,
309						0x03,
310						0x04
311					}
312				},
313				Package (0x02)
314				{
315					"link-frequencies",
316					Package (0x02)
317					{
318						0x15752A00,
319						0xABA9500
320					}
321				},
322				Package (0x02)
323				{
324					"remote-endpoint",
325					Package (0x03)
326					{
327						IPU0,
328						0,
329						0
330					}
331				}
332			}
333		})
334	}
335
336	PowerResource (VCPR, 0x00, 0x0000)
337	{
338		Name (STA, 0)
339		Method (_ON, 0, Serialized)  /* VCPR_ON_: VCM Power On */
340		{
341			If (REFC == 0)
342			{
343				/* Pull PWREN high */
344				STXS(GPP_H20)
345			}
346			REFC++
347			STA = 1
348		}
349		Method (_OFF, 0, Serialized)  /* VCPR_OFF: VCM Power Off */
350		{
351			If (REFC == 1)
352			{
353				/* Pull PWREN low */
354				CTXS(GPP_H20)
355			}
356			REFC--
357			STA = 0
358		}
359		Method (_STA, 0, NotSerialized)
360		{
361			Return (STA)
362		}
363	}
364
365	Device (VCM0)
366	{
367		Name (_HID, "PRP0001")
368		Name (_UID, 0x00)
369		Name (_DDN, "DW9768 VCM")  /* _DDN: DOS Device Name */
370		Method (_STA, 0, NotSerialized)
371		{
372			Return (0x0F)
373		}
374		Name (_CRS, ResourceTemplate ()  /* _CRS: Current Resource Settings */
375		{
376			I2cSerialBus (0x000C, ControllerInitiated, 0x00061A80,
377				AddressingMode7Bit, "\\_SB.PCI0.I2C3",
378				0x00, ResourceConsumer, ,
379			)
380		})
381		Name (_DEP, Package (0x01)  /* _DEP: Dependencies */
382		{
383			CAM0
384		})
385		Name (_PR0, Package (0x01)  /* _PR0: Power Resources for D0 */
386		{
387			VCPR
388		})
389		Name (_PR3, Package (0x01)  /* _PR3: Power Resources for D3hot */
390		{
391			VCPR
392		})
393		Name (_DSD, Package (0x02)  /* _DSD: Device-Specific Data */
394		{
395			ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
396			Package (0x02)
397			{
398				Package (0x02)
399				{
400					"compatible",
401					"dongwoon,dw9768"
402				},
403				Package (0x02)
404				{
405					"i2c-allow-low-power-probe",
406					0x01
407				}
408			}
409		})
410	}
411	Device (NVM0)
412	{
413		Name (_HID, "PRP0001")
414		Name (_UID, 0x01)
415		Name (_DDN, "AT24 EEPROM")  // _DDN: DOS Device Name
416		Method (_STA, 0, NotSerialized)
417		{
418			Return (0x0F)
419		}
420		Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
421		{
422			I2cSerialBusV2 (0x0058, ControllerInitiated, 0x00061A80,
423				AddressingMode7Bit, "\\_SB.PCI0.I2C3",
424				0x00, ResourceConsumer, , Exclusive,
425				)
426		})
427		Name (_DEP, Package (0x01)  // _DEP: Dependencies
428		{
429			CAM0
430		})
431		Name (_PR0, Package (0x01)  // _PR0: Power Resources for D0
432		{
433			RCPR
434		})
435		Name (_PR3, Package (0x01)  // _PR3: Power Resources for D3hot
436		{
437			RCPR
438		})
439		Name (_DSD, Package (0x02)  // _DSD: Device-Specific Data
440		{
441			ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */,
442			Package (0x06)
443			{
444				Package (0x02)
445				{
446					"size",
447					0x2800
448				},
449				Package (0x02)
450				{
451					"pagesize",
452					1
453				},
454				Package (0x02)
455				{
456					"read-only",
457					1
458				},
459				Package (0x02)
460				{
461					"address-width",
462					0x10
463				},
464				Package (0x02)
465				{
466					"compatible",
467					"atmel,24c1024"
468				},
469				Package (0x02)
470				{
471					"i2c-allow-low-power-probe",
472					0x01
473				}
474			}
475		})
476	}
477}
478
479Scope (\_SB.PCI0.I2C2)
480{
481	Name (STA, 0)
482	PowerResource (FCPR, 0x00, 0x0000)
483	{
484		Method (_ON, 0, Serialized)  /* Front camera_ON_: Power On */
485		{
486			If (STA == 0)
487			{
488				/* Enable IMG_CLK */
489				MCON(2,1) /* Clock 2, 19.2MHz */
490
491				/* Pull RST low */
492				CTXS(GPP_D4)
493
494				/* Pull SNRPWR_EN high */
495				STXS(GPP_D18)
496
497				/* Pull PWREN high */
498				STXS(GPP_D17)
499				Sleep(10) /* t9 */
500
501				/* Pull RST high */
502				STXS(GPP_D4)
503				Sleep(1) /* t2 */
504
505				STA = 1
506			}
507		}
508		Method (_OFF, 0, Serialized)  /* Front camera_OFF_: Power Off */
509		{
510			If (STA == 1)
511			{
512				/* Disable IMG_CLK */
513				Sleep(1) /* t0+t1 */
514				MCOF(2) /* Clock 2 */
515
516				/* Pull RST low */
517				CTXS(GPP_D4)
518
519				/* Pull PWREN low */
520				CTXS(GPP_D17)
521
522				/* Pull SNRPWR_EN low */
523				CTXS(GPP_D18)
524
525				STA = 0
526			}
527		}
528		Method (_STA, 0, NotSerialized)
529		{
530			Return (STA)
531		}
532	}
533
534	Device (CAM1)
535	{
536		Name (_HID, "INT3474")
537		Name (_UID, 0)
538		Name (_DDN, "Ov 2740 Camera")  /* _DDN: DOS Device Name */
539		Method (_STA, 0, NotSerialized)
540		{
541			Return (0x0F)
542		}
543		Name (_CRS, ResourceTemplate ()  /* _CRS: Current Resource Settings */
544		{
545			I2cSerialBus (0x0010, ControllerInitiated, 0x00061A80,
546				AddressingMode7Bit, "\\_SB.PCI0.I2C2",
547				0x00, ResourceConsumer, ,
548			)
549		})
550		Name (_PR0, Package (0x01)  /* _PR0: Power Resources for D0 */
551		{
552			FCPR
553		})
554		Name (_PR3, Package (0x01)  /* _PR3: Power Resources for D3hot */
555		{
556			FCPR
557		})
558		Name (_DSD, Package (0x04)  /* _DSD: Device-Specific Data */
559		{
560			ToUUID ("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
561			Package (0x01)
562			{
563				Package (0x02)
564				{
565					"port0",
566					"PRT0"
567				}
568			},
569			ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
570			Package (0x02)
571			{
572				Package (0x02)
573				{
574					"clock-frequency",
575					0x0124F800
576				},
577				Package (0x02)
578				{
579					"i2c-allow-low-power-probe",
580					0x01
581				}
582			}
583		})
584		Name (PRT0, Package (0x04)
585		{
586			ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
587			Package (0x01)
588			{
589				Package (0x02)
590				{
591					"port",
592					0
593				}
594			},
595			ToUUID ("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
596			Package (0x01)
597			{
598				Package (0x02)
599				{
600					"endpoint0",
601					"EP00"
602				}
603			}
604		})
605		Name (EP00, Package (0x02)
606		{
607			ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
608			Package (0x05)
609			{
610				Package (0x02)
611				{
612					"endpoint",
613					0
614				},
615				Package (0x02)
616				{
617					"clock-lanes",
618					0
619				},
620				Package (0x02)
621				{
622					"data-lanes",
623					Package (0x02)
624					{
625						1,
626						0x02
627					}
628				},
629				Package (0x02)
630				{
631					"link-frequencies",
632					Package (0x01)
633					{
634						0x15752A00
635					}
636				},
637				Package (0x02)
638				{
639					"remote-endpoint",
640					Package (0x03)
641					{
642						IPU0,
643						1,
644						0
645					}
646				}
647			}
648		})
649	}
650}
651