From: Daniel Scally <djrscally@gmail.com>
To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Hans de Goede <hdegoede@redhat.com>,
Mark Gross <mgross@linux.intel.com>,
Maximilian Luz <luzmaximilian@gmail.com>,
Kieran Bingham <kieran.bingham@ideasonboard.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: [RFC PATCH v2 3/3] platform/surface: Add Surface Go 2 board file
Date: Wed, 25 Aug 2021 00:06:20 +0100 [thread overview]
Message-ID: <20210824230620.1003828-4-djrscally@gmail.com> (raw)
In-Reply-To: <20210824230620.1003828-1-djrscally@gmail.com>
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 <djrscally@gmail.com>
---
Changes in v2:
- Re-written to use regulator_add_lookup() instead of the software
node api from v1.
- Added a dmi check to prevent the lookups from being added where the
platform running the code is not a Microsoft Surface Go 2 (Laurent)
MAINTAINERS | 6 ++
drivers/platform/surface/Kconfig | 10 +++
drivers/platform/surface/Makefile | 1 +
drivers/platform/surface/surface_go_2.c | 97 +++++++++++++++++++++++++
4 files changed, 114 insertions(+)
create mode 100644 drivers/platform/surface/surface_go_2.c
diff --git a/MAINTAINERS b/MAINTAINERS
index dc24e97d5386..891189cecd51 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12329,6 +12329,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 <djrscally@gmail.com>
+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 <luzmaximilian@gmail.com>
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..31fd6a3ca4aa
--- /dev/null
+++ b/drivers/platform/surface/surface_go_2.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Author: Dan Scally <djrscally@gmail.com> */
+
+#include <linux/dmi.h>
+#include <linux/gpio/machine.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/regulator/machine.h>
+
+static const struct dmi_system_id surface_go_2_dmi_table[] = {
+ {
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Surface Go 2"),
+ },
+ },
+ { }
+};
+
+static struct regulator_consumer_supply ana_consumer_supplies[] = {
+ REGULATOR_SUPPLY("avdd", "i2c-INT347A:00"),
+};
+
+static struct regulator_lookup ana_lookup = {
+ .device_name = "i2c-INT3472:05",
+ .regulator_name = "ANA",
+ .init_data = {
+ .constraints = {
+ .min_uV = 2815200,
+ .max_uV = 2815200,
+ .apply_uV = 1,
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
+ .num_consumer_supplies = ARRAY_SIZE(ana_consumer_supplies),
+ .consumer_supplies = ana_consumer_supplies,
+ },
+};
+
+static struct regulator_consumer_supply vsio_consumer_supplies[] = {
+ REGULATOR_SUPPLY("dovdd", "i2c-INT347A:00"),
+};
+
+static struct regulator_lookup vsio_lookup = {
+ .device_name = "i2c-INT3472:05",
+ .regulator_name = "VSIO",
+ .init_data = {
+ .constraints = {
+ .min_uV = 1800600,
+ .max_uV = 1800600,
+ .apply_uV = 1,
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
+ .num_consumer_supplies = ARRAY_SIZE(vsio_consumer_supplies),
+ .consumer_supplies = vsio_consumer_supplies,
+ },
+};
+
+static struct regulator_consumer_supply core_consumer_supplies[] = {
+ REGULATOR_SUPPLY("dvdd", "i2c-INT347A:00"),
+};
+
+static struct regulator_lookup core_lookup = {
+ .device_name = "i2c-INT3472:05",
+ .regulator_name = "CORE",
+ .init_data = {
+ .constraints = {
+ .min_uV = 1200000,
+ .max_uV = 1200000,
+ .apply_uV = 1,
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
+ .num_consumer_supplies = ARRAY_SIZE(core_consumer_supplies),
+ .consumer_supplies = core_consumer_supplies,
+ },
+};
+
+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)
+{
+ if (!dmi_check_system(surface_go_2_dmi_table))
+ return -EINVAL;
+
+ regulator_add_lookup(&ana_lookup);
+ regulator_add_lookup(&vsio_lookup);
+ regulator_add_lookup(&core_lookup);
+ gpiod_add_lookup_table(&surface_go_2_gpios);
+
+ return 0;
+}
+device_initcall(surface_go_2_init);
--
2.25.1
prev parent reply other threads:[~2021-08-24 23:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 23:06 [RFC PATCH v2 0/3] Add regulator_lookup_list and API Daniel Scally
2021-08-24 23:06 ` [RFC PATCH v2 1/3] regulator: core: Add regulator_lookup_list Daniel Scally
2021-08-25 10:33 ` Mark Brown
2021-08-25 11:10 ` Andy Shevchenko
2021-08-25 11:30 ` Mark Brown
2021-08-25 12:26 ` Andy Shevchenko
2021-08-25 13:11 ` Mark Brown
2021-08-25 13:59 ` Laurent Pinchart
2021-08-25 14:03 ` Laurent Pinchart
2021-08-25 14:33 ` Andy Shevchenko
2021-08-25 14:12 ` Daniel Scally
2021-08-25 14:22 ` Laurent Pinchart
2021-08-25 14:52 ` Mark Brown
2021-08-25 22:09 ` Daniel Scally
2021-08-26 12:40 ` Mark Brown
2021-08-25 14:41 ` Mark Brown
2021-08-25 14:48 ` Hans de Goede
2021-08-25 15:27 ` Mark Brown
2021-08-25 15:42 ` Laurent Pinchart
2021-08-25 16:13 ` Mark Brown
2021-08-25 20:25 ` Hans de Goede
2021-08-25 20:40 ` Laurent Pinchart
2021-08-25 21:24 ` Daniel Scally
2021-08-25 21:17 ` Daniel Scally
2021-08-24 23:06 ` [RFC PATCH v2 2/3] Documentation: power: Document regulator_lookup_list Daniel Scally
2021-08-24 23:06 ` Daniel Scally [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210824230620.1003828-4-djrscally@gmail.com \
--to=djrscally@gmail.com \
--cc=broonie@kernel.org \
--cc=hdegoede@redhat.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luzmaximilian@gmail.com \
--cc=mgross@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox