Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp83840pxv; Thu, 8 Jul 2021 15:45:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrtoXKfCw761Ly/cSV/ceUOSSa2fWnXBcuqNDGx2JELVueMuo8U5J0ppJU4nFj7OPMIsdF X-Received: by 2002:a05:6402:1297:: with SMTP id w23mr40288894edv.311.1625784304692; Thu, 08 Jul 2021 15:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625784304; cv=none; d=google.com; s=arc-20160816; b=RdheHqFhE2lTasVrpwdaZiQs4qFH8OBl8YcsEeJuF0qQTNKWA+/r3KQgIYj8v0KkAi 0f/1bODmqwJ1MuidZ+Lfjtg9NXrhC8nYMdl56IZuQeDAlDNaSQpuYGQC7tDB6B4nezQB ASdQVZRSg+23pj9bPy8uvMwnTYzEawyY9dx5hIeWsziovdfjG6larTwtYRRQPxMVUo0y omuqCbIbMeHPZLh6IZF3uuM6sQMzyTEwQ/BAvaNaFUJwvfrQXiEUAcdsQ+X/QBc15t5X coggrmrL4LEQegoJHd+K+UXhbtVQFJBJricJu52JPLh7vvb3XiITQxnTuhdIaK0NqqzJ 83ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bUg0OzAAYGqZcpEHpJpOK9a0znuiIQ3W0JwwGxaqD0o=; b=a0WQ+zEd/0pig2h/psKq9cvONxMpNUX9nvr5mAx0FSgy6nqHSju5VpxHxs9vvDQDwR z7fqhZn0hRwJr6UgLyk3LttDFH3XpJ6YRBjF8VDUHYJkUicQzWRhXGeo1COW4MIHZTje 1JwuPfLk8RKi0ECeGBAYKj/PLDvCXmif6QJepY7lOK8AtsvkkixIK9cYnY4lkNjYkyJ4 6f0YmSugUfOQiFPO2OAOXo/59kkhHquwursnTb34aiPt0QdQHb8KQHuE7ULQt41M4DXU XdZOykwsgB1pV8cvsJ5t3DpENEdvVn/LfhyxKw+Fn2FRVampG2sy/8gO5YelQ1qAfG+o lDCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lhiYDZxD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si4476644edc.210.2021.07.08.15.44.41; Thu, 08 Jul 2021 15:45:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lhiYDZxD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230516AbhGHWp2 (ORCPT + 99 others); Thu, 8 Jul 2021 18:45:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbhGHWpU (ORCPT ); Thu, 8 Jul 2021 18:45:20 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B24D7C061574; Thu, 8 Jul 2021 15:42:37 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id n33so5098340wms.1; Thu, 08 Jul 2021 15:42:37 -0700 (PDT) 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=bUg0OzAAYGqZcpEHpJpOK9a0znuiIQ3W0JwwGxaqD0o=; b=lhiYDZxDdw4bNnOCZ3Y6pShqZ/RC9q1TPMxVm+5O/1EYjyZ78Dq+lkSt8FubGYcFEE po+UB7U4QKHpifAKTNHYHqmPh+s12fMu1G4BsCd4kwAMwkz2oz8MqmREbrvPBTkxr5YJ BssnHR6Udm0UP75Oz7SQh0BRYVXnqKl0809ZGICxzrj0kwu77ufajA0Gw0LPBXhu6unw GtDuFRyn/C106L5aiZ0hs/pNlC/Aa4ZeNw9y2DrAqP0WT/27AbFwCNKwpF7hHz5LCA8j mNkwURAsu3HaSu1tsQHhCJJtFu5IaNWrUFYuzGwd6NUmMbK0tNzwUf47Ih7jnSHggJRv aF6A== 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=bUg0OzAAYGqZcpEHpJpOK9a0znuiIQ3W0JwwGxaqD0o=; b=Vk/N3uYgK6xX6rk8JDZ1EoG+mGCZ8Rbxp+rdOiuy8Rwacd4sz1iJYlArmm0F31tWKZ lKI9tTeED/9ytnAQjahCAExfCvvymzF8ZpcuukfgwSrKWS0AnXMiWgQYQnj4lfjke9mH z/S/e5VsuX47r8Uis8PExf79fE1JAj2I6oqIsm3emPkrX1ujuYZT0UUTEMl/URYdifxr eGnvIYjKzJHCsHa26QCGDnQVvMehUCumvasSgDxpAtOVjtDir6zVXQ1CXyFoVhwBNz9x lq2DcsZuD8UhPe38fqrjclfd0Q0zBTr2sA9S1oAWc87z4dLnjOZQwgbxpILgdE1WatyC Jm5A== X-Gm-Message-State: AOAM532oIgWrBgKvy1rQVImWJxCK95d0WwOE7hKv5NXB+hdbD+b03DBU 8BrYNHFPAy6VSCsIpC4f7/EDf+RRe0A= X-Received: by 2002:a1c:f717:: with SMTP id v23mr7673943wmh.32.1625784156381; Thu, 08 Jul 2021 15:42:36 -0700 (PDT) Received: from valhalla.home ([2.29.20.111]) by smtp.gmail.com with ESMTPSA id l4sm3080655wme.26.2021.07.08.15.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 15:42:36 -0700 (PDT) From: Daniel Scally To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Cc: hdegoede@redhat.com, mgross@linux.intel.com, luzmaximilian@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [RFC PATCH 2/2] platform/surface: Add Surface Go 2 board file Date: Thu, 8 Jul 2021 23:42:26 +0100 Message-Id: <20210708224226.457224-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210708224226.457224-1-djrscally@gmail.com> References: <20210708224226.457224-1-djrscally@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DSDT tables on the Surface Go 2 contain no power control methods for the world facing camera, so the regulator, gpio and clk frameworks have no way to discover the appropriate connections and settings. To compensate for the shortcomings, define the connections and other parameters in a board file for this device. Signed-off-by: Daniel Scally --- MAINTAINERS | 6 ++ drivers/platform/surface/Kconfig | 10 ++ drivers/platform/surface/Makefile | 1 + drivers/platform/surface/surface_go_2.c | 135 ++++++++++++++++++++++++ 4 files changed, 152 insertions(+) create mode 100644 drivers/platform/surface/surface_go_2.c diff --git a/MAINTAINERS b/MAINTAINERS index 52e61092c63b..f11e68daf939 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12143,6 +12143,12 @@ F: Documentation/driver-api/surface_aggregator/clients/dtx.rst F: drivers/platform/surface/surface_dtx.c F: include/uapi/linux/surface_aggregator/dtx.h +MICROSOFT SURFACE GO 2 SUPPORT +M: Daniel Scally +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: drivers/platform/surface/surface_go_2.c + MICROSOFT SURFACE GPE LID SUPPORT DRIVER M: Maximilian Luz L: platform-driver-x86@vger.kernel.org diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig index 3105f651614f..0c55bd531592 100644 --- a/drivers/platform/surface/Kconfig +++ b/drivers/platform/surface/Kconfig @@ -124,6 +124,16 @@ config SURFACE_DTX Aggregator Bus (i.e. CONFIG_SURFACE_AGGREGATOR_BUS=n). In that case, some devices, specifically the Surface Book 3, will not be supported. +config SURFACE_GO_2 + bool "Surface Go 2 Specific Driver" + help + This board file performs some platform specific configuration to help + the regulator, gpio and clk frameworks link those resources to the + consuming devices - specifically the world facing camera. + + Select Y here if your device is a Microsoft Surface Go 2, otherwise + select N. + 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 32889482de55..9f858d2a3d77 100644 --- a/drivers/platform/surface/Makefile +++ b/drivers/platform/surface/Makefile @@ -12,6 +12,7 @@ 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_DTX) += surface_dtx.o +obj-$(CONFIG_SURFACE_GO_2) += surface_go_2.o obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o obj-$(CONFIG_SURFACE_HOTPLUG) += surface_hotplug.o obj-$(CONFIG_SURFACE_PLATFORM_PROFILE) += surface_platform_profile.o diff --git a/drivers/platform/surface/surface_go_2.c b/drivers/platform/surface/surface_go_2.c new file mode 100644 index 000000000000..4a335f0d5fd5 --- /dev/null +++ b/drivers/platform/surface/surface_go_2.c @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Author: Dan Scally */ + +#include +#include +#include +#include +#include + +static const struct software_node tps68470_node = { + "INT3472", +}; + +static const struct property_entry ana_properties[] = { + PROPERTY_ENTRY_STRING("regulator-name", "ANA"), + PROPERTY_ENTRY_U32("regulator-min-microvolt", 2815200), + PROPERTY_ENTRY_U32("regulator-max-microvolt", 2815200), + { } +}; + +static const struct property_entry vsio_properties[] = { + PROPERTY_ENTRY_STRING("regulator-name", "VSIO"), + PROPERTY_ENTRY_U32("regulator-min-microvolt", 1800600), + PROPERTY_ENTRY_U32("regulator-max-microvolt", 1800600), + { } +}; + +static const struct property_entry core_properties[] = { + PROPERTY_ENTRY_STRING("regulator-name", "CORE"), + PROPERTY_ENTRY_U32("regulator-min-microvolt", 1200000), + PROPERTY_ENTRY_U32("regulator-max-microvolt", 1200000), + { } +}; + +static const struct software_node regulator_nodes[] = { + {"ANA", &tps68470_node, ana_properties}, + {"VSIO", &tps68470_node, vsio_properties}, + {"CORE", &tps68470_node, core_properties}, +}; + +static const struct property_entry sensor_properties[] = { + PROPERTY_ENTRY_REF("avdd-supply", ®ulator_nodes[0]), + PROPERTY_ENTRY_REF("dovdd-supply", ®ulator_nodes[1]), + PROPERTY_ENTRY_REF("dvdd-supply", ®ulator_nodes[2]), + { } +}; + +static struct software_node sensor_node = { + .name = "INT347A", + .properties = sensor_properties, +}; + +static struct gpiod_lookup_table surface_go_2_gpios = { + .dev_id = "i2c-INT347A:00", + .table = { + GPIO_LOOKUP("tps68470-gpio", 9, "reset", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tps68470-gpio", 7, "powerdown", GPIO_ACTIVE_LOW) + } +}; + +static int __init surface_go_2_init(void) +{ + struct fwnode_handle *fwnode, *sensor_fwnode; + struct acpi_device *adev, *sensor; + int ret; + + adev = acpi_dev_get_first_match_dev("INT3472", "0", -1); + if (!adev) { + pr_err("%s(): Failed to find INT3472 ACPI device\n", __func__); + return -EINVAL; + } + + ret = software_node_register(&tps68470_node); + if (ret) { + dev_err(&adev->dev, "Failed to add tps68470 software node\n"); + goto err_put_adev; + } + + fwnode = software_node_fwnode(&tps68470_node); + if (!fwnode) { + dev_err(&adev->dev, "Failed to find tps68470 fwnode\n"); + ret = -ENODEV; + goto err_put_adev; + } + + adev->fwnode.secondary = fwnode; + + ret = software_node_register_nodes(regulator_nodes); + if (ret) { + dev_err(&adev->dev, + "failed to register software nodes for regulator\n"); + goto err_unregister_node; + } + + gpiod_add_lookup_table(&surface_go_2_gpios); + + sensor = acpi_dev_get_first_match_dev("INT347A", "0", -1); + if (!sensor) { + pr_err("%s(): Failed to find sensor\n", __func__); + ret = -ENODEV; + goto err_remove_gpio_lookup; + } + + ret = software_node_register(&sensor_node); + if (ret) { + dev_err(&sensor->dev, "Failed to add sensor node\n"); + goto err_put_sensor; + } + + sensor_fwnode = software_node_fwnode(&sensor_node); + if (!sensor_fwnode) { + dev_err(&sensor->dev, "Failed to find sensor fwnode\n"); + ret = -ENODEV; + goto err_unregister_sensor_node; + } + + sensor->fwnode.secondary = sensor_fwnode; + + return ret; + +err_unregister_sensor_node: + software_node_unregister(&sensor_node); +err_put_sensor: + acpi_dev_put(sensor); +err_remove_gpio_lookup: + gpiod_remove_lookup_table(&surface_go_2_gpios); +err_unregister_node: + adev->fwnode.secondary = -ENODEV; + software_node_unregister(&tps68470_node); +err_put_adev: + acpi_dev_put(adev); + + return ret; +} +device_initcall(surface_go_2_init); -- 2.25.1