From fc1ba7e3b00890682ca566d1f44f2c5bfc7cf8b5 Mon Sep 17 00:00:00 2001
From: Reagan Bohan <xbjfk.github@gmail.com>
Date: Tue, 21 Feb 2023 19:11:35 +1300
Subject: [PATCH] Add more Linux instructions to finding acpi paths

---
 Laptops/laptop-disable.md         | 54 ++++++++++++++++++++-----------
 Manual/dump.md                    |  5 ++-
 Universal/ec-methods/manual.md    | 23 +++++++++++++
 Universal/plug-methods/manual.md  | 13 ++++++--
 Universal/smbus-methods/manual.md | 20 +++++++++++-
 dictionary/dictionary.txt         |  1 +
 6 files changed, 93 insertions(+), 23 deletions(-)

diff --git a/Laptops/laptop-disable.md b/Laptops/laptop-disable.md
index 74584a8b..5dfa1ae3 100644
--- a/Laptops/laptop-disable.md
+++ b/Laptops/laptop-disable.md
@@ -7,13 +7,11 @@ So with laptops, we can hide the dGPU from macOS with the little boot-arg called
 
 Note that this is not needed for install, but recommended for post-install
 
-## Optimus Method
-
-How this works is that we call the `.off` method found on Optimus GPUs, this is the expected way to power off a GPU but some may find their dGPU will power back up later on. Mainly seen in Lenovo's, the Optimus method should work for most users:
+## Finding the ACPI Path
 
-To start, grab [SSDT-dGPU-Off.dsl](https://github.com/dortania/Getting-Started-With-ACPI/blob/master/extra-files/decompiled/SSDT-dGPU-Off.dsl.zip)
+### Windows
 
-Next we need to get on Windows, and head to the following:
+Head to the following:
 
 ```
 Device Manager -> Display Adapters -> dGPU -> Properties -> Details > BIOS device name
@@ -21,14 +19,43 @@ Device Manager -> Display Adapters -> dGPU -> Properties -> Details > BIOS devic
 
 * Note some GPUs may be hiding under "BIOS device name"
 
-This should provided you with an ACPI path for your dGPU, most commonly:
+This should have provided you with an ACPI path for your dGPU, most commonly:
 
 * Nvidia dGPU: `\_SB.PCI0.PEG0.PEGP`
 * AMD dGPU: `\_SB.PCI0.PEGP.DGFX`
 
 ![Credit to 1Revenger1 for the image](../images/Desktops/nvidia.png)
 
-Now with that, we'll need to change the ACPI path in the SSDT. Main sections:
+### Linux
+
+Use `lcpci` to find the PCI path of your device:
+
+```sh
+$ lspci -D | grep VGA
+0000:00:02.0 VGA compatible controller: Intel Corporation UHD Graphics (rev 05)
+0000:01:00.0 VGA compatible controller: NVIDIA Corporation TU106M [GeForce RTX 2060 Max-Q] (rev a1)
+```
+
+Make a note of the PCI path of the dedicated graphics card (`0000:01:00.0` in my case).
+
+Then use `cat` to get the ACPI path (substituting `[PCI path]` with the path obtained above):
+
+```
+cat /sys/bus/pci/devices/[PCI path]/firmware_node/path
+```
+
+This should have provided you with an ACPI path for your dGPU, most commonly:
+
+* Nvidia dGPU: `\_SB.PCI0.PEG0.PEGP`
+* AMD dGPU: `\_SB.PCI0.PEGP.DGFX`
+
+## Optimus Method
+
+How this works is that we call the `.off` method found on Optimus GPUs, this is the expected way to power off a GPU but some may find their dGPU will power back up later on. Mainly seen in Lenovo's, the Optimus method should work for most users:
+
+To start, grab [SSDT-dGPU-Off.dsl](https://github.com/dortania/Getting-Started-With-ACPI/blob/master/extra-files/decompiled/SSDT-dGPU-Off.dsl.zip)
+
+Using the ACPI path you acquired, we'll need to change the ACPI path in the SSDT. Main sections:
 
 ```
 External(_SB.PCI0.PEG0.PEGP._OFF, MethodObj)
@@ -48,18 +75,7 @@ With some machines, the simple `.off` call won't keep the card off properly, tha
 
 To start, grab [SSDT-NoHybGfx.dsl](https://github.com/dortania/Getting-Started-With-ACPI/blob/master/extra-files/decompiled/SSDT-NoHybGfx.dsl.zip)
 
-Next we need to get on Windows, and head to the following:
-
-```
-Device Manager -> Display Adapters -> dGPU -> Properties -> Details > BIOS device name
-```
-
-This should provided you with an ACPI path for your dGPU, most commonly:
-
-* Nvidia dGPU: `\_SB.PCI0.PEG0.PEGP`
-* AMD dGPU: `\_SB.PCI0.PEGP.DGFX`
-
-Now with that, we'll need to change the ACPI path in the SSDT. Main sections:
+Using the ACPI path you acquired, we'll need to change the ACPI path in the SSDT. Main sections:
 
 ```
 External (_SB_.PCI0.PEG0.PEGP._DSM, MethodObj)    // dGPU ACPI Path
diff --git a/Manual/dump.md b/Manual/dump.md
index 54be84e0..80c91e24 100644
--- a/Manual/dump.md
+++ b/Manual/dump.md
@@ -17,7 +17,10 @@ So to start, we'll need to get a copy of your DSDT from your firmware. The easie
 * [SSDTTime](https://github.com/corpnewt/SSDTTime)
   * Supports both Windows and Linux for DSDT dumping
   * `4. Dump DSDT - Automatically dump the system DSDT`
-* Do note that all ACPI patches from clover/OpenCore will be applied to the DSDT with the above method
+* sysfs
+  * Run `sudo cat /sys/firmware/acpi/tables/DSDT > DSDT.aml`
+
+* Do note that all ACPI patches from clover/OpenCore will be applied to the DSDT with the above 2 methods
 
 ## From Clover
 
diff --git a/Universal/ec-methods/manual.md b/Universal/ec-methods/manual.md
index d1b3b0af..f7f39621 100644
--- a/Universal/ec-methods/manual.md
+++ b/Universal/ec-methods/manual.md
@@ -23,6 +23,7 @@ To find the ACPI pathing, you have 2 methods:
 
 * [DSDT](#dsdt)
 * [DeviceManager](#devicemanager)
+* [Linux](#linux)
 
 ### DSDT
 
@@ -62,6 +63,28 @@ From the above, we can see that our pathing is `SB.PC00.LPC0.EC0`
 
 Now with the pathing, you can head here: [Edits to the sample SSDT](#edits-to-the-sample-ssdt)
 
+### Linux
+
+Use `find` over the ACPI tree:
+
+```
+find /sys/devices/LNXSYSTM:00 -name 'PNP0C09:*'
+```
+
+The above command finds all PNP0C09 devices in the ACPI tree. The output may be something like:
+
+```
+/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00
+```
+
+To get the pathing, cat the `path`, taking the results from above, like so:
+
+```
+cat /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:18/PNP0C09:00/path
+```
+
+Now with the pathing, you can head here: [Edits to the sample SSDT](#edits-to-the-sample-ssdt)
+
 ## Edits to the sample SSDT
 
 Now that we have our ACPI path, lets grab our SSDT and get to work:
diff --git a/Universal/plug-methods/manual.md b/Universal/plug-methods/manual.md
index eb36b520..72d54390 100644
--- a/Universal/plug-methods/manual.md
+++ b/Universal/plug-methods/manual.md
@@ -9,10 +9,11 @@
 
 ## Finding the ACPI path
 
-To find the ACPI pathing, you have 2 methods:
+To find the ACPI pathing, you have 3 methods:
 
 * [DSDT](#dsdt)
 * [DeviceManager](#devicemanager)
+* [Linux](#linux)
 
 ### DSDT
 
@@ -36,7 +37,7 @@ If we then search for instances of `CP00` we find that its full ACPI pathing is
 
 Now with the pathing, you can head here: [Edits to the sample SSDT](#edits-to-the-sample-ssdt)
 
-##### DeviceManager
+### DeviceManager
 
 If you already have Windows installed on this machine, finding the CPU pathing is fairly easy.
 
@@ -61,6 +62,14 @@ So with the above X299 example, our CPU pathing would be `SB.SCK0.CP00`
 
 Now with the pathing, you can head here: [Edits to the sample SSDT](#edits-to-the-sample-ssdt)
 
+### Linux
+
+Finding the CPU's ACPI path with Linux is very simple. Simply `cat` the firmware_node path:
+
+```
+cat /sys/devices/system/cpu/cpu0/firmware_node/path
+```
+
 ## Edits to the sample SSDT
 
 Now that we have our ACPI path, lets grab our SSDT and get to work:
diff --git a/Universal/smbus-methods/manual.md b/Universal/smbus-methods/manual.md
index 790d2038..91b84aa1 100644
--- a/Universal/smbus-methods/manual.md
+++ b/Universal/smbus-methods/manual.md
@@ -9,10 +9,11 @@
 
 ## Finding the ACPI path
 
-So to find the ACPI pathing of our SMBus, we've got 2 methods:
+So to find the ACPI pathing of our SMBus, we've got 3 methods:
 
 * [Hackintool](#hackintool)
 * [DeviceManager](#devicemanager)
+* [Linux](#linux)
 
 ### Hackintool
 
@@ -40,6 +41,23 @@ From the above example, we can see the SMBus is located at:
 PC00.SMBS
 ```
 
+### Linux
+
+Use `lcpci` to find the PCI path of the SMBus:
+
+```sh
+$ lspci -D | grep SMBus
+0000:00:1f.4 SMBus: Intel Corporation Alder Lake-S PCH SMBus Controller (rev 11)
+```
+
+Make a note of the PCI path of the SMBus controller (`0000:00:1f.4` in my case).
+
+Then use `cat` to get the ACPI path (substituting `[PCI path]` with the path obtained above):
+
+```
+cat /sys/bus/pci/devices/[PCI path]/firmware_node/path
+```
+
 With the ACPI pathing, you can now head here: [Edits to the sample SSDT](#edits-to-the-sample-ssdt)
 
 ## Edits to the sample SSDT
diff --git a/dictionary/dictionary.txt b/dictionary/dictionary.txt
index f63299ab..aae71413 100644
--- a/dictionary/dictionary.txt
+++ b/dictionary/dictionary.txt
@@ -1157,6 +1157,7 @@ stolenmem
 subreddit
 sudo
 sysctl
+sysfs
 takedowns
 tbh
 threadripper