From patchwork Mon Feb 8 19:35:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 12076393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18530C4332B for ; Mon, 8 Feb 2021 19:37:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E560464DDD for ; Mon, 8 Feb 2021 19:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236332AbhBHTg7 (ORCPT ); Mon, 8 Feb 2021 14:36:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236366AbhBHTgD (ORCPT ); Mon, 8 Feb 2021 14:36:03 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27409C061788; Mon, 8 Feb 2021 11:35:21 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id a9so27051127ejr.2; Mon, 08 Feb 2021 11:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HlT0zQ09HCBL/EqVDeSwK4irS0GIPz8ludMUB5Yh17g=; b=ne1ksQ1ulaqvrAVyWYd3SvCrOkYJsRZyHmdl7ry7mKgpfzrm5AG4cmrPhfnQRPw0rA hWkUMLh87YbYjKFSR837MwRn6SRk14lg2vssHHgLuII+xqp41MBwCAE+reXCEJU4mtRi 124vMNc1oJ/zvK8QLW3gkQbpCzEf7Bj20e8UNxTRAapREPTPlhmdK/TuZohn0+zZl1CS XbbcVAR95PCd0gg9YYn+qwfUmhGF0Bbz98vG1GU0weZDYqZtT0SG60cs/IdV5r3gsZG0 RkMm3VvOmaBzLvlmq5qJvfRXPadwu/ad+R6gPqYuVexpf5ACeoer2jqyC5joGToHA/lo c86Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HlT0zQ09HCBL/EqVDeSwK4irS0GIPz8ludMUB5Yh17g=; b=fXwd5QhKIcwMYiA1dwrrlV/6RUtqDxxzRZQwiY90Jiq2Tb4SZ19TJMF9aQF80AKIzD mjLU2o5MoUwzBC+gOSl9SqtyEGWkm74Ut3O5M2tczJ+BgDeUe1z1vYKowCf51pa1bOaO sSHCMmge1uTwKcRsQ9f4dVnXKeyRlcfAeBZ9zrj+5IFmcq0wpm+znWK0o1BGMUJOR7wH XYsTf+nXAySy1AQJ6tKY/8qOJfZ1EiOznYhrs/rlyp6JyZF9cGlcsA0AHtHgOoyLAMhR i4Ok/eqbmOfSBBZ2IirJmXUdPWasZHjADICOt6Pb8WjKhYCS0I6mvEBaJo4kpBmh3FEy 1vIg== X-Gm-Message-State: AOAM5338tHtY00h+09amA1ZhTdJeUTNFYbMSNQrVA3C9DkIrvKgEn5ts pTyxc8tAXLn4jzjK7MXYS/E= X-Google-Smtp-Source: ABdhPJw/+HXKuVoQfHiwTXp7VsWrTjzbVin2mjMMwHb/z1appjQ4sk1vy3UBcH4rERUi4K0I6lkSAg== X-Received: by 2002:a17:906:a28a:: with SMTP id i10mr18643249ejz.422.1612812920334; Mon, 08 Feb 2021 11:35:20 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id g9sm9241414ejp.55.2021.02.08.11.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 11:35:19 -0800 (PST) From: Maximilian Luz To: Hans de Goede Cc: Maximilian Luz , Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] platform/surface: Set up Surface Aggregator device registry Date: Mon, 8 Feb 2021 20:35:03 +0100 Message-Id: <20210208193508.3038055-2-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208193508.3038055-1-luzmaximilian@gmail.com> References: <20210208193508.3038055-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The Surface System Aggregator Module (SSAM) subsystem provides various functionalities, which are separated by spreading them across multiple devices and corresponding drivers. Parts of that functionality / some of those devices, however, can (as far as we currently know) not be auto-detected by conventional means. While older (specifically 5th- and 6th-)generation models do advertise most of their functionality via standard platform devices in ACPI, newer generations do not. As we are currently also not aware of any feasible way to query said functionalities dynamically, this poses a problem. There is, however, a device in ACPI that seems to be used by Windows for identifying different Surface models: The Windows Surface Integration Device (WSID). This device seems to have a HID corresponding to the overall set of functionalities SSAM provides for the associated model. This commit introduces a registry providing non-detectable device information via software nodes. In addition, a SSAM platform hub driver is introduced, which takes care of creating and managing the SSAM devices specified in this registry. This approach allows for a hierarchical setup akin to ACPI and is easily extendable, e.g. via firmware node properties. Note that this commit only provides the basis for the platform hub and registry, and does not add any content to it. The registry will be expanded in subsequent commits. Signed-off-by: Maximilian Luz --- MAINTAINERS | 1 + drivers/platform/surface/Kconfig | 26 ++ drivers/platform/surface/Makefile | 1 + .../surface/surface_aggregator_registry.c | 284 ++++++++++++++++++ 4 files changed, 312 insertions(+) create mode 100644 drivers/platform/surface/surface_aggregator_registry.c diff --git a/MAINTAINERS b/MAINTAINERS index 4fcf3df517a8..000a82f59c76 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11826,6 +11826,7 @@ F: Documentation/driver-api/surface_aggregator/ F: drivers/platform/surface/aggregator/ F: drivers/platform/surface/surface_acpi_notify.c F: drivers/platform/surface/surface_aggregator_cdev.c +F: drivers/platform/surface/surface_aggregator_registry.c F: include/linux/surface_acpi_notify.h F: include/linux/surface_aggregator/ F: include/uapi/linux/surface_aggregator/ diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig index 0847b2dc97bf..1cd37c041710 100644 --- a/drivers/platform/surface/Kconfig +++ b/drivers/platform/surface/Kconfig @@ -77,6 +77,32 @@ config SURFACE_AGGREGATOR_CDEV The provided interface is intended for debugging and development only, and should not be used otherwise. +config SURFACE_AGGREGATOR_REGISTRY + tristate "Surface System Aggregator Module Device Registry" + depends on SURFACE_AGGREGATOR_BUS + help + Device-registry and device-hubs for Surface System Aggregator Module + (SSAM) devices. + + Provides a module and driver which act as a device-registry for SSAM + client devices that cannot be detected automatically, e.g. via ACPI. + Such devices are instead provided via this registry and attached via + device hubs, also provided in this module. + + Devices provided via this registry are: + - Platform profile (performance-/cooling-mode) device (5th- and later + generations). + - Battery/AC devices (7th-generation). + - HID input devices (7th-generation). + + Select M (recommended) or Y here if you want support for the above + mentioned devices on the corresponding Surface models. Without this + module, the respective devices will not be instantiated and thus any + functionality provided by them will be missing, even when drivers for + these devices are present. In other words, this module only provides + the respective client devices. Drivers for these devices still need to + be selected via the other options. + config SURFACE_GPE tristate "Surface GPE/Lid Support Driver" depends on DMI diff --git a/drivers/platform/surface/Makefile b/drivers/platform/surface/Makefile index 990424c5f0c9..80035ee540bf 100644 --- a/drivers/platform/surface/Makefile +++ b/drivers/platform/surface/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_SURFACE_3_POWER_OPREGION) += surface3_power.o obj-$(CONFIG_SURFACE_ACPI_NOTIFY) += surface_acpi_notify.o obj-$(CONFIG_SURFACE_AGGREGATOR) += aggregator/ obj-$(CONFIG_SURFACE_AGGREGATOR_CDEV) += surface_aggregator_cdev.o +obj-$(CONFIG_SURFACE_AGGREGATOR_REGISTRY) += surface_aggregator_registry.o obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o obj-$(CONFIG_SURFACE_HOTPLUG) += surface_hotplug.o obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c new file mode 100644 index 000000000000..a051d941ad96 --- /dev/null +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -0,0 +1,284 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Surface System Aggregator Module (SSAM) client device registry. + * + * Registry for non-platform/non-ACPI SSAM client devices, i.e. devices that + * cannot be auto-detected. Provides device-hubs and performs instantiation + * for these devices. + * + * Copyright (C) 2020-2021 Maximilian Luz + */ + +#include +#include +#include +#include +#include + +#include +#include + + +/* -- Device registry. ------------------------------------------------------ */ + +/* + * SSAM device names follow the SSAM module alias, meaning they are prefixed + * with 'ssam:', followed by domain, category, target ID, instance ID, and + * function, each encoded as two-digit hexadecimal, separated by ':'. In other + * words, it follows the scheme + * + * ssam:dd:cc:tt:ii:ff + * + * Where, 'dd', 'cc', 'tt', 'ii', and 'ff' are the two-digit hexadecimal + * values mentioned above, respectively. + */ + +/* Root node. */ +static const struct software_node ssam_node_root = { + .name = "ssam_platform_hub", +}; + +/* Devices for Surface Book 2. */ +static const struct software_node *ssam_node_group_sb2[] = { + &ssam_node_root, + NULL, +}; + +/* Devices for Surface Book 3. */ +static const struct software_node *ssam_node_group_sb3[] = { + &ssam_node_root, + NULL, +}; + +/* Devices for Surface Laptop 1. */ +static const struct software_node *ssam_node_group_sl1[] = { + &ssam_node_root, + NULL, +}; + +/* Devices for Surface Laptop 2. */ +static const struct software_node *ssam_node_group_sl2[] = { + &ssam_node_root, + NULL, +}; + +/* Devices for Surface Laptop 3. */ +static const struct software_node *ssam_node_group_sl3[] = { + &ssam_node_root, + NULL, +}; + +/* Devices for Surface Laptop Go. */ +static const struct software_node *ssam_node_group_slg1[] = { + &ssam_node_root, + NULL, +}; + +/* Devices for Surface Pro 5. */ +static const struct software_node *ssam_node_group_sp5[] = { + &ssam_node_root, + NULL, +}; + +/* Devices for Surface Pro 6. */ +static const struct software_node *ssam_node_group_sp6[] = { + &ssam_node_root, + NULL, +}; + +/* Devices for Surface Pro 7. */ +static const struct software_node *ssam_node_group_sp7[] = { + &ssam_node_root, + NULL, +}; + + +/* -- Device registry helper functions. ------------------------------------- */ + +static int ssam_uid_from_string(const char *str, struct ssam_device_uid *uid) +{ + u8 d, tc, tid, iid, fn; + int n; + + n = sscanf(str, "ssam:%hhx:%hhx:%hhx:%hhx:%hhx", &d, &tc, &tid, &iid, &fn); + if (n != 5) + return -EINVAL; + + uid->domain = d; + uid->category = tc; + uid->target = tid; + uid->instance = iid; + uid->function = fn; + + return 0; +} + +static int ssam_hub_remove_devices_fn(struct device *dev, void *data) +{ + if (!is_ssam_device(dev)) + return 0; + + ssam_device_remove(to_ssam_device(dev)); + return 0; +} + +static void ssam_hub_remove_devices(struct device *parent) +{ + device_for_each_child_reverse(parent, NULL, ssam_hub_remove_devices_fn); +} + +static int ssam_hub_add_device(struct device *parent, struct ssam_controller *ctrl, + struct fwnode_handle *node) +{ + struct ssam_device_uid uid; + struct ssam_device *sdev; + int status; + + status = ssam_uid_from_string(fwnode_get_name(node), &uid); + if (status) + return status; + + sdev = ssam_device_alloc(ctrl, uid); + if (!sdev) + return -ENOMEM; + + sdev->dev.parent = parent; + sdev->dev.fwnode = node; + + status = ssam_device_add(sdev); + if (status) + ssam_device_put(sdev); + + return status; +} + +static int ssam_hub_add_devices(struct device *parent, struct ssam_controller *ctrl, + struct fwnode_handle *node) +{ + struct fwnode_handle *child; + int status; + + fwnode_for_each_child_node(node, child) { + /* + * Try to add the device specified in the firmware node. If + * this fails with -EINVAL, the node does not specify any SSAM + * device, so ignore it and continue with the next one. + */ + + status = ssam_hub_add_device(parent, ctrl, child); + if (status && status != -EINVAL) + goto err; + } + + return 0; +err: + ssam_hub_remove_devices(parent); + return status; +} + + +/* -- SSAM platform/meta-hub driver. ---------------------------------------- */ + +static const struct acpi_device_id ssam_platform_hub_match[] = { + /* Surface Pro 4, 5, and 6 (OMBR < 0x10) */ + { "MSHW0081", (unsigned long)ssam_node_group_sp5 }, + + /* Surface Pro 6 (OMBR >= 0x10) */ + { "MSHW0111", (unsigned long)ssam_node_group_sp6 }, + + /* Surface Pro 7 */ + { "MSHW0116", (unsigned long)ssam_node_group_sp7 }, + + /* Surface Book 2 */ + { "MSHW0107", (unsigned long)ssam_node_group_sb2 }, + + /* Surface Book 3 */ + { "MSHW0117", (unsigned long)ssam_node_group_sb3 }, + + /* Surface Laptop 1 */ + { "MSHW0086", (unsigned long)ssam_node_group_sl1 }, + + /* Surface Laptop 2 */ + { "MSHW0112", (unsigned long)ssam_node_group_sl2 }, + + /* Surface Laptop 3 (13", Intel) */ + { "MSHW0114", (unsigned long)ssam_node_group_sl3 }, + + /* Surface Laptop 3 (15", AMD) */ + { "MSHW0110", (unsigned long)ssam_node_group_sl3 }, + + /* Surface Laptop Go 1 */ + { "MSHW0118", (unsigned long)ssam_node_group_slg1 }, + + { }, +}; +MODULE_DEVICE_TABLE(acpi, ssam_platform_hub_match); + +static int ssam_platform_hub_probe(struct platform_device *pdev) +{ + const struct software_node **nodes; + struct ssam_controller *ctrl; + struct fwnode_handle *root; + int status; + + nodes = (const struct software_node **)acpi_device_get_match_data(&pdev->dev); + if (!nodes) + return -ENODEV; + + /* + * As we're adding the SSAM client devices as children under this device + * and not the SSAM controller, we need to add a device link to the + * controller to ensure that we remove all of our devices before the + * controller is removed. This also guarantees proper ordering for + * suspend/resume of the devices on this hub. + */ + ctrl = ssam_client_bind(&pdev->dev); + if (IS_ERR(ctrl)) + return PTR_ERR(ctrl) == -ENODEV ? -EPROBE_DEFER : PTR_ERR(ctrl); + + status = software_node_register_node_group(nodes); + if (status) + return status; + + root = software_node_fwnode(&ssam_node_root); + if (!root) { + software_node_unregister_node_group(nodes); + return -ENOENT; + } + + set_secondary_fwnode(&pdev->dev, root); + + status = ssam_hub_add_devices(&pdev->dev, ctrl, root); + if (status) { + set_secondary_fwnode(&pdev->dev, NULL); + software_node_unregister_node_group(nodes); + } + + platform_set_drvdata(pdev, nodes); + return status; +} + +static int ssam_platform_hub_remove(struct platform_device *pdev) +{ + const struct software_node **nodes = platform_get_drvdata(pdev); + + ssam_hub_remove_devices(&pdev->dev); + set_secondary_fwnode(&pdev->dev, NULL); + software_node_unregister_node_group(nodes); + return 0; +} + +static struct platform_driver ssam_platform_hub_driver = { + .probe = ssam_platform_hub_probe, + .remove = ssam_platform_hub_remove, + .driver = { + .name = "surface_aggregator_platform_hub", + .acpi_match_table = ssam_platform_hub_match, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, +}; +module_platform_driver(ssam_platform_hub_driver); + +MODULE_AUTHOR("Maximilian Luz "); +MODULE_DESCRIPTION("Device-registry for Surface System Aggregator Module"); +MODULE_LICENSE("GPL"); From patchwork Mon Feb 8 19:35:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 12076391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB449C433E9 for ; Mon, 8 Feb 2021 19:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE32160238 for ; Mon, 8 Feb 2021 19:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236342AbhBHTgy (ORCPT ); Mon, 8 Feb 2021 14:36:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236384AbhBHTgD (ORCPT ); Mon, 8 Feb 2021 14:36:03 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5550EC06178A; Mon, 8 Feb 2021 11:35:23 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id w1so26978012ejf.11; Mon, 08 Feb 2021 11:35:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CKTjcZrKPElcKyPJ5qAyLAr8f1S682D7/6q/UuWh6ys=; b=tiOe0Tx+kT0lO1I85fHzss690AbbHPQLgtZ4OxesVPRHqSEhFYlHC0vJJMTECD1EQC cZagIfwiywfbuA275x/5qVf5zR7DaosZIHKpovUC619wucprZA0k/BWN+GxFkcLtvxqc r13yATT7mLpXXAxTKDKgx750zKe654XiuSHuBenfCXolbblSF9HC6xFOYiufCsOUDNTU N3uLnVuwtiZQ2dlVOr+Z0g4pBm2lwHmOKgYB1mSPl6hTVDEYVFP6Zayrmx8GZWV+5G4x YvcJzXYOJ3R33L8odNgu7BGBlNHftkZP+WO8xYvjZ0zKZBXsv2twh+6pnT2471XB26Vv rhRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CKTjcZrKPElcKyPJ5qAyLAr8f1S682D7/6q/UuWh6ys=; b=P/VTQBANmeJ64QhfVHD3Amx6N/n/23S4n9K/DJl0lbXudyyWcQfrAZJtT634Vbsa+P VeJWC5AlTlnYq4IXhQzF9mkexh2pCVwR0yNPoy0B/NwdRKHXfbkwBMauOjgCSp9uxjBC eHMxenBzs1WiZgA53RAwaBqVUfSRfq5A7mvSiFDNvnX+DpufdprBKtAr2xLPZLlushpP FXPyv0x5VTqIIyHgwJKKeN+DfqL8B18p9DPKOAIpSeONQhBe7WeRM6dayj38VMwzJAeL FKAbcj+Mh7/HiCRWVISqFZO8vgfDl6bayHmiaSbRkM8DidfBUiJbKlICgXIVv5QNDrCW zo8g== X-Gm-Message-State: AOAM533Sgt/vcIO86x5OsXZN5dELich3BaNtunZnNlSXiqZnW4oYHTM4 T/HbG5fnFxU/VY8j26+5Mtw= X-Google-Smtp-Source: ABdhPJyvZZ77WkLVc4OOOnTjuMqyWftQVh5dXOCZVtOPfMhb9ucyw4ORdNE3yz7dq2NHoI+CymJW/g== X-Received: by 2002:a17:906:e104:: with SMTP id gj4mr18364099ejb.349.1612812922078; Mon, 08 Feb 2021 11:35:22 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id g9sm9241414ejp.55.2021.02.08.11.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 11:35:21 -0800 (PST) From: Maximilian Luz To: Hans de Goede Cc: Maximilian Luz , Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] platform/surface: aggregator_registry: Add base device hub Date: Mon, 8 Feb 2021 20:35:04 +0100 Message-Id: <20210208193508.3038055-3-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208193508.3038055-1-luzmaximilian@gmail.com> References: <20210208193508.3038055-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The Surface Book 3 has a detachable base part. While the top part (so-called clipboard) contains the CPU, touchscreen, and primary battery, the base contains, among other things, a keyboard, touchpad, and secondary battery. Those devices do not react well to being accessed when the base part is detached and should thus be removed and added in sync with the base. To facilitate this, we introduce a virtual base device hub, which automatically removes or adds the devices registered under it. Signed-off-by: Maximilian Luz --- .../surface/surface_aggregator_registry.c | 261 +++++++++++++++++- 1 file changed, 260 insertions(+), 1 deletion(-) diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c index a051d941ad96..0d802804594c 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -11,9 +11,12 @@ #include #include +#include #include +#include #include #include +#include #include #include @@ -38,6 +41,12 @@ static const struct software_node ssam_node_root = { .name = "ssam_platform_hub", }; +/* Base device hub (devices attached to Surface Book 3 base). */ +static const struct software_node ssam_node_hub_base = { + .name = "ssam:00:00:02:00:00", + .parent = &ssam_node_root, +}; + /* Devices for Surface Book 2. */ static const struct software_node *ssam_node_group_sb2[] = { &ssam_node_root, @@ -47,6 +56,7 @@ static const struct software_node *ssam_node_group_sb2[] = { /* Devices for Surface Book 3. */ static const struct software_node *ssam_node_group_sb3[] = { &ssam_node_root, + &ssam_node_hub_base, NULL, }; @@ -177,6 +187,230 @@ static int ssam_hub_add_devices(struct device *parent, struct ssam_controller *c } +/* -- SSAM base-hub driver. ------------------------------------------------- */ + +enum ssam_base_hub_state { + SSAM_BASE_HUB_UNINITIALIZED, + SSAM_BASE_HUB_CONNECTED, + SSAM_BASE_HUB_DISCONNECTED, +}; + +struct ssam_base_hub { + struct ssam_device *sdev; + + struct mutex lock; /* Guards state update checks and transitions. */ + enum ssam_base_hub_state state; + + struct ssam_event_notifier notif; +}; + +static SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_query_opmode, u8, { + .target_category = SSAM_SSH_TC_BAS, + .target_id = 0x01, + .command_id = 0x0d, + .instance_id = 0x00, +}); + +#define SSAM_BAS_OPMODE_TABLET 0x00 +#define SSAM_EVENT_BAS_CID_CONNECTION 0x0c + +static int ssam_base_hub_query_state(struct ssam_base_hub *hub, enum ssam_base_hub_state *state) +{ + u8 opmode; + int status; + + status = ssam_retry(ssam_bas_query_opmode, hub->sdev->ctrl, &opmode); + if (status < 0) { + dev_err(&hub->sdev->dev, "failed to query base state: %d\n", status); + return status; + } + + if (opmode != SSAM_BAS_OPMODE_TABLET) + *state = SSAM_BASE_HUB_CONNECTED; + else + *state = SSAM_BASE_HUB_DISCONNECTED; + + return 0; +} + +static ssize_t ssam_base_hub_state_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct ssam_base_hub *hub = dev_get_drvdata(dev); + bool connected; + + mutex_lock(&hub->lock); + connected = hub->state == SSAM_BASE_HUB_CONNECTED; + mutex_unlock(&hub->lock); + + return sysfs_emit(buf, "%d\n", connected); +} + +static struct device_attribute ssam_base_hub_attr_state = + __ATTR(state, 0444, ssam_base_hub_state_show, NULL); + +static struct attribute *ssam_base_hub_attrs[] = { + &ssam_base_hub_attr_state.attr, + NULL, +}; + +const struct attribute_group ssam_base_hub_group = { + .attrs = ssam_base_hub_attrs, +}; + +static int __ssam_base_hub_update(struct ssam_base_hub *hub, enum ssam_base_hub_state new) +{ + struct fwnode_handle *node = dev_fwnode(&hub->sdev->dev); + int status = 0; + + lockdep_assert_held(hub->lock); + + if (hub->state == new) + return 0; + hub->state = new; + + if (hub->state == SSAM_BASE_HUB_CONNECTED) + status = ssam_hub_add_devices(&hub->sdev->dev, hub->sdev->ctrl, node); + else + ssam_hub_remove_devices(&hub->sdev->dev); + + if (status) + dev_err(&hub->sdev->dev, "failed to update base-hub devices: %d\n", status); + + return status; +} + +static int ssam_base_hub_update(struct ssam_base_hub *hub) +{ + enum ssam_base_hub_state state; + int status; + + mutex_lock(&hub->lock); + + status = ssam_base_hub_query_state(hub, &state); + if (!status) + status = __ssam_base_hub_update(hub, state); + + mutex_unlock(&hub->lock); + return status; +} + +static u32 ssam_base_hub_notif(struct ssam_event_notifier *nf, const struct ssam_event *event) +{ + struct ssam_base_hub *hub; + struct ssam_device *sdev; + enum ssam_base_hub_state new; + + hub = container_of(nf, struct ssam_base_hub, notif); + sdev = hub->sdev; + + if (event->command_id != SSAM_EVENT_BAS_CID_CONNECTION) + return 0; + + if (event->length < 1) { + dev_err(&sdev->dev, "unexpected payload size: %u\n", + event->length); + return 0; + } + + if (event->data[0]) + new = SSAM_BASE_HUB_CONNECTED; + else + new = SSAM_BASE_HUB_DISCONNECTED; + + mutex_lock(&hub->lock); + __ssam_base_hub_update(hub, new); + mutex_unlock(&hub->lock); + + /* + * Do not return SSAM_NOTIF_HANDLED: The event should be picked up and + * consumed by the detachment system driver. We're just a (more or less) + * silent observer. + */ + return 0; +} + +static int __maybe_unused ssam_base_hub_resume(struct device *dev) +{ + return ssam_base_hub_update(dev_get_drvdata(dev)); +} +static SIMPLE_DEV_PM_OPS(ssam_base_hub_pm_ops, NULL, ssam_base_hub_resume); + +static int ssam_base_hub_probe(struct ssam_device *sdev) +{ + struct ssam_base_hub *hub; + int status; + + hub = devm_kzalloc(&sdev->dev, sizeof(*hub), GFP_KERNEL); + if (!hub) + return -ENOMEM; + + mutex_init(&hub->lock); + + hub->sdev = sdev; + hub->state = SSAM_BASE_HUB_UNINITIALIZED; + + hub->notif.base.priority = INT_MAX; /* This notifier should run first. */ + hub->notif.base.fn = ssam_base_hub_notif; + hub->notif.event.reg = SSAM_EVENT_REGISTRY_SAM; + hub->notif.event.id.target_category = SSAM_SSH_TC_BAS, + hub->notif.event.id.instance = 0, + hub->notif.event.mask = SSAM_EVENT_MASK_NONE; + hub->notif.event.flags = SSAM_EVENT_SEQUENCED; + + ssam_device_set_drvdata(sdev, hub); + + status = ssam_notifier_register(sdev->ctrl, &hub->notif); + if (status) + goto err_register; + + status = ssam_base_hub_update(hub); + if (status) + goto err_update; + + status = sysfs_create_group(&sdev->dev.kobj, &ssam_base_hub_group); + if (status) + goto err_update; + + return 0; + +err_update: + ssam_notifier_unregister(sdev->ctrl, &hub->notif); + ssam_hub_remove_devices(&sdev->dev); +err_register: + mutex_destroy(&hub->lock); + return status; +} + +static void ssam_base_hub_remove(struct ssam_device *sdev) +{ + struct ssam_base_hub *hub = ssam_device_get_drvdata(sdev); + + sysfs_remove_group(&sdev->dev.kobj, &ssam_base_hub_group); + + ssam_notifier_unregister(sdev->ctrl, &hub->notif); + ssam_hub_remove_devices(&sdev->dev); + + mutex_destroy(&hub->lock); +} + +static const struct ssam_device_id ssam_base_hub_match[] = { + { SSAM_VDEV(HUB, 0x02, SSAM_ANY_IID, 0x00) }, + { }, +}; + +static struct ssam_device_driver ssam_base_hub_driver = { + .probe = ssam_base_hub_probe, + .remove = ssam_base_hub_remove, + .match_table = ssam_base_hub_match, + .driver = { + .name = "surface_aggregator_base_hub", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + .pm = &ssam_base_hub_pm_ops, + }, +}; + + /* -- SSAM platform/meta-hub driver. ---------------------------------------- */ static const struct acpi_device_id ssam_platform_hub_match[] = { @@ -277,7 +511,32 @@ static struct platform_driver ssam_platform_hub_driver = { .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, }; -module_platform_driver(ssam_platform_hub_driver); + + +/* -- Module initialization. ------------------------------------------------ */ + +static int __init ssam_device_hub_init(void) +{ + int status; + + status = platform_driver_register(&ssam_platform_hub_driver); + if (status) + return status; + + status = ssam_device_driver_register(&ssam_base_hub_driver); + if (status) + platform_driver_unregister(&ssam_platform_hub_driver); + + return status; +} +module_init(ssam_device_hub_init); + +static void __exit ssam_device_hub_exit(void) +{ + ssam_device_driver_unregister(&ssam_base_hub_driver); + platform_driver_unregister(&ssam_platform_hub_driver); +} +module_exit(ssam_device_hub_exit); MODULE_AUTHOR("Maximilian Luz "); MODULE_DESCRIPTION("Device-registry for Surface System Aggregator Module"); From patchwork Mon Feb 8 19:35:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 12076395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75FDBC4332D for ; Mon, 8 Feb 2021 19:37:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AF8564E8F for ; Mon, 8 Feb 2021 19:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236352AbhBHThE (ORCPT ); Mon, 8 Feb 2021 14:37:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236216AbhBHTgF (ORCPT ); Mon, 8 Feb 2021 14:36:05 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3395C06178B; Mon, 8 Feb 2021 11:35:24 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id lg21so27068939ejb.3; Mon, 08 Feb 2021 11:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9Md7oHiTHjbwRSktyunhTsYtpsxjjWEPdbXs75rlCNs=; b=J7wGk+lkfGiegQ1Cta04DXg28H/jJcVhDu37qQ6XsTZeJ9SN7v17kVc5959vGXS76f 16GI83uAPwqDvBMYqpK0J0FhjWhXtL7T378GYh70dmWskSpCfp5AhqkuGM3ZUawQtIJv NjwiamnVMW91p1V8yBmRtC+c9WfWHwEFZWVtbPTqYNHq9tBViXWF7TPiCShqeBFpDmhb BTiPudQ+AleAmk7eSzSzSQV4kgznJk3L3p5yoSE8VRQADa4YDUd0Cb8DQS8+w8A8nHH3 Yi5ZK9TWPGoybvtbNyX+kYFpQamVnkXtHsquKGqISHsPk6ZrEjUidoZimfF8SwhA7nPr iYnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Md7oHiTHjbwRSktyunhTsYtpsxjjWEPdbXs75rlCNs=; b=N8OsgrSNaoKsYdHvCVR1ht3E8gisaqhX+mA0/JptfimFAFQV5PgtLRuYNGrzerbz0O yiZBMKU4rNIfM44IBubpM7vXEN/6pUj1GIDY5z7yZ2k5Lu8hxQ2dUtmU1m1fVNnBktPk r1Wz8hrWS74Z9SDgw/+akQy20uSooZ77EVRhj9fiIRicqxaBOqbolVDXWW/RDo+/UO2I euuivYlEp5LyMdP94BLL3FKsK9QJN8P1Oiz02WNVNsV8/S5gchD924LMOeF1QoNLbPPa i9an77ZH9ucL2rlcpfTgBJGPMQTp9attWRFh0azorT+25OYvVFbj16BNIlJwIf3Vlg9R oQqw== X-Gm-Message-State: AOAM532wkBD6IZzN+Dp8cFqn/rWmrtxvpPQyvds+2MXrRoUnsTDlA3HE AU9cVkgmz+rfPA0EQ+aK8AYAeEhRsbMHcg== X-Google-Smtp-Source: ABdhPJw1as3iXGuEPUD5NsUhFgrUx7wgIMZrhXt2zmfgLm3MXrG9V38FGYzEoEdw+thJKORcoaSMVA== X-Received: by 2002:a17:906:3a10:: with SMTP id z16mr3490304eje.483.1612812923604; Mon, 08 Feb 2021 11:35:23 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id g9sm9241414ejp.55.2021.02.08.11.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 11:35:22 -0800 (PST) From: Maximilian Luz To: Hans de Goede Cc: Maximilian Luz , Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] platform/surface: aggregator_registry: Add battery subsystem devices Date: Mon, 8 Feb 2021 20:35:05 +0100 Message-Id: <20210208193508.3038055-4-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208193508.3038055-1-luzmaximilian@gmail.com> References: <20210208193508.3038055-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Add battery subsystem (TC=0x02) devices (battery and AC) to the SSAM device registry. These devices need to be registered for 7th-generation Surface models. On 5th- and 6th-generation models, these devices are handled via the standard ACPI battery/AC interface, which in turn accesses the same SSAM interface via the Surface ACPI Notify (SAN) driver. Signed-off-by: Maximilian Luz --- .../surface/surface_aggregator_registry.c | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c index 0d802804594c..7e7b801bc606 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -47,6 +47,24 @@ static const struct software_node ssam_node_hub_base = { .parent = &ssam_node_root, }; +/* AC adapter. */ +static const struct software_node ssam_node_bat_ac = { + .name = "ssam:01:02:01:01:01", + .parent = &ssam_node_root, +}; + +/* Primary battery. */ +static const struct software_node ssam_node_bat_main = { + .name = "ssam:01:02:01:01:00", + .parent = &ssam_node_root, +}; + +/* Secondary battery (Surface Book 3). */ +static const struct software_node ssam_node_bat_sb3base = { + .name = "ssam:01:02:02:01:00", + .parent = &ssam_node_hub_base, +}; + /* Devices for Surface Book 2. */ static const struct software_node *ssam_node_group_sb2[] = { &ssam_node_root, @@ -57,6 +75,9 @@ static const struct software_node *ssam_node_group_sb2[] = { static const struct software_node *ssam_node_group_sb3[] = { &ssam_node_root, &ssam_node_hub_base, + &ssam_node_bat_ac, + &ssam_node_bat_main, + &ssam_node_bat_sb3base, NULL, }; @@ -75,12 +96,16 @@ static const struct software_node *ssam_node_group_sl2[] = { /* Devices for Surface Laptop 3. */ static const struct software_node *ssam_node_group_sl3[] = { &ssam_node_root, + &ssam_node_bat_ac, + &ssam_node_bat_main, NULL, }; /* Devices for Surface Laptop Go. */ static const struct software_node *ssam_node_group_slg1[] = { &ssam_node_root, + &ssam_node_bat_ac, + &ssam_node_bat_main, NULL, }; @@ -99,6 +124,8 @@ static const struct software_node *ssam_node_group_sp6[] = { /* Devices for Surface Pro 7. */ static const struct software_node *ssam_node_group_sp7[] = { &ssam_node_root, + &ssam_node_bat_ac, + &ssam_node_bat_main, NULL, }; From patchwork Mon Feb 8 19:35:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 12076399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55059C433E0 for ; Mon, 8 Feb 2021 19:38:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D08064E85 for ; Mon, 8 Feb 2021 19:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236367AbhBHThO (ORCPT ); Mon, 8 Feb 2021 14:37:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232766AbhBHTgG (ORCPT ); Mon, 8 Feb 2021 14:36:06 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D8AEC06178C; Mon, 8 Feb 2021 11:35:26 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id hs11so27115027ejc.1; Mon, 08 Feb 2021 11:35:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/ki372JPzgSTNSo8pjr6Qw99cDcb/v0iRPGUG+av7wM=; b=cVaiIw30T0+miPLGI/MQ6yRhVfVP/VDobvEgcQD20KEmh5F6s8F4fO0gRG51Zy7Czz 3Yw0VO6jIFe+ma350fFaMUUjeItnDwpl9xWqjToILY5l+HTUYYAefz9lZnhOLzAzkK4+ EBkauxhVcQfQUuoSO3pwiao1rzNpsC2gXLwxDDZa8BTgNlD6TrAa00b4sOizULVwyxml oSgomik+Cp9fFSX87zoTmZr+DviTWDn74jhTTji3vtbIwwHM37IGtDc5A5/ZsRdlTnyn sUIyR7ilT3IsBr7vaCkvbEC3Ut41wiUo6KkoFoS5hOSWUVRxsu26yvb+PKiY1dMWWwYR GFew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/ki372JPzgSTNSo8pjr6Qw99cDcb/v0iRPGUG+av7wM=; b=mks/OKNfiIAGL902gUJP7TSlecbcdTdkxnMOPe5fLKTszJMH8Zop82FlQvqnr6YSYw I//XH+ulWqGuh5mQzgTmVPSP2fqHEbYu83tr1B9uXuvJiPxy4Gr4ThrIv7tx1SwtGgRD Pw3LvT0HtY09en8bJCbkSpkJFJJDGXNqt6Eswfq6kbEpAvcGtc11Ppkfi0w7vBmJpWTc vYBNqSEcwqZSfEdnaBMM4OzhDbT04BEEqiD907ET9+PueAcvxrUTwUeBsFQ6l6ZYYXe/ NafGrHH3+JiDwYkr+Mcc1ji1YgubUxtIgnFoUTqV/wYIgWcJWFOkx90ZHBoDeMLfeEfT MYAQ== X-Gm-Message-State: AOAM533LxqnNDhpFkpg/GJX49KRHgslQkYjloS69YkGNrgr5d2z1diqc fkXrCNtOuig+02OLwSGLIZI8hCoNfzl/zA== X-Google-Smtp-Source: ABdhPJy6CqGMLdnHzYpER6/g3RyEd9/cr7gPm5s6FAlg3xrN9rSCv/ReTPXxXiW3SL5EYmxemEfJHw== X-Received: by 2002:a17:906:40f:: with SMTP id d15mr18797571eja.522.1612812925160; Mon, 08 Feb 2021 11:35:25 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id g9sm9241414ejp.55.2021.02.08.11.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 11:35:24 -0800 (PST) From: Maximilian Luz To: Hans de Goede Cc: Maximilian Luz , Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] platform/surface: aggregator_registry: Add platform profile device Date: Mon, 8 Feb 2021 20:35:06 +0100 Message-Id: <20210208193508.3038055-5-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208193508.3038055-1-luzmaximilian@gmail.com> References: <20210208193508.3038055-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Add the SSAM platform profile device to the SSAM device registry. This device is accessible under the thermal subsystem (TC=0x03) and needs to be registered for all Surface models. Signed-off-by: Maximilian Luz --- .../surface/surface_aggregator_registry.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c index 7e7b801bc606..913fa5cae705 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -65,9 +65,16 @@ static const struct software_node ssam_node_bat_sb3base = { .parent = &ssam_node_hub_base, }; +/* Platform profile / performance-mode device. */ +static const struct software_node ssam_node_tmp_pprof = { + .name = "ssam:01:03:01:00:01", + .parent = &ssam_node_root, +}; + /* Devices for Surface Book 2. */ static const struct software_node *ssam_node_group_sb2[] = { &ssam_node_root, + &ssam_node_tmp_pprof, NULL, }; @@ -78,18 +85,21 @@ static const struct software_node *ssam_node_group_sb3[] = { &ssam_node_bat_ac, &ssam_node_bat_main, &ssam_node_bat_sb3base, + &ssam_node_tmp_pprof, NULL, }; /* Devices for Surface Laptop 1. */ static const struct software_node *ssam_node_group_sl1[] = { &ssam_node_root, + &ssam_node_tmp_pprof, NULL, }; /* Devices for Surface Laptop 2. */ static const struct software_node *ssam_node_group_sl2[] = { &ssam_node_root, + &ssam_node_tmp_pprof, NULL, }; @@ -98,6 +108,7 @@ static const struct software_node *ssam_node_group_sl3[] = { &ssam_node_root, &ssam_node_bat_ac, &ssam_node_bat_main, + &ssam_node_tmp_pprof, NULL, }; @@ -106,18 +117,21 @@ static const struct software_node *ssam_node_group_slg1[] = { &ssam_node_root, &ssam_node_bat_ac, &ssam_node_bat_main, + &ssam_node_tmp_pprof, NULL, }; /* Devices for Surface Pro 5. */ static const struct software_node *ssam_node_group_sp5[] = { &ssam_node_root, + &ssam_node_tmp_pprof, NULL, }; /* Devices for Surface Pro 6. */ static const struct software_node *ssam_node_group_sp6[] = { &ssam_node_root, + &ssam_node_tmp_pprof, NULL, }; @@ -126,6 +140,7 @@ static const struct software_node *ssam_node_group_sp7[] = { &ssam_node_root, &ssam_node_bat_ac, &ssam_node_bat_main, + &ssam_node_tmp_pprof, NULL, }; From patchwork Mon Feb 8 19:35:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 12076397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FE43C433E6 for ; Mon, 8 Feb 2021 19:38:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3748864E8F for ; Mon, 8 Feb 2021 19:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235193AbhBHThU (ORCPT ); Mon, 8 Feb 2021 14:37:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233420AbhBHTgQ (ORCPT ); Mon, 8 Feb 2021 14:36:16 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5171C0617AA; Mon, 8 Feb 2021 11:35:27 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id t5so20119400eds.12; Mon, 08 Feb 2021 11:35:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zCukg/KgnVqLu7nAjOfWD7rNSU7F1rMMVwt26iP/dqU=; b=ty/IJtlIHRDpFugNZ3CHWS2dHJqVxGVbBMB87Yzw5G6yEi1B9uEgK+nZ6MTvq2zuIY GBql1+FsFG08agEOFxbseHfsRQDtXlE86VH8MifQlp2Yh6F8+mwcRvPomJu+a3mYoWDZ t+97vpXjFEon5+AB3owH7qxFUa8iq57Qj7VURYbDzQYEh2NmRo3p7BIplvoFe/ivJlEA bWyR4nLp0aDB+0sUAev6oimspVkd9fzT54XtLEZCoDWU90S7ISinpR4FHRp3Eg6V0ctm 31pzukMqqyc9AWjgWfVbbJ7VQvT/CUQHboqoCXS2wkb0upYYNfWSywCmt4EJ2wNI7Muq DGWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zCukg/KgnVqLu7nAjOfWD7rNSU7F1rMMVwt26iP/dqU=; b=BuLvZvkZjw8n9aZUicI4kPyzVdK3B+iwAdTdSrKiQppNSWDNzNF1ORLa0YKpVSTSk2 ZOu0urmnzd+C1xFn0FtIpmCLi2JPakNLUcRClLjPl/3KCK/0BHFKctAAzBCCCyD1tYs+ YvLHOHB3Obfe7Ns9FDuKU96MQMvXFf2FsenGK/thouftMy1l5NKN90xLI+WaeSce9u/x YnLUpbklIk8WC/ULlOiPbYXWI0tR3S4KVysddYi5W3Y6pnAwX0chC+5DwEm6ohWpHVDt ZW1Fx2KMlMe4NfeVLaryMn6bIUSqPVaQHbO98wroDY+PQpKDRzhZePRfQ2pnILlZBZ6x 0MhQ== X-Gm-Message-State: AOAM532+pv8uXr+g6zV5A/KsYJ/EPeeWpQJ9FoZMFS8W6YI+kKUA3lbq 7p9905WLegN1AuARoRkk5t0= X-Google-Smtp-Source: ABdhPJw58iBzM/+C1+aA1z/9IE8pHExoUQafXxNnJLt79SqlOok/4yvwO4xmgNeJrhRK7GjlJgRZEw== X-Received: by 2002:a05:6402:d05:: with SMTP id eb5mr18483174edb.143.1612812926648; Mon, 08 Feb 2021 11:35:26 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id g9sm9241414ejp.55.2021.02.08.11.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 11:35:26 -0800 (PST) From: Maximilian Luz To: Hans de Goede Cc: Maximilian Luz , Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] platform/surface: aggregator_registry: Add DTX device Date: Mon, 8 Feb 2021 20:35:07 +0100 Message-Id: <20210208193508.3038055-6-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208193508.3038055-1-luzmaximilian@gmail.com> References: <20210208193508.3038055-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Add the detachment system (DTX) SSAM device for the Surface Book 3. This device is accessible under the base (TC=0x11) subsystem. Signed-off-by: Maximilian Luz --- drivers/platform/surface/surface_aggregator_registry.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c index 913fa5cae705..4c74e80dc34a 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -71,6 +71,12 @@ static const struct software_node ssam_node_tmp_pprof = { .parent = &ssam_node_root, }; +/* DTX / detachment-system device (Surface Book 3). */ +static const struct software_node ssam_node_bas_dtx = { + .name = "ssam:01:11:01:00:00", + .parent = &ssam_node_root, +}; + /* Devices for Surface Book 2. */ static const struct software_node *ssam_node_group_sb2[] = { &ssam_node_root, @@ -86,6 +92,7 @@ static const struct software_node *ssam_node_group_sb3[] = { &ssam_node_bat_main, &ssam_node_bat_sb3base, &ssam_node_tmp_pprof, + &ssam_node_bas_dtx, NULL, }; From patchwork Mon Feb 8 19:35:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Luz X-Patchwork-Id: 12076401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84A1DC433E9 for ; Mon, 8 Feb 2021 19:38:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D61664DDD for ; Mon, 8 Feb 2021 19:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236316AbhBHTh2 (ORCPT ); Mon, 8 Feb 2021 14:37:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236331AbhBHTgk (ORCPT ); Mon, 8 Feb 2021 14:36:40 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75DEDC0617AB; Mon, 8 Feb 2021 11:35:29 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id a9so27051958ejr.2; Mon, 08 Feb 2021 11:35:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R6dNG5V5dWsYH7eHxyaPUs81huQoeK3laGD/naMd3MI=; b=CHbzY5FFybjixBJkOKuQ+JQw1DIvi3NOmwErK5cM6JIaCy4PLKcm3nYQgS863HPnwS BXKDgfB9EgxFdPupKh2WH9xdnAJcz55TE6Z9Y4xj3w8j9LD/Xe3C8Fh2pyOyqUD8Sswg YwC/4net2CQAiTtmAiBj4ZkSIGAzKI5T4g574/b14z2/hI3igFU8KI741QpcsZLnhRmK zkaqdLQcoHDPW2oqFlYH6G8Ahp6jZx4SMzfNbtntNurEot5k57o6kqtY0dtuClapiOfb Ps71T7mRDm8tibRfTVnYilp6ok+qtGzHNlxCrMD3nlVqJEYiLMLRGAHRz03N/2RkWgKq 7ZeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R6dNG5V5dWsYH7eHxyaPUs81huQoeK3laGD/naMd3MI=; b=OgC+5iyS8WW9ByIdotnQIoaZ6zAvE6t1U0C8EanAWAko5tQVg22nYwR0QeoR2xuToT s1a5tBqt1i4D0DDUB5y9DC0SreY0nRS/0RlcU4u645PO+uy1joVZzK8GxVVdFWMVqnYN UhhUYKCLABNu2z8qWx0pxU7i2WP1UPBW9NVGioBBc9i/qcNFA5NnW9zR83Wsi6YtM7P1 ijZe2Fu4T9iV1CMcOSMU9CtDcXBZSGzvLpUL2jHO93M1Jy/xGXwtNZSIDOzjcNbySGIH lYVu3qN7Svb+zl5xCvvcsp+QrFZlru5OmVyD0QSUdtoR+cwkQ48SH4D7UY7VdzbY/d3Z 1Luw== X-Gm-Message-State: AOAM531UX6KvawWIDSOaDe8da02HGnENuqdCJAzv4DwM8HO3CTn6xb5h Mk0gM2HDgcB0QTvXBuFznZKkwJsG8rNydA== X-Google-Smtp-Source: ABdhPJy4fn5Ni+hVifH+PdTcEvSUNKAcSqMpM4IphaVuf5pJqnHAIoTk6dCX9k2S8fx3ERy5jghVtw== X-Received: by 2002:a17:906:b752:: with SMTP id fx18mr19117055ejb.17.1612812928177; Mon, 08 Feb 2021 11:35:28 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id g9sm9241414ejp.55.2021.02.08.11.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 11:35:27 -0800 (PST) From: Maximilian Luz To: Hans de Goede Cc: Maximilian Luz , Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] platform/surface: aggregator_registry: Add HID subsystem devices Date: Mon, 8 Feb 2021 20:35:08 +0100 Message-Id: <20210208193508.3038055-7-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208193508.3038055-1-luzmaximilian@gmail.com> References: <20210208193508.3038055-1-luzmaximilian@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Add HID subsystem (TC=0x15) devices. These devices need to be registered for 7th-generation Surface models. On previous generations, these devices are either provided as platform devices via ACPI (Surface Laptop 1 and 2) or implemented as standard USB device. Signed-off-by: Maximilian Luz --- .../surface/surface_aggregator_registry.c | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c index 4c74e80dc34a..07cadd5a10f2 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -77,6 +77,48 @@ static const struct software_node ssam_node_bas_dtx = { .parent = &ssam_node_root, }; +/* HID keyboard. */ +static const struct software_node ssam_node_hid_main_keyboard = { + .name = "ssam:01:15:02:01:00", + .parent = &ssam_node_root, +}; + +/* HID touchpad. */ +static const struct software_node ssam_node_hid_main_touchpad = { + .name = "ssam:01:15:02:03:00", + .parent = &ssam_node_root, +}; + +/* HID device instance 5 (unknown HID device). */ +static const struct software_node ssam_node_hid_main_iid5 = { + .name = "ssam:01:15:02:05:00", + .parent = &ssam_node_root, +}; + +/* HID keyboard (base hub). */ +static const struct software_node ssam_node_hid_base_keyboard = { + .name = "ssam:01:15:02:01:00", + .parent = &ssam_node_hub_base, +}; + +/* HID touchpad (base hub). */ +static const struct software_node ssam_node_hid_base_touchpad = { + .name = "ssam:01:15:02:03:00", + .parent = &ssam_node_hub_base, +}; + +/* HID device instance 5 (unknown HID device, base hub). */ +static const struct software_node ssam_node_hid_base_iid5 = { + .name = "ssam:01:15:02:05:00", + .parent = &ssam_node_hub_base, +}; + +/* HID device instance 6 (unknown HID device, base hub). */ +static const struct software_node ssam_node_hid_base_iid6 = { + .name = "ssam:01:15:02:06:00", + .parent = &ssam_node_hub_base, +}; + /* Devices for Surface Book 2. */ static const struct software_node *ssam_node_group_sb2[] = { &ssam_node_root, @@ -93,6 +135,10 @@ static const struct software_node *ssam_node_group_sb3[] = { &ssam_node_bat_sb3base, &ssam_node_tmp_pprof, &ssam_node_bas_dtx, + &ssam_node_hid_base_keyboard, + &ssam_node_hid_base_touchpad, + &ssam_node_hid_base_iid5, + &ssam_node_hid_base_iid6, NULL, }; @@ -116,6 +162,9 @@ static const struct software_node *ssam_node_group_sl3[] = { &ssam_node_bat_ac, &ssam_node_bat_main, &ssam_node_tmp_pprof, + &ssam_node_hid_main_keyboard, + &ssam_node_hid_main_touchpad, + &ssam_node_hid_main_iid5, NULL, };