From 424d56857067fec8944f562b75028dd3c1a8d9bd Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Sun, 24 Sep 2023 15:02:33 -0700 Subject: [PATCH 09/21] mfd: steamdeck: Expose controller board power in sysfs As of version 118 Deck's BIOS implements "SCBP" method that allows gating power of the controller board (VBUS). Add a basic WO method to our root MFD device to allow toggling that. Signed-off-by: Andrey Smirnov (cherry picked from commit f97f32718acc10cbb51fef925842392e80904d74) Signed-off-by: Cristian Ciocaltea --- drivers/mfd/steamdeck.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/mfd/steamdeck.c b/drivers/mfd/steamdeck.c index 0e504b3c2796..a60fa7db9141 100644 --- a/drivers/mfd/steamdeck.c +++ b/drivers/mfd/steamdeck.c @@ -41,9 +41,29 @@ struct steamdeck { STEAMDECK_ATTR_RO(firmware_version, "PDFW"); STEAMDECK_ATTR_RO(board_id, "BOID"); +static ssize_t controller_board_power_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct steamdeck *sd = dev_get_drvdata(dev); + bool enabled; + ssize_t ret = kstrtobool(buf, &enabled); + + if (ret) + return ret; + + if (ACPI_FAILURE(acpi_execute_simple_method(sd->adev->handle, + "SCBP", enabled))) + return -EIO; + + return count; +} +static DEVICE_ATTR_WO(controller_board_power); + static struct attribute *steamdeck_attrs[] = { &dev_attr_firmware_version.attr, &dev_attr_board_id.attr, + &dev_attr_controller_board_power.attr, NULL }; -- 2.44.0