Compare commits
	
		
			34 Commits
		
	
	
		
			main
			...
			brightness
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | aa3cac14ab | ||
|  | f3ecbaeb3b | ||
|  | e8df441ef2 | ||
|  | e824c88b95 | ||
|  | f7cea308fc | ||
|  | 566623f0fc | ||
|  | 2c8c5cf25b | ||
|  | c70505ff8d | ||
|  | 7df47320ec | ||
|  | 6ab4a7243c | ||
|  | 38c3eda699 | ||
|  | 4a2741633b | ||
|  | 60f3d71981 | ||
|  | d6d4c5e355 | ||
|  | 5b13dc0f5e | ||
|  | f941def9dd | ||
|  | b41369176f | ||
|  | e96476dd65 | ||
|  | 9113e145db | ||
|  | bb54e49a54 | ||
|  | be0dfcd68a | ||
|  | ed92a6d587 | ||
|  | b21bd87af0 | ||
|  | f224ddbc78 | ||
|  | e3033b56fe | ||
|  | cfa8635d03 | ||
|  | 868c102d2f | ||
|  | f6ed8684a5 | ||
|  | 920d350c9f | ||
|  | d241bc97c9 | ||
|  | 70657e373f | ||
|  | 8d5df37c79 | ||
|  | ed35db9071 | ||
|  | f2182a3f95 | 
							
								
								
									
										36
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										36
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @@ -1,70 +1,70 @@ | ||||
| [submodule "3rdparty/blobs"] | ||||
| 	path = 3rdparty/blobs | ||||
| 	url = ../blobs.git | ||||
| 	url = https://review.coreboot.org/blobs.git | ||||
| 	update = none | ||||
| 	ignore = dirty | ||||
| [submodule "util/nvidia-cbootimage"] | ||||
| 	path = util/nvidia/cbootimage | ||||
| 	url = ../nvidia-cbootimage.git | ||||
| 	url = https://review.coreboot.org/nvidia-cbootimage.git | ||||
| [submodule "vboot"] | ||||
| 	path = 3rdparty/vboot | ||||
| 	url = ../vboot.git | ||||
| 	url = https://review.coreboot.org/vboot.git | ||||
| 	branch = main | ||||
| [submodule "arm-trusted-firmware"] | ||||
| 	path = 3rdparty/arm-trusted-firmware | ||||
| 	url = ../arm-trusted-firmware.git | ||||
| 	url = https://review.coreboot.org/arm-trusted-firmware.git | ||||
| [submodule "3rdparty/chromeec"] | ||||
| 	path = 3rdparty/chromeec | ||||
| 	url = ../chrome-ec.git | ||||
| 	url = https://review.coreboot.org/chrome-ec.git | ||||
| [submodule "libhwbase"] | ||||
| 	path = 3rdparty/libhwbase | ||||
| 	url = ../libhwbase.git | ||||
| 	url = https://review.coreboot.org/libhwbase.git | ||||
| [submodule "libgfxinit"] | ||||
| 	path = 3rdparty/libgfxinit | ||||
| 	url = ../libgfxinit.git | ||||
| 	url = https://review.coreboot.org/libgfxinit.git | ||||
| [submodule "3rdparty/fsp"] | ||||
| 	path = 3rdparty/fsp | ||||
| 	url = ../fsp.git | ||||
| 	url = https://review.coreboot.org/fsp.git | ||||
| 	update = none | ||||
| 	ignore = dirty | ||||
| [submodule "opensbi"] | ||||
| 	path = 3rdparty/opensbi | ||||
| 	url = ../opensbi.git | ||||
| 	url = https://review.coreboot.org/opensbi.git | ||||
| [submodule "intel-microcode"] | ||||
| 	path = 3rdparty/intel-microcode | ||||
| 	url = ../intel-microcode.git | ||||
| 	url = https://review.coreboot.org/intel-microcode.git | ||||
| 	update = none | ||||
| 	ignore = dirty | ||||
| 	branch = main | ||||
| [submodule "3rdparty/ffs"] | ||||
| 	path = 3rdparty/ffs | ||||
| 	url = ../ffs.git | ||||
| 	url = https://review.coreboot.org/ffs.git | ||||
| [submodule "3rdparty/amd_blobs"] | ||||
| 	path = 3rdparty/amd_blobs | ||||
| 	url = ../amd_blobs | ||||
| 	url = https://review.coreboot.org/amd_blobs | ||||
| 	update = none | ||||
| 	ignore = dirty | ||||
| [submodule "3rdparty/cmocka"] | ||||
| 	path = 3rdparty/cmocka | ||||
| 	url = ../cmocka.git | ||||
| 	url = https://review.coreboot.org/cmocka.git | ||||
| 	update = none | ||||
| 	branch = stable-1.1 | ||||
| [submodule "3rdparty/qc_blobs"] | ||||
| 	path = 3rdparty/qc_blobs | ||||
| 	url = ../qc_blobs.git | ||||
| 	url = https://review.coreboot.org/qc_blobs.git | ||||
| 	update = none | ||||
| 	ignore = dirty | ||||
| [submodule "3rdparty/intel-sec-tools"] | ||||
| 	path = 3rdparty/intel-sec-tools | ||||
| 	url = ../9esec-security-tooling.git | ||||
| 	url = https://review.coreboot.org/9esec-security-tooling.git | ||||
| [submodule "3rdparty/stm"] | ||||
| 	path = 3rdparty/stm | ||||
| 	url = ../STM | ||||
| 	url = https://review.coreboot.org/STM | ||||
| 	branch = stmpe | ||||
| [submodule "util/goswid"] | ||||
| 	path = util/goswid | ||||
| 	url = ../goswid | ||||
| 	url = https://review.coreboot.org/goswid.git | ||||
| 	branch = trunk | ||||
| [submodule "src/vendorcode/amd/opensil/genoa_poc/opensil"] | ||||
| 	path = src/vendorcode/amd/opensil/genoa_poc/opensil | ||||
| 	url = ../opensil_genoa_poc.git | ||||
| 	url = https://review.coreboot.org/opensil_genoa_poc.git | ||||
|   | ||||
							
								
								
									
										38
									
								
								src/drivers/gfx/nvidia/Kconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/drivers/gfx/nvidia/Kconfig
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| config DRIVERS_GFX_NVIDIA | ||||
| 	bool | ||||
| 	default n | ||||
| 	help | ||||
| 	  Support for NVIDIA Optimus graphics | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_BRIDGE | ||||
| 	hex "PCI bridge for the GPU device" | ||||
| 	default 0x01 | ||||
| 	depends on DRIVERS_GFX_NVIDIA | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	depends on DRIVERS_GFX_NVIDIA | ||||
| 	bool | ||||
| 	default n | ||||
| 	help | ||||
| 	  Support for NVIDIA Dynamic Boost | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_TPP | ||||
| 	int "Total processor power offset from default TGP in watts" | ||||
| 	default 45 | ||||
| 	depends on DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	help | ||||
| 	  This identifies the available power for the CPU or GPU boost | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_MIN | ||||
| 	int "Minimum TGP offset from default TGP in watts" | ||||
| 	default 0 | ||||
| 	depends on DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	help | ||||
| 	  This is used to transfer power from the GPU to the CPU | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_MAX | ||||
| 	int "Maximum TGP offset from default TGP in watts" | ||||
| 	default 0 | ||||
| 	depends on DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	help | ||||
| 	  This is used to transfer power from the CPU to the GPU | ||||
							
								
								
									
										5
									
								
								src/drivers/gfx/nvidia/Makefile.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/drivers/gfx/nvidia/Makefile.inc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| # SPDX-License-Identifier: GPL-2.0-only | ||||
|  | ||||
| romstage-$(CONFIG_DRIVERS_GFX_NVIDIA) += romstage.c | ||||
|  | ||||
| ramstage-$(CONFIG_DRIVERS_GFX_NVIDIA) += nvidia.c | ||||
							
								
								
									
										96
									
								
								src/drivers/gfx/nvidia/acpi/coffeelake.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								src/drivers/gfx/nvidia/acpi/coffeelake.asl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,96 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
| /* NVIDIA GC6 on CFL and CML CPU PCIe ports */ | ||||
|  | ||||
| // Memory mapped PCI express config space | ||||
| OperationRegion (PCIC, SystemMemory, CONFIG_ECAM_MMCONF_BASE_ADDRESS + (CONFIG_DRIVERS_GFX_NVIDIA_BRIDGE << 15), 0x1000) | ||||
|  | ||||
| Field (PCIC, ByteAcc, NoLock, Preserve) { | ||||
| 	PVID,   16, | ||||
| 	PDID,   16, | ||||
|  | ||||
| 	Offset (0x248), | ||||
| 		,   7, | ||||
| 	L23E,   1,      /* L23_Rdy Entry Request */ | ||||
| 	L23R,   1,      /* L23_Rdy to Detect Transition */ | ||||
|  | ||||
| 	Offset (0xC20), | ||||
| 		,   4, | ||||
| 	P0AP,   2,      /* Additional power savings */ | ||||
|  | ||||
| 	Offset (0xC38), | ||||
| 		,   3, | ||||
| 	P0RM,   1,      /* Robust squelch mechanism */ | ||||
| } | ||||
|  | ||||
| // Enter L23 | ||||
| Method (DL23, 0, Serialized) { | ||||
| 	Printf("      GPU PORT DL23 START") | ||||
|  | ||||
| 	L23E = 1 | ||||
| 	Sleep (16) | ||||
| 	Local0 = 0 | ||||
| 	While (L23E) { | ||||
| 		If ((Local0 > 4)) { | ||||
| 			Break | ||||
| 		} | ||||
|  | ||||
| 		Sleep (16) | ||||
| 		Local0++ | ||||
| 	} | ||||
|  | ||||
| 	P0RM = 1 | ||||
| 	P0AP = 3 | ||||
|  | ||||
| 	Printf("      GPU PORT DL23 FINISH") | ||||
| } | ||||
|  | ||||
| // Exit L23 | ||||
| Method (L23D, 0, Serialized) { | ||||
| 	Printf("      GPU PORT L23D START") | ||||
|  | ||||
| 	L23R = 1 | ||||
| 	Sleep (16) | ||||
| 	Local0 = 0 | ||||
| 	While (L23R) { | ||||
| 		If ((Local0 > 4)) { | ||||
| 			Break | ||||
| 		} | ||||
|  | ||||
| 		Sleep (16) | ||||
| 		Local0++ | ||||
| 	} | ||||
|  | ||||
| 	P0RM = 0 | ||||
| 	P0AP = 0 | ||||
|  | ||||
| 	Printf("      GPU PORT L23D FINISH") | ||||
| } | ||||
|  | ||||
| // Main power resource | ||||
| PowerResource (PWRR, 0, 0) { | ||||
| 	Name (_STA, 1) | ||||
|  | ||||
| 	Method (_ON, 0, Serialized) { | ||||
| 		Printf("GPU PORT PWRR._ON") | ||||
|  | ||||
| 		^^DEV0._ON() | ||||
|  | ||||
| 		_STA = 1 | ||||
| 	} | ||||
|  | ||||
| 	Method (_OFF, 0, Serialized) { | ||||
| 		Printf("GPU PORT PWRR._OFF") | ||||
|  | ||||
| 		^^DEV0._OFF() | ||||
|  | ||||
| 		_STA = 0 | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Power resources for entering D0 | ||||
| Name (_PR0, Package () { PWRR }) | ||||
|  | ||||
| // Power resources for entering D3 | ||||
| Name (_PR3, Package () { PWRR }) | ||||
|  | ||||
| #include "common/gpu.asl" | ||||
							
								
								
									
										30
									
								
								src/drivers/gfx/nvidia/acpi/common/dsm.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/drivers/gfx/nvidia/acpi/common/dsm.asl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #define NV_ERROR_SUCCESS 0x0 | ||||
| #define NV_ERROR_UNSPECIFIED 0x80000001 | ||||
| #define NV_ERROR_UNSUPPORTED 0x80000002 | ||||
|  | ||||
| #include "gps.asl" | ||||
| #include "nvjt.asl" | ||||
|  | ||||
| Method (_DSM, 4, Serialized) { | ||||
| 	Printf("GPU _DSM") | ||||
| 	If (Arg0 == ToUUID (JT_DSM_GUID)) { | ||||
| 		If (ToInteger(Arg1) >= JT_REVISION_ID_MIN) { | ||||
| 			Return (NVJT(Arg2, Arg3)) | ||||
| 		} Else { | ||||
| 			Printf("  Unsupported JT revision: %o", SFST(Arg1)) | ||||
| 			Return (NV_ERROR_UNSUPPORTED) | ||||
| 		} | ||||
| 	} ElseIf (Arg0 == ToUUID (GPS_DSM_GUID)) { | ||||
| 		If (ToInteger(Arg1) == GPS_REVISION_ID) { | ||||
| 			Return (GPS(Arg2, Arg3)) | ||||
| 		} Else { | ||||
| 			Printf("  Unsupported GPS revision: %o", SFST(Arg1)) | ||||
| 			Return (NV_ERROR_UNSUPPORTED) | ||||
| 		} | ||||
| 	} Else { | ||||
| 		Printf("  Unsupported GUID: %o", IDST(Arg0)) | ||||
| 		Return (NV_ERROR_UNSPECIFIED) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										66
									
								
								src/drivers/gfx/nvidia/acpi/common/gps.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								src/drivers/gfx/nvidia/acpi/common/gps.asl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #define GPS_DSM_GUID "A3132D01-8CDA-49BA-A52E-BC9D46DF6B81" | ||||
| #define GPS_REVISION_ID 0x00000200 | ||||
| #define GPS_FUNC_SUPPORT 0x00000000 | ||||
| #define GPS_FUNC_PSHARESTATUS 0x00000020 | ||||
| #define GPS_FUNC_PSHAREPARAMS 0x0000002A | ||||
|  | ||||
| Method(GPS, 2, Serialized) { | ||||
| 	Printf("  GPU GPS") | ||||
| 	Switch(ToInteger(Arg0)) { | ||||
| 		Case(GPS_FUNC_SUPPORT) { | ||||
| 			Printf("    Supported Functions") | ||||
| 			Return(ITOB( | ||||
| 				(1 << GPS_FUNC_SUPPORT) | | ||||
| 				(1 << GPS_FUNC_PSHARESTATUS) | | ||||
| 				(1 << GPS_FUNC_PSHAREPARAMS) | ||||
| 			)) | ||||
| 		} | ||||
| 		Case(GPS_FUNC_PSHARESTATUS) { | ||||
| 			Printf("    Power Share Status") | ||||
| 			Return(ITOB(0)) | ||||
| 		} | ||||
| 		Case(GPS_FUNC_PSHAREPARAMS) { | ||||
| 			Printf("    Power Share Parameters") | ||||
|  | ||||
| 			CreateField(Arg1, 0, 4, QTYP) // Query type | ||||
|  | ||||
| 			Name(GPSP, Buffer(36) { 0x00 }) | ||||
| 			CreateDWordField(GPSP, 0, RSTS) // Response status | ||||
| 			CreateDWordField(GPSP, 4, VERS) // Version | ||||
|  | ||||
| 			// Set query type of response | ||||
| 			RSTS = QTYP | ||||
| 			// Set version of response | ||||
| 			VERS = 0x00010000 | ||||
|  | ||||
| 			Switch(ToInteger(QTYP)) { | ||||
| 				Case(0) { | ||||
| 					Printf("      Request Current Information") | ||||
| 					// No required information | ||||
| 					Return(GPSP) | ||||
| 				} | ||||
| 				Case(1) { | ||||
| 					Printf("      Request Supported Fields") | ||||
| 					// Support GPU temperature field | ||||
| 					RSTS |= (1 << 8) | ||||
| 					Return(GPSP) | ||||
| 				} | ||||
| 				Case(2) { | ||||
| 					Printf("      Request Current Limits") | ||||
| 					// No required limits | ||||
| 					Return(GPSP) | ||||
| 				} | ||||
| 				Default { | ||||
| 					Printf("      Unknown Query: %o", SFST(QTYP)) | ||||
| 					Return(NV_ERROR_UNSUPPORTED) | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		Default { | ||||
| 			Printf("    Unsupported function: %o", SFST(Arg0)) | ||||
| 			Return(NV_ERROR_UNSUPPORTED) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										18
									
								
								src/drivers/gfx/nvidia/acpi/common/gpu.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/drivers/gfx/nvidia/acpi/common/gpu.asl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| Device (DEV0) { | ||||
| 	Name(_ADR, 0x00000000) | ||||
|  | ||||
| 	#include "utility.asl" | ||||
| 	#include "dsm.asl" | ||||
| 	#include "power.asl" | ||||
| } | ||||
|  | ||||
| #if CONFIG(DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST) | ||||
| Scope (\_SB) { | ||||
| 	Device(NPCF) { | ||||
| 		#include "utility.asl" | ||||
| 		#include "nvpcf.asl" | ||||
| 	} | ||||
| } | ||||
| #endif | ||||
							
								
								
									
										152
									
								
								src/drivers/gfx/nvidia/acpi/common/nvjt.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								src/drivers/gfx/nvidia/acpi/common/nvjt.asl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,152 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #define JT_DSM_GUID "CBECA351-067B-4924-9CBD-B46B00B86F34" | ||||
| #define JT_REVISION_ID_MIN 0x00000100 | ||||
| #define JT_REVISION_ID_MAX 0x00000200 | ||||
| #define JT_FUNC_SUPPORT 0x00000000 | ||||
| #define JT_FUNC_CAPS 0x00000001 | ||||
| #define JT_FUNC_POWERCONTROL 0x00000003 | ||||
|  | ||||
| //TODO: SMI traps and EGIN/XCLM | ||||
| #define JT_GPC_GSS 0 // Get current GPU GCx sleep status | ||||
| #define JT_GPC_EGNS 1 // Enter GC6 without self-refresh | ||||
| #define JT_GPC_EGIS 2 // Enter GC6 with self-refresh | ||||
| #define JT_GPC_XGXS 3 // Exit GC6 and stop self-refresh | ||||
| #define JT_GPC_XGIS 4 // Exit GC6 for self-refresh update | ||||
|  | ||||
| #define JT_DFGC_NONE 0 // Handle request immediately | ||||
| #define JT_DFGC_DEFER 1 // Defer GPC and GPCX | ||||
| //TODO #define JT_DFGC_CLEAR 2 // Clear pending requests | ||||
|  | ||||
| // Deferred GC6 enter/exit until D3-cold (saved DFGC) | ||||
| Name(DFEN, 0) | ||||
|  | ||||
| // Deferred GC6 enter control (saved GPC) | ||||
| Name(DFCI, 0) | ||||
|  | ||||
| // Deferred GC6 exit control (saved GPCX) | ||||
| Name(DFCO, 0) | ||||
|  | ||||
| Method (NVJT, 2, Serialized) { | ||||
| 	Printf("  GPU NVJT") | ||||
| 	Switch (ToInteger(Arg0)) { | ||||
| 		Case (JT_FUNC_SUPPORT) { | ||||
| 			Printf("    Supported Functions") | ||||
| 			Return(ITOB( | ||||
| 				(1 << JT_FUNC_SUPPORT) | | ||||
| 				(1 << JT_FUNC_CAPS) | | ||||
| 				(1 << JT_FUNC_POWERCONTROL) | ||||
| 			)) | ||||
| 		} | ||||
| 		Case (JT_FUNC_CAPS) { | ||||
| 			Printf("    Capabilities") | ||||
| 			Return(ITOB( | ||||
| 				(1 << 0) | // G-SYNC NSVR power-saving features are enabled | ||||
| 				(1 << 1) | // NVSR disabled | ||||
| 				(2 << 3) | // Panel power and backlight are on the suspend rail | ||||
| 				(0 << 5) | // self-refresh controller remains powered while panel is powered | ||||
| 				(0 << 6) | // FB is not on the suspend rail but is powered on in GC6 | ||||
| 				(0 << 8) | // Combined power rail for all GPUs | ||||
| 				(0 << 10) | // External SPI ROM | ||||
| 				(1 << 11) | // No SMI handler for kernel panic exit while in GC6 | ||||
| 				(0 << 12) | // Supports notify on GC6 state done | ||||
| 				(1 << 13) | // Support deferred GC6 | ||||
| 				(1 << 14) | // Support fine-grained root port control | ||||
| 				(2 << 15) | // GC6 version is GC6-R | ||||
| 				(0 << 17) | // GC6 exit ISR is not supported | ||||
| 				(0 << 18) | // GC6 self wakeup not supported | ||||
| 				(JT_REVISION_ID_MAX << 20) // Highest revision supported | ||||
| 			)) | ||||
| 		} | ||||
| 		Case (JT_FUNC_POWERCONTROL) { | ||||
| 			Printf("    Power Control: %o", SFST(Arg1)) | ||||
|  | ||||
| 			CreateField (Arg1, 0, 3, GPC) // GPU power control | ||||
| 			CreateField (Arg1, 4, 1, PPC) // Panel power control | ||||
| 			CreateField (Arg1, 14, 2, DFGC) // Defer GC6 enter/exit until D3 cold | ||||
| 			CreateField (Arg1, 16, 3, GPCX) // Deferred GC6 exit control | ||||
|  | ||||
| 			// Save deferred GC6 request | ||||
| 			If ((ToInteger(GPC) != 0) || (ToInteger(DFGC) != 0)) { | ||||
| 				DFEN = DFGC | ||||
| 				DFCI = GPC | ||||
| 				DFCO = GPCX | ||||
| 			} | ||||
|  | ||||
| 			// Buffer to cache current state | ||||
| 			Name (JTBF, Buffer (4) { 0, 0, 0, 0 }) | ||||
| 			CreateField (JTBF, 0, 3, CGCS) // Current GC state | ||||
| 			CreateField (JTBF, 3, 1, CGPS) // Current GPU power status | ||||
| 			CreateField (JTBF, 7, 1, CPSS) // Current panel and SRC state (0 when on) | ||||
|  | ||||
| 			// If doing deferred GC6 request, return now | ||||
| 			If (ToInteger(DFGC) != 0) { | ||||
| 				CGCS = 1 | ||||
| 				CGPS = 1 | ||||
| 				Return (JTBF) | ||||
| 			} | ||||
|  | ||||
| 			// Apply requested state | ||||
| 			Switch (ToInteger(GPC)) { | ||||
| 				Case (JT_GPC_GSS) { | ||||
| 					Printf("    Get current GPU GCx sleep status") | ||||
| 					//TODO: include transitions! | ||||
| 					If (GTXS(DGPU_RST_N)) { | ||||
| 						// GPU powered on | ||||
| 						CGCS = 1 | ||||
| 						CGPS = 1 | ||||
| 					} ElseIf (GTXS(DGPU_PWR_EN)) { | ||||
| 						// GPU powered off, GC6 | ||||
| 						CGCS = 3 | ||||
| 						CGPS = 0 | ||||
| 					} Else { | ||||
| 						// GPU powered off, D3 cold | ||||
| 						CGCS = 2 | ||||
| 						CGPS = 0 | ||||
| 					} | ||||
| 				} | ||||
| 				Case (JT_GPC_EGNS) { | ||||
| 					Printf("    Enter GC6 without self-refresh") | ||||
| 					GC6I() | ||||
| 					CPSS = 1 | ||||
| 				} | ||||
| 				Case (JT_GPC_EGIS) { | ||||
| 					Printf("    Enter GC6 with self-refresh") | ||||
| 					GC6I() | ||||
| 					If (ToInteger(PPC) == 0) { | ||||
| 						CPSS = 0 | ||||
| 					} | ||||
| 				} | ||||
| 				Case (JT_GPC_XGXS) { | ||||
| 					Printf("    Exit GC6 and stop self-refresh") | ||||
| 					GC6O() | ||||
|  | ||||
| 					CGCS = 1 | ||||
| 					CGPS = 1 | ||||
| 					If (ToInteger(PPC) != 0) { | ||||
| 						CPSS = 0 | ||||
| 					} | ||||
| 				} | ||||
| 				Case (JT_GPC_XGIS) { | ||||
| 					Printf("    Exit GC6 for self-refresh update") | ||||
| 					GC6O() | ||||
|  | ||||
| 					CGCS = 1 | ||||
| 					CGPS = 1 | ||||
| 					If (ToInteger(PPC) != 0) { | ||||
| 						CPSS = 0 | ||||
| 					} | ||||
| 				} | ||||
| 				Default { | ||||
| 					Printf("    Unsupported GPU power control: %o", SFST(GPC)) | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			Return (JTBF) | ||||
| 		} | ||||
| 		Default { | ||||
| 			Printf("    Unsupported function: %o", SFST(Arg0)) | ||||
| 			Return (NV_ERROR_UNSUPPORTED) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										113
									
								
								src/drivers/gfx/nvidia/acpi/common/nvpcf.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								src/drivers/gfx/nvidia/acpi/common/nvpcf.asl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,113 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #define NVPCF_DSM_GUID "36b49710-2483-11e7-9598-0800200c9a66" | ||||
| #define NVPCF_REVISION_ID 0x00000200 | ||||
| #define NVPCF_ERROR_SUCCESS 0x0 | ||||
| #define NVPCF_ERROR_GENERIC 0x80000001 | ||||
| #define NVPCF_ERROR_UNSUPPORTED 0x80000002 | ||||
| #define NVPCF_FUNC_GET_SUPPORTED 0x00000000 | ||||
| #define NVPCF_FUNC_GET_STATIC_CONFIG_TABLES 0x00000001 | ||||
| #define NVPCF_FUNC_UPDATE_DYNAMIC_PARAMS 0x00000002 | ||||
|  | ||||
| Name(_HID, "NVDA0820") | ||||
|  | ||||
| Name(_UID, "NPCF") | ||||
|  | ||||
| Method(_DSM, 4, Serialized) { | ||||
| 	Printf("NVPCF _DSM") | ||||
| 	If (Arg0 == ToUUID(NVPCF_DSM_GUID)) { | ||||
| 		If (ToInteger(Arg1) == NVPCF_REVISION_ID) { | ||||
| 			Return(NPCF(Arg2, Arg3)) | ||||
| 		} Else { | ||||
| 			Printf("  Unsupported NVPCF revision: %o", SFST(Arg1)) | ||||
| 			Return(NVPCF_ERROR_GENERIC) | ||||
| 		} | ||||
| 	} Else { | ||||
| 		Printf("  Unsupported GUID: %o", IDST(Arg0)) | ||||
| 		Return(NVPCF_ERROR_GENERIC) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| Method(NPCF, 2, Serialized) { | ||||
| 	Printf("  NVPCF NPCF") | ||||
| 	Switch(ToInteger(Arg0)) { | ||||
| 		Case(NVPCF_FUNC_GET_SUPPORTED) { | ||||
| 			Printf("    Supported Functions") | ||||
| 			Return(ITOB( | ||||
| 				(1 << NVPCF_FUNC_GET_SUPPORTED) | | ||||
| 				(1 << NVPCF_FUNC_GET_STATIC_CONFIG_TABLES) | | ||||
| 				(1 << NVPCF_FUNC_UPDATE_DYNAMIC_PARAMS) | ||||
| 			)) | ||||
| 		} | ||||
| 		Case(NVPCF_FUNC_GET_STATIC_CONFIG_TABLES) { | ||||
| 			Printf("    Get Static Config") | ||||
| 			Return(Buffer(14) { | ||||
| 				// Device table header | ||||
| 				0x20, 0x03, 0x01, | ||||
| 				// Intel + NVIDIA | ||||
| 				0x00, | ||||
| 				// Controller table header | ||||
| 				0x23, 0x04, 0x05, 0x01, | ||||
| 				// Dynamic boost controller | ||||
| 				0x01, | ||||
| 				// Supports DC | ||||
| 				0x01, | ||||
| 				// Reserved | ||||
| 				0x00, 0x00, 0x00, | ||||
| 				// Checksum | ||||
| 				0xAD | ||||
| 			}) | ||||
| 		} | ||||
| 		Case(NVPCF_FUNC_UPDATE_DYNAMIC_PARAMS) { | ||||
| 			Printf("    Update Dynamic Boost") | ||||
|  | ||||
| 			CreateField(Arg1, 0x28, 2, ICMD) // Input command | ||||
|  | ||||
| 			Name(PCFP, Buffer(49) { | ||||
| 				// Table version | ||||
| 				0x23, | ||||
| 				// Table header size | ||||
| 				0x05, | ||||
| 				// Size of common status in bytes | ||||
| 				0x10, | ||||
| 				// Size of controller entry in bytes | ||||
| 				0x1C, | ||||
| 				// Other fields filled in later | ||||
| 			}) | ||||
| 			CreateByteField(PCFP, 0x04, CCNT) // Controller count | ||||
| 			CreateWordField(PCFP, 0x19, ATPP) // AC TPP offset | ||||
| 			CreateWordField(PCFP, 0x1D, AMXP) // AC maximum TGP offset | ||||
| 			CreateWordField(PCFP, 0x21, AMNP) // AC minimum TGP offset | ||||
|  | ||||
| 			Switch(ToInteger(ICMD)) { | ||||
| 				Case(0) { | ||||
| 					Printf("      Get Controller Params") | ||||
| 					// Number of controllers | ||||
| 					CCNT = 1 | ||||
| 					// AC total processor power offset from default TGP in 1/8 watt units | ||||
| 					ATPP = (CONFIG_DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_TPP << 3) | ||||
| 					// AC maximum TGP offset from default TGP in 1/8 watt units | ||||
| 					AMXP = (CONFIG_DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_MAX << 3) | ||||
| 					// AC minimum TGP offset from default TGP in 1/8 watt units | ||||
| 					AMNP = (CONFIG_DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_MIN << 3) | ||||
| 					Printf("PCFP: %o", SFST(PCFP)) | ||||
| 					Return(PCFP) | ||||
| 				} | ||||
| 				Case(1) { | ||||
| 					Printf("      Set Controller Status") | ||||
| 					//TODO | ||||
| 					Printf("PCFP: %o", SFST(PCFP)) | ||||
| 					Return(PCFP) | ||||
| 				} | ||||
| 				Default { | ||||
| 					Printf("      Unknown Input Command: %o", SFST(ICMD)) | ||||
| 					Return(NV_ERROR_UNSUPPORTED) | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		Default { | ||||
| 			Printf("    Unsupported function: %o", SFST(Arg0)) | ||||
| 			Return(NVPCF_ERROR_UNSUPPORTED) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										120
									
								
								src/drivers/gfx/nvidia/acpi/common/power.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								src/drivers/gfx/nvidia/acpi/common/power.asl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,120 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| //TODO: evaluate sleeps | ||||
|  | ||||
| OperationRegion (PCIC, PCI_Config, 0x00, 0xFF) | ||||
| Field (PCIC, DwordAcc, NoLock, Preserve) { | ||||
| 	Offset (0x40), | ||||
| 	SSID, 32, // Subsystem vendor and product ID | ||||
| } | ||||
|  | ||||
| // Enter GC6 | ||||
| Method(GC6I, 0, Serialized) { | ||||
| 	Printf("    GPU GC6I START") | ||||
|  | ||||
| 	// Enter L23 | ||||
| 	^^DL23() | ||||
| 	Sleep(5) | ||||
|  | ||||
| 	// Put GPU into reset | ||||
| 	Printf("      Put GPU into reset") | ||||
| 	CTXS(DGPU_RST_N) | ||||
| 	Sleep(5) | ||||
|  | ||||
| 	Printf("    GPU GC6I FINISH") | ||||
| } | ||||
|  | ||||
| // Exit GC6 | ||||
| Method(GC6O, 0, Serialized) { | ||||
| 	Printf("    GPU GC6O START") | ||||
|  | ||||
| 	// Bring GPU out of reset | ||||
| 	Printf("      Bring GPU out of reset") | ||||
| 	STXS(DGPU_RST_N) | ||||
| 	Sleep(5) | ||||
|  | ||||
| 	// Exit L23 | ||||
| 	^^L23D() | ||||
| 	Sleep(5) | ||||
|  | ||||
| 	Printf("    GPU GC6O FINISH") | ||||
| } | ||||
|  | ||||
| Method (_ON, 0, Serialized) { | ||||
| 	Printf("  GPU _ON START") | ||||
|  | ||||
| 	If (DFEN == JT_DFGC_DEFER) { | ||||
| 		Switch (ToInteger(DFCO)) { | ||||
| 			Case (JT_GPC_XGXS) { | ||||
| 				Printf("    Exit GC6 and stop self-refresh") | ||||
| 				GC6O() | ||||
| 			} | ||||
| 			Default { | ||||
| 				Printf("    Unsupported DFCO: %o", SFST(DFCO)) | ||||
| 			} | ||||
| 		} | ||||
| 		DFEN = JT_DFGC_NONE | ||||
| 	} Else { | ||||
| 		Printf("    Standard RTD3 power on") | ||||
| 		STXS(DGPU_PWR_EN) | ||||
| 		Sleep(5) | ||||
| 		GC6O() | ||||
| 	} | ||||
|  | ||||
| 	Printf("  GPU _ON FINISH") | ||||
| } | ||||
|  | ||||
| Method (_OFF, 0, Serialized) { | ||||
| 	Printf("  GPU _OFF START") | ||||
|  | ||||
| 	If (DFEN == JT_DFGC_DEFER) { | ||||
| 		Switch (ToInteger(DFCI)) { | ||||
| 			Case (JT_GPC_EGNS) { | ||||
| 				Printf("    Enter GC6 without self-refresh") | ||||
| 				GC6I() | ||||
| 			} | ||||
| 			Case (JT_GPC_EGIS) { | ||||
| 				Printf("    Enter GC6 with self-refresh") | ||||
| 				GC6I() | ||||
| 			} | ||||
| 			Default { | ||||
| 				Printf("    Unsupported DFCI: %o", SFST(DFCI)) | ||||
| 			} | ||||
| 		} | ||||
| 		DFEN = JT_DFGC_NONE | ||||
| 	} Else { | ||||
| 		Printf("    Standard RTD3 power off") | ||||
| 		GC6I() | ||||
| 		CTXS(DGPU_PWR_EN) | ||||
| 		Sleep(5) | ||||
| 	} | ||||
|  | ||||
| 	Printf("  GPU _OFF FINISH") | ||||
| } | ||||
|  | ||||
| // Main power resource | ||||
| PowerResource (PWRR, 0, 0) { | ||||
| 	Name (_STA, 1) | ||||
|  | ||||
| 	Method (_ON, 0, Serialized) { | ||||
| 		Printf("GPU PWRR._ON") | ||||
|  | ||||
| 		// Restore SSID | ||||
| 		^^SSID = DGPU_SSID | ||||
| 		Printf("  Restore SSID: %o", SFST(^^SSID)) | ||||
|  | ||||
| 		_STA = 1 | ||||
| 	} | ||||
|  | ||||
| 	Method (_OFF, 0, Serialized) { | ||||
| 		Printf("GPU PWRR._OFF") | ||||
|  | ||||
| 		_STA = 0 | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Power resources for entering D0 | ||||
| Name (_PR0, Package () { PWRR }) | ||||
|  | ||||
| // Power resources for entering D3 | ||||
| Name (_PR3, Package () { PWRR }) | ||||
							
								
								
									
										63
									
								
								src/drivers/gfx/nvidia/acpi/common/utility.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/drivers/gfx/nvidia/acpi/common/utility.asl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,63 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| // Convert a byte to a hex string, trimming extra parts | ||||
| Method (BHEX, 1) { | ||||
| 	Local0 = ToHexString(Arg0) | ||||
| 	Return (Mid(Local0, SizeOf(Local0) - 2, 2)) | ||||
| } | ||||
|  | ||||
| // UUID to string | ||||
| Method (IDST, 1) { | ||||
| 	Local0 = "" | ||||
| 	Fprintf( | ||||
| 		Local0, | ||||
| 		"%o%o%o%o-%o%o-%o%o-%o%o-%o%o%o%o%o%o", | ||||
| 		BHEX(DerefOf(Arg0[3])), | ||||
| 		BHEX(DerefOf(Arg0[2])), | ||||
| 		BHEX(DerefOf(Arg0[1])), | ||||
| 		BHEX(DerefOf(Arg0[0])), | ||||
| 		BHEX(DerefOf(Arg0[5])), | ||||
| 		BHEX(DerefOf(Arg0[4])), | ||||
| 		BHEX(DerefOf(Arg0[7])), | ||||
| 		BHEX(DerefOf(Arg0[6])), | ||||
| 		BHEX(DerefOf(Arg0[8])), | ||||
| 		BHEX(DerefOf(Arg0[9])), | ||||
| 		BHEX(DerefOf(Arg0[10])), | ||||
| 		BHEX(DerefOf(Arg0[11])), | ||||
| 		BHEX(DerefOf(Arg0[12])), | ||||
| 		BHEX(DerefOf(Arg0[13])), | ||||
| 		BHEX(DerefOf(Arg0[14])), | ||||
| 		BHEX(DerefOf(Arg0[15])) | ||||
| 	) | ||||
| 	Return (Local0) | ||||
| } | ||||
|  | ||||
| // Safe hex conversion, checks type first | ||||
| Method (SFST, 1) { | ||||
| 	Local0 = ObjectType(Arg0) | ||||
| 	If (Local0 == 1 || Local0 == 2 || Local0 == 3) { | ||||
| 		Return (ToHexString(Arg0)) | ||||
| 	} Else { | ||||
| 		Return (Concatenate("Type: ", Arg0)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Convert from 4-byte buffer to 32-bit integer | ||||
| Method (BTOI, 1) { | ||||
| 	Return( | ||||
| 		DerefOf(Arg0[0]) | | ||||
| 		(DerefOf(Arg0[1]) << 8) | | ||||
| 		(DerefOf(Arg0[2]) << 16) | | ||||
| 		(DerefOf(Arg0[3]) << 24) | ||||
| 	) | ||||
| } | ||||
|  | ||||
| // Convert from 32-bit integer to 4-byte buffer | ||||
| 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) | ||||
| } | ||||
							
								
								
									
										140
									
								
								src/drivers/gfx/nvidia/acpi/tigerlake.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								src/drivers/gfx/nvidia/acpi/tigerlake.asl
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,140 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
| /* NVIDIA GC6 on (TGL and ADL) (CPU and PCH) PCIe ports */ | ||||
|  | ||||
| // Port mapped PCI express config space | ||||
| OperationRegion (PCIC, PCI_Config, 0x00, 0xFF) | ||||
|  | ||||
| Field (PCIC, AnyAcc, NoLock, Preserve) { | ||||
| 	Offset(0x52),  /* LSTS - Link Status Register */ | ||||
| 	, 13, | ||||
| 	LASX, 1,       /* 0, Link Active Status */ | ||||
|  | ||||
| 	Offset(0x60),  /* RSTS - Root Status Register */ | ||||
| 	, 16, | ||||
| 	PSPX, 1,       /* 16,  PME Status */ | ||||
|  | ||||
| 	Offset(0xD8),  /* 0xD8, MPC - Miscellaneous Port Configuration Register */ | ||||
| 	, 30, | ||||
| 	HPEX, 1,       /* 30,  Hot Plug SCI Enable */ | ||||
| 	PMEX, 1,       /* 31,  Power Management SCI Enable */ | ||||
|  | ||||
| 	Offset (0xE0), /* 0xE0, SPR - Scratch Pad Register */ | ||||
| 	SCB0, 1,       /* Scratch bit 0 */ | ||||
|  | ||||
| 	Offset(0xE2),  /* 0xE2, RPPGEN - Root Port Power Gating Enable */ | ||||
| 	, 2, | ||||
| 	L23E, 1,       /* 2,   L23_Rdy Entry Request (L23ER) */ | ||||
| 	L23R, 1,       /* 3,   L23_Rdy to Detect Transition (L23R2DT) */ | ||||
| } | ||||
|  | ||||
| Field (PCIC, AnyAcc, NoLock, WriteAsZeros) { | ||||
| 	Offset(0xDC),  /* 0xDC, SMSCS - SMI/SCI Status Register */ | ||||
| 	, 30, | ||||
| 	HPSX, 1,       /* 30,  Hot Plug SCI Status */ | ||||
| 	PMSX, 1        /* 31,  Power Management SCI Status */ | ||||
| } | ||||
|  | ||||
| // Enter L23 | ||||
| Method (DL23, 0, Serialized) { | ||||
| 	Printf("      GPU PORT DL23 START") | ||||
|  | ||||
| 	L23E = 1 | ||||
| 	Sleep (16) | ||||
| 	Local0 = 0 | ||||
| 	While (L23E) { | ||||
| 		If ((Local0 > 4)) { | ||||
| 			Break | ||||
| 		} | ||||
|  | ||||
| 		Sleep (16) | ||||
| 		Local0++ | ||||
| 	} | ||||
| 	SCB0 = 1 | ||||
|  | ||||
| 	Printf("      GPU PORT DL23 FINISH") | ||||
| } | ||||
|  | ||||
| // Exit L23 | ||||
| Method (L23D, 0, Serialized) { | ||||
| 	Printf("      GPU PORT L23D START") | ||||
|  | ||||
| 	If ((SCB0 == 1)) { | ||||
| 		L23R = 1 | ||||
| 		Local0 = 0 | ||||
| 		While (L23R) { | ||||
| 			If ((Local0 > 4)) { | ||||
| 				Break | ||||
| 			} | ||||
| 			Sleep (16) | ||||
| 			Local0++ | ||||
| 		} | ||||
|  | ||||
| 		SCB0 = 0 | ||||
| 		Local0 = 0 | ||||
| 		While ((LASX == 0)) { | ||||
| 			If ((Local0 > 8)) { | ||||
| 				Break | ||||
| 			} | ||||
| 			Sleep (16) | ||||
| 			Local0++ | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	Printf("      GPU PORT L23D FINISH") | ||||
| } | ||||
|  | ||||
| Method (HPME, 0, Serialized) { | ||||
| 	Printf("  GPU PORT HPME START") | ||||
|  | ||||
| 	If (PMSX == 1) { | ||||
| 		Printf("    Notify GPU driver of PME SCI") | ||||
| 		Notify(DEV0, 0x2) | ||||
| 		Printf("    Clear PME SCI") | ||||
| 		PMSX = 1 | ||||
| 		Printf("    Consume PME notification") | ||||
| 		PSPX = 1 | ||||
| 	} | ||||
|  | ||||
| 	Printf("  GPU PORT HPME FINISH") | ||||
| } | ||||
|  | ||||
| // Main power resource | ||||
| PowerResource (PWRR, 0, 0) { | ||||
| 	Name (_STA, 1) | ||||
|  | ||||
| 	Method (_ON, 0, Serialized) { | ||||
| 		Printf("GPU PORT PWRR._ON") | ||||
|  | ||||
| 		HPME(); | ||||
| 		If (PMEX == 1) { | ||||
| 			Printf("  Disable power management SCI") | ||||
| 			PMEX = 0 | ||||
| 		} | ||||
|  | ||||
| 		^^DEV0._ON() | ||||
|  | ||||
| 		_STA = 1 | ||||
| 	} | ||||
|  | ||||
| 	Method (_OFF, 0, Serialized) { | ||||
| 		Printf("GPU PORT PWRR._OFF") | ||||
|  | ||||
| 		^^DEV0._OFF() | ||||
|  | ||||
| 		If (PMEX == 0) { | ||||
| 			Printf("  Enable power management SCI") | ||||
| 			PMEX = 1 | ||||
| 			HPME() | ||||
| 		} | ||||
|  | ||||
| 		_STA = 0 | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Power resources for entering D0 | ||||
| Name (_PR0, Package () { PWRR }) | ||||
|  | ||||
| // Power resources for entering D3 | ||||
| Name (_PR3, Package () { PWRR }) | ||||
|  | ||||
| #include "common/gpu.asl" | ||||
							
								
								
									
										10
									
								
								src/drivers/gfx/nvidia/chip.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/drivers/gfx/nvidia/chip.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef _DRIVERS_GFX_NVIDIA_CHIP_H_ | ||||
| #define _DRIVERS_GFX_NVIDIA_CHIP_H_ | ||||
|  | ||||
| struct drivers_gfx_nvidia_config { | ||||
| 	/* TODO: Set GPIOs in devicetree? */ | ||||
| }; | ||||
|  | ||||
| #endif /* _DRIVERS_GFX_NVIDIA_CHIP_H_ */ | ||||
							
								
								
									
										19
									
								
								src/drivers/gfx/nvidia/gpu.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/drivers/gfx/nvidia/gpu.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef _DRIVERS_GFX_NVIDIA_GPU_H_ | ||||
| #define _DRIVERS_GFX_NVIDIA_GPU_H_ | ||||
|  | ||||
| #include <stdbool.h> | ||||
|  | ||||
| struct nvidia_gpu_config { | ||||
| 	/* GPIO for GPU_PWR_EN */ | ||||
| 	unsigned int power_gpio; | ||||
| 	/* GPIO for GPU_RST# */ | ||||
| 	unsigned int reset_gpio; | ||||
| 	/* Enable or disable GPU power */ | ||||
| 	bool enable; | ||||
| }; | ||||
|  | ||||
| void nvidia_set_power(const struct nvidia_gpu_config *config); | ||||
|  | ||||
| #endif /* _DRIVERS_NVIDIA_GPU_H_ */ | ||||
							
								
								
									
										71
									
								
								src/drivers/gfx/nvidia/nvidia.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								src/drivers/gfx/nvidia/nvidia.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include "chip.h" | ||||
| #include <console/console.h> | ||||
| #include <device/device.h> | ||||
| #include <device/pci.h> | ||||
| #include <device/pci_ids.h> | ||||
|  | ||||
| #define NVIDIA_SUBSYSTEM_ID_OFFSET 0x40 | ||||
|  | ||||
| static void nvidia_read_resources(struct device *dev) | ||||
| { | ||||
| 	printk(BIOS_DEBUG, "%s: %s\n", __func__, dev_path(dev)); | ||||
|  | ||||
| 	pci_dev_read_resources(dev); | ||||
|  | ||||
| 	// Find all BARs on GPU, mark them above 4g if prefetchable | ||||
| 	for (int bar = PCI_BASE_ADDRESS_0; bar <= PCI_BASE_ADDRESS_5; bar += 4) { | ||||
| 		struct resource *res = probe_resource(dev, bar); | ||||
|  | ||||
| 		if (res) { | ||||
| 			if (res->flags & IORESOURCE_PREFETCH) { | ||||
| 				printk(BIOS_INFO, "  BAR at 0x%02x marked above 4g\n", bar); | ||||
| 				res->flags |= IORESOURCE_ABOVE_4G; | ||||
| 			} else { | ||||
| 				printk(BIOS_DEBUG, "  BAR at 0x%02x not prefetch\n", bar); | ||||
| 			} | ||||
| 		} else { | ||||
| 			printk(BIOS_DEBUG, "  BAR at 0x%02x not found\n", bar); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static void nvidia_set_subsystem(struct device *dev, unsigned int vendor, unsigned int device) | ||||
| { | ||||
| 	pci_write_config32(dev, NVIDIA_SUBSYSTEM_ID_OFFSET, | ||||
| 		((device & 0xffff) << 16) | (vendor & 0xffff)); | ||||
| } | ||||
|  | ||||
| static struct pci_operations nvidia_device_ops_pci = { | ||||
| 	.set_subsystem = nvidia_set_subsystem, | ||||
| }; | ||||
|  | ||||
| static struct device_operations nvidia_device_ops = { | ||||
| 	.read_resources   = nvidia_read_resources, | ||||
| 	.set_resources    = pci_dev_set_resources, | ||||
| 	.enable_resources = pci_dev_enable_resources, | ||||
| #if CONFIG(HAVE_ACPI_TABLES) | ||||
| 	.write_acpi_tables = pci_rom_write_acpi_tables, | ||||
| 	.acpi_fill_ssdt    = pci_rom_ssdt, | ||||
| #endif | ||||
| 	.init             = pci_dev_init, | ||||
| 	.ops_pci          = &nvidia_device_ops_pci, | ||||
|  | ||||
| }; | ||||
|  | ||||
| static void nvidia_enable(struct device *dev) | ||||
| { | ||||
| 	if (!is_dev_enabled(dev) || dev->path.type != DEVICE_PATH_PCI) | ||||
| 		return; | ||||
|  | ||||
| 	if (pci_read_config16(dev, PCI_VENDOR_ID) != PCI_VID_NVIDIA) | ||||
| 		return; | ||||
|  | ||||
| 	dev->ops = &nvidia_device_ops; | ||||
| } | ||||
|  | ||||
| struct chip_operations drivers_gfx_nvidia_ops = { | ||||
| 	.name = "NVIDIA Optimus Graphics Device", | ||||
| 	.enable_dev = nvidia_enable | ||||
| }; | ||||
							
								
								
									
										33
									
								
								src/drivers/gfx/nvidia/romstage.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/drivers/gfx/nvidia/romstage.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <console/console.h> | ||||
| #include <delay.h> | ||||
| #include <device/device.h> | ||||
| #include <device/pci.h> | ||||
| #include <gpio.h> | ||||
| #include "chip.h" | ||||
| #include "gpu.h" | ||||
|  | ||||
| void nvidia_set_power(const struct nvidia_gpu_config *config) | ||||
| { | ||||
| 	if (!config->power_gpio || !config->reset_gpio) { | ||||
| 		printk(BIOS_ERR, "%s: GPU_PWR_EN and GPU_RST# must be set\n", __func__); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	printk(BIOS_DEBUG, "%s: GPU_PWR_EN = %d\n", __func__, config->power_gpio); | ||||
| 	printk(BIOS_DEBUG, "%s: GPU_RST# = %d\n", __func__, config->reset_gpio); | ||||
|  | ||||
| 	gpio_set(config->reset_gpio, 0); | ||||
| 	mdelay(10); | ||||
|  | ||||
| 	if (config->enable) { | ||||
| 		gpio_set(config->power_gpio, 1); | ||||
| 		mdelay(25); | ||||
| 		gpio_set(config->reset_gpio, 1); | ||||
| 	} else { | ||||
| 		gpio_set(config->power_gpio, 0); | ||||
| 	} | ||||
|  | ||||
| 	mdelay(10); | ||||
| } | ||||
							
								
								
									
										5
									
								
								src/drivers/intel/dtbt/Kconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/drivers/intel/dtbt/Kconfig
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| config DRIVERS_INTEL_DTBT | ||||
| 	bool | ||||
| 	default n | ||||
| 	help | ||||
| 	  Support for discrete Thunderbolt controllers | ||||
							
								
								
									
										3
									
								
								src/drivers/intel/dtbt/Makefile.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/drivers/intel/dtbt/Makefile.inc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| # SPDX-License-Identifier: GPL-2.0-only | ||||
|  | ||||
| ramstage-$(CONFIG_DRIVERS_INTEL_DTBT) += dtbt.c | ||||
							
								
								
									
										8
									
								
								src/drivers/intel/dtbt/chip.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/drivers/intel/dtbt/chip.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef _DRIVERS_INTEL_DTBT_CHIP_H_ | ||||
| #define _DRIVERS_INTEL_DTBT_CHIP_H_ | ||||
|  | ||||
| struct drivers_intel_dtbt_config {}; | ||||
|  | ||||
| #endif /* _DRIVERS_INTEL_DTBT_CHIP_H_ */ | ||||
							
								
								
									
										214
									
								
								src/drivers/intel/dtbt/dtbt.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										214
									
								
								src/drivers/intel/dtbt/dtbt.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,214 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include "chip.h" | ||||
| #include <acpi/acpigen.h> | ||||
| #include <console/console.h> | ||||
| #include <delay.h> | ||||
| #include <device/device.h> | ||||
| #include <device/pci.h> | ||||
| #include <device/pciexp.h> | ||||
| #include <device/pci_ids.h> | ||||
|  | ||||
| #define PCIE2TBT 0x54C | ||||
| #define PCIE2TBT_GO2SX ((0x02 << 1) | 1) | ||||
| #define PCIE2TBT_GO2SX_NO_WAKE ((0x03 << 1) | 1) | ||||
| #define PCIE2TBT_SX_EXIT_TBT_CONNECTED ((0x04 << 1) | 1) | ||||
| #define PCIE2TBT_SX_EXIT_NO_TBT_CONNECTED ((0x05 << 1) | 1) | ||||
| #define PCIE2TBT_SET_SECURITY_LEVEL ((0x08 << 1) | 1) | ||||
| #define PCIE2TBT_GET_SECURITY_LEVEL ((0x09 << 1) | 1) | ||||
| #define PCIE2TBT_BOOT_ON ((0x18 << 1) | 1) | ||||
| #define TBT2PCIE 0x548 | ||||
|  | ||||
| static void dtbt_cmd(struct device *dev, u32 command) | ||||
| { | ||||
| 	printk(BIOS_DEBUG, "DTBT send command %08x\n", command); | ||||
|  | ||||
| 	pci_write_config32(dev, PCIE2TBT, command); | ||||
|  | ||||
| 	u32 timeout; | ||||
| 	u32 status; | ||||
| 	for (timeout = 1000000; timeout > 0; timeout--) { | ||||
| 		status = pci_read_config32(dev, TBT2PCIE); | ||||
| 		if (status & 1) { | ||||
| 			break; | ||||
| 		} | ||||
| 		udelay(1); | ||||
| 	} | ||||
| 	if (timeout == 0) { | ||||
| 		printk(BIOS_ERR, "DTBT command %08x timeout on status %08x\n", command, status); | ||||
| 	} | ||||
|  | ||||
| 	printk(BIOS_DEBUG, "DTBT command %08x status %08x\n", command, status); | ||||
|  | ||||
| 	pci_write_config32(dev, PCIE2TBT, 0); | ||||
|  | ||||
| 	u32 status_clear; | ||||
| 	for (timeout = 1000000; timeout > 0; timeout--) { | ||||
| 		status_clear = pci_read_config32(dev, TBT2PCIE); | ||||
| 		if (!(status_clear & 1)) { | ||||
| 			break; | ||||
| 		} | ||||
| 		udelay(1); | ||||
| 	} | ||||
| 	if (timeout == 0) { | ||||
| 		printk(BIOS_ERR, "DTBT command %08x timeout on status clear %08x\n", command, status_clear); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static void dtbt_fill_ssdt(const struct device *dev) | ||||
| { | ||||
| 	printk(BIOS_DEBUG, "DTBT fill SSDT\n"); | ||||
|  | ||||
| 	if (!dev) { | ||||
| 		printk(BIOS_ERR, "DTBT device invalid\n"); | ||||
| 	} | ||||
| 	printk(BIOS_DEBUG, "  Dev %s\n", dev_path(dev)); | ||||
|  | ||||
| 	struct bus *bus = dev->upstream; | ||||
| 	if (!bus) { | ||||
| 		printk(BIOS_ERR, "DTBT bus invalid\n"); | ||||
| 	} | ||||
|  | ||||
| 	struct device *parent = bus->dev; | ||||
| 	if (!parent || parent->path.type != DEVICE_PATH_PCI) { | ||||
| 		printk(BIOS_ERR, "DTBT parent invalid\n"); | ||||
| 		return; | ||||
| 	} | ||||
| 	printk(BIOS_DEBUG, "  Parent %s\n", dev_path(parent)); | ||||
|  | ||||
| 	const char *parent_scope = acpi_device_path(parent); | ||||
| 	if (!parent_scope) { | ||||
| 		printk(BIOS_ERR, "DTBT parent scope not valid\n"); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	{ /* Scope */ | ||||
| 		printk(BIOS_DEBUG, "  Scope %s\n", parent_scope); | ||||
| 		acpigen_write_scope(parent_scope); | ||||
|  | ||||
| 		struct acpi_dp *dsd = acpi_dp_new_table("_DSD"); | ||||
|  | ||||
| 		/* Indicate that device supports hotplug in D3. */ | ||||
| 		acpi_device_add_hotplug_support_in_d3(dsd); | ||||
|  | ||||
| 		/* Indicate that port is external. */ | ||||
| 		acpi_device_add_external_facing_port(dsd); | ||||
|  | ||||
| 		acpi_dp_write(dsd); | ||||
|  | ||||
| 		{ /* Device */ | ||||
| 			const char *dev_name = acpi_device_name(dev); | ||||
| 			printk(BIOS_DEBUG, "    Device %s\n", dev_name); | ||||
| 			acpigen_write_device(dev_name); | ||||
|  | ||||
| 			acpigen_write_name_integer("_ADR", 0); | ||||
|  | ||||
| 			uintptr_t mmconf_base = (uintptr_t)CONFIG_ECAM_MMCONF_BASE_ADDRESS | ||||
| 						+ (((uintptr_t)(bus->secondary)) << 20); | ||||
| 			printk(BIOS_DEBUG, "      MMCONF base %08lx\n", mmconf_base); | ||||
| 			const struct opregion opregion = OPREGION("PXCS", SYSTEMMEMORY, mmconf_base, 0x1000); | ||||
| 			const struct fieldlist fieldlist[] = { | ||||
| 				FIELDLIST_OFFSET(TBT2PCIE), | ||||
| 				FIELDLIST_NAMESTR("TB2P", 32), | ||||
| 				FIELDLIST_OFFSET(PCIE2TBT), | ||||
| 				FIELDLIST_NAMESTR("P2TB", 32), | ||||
| 			}; | ||||
| 			acpigen_write_opregion(&opregion); | ||||
| 			acpigen_write_field("PXCS", fieldlist, ARRAY_SIZE(fieldlist), | ||||
| 					    FIELD_DWORDACC | FIELD_NOLOCK | FIELD_PRESERVE); | ||||
|  | ||||
| 			{ /* Method */ | ||||
| 				acpigen_write_method_serialized("PTS", 0); | ||||
|  | ||||
| 				acpigen_write_debug_string("DTBT prepare to sleep"); | ||||
|  | ||||
| 				acpigen_write_store_int_to_namestr(PCIE2TBT_GO2SX_NO_WAKE, "P2TB"); | ||||
| 				acpigen_write_delay_until_namestr_int(600, "TB2P", PCIE2TBT_GO2SX_NO_WAKE); | ||||
|  | ||||
| 				acpigen_write_debug_namestr("TB2P"); | ||||
|  | ||||
| 				acpigen_write_store_int_to_namestr(0, "P2TB"); | ||||
| 				acpigen_write_delay_until_namestr_int(600, "TB2P", 0); | ||||
|  | ||||
| 				acpigen_write_debug_namestr("TB2P"); | ||||
|  | ||||
| 				acpigen_write_method_end(); | ||||
| 			} | ||||
|  | ||||
| 			acpigen_write_device_end(); | ||||
| 		} | ||||
|  | ||||
| 		acpigen_write_scope_end(); | ||||
| 	} | ||||
|  | ||||
| 	{ /* Scope */ | ||||
| 		acpigen_write_scope("\\"); | ||||
|  | ||||
| 		{ /* Method */ | ||||
| 			acpigen_write_method("TBTS", 0); | ||||
|  | ||||
| 			acpigen_emit_namestring(acpi_device_path_join(dev, "PTS")); | ||||
|  | ||||
| 			acpigen_write_method_end(); | ||||
| 		} | ||||
|  | ||||
| 		acpigen_write_scope_end(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static const char *dtbt_acpi_name(const struct device *dev) | ||||
| { | ||||
| 	return "DTBT"; | ||||
| } | ||||
|  | ||||
| static struct pci_operations dtbt_device_ops_pci = { | ||||
| 	.set_subsystem = 0, | ||||
| }; | ||||
|  | ||||
| static struct device_operations dtbt_device_ops = { | ||||
| 	.read_resources   = pci_bus_read_resources, | ||||
| 	.set_resources    = pci_dev_set_resources, | ||||
| 	.enable_resources = pci_bus_enable_resources, | ||||
| 	.acpi_fill_ssdt   = dtbt_fill_ssdt, | ||||
| 	.acpi_name        = dtbt_acpi_name, | ||||
| 	.scan_bus         = pciexp_scan_bridge, | ||||
| 	.reset_bus        = pci_bus_reset, | ||||
| 	.ops_pci          = &dtbt_device_ops_pci, | ||||
| }; | ||||
|  | ||||
| static void dtbt_enable(struct device *dev) | ||||
| { | ||||
| 	if (!is_dev_enabled(dev) || dev->path.type != DEVICE_PATH_PCI) | ||||
| 		return; | ||||
|  | ||||
| 	if (pci_read_config16(dev, PCI_VENDOR_ID) != PCI_VID_INTEL) | ||||
| 		return; | ||||
|  | ||||
| 	// TODO: check device ID | ||||
|  | ||||
| 	dev->ops = &dtbt_device_ops; | ||||
|  | ||||
| 	printk(BIOS_INFO, "DTBT controller found at %s\n", dev_path(dev)); | ||||
|  | ||||
| 	printk(BIOS_DEBUG, "DTBT get security level\n"); | ||||
| 	dtbt_cmd(dev, PCIE2TBT_GET_SECURITY_LEVEL); | ||||
|  | ||||
| 	printk(BIOS_DEBUG, "DTBT set security level SL0\n"); | ||||
| 	dtbt_cmd(dev, PCIE2TBT_SET_SECURITY_LEVEL); | ||||
|  | ||||
| 	printk(BIOS_DEBUG, "DTBT get security level\n"); | ||||
| 	dtbt_cmd(dev, PCIE2TBT_GET_SECURITY_LEVEL); | ||||
|  | ||||
| 	if (acpi_is_wakeup_s3()) { | ||||
| 		printk(BIOS_INFO, "DTBT SX exit\n"); | ||||
| 		dtbt_cmd(dev, PCIE2TBT_SX_EXIT_TBT_CONNECTED); | ||||
| 	} else { | ||||
| 		printk(BIOS_INFO, "DTBT boot on\n"); | ||||
| 		dtbt_cmd(dev, PCIE2TBT_BOOT_ON); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| struct chip_operations drivers_intel_dtbt_ops = { | ||||
| 	.name = "Intel Discrete Thunderbolt Device", | ||||
| 	.enable_dev = dtbt_enable | ||||
| }; | ||||
| @@ -9,6 +9,7 @@ | ||||
| #include <smmstore.h> | ||||
| #include <types.h> | ||||
| #include <cbmem.h> | ||||
| #include <delay.h> | ||||
|  | ||||
| static struct smmstore_params_info info; | ||||
|  | ||||
| @@ -39,6 +40,7 @@ static void init_store(void *unused) | ||||
| { | ||||
| 	struct smmstore_params_init args; | ||||
| 	uint32_t ret = ~0; | ||||
| 	uint8_t retry = 5; | ||||
|  | ||||
| 	if (smmstore_get_info(&info) < 0) { | ||||
| 		printk(BIOS_INFO, "SMMSTORE: Failed to get meta data\n"); | ||||
| @@ -56,8 +58,17 @@ static void init_store(void *unused) | ||||
|  | ||||
| 	printk(BIOS_INFO, "SMMSTORE: Setting up SMI handler\n"); | ||||
|  | ||||
| 	/* Issue SMI using APM to update the com buffer and to lock the SMMSTORE */ | ||||
| 	/* | ||||
| 	 * Issue SMI using APM to update the com buffer and to lock the SMMSTORE. | ||||
| 	 * Retry 5 times in case the SMI isn't triggered immediately. | ||||
| 	 */ | ||||
| 	do { | ||||
| 		ret = call_smm(APM_CNT_SMMSTORE, SMMSTORE_CMD_INIT, &args); | ||||
| 		if (ret == SMMSTORE_RET_SUCCESS) | ||||
| 			break; | ||||
|  | ||||
| 		mdelay(1); | ||||
| 	} while (retry--); | ||||
|  | ||||
| 	if (ret != SMMSTORE_RET_SUCCESS) { | ||||
| 		printk(BIOS_ERR, "SMMSTORE: Failed to install com buffer\n"); | ||||
|   | ||||
| @@ -15,6 +15,11 @@ config EC_SYSTEM76_EC_DGPU | ||||
| 	bool | ||||
| 	default n | ||||
|  | ||||
| config EC_SYSTEM76_EC_LOCKDOWN | ||||
| 	depends on EC_SYSTEM76_EC | ||||
| 	bool | ||||
| 	default n | ||||
|  | ||||
| config EC_SYSTEM76_EC_OLED | ||||
| 	depends on EC_SYSTEM76_EC | ||||
| 	bool | ||||
|   | ||||
| @@ -4,6 +4,7 @@ ifeq ($(CONFIG_EC_SYSTEM76_EC),y) | ||||
| all-y += system76_ec.c | ||||
|  | ||||
| ramstage-y += smbios.c | ||||
| ramstage-$(CONFIG_EC_SYSTEM76_EC_LOCKDOWN) += lockdown.c | ||||
|  | ||||
| smm-$(CONFIG_DEBUG_SMI) += system76_ec.c | ||||
|  | ||||
|   | ||||
							
								
								
									
										59
									
								
								src/ec/system76/ec/lockdown.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								src/ec/system76/ec/lockdown.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include "system76_ec.h" | ||||
| #include <bootstate.h> | ||||
| #include <commonlib/region.h> | ||||
| #include <fmap.h> | ||||
| #include <spi_flash.h> | ||||
|  | ||||
| static int protect_region_by_name(const char *name) | ||||
| { | ||||
| 	int res; | ||||
| 	struct region region; | ||||
|  | ||||
| 	res = fmap_locate_area(name, ®ion); | ||||
| 	if (res < 0) { | ||||
| 		printk(BIOS_ERR, "fmap_locate_area '%s' failed: %d\n", name, res); | ||||
| 		return res; | ||||
| 	} | ||||
|  | ||||
| 	res = spi_flash_ctrlr_protect_region( | ||||
| 		boot_device_spi_flash(), | ||||
| 		®ion, | ||||
| 		WRITE_PROTECT | ||||
| 	); | ||||
| 	if (res < 0) { | ||||
| 		printk(BIOS_ERR, "spi_flash_ctrlr_protect_region '%s' failed: %d\n", name, res); | ||||
| 		return res; | ||||
| 	} | ||||
|  | ||||
| 	printk(BIOS_INFO, "protected '%s'\n", name); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static void lock(void *unused) | ||||
| { | ||||
| 	uint8_t state = SYSTEM76_EC_SECURITY_STATE_UNLOCK; | ||||
| 	if (!system76_ec_security_get(&state)) { | ||||
| 		printk(BIOS_INFO, "failed to get security state, assuming unlocked\n"); | ||||
| 		state = SYSTEM76_EC_SECURITY_STATE_UNLOCK; | ||||
| 	} | ||||
|  | ||||
| 	printk(BIOS_INFO, "security state: %d\n", state); | ||||
| 	if (state != SYSTEM76_EC_SECURITY_STATE_UNLOCK) { | ||||
| 		// Protect WP_RO region, which should contain FMAP and COREBOOT | ||||
| 		protect_region_by_name("WP_RO"); | ||||
| 		// Protect RW_MRC_CACHE region, this must be done after it is written | ||||
| 		protect_region_by_name("RW_MRC_CACHE"); | ||||
| 		//TODO: protect entire flash except when in SMM? | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /* | ||||
|  * Keep in sync with mrc_cache.c | ||||
|  */ | ||||
| #if CONFIG(MRC_WRITE_NV_LATE) | ||||
| BOOT_STATE_INIT_ENTRY(BS_OS_RESUME_CHECK, BS_ON_EXIT, lock, NULL); | ||||
| #else | ||||
| BOOT_STATE_INIT_ENTRY(BS_DEV_RESOURCES, BS_ON_ENTRY, lock, NULL); | ||||
| #endif | ||||
| @@ -26,6 +26,9 @@ | ||||
| #define CMD_PRINT_REG_LEN 3 | ||||
| #define CMD_PRINT_REG_DATA 4 | ||||
|  | ||||
| // Get security state command | ||||
| #define CMD_SECURITY_GET 20 | ||||
|  | ||||
| static inline uint8_t system76_ec_read(uint8_t addr) | ||||
| { | ||||
| 	return inb(SYSTEM76_EC_BASE + (uint16_t)addr); | ||||
| @@ -110,3 +113,9 @@ bool system76_ec_cmd(uint8_t cmd, const uint8_t *request_data, | ||||
|  | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| bool system76_ec_security_get(uint8_t *state) | ||||
| { | ||||
| 	*state = SYSTEM76_EC_SECURITY_STATE_LOCK; | ||||
| 	return system76_ec_cmd(CMD_SECURITY_GET, NULL, 0, state, sizeof(*state)); | ||||
| } | ||||
|   | ||||
| @@ -6,6 +6,15 @@ | ||||
| #include <stdbool.h> | ||||
| #include <stdint.h> | ||||
|  | ||||
| // Default value, flashing is prevented, cannot be set with CMD_SECURITY_SET | ||||
| #define SYSTEM76_EC_SECURITY_STATE_LOCK 0 | ||||
| // Flashing is allowed, cannot be set with CMD_SECURITY_SET | ||||
| #define SYSTEM76_EC_SECURITY_STATE_UNLOCK 1 | ||||
| // Flashing will be prevented on the next reboot | ||||
| #define SYSTEM76_EC_SECURITY_STATE_PREPARE_LOCK 2 | ||||
| // Flashing will be allowed on the next reboot | ||||
| #define SYSTEM76_EC_SECURITY_STATE_PREPARE_UNLOCK 3 | ||||
|  | ||||
| /* | ||||
|  * Send a command to the EC.  request_data/request_size are the request payload, | ||||
|  * request_data can be NULL if request_size is 0.  reply_data/reply_size are | ||||
| @@ -14,4 +23,6 @@ | ||||
| bool system76_ec_cmd(uint8_t cmd, const uint8_t *request_data, | ||||
| 	uint8_t request_size, uint8_t *reply_data, uint8_t reply_size); | ||||
|  | ||||
| bool system76_ec_security_get(uint8_t *state); | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -35,6 +35,18 @@ | ||||
| #define DDR4_SPD_PART_OFF	329 | ||||
| #define DDR4_SPD_PART_LEN	20 | ||||
| #define DDR4_SPD_SN_OFF		325 | ||||
| #define MAX_SPD_PAGE_SIZE_SPD5	128 | ||||
| #define MAX_SPD_SIZE		(SPD_PAGE_LEN * SPD_SN_LEN) | ||||
| #define SPD_HUB_MEMREG(addr)	((u8)(0x80 | (addr))) | ||||
| #define SPD5_MR11		0x0B | ||||
| #define SPD5_MR0		0x00 | ||||
| #define SPD5_MEMREG_REG(addr)	((u8)((~0x80) & (addr))) | ||||
| #define SPD5_MR0_SPD5_HUB_DEV	0x51 | ||||
|  | ||||
| struct spd_offset_table { | ||||
| 	u16 start;		/* Offset 0 */ | ||||
| 	u16 end;		/* Offset 2 */ | ||||
| }; | ||||
|  | ||||
| struct spd_block { | ||||
| 	u8 addr_map[CONFIG_DIMM_MAX]; /* 7 bit I2C addresses */ | ||||
|   | ||||
| @@ -126,7 +126,7 @@ static int rtc_month_days(unsigned int month, unsigned int year) | ||||
| { | ||||
| 	int month_days[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | ||||
|  | ||||
| 	return month_days[month] + (LEAP_YEAR(year) && month == 2); | ||||
| 	return month_days[month] + (LEAP_YEAR(year) && month == 1); | ||||
| } | ||||
|  | ||||
| int rtc_invalid(const struct rtc_time *tm) | ||||
|   | ||||
| @@ -209,7 +209,7 @@ enum cb_err spd_fill_from_cache(uint8_t *spd_cache, struct spd_block *blk) | ||||
|  | ||||
| 	dram_type = *(spd_cache + SC_SPD_OFFSET(i) + SPD_DRAM_TYPE); | ||||
|  | ||||
| 	if (dram_type == SPD_DRAM_DDR4) | ||||
| 	if (dram_type == SPD_DRAM_DDR4 || dram_type == SPD_DRAM_DDR5) | ||||
| 		blk->len = SPD_PAGE_LEN_DDR4; | ||||
| 	else | ||||
| 		blk->len = SPD_PAGE_LEN; | ||||
|   | ||||
| @@ -7,6 +7,7 @@ config BOARD_SPECIFIC_OPTIONS | ||||
| 	select BOARD_ROMSIZE_KB_16384 | ||||
| 	select DRIVERS_GENERIC_CBFS_SERIAL | ||||
| 	select DRIVERS_GENERIC_CBFS_UUID | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_I2C_HID | ||||
| 	select DRIVERS_I2C_TAS5825M | ||||
| 	select EC_SYSTEM76_EC | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| ## SPDX-License-Identifier: GPL-2.0-only | ||||
|  | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/include | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/variants/$(VARIANT_DIR)/include | ||||
|  | ||||
| bootblock-y += bootblock.c | ||||
| bootblock-y += variants/$(VARIANT_DIR)/gpio_early.c | ||||
|   | ||||
| @@ -1,11 +1,19 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <variant/gpio.h> | ||||
|  | ||||
| #define EC_GPE_SCI 0x03 /* GPP_K3 */ | ||||
| #define EC_GPE_SWI 0x06 /* GPP_K6 */ | ||||
| #include <ec/system76/ec/acpi/ec.asl> | ||||
|  | ||||
| Scope (\_SB) { | ||||
| 	#include "sleep.asl" | ||||
| 	Scope (PCI0) { | ||||
| 		Device (PEGP) { | ||||
| 			Name (_ADR, CONFIG_DRIVERS_GFX_NVIDIA_BRIDGE << 16) | ||||
| 			#include <drivers/gfx/nvidia/acpi/coffeelake.asl> | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| Scope (\_GPE) { | ||||
|   | ||||
| @@ -56,6 +56,12 @@ chip soc/intel/cannonlake | ||||
| 			# PCI Express Graphics #0 x16, Clock 8 (NVIDIA GPU) | ||||
| 			register "PcieClkSrcUsage[8]" = "0x40" | ||||
| 			register "PcieClkSrcClkReq[8]" = "8" | ||||
| 			chip drivers/gfx/nvidia | ||||
| 				device pci 00.0 on end # VGA controller | ||||
| 				device pci 00.1 on end # Audio device | ||||
| 				device pci 00.2 on end # USB xHCI Host controller | ||||
| 				device pci 00.3 on end # USB Type-C UCSI controller | ||||
| 			end | ||||
| 		end | ||||
| 		device pci 02.0 on  end # Integrated Graphics Device | ||||
| 		device pci 04.0 on      # SA Thermal device | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/gfx/nvidia/gpu.h> | ||||
| #include <soc/cnl_memcfg_init.h> | ||||
| #include <soc/romstage.h> | ||||
| #include <variant/gpio.h> | ||||
|  | ||||
| static const struct cnl_mb_cfg memcfg = { | ||||
| 	.spd[0] = { | ||||
| @@ -20,5 +22,17 @@ static const struct cnl_mb_cfg memcfg = { | ||||
|  | ||||
| void mainboard_memory_init_params(FSPM_UPD *memupd) | ||||
| { | ||||
| 	const struct nvidia_gpu_config config = { | ||||
| 		.power_gpio = DGPU_PWR_EN, | ||||
| 		.reset_gpio = DGPU_RST_N, | ||||
| 		.enable = true, | ||||
| 	}; | ||||
|  | ||||
| 	// Enable dGPU power | ||||
| 	nvidia_set_power(&config); | ||||
|  | ||||
| 	// Set primary display to internal graphics | ||||
| 	memupd->FspmConfig.PrimaryDisplay = 0; | ||||
|  | ||||
| 	cannonlake_memcfg_init(&memupd->FspmConfig, &memcfg); | ||||
| } | ||||
|   | ||||
| @@ -3,7 +3,16 @@ | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
| 
 | ||||
| #include <soc/gpio.h> | ||||
| 
 | ||||
| #define DGPU_RST_N	GPP_F22 | ||||
| #define DGPU_PWR_EN	GPP_F23 | ||||
| #define DGPU_GC6	GPP_C12 | ||||
| #define DGPU_SSID	0x65d11558 | ||||
| 
 | ||||
| #ifndef __ACPI__ | ||||
| void variant_configure_early_gpios(void); | ||||
| void variant_configure_gpios(void); | ||||
| #endif | ||||
| 
 | ||||
| #endif | ||||
| @@ -0,0 +1,18 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_F22 | ||||
| #define DGPU_PWR_EN	GPP_F23 | ||||
| #define DGPU_GC6	GPP_C12 | ||||
| #define DGPU_SSID	0x65e11558 | ||||
|  | ||||
| #ifndef __ACPI__ | ||||
| void variant_configure_early_gpios(void); | ||||
| void variant_configure_gpios(void); | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| @@ -10,6 +10,7 @@ config BOARD_SYSTEM76_ADL_COMMON | ||||
| 	select DRIVERS_INTEL_PMC | ||||
| 	select DRIVERS_INTEL_USB4_RETIMER | ||||
| 	select EC_SYSTEM76_EC | ||||
| 	select EC_SYSTEM76_EC_LOCKDOWN | ||||
| 	select HAVE_ACPI_RESUME | ||||
| 	select HAVE_ACPI_TABLES | ||||
| 	select HAVE_CMOS_DEFAULT | ||||
| @@ -35,10 +36,12 @@ config BOARD_SYSTEM76_GALP6 | ||||
|  | ||||
| config BOARD_SYSTEM76_GAZE17_3050 | ||||
| 	select BOARD_SYSTEM76_ADL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
|  | ||||
| config BOARD_SYSTEM76_GAZE17_3060_B | ||||
| 	select BOARD_SYSTEM76_ADL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
| 	select MAINBOARD_USES_IFD_GBE_REGION | ||||
|  | ||||
| @@ -48,11 +51,15 @@ config BOARD_SYSTEM76_LEMP11 | ||||
|  | ||||
| config BOARD_SYSTEM76_ORYP9 | ||||
| 	select BOARD_SYSTEM76_ADL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	select DRIVERS_I2C_TAS5825M | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
|  | ||||
| config BOARD_SYSTEM76_ORYP10 | ||||
| 	select BOARD_SYSTEM76_ADL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
|  | ||||
| if BOARD_SYSTEM76_ADL_COMMON | ||||
| @@ -97,6 +104,10 @@ config MAINBOARD_VERSION | ||||
| 	default "oryp9" if BOARD_SYSTEM76_ORYP9 | ||||
| 	default "oryp10" if BOARD_SYSTEM76_ORYP10 | ||||
|  | ||||
| config CMOS_DEFAULT_FILE | ||||
| 	default "src/mainboard/\$(MAINBOARDDIR)/cmos-csme.default" if BOARD_SYSTEM76_DARP8 | ||||
| 	default "src/mainboard/\$(MAINBOARDDIR)/cmos.default" | ||||
|  | ||||
| config CONSOLE_POST | ||||
| 	default y | ||||
|  | ||||
| @@ -106,6 +117,12 @@ config D3COLD_SUPPORT | ||||
| config DIMM_SPD_SIZE | ||||
| 	default 512 | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_TPP | ||||
| 	default 45 if BOARD_SYSTEM76_ORYP9 || BOARD_SYSTEM76_ORYP10 | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_MAX | ||||
| 	default 25 if BOARD_SYSTEM76_ORYP9 || BOARD_SYSTEM76_ORYP10 | ||||
|  | ||||
| config FMDFILE | ||||
| 	default "src/mainboard/\$(CONFIG_MAINBOARD_DIR)/board.fmd" | ||||
|  | ||||
|   | ||||
| @@ -2,6 +2,10 @@ | ||||
|  | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/include | ||||
|  | ||||
| ifeq ($(CONFIG_DRIVERS_GFX_NVIDIA),y) | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/variants/$(VARIANT_DIR)/include | ||||
| endif | ||||
|  | ||||
| bootblock-y += bootblock.c | ||||
| bootblock-y += variants/$(VARIANT_DIR)/gpio_early.c | ||||
|  | ||||
|   | ||||
| @@ -1,31 +0,0 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/intel/gma/acpi/gma.asl> | ||||
|  | ||||
| Scope (GFX0) | ||||
| { | ||||
| 	Name (BRIG, Package (22) { | ||||
| 		40, /* default AC */ | ||||
| 		40, /* default Battery */ | ||||
| 		5, | ||||
| 		10, | ||||
| 		15, | ||||
| 		20, | ||||
| 		25, | ||||
| 		30, | ||||
| 		35, | ||||
| 		40, | ||||
| 		45, | ||||
| 		50, | ||||
| 		55, | ||||
| 		60, | ||||
| 		65, | ||||
| 		70, | ||||
| 		75, | ||||
| 		80, | ||||
| 		85, | ||||
| 		90, | ||||
| 		95, | ||||
| 		100 | ||||
| 	}) | ||||
| } | ||||
| @@ -1,5 +1,9 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #if CONFIG(DRIVERS_GFX_NVIDIA) | ||||
| #include <variant/gpio.h> | ||||
| #endif | ||||
|  | ||||
| #define EC_GPE_SCI 0x6E | ||||
| #define EC_GPE_SWI 0x6B | ||||
| #include <ec/system76/ec/acpi/ec.asl> | ||||
| @@ -7,6 +11,10 @@ | ||||
| Scope (\_SB) { | ||||
| 	#include "sleep.asl" | ||||
| 	Scope (PCI0) { | ||||
| 		#include "backlight.asl" | ||||
| #if CONFIG(DRIVERS_GFX_NVIDIA) | ||||
| 		Scope (PEG2) { | ||||
| 			#include <drivers/gfx/nvidia/acpi/tigerlake.asl> | ||||
| 		} | ||||
| #endif | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										3
									
								
								src/mainboard/system76/adl/cmos-csme.default
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/mainboard/system76/adl/cmos-csme.default
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| boot_option=Fallback | ||||
| debug_level=Debug | ||||
| me_state=Enable | ||||
| @@ -81,6 +81,7 @@ chip soc/intel/alderlake | ||||
| 		end | ||||
| 		device ref p2sb on end | ||||
| 		device ref hda on | ||||
| 			register "pch_hda_sdi_enable[0]" = "1" | ||||
| 			register "pch_hda_audio_link_hda_enable" = "1" | ||||
| 			register "pch_hda_idisp_codec_enable" = "1" | ||||
| 			register "pch_hda_idisp_link_frequency" = "HDA_LINKFREQ_96MHZ" | ||||
|   | ||||
| @@ -20,6 +20,7 @@ DefinitionBlock( | ||||
| 		#include <soc/intel/common/block/acpi/acpi/northbridge.asl> | ||||
| 		#include <soc/intel/alderlake/acpi/southbridge.asl> | ||||
| 		#include <soc/intel/alderlake/acpi/tcss.asl> | ||||
| 		#include <drivers/intel/gma/acpi/default_brightness_levels.asl> | ||||
| 	} | ||||
|  | ||||
| 	#include <southbridge/intel/common/acpi/sleepstates.asl> | ||||
|   | ||||
| @@ -1,4 +1,6 @@ | ||||
| chip soc/intel/alderlake | ||||
| 	register "s0ix_enable" = "1" | ||||
|  | ||||
| 	register "power_limits_config[ADL_P_282_442_482_28W_CORE]" = "{ | ||||
| 		.tdp_pl1_override = 20, | ||||
| 		.tdp_pl2_override = 56, | ||||
| @@ -152,6 +154,7 @@ chip soc/intel/alderlake | ||||
| 				.clk_src = 4, | ||||
| 				.clk_req = 4, | ||||
| 				.flags = PCIE_RP_LTR, | ||||
| 				.pcie_rp_detect_timeout_ms = 50, | ||||
| 			}" | ||||
| 			# FIXME: Drives do not exit D3cold on S3 exit | ||||
| 			#chip soc/intel/common/block/pcie/rtd3 | ||||
|   | ||||
| @@ -0,0 +1,13 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_B2 | ||||
| #define DGPU_PWR_EN	GPP_A14 | ||||
| #define DGPU_GC6	GPP_F13 | ||||
| #define DGPU_SSID	0x866d1558 | ||||
|  | ||||
| #endif | ||||
| @@ -38,6 +38,10 @@ chip soc/intel/alderlake | ||||
| 				.clk_req = 3, | ||||
| 				.flags = PCIE_RP_LTR, | ||||
| 			}" | ||||
| 			chip drivers/gfx/nvidia | ||||
| 				device pci 00.0 on end # VGA controller | ||||
| 				device pci 00.1 on end # Audio device | ||||
| 			end | ||||
| 		end | ||||
| 		device ref pcie4_0 on | ||||
| 			# PCIe PEG0 x4, Clock 0 (SSD2) | ||||
| @@ -98,6 +102,7 @@ chip soc/intel/alderlake | ||||
| 				.clk_src = 1, | ||||
| 				.clk_req = 1, | ||||
| 				.flags = PCIE_RP_LTR, | ||||
| 				.pcie_rp_detect_timeout_ms = 50, | ||||
| 			}" | ||||
| 		end | ||||
| 		device ref pcie_rp9 on | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/gfx/nvidia/gpu.h> | ||||
| #include <soc/meminit.h> | ||||
| #include <soc/romstage.h> | ||||
| #include <variant/gpio.h> | ||||
|  | ||||
| void mainboard_memory_init_params(FSPM_UPD *mupd) | ||||
| { | ||||
| @@ -17,6 +19,14 @@ void mainboard_memory_init_params(FSPM_UPD *mupd) | ||||
| 	}; | ||||
| 	const bool half_populated = false; | ||||
|  | ||||
| 	const struct nvidia_gpu_config config = { | ||||
| 		.power_gpio = DGPU_PWR_EN, | ||||
| 		.reset_gpio = DGPU_RST_N, | ||||
| 		.enable = true, | ||||
| 	}; | ||||
| 	// Enable dGPU power | ||||
| 	nvidia_set_power(&config); | ||||
|  | ||||
| 	// Set primary display to internal graphics | ||||
| 	mupd->FspmConfig.PrimaryDisplay = 0; | ||||
|  | ||||
|   | ||||
| @@ -0,0 +1,13 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_B2 | ||||
| #define DGPU_PWR_EN	GPP_A14 | ||||
| #define DGPU_GC6	GPP_F13 | ||||
| #define DGPU_SSID	0x867c1558 | ||||
|  | ||||
| #endif | ||||
| @@ -38,6 +38,10 @@ chip soc/intel/alderlake | ||||
| 				.clk_req = 3, | ||||
| 				.flags = PCIE_RP_LTR, | ||||
| 			}" | ||||
| 			chip drivers/gfx/nvidia | ||||
| 				device pci 00.0 on end # VGA controller | ||||
| 				device pci 00.1 on end # Audio device | ||||
| 			end | ||||
| 		end | ||||
| 		device ref igpu on | ||||
| 			# DDIA is eDP | ||||
| @@ -130,6 +134,7 @@ chip soc/intel/alderlake | ||||
| 				.clk_src = 1, | ||||
| 				.clk_req = 1, | ||||
| 				.flags = PCIE_RP_LTR, | ||||
| 				.pcie_rp_detect_timeout_ms = 50, | ||||
| 			}" | ||||
| 		end | ||||
| 		device ref gbe on end | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/gfx/nvidia/gpu.h> | ||||
| #include <soc/meminit.h> | ||||
| #include <soc/romstage.h> | ||||
| #include <variant/gpio.h> | ||||
|  | ||||
| void mainboard_memory_init_params(FSPM_UPD *mupd) | ||||
| { | ||||
| @@ -17,6 +19,14 @@ void mainboard_memory_init_params(FSPM_UPD *mupd) | ||||
| 	}; | ||||
| 	const bool half_populated = false; | ||||
|  | ||||
| 	const struct nvidia_gpu_config config = { | ||||
| 		.power_gpio = DGPU_PWR_EN, | ||||
| 		.reset_gpio = DGPU_RST_N, | ||||
| 		.enable = true, | ||||
| 	}; | ||||
| 	// Enable dGPU power | ||||
| 	nvidia_set_power(&config); | ||||
|  | ||||
| 	// Set primary display to internal graphics | ||||
| 	mupd->FspmConfig.PrimaryDisplay = 0; | ||||
|  | ||||
|   | ||||
| @@ -138,6 +138,7 @@ chip soc/intel/alderlake | ||||
| 				.clk_src = 1, | ||||
| 				.clk_req = 1, | ||||
| 				.flags = PCIE_RP_LTR, | ||||
| 				.pcie_rp_detect_timeout_ms = 50, | ||||
| 			}" | ||||
| 			# FIXME: Drives do not exit D3cold on S3 exit | ||||
| 			#chip soc/intel/common/block/pcie/rtd3 | ||||
|   | ||||
| @@ -15,7 +15,6 @@ void mainboard_memory_init_params(FSPM_UPD *mupd) | ||||
| 	}; | ||||
| 	const bool half_populated = false; | ||||
|  | ||||
| 	mupd->FspmConfig.PchHdaAudioLinkHdaEnable = 1; | ||||
| 	mupd->FspmConfig.DmiMaxLinkSpeed = 4; | ||||
| 	mupd->FspmConfig.GpioOverride = 0; | ||||
|  | ||||
|   | ||||
| @@ -0,0 +1,13 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_B2 | ||||
| #define DGPU_PWR_EN	GPP_A14 | ||||
| #define DGPU_GC6	GPP_A7 | ||||
| #define DGPU_SSID	0x65f51558 | ||||
|  | ||||
| #endif | ||||
| @@ -23,6 +23,10 @@ chip soc/intel/alderlake | ||||
| 				.clk_req = 3, | ||||
| 				.flags = PCIE_RP_LTR, | ||||
| 			}" | ||||
| 			chip drivers/gfx/nvidia | ||||
| 				device pci 00.0 on end # VGA controller | ||||
| 				device pci 00.1 on end # Audio device | ||||
| 			end | ||||
| 		end | ||||
| 		device ref igpu on | ||||
| 			register "ddi_portA_config" = "1" | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/gfx/nvidia/gpu.h> | ||||
| #include <soc/meminit.h> | ||||
| #include <soc/romstage.h> | ||||
| #include <variant/gpio.h> | ||||
|  | ||||
| void mainboard_memory_init_params(FSPM_UPD *mupd) | ||||
| { | ||||
| @@ -20,10 +22,17 @@ void mainboard_memory_init_params(FSPM_UPD *mupd) | ||||
| 	}; | ||||
| 	const bool half_populated = false; | ||||
|  | ||||
| 	const struct nvidia_gpu_config config = { | ||||
| 		.power_gpio = DGPU_PWR_EN, | ||||
| 		.reset_gpio = DGPU_RST_N, | ||||
| 		.enable = true, | ||||
| 	}; | ||||
| 	// Enable dGPU power | ||||
| 	nvidia_set_power(&config); | ||||
|  | ||||
| 	// Set primary display to internal graphics | ||||
| 	mupd->FspmConfig.PrimaryDisplay = 0; | ||||
|  | ||||
| 	mupd->FspmConfig.PchHdaAudioLinkHdaEnable = 1; | ||||
| 	mupd->FspmConfig.DmiMaxLinkSpeed = 4; | ||||
| 	mupd->FspmConfig.GpioOverride = 0; | ||||
|  | ||||
|   | ||||
| @@ -0,0 +1,13 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_B2 | ||||
| #define DGPU_PWR_EN	GPP_A14 | ||||
| #define DGPU_GC6	GPP_A7 | ||||
| #define DGPU_SSID	0x65f51558 | ||||
|  | ||||
| #endif | ||||
| @@ -23,6 +23,10 @@ chip soc/intel/alderlake | ||||
| 				.clk_req = 3, | ||||
| 				.flags = PCIE_RP_LTR, | ||||
| 			}" | ||||
| 			chip drivers/gfx/nvidia | ||||
| 				device pci 00.0 on end # VGA controller | ||||
| 				device pci 00.1 on end # Audio device | ||||
| 			end | ||||
| 		end | ||||
| 		device ref igpu on | ||||
| 			register "ddi_portA_config" = "1" | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/gfx/nvidia/gpu.h> | ||||
| #include <soc/meminit.h> | ||||
| #include <soc/romstage.h> | ||||
| #include <variant/gpio.h> | ||||
|  | ||||
| void mainboard_memory_init_params(FSPM_UPD *mupd) | ||||
| { | ||||
| @@ -17,10 +19,17 @@ void mainboard_memory_init_params(FSPM_UPD *mupd) | ||||
| 	}; | ||||
| 	const bool half_populated = false; | ||||
|  | ||||
| 	const struct nvidia_gpu_config config = { | ||||
| 		.power_gpio = DGPU_PWR_EN, | ||||
| 		.reset_gpio = DGPU_RST_N, | ||||
| 		.enable = true, | ||||
| 	}; | ||||
| 	// Enable dGPU power | ||||
| 	nvidia_set_power(&config); | ||||
|  | ||||
| 	// Set primary display to internal graphics | ||||
| 	mupd->FspmConfig.PrimaryDisplay = 0; | ||||
|  | ||||
| 	mupd->FspmConfig.PchHdaAudioLinkHdaEnable = 1; | ||||
| 	mupd->FspmConfig.DmiMaxLinkSpeed = 4; | ||||
| 	mupd->FspmConfig.GpioOverride = 0; | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,9 @@ config BOARD_SPECIFIC_OPTIONS | ||||
| 	select BOARD_ROMSIZE_KB_16384 | ||||
| 	select DRIVERS_GENERIC_CBFS_SERIAL | ||||
| 	select DRIVERS_GENERIC_CBFS_UUID | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_I2C_HID | ||||
| 	select DRIVERS_I2C_TAS5825M | ||||
| 	select EC_SYSTEM76_EC | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
| 	select HAVE_ACPI_RESUME | ||||
|   | ||||
| @@ -10,3 +10,4 @@ romstage-y += romstage.c | ||||
| ramstage-y += ramstage.c | ||||
| ramstage-y += gpio.c | ||||
| ramstage-y += hda_verb.c | ||||
| ramstage-y += tas5825m.c | ||||
|   | ||||
| @@ -59,12 +59,13 @@ chip soc/intel/cannonlake | ||||
| 			# PCI Express Graphics #0 x16, Clock 7 (NVIDIA GPU) | ||||
| 			register "PcieClkSrcUsage[7]" = "0x40" | ||||
| 			register "PcieClkSrcClkReq[7]" = "7" | ||||
|  | ||||
| 			chip drivers/gfx/nvidia | ||||
| 				device pci 00.0 on end # VGA controller | ||||
| 				device pci 00.1 on end # Audio device | ||||
| 				device pci 00.2 on end # USB xHCI Host controller | ||||
| 				device pci 00.3 on end # USB Type-C UCSI controller | ||||
| 			end | ||||
| 		end | ||||
| 		# TODO: is this enough to disable iGPU? | ||||
| 		device pci 02.0 off end # Integrated Graphics Device | ||||
| 		device pci 04.0 on  end # SA Thermal device | ||||
| @@ -219,7 +220,16 @@ chip soc/intel/cannonlake | ||||
| 		device pci 1f.3 on      # Intel HDA | ||||
| 			register "PchHdaAudioLinkHda" = "1" | ||||
| 		end | ||||
| 		device pci 1f.4 on  end # SMBus | ||||
| 		device pci 1f.4 on      # SMBus | ||||
| 			chip drivers/i2c/tas5825m | ||||
| 				register "id" = "0" | ||||
| 				device i2c 4e on end # (8bit address: 0x9c) | ||||
| 			end | ||||
| 			chip drivers/i2c/tas5825m | ||||
| 				register "id" = "1" | ||||
| 				device i2c 4f on end # (8bit address: 0x9e) | ||||
| 			end | ||||
| 		end | ||||
| 		device pci 1f.5 on  end # PCH SPI | ||||
| 		device pci 1f.6 off end # GbE | ||||
| 	end | ||||
|   | ||||
							
								
								
									
										1240
									
								
								src/mainboard/system76/bonw14/tas5825m-normal.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1240
									
								
								src/mainboard/system76/bonw14/tas5825m-normal.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1240
									
								
								src/mainboard/system76/bonw14/tas5825m-sub.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1240
									
								
								src/mainboard/system76/bonw14/tas5825m-sub.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										15
									
								
								src/mainboard/system76/bonw14/tas5825m.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/mainboard/system76/bonw14/tas5825m.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/i2c/tas5825m/tas5825m.h> | ||||
|  | ||||
| #include "tas5825m-normal.c" | ||||
| #include "tas5825m-sub.c" | ||||
|  | ||||
| int tas5825m_setup(struct device *dev, int id) | ||||
| { | ||||
| 	if (id == 0) | ||||
| 		return tas5825m_setup_normal(dev); | ||||
| 	if (id == 1) | ||||
| 		return tas5825m_setup_sub(dev); | ||||
| 	return -1; | ||||
| } | ||||
| @@ -1,31 +0,0 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/intel/gma/acpi/gma.asl> | ||||
|  | ||||
| Scope (GFX0) | ||||
| { | ||||
| 	Name (BRIG, Package (22) { | ||||
| 		40, /* default AC */ | ||||
| 		40, /* default Battery */ | ||||
| 		5, | ||||
| 		10, | ||||
| 		15, | ||||
| 		20, | ||||
| 		25, | ||||
| 		30, | ||||
| 		35, | ||||
| 		40, | ||||
| 		45, | ||||
| 		50, | ||||
| 		55, | ||||
| 		60, | ||||
| 		65, | ||||
| 		70, | ||||
| 		75, | ||||
| 		80, | ||||
| 		85, | ||||
| 		90, | ||||
| 		95, | ||||
| 		100 | ||||
| 	}) | ||||
| } | ||||
| @@ -6,9 +6,6 @@ | ||||
|  | ||||
| Scope (\_SB) { | ||||
| 	#include "sleep.asl" | ||||
| 	Scope (PCI0) { | ||||
| 		#include "backlight.asl" | ||||
| 	} | ||||
| } | ||||
|  | ||||
| Scope (\_GPE) { | ||||
|   | ||||
| @@ -19,6 +19,7 @@ DefinitionBlock( | ||||
| 	{ | ||||
| 		#include <soc/intel/common/block/acpi/acpi/northbridge.asl> | ||||
| 		#include <soc/intel/cannonlake/acpi/southbridge.asl> | ||||
| 		#include <drivers/intel/gma/acpi/default_brightness_levels.asl> | ||||
| 	} | ||||
|  | ||||
| 	#include <southbridge/intel/common/acpi/sleepstates.asl> | ||||
|   | ||||
| @@ -7,6 +7,7 @@ config BOARD_SPECIFIC_OPTIONS | ||||
| 	select BOARD_ROMSIZE_KB_16384 | ||||
| 	select DRIVERS_GENERIC_CBFS_SERIAL | ||||
| 	select DRIVERS_GENERIC_CBFS_UUID | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_I2C_HID | ||||
| 	select EC_SYSTEM76_EC | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| ## SPDX-License-Identifier: GPL-2.0-only | ||||
|  | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/include | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/variants/$(VARIANT_DIR)/include | ||||
|  | ||||
| bootblock-y += bootblock.c | ||||
| bootblock-y += variants/$(VARIANT_DIR)/gpio_early.c | ||||
|   | ||||
| @@ -1,31 +0,0 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/intel/gma/acpi/gma.asl> | ||||
|  | ||||
| Scope (GFX0) | ||||
| { | ||||
| 	Name (BRIG, Package (22) { | ||||
| 		40, /* default AC */ | ||||
| 		40, /* default Battery */ | ||||
| 		5, | ||||
| 		10, | ||||
| 		15, | ||||
| 		20, | ||||
| 		25, | ||||
| 		30, | ||||
| 		35, | ||||
| 		40, | ||||
| 		45, | ||||
| 		50, | ||||
| 		55, | ||||
| 		60, | ||||
| 		65, | ||||
| 		70, | ||||
| 		75, | ||||
| 		80, | ||||
| 		85, | ||||
| 		90, | ||||
| 		95, | ||||
| 		100 | ||||
| 	}) | ||||
| } | ||||
| @@ -1,5 +1,7 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <variant/gpio.h> | ||||
|  | ||||
| #define EC_GPE_SCI 0x03 /* GPP_K3 */ | ||||
| #define EC_GPE_SWI 0x06 /* GPP_K6 */ | ||||
| #include <ec/system76/ec/acpi/ec.asl> | ||||
| @@ -7,7 +9,10 @@ | ||||
| Scope (\_SB) { | ||||
| 	#include "sleep.asl" | ||||
| 	Scope (PCI0) { | ||||
| 		#include "backlight.asl" | ||||
| 		Device (PEGP) { | ||||
| 			Name (_ADR, CONFIG_DRIVERS_GFX_NVIDIA_BRIDGE << 16) | ||||
| 			#include <drivers/gfx/nvidia/acpi/coffeelake.asl> | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -55,6 +55,12 @@ chip soc/intel/cannonlake | ||||
| 			# PCI Express Graphics #0 x16, Clock 8 (NVIDIA GPU) | ||||
| 			register "PcieClkSrcUsage[8]" = "0x40" | ||||
| 			register "PcieClkSrcClkReq[8]" = "8" | ||||
| 			chip drivers/gfx/nvidia | ||||
| 				device pci 00.0 on end # VGA controller | ||||
| 				device pci 00.1 on end # Audio device | ||||
| 				device pci 00.2 on end # USB xHCI Host controller | ||||
| 				device pci 00.3 on end # USB Type-C UCSI controller | ||||
| 			end | ||||
| 		end | ||||
| 		device pci 02.0 on      # Integrated Graphics Device | ||||
| 			register "gfx" = "GMA_DEFAULT_PANEL(0)" | ||||
|   | ||||
| @@ -18,6 +18,7 @@ DefinitionBlock( | ||||
| 	Device (\_SB.PCI0) { | ||||
| 		#include <soc/intel/common/block/acpi/acpi/northbridge.asl> | ||||
| 		#include <soc/intel/cannonlake/acpi/southbridge.asl> | ||||
| 		#include <drivers/intel/gma/acpi/default_brightness_levels.asl> | ||||
| 	} | ||||
|  | ||||
| 	#include <southbridge/intel/common/acpi/sleepstates.asl> | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/gfx/nvidia/gpu.h> | ||||
| #include <soc/cnl_memcfg_init.h> | ||||
| #include <soc/romstage.h> | ||||
| #include <variant/gpio.h> | ||||
|  | ||||
| static const struct cnl_mb_cfg memcfg = { | ||||
| 	.spd[0] = { | ||||
| @@ -20,5 +22,17 @@ static const struct cnl_mb_cfg memcfg = { | ||||
|  | ||||
| void mainboard_memory_init_params(FSPM_UPD *memupd) | ||||
| { | ||||
| 	const struct nvidia_gpu_config config = { | ||||
| 		.power_gpio = DGPU_PWR_EN, | ||||
| 		.reset_gpio = DGPU_RST_N, | ||||
| 		.enable = true, | ||||
| 	}; | ||||
|  | ||||
| 	// Enable dGPU power | ||||
| 	nvidia_set_power(&config); | ||||
|  | ||||
| 	// Set primary display to internal graphics | ||||
| 	memupd->FspmConfig.PrimaryDisplay = 0; | ||||
|  | ||||
| 	cannonlake_memcfg_init(&memupd->FspmConfig, &memcfg); | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,18 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_F22 | ||||
| #define DGPU_PWR_EN	GPP_F23 | ||||
| #define DGPU_GC6	GPP_K21 | ||||
| #define DGPU_SSID	0x85501558 | ||||
|  | ||||
| #ifndef __ACPI__ | ||||
| void variant_configure_early_gpios(void); | ||||
| void variant_configure_gpios(void); | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| @@ -0,0 +1,18 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_F22 | ||||
| #define DGPU_PWR_EN	GPP_F23 | ||||
| #define DGPU_GC6	GPP_K21 | ||||
| #define DGPU_SSID	0x85201558 | ||||
|  | ||||
| #ifndef __ACPI__ | ||||
| void variant_configure_early_gpios(void); | ||||
| void variant_configure_gpios(void); | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| @@ -1,31 +0,0 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/intel/gma/acpi/gma.asl> | ||||
|  | ||||
| Scope (GFX0) | ||||
| { | ||||
| 	Name (BRIG, Package (22) { | ||||
| 		40, /* default AC */ | ||||
| 		40, /* default Battery */ | ||||
| 		5, | ||||
| 		10, | ||||
| 		15, | ||||
| 		20, | ||||
| 		25, | ||||
| 		30, | ||||
| 		35, | ||||
| 		40, | ||||
| 		45, | ||||
| 		50, | ||||
| 		55, | ||||
| 		60, | ||||
| 		65, | ||||
| 		70, | ||||
| 		75, | ||||
| 		80, | ||||
| 		85, | ||||
| 		90, | ||||
| 		95, | ||||
| 		100 | ||||
| 	}) | ||||
| } | ||||
| @@ -1,10 +1,6 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| Scope (\_SB) { | ||||
| 	Scope (PCI0) { | ||||
| 		#include "backlight.asl" | ||||
| 	} | ||||
|  | ||||
| 	#include "ac.asl" | ||||
| 	#include "battery.asl" | ||||
| 	#include "buttons.asl" | ||||
|   | ||||
| @@ -19,6 +19,7 @@ DefinitionBlock( | ||||
| 	{ | ||||
| 		#include <soc/intel/skylake/acpi/systemagent.asl> | ||||
| 		#include <soc/intel/skylake/acpi/pch.asl> | ||||
| 		#include <drivers/intel/gma/acpi/default_brightness_levels.asl> | ||||
| 	} | ||||
|  | ||||
| 	#include <southbridge/intel/common/acpi/sleepstates.asl> | ||||
|   | ||||
| @@ -7,6 +7,7 @@ config BOARD_SPECIFIC_OPTIONS | ||||
| 	select BOARD_ROMSIZE_KB_16384 | ||||
| 	select DRIVERS_GENERIC_CBFS_SERIAL | ||||
| 	select DRIVERS_GENERIC_CBFS_UUID | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_I2C_HID | ||||
| 	select DRIVERS_I2C_TAS5825M | ||||
| 	select EC_SYSTEM76_EC | ||||
|   | ||||
| @@ -1,31 +0,0 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/intel/gma/acpi/gma.asl> | ||||
|  | ||||
| Scope (GFX0) | ||||
| { | ||||
| 	Name (BRIG, Package (22) { | ||||
| 		40, /* default AC */ | ||||
| 		40, /* default Battery */ | ||||
| 		5, | ||||
| 		10, | ||||
| 		15, | ||||
| 		20, | ||||
| 		25, | ||||
| 		30, | ||||
| 		35, | ||||
| 		40, | ||||
| 		45, | ||||
| 		50, | ||||
| 		55, | ||||
| 		60, | ||||
| 		65, | ||||
| 		70, | ||||
| 		75, | ||||
| 		80, | ||||
| 		85, | ||||
| 		90, | ||||
| 		95, | ||||
| 		100 | ||||
| 	}) | ||||
| } | ||||
| @@ -1,5 +1,7 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <mainboard/gpio.h> | ||||
|  | ||||
| #define EC_GPE_SCI 0x17 /* GPP_B23 */ | ||||
| #define EC_GPE_SWI 0x26 /* GPP_G6 */ | ||||
| #include <ec/system76/ec/acpi/ec.asl> | ||||
| @@ -8,7 +10,10 @@ Scope (\_SB) | ||||
| { | ||||
| 	#include "sleep.asl" | ||||
| 	Scope (PCI0) { | ||||
| 		#include "backlight.asl" | ||||
| 		Device (PEGP) { | ||||
| 			Name (_ADR, CONFIG_DRIVERS_GFX_NVIDIA_BRIDGE << 16) | ||||
| 			#include <drivers/gfx/nvidia/acpi/coffeelake.asl> | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -63,6 +63,12 @@ chip soc/intel/cannonlake | ||||
| 			# PCI Express Graphics #0 x16, Clock 8 (NVIDIA GPU) | ||||
| 			register "PcieClkSrcUsage[8]" = "0x40" | ||||
| 			register "PcieClkSrcClkReq[8]" = "8" | ||||
| 			chip drivers/gfx/nvidia | ||||
| 				device pci 00.0 on end # VGA controller | ||||
| 				device pci 00.1 on end # Audio device | ||||
| 				device pci 00.2 on end # USB xHCI Host controller | ||||
| 				device pci 00.3 on end # USB Type-C UCSI controller | ||||
| 			end | ||||
| 		end | ||||
| 		device pci 02.0 on      # Integrated Graphics Device | ||||
| 			register "gfx" = "GMA_DEFAULT_PANEL(0)" | ||||
|   | ||||
| @@ -19,6 +19,7 @@ DefinitionBlock( | ||||
| 	{ | ||||
| 		#include <soc/intel/common/block/acpi/acpi/northbridge.asl> | ||||
| 		#include <soc/intel/cannonlake/acpi/southbridge.asl> | ||||
| 		#include <drivers/intel/gma/acpi/default_brightness_levels.asl> | ||||
| 	} | ||||
|  | ||||
| 	#include <southbridge/intel/common/acpi/sleepstates.asl> | ||||
|   | ||||
| @@ -3,7 +3,16 @@ | ||||
| #ifndef MAINBOARD_GPIO_H | ||||
| #define MAINBOARD_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_F22 | ||||
| #define DGPU_PWR_EN	GPP_F23 | ||||
| #define DGPU_GC6	GPP_C12 | ||||
| #define DGPU_SSID	0x95e61558 | ||||
|  | ||||
| #ifndef __ACPI__ | ||||
| void mainboard_configure_early_gpios(void); | ||||
| void mainboard_configure_gpios(void); | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
|   | ||||
| @@ -1,5 +1,7 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/gfx/nvidia/gpu.h> | ||||
| #include <mainboard/gpio.h> | ||||
| #include <soc/cnl_memcfg_init.h> | ||||
| #include <soc/romstage.h> | ||||
|  | ||||
| @@ -20,6 +22,18 @@ static const struct cnl_mb_cfg memcfg = { | ||||
|  | ||||
| void mainboard_memory_init_params(FSPM_UPD *memupd) | ||||
| { | ||||
| 	const struct nvidia_gpu_config config = { | ||||
| 		.power_gpio = DGPU_PWR_EN, | ||||
| 		.reset_gpio = DGPU_RST_N, | ||||
| 		.enable = true, | ||||
| 	}; | ||||
|  | ||||
| 	// Enable dGPU power | ||||
| 	nvidia_set_power(&config); | ||||
|  | ||||
| 	// Set primary display to internal graphics | ||||
| 	memupd->FspmConfig.PrimaryDisplay = 0; | ||||
|  | ||||
| 	// Allow memory speeds higher than 2666 MT/s | ||||
| 	memupd->FspmConfig.SaOcSupport = 1; | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ config BOARD_SPECIFIC_OPTIONS | ||||
| 	select BOARD_ROMSIZE_KB_16384 | ||||
| 	select DRIVERS_GENERIC_CBFS_SERIAL | ||||
| 	select DRIVERS_GENERIC_CBFS_UUID | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_I2C_HID | ||||
| 	select DRIVERS_I2C_TAS5825M | ||||
| 	select EC_SYSTEM76_EC | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| ## SPDX-License-Identifier: GPL-2.0-only | ||||
|  | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/include | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/variants/$(VARIANT_DIR)/include | ||||
|  | ||||
| bootblock-y += bootblock.c | ||||
| bootblock-y += variants/$(VARIANT_DIR)/gpio_early.c | ||||
|   | ||||
| @@ -1,31 +0,0 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/intel/gma/acpi/gma.asl> | ||||
|  | ||||
| Scope (GFX0) | ||||
| { | ||||
| 	Name (BRIG, Package (22) { | ||||
| 		40, /* default AC */ | ||||
| 		40, /* default Battery */ | ||||
| 		5, | ||||
| 		10, | ||||
| 		15, | ||||
| 		20, | ||||
| 		25, | ||||
| 		30, | ||||
| 		35, | ||||
| 		40, | ||||
| 		45, | ||||
| 		50, | ||||
| 		55, | ||||
| 		60, | ||||
| 		65, | ||||
| 		70, | ||||
| 		75, | ||||
| 		80, | ||||
| 		85, | ||||
| 		90, | ||||
| 		95, | ||||
| 		100 | ||||
| 	}) | ||||
| } | ||||
| @@ -1,5 +1,7 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <variant/gpio.h> | ||||
|  | ||||
| #define EC_GPE_SCI 0x03 /* GPP_K3 */ | ||||
| #define EC_GPE_SWI 0x06 /* GPP_K6 */ | ||||
| #include <ec/system76/ec/acpi/ec.asl> | ||||
| @@ -7,7 +9,10 @@ | ||||
| Scope (\_SB) { | ||||
| 	#include "sleep.asl" | ||||
| 	Scope (PCI0) { | ||||
| 		#include "backlight.asl" | ||||
| 		Device (PEGP) { | ||||
| 			Name (_ADR, CONFIG_DRIVERS_GFX_NVIDIA_BRIDGE << 16) | ||||
| 			#include <drivers/gfx/nvidia/acpi/coffeelake.asl> | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -60,6 +60,12 @@ chip soc/intel/cannonlake | ||||
| 			# PCI Express Graphics #0 x16, Clock 8 (NVIDIA GPU) | ||||
| 			register "PcieClkSrcUsage[8]" = "0x40" | ||||
| 			register "PcieClkSrcClkReq[8]" = "8" | ||||
| 			chip drivers/gfx/nvidia | ||||
| 				device pci 00.0 on end # VGA controller | ||||
| 				device pci 00.1 on end # Audio device | ||||
| 				device pci 00.2 on end # USB xHCI Host controller | ||||
| 				device pci 00.3 on end # USB Type-C UCSI controller | ||||
| 			end | ||||
| 		end | ||||
| 		device pci 02.0 on      # Integrated Graphics Device | ||||
| 			register "gfx" = "GMA_DEFAULT_PANEL(0)" | ||||
|   | ||||
| @@ -18,6 +18,7 @@ DefinitionBlock( | ||||
| 	Device (\_SB.PCI0) { | ||||
| 		#include <soc/intel/common/block/acpi/acpi/northbridge.asl> | ||||
| 		#include <soc/intel/cannonlake/acpi/southbridge.asl> | ||||
| 		#include <drivers/intel/gma/acpi/default_brightness_levels.asl> | ||||
| 	} | ||||
|  | ||||
| 	#include <southbridge/intel/common/acpi/sleepstates.asl> | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/gfx/nvidia/gpu.h> | ||||
| #include <soc/cnl_memcfg_init.h> | ||||
| #include <soc/romstage.h> | ||||
| #include <variant/gpio.h> | ||||
| #include <variant/romstage.h> | ||||
|  | ||||
| static const struct cnl_mb_cfg memcfg = { | ||||
| @@ -21,6 +23,18 @@ static const struct cnl_mb_cfg memcfg = { | ||||
|  | ||||
| void mainboard_memory_init_params(FSPM_UPD *memupd) | ||||
| { | ||||
| 	const struct nvidia_gpu_config config = { | ||||
| 		.power_gpio = DGPU_PWR_EN, | ||||
| 		.reset_gpio = DGPU_RST_N, | ||||
| 		.enable = true, | ||||
| 	}; | ||||
|  | ||||
| 	// Enable dGPU power | ||||
| 	nvidia_set_power(&config); | ||||
|  | ||||
| 	// Set primary display to internal graphics | ||||
| 	memupd->FspmConfig.PrimaryDisplay = 0; | ||||
|  | ||||
| 	variant_configure_fspm(memupd); | ||||
|  | ||||
| 	cannonlake_memcfg_init(&memupd->FspmConfig, &memcfg); | ||||
|   | ||||
| @@ -0,0 +1,18 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_F22 | ||||
| #define DGPU_PWR_EN	GPP_F23 | ||||
| #define DGPU_GC6	GPP_K21 | ||||
| #define DGPU_SSID	0x50d31558 | ||||
|  | ||||
| #ifndef __ACPI__ | ||||
| void variant_configure_early_gpios(void); | ||||
| void variant_configure_gpios(void); | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| @@ -0,0 +1,18 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #ifndef VARIANT_GPIO_H | ||||
| #define VARIANT_GPIO_H | ||||
|  | ||||
| #include <soc/gpio.h> | ||||
|  | ||||
| #define DGPU_RST_N	GPP_F22 | ||||
| #define DGPU_PWR_EN	GPP_F23 | ||||
| #define DGPU_GC6	GPP_K21 | ||||
| #define DGPU_SSID	0x65e51558 | ||||
|  | ||||
| #ifndef __ACPI__ | ||||
| void variant_configure_early_gpios(void); | ||||
| void variant_configure_gpios(void); | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| @@ -8,6 +8,7 @@ config BOARD_SYSTEM76_RPL_COMMON | ||||
| 	select DRIVERS_GENERIC_CBFS_UUID | ||||
| 	select DRIVERS_I2C_HID | ||||
| 	select EC_SYSTEM76_EC | ||||
| 	select EC_SYSTEM76_EC_LOCKDOWN | ||||
| 	select HAVE_ACPI_RESUME | ||||
| 	select HAVE_ACPI_TABLES | ||||
| 	select HAVE_CMOS_DEFAULT | ||||
| @@ -27,13 +28,27 @@ config BOARD_SYSTEM76_RPL_COMMON | ||||
|  | ||||
| config BOARD_SYSTEM76_ADDW3 | ||||
| 	select BOARD_SYSTEM76_RPL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	select DRIVERS_INTEL_DTBT | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
| 	select MAINBOARD_USES_IFD_GBE_REGION | ||||
| 	select PCIEXP_HOTPLUG | ||||
| 	select SOC_INTEL_ALDERLAKE_PCH_S | ||||
|  | ||||
| config BOARD_SYSTEM76_ADDW4 | ||||
| 	select BOARD_SYSTEM76_RPL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
| 	select PCIEXP_HOTPLUG | ||||
| 	select SOC_INTEL_ALDERLAKE_PCH_S | ||||
|  | ||||
| config BOARD_SYSTEM76_BONW15 | ||||
| 	select BOARD_SYSTEM76_RPL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	select DRIVERS_INTEL_DTBT | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
| 	select PCIEXP_HOTPLUG | ||||
| 	select SOC_INTEL_ALDERLAKE_PCH_S | ||||
| @@ -50,6 +65,8 @@ config BOARD_SYSTEM76_GALP7 | ||||
|  | ||||
| config BOARD_SYSTEM76_GAZE18 | ||||
| 	select BOARD_SYSTEM76_RPL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
| 	select SOC_INTEL_ALDERLAKE_PCH_P | ||||
|  | ||||
| @@ -61,12 +78,17 @@ config BOARD_SYSTEM76_LEMP12 | ||||
|  | ||||
| config BOARD_SYSTEM76_ORYP11 | ||||
| 	select BOARD_SYSTEM76_RPL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
| 	select SOC_INTEL_ALDERLAKE_PCH_P | ||||
| 	select SOC_INTEL_ENABLE_USB4_PCIE_RESOURCES | ||||
|  | ||||
| config BOARD_SYSTEM76_SERW13 | ||||
| 	select BOARD_SYSTEM76_RPL_COMMON | ||||
| 	select DRIVERS_GFX_NVIDIA | ||||
| 	select DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST | ||||
| 	select DRIVERS_INTEL_DTBT | ||||
| 	select EC_SYSTEM76_EC_DGPU | ||||
| 	select PCIEXP_HOTPLUG | ||||
| 	select SOC_INTEL_ALDERLAKE_PCH_S | ||||
| @@ -78,6 +100,7 @@ config MAINBOARD_DIR | ||||
|  | ||||
| config VARIANT_DIR | ||||
| 	default "addw3" if BOARD_SYSTEM76_ADDW3 | ||||
| 	default "addw4" if BOARD_SYSTEM76_ADDW4 | ||||
| 	default "bonw15" if BOARD_SYSTEM76_BONW15 | ||||
| 	default "darp9" if BOARD_SYSTEM76_DARP9 | ||||
| 	default "galp7" if BOARD_SYSTEM76_GALP7 | ||||
| @@ -91,6 +114,7 @@ config OVERRIDE_DEVICETREE | ||||
|  | ||||
| config MAINBOARD_PART_NUMBER | ||||
| 	default "addw3" if BOARD_SYSTEM76_ADDW3 | ||||
| 	default "addw4" if BOARD_SYSTEM76_ADDW4 | ||||
| 	default "bonw15" if BOARD_SYSTEM76_BONW15 | ||||
| 	default "darp9" if BOARD_SYSTEM76_DARP9 | ||||
| 	default "galp7" if BOARD_SYSTEM76_GALP7 | ||||
| @@ -100,7 +124,7 @@ config MAINBOARD_PART_NUMBER | ||||
| 	default "serw13" if BOARD_SYSTEM76_SERW13 | ||||
|  | ||||
| config MAINBOARD_SMBIOS_PRODUCT_NAME | ||||
| 	default "Adder WS" if BOARD_SYSTEM76_ADDW3 | ||||
| 	default "Adder WS" if BOARD_SYSTEM76_ADDW3 || BOARD_SYSTEM76_ADDW4 | ||||
| 	default "Bonobo WS" if BOARD_SYSTEM76_BONW15 | ||||
| 	default "Darter Pro" if BOARD_SYSTEM76_DARP9 | ||||
| 	default "Galago Pro" if BOARD_SYSTEM76_GALP7 | ||||
| @@ -111,6 +135,7 @@ config MAINBOARD_SMBIOS_PRODUCT_NAME | ||||
|  | ||||
| config MAINBOARD_VERSION | ||||
| 	default "addw3" if BOARD_SYSTEM76_ADDW3 | ||||
| 	default "addw4" if BOARD_SYSTEM76_ADDW4 | ||||
| 	default "bonw15" if BOARD_SYSTEM76_BONW15 | ||||
| 	default "darp9" if BOARD_SYSTEM76_DARP9 | ||||
| 	default "galp7" if BOARD_SYSTEM76_GALP7 | ||||
| @@ -119,6 +144,10 @@ config MAINBOARD_VERSION | ||||
| 	default "oryp11" if BOARD_SYSTEM76_ORYP11 | ||||
| 	default "serw13" if BOARD_SYSTEM76_SERW13 | ||||
|  | ||||
| config CMOS_DEFAULT_FILE | ||||
| 	default "src/mainboard/\$(MAINBOARDDIR)/cmos-csme.default" if BOARD_SYSTEM76_DARP9 | ||||
| 	default "src/mainboard/\$(MAINBOARDDIR)/cmos.default" | ||||
|  | ||||
| config CONSOLE_POST | ||||
| 	default y | ||||
|  | ||||
| @@ -128,6 +157,17 @@ config D3COLD_SUPPORT | ||||
| config DIMM_SPD_SIZE | ||||
| 	default 512 | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_BRIDGE | ||||
| 	default 0x02 if BOARD_SYSTEM76_BONW15 | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_TPP | ||||
| 	default 45 if BOARD_SYSTEM76_ORYP11 | ||||
| 	default 55 if BOARD_SYSTEM76_ADDW3 || BOARD_SYSTEM76_ADDW4 || BOARD_SYSTEM76_GAZE18 || BOARD_SYSTEM76_SERW13 | ||||
| 	default 80 if BOARD_SYSTEM76_BONW15 | ||||
|  | ||||
| config DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST_MAX | ||||
| 	default 25 if BOARD_SYSTEM76_ADDW3 || BOARD_SYSTEM76_ADDW4 || BOARD_SYSTEM76_BONW15 || BOARD_SYSTEM76_GAZE18 || BOARD_SYSTEM76_ORYP11 || BOARD_SYSTEM76_SERW13 | ||||
|  | ||||
| config FMDFILE | ||||
| 	default "src/mainboard/\$(CONFIG_MAINBOARD_DIR)/variants/\$(CONFIG_VARIANT_DIR)/board.fmd" | ||||
|  | ||||
|   | ||||
| @@ -3,6 +3,9 @@ | ||||
| config BOARD_SYSTEM76_ADDW3 | ||||
| 	bool "addw3" | ||||
|  | ||||
| config BOARD_SYSTEM76_ADDW4 | ||||
| 	bool "addw4" | ||||
|  | ||||
| config BOARD_SYSTEM76_BONW15 | ||||
| 	bool "bonw15" | ||||
|  | ||||
|   | ||||
| @@ -2,6 +2,10 @@ | ||||
|  | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/include | ||||
|  | ||||
| ifeq ($(CONFIG_DRIVERS_GFX_NVIDIA),y) | ||||
| CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/variants/$(VARIANT_DIR)/include | ||||
| endif | ||||
|  | ||||
| bootblock-y += bootblock.c | ||||
| bootblock-y += variants/$(VARIANT_DIR)/gpio_early.c | ||||
|  | ||||
|   | ||||
| @@ -1,31 +0,0 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #include <drivers/intel/gma/acpi/gma.asl> | ||||
|  | ||||
| Scope (GFX0) | ||||
| { | ||||
| 	Name (BRIG, Package (22) { | ||||
| 		40, /* default AC */ | ||||
| 		40, /* default Battery */ | ||||
| 		5, | ||||
| 		10, | ||||
| 		15, | ||||
| 		20, | ||||
| 		25, | ||||
| 		30, | ||||
| 		35, | ||||
| 		40, | ||||
| 		45, | ||||
| 		50, | ||||
| 		55, | ||||
| 		60, | ||||
| 		65, | ||||
| 		70, | ||||
| 		75, | ||||
| 		80, | ||||
| 		85, | ||||
| 		90, | ||||
| 		95, | ||||
| 		100 | ||||
| 	}) | ||||
| } | ||||
| @@ -1,5 +1,9 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
|  | ||||
| #if CONFIG(DRIVERS_GFX_NVIDIA) | ||||
| #include <variant/gpio.h> | ||||
| #endif | ||||
|  | ||||
| #define EC_GPE_SCI 0x6E | ||||
| #define EC_GPE_SWI 0x6B | ||||
| #include <ec/system76/ec/acpi/ec.asl> | ||||
| @@ -7,6 +11,16 @@ | ||||
| Scope (\_SB) { | ||||
| 	#include "sleep.asl" | ||||
| 	Scope (PCI0) { | ||||
| 		#include "backlight.asl" | ||||
| #if CONFIG(DRIVERS_GFX_NVIDIA) | ||||
| #if CONFIG(SOC_INTEL_ALDERLAKE_PCH_P) || CONFIG(BOARD_SYSTEM76_BONW15) | ||||
| 		Scope (PEG2) { | ||||
| 			#include <drivers/gfx/nvidia/acpi/tigerlake.asl> | ||||
| 		} | ||||
| #else | ||||
| 		Scope (PEG1) { | ||||
| 			#include <drivers/gfx/nvidia/acpi/tigerlake.asl> | ||||
| 		} | ||||
| #endif | ||||
| #endif // CONFIG(DRIVERS_GFX_NVIDIA) | ||||
| 	} | ||||
| } | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user