Skip to contentSkip to conversation

ACPI: device_sysfs: Add sysfs support for _PLD

PATCH Superseded Won Chung 1 participant 1 message Feb 2, 2022

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Won Chung

author
#0 lore raw

PATCH v5 1/1 ACPI: device_sysfs: Add sysfs support for _PLD

When ACPI table includes _PLD fields for a device, create a new directory (pld) in sysfs to share _PLD fields.

Currently without PLD information, when there are multiple of same devices, it is hard to distinguish which device corresponds to which location. For example, when there are two Type C connectors, it is hard to find out which connector corresponds to the Type C port on the left panel versus the Type C port on the right panel. With PLD information provided, we can determine which specific device is doing what.

---
 Documentation/ABI/testing/sysfs-bus-acpi | 107 +++++++++++++++++++++++
 drivers/acpi/device_sysfs.c              |  51 +++++++++++
 drivers/acpi/scan.c                      |  10 +--
 include/acpi/acpi_bus.h                  |   1 +
 4 files changed, 163 insertions(+), 6 deletions(-)
Documentation/ABI/testing/sysfs-bus-acpi +107 -0
index 58abacf59b2a..b8b71c8f3cfd 100644
@@ -96,3 +96,110 @@ Description:
 		hardware, if the _HRV control method is present.  It is mostly
 		useful for non-PCI devices because lspci can list the hardware
 		version for PCI devices.
+
+What:		/sys/bus/acpi/devices/.../pld/
+Date:		Feb, 2022
+Contact:	Won Chung <[email protected]>
+Description:
+		This directory contains the output of the device object's _PLD
+		control method, if present. This information provides details
+		on physical location of a device.
+
+What:		/sys/bus/acpi/devices/.../pld/revision
+Date:		Feb, 2022
+Contact:	Won Chung <[email protected]>
+Description:
+		The current revision is 0x2.
+
+What:           /sys/bus/acpi/devices/.../pld/group_token
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		Unique numerical value identifying a group.
+
+What:           /sys/bus/acpi/devices/.../pld/group_position
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		Identifies this device connection point’s position in the group.
+
+What:           /sys/bus/acpi/devices/.../pld/user_visible
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		Set if the device connection point can be seen by the user
+		without disassembly.
+
+What:           /sys/bus/acpi/devices/.../pld/dock
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		Set if the device connection point resides in a docking station
+		or port replicator.
+
+What:           /sys/bus/acpi/devices/.../pld/bay
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		Set if describing a device in a bay or if device connection
+		point is a bay.
+
+What:           /sys/bus/acpi/devices/.../pld/lid
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		Set if this device connection point resides on the lid of
+		laptop system.
+
+What:           /sys/bus/acpi/devices/.../pld/panel
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		Describes which panel surface of the system’s housing the
+		device connection point resides on:
+		0 - Top
+		1 - Bottom
+		2 - Left
+		3 - Right
+		4 - Front
+		5 - Back
+		6 - Unknown (Vertical Position and Horizontal Position will be
+		ignored)
+
+What:           /sys/bus/acpi/devices/.../pld/vertical_position
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		0 - Upper
+		1 - Center
+		2 - Lower
+
+What:           /sys/bus/acpi/devices/.../pld/horizontal_position
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		ACPI specification does not define horizontal position field.
+		Can be used as either
+		0 - Left
+		1 - Center
+		2 - Right
+		or
+		0 - Leftmost
+		and higher numbers going toward the right.
+
+What:           /sys/bus/acpi/devices/.../pld/shape
+Date:           Feb, 2022
+Contact:        Won Chung <[email protected]>
+Description:
+		Describes the shape of the device connection point.
+		0 - Round
+		1 - Oval
+		2 - Square
+		3 - Vertical Rectangle
+		4 - Horizontal Rectangle
+		5 - Vertical Trapezoid
+		6 - Horizontal Trapezoid
+		7 - Unknown - Shape rendered as a Rectangle with dotted lines
+		8 - Chamfered
+		15:9 - Reserved
+
drivers/acpi/device_sysfs.c +51 -0

67 lines not on this page · raw message

drivers/acpi/scan.c +4 -6
index 1331756d4cfc..92c40de36ca8 100644
@@ -668,17 +668,15 @@ static int acpi_tie_acpi_dev(struct acpi_device *adev)
 	return 0;
 }
 
-static void acpi_store_pld_crc(struct acpi_device *adev)
+static void acpi_store_pld(struct acpi_device *adev)
 {
-	struct acpi_pld_info *pld;
 	acpi_status status;
 
-	status = acpi_get_physical_device_location(adev->handle, &pld);
+	status = acpi_get_physical_device_location(adev->handle, &adev->pld);
 	if (ACPI_FAILURE(status))
 		return;
 
-	adev->pld_crc = crc32(~0, pld, sizeof(*pld));
-	ACPI_FREE(pld);
+	adev->pld_crc = crc32(~0, adev->pld, sizeof(*adev->pld));
 }
 
 static int __acpi_device_add(struct acpi_device *device,
@@ -739,7 +737,7 @@ static int __acpi_device_add(struct acpi_device *device,
 	if (device->wakeup.flags.valid)
 		list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list);
 
-	acpi_store_pld_crc(device);
+	acpi_store_pld(device);
 
 	mutex_unlock(&acpi_device_lock);
 
include/acpi/acpi_bus.h +1 -0
index ca88c4706f2b..929e726a666b 100644
@@ -381,6 +381,7 @@ struct acpi_device {
 	struct acpi_hotplug_context *hp;
 	struct acpi_driver *driver;
 	const struct acpi_gpio_mapping *driver_gpios;
+	struct acpi_pld_info *pld;
 	void *driver_data;
 	struct device dev;
 	unsigned int physical_node_count;
Signature · 1 line
2.35.0.263.gb82422642f-goog