Skip to contentSkip to conversation

platform/chrome: Add ChromeOS ACPI device driver

PATCH Applied Muhammad Usama Anjum 2 participants 3 messages May 13, 2022 – May 16, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v13 1/1 platform/chrome: Add ChromeOS ACPI device driver

From: Enric Balletbo i Serra <[email protected]>

The x86 Chromebooks have the ChromeOS ACPI device. This driver attaches to the ChromeOS ACPI device and exports the values reported by ACPI in a sysfs directory. This data isn't present in ACPI tables when read through ACPI tools, hence a driver is needed to do it. The driver gets data from firmware using the ACPI component of the kernel. The ACPI values are presented in string form (numbers as decimal values) or binary blobs, and can be accessed as the contents of the appropriate read only files in the standard ACPI device's sysfs directory tree. This data is consumed by the ChromeOS user space.

---
Changes in v13:
- Made error handling better in some functions

Changes in v12:
- Use one type of correct commenting style
- Optimize parse_attr_name
- Made code a little more readable at some places
- Remove usage of ACPI_PTR

Changes in v11:
- Use __ATTR macro
- Remove local variable length and return instead

Changes in v10:
- Remove COMPILE_TEST as driver depends on ACPI component which isn't enabled by COMPILE_TEST itself.
- Fix build warnings

Changes in v9:
- Changed the implementation completely
- Move the driver to drivers/platform/chrome
- Remove Acked-by Rafael as driver has changed
- Corrected some typos
- Changed the author of the module

Changes in v8:
- Change struct platform_driver name from chromeos_acpi_driver to chromeos_acpi_device_driver

Changes in v7:
- Rename acpi_chromeos Kconfig option to chromeos_acpi
- Change this acpi driver to platform driver
- Minor cosmetic changes

There were the following concerns on v4 which have been delt with in v5/v6:
- Remove BINF.{0,1,4} from sysfs as they are reserved and not used anymore
- Reword the description of MECK
- Change function name from chromeos_acpi_alloc_name() to chromeos_acpi_gen_file_name()
- Remove local variable obj in chromeos_acpi_add_method()
- Replace usage of dev_info() to dev_dbg()
- Improve the description of the patch
- Add the firmware interface document which serves as primary documentation and garantees that this interface will not change
- GGL0001 is valid PNP ID of the Google. PNP ID can be used with the ACPI devices. Consensus was developed on it in discussion of v4.

Changes in v6:
- Correct authorship and path email's From
- Add changelog between v4 and v5 in detail
- Add copywrite year 2022
- Improve the description and add concerns from V4 which have been fixed

Changes in v5:
- Improve the description of the patch
- Document firmware interface
- Update sysfs interface documentation
- Remove binf{0,1,4} as they have been deprecated
- Update some cleanup logic in case of error
- Remove freeing of chromeos_acpi.root explicitely in chromeos_acpi_device_remove() as it'll be automatically freed by chromeos_acpi_remove_groups()
- If sysfs_create_groups() fails in chromeos_acpi_process_mlst(), cleanup all groups
- Cosmetic changes

Changes in v4:
https://lore.kernel.org/lkml/[email protected]/t/
- Add COMPILE_TEST to increase build coverage.
- Add sysfs ABI documentation.
- Rebased on top of 5.7-rc1 and solve conflicts.
- Cc ACPI maintainers.

Changes in v3:
- Use attribute groups instead of adding files "by hand".
- Do not use "raw" kobject to create directories.
- Do not abuse of the platform_device interface. Remove it.

Changes in v2:
- Note that this version is a total rework, with those major changes:
- Use lists to track dinamically allocated attributes and groups.
- Use sysfs binary attributes to store the ACPI contents.
- Remove all the functionalities except the one that creates the sysfs files.

---
 .../ABI/testing/sysfs-driver-chromeos-acpi    | 126 ++++++
 .../acpi/chromeos-acpi-device.rst             | 363 ++++++++++++++++++
 Documentation/firmware-guide/acpi/index.rst   |   1 +
 drivers/platform/chrome/Kconfig               |  11 +
 drivers/platform/chrome/Makefile              |   1 +
 drivers/platform/chrome/chromeos_acpi.c       | 257 +++++++++++++
 6 files changed, 759 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-chromeos-acpi
 create mode 100644 Documentation/firmware-guide/acpi/chromeos-acpi-device.rst
 create mode 100644 drivers/platform/chrome/chromeos_acpi.c
Documentation/ABI/testing/sysfs-driver-chromeos-acpi new file +126 -0
new file mode 100644
index 0000000000000..5b59ef9d7b371
@@ -0,0 +1,126 @@
+What:		/sys/bus/platform/devices/GGL0001:*/BINF.2
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows information about the current boot of
+		the active EC firmware.
+		  * 0 - Read only (recovery) firmware.
+		  * 1 - Rewritable firmware.
+
+What:		/sys/bus/platform/devices/GGL0001:*/BINF.3
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows information about the current boot of
+		the active main	firmware type.
+		  * 0 - Recovery.
+		  * 1 - Normal.
+		  * 2 - Developer.
+		  * 3 - Netboot (factory installation only).
+
+What:		/sys/bus/platform/devices/GGL0001:*/CHSW
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the switch position for the Chrome OS specific
+		hardware switches.
+		  * 0   - No changes.
+		  * 2   - Recovery button was pressed when firmware booted.
+		  * 4   - Recovery button was pressed when EC firmware booted.
+		  * 32  - Developer switch was enabled when firmware booted.
+		  * 512 - Firmware write protection was disabled when firmware
+			  booted.
+
+What:		/sys/bus/platform/devices/GGL0001:*/FMAP
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the physical memory address of the start of
+		the main processor firmware flashmap.
+
+What:		/sys/bus/platform/devices/GGL0001:*/FRID
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the firmware version for the read-only portion
+		of the main processor firmware.
+
+What:		/sys/bus/platform/devices/GGL0001:*/FWID
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the firmware version for the rewritable portion
+		of the main processor firmware.
+
+What:		/sys/bus/platform/devices/GGL0001:*/GPIO.X/GPIO.0
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the type of the GPIO signal for the Chrome OS
+		specific GPIO assignments.
+		  * 1   - Recovery button.
+		  * 2   - Developer mode switch.
+		  * 3   - Firmware write protection switch.
+		  * 256 to 511 - Debug header GPIO 0 to GPIO 255.
+
+What:		/sys/bus/platform/devices/GGL0001:*/GPIO.X/GPIO.1
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the signal attributes of the GPIO signal.
+		  * 0 - Signal is active low.
+		  * 1 - Signal is active high.
+
+What:		/sys/bus/platform/devices/GGL0001:*/GPIO.X/GPIO.2
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the GPIO number on the specified GPIO
+		controller.
+
+What:		/sys/bus/platform/devices/GGL0001:*/GPIO.X/GPIO.3
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the name of the GPIO controller.
+
+What:		/sys/bus/platform/devices/GGL0001:*/HWID
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the hardware ID for the Chromebook.
+
+What:		/sys/bus/platform/devices/GGL0001:*/MECK
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This binary file returns the SHA-1 or SHA-256 hash that is
+		read out of the Management Engine extended registers during
+		boot. The hash is exported vi ACPI so the OS can verify that
+		the Management Engine firmware has not changed. If Management
+		Engine is not present, or if the firmware was unable to read the
+		extended registers, this buffer size can be zero.
+
+What:		/sys/bus/platform/devices/GGL0001:*/VBNV.0
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the offset in CMOS bank 0 of the verified boot
+		non-volatile storage block, counting from the first writable
+		CMOS byte (that is, 'offset = 0' is the byte following the 14
+		bytes of clock data).
+
+What:		/sys/bus/platform/devices/GGL0001:*/VBNV.1
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This file shows the size in bytes of the verified boot
+		non-volatile storage block.
+
+What:		/sys/bus/platform/devices/GGL0001:*/VDAT
+Date:		May 2022
+KernelVersion:	5.19
+Description:
+		This binary file returns the verified boot data block shared
+		between the firmware verification step and the kernel
+		verification step.
Documentation/firmware-guide/acpi/chromeos-acpi-device.rst new file +363 -0

363 lines not on this page · raw message

Documentation/firmware-guide/acpi/index.rst +1 -0
index b053b0c3d6969..b6a42f4ffe032 100644
@@ -29,3 +29,4 @@ ACPI Support
    non-d0-probe
    extcon-intel-int3496
    intel-pmc-mux
+   chromeos-acpi-device
drivers/platform/chrome/Kconfig +11 -0
index 75e93efd669f0..717299cbccac6 100644
@@ -15,6 +15,17 @@ menuconfig CHROME_PLATFORMS
 
 if CHROME_PLATFORMS
 
+config CHROMEOS_ACPI
+	tristate "ChromeOS specific ACPI extensions"
+	depends on ACPI
+	help
+	  This driver provides the firmware interface for the services
+	  exported through the ChromeOS interfaces when using ChromeOS
+	  ACPI firmware.
+
+	  If you have an ACPI-compatible Chromebook, say Y or M here.
+	  The module will be called chromeos_acpi.
+
 config CHROMEOS_LAPTOP
 	tristate "Chrome OS Laptop"
 	depends on I2C && DMI && X86
drivers/platform/chrome/Makefile +1 -0
index 6420ca129548e..52f5a2dde8b81 100644
@@ -4,6 +4,7 @@
 CFLAGS_cros_ec_trace.o:=		-I$(src)
 CFLAGS_cros_ec_sensorhub_ring.o:=	-I$(src)
 
+obj-$(CONFIG_CHROMEOS_ACPI)		+= chromeos_acpi.o
 obj-$(CONFIG_CHROMEOS_LAPTOP)		+= chromeos_laptop.o
 obj-$(CONFIG_CHROMEOS_PRIVACY_SCREEN)	+= chromeos_privacy_screen.o
 obj-$(CONFIG_CHROMEOS_PSTORE)		+= chromeos_pstore.o
drivers/platform/chrome/chromeos_acpi.c new file +257 -0

257 lines not on this page · raw message

Signature · 1 line
2.30.2
#1 lore raw
This patch was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Hello:

This patch was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Quoted 12 lines · On Fri, 13 May 2022 12:52:09 +0500 you wrote:

From: Enric Balletbo i Serra <[email protected]>

The x86 Chromebooks have the ChromeOS ACPI device. This driver attaches to the ChromeOS ACPI device and exports the values reported by ACPI in a sysfs directory. This data isn't present in ACPI tables when read through ACPI tools, hence a driver is needed to do it. The driver gets data from firmware using the ACPI component of the kernel. The ACPI values are presented in string form (numbers as decimal values) or binary blobs, and can be accessed as the contents of the appropriate read only files in the standard ACPI device's sysfs directory tree. This data is consumed by the ChromeOS user space.

Quoted 1 line

[...]

Here is the summary with links:
- [v13] platform/chrome: Add ChromeOS ACPI device driver

    https://git.kernel.org/chrome-platform/c/0a4cad9c11ad

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#2 lore raw
In reply to Muhammad Usama Anjum
This patch was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Hello:

This patch was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Quoted 12 lines · On Fri, 13 May 2022 12:52:09 +0500 you wrote:

From: Enric Balletbo i Serra <[email protected]>

The x86 Chromebooks have the ChromeOS ACPI device. This driver attaches to the ChromeOS ACPI device and exports the values reported by ACPI in a sysfs directory. This data isn't present in ACPI tables when read through ACPI tools, hence a driver is needed to do it. The driver gets data from firmware using the ACPI component of the kernel. The ACPI values are presented in string form (numbers as decimal values) or binary blobs, and can be accessed as the contents of the appropriate read only files in the standard ACPI device's sysfs directory tree. This data is consumed by the ChromeOS user space.

Quoted 1 line

[...]

Here is the summary with links:
- [v13] platform/chrome: Add ChromeOS ACPI device driver

    https://git.kernel.org/chrome-platform/c/0a4cad9c11ad

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html