WIP: bonw15 GPU ACPI
Change-Id: Ie000be60805029c7fcce9480852f685aa91dd999
This commit is contained in:
		@@ -14,7 +14,11 @@ Scope (\_SB) {
 | 
			
		||||
		#include "backlight.asl"
 | 
			
		||||
 | 
			
		||||
#if CONFIG(DRIVERS_GFX_NVIDIA)
 | 
			
		||||
#if CONFIG(SOC_INTEL_ALDERLAKE_PCH_P) || CONFIG(BOARD_SYSTEM76_BONW15)
 | 
			
		||||
#if CONFIG(BOARD_SYSTEM76_BONW15)
 | 
			
		||||
		Scope (PEG1) {
 | 
			
		||||
			#include "../variants/bonw15/acpi/gpu.asl"
 | 
			
		||||
		}
 | 
			
		||||
#elif CONFIG(SOC_INTEL_ALDERLAKE_PCH_P)
 | 
			
		||||
		Scope (PEG2) {
 | 
			
		||||
			#include <drivers/gfx/nvidia/acpi/tigerlake.asl>
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								src/mainboard/system76/rpl/variants/bonw15/acpi/dsm.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/mainboard/system76/rpl/variants/bonw15/acpi/dsm.asl
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
/* 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"
 | 
			
		||||
 | 
			
		||||
Method (_DSM, 4, Serialized) {
 | 
			
		||||
	Printf("GPU _DSM")
 | 
			
		||||
	If (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/mainboard/system76/rpl/variants/bonw15/acpi/gps.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								src/mainboard/system76/rpl/variants/bonw15/acpi/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)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										17
									
								
								src/mainboard/system76/rpl/variants/bonw15/acpi/gpu.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/mainboard/system76/rpl/variants/bonw15/acpi/gpu.asl
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
/* SPDX-License-Identifier: GPL-2.0-only */
 | 
			
		||||
 | 
			
		||||
Device (DEV0) {
 | 
			
		||||
	Name(_ADR, 0x00000000)
 | 
			
		||||
 | 
			
		||||
	#include "utility.asl"
 | 
			
		||||
	#include "dsm.asl"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if CONFIG(DRIVERS_GFX_NVIDIA_DYNAMIC_BOOST)
 | 
			
		||||
Scope (\_SB) {
 | 
			
		||||
	Device(NPCF) {
 | 
			
		||||
		#include "utility.asl"
 | 
			
		||||
		#include "nvpcf.asl"
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										111
									
								
								src/mainboard/system76/rpl/variants/bonw15/acpi/nvpcf.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								src/mainboard/system76/rpl/variants/bonw15/acpi/nvpcf.asl
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,111 @@
 | 
			
		||||
#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)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										63
									
								
								src/mainboard/system76/rpl/variants/bonw15/acpi/utility.asl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/mainboard/system76/rpl/variants/bonw15/acpi/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)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user