|
|
@ -1,4 +1,4 @@
|
|
|
|
From ac17033208f929d076dd302839c9473648d2958d Mon Sep 17 00:00:00 2001
|
|
|
|
From 4d748f3baa99a037bcf82e0eeadb37f9f414725f Mon Sep 17 00:00:00 2001
|
|
|
|
From: qzed <qzed@users.noreply.github.com>
|
|
|
|
From: qzed <qzed@users.noreply.github.com>
|
|
|
|
Date: Mon, 26 Aug 2019 01:11:08 +0200
|
|
|
|
Date: Mon, 26 Aug 2019 01:11:08 +0200
|
|
|
|
Subject: [PATCH] ACPI: Fix buffer/integer type mismatch
|
|
|
|
Subject: [PATCH] ACPI: Fix buffer/integer type mismatch
|
|
|
@ -60,7 +60,7 @@ index d3d2dbfba680..0b7f617a6e9b 100644
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
2.29.2
|
|
|
|
|
|
|
|
|
|
|
|
From a757e866a23d47d85adda8e734fd9f4183d12fac Mon Sep 17 00:00:00 2001
|
|
|
|
From d92ec71cdcfd601d5ca8b2b8606d45ee47b8f2e3 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Tue, 24 Sep 2019 17:38:12 +0200
|
|
|
|
Date: Tue, 24 Sep 2019 17:38:12 +0200
|
|
|
|
Subject: [PATCH] serdev: Add ACPI devices by ResourceSource field
|
|
|
|
Subject: [PATCH] serdev: Add ACPI devices by ResourceSource field
|
|
|
@ -248,7 +248,7 @@ index a9719858c950..ce5309d00280 100644
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
2.29.2
|
|
|
|
|
|
|
|
|
|
|
|
From 09933f9205430ef74c98c492d40a3423feed3165 Mon Sep 17 00:00:00 2001
|
|
|
|
From 6d87a01f7841f9c287607adec3604cbf16292453 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Thu, 29 Oct 2020 22:04:38 +0100
|
|
|
|
Date: Thu, 29 Oct 2020 22:04:38 +0100
|
|
|
|
Subject: [PATCH] PCI: Allow D3cold for hot-plug ports on Surface Books
|
|
|
|
Subject: [PATCH] PCI: Allow D3cold for hot-plug ports on Surface Books
|
|
|
@ -333,90 +333,69 @@ index b1b2c8ddbc92..15566ec8f75d 100644
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
2.29.2
|
|
|
|
|
|
|
|
|
|
|
|
From 0e455871fcc6d9ea928be2846e137c4f5c48dd15 Mon Sep 17 00:00:00 2001
|
|
|
|
From da5f35bad772a6854c80df04f6710a2842b3d040 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Sat, 31 Oct 2020 19:48:06 +0100
|
|
|
|
Date: Mon, 9 Nov 2020 14:23:00 +0100
|
|
|
|
Subject: [PATCH] PCI: Update platform power state when updating PCI state
|
|
|
|
Subject: [PATCH] PCI: Run platform power transition on initial D0 entry
|
|
|
|
|
|
|
|
|
|
|
|
On some devices and platforms, the initial platform power state is not
|
|
|
|
On some devices and platforms, the initial platform power state is not
|
|
|
|
in sync with the power state of the PCI device.
|
|
|
|
in sync with the power state of the PCI device.
|
|
|
|
|
|
|
|
|
|
|
|
Specifically, on the Surface Book 2 and 3, some ACPI power regions that
|
|
|
|
pci_enable_device_flags() updates the state of a PCI device by reading
|
|
|
|
should be "on" for the D0 state (and others) are initialized as "off" in
|
|
|
|
from the the PCI_PM_CTRL register. This may change the stored power
|
|
|
|
ACPI, whereas the PCI device is in D0. As the state is updated in
|
|
|
|
state of the device without running the appropriate platform power
|
|
|
|
pci_enable_device_flags() without ensuring that the platform state is
|
|
|
|
transition.
|
|
|
|
also updated, the power resource will never be properly turned on.
|
|
|
|
|
|
|
|
Instead, it lives in a sort of on-but-marked-as-off zombie-state, which
|
|
|
|
|
|
|
|
confuses things down the line when attempting to transition the device
|
|
|
|
|
|
|
|
into D3cold: As the resource is already marked as off, it won't be
|
|
|
|
|
|
|
|
turned off and the device does not fully enter D3cold, causing increased
|
|
|
|
|
|
|
|
power consumption during (runtime-)suspend.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ensuring that the platform power state is in sync with the PCI power
|
|
|
|
Due to the stored power-state being changed, the later call to
|
|
|
|
state when updating the latter guarantees that all required ACPI power
|
|
|
|
pci_set_power_state(..., PCI_D0) in do_pci_enable_device() can evaluate
|
|
|
|
regions are powered on/off in accordance with the requirements
|
|
|
|
to a no-op if the stored state has been changed to D0 via that. This
|
|
|
|
(specified in the ACPI _PRn fields) for the current PCI power state.
|
|
|
|
will then prevent the appropriate platform power transition to be run,
|
|
|
|
|
|
|
|
which can on some devices and platforms lead to platform and PCI power
|
|
|
|
|
|
|
|
state being entirely different, i.e. out-of-sync. On ACPI platforms,
|
|
|
|
|
|
|
|
this can lead to power resources not being turned on, even though they
|
|
|
|
|
|
|
|
are marked as required for D0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Specifically, on the Microsoft Surface Book 2 and 3, some ACPI power
|
|
|
|
|
|
|
|
regions that should be "on" for the D0 state (and others) are
|
|
|
|
|
|
|
|
initialized as "off" in ACPI, whereas the PCI device is in D0. As the
|
|
|
|
|
|
|
|
state is updated in pci_enable_device_flags() without ensuring that the
|
|
|
|
|
|
|
|
platform state is also updated, the power resource will never be
|
|
|
|
|
|
|
|
properly turned on. Instead, it lives in a sort of on-but-marked-as-off
|
|
|
|
|
|
|
|
zombie-state, which confuses things down the line when attempting to
|
|
|
|
|
|
|
|
transition the device into D3cold: As the resource is already marked as
|
|
|
|
|
|
|
|
off, it won't be turned off and the device does not fully enter D3cold,
|
|
|
|
|
|
|
|
causing increased power consumption during (runtime-)suspend.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
By replacing pci_set_power_state() in do_pci_enable_device() with
|
|
|
|
|
|
|
|
pci_power_up(), we can force pci_platform_power_transition() to be
|
|
|
|
|
|
|
|
called, which will then check if the platform power state needs updating
|
|
|
|
|
|
|
|
and appropriate actions need to be taken.
|
|
|
|
|
|
|
|
|
|
|
|
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Patchset: surface-sam
|
|
|
|
Patchset: surface-sam
|
|
|
|
---
|
|
|
|
---
|
|
|
|
drivers/pci/pci.c | 30 ++++++++++++++++++++++++++++--
|
|
|
|
drivers/pci/pci.c | 4 +---
|
|
|
|
1 file changed, 28 insertions(+), 2 deletions(-)
|
|
|
|
1 file changed, 1 insertion(+), 3 deletions(-)
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
|
|
|
|
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
|
|
|
|
index 15566ec8f75d..6839053db5a5 100644
|
|
|
|
index 15566ec8f75d..9b0a591fc60b 100644
|
|
|
|
--- a/drivers/pci/pci.c
|
|
|
|
--- a/drivers/pci/pci.c
|
|
|
|
+++ b/drivers/pci/pci.c
|
|
|
|
+++ b/drivers/pci/pci.c
|
|
|
|
@@ -1663,7 +1663,7 @@ static void pci_enable_bridge(struct pci_dev *dev)
|
|
|
|
@@ -1596,9 +1596,7 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars)
|
|
|
|
static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
|
|
|
|
u16 cmd;
|
|
|
|
{
|
|
|
|
u8 pin;
|
|
|
|
struct pci_dev *bridge;
|
|
|
|
|
|
|
|
- int err;
|
|
|
|
|
|
|
|
+ int err = 0;
|
|
|
|
|
|
|
|
int i, bars = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
- err = pci_set_power_state(dev, PCI_D0);
|
|
|
|
@@ -1673,9 +1673,35 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
|
|
|
|
- if (err < 0 && err != -EIO)
|
|
|
|
* (e.g. if the device really is in D0 at enable time).
|
|
|
|
- return err;
|
|
|
|
*/
|
|
|
|
+ pci_power_up(dev);
|
|
|
|
if (dev->pm_cap) {
|
|
|
|
|
|
|
|
+ pci_power_t current_state;
|
|
|
|
|
|
|
|
u16 pmcsr;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
|
|
|
|
|
|
|
|
- dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
|
|
|
|
|
|
|
|
+ current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
|
|
|
+ * On some platforms, the initial power state may not be in
|
|
|
|
|
|
|
|
+ * sync with the PCI power state. Specifically, on ACPI based
|
|
|
|
|
|
|
|
+ * platforms, power-resources for the current state may not
|
|
|
|
|
|
|
|
+ * have been properly enabled (or power-resources not required
|
|
|
|
|
|
|
|
+ * for the current state disabled) yet. Thus, ensure that the
|
|
|
|
|
|
|
|
+ * platform power state reflects the PCI state.
|
|
|
|
|
|
|
|
+ *
|
|
|
|
|
|
|
|
+ * Update platform state before actually setting current state
|
|
|
|
|
|
|
|
+ * so that it can still be accessed in platform code, if
|
|
|
|
|
|
|
|
+ * necessary.
|
|
|
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
+ if (platform_pci_power_manageable(dev))
|
|
|
|
|
|
|
|
+ err = platform_pci_set_power_state(dev, current_state);
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ // always update current state
|
|
|
|
|
|
|
|
+ dev->current_state = current_state;
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+ if (err) {
|
|
|
|
|
|
|
|
+ pci_err(dev, "failed to update platform power state: %d\n",
|
|
|
|
|
|
|
|
+ err);
|
|
|
|
|
|
|
|
+ return err;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (atomic_inc_return(&dev->enable_cnt) > 1)
|
|
|
|
bridge = pci_upstream_bridge(dev);
|
|
|
|
|
|
|
|
if (bridge)
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
2.29.2
|
|
|
|
|
|
|
|
|
|
|
|
From fd5cd1327bf1d3ad4afae59883c72377e1c4afd3 Mon Sep 17 00:00:00 2001
|
|
|
|
From f8142da29f19db03995420b7f8e798c38ae03200 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Sat, 31 Oct 2020 20:46:33 +0100
|
|
|
|
Date: Sat, 31 Oct 2020 20:46:33 +0100
|
|
|
|
Subject: [PATCH] PCI: Add sysfs attribute for PCI device power state
|
|
|
|
Subject: [PATCH] PCI: Add sysfs attribute for PCI device power state
|
|
|
@ -489,7 +468,7 @@ index e401f040f157..418927872ae6 100644
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
2.29.2
|
|
|
|
|
|
|
|
|
|
|
|
From b0dc7bcd746fd167d16f35f298c099797be5f7a3 Mon Sep 17 00:00:00 2001
|
|
|
|
From 9f6c88bb06a99de23bf214f8d5b5bea49c164d09 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Mon, 17 Aug 2020 01:23:20 +0200
|
|
|
|
Date: Mon, 17 Aug 2020 01:23:20 +0200
|
|
|
|
Subject: [PATCH] misc: surface_sam: Add file2alias support for Surface SAM
|
|
|
|
Subject: [PATCH] misc: surface_sam: Add file2alias support for Surface SAM
|
|
|
@ -591,7 +570,7 @@ index c91eba751804..bc06f7631200 100644
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.29.2
|
|
|
|
2.29.2
|
|
|
|
|
|
|
|
|
|
|
|
From 21fd6098eee8750891488d2e1e99d36bea9f17ac Mon Sep 17 00:00:00 2001
|
|
|
|
From 9f94a0785a1171b88ccf73cffd472dd2fd973dae Mon Sep 17 00:00:00 2001
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Mon, 17 Aug 2020 01:44:30 +0200
|
|
|
|
Date: Mon, 17 Aug 2020 01:44:30 +0200
|
|
|
|
Subject: [PATCH] misc: Add support for Surface System Aggregator Module
|
|
|
|
Subject: [PATCH] misc: Add support for Surface System Aggregator Module
|
|
|
@ -631,12 +610,12 @@ Patchset: surface-sam
|
|
|
|
.../clients/surface_acpi_notify.c | 884 ++++++
|
|
|
|
.../clients/surface_acpi_notify.c | 884 ++++++
|
|
|
|
.../clients/surface_aggregator_cdev.c | 299 ++
|
|
|
|
.../clients/surface_aggregator_cdev.c | 299 ++
|
|
|
|
.../clients/surface_aggregator_registry.c | 609 ++++
|
|
|
|
.../clients/surface_aggregator_registry.c | 609 ++++
|
|
|
|
.../clients/surface_battery.c | 1195 ++++++++
|
|
|
|
.../clients/surface_battery.c | 1192 ++++++++
|
|
|
|
.../surface_aggregator/clients/surface_dtx.c | 1277 ++++++++
|
|
|
|
.../surface_aggregator/clients/surface_dtx.c | 1279 +++++++++
|
|
|
|
.../surface_aggregator/clients/surface_hid.c | 925 ++++++
|
|
|
|
.../surface_aggregator/clients/surface_hid.c | 922 ++++++
|
|
|
|
.../clients/surface_hotplug.c | 269 ++
|
|
|
|
.../clients/surface_hotplug.c | 269 ++
|
|
|
|
.../clients/surface_perfmode.c | 122 +
|
|
|
|
.../clients/surface_perfmode.c | 122 +
|
|
|
|
drivers/misc/surface_aggregator/controller.c | 2555 +++++++++++++++++
|
|
|
|
drivers/misc/surface_aggregator/controller.c | 2557 +++++++++++++++++
|
|
|
|
drivers/misc/surface_aggregator/controller.h | 288 ++
|
|
|
|
drivers/misc/surface_aggregator/controller.h | 288 ++
|
|
|
|
drivers/misc/surface_aggregator/core.c | 842 ++++++
|
|
|
|
drivers/misc/surface_aggregator/core.c | 842 ++++++
|
|
|
|
drivers/misc/surface_aggregator/ssh_msgb.h | 201 ++
|
|
|
|
drivers/misc/surface_aggregator/ssh_msgb.h | 201 ++
|
|
|
@ -649,14 +628,14 @@ Patchset: surface-sam
|
|
|
|
drivers/misc/surface_aggregator/trace.h | 625 ++++
|
|
|
|
drivers/misc/surface_aggregator/trace.h | 625 ++++
|
|
|
|
include/linux/mod_devicetable.h | 5 +-
|
|
|
|
include/linux/mod_devicetable.h | 5 +-
|
|
|
|
include/linux/surface_acpi_notify.h | 39 +
|
|
|
|
include/linux/surface_acpi_notify.h | 39 +
|
|
|
|
include/linux/surface_aggregator/controller.h | 815 ++++++
|
|
|
|
include/linux/surface_aggregator/controller.h | 832 ++++++
|
|
|
|
include/linux/surface_aggregator/device.h | 430 +++
|
|
|
|
include/linux/surface_aggregator/device.h | 430 +++
|
|
|
|
include/linux/surface_aggregator/serial_hub.h | 659 +++++
|
|
|
|
include/linux/surface_aggregator/serial_hub.h | 659 +++++
|
|
|
|
include/uapi/linux/surface_aggregator/cdev.h | 58 +
|
|
|
|
include/uapi/linux/surface_aggregator/cdev.h | 58 +
|
|
|
|
include/uapi/linux/surface_aggregator/dtx.h | 150 +
|
|
|
|
include/uapi/linux/surface_aggregator/dtx.h | 150 +
|
|
|
|
scripts/mod/devicetable-offsets.c | 3 +-
|
|
|
|
scripts/mod/devicetable-offsets.c | 3 +-
|
|
|
|
scripts/mod/file2alias.c | 10 +-
|
|
|
|
scripts/mod/file2alias.c | 10 +-
|
|
|
|
48 files changed, 18772 insertions(+), 7 deletions(-)
|
|
|
|
48 files changed, 18787 insertions(+), 7 deletions(-)
|
|
|
|
create mode 100644 Documentation/driver-api/surface_aggregator/client-api.rst
|
|
|
|
create mode 100644 Documentation/driver-api/surface_aggregator/client-api.rst
|
|
|
|
create mode 100644 Documentation/driver-api/surface_aggregator/client.rst
|
|
|
|
create mode 100644 Documentation/driver-api/surface_aggregator/client.rst
|
|
|
|
create mode 100644 Documentation/driver-api/surface_aggregator/clients/cdev.rst
|
|
|
|
create mode 100644 Documentation/driver-api/surface_aggregator/clients/cdev.rst
|
|
|
@ -3385,7 +3364,7 @@ index 000000000000..7320922ba755
|
|
|
|
+obj-$(CONFIG_SURFACE_PERFMODE) += surface_perfmode.o
|
|
|
|
+obj-$(CONFIG_SURFACE_PERFMODE) += surface_perfmode.o
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_acpi_notify.c b/drivers/misc/surface_aggregator/clients/surface_acpi_notify.c
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_acpi_notify.c b/drivers/misc/surface_aggregator/clients/surface_acpi_notify.c
|
|
|
|
new file mode 100644
|
|
|
|
new file mode 100644
|
|
|
|
index 000000000000..9010f3aafd28
|
|
|
|
index 000000000000..7a5b8f280036
|
|
|
|
--- /dev/null
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_acpi_notify.c
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_acpi_notify.c
|
|
|
|
@@ -0,0 +1,884 @@
|
|
|
|
@@ -0,0 +1,884 @@
|
|
|
@ -3977,8 +3956,8 @@ index 000000000000..9010f3aafd28
|
|
|
|
+ return san_rqst_fixup_suspended(d, &rqst, buffer);
|
|
|
|
+ return san_rqst_fixup_suspended(d, &rqst, buffer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_retry(ssam_request_sync_onstack, SAN_REQUEST_NUM_TRIES,
|
|
|
|
+ status = __ssam_retry(ssam_request_sync_onstack, SAN_REQUEST_NUM_TRIES,
|
|
|
|
+ d->ctrl, &rqst, &rsp, SAN_GSB_MAX_RQSX_PAYLOAD);
|
|
|
|
+ d->ctrl, &rqst, &rsp, SAN_GSB_MAX_RQSX_PAYLOAD);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (!status) {
|
|
|
|
+ if (!status) {
|
|
|
|
+ gsb_rqsx_response_success(buffer, rsp.pointer, rsp.length);
|
|
|
|
+ gsb_rqsx_response_success(buffer, rsp.pointer, rsp.length);
|
|
|
@ -4580,7 +4559,7 @@ index 000000000000..f5e81cd67357
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_aggregator_registry.c b/drivers/misc/surface_aggregator/clients/surface_aggregator_registry.c
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_aggregator_registry.c b/drivers/misc/surface_aggregator/clients/surface_aggregator_registry.c
|
|
|
|
new file mode 100644
|
|
|
|
new file mode 100644
|
|
|
|
index 000000000000..282f4409535b
|
|
|
|
index 000000000000..215308c79666
|
|
|
|
--- /dev/null
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_aggregator_registry.c
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_aggregator_registry.c
|
|
|
|
@@ -0,0 +1,609 @@
|
|
|
|
@@ -0,0 +1,609 @@
|
|
|
@ -4868,7 +4847,7 @@ index 000000000000..282f4409535b
|
|
|
|
+ u8 opmode;
|
|
|
|
+ u8 opmode;
|
|
|
|
+ int status;
|
|
|
|
+ int status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_bas_query_opmode(sdev->ctrl, &opmode);
|
|
|
|
+ status = ssam_retry(ssam_bas_query_opmode, sdev->ctrl, &opmode);
|
|
|
|
+ if (status < 0) {
|
|
|
|
+ if (status < 0) {
|
|
|
|
+ dev_err(&sdev->dev, "failed to query base state: %d\n", status);
|
|
|
|
+ dev_err(&sdev->dev, "failed to query base state: %d\n", status);
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
@ -5195,10 +5174,10 @@ index 000000000000..282f4409535b
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_battery.c b/drivers/misc/surface_aggregator/clients/surface_battery.c
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_battery.c b/drivers/misc/surface_aggregator/clients/surface_battery.c
|
|
|
|
new file mode 100644
|
|
|
|
new file mode 100644
|
|
|
|
index 000000000000..e1e0804eeb54
|
|
|
|
index 000000000000..7ed9ba3f98d7
|
|
|
|
--- /dev/null
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_battery.c
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_battery.c
|
|
|
|
@@ -0,0 +1,1195 @@
|
|
|
|
@@ -0,0 +1,1192 @@
|
|
|
|
+// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
+// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
+/*
|
|
|
|
+/*
|
|
|
|
+ * Surface battery and AC device driver.
|
|
|
|
+ * Surface battery and AC device driver.
|
|
|
@ -5220,9 +5199,6 @@ index 000000000000..e1e0804eeb54
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+#include <linux/surface_aggregator/device.h>
|
|
|
|
+#include <linux/surface_aggregator/device.h>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+#define SPWR_RETRY 3
|
|
|
|
|
|
|
|
+#define spwr_retry(fn, args...) ssam_retry(fn, SPWR_RETRY, args)
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+#define SPWR_AC_BAT_UPDATE_DELAY msecs_to_jiffies(5000)
|
|
|
|
+#define SPWR_AC_BAT_UPDATE_DELAY msecs_to_jiffies(5000)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -5451,7 +5427,7 @@ index 000000000000..e1e0804eeb54
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+static int spwr_battery_load_sta(struct spwr_battery_device *bat)
|
|
|
|
+static int spwr_battery_load_sta(struct spwr_battery_device *bat)
|
|
|
|
+{
|
|
|
|
+{
|
|
|
|
+ return spwr_retry(ssam_bat_get_sta, bat->sdev, &bat->sta);
|
|
|
|
+ return ssam_retry(ssam_bat_get_sta, bat->sdev, &bat->sta);
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+static int spwr_battery_load_bix(struct spwr_battery_device *bat)
|
|
|
|
+static int spwr_battery_load_bix(struct spwr_battery_device *bat)
|
|
|
@ -5461,7 +5437,7 @@ index 000000000000..e1e0804eeb54
|
|
|
|
+ if (!spwr_battery_present(bat))
|
|
|
|
+ if (!spwr_battery_present(bat))
|
|
|
|
+ return 0;
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = spwr_retry(ssam_bat_get_bix, bat->sdev, &bat->bix);
|
|
|
|
+ status = ssam_retry(ssam_bat_get_bix, bat->sdev, &bat->bix);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // enforce NULL terminated strings in case anything goes wrong...
|
|
|
|
+ // enforce NULL terminated strings in case anything goes wrong...
|
|
|
|
+ bat->bix.model[ARRAY_SIZE(bat->bix.model) - 1] = 0;
|
|
|
|
+ bat->bix.model[ARRAY_SIZE(bat->bix.model) - 1] = 0;
|
|
|
@ -5477,7 +5453,7 @@ index 000000000000..e1e0804eeb54
|
|
|
|
+ if (!spwr_battery_present(bat))
|
|
|
|
+ if (!spwr_battery_present(bat))
|
|
|
|
+ return 0;
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return spwr_retry(ssam_bat_get_bst, bat->sdev, &bat->bst);
|
|
|
|
+ return ssam_retry(ssam_bat_get_bst, bat->sdev, &bat->bst);
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+static int spwr_battery_set_alarm_unlocked(struct spwr_battery_device *bat,
|
|
|
|
+static int spwr_battery_set_alarm_unlocked(struct spwr_battery_device *bat,
|
|
|
@ -5486,7 +5462,7 @@ index 000000000000..e1e0804eeb54
|
|
|
|
+ __le32 value_le = cpu_to_le32(value);
|
|
|
|
+ __le32 value_le = cpu_to_le32(value);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ bat->alarm = value;
|
|
|
|
+ bat->alarm = value;
|
|
|
|
+ return spwr_retry(ssam_bat_set_btp, bat->sdev, &value_le);
|
|
|
|
+ return ssam_retry(ssam_bat_set_btp, bat->sdev, &value_le);
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+static int spwr_battery_set_alarm(struct spwr_battery_device *bat, u32 value)
|
|
|
|
+static int spwr_battery_set_alarm(struct spwr_battery_device *bat, u32 value)
|
|
|
@ -5563,7 +5539,7 @@ index 000000000000..e1e0804eeb54
|
|
|
|
+ int status;
|
|
|
|
+ int status;
|
|
|
|
+ u32 old = ac->state;
|
|
|
|
+ u32 old = ac->state;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = spwr_retry(ssam_bat_get_psrc, ac->sdev, &ac->state);
|
|
|
|
+ status = ssam_retry(ssam_bat_get_psrc, ac->sdev, &ac->state);
|
|
|
|
+ if (status < 0)
|
|
|
|
+ if (status < 0)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -6091,7 +6067,7 @@ index 000000000000..e1e0804eeb54
|
|
|
|
+ int status;
|
|
|
|
+ int status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // make sure the device is there and functioning properly
|
|
|
|
+ // make sure the device is there and functioning properly
|
|
|
|
+ status = spwr_retry(ssam_bat_get_sta, ac->sdev, &sta);
|
|
|
|
+ status = ssam_retry(ssam_bat_get_sta, ac->sdev, &sta);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -6154,7 +6130,7 @@ index 000000000000..e1e0804eeb54
|
|
|
|
+ int status;
|
|
|
|
+ int status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // make sure the device is there and functioning properly
|
|
|
|
+ // make sure the device is there and functioning properly
|
|
|
|
+ status = spwr_retry(ssam_bat_get_sta, bat->sdev, &sta);
|
|
|
|
+ status = ssam_retry(ssam_bat_get_sta, bat->sdev, &sta);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -6396,10 +6372,10 @@ index 000000000000..e1e0804eeb54
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_dtx.c b/drivers/misc/surface_aggregator/clients/surface_dtx.c
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_dtx.c b/drivers/misc/surface_aggregator/clients/surface_dtx.c
|
|
|
|
new file mode 100644
|
|
|
|
new file mode 100644
|
|
|
|
index 000000000000..588931ddcb48
|
|
|
|
index 000000000000..346b54848b8f
|
|
|
|
--- /dev/null
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_dtx.c
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_dtx.c
|
|
|
|
@@ -0,0 +1,1277 @@
|
|
|
|
@@ -0,0 +1,1279 @@
|
|
|
|
+// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
+// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
+/*
|
|
|
|
+/*
|
|
|
|
+ * Surface Book (gen. 2 and later) detachment system (DTX) driver.
|
|
|
|
+ * Surface Book (gen. 2 and later) detachment system (DTX) driver.
|
|
|
@ -6688,7 +6664,7 @@ index 000000000000..588931ddcb48
|
|
|
|
+ struct sdtx_base_info info;
|
|
|
|
+ struct sdtx_base_info info;
|
|
|
|
+ int status;
|
|
|
|
+ int status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_bas_get_base(ddev->ctrl, &raw);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_base, ddev->ctrl, &raw);
|
|
|
|
+ if (status < 0)
|
|
|
|
+ if (status < 0)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -6706,7 +6682,7 @@ index 000000000000..588931ddcb48
|
|
|
|
+ u8 mode;
|
|
|
|
+ u8 mode;
|
|
|
|
+ int status;
|
|
|
|
+ int status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_bas_get_device_mode(ddev->ctrl, &mode);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_device_mode, ddev->ctrl, &mode);
|
|
|
|
+ if (status < 0)
|
|
|
|
+ if (status < 0)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -6718,7 +6694,7 @@ index 000000000000..588931ddcb48
|
|
|
|
+ u8 latch;
|
|
|
|
+ u8 latch;
|
|
|
|
+ int status;
|
|
|
|
+ int status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_bas_get_latch_status(ddev->ctrl, &latch);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_latch_status, ddev->ctrl, &latch);
|
|
|
|
+ if (status < 0)
|
|
|
|
+ if (status < 0)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -6740,22 +6716,22 @@ index 000000000000..588931ddcb48
|
|
|
|
+ return 0;
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case SDTX_IOCTL_LATCH_LOCK:
|
|
|
|
+ case SDTX_IOCTL_LATCH_LOCK:
|
|
|
|
+ return ssam_bas_latch_lock(ddev->ctrl);
|
|
|
|
+ return ssam_retry(ssam_bas_latch_lock, ddev->ctrl);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case SDTX_IOCTL_LATCH_UNLOCK:
|
|
|
|
+ case SDTX_IOCTL_LATCH_UNLOCK:
|
|
|
|
+ return ssam_bas_latch_unlock(ddev->ctrl);
|
|
|
|
+ return ssam_retry(ssam_bas_latch_unlock, ddev->ctrl);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case SDTX_IOCTL_LATCH_REQUEST:
|
|
|
|
+ case SDTX_IOCTL_LATCH_REQUEST:
|
|
|
|
+ return ssam_bas_latch_request(ddev->ctrl);
|
|
|
|
+ return ssam_retry(ssam_bas_latch_request, ddev->ctrl);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case SDTX_IOCTL_LATCH_CONFIRM:
|
|
|
|
+ case SDTX_IOCTL_LATCH_CONFIRM:
|
|
|
|
+ return ssam_bas_latch_confirm(ddev->ctrl);
|
|
|
|
+ return ssam_retry(ssam_bas_latch_confirm, ddev->ctrl);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case SDTX_IOCTL_LATCH_HEARTBEAT:
|
|
|
|
+ case SDTX_IOCTL_LATCH_HEARTBEAT:
|
|
|
|
+ return ssam_bas_latch_heartbeat(ddev->ctrl);
|
|
|
|
+ return ssam_retry(ssam_bas_latch_heartbeat, ddev->ctrl);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case SDTX_IOCTL_LATCH_CANCEL:
|
|
|
|
+ case SDTX_IOCTL_LATCH_CANCEL:
|
|
|
|
+ return ssam_bas_latch_cancel(ddev->ctrl);
|
|
|
|
+ return ssam_retry(ssam_bas_latch_cancel, ddev->ctrl);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case SDTX_IOCTL_GET_BASE_INFO:
|
|
|
|
+ case SDTX_IOCTL_GET_BASE_INFO:
|
|
|
|
+ return sdtx_ioctl_get_base_info(ddev,
|
|
|
|
+ return sdtx_ioctl_get_base_info(ddev,
|
|
|
@ -7136,14 +7112,14 @@ index 000000000000..588931ddcb48
|
|
|
|
+ ddev = container_of(work, struct sdtx_device, mode_work.work);
|
|
|
|
+ ddev = container_of(work, struct sdtx_device, mode_work.work);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // get operation mode
|
|
|
|
+ // get operation mode
|
|
|
|
+ status = ssam_bas_get_device_mode(ddev->ctrl, &mode);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_device_mode, ddev->ctrl, &mode);
|
|
|
|
+ if (status) {
|
|
|
|
+ if (status) {
|
|
|
|
+ dev_err(ddev->dev, "failed to get device mode: %d\n", status);
|
|
|
|
+ dev_err(ddev->dev, "failed to get device mode: %d\n", status);
|
|
|
|
+ return;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // get base info
|
|
|
|
+ // get base info
|
|
|
|
+ status = ssam_bas_get_base(ddev->ctrl, &base);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_base, ddev->ctrl, &base);
|
|
|
|
+ if (status) {
|
|
|
|
+ if (status) {
|
|
|
|
+ dev_err(ddev->dev, "failed to get base info: %d\n", status);
|
|
|
|
+ dev_err(ddev->dev, "failed to get base info: %d\n", status);
|
|
|
|
+ return;
|
|
|
|
+ return;
|
|
|
@ -7287,19 +7263,19 @@ index 000000000000..588931ddcb48
|
|
|
|
+ */
|
|
|
|
+ */
|
|
|
|
+ smp_mb__after_atomic();
|
|
|
|
+ smp_mb__after_atomic();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_bas_get_base(ddev->ctrl, &base);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_base, ddev->ctrl, &base);
|
|
|
|
+ if (status) {
|
|
|
|
+ if (status) {
|
|
|
|
+ dev_err(ddev->dev, "failed to get base state: %d\n", status);
|
|
|
|
+ dev_err(ddev->dev, "failed to get base state: %d\n", status);
|
|
|
|
+ return;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_bas_get_device_mode(ddev->ctrl, &mode);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_device_mode, ddev->ctrl, &mode);
|
|
|
|
+ if (status) {
|
|
|
|
+ if (status) {
|
|
|
|
+ dev_err(ddev->dev, "failed to get device mode: %d\n", status);
|
|
|
|
+ dev_err(ddev->dev, "failed to get device mode: %d\n", status);
|
|
|
|
+ return;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_bas_get_latch_status(ddev->ctrl, &latch);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_latch_status, ddev->ctrl, &latch);
|
|
|
|
+ if (status) {
|
|
|
|
+ if (status) {
|
|
|
|
+ dev_err(ddev->dev, "failed to get latch status: %d\n", status);
|
|
|
|
+ dev_err(ddev->dev, "failed to get latch status: %d\n", status);
|
|
|
|
+ return;
|
|
|
|
+ return;
|
|
|
@ -7377,15 +7353,17 @@ index 000000000000..588931ddcb48
|
|
|
|
+ * Note that we also need to do this before registring the event
|
|
|
|
+ * Note that we also need to do this before registring the event
|
|
|
|
+ * notifier, as that may access the state values.
|
|
|
|
+ * notifier, as that may access the state values.
|
|
|
|
+ */
|
|
|
|
+ */
|
|
|
|
+ status = ssam_bas_get_base(ddev->ctrl, &ddev->state.base);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_base, ddev->ctrl, &ddev->state.base);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_bas_get_device_mode(ddev->ctrl, &ddev->state.device_mode);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_device_mode, ddev->ctrl,
|
|
|
|
|
|
|
|
+ &ddev->state.device_mode);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_bas_get_latch_status(ddev->ctrl, &ddev->state.latch_status);
|
|
|
|
+ status = ssam_retry(ssam_bas_get_latch_status, ddev->ctrl,
|
|
|
|
|
|
|
|
+ &ddev->state.latch_status);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -7679,10 +7657,10 @@ index 000000000000..588931ddcb48
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_hid.c b/drivers/misc/surface_aggregator/clients/surface_hid.c
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_hid.c b/drivers/misc/surface_aggregator/clients/surface_hid.c
|
|
|
|
new file mode 100644
|
|
|
|
new file mode 100644
|
|
|
|
index 000000000000..60691800e7e5
|
|
|
|
index 000000000000..033abc9aa95e
|
|
|
|
--- /dev/null
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_hid.c
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_hid.c
|
|
|
|
@@ -0,0 +1,925 @@
|
|
|
|
@@ -0,0 +1,922 @@
|
|
|
|
+// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
+// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
+/*
|
|
|
|
+/*
|
|
|
|
+ * Surface System Aggregator Module (SSAM) HID device driver.
|
|
|
|
+ * Surface System Aggregator Module (SSAM) HID device driver.
|
|
|
@ -7707,9 +7685,6 @@ index 000000000000..60691800e7e5
|
|
|
|
+#include <linux/surface_aggregator/controller.h>
|
|
|
|
+#include <linux/surface_aggregator/controller.h>
|
|
|
|
+#include <linux/surface_aggregator/device.h>
|
|
|
|
+#include <linux/surface_aggregator/device.h>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+#define SHID_RETRY 3
|
|
|
|
|
|
|
|
+#define shid_retry(fn, args...) ssam_retry(fn, SHID_RETRY, args)
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+enum surface_hid_descriptor_entry {
|
|
|
|
+enum surface_hid_descriptor_entry {
|
|
|
|
+ SURFACE_HID_DESC_HID = 0,
|
|
|
|
+ SURFACE_HID_DESC_HID = 0,
|
|
|
@ -7831,7 +7806,7 @@ index 000000000000..60691800e7e5
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ rsp.length = 0;
|
|
|
|
+ rsp.length = 0;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = shid_retry(ssam_request_sync_onstack, shid->ctrl,
|
|
|
|
+ status = ssam_retry(ssam_request_sync_onstack, shid->ctrl,
|
|
|
|
+ &rqst, &rsp, sizeof(*slice));
|
|
|
|
+ &rqst, &rsp, sizeof(*slice));
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
@ -7883,7 +7858,7 @@ index 000000000000..60691800e7e5
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ buf[0] = report_id;
|
|
|
|
+ buf[0] = report_id;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return shid_retry(ssam_request_sync, shid->ctrl, &rqst, NULL);
|
|
|
|
+ return ssam_retry(ssam_request_sync, shid->ctrl, &rqst, NULL);
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+static int ssam_hid_get_raw_report(struct surface_hid_device *shid,
|
|
|
|
+static int ssam_hid_get_raw_report(struct surface_hid_device *shid,
|
|
|
@ -7904,7 +7879,7 @@ index 000000000000..60691800e7e5
|
|
|
|
+ rsp.length = 0;
|
|
|
|
+ rsp.length = 0;
|
|
|
|
+ rsp.pointer = buf;
|
|
|
|
+ rsp.pointer = buf;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return shid_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
|
|
|
|
+ return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
|
|
|
|
+ sizeof(report_id));
|
|
|
|
+ sizeof(report_id));
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -7989,7 +7964,7 @@ index 000000000000..60691800e7e5
|
|
|
|
+ rsp.length = 0;
|
|
|
|
+ rsp.length = 0;
|
|
|
|
+ rsp.pointer = buf;
|
|
|
|
+ rsp.pointer = buf;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = shid_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
|
|
|
|
+ status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
|
|
|
|
+ sizeof(entry));
|
|
|
|
+ sizeof(entry));
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
@ -8016,7 +7991,7 @@ index 000000000000..60691800e7e5
|
|
|
|
+ rqst.length = sizeof(value_u8);
|
|
|
|
+ rqst.length = sizeof(value_u8);
|
|
|
|
+ rqst.payload = &value_u8;
|
|
|
|
+ rqst.payload = &value_u8;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return shid_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, NULL,
|
|
|
|
+ return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, NULL,
|
|
|
|
+ sizeof(value_u8));
|
|
|
|
+ sizeof(value_u8));
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -8040,7 +8015,7 @@ index 000000000000..60691800e7e5
|
|
|
|
+ rsp.length = 0;
|
|
|
|
+ rsp.length = 0;
|
|
|
|
+ rsp.pointer = buf;
|
|
|
|
+ rsp.pointer = buf;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = shid_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
|
|
|
|
+ status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
|
|
|
|
+ sizeof(payload));
|
|
|
|
+ sizeof(payload));
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
@ -8885,7 +8860,7 @@ index 000000000000..9afddfc6a358
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_perfmode.c b/drivers/misc/surface_aggregator/clients/surface_perfmode.c
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/clients/surface_perfmode.c b/drivers/misc/surface_aggregator/clients/surface_perfmode.c
|
|
|
|
new file mode 100644
|
|
|
|
new file mode 100644
|
|
|
|
index 000000000000..006601b3bea6
|
|
|
|
index 000000000000..e13f4995b28b
|
|
|
|
--- /dev/null
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_perfmode.c
|
|
|
|
+++ b/drivers/misc/surface_aggregator/clients/surface_perfmode.c
|
|
|
|
@@ -0,0 +1,122 @@
|
|
|
|
@@ -0,0 +1,122 @@
|
|
|
@ -8941,7 +8916,7 @@ index 000000000000..006601b3bea6
|
|
|
|
+ if (mode < __SAM_PERF_MODE__MIN || mode > __SAM_PERF_MODE__MAX)
|
|
|
|
+ if (mode < __SAM_PERF_MODE__MIN || mode > __SAM_PERF_MODE__MAX)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return __ssam_tmp_perf_mode_set(sdev, &mode_le);
|
|
|
|
+ return ssam_retry(__ssam_tmp_perf_mode_set, sdev, &mode_le);
|
|
|
|
+}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+static ssize_t perf_mode_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
+static ssize_t perf_mode_show(struct device *dev, struct device_attribute *attr,
|
|
|
@ -8951,7 +8926,7 @@ index 000000000000..006601b3bea6
|
|
|
|
+ struct ssam_perf_info info;
|
|
|
|
+ struct ssam_perf_info info;
|
|
|
|
+ int status;
|
|
|
|
+ int status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_tmp_perf_mode_get(sdev, &info);
|
|
|
|
+ status = ssam_retry(ssam_tmp_perf_mode_get, sdev, &info);
|
|
|
|
+ if (status) {
|
|
|
|
+ if (status) {
|
|
|
|
+ dev_err(dev, "failed to get current performance mode: %d\n",
|
|
|
|
+ dev_err(dev, "failed to get current performance mode: %d\n",
|
|
|
|
+ status);
|
|
|
|
+ status);
|
|
|
@ -9013,10 +8988,10 @@ index 000000000000..006601b3bea6
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/controller.c b/drivers/misc/surface_aggregator/controller.c
|
|
|
|
diff --git a/drivers/misc/surface_aggregator/controller.c b/drivers/misc/surface_aggregator/controller.c
|
|
|
|
new file mode 100644
|
|
|
|
new file mode 100644
|
|
|
|
index 000000000000..c5d19feb4d38
|
|
|
|
index 000000000000..feee7c7c5945
|
|
|
|
--- /dev/null
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/drivers/misc/surface_aggregator/controller.c
|
|
|
|
+++ b/drivers/misc/surface_aggregator/controller.c
|
|
|
|
@@ -0,0 +1,2555 @@
|
|
|
|
@@ -0,0 +1,2557 @@
|
|
|
|
+// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
+// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
+/*
|
|
|
|
+/*
|
|
|
|
+ * Main SSAM/SSH controller structure and functionality.
|
|
|
|
+ * Main SSAM/SSH controller structure and functionality.
|
|
|
@ -10836,7 +10811,8 @@ index 000000000000..c5d19feb4d38
|
|
|
|
+ result.length = 0;
|
|
|
|
+ result.length = 0;
|
|
|
|
+ result.pointer = buf;
|
|
|
|
+ result.pointer = buf;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_request_sync_onstack(ctrl, &rqst, &result, sizeof(params));
|
|
|
|
+ status = ssam_retry(ssam_request_sync_onstack, ctrl, &rqst, &result,
|
|
|
|
|
|
|
|
+ sizeof(params));
|
|
|
|
+ if (status) {
|
|
|
|
+ if (status) {
|
|
|
|
+ ssam_err(ctrl, "failed to enable event source (tc: 0x%02x, "
|
|
|
|
+ ssam_err(ctrl, "failed to enable event source (tc: 0x%02x, "
|
|
|
|
+ "iid: 0x%02x, reg: 0x%02x)\n", id.target_category,
|
|
|
|
+ "iid: 0x%02x, reg: 0x%02x)\n", id.target_category,
|
|
|
@ -10904,7 +10880,8 @@ index 000000000000..c5d19feb4d38
|
|
|
|
+ result.length = 0;
|
|
|
|
+ result.length = 0;
|
|
|
|
+ result.pointer = buf;
|
|
|
|
+ result.pointer = buf;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_request_sync_onstack(ctrl, &rqst, &result, sizeof(params));
|
|
|
|
+ status = ssam_retry(ssam_request_sync_onstack, ctrl, &rqst, &result,
|
|
|
|
|
|
|
|
+ sizeof(params));
|
|
|
|
+ if (status) {
|
|
|
|
+ if (status) {
|
|
|
|
+ ssam_err(ctrl, "failed to disable event source (tc: 0x%02x, "
|
|
|
|
+ ssam_err(ctrl, "failed to disable event source (tc: 0x%02x, "
|
|
|
|
+ "iid: 0x%02x, reg: 0x%02x)\n", id.target_category,
|
|
|
|
+ "iid: 0x%02x, reg: 0x%02x)\n", id.target_category,
|
|
|
@ -10938,7 +10915,7 @@ index 000000000000..c5d19feb4d38
|
|
|
|
+ __le32 __version;
|
|
|
|
+ __le32 __version;
|
|
|
|
+ int status;
|
|
|
|
+ int status;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_ssh_get_firmware_version(ctrl, &__version);
|
|
|
|
+ status = ssam_retry(ssam_ssh_get_firmware_version, ctrl, &__version);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -10980,7 +10957,7 @@ index 000000000000..c5d19feb4d38
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ssam_dbg(ctrl, "pm: notifying display off\n");
|
|
|
|
+ ssam_dbg(ctrl, "pm: notifying display off\n");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_ssh_notif_display_off(ctrl, &response);
|
|
|
|
+ status = ssam_retry(ssam_ssh_notif_display_off, ctrl, &response);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -11019,7 +10996,7 @@ index 000000000000..c5d19feb4d38
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ssam_dbg(ctrl, "pm: notifying display on\n");
|
|
|
|
+ ssam_dbg(ctrl, "pm: notifying display on\n");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_ssh_notif_display_on(ctrl, &response);
|
|
|
|
+ status = ssam_retry(ssam_ssh_notif_display_on, ctrl, &response);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -11061,7 +11038,7 @@ index 000000000000..c5d19feb4d38
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ssam_dbg(ctrl, "pm: notifying D0 exit\n");
|
|
|
|
+ ssam_dbg(ctrl, "pm: notifying D0 exit\n");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_ssh_notif_d0_exit(ctrl, &response);
|
|
|
|
+ status = ssam_retry(ssam_ssh_notif_d0_exit, ctrl, &response);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -11103,7 +11080,7 @@ index 000000000000..c5d19feb4d38
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ssam_dbg(ctrl, "pm: notifying D0 entry\n");
|
|
|
|
+ ssam_dbg(ctrl, "pm: notifying D0 entry\n");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ status = ssam_ssh_notif_d0_entry(ctrl, &response);
|
|
|
|
+ status = ssam_retry(ssam_ssh_notif_d0_entry, ctrl, &response);
|
|
|
|
+ if (status)
|
|
|
|
+ if (status)
|
|
|
|
+ return status;
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+
|
|
|
@ -17624,10 +17601,10 @@ index 000000000000..8e3e86c7d78c
|
|
|
|
+#endif /* _LINUX_SURFACE_ACPI_NOTIFY_H */
|
|
|
|
+#endif /* _LINUX_SURFACE_ACPI_NOTIFY_H */
|
|
|
|
diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
|
|
|
|
diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
|
|
|
|
new file mode 100644
|
|
|
|
new file mode 100644
|
|
|
|
index 000000000000..447cda590409
|
|
|
|
index 000000000000..d128c68c04e0
|
|
|
|
--- /dev/null
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/include/linux/surface_aggregator/controller.h
|
|
|
|
+++ b/include/linux/surface_aggregator/controller.h
|
|
|
|
@@ -0,0 +1,815 @@
|
|
|
|
@@ -0,0 +1,832 @@
|
|
|
|
+/* SPDX-License-Identifier: GPL-2.0+ */
|
|
|
|
+/* SPDX-License-Identifier: GPL-2.0+ */
|
|
|
|
+/*
|
|
|
|
+/*
|
|
|
|
+ * Surface System Aggregator Module (SSAM) controller interface.
|
|
|
|
+ * Surface System Aggregator Module (SSAM) controller interface.
|
|
|
@ -17876,7 +17853,7 @@ index 000000000000..447cda590409
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+/**
|
|
|
|
+ * ssam_retry - Retry request in case of I/O errors or timeouts.
|
|
|
|
+ * __ssam_retry - Retry request in case of I/O errors or timeouts.
|
|
|
|
+ * @request: The request function to execute. Must return an integer.
|
|
|
|
+ * @request: The request function to execute. Must return an integer.
|
|
|
|
+ * @n: Number of tries.
|
|
|
|
+ * @n: Number of tries.
|
|
|
|
+ * @args: Arguments for the request function.
|
|
|
|
+ * @args: Arguments for the request function.
|
|
|
@ -17888,7 +17865,7 @@ index 000000000000..447cda590409
|
|
|
|
+ *
|
|
|
|
+ *
|
|
|
|
+ * Return: Returns the return value of the last execution of @request.
|
|
|
|
+ * Return: Returns the return value of the last execution of @request.
|
|
|
|
+ */
|
|
|
|
+ */
|
|
|
|
+#define ssam_retry(request, n, args...) \
|
|
|
|
+#define __ssam_retry(request, n, args...) \
|
|
|
|
+ ({ \
|
|
|
|
+ ({ \
|
|
|
|
+ int __i, __s = 0; \
|
|
|
|
+ int __i, __s = 0; \
|
|
|
|
+ \
|
|
|
|
+ \
|
|
|
@ -17900,6 +17877,23 @@ index 000000000000..447cda590409
|
|
|
|
+ __s; \
|
|
|
|
+ __s; \
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
|
|
|
+ * ssam_retry - Retry request in case of I/O errors or timeouts up to three
|
|
|
|
|
|
|
|
+ * times in total.
|
|
|
|
|
|
|
|
+ * @request: The request function to execute. Must return an integer.
|
|
|
|
|
|
|
|
+ * @args: Arguments for the request function.
|
|
|
|
|
|
|
|
+ *
|
|
|
|
|
|
|
|
+ * Executes the given request function, i.e. calls @request. In case the
|
|
|
|
|
|
|
|
+ * request returns %-EREMOTEIO (indicates I/O error) or -%ETIMEDOUT (request
|
|
|
|
|
|
|
|
+ * or underlying packet timed out), @request will be re-executed again, up to
|
|
|
|
|
|
|
|
+ * three times in total.
|
|
|
|
|
|
|
|
+ *
|
|
|
|
|
|
|
|
+ * See __ssam_retry() for a more generic macro for this purpose.
|
|
|
|
|
|
|
|
+ *
|
|
|
|
|
|
|
|
+ * Return: Returns the return value of the last execution of @request.
|
|
|
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
+#define ssam_retry(request, args...) \
|
|
|
|
|
|
|
|
+ __ssam_retry(request, 3, args)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+/**
|
|
|
|
+ * struct ssam_request_spec - Blue-print specification of SAM request.
|
|
|
|
+ * struct ssam_request_spec - Blue-print specification of SAM request.
|
|
|
|