projects/linux·commit 983e4ada

Merge tag 'platform-drivers-x86-v5.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86

983e4ada · Linus Torvalds <[email protected]> · 2021-02-22 08:50:01 -08:00

Pull x86 platform driver updates from Hans de Goede:
 "Highlights:

   - Microsoft Surface devices System Aggregator Module support

   - SW_TABLET_MODE reporting improvements

   - thinkpad_acpi keyboard language setting support

   - platform / DPTF profile settings support:

      - Base / userspace API parts merged from Rafael's acpi-platform
        branch

      - thinkpad_acpi and ideapad-laptop support through pdx86

   - Remove support for some obsolete Intel MID platforms through
     merging of the shared intel-mid-removal branch

   - Big cleanup of the ideapad-laptop driver

   - Misc other fixes / new hw support / quirks"

* tag 'platform-drivers-x86-v5.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (99 commits)
  platform/x86: intel_scu_ipc: Increase virtual timeout from 3 to 5 seconds
  platform/surface: aggregator: Fix access of unaligned value
  tools/power/x86/intel-speed-select: Update version to 1.8
  tools/power/x86/intel-speed-select: Add new command to get/set TRL
  tools/power/x86/intel-speed-select: Add new command turbo-mode
  Platform: OLPC: Constify static struct regulator_ops
  platform/surface: Add Surface Hot-Plug driver
  platform/x86: intel_scu_wdt: Drop mistakenly added const
  platform/x86: Kconfig: add missing selects for ideapad-laptop
  platform/x86: acer-wmi: Don't use ACPI_EXCEPTION()
  platform/x86: thinkpad_acpi: Replace ifdef CONFIG_ACPI_PLATFORM_PROFILE with depends on
  platform/x86: thinkpad_acpi: Fix 'warning: no previous prototype for' warnings
  platform/x86: msi-wmi: Fix variable 'status' set but not used compiler warning
  platform/surface: surface3-wmi: Fix variable 'status' set but not used compiler warning
  platform/x86: Move all dell drivers to their own subdirectory
  Documentation/ABI: sysfs-platform-ideapad-laptop: conservation_mode attribute
  Documentation/ABI: sysfs-platform-ideapad-laptop: update device attribute paths
  platform/x86: ideapad-laptop: add "always on USB charging" control support
  platform/x86: ideapad-laptop: add keyboard backlight control support
  platform/x86: ideapad-laptop: send notification about touchpad state change to sysfs
  ...
Commit
983e4adae0cfa4d3dfdf73b79aabc450dda8ce0e
Parents
31caf8b2 · a7d53dbb

Merge commit. Changes below are compared with the first parent: 31caf8b2.

Changes

108 files changed · +16545 −3452

FileStatusAddDelContent
Documentation/ABI/testing/sysfs-platform-ideapad-laptopmodified+22−4View file
Documentation/admin-guide/laptops/thinkpad-acpi.rstmodified+25−0View file
Documentation/driver-api/index.rstmodified+1−0View file
Documentation/driver-api/surface_aggregator/client-api.rstadded+38−0View file
Documentation/driver-api/surface_aggregator/client.rstadded+393−0View file
Documentation/driver-api/surface_aggregator/clients/cdev.rstadded+87−0View file
Documentation/driver-api/surface_aggregator/clients/index.rstadded+21−0View file
Documentation/driver-api/surface_aggregator/clients/san.rstadded+44−0View file
Documentation/driver-api/surface_aggregator/index.rstadded+21−0View file
Documentation/driver-api/surface_aggregator/internal-api.rstadded+67−0View file
Documentation/driver-api/surface_aggregator/internal.rstadded+577−0View file
Documentation/driver-api/surface_aggregator/overview.rstadded+77−0View file
Documentation/driver-api/surface_aggregator/ssh.rstadded+344−0View file
Documentation/userspace-api/ioctl/ioctl-number.rstmodified+2−0View file
MAINTAINERSmodified+31−14View file
arch/x86/platform/intel-mid/device_libs/Makefilemodified+0−1View file
drivers/gpio/Kconfigmodified+0−14View file
drivers/gpio/Makefilemodified+0−1View file
drivers/gpio/TODOmodified+1−1View file
drivers/gpio/gpio-intel-mid.cdeleted+0−414View before deletion
drivers/gpio/gpio-msic.cdeleted+0−314View before deletion
drivers/gpu/drm/gma500/oaktrail_device.cmodified+0−3View file
drivers/gpu/drm/gma500/psb_drv.hmodified+3−0View file
drivers/platform/olpc/olpc-ec.cmodified+19−18View file
drivers/platform/surface/Kconfigmodified+57−0View file
drivers/platform/surface/Makefilemodified+4−0View file
drivers/platform/surface/aggregator/Kconfigadded+68−0View file
drivers/platform/surface/aggregator/Makefileadded+17−0View file
drivers/platform/surface/aggregator/bus.cadded+415−0View file
drivers/platform/surface/aggregator/bus.hadded+27−0View file
drivers/platform/surface/aggregator/controller.cadded+2579−0View file
drivers/platform/surface/aggregator/controller.hadded+285−0View file
drivers/platform/surface/aggregator/core.cadded+839−0View file
drivers/platform/surface/aggregator/ssh_msgb.hadded+205−0View file
drivers/platform/surface/aggregator/ssh_packet_layer.cadded+2074−0View file
drivers/platform/surface/aggregator/ssh_packet_layer.hadded+190−0View file
drivers/platform/surface/aggregator/ssh_parser.cadded+228−0View file
drivers/platform/surface/aggregator/ssh_parser.hadded+154−0View file
drivers/platform/surface/aggregator/ssh_request_layer.cadded+1263−0View file
drivers/platform/surface/aggregator/ssh_request_layer.hadded+143−0View file
drivers/platform/surface/aggregator/trace.hadded+632−0View file
drivers/platform/surface/surface3-wmi.cmodified+5−1View file
drivers/platform/surface/surface_acpi_notify.cadded+886−0View file
drivers/platform/surface/surface_aggregator_cdev.cadded+322−0View file
drivers/platform/surface/surface_hotplug.cadded+282−0View file
drivers/platform/x86/Kconfigmodified+16−191View file
drivers/platform/x86/Makefilemodified+2−17View file
drivers/platform/x86/acer-wmi.cmodified+2−2View file
drivers/platform/x86/amd-pmc.cmodified+11−3View file
drivers/platform/x86/dell/Kconfigadded+207−0View file
drivers/platform/x86/dell/Makefileadded+21−0View file
drivers/platform/x86/alienware-wmi.c → drivers/platform/x86/dell/alienware-wmi.crenamed+0−0View file
drivers/platform/x86/dcdbas.c → drivers/platform/x86/dell/dcdbas.crenamed+0−0View file
drivers/platform/x86/dcdbas.h → drivers/platform/x86/dell/dcdbas.hrenamed+0−0View file
drivers/platform/x86/dell-laptop.c → drivers/platform/x86/dell/dell-laptop.crenamed+0−0View file
drivers/platform/x86/dell-rbtn.c → drivers/platform/x86/dell/dell-rbtn.crenamed+0−0View file
drivers/platform/x86/dell-rbtn.h → drivers/platform/x86/dell/dell-rbtn.hrenamed+0−0View file
drivers/platform/x86/dell-smbios-base.c → drivers/platform/x86/dell/dell-smbios-base.crenamed+0−0View file
drivers/platform/x86/dell-smbios-smm.c → drivers/platform/x86/dell/dell-smbios-smm.crenamed+0−0View file
drivers/platform/x86/dell-smbios-wmi.c → drivers/platform/x86/dell/dell-smbios-wmi.crenamed+0−0View file
drivers/platform/x86/dell-smbios.h → drivers/platform/x86/dell/dell-smbios.hrenamed+0−0View file
drivers/platform/x86/dell-smo8800.c → drivers/platform/x86/dell/dell-smo8800.crenamed+0−0View file
drivers/platform/x86/dell-wmi-aio.c → drivers/platform/x86/dell/dell-wmi-aio.crenamed+0−0View file
drivers/platform/x86/dell-wmi-descriptor.c → drivers/platform/x86/dell/dell-wmi-descriptor.crenamed+0−0View file
drivers/platform/x86/dell-wmi-descriptor.h → drivers/platform/x86/dell/dell-wmi-descriptor.hrenamed+0−0View file
drivers/platform/x86/dell-wmi-led.c → drivers/platform/x86/dell/dell-wmi-led.crenamed+0−0View file
drivers/platform/x86/dell-wmi-sysman/Makefile → drivers/platform/x86/dell/dell-wmi-sysman/Makefilerenamed+0−0View file
drivers/platform/x86/dell-wmi-sysman/biosattr-interface.c → drivers/platform/x86/dell/dell-wmi-sysman/biosattr-interface.crenamed+0−0View file
drivers/platform/x86/dell-wmi-sysman/dell-wmi-sysman.h → drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.hrenamed+0−0View file
drivers/platform/x86/dell-wmi-sysman/enum-attributes.c → drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.crenamed+0−0View file
drivers/platform/x86/dell-wmi-sysman/int-attributes.c → drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.crenamed+0−0View file
drivers/platform/x86/dell-wmi-sysman/passobj-attributes.c → drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.crenamed+0−0View file
drivers/platform/x86/dell-wmi-sysman/passwordattr-interface.c → drivers/platform/x86/dell/dell-wmi-sysman/passwordattr-interface.crenamed+0−0View file
drivers/platform/x86/dell-wmi-sysman/string-attributes.c → drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.crenamed+0−0View file
drivers/platform/x86/dell-wmi-sysman/sysman.c → drivers/platform/x86/dell/dell-wmi-sysman/sysman.crenamed+0−0View file
drivers/platform/x86/dell-wmi.c → drivers/platform/x86/dell/dell-wmi.crenamed+0−0View file
drivers/platform/x86/dell_rbu.c → drivers/platform/x86/dell/dell_rbu.crenamed+0−0View file
drivers/platform/x86/ideapad-laptop.cmodified+1017−439View file
drivers/platform/x86/intel-uncore-frequency.cmodified+1−0View file
drivers/platform/x86/intel-vbtn.cmodified+81−57View file
drivers/platform/x86/intel_mid_powerbtn.cdeleted+0−233View before deletion
drivers/platform/x86/intel_mid_thermal.cdeleted+0−560View before deletion
drivers/platform/x86/intel_scu_ipc.cmodified+1−1View file
arch/x86/platform/intel-mid/device_libs/platform_mrfld_wdt.c → drivers/platform/x86/intel_scu_wdt.crenamed+17−24View file
drivers/platform/x86/msi-wmi.cmodified+2−0View file
drivers/platform/x86/thinkpad_acpi.cmodified+458−6View file
drivers/platform/x86/touchscreen_dmi.cmodified+27−0View file
drivers/rtc/Kconfigmodified+0−12View file
drivers/rtc/Makefilemodified+0−1View file
drivers/rtc/rtc-mrst.cdeleted+0−521View before deletion
drivers/watchdog/Kconfigmodified+0−9View file
drivers/watchdog/Makefilemodified+0−1View file
drivers/watchdog/intel-mid_wdt.cmodified+4−4View file
drivers/watchdog/intel_scu_watchdog.cdeleted+0−533View before deletion
drivers/watchdog/intel_scu_watchdog.hdeleted+0−50View before deletion
include/linux/mod_devicetable.hmodified+18−0View file
include/linux/sony-laptop.hmodified+1−1View file
include/linux/surface_acpi_notify.hadded+39−0View file
include/linux/surface_aggregator/controller.hadded+824−0View file
include/linux/surface_aggregator/device.hadded+423−0View file
include/linux/surface_aggregator/serial_hub.hadded+672−0View file
include/uapi/linux/surface_aggregator/cdev.hadded+78−0View file
scripts/mod/devicetable-offsets.cmodified+8−0View file
scripts/mod/file2alias.cmodified+23−0View file
tools/power/x86/intel-speed-select/isst-config.cmodified+113−2View file
tools/power/x86/intel-speed-select/isst-core.cmodified+11−0View file
tools/power/x86/intel-speed-select/isst-display.cmodified+18−0View file
tools/power/x86/intel-speed-select/isst.hmodified+2−0View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/ABI/testing/sysfs-platform-ideapad-laptop

View file
diff --git a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
index fd2ac02..4989ab2 100644
--- a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
+++ b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
@@ -1,11 +1,11 @@
-What: /sys/devices/platform/ideapad/camera_power
+What: /sys/bus/platform/devices/VPC2004:*/camera_power
Date: Dec 2010
KernelVersion: 2.6.37
Contact: "Ike Panhc <[email protected]>"
Description:
Control the power of camera module. 1 means on, 0 means off.
-What: /sys/devices/platform/ideapad/fan_mode
+What: /sys/bus/platform/devices/VPC2004:*/fan_mode
Date: June 2012
KernelVersion: 3.6
Contact: "Maxim Mikityanskiy <[email protected]>"
@@ -18,7 +18,7 @@ Description:
* 2 -> Dust Cleaning
* 4 -> Efficient Thermal Dissipation Mode
-What: /sys/devices/platform/ideapad/touchpad
+What: /sys/bus/platform/devices/VPC2004:*/touchpad
Date: May 2017
KernelVersion: 4.13
Contact: "Ritesh Raj Sarraf <[email protected]>"
@@ -27,7 +27,16 @@ Description:
* 1 -> Switched On
* 0 -> Switched Off
-What: /sys/bus/pci/devices/<bdf>/<device>/VPC2004:00/fn_lock
+What: /sys/bus/platform/devices/VPC2004:*/conservation_mode
+Date: Aug 2017
+KernelVersion: 4.14
+Description:
+ Controls whether the conservation mode is enabled or not.
+ This feature limits the maximum battery charge percentage to
+ around 50-60% in order to prolong the lifetime of the battery.
+
+What: /sys/bus/platform/devices/VPC2004:*/fn_lock
Date: May 2018
KernelVersion: 4.18
Contact: "Oleg Keri <[email protected]>"
@@ -41,3 +50,12 @@ Description:
# echo "0" > \
/sys/bus/pci/devices/0000:00:1f.0/PNP0C09:00/VPC2004:00/fn_lock
+
+What: /sys/bus/platform/devices/VPC2004:*/usb_charging
+Date: Feb 2021
+KernelVersion: 5.12
+Description:
+ Controls whether the "always on USB charging" feature is
+ enabled or not. This feature enables charging USB devices
+ even if the computer is not turned on.

Documentation/admin-guide/laptops/thinkpad-acpi.rst

View file
diff --git a/Documentation/admin-guide/laptops/thinkpad-acpi.rst b/Documentation/admin-guide/laptops/thinkpad-acpi.rst
index 5fe1ade..91fd684 100644
--- a/Documentation/admin-guide/laptops/thinkpad-acpi.rst
+++ b/Documentation/admin-guide/laptops/thinkpad-acpi.rst
@@ -51,6 +51,7 @@ detailed description):
- UWB enable and disable
- LCD Shadow (PrivacyGuard) enable and disable
- Lap mode sensor
+ - Setting keyboard language
A compatibility table by model and feature is maintained on the web
site, http://ibm-acpi.sf.net/. I appreciate any success or failure
@@ -1466,6 +1467,30 @@ Sysfs notes
rfkill controller switch "tpacpi_uwb_sw": refer to
Documentation/driver-api/rfkill.rst for details.
+
+Setting keyboard language
+-------------------------
+
+sysfs: keyboard_lang
+
+This feature is used to set keyboard language to ECFW using ASL interface.
+Fewer thinkpads models like T580 , T590 , T15 Gen 1 etc.. has "=", "(',
+")" numeric keys, which are not displaying correctly, when keyboard language
+is other than "english". This is because the default keyboard language in ECFW
+is set as "english". Hence using this sysfs, user can set the correct keyboard
+language to ECFW and then these key's will work correctly.
+
+Example of command to set keyboard language is mentioned below::
+
+ echo jp > /sys/devices/platform/thinkpad_acpi/keyboard_lang
+
+Text corresponding to keyboard layout to be set in sysfs are: be(Belgian),
+cz(Czech), da(Danish), de(German), en(English), es(Spain), et(Estonian),
+fr(French), fr-ch(French(Switzerland)), hu(Hungarian), it(Italy), jp (Japan),
+nl(Dutch), nn(Norway), pl(Polish), pt(portugese), sl(Slovenian), sv(Sweden),
+tr(Turkey)
+
+
Adaptive keyboard
-----------------

Documentation/driver-api/index.rst

View file
diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/index.rst
index 2456d0a..9d9af54 100644
--- a/Documentation/driver-api/index.rst
+++ b/Documentation/driver-api/index.rst
@@ -99,6 +99,7 @@ available subsections can be seen below.
rfkill
serial/index
sm501
+ surface_aggregator/index
switchtec
sync_file
vfio-mediated-device

Documentation/driver-api/surface_aggregator/client-api.rst

View file
diff --git a/Documentation/driver-api/surface_aggregator/client-api.rst b/Documentation/driver-api/surface_aggregator/client-api.rst
new file mode 100644
index 0000000..8e0b000
--- /dev/null
+++ b/Documentation/driver-api/surface_aggregator/client-api.rst
@@ -0,0 +1,38 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+===============================
+Client Driver API Documentation
+===============================
+
+.. contents::
+ :depth: 2
+
+
+Serial Hub Communication
+========================
+
+.. kernel-doc:: include/linux/surface_aggregator/serial_hub.h
+
+.. kernel-doc:: drivers/platform/surface/aggregator/ssh_packet_layer.c
+ :export:
+
+
+Controller and Core Interface
+=============================
+
+.. kernel-doc:: include/linux/surface_aggregator/controller.h
+
+.. kernel-doc:: drivers/platform/surface/aggregator/controller.c
+ :export:
+
+.. kernel-doc:: drivers/platform/surface/aggregator/core.c
+ :export:
+
+
+Client Bus and Client Device API
+================================
+
+.. kernel-doc:: include/linux/surface_aggregator/device.h
+
+.. kernel-doc:: drivers/platform/surface/aggregator/bus.c
+ :export:

Documentation/driver-api/surface_aggregator/client.rst

View file
diff --git a/Documentation/driver-api/surface_aggregator/client.rst b/Documentation/driver-api/surface_aggregator/client.rst
new file mode 100644
index 0000000..26d1308
--- /dev/null
+++ b/Documentation/driver-api/surface_aggregator/client.rst
@@ -0,0 +1,393 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+.. |ssam_controller| replace:: :c:type:`struct ssam_controller <ssam_controller>`
+.. |ssam_device| replace:: :c:type:`struct ssam_device <ssam_device>`
+.. |ssam_device_driver| replace:: :c:type:`struct ssam_device_driver <ssam_device_driver>`
+.. |ssam_client_bind| replace:: :c:func:`ssam_client_bind`
+.. |ssam_client_link| replace:: :c:func:`ssam_client_link`
+.. |ssam_get_controller| replace:: :c:func:`ssam_get_controller`
+.. |ssam_controller_get| replace:: :c:func:`ssam_controller_get`
+.. |ssam_controller_put| replace:: :c:func:`ssam_controller_put`
+.. |ssam_device_alloc| replace:: :c:func:`ssam_device_alloc`
+.. |ssam_device_add| replace:: :c:func:`ssam_device_add`
+.. |ssam_device_remove| replace:: :c:func:`ssam_device_remove`
+.. |ssam_device_driver_register| replace:: :c:func:`ssam_device_driver_register`
+.. |ssam_device_driver_unregister| replace:: :c:func:`ssam_device_driver_unregister`
+.. |module_ssam_device_driver| replace:: :c:func:`module_ssam_device_driver`
+.. |SSAM_DEVICE| replace:: :c:func:`SSAM_DEVICE`
+.. |ssam_notifier_register| replace:: :c:func:`ssam_notifier_register`
+.. |ssam_notifier_unregister| replace:: :c:func:`ssam_notifier_unregister`
+.. |ssam_request_sync| replace:: :c:func:`ssam_request_sync`
+.. |ssam_event_mask| replace:: :c:type:`enum ssam_event_mask <ssam_event_mask>`
+
+
+======================
+Writing Client Drivers
+======================
+
+For the API documentation, refer to:
+
+.. toctree::
+ :maxdepth: 2
+
+ client-api
+
+
+Overview
+========
+
+Client drivers can be set up in two main ways, depending on how the
+corresponding device is made available to the system. We specifically
+differentiate between devices that are presented to the system via one of
+the conventional ways, e.g. as platform devices via ACPI, and devices that
+are non-discoverable and instead need to be explicitly provided by some
+other mechanism, as discussed further below.
+
+
+Non-SSAM Client Drivers
+=======================
+
+All communication with the SAM EC is handled via the |ssam_controller|
+representing that EC to the kernel. Drivers targeting a non-SSAM device (and
+thus not being a |ssam_device_driver|) need to explicitly establish a
+connection/relation to that controller. This can be done via the
+|ssam_client_bind| function. Said function returns a reference to the SSAM
+controller, but, more importantly, also establishes a device link between
+client device and controller (this can also be done separate via
+|ssam_client_link|). It is important to do this, as it, first, guarantees
+that the returned controller is valid for use in the client driver for as
+long as this driver is bound to its device, i.e. that the driver gets
+unbound before the controller ever becomes invalid, and, second, as it
+ensures correct suspend/resume ordering. This setup should be done in the
+driver's probe function, and may be used to defer probing in case the SSAM
+subsystem is not ready yet, for example:
+
+.. code-block:: c
+
+ static int client_driver_probe(struct platform_device *pdev)
+ {
+ struct ssam_controller *ctrl;
+
+ ctrl = ssam_client_bind(&pdev->dev);
+ if (IS_ERR(ctrl))
+ return PTR_ERR(ctrl) == -ENODEV ? -EPROBE_DEFER : PTR_ERR(ctrl);
+
+ // ...
+
+ return 0;
+ }
+
+The controller may be separately obtained via |ssam_get_controller| and its
+lifetime be guaranteed via |ssam_controller_get| and |ssam_controller_put|.
+Note that none of these functions, however, guarantee that the controller
+will not be shut down or suspended. These functions essentially only operate
+on the reference, i.e. only guarantee a bare minimum of accessibility
+without any guarantees at all on practical operability.
+
+
+Adding SSAM Devices
+===================
+
+If a device does not already exist/is not already provided via conventional
+means, it should be provided as |ssam_device| via the SSAM client device
+hub. New devices can be added to this hub by entering their UID into the
+corresponding registry. SSAM devices can also be manually allocated via
+|ssam_device_alloc|, subsequently to which they have to be added via
+|ssam_device_add| and eventually removed via |ssam_device_remove|. By
+default, the parent of the device is set to the controller device provided
+for allocation, however this may be changed before the device is added. Note
+that, when changing the parent device, care must be taken to ensure that the
+controller lifetime and suspend/resume ordering guarantees, in the default
+setup provided through the parent-child relation, are preserved. If
+necessary, by use of |ssam_client_link| as is done for non-SSAM client
+drivers and described in more detail above.
+
+A client device must always be removed by the party which added the
+respective device before the controller shuts down. Such removal can be
+guaranteed by linking the driver providing the SSAM device to the controller
+via |ssam_client_link|, causing it to unbind before the controller driver
+unbinds. Client devices registered with the controller as parent are
+automatically removed when the controller shuts down, but this should not be
+relied upon, especially as this does not extend to client devices with a
+different parent.
+
+
+SSAM Client Drivers
+===================
+
+SSAM client device drivers are, in essence, no different than other device
+driver types. They are represented via |ssam_device_driver| and bind to a
+|ssam_device| via its UID (:c:type:`struct ssam_device.uid <ssam_device>`)
+member and the match table
+(:c:type:`struct ssam_device_driver.match_table <ssam_device_driver>`),
+which should be set when declaring the driver struct instance. Refer to the
+|SSAM_DEVICE| macro documentation for more details on how to define members
+of the driver's match table.
+
+The UID for SSAM client devices consists of a ``domain``, a ``category``,
+a ``target``, an ``instance``, and a ``function``. The ``domain`` is used
+differentiate between physical SAM devices
+(:c:type:`SSAM_DOMAIN_SERIALHUB <ssam_device_domain>`), i.e. devices that can
+be accessed via the Surface Serial Hub, and virtual ones
+(:c:type:`SSAM_DOMAIN_VIRTUAL <ssam_device_domain>`), such as client-device
+hubs, that have no real representation on the SAM EC and are solely used on
+the kernel/driver-side. For physical devices, ``category`` represents the
+target category, ``target`` the target ID, and ``instance`` the instance ID
+used to access the physical SAM device. In addition, ``function`` references
+a specific device functionality, but has no meaning to the SAM EC. The
+(default) name of a client device is generated based on its UID.
+
+A driver instance can be registered via |ssam_device_driver_register| and
+unregistered via |ssam_device_driver_unregister|. For convenience, the
+|module_ssam_device_driver| macro may be used to define module init- and
+exit-functions registering the driver.
+
+The controller associated with a SSAM client device can be found in its
+:c:type:`struct ssam_device.ctrl <ssam_device>` member. This reference is
+guaranteed to be valid for at least as long as the client driver is bound,
+but should also be valid for as long as the client device exists. Note,
+however, that access outside of the bound client driver must ensure that the
+controller device is not suspended while making any requests or
+(un-)registering event notifiers (and thus should generally be avoided). This
+is guaranteed when the controller is accessed from inside the bound client
+driver.
+
+
+Making Synchronous Requests
+===========================
+
+Synchronous requests are (currently) the main form of host-initiated
+communication with the EC. There are a couple of ways to define and execute
+such requests, however, most of them boil down to something similar as shown
+in the example below. This example defines a write-read request, meaning
+that the caller provides an argument to the SAM EC and receives a response.
+The caller needs to know the (maximum) length of the response payload and
+provide a buffer for it.
+
+Care must be taken to ensure that any command payload data passed to the SAM
+EC is provided in little-endian format and, similarly, any response payload
+data received from it is converted from little-endian to host endianness.
+
+.. code-block:: c
+
+ int perform_request(struct ssam_controller *ctrl, u32 arg, u32 *ret)
+ {
+ struct ssam_request rqst;
+ struct ssam_response resp;
+ int status;
+
+ /* Convert request argument to little-endian. */
+ __le32 arg_le = cpu_to_le32(arg);
+ __le32 ret_le = cpu_to_le32(0);
+
+ /*
+ * Initialize request specification. Replace this with your values.
+ * The rqst.payload field may be NULL if rqst.length is zero,
+ * indicating that the request does not have any argument.
+ *
+ * Note: The request parameters used here are not valid, i.e.
+ * they do not correspond to an actual SAM/EC request.
+ */
+ rqst.target_category = SSAM_SSH_TC_SAM;
+ rqst.target_id = 0x01;
+ rqst.command_id = 0x02;
+ rqst.instance_id = 0x03;
+ rqst.flags = SSAM_REQUEST_HAS_RESPONSE;
+ rqst.length = sizeof(arg_le);
+ rqst.payload = (u8 *)&arg_le;
+
+ /* Initialize request response. */
+ resp.capacity = sizeof(ret_le);
+ resp.length = 0;
+ resp.pointer = (u8 *)&ret_le;
+
+ /*
+ * Perform actual request. The response pointer may be null in case
+ * the request does not have any response. This must be consistent
+ * with the SSAM_REQUEST_HAS_RESPONSE flag set in the specification
+ * above.
+ */
+ status = ssam_request_sync(ctrl, &rqst, &resp);
+
+ /*
+ * Alternatively use
+ *
+ * ssam_request_sync_onstack(ctrl, &rqst, &resp, sizeof(arg_le));
+ *
+ * to perform the request, allocating the message buffer directly
+ * on the stack as opposed to allocation via kzalloc().
+ */
+
+ /*
+ * Convert request response back to native format. Note that in the
+ * error case, this value is not touched by the SSAM core, i.e.
+ * 'ret_le' will be zero as specified in its initialization.
+ */
+ *ret = le32_to_cpu(ret_le);
+
+ return status;
+ }
+
+Note that |ssam_request_sync| in its essence is a wrapper over lower-level
+request primitives, which may also be used to perform requests. Refer to its
+implementation and documentation for more details.
+
+An arguably more user-friendly way of defining such functions is by using
+one of the generator macros, for example via:
+
+.. code-block:: c
+
+ SSAM_DEFINE_SYNC_REQUEST_W(__ssam_tmp_perf_mode_set, __le32, {
+ .target_category = SSAM_SSH_TC_TMP,
+ .target_id = 0x01,
+ .command_id = 0x03,
+ .instance_id = 0x00,
+ });
+
+This example defines a function
+
+.. code-block:: c
+
+ int __ssam_tmp_perf_mode_set(struct ssam_controller *ctrl, const __le32 *arg);
+
+executing the specified request, with the controller passed in when calling
+said function. In this example, the argument is provided via the ``arg``
+pointer. Note that the generated function allocates the message buffer on
+the stack. Thus, if the argument provided via the request is large, these
+kinds of macros should be avoided. Also note that, in contrast to the
+previous non-macro example, this function does not do any endianness
+conversion, which has to be handled by the caller. Apart from those
+differences the function generated by the macro is similar to the one
+provided in the non-macro example above.
+
+The full list of such function-generating macros is
+
+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_N` for requests without return value and
+ without argument.
+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_R` for requests with return value but no
+ argument.
+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_W` for requests without return value but
+ with argument.
+
+Refer to their respective documentation for more details. For each one of
+these macros, a special variant is provided, which targets request types
+applicable to multiple instances of the same device type:
+
+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_MD_N`
+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_MD_R`
+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_MD_W`
+
+The difference of those macros to the previously mentioned versions is, that
+the device target and instance IDs are not fixed for the generated function,
+but instead have to be provided by the caller of said function.
+
+Additionally, variants for direct use with client devices, i.e.
+|ssam_device|, are also provided. These can, for example, be used as
+follows:
+
+.. code-block:: c
+
+ SSAM_DEFINE_SYNC_REQUEST_CL_R(ssam_bat_get_sta, __le32, {
+ .target_category = SSAM_SSH_TC_BAT,
+ .command_id = 0x01,
+ });
+
+This invocation of the macro defines a function
+
+.. code-block:: c
+
+ int ssam_bat_get_sta(struct ssam_device *sdev, __le32 *ret);
+
+executing the specified request, using the device IDs and controller given
+in the client device. The full list of such macros for client devices is:
+
+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_CL_N`
+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_CL_R`
+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_CL_W`
+
+
+Handling Events
+===============
+
+To receive events from the SAM EC, an event notifier must be registered for
+the desired event via |ssam_notifier_register|. The notifier must be
+unregistered via |ssam_notifier_unregister| once it is not required any
+more.
+
+Event notifiers are registered by providing (at minimum) a callback to call
+in case an event has been received, the registry specifying how the event
+should be enabled, an event ID specifying for which target category and,
+optionally and depending on the registry used, for which instance ID events
+should be enabled, and finally, flags describing how the EC will send these
+events. If the specific registry does not enable events by instance ID, the
+instance ID must be set to zero. Additionally, a priority for the respective
+notifier may be specified, which determines its order in relation to any
+other notifier registered for the same target category.
+
+By default, event notifiers will receive all events for the specific target
+category, regardless of the instance ID specified when registering the
+notifier. The core may be instructed to only call a notifier if the target
+ID or instance ID (or both) of the event match the ones implied by the
+notifier IDs (in case of target ID, the target ID of the registry), by
+providing an event mask (see |ssam_event_mask|).
+
+In general, the target ID of the registry is also the target ID of the
+enabled event (with the notable exception being keyboard input events on the
+Surface Laptop 1 and 2, which are enabled via a registry with target ID 1,
+but provide events with target ID 2).
+
+A full example for registering an event notifier and handling received
+events is provided below:
+
+.. code-block:: c
+
+ u32 notifier_callback(struct ssam_event_notifier *nf,
+ const struct ssam_event *event)
+ {
+ int status = ...
+
+ /* Handle the event here ... */
+
+ /* Convert return value and indicate that we handled the event. */
+ return ssam_notifier_from_errno(status) | SSAM_NOTIF_HANDLED;
+ }
+
+ int setup_notifier(struct ssam_device *sdev,
+ struct ssam_event_notifier *nf)
+ {
+ /* Set priority wrt. other handlers of same target category. */
+ nf->base.priority = 1;
+
+ /* Set event/notifier callback. */
+ nf->base.fn = notifier_callback;
+
+ /* Specify event registry, i.e. how events get enabled/disabled. */
+ nf->event.reg = SSAM_EVENT_REGISTRY_KIP;
+
+ /* Specify which event to enable/disable */
+ nf->event.id.target_category = sdev->uid.category;
+ nf->event.id.instance = sdev->uid.instance;
+
+ /*
+ * Specify for which events the notifier callback gets executed.
+ * This essentially tells the core if it can skip notifiers that
+ * don't have target or instance IDs matching those of the event.
+ */
+ nf->event.mask = SSAM_EVENT_MASK_STRICT;
+
+ /* Specify event flags. */
+ nf->event.flags = SSAM_EVENT_SEQUENCED;
+
+ return ssam_notifier_register(sdev->ctrl, nf);
+ }
+
+Multiple event notifiers can be registered for the same event. The event
+handler core takes care of enabling and disabling events when notifiers are
+registered and unregistered, by keeping track of how many notifiers for a
+specific event (combination of registry, event target category, and event
+instance ID) are currently registered. This means that a specific event will
+be enabled when the first notifier for it is being registered and disabled
+when the last notifier for it is being unregistered. Note that the event
+flags are therefore only used on the first registered notifier, however, one
+should take care that notifiers for a specific event are always registered
+with the same flag and it is considered a bug to do otherwise.

Documentation/driver-api/surface_aggregator/clients/cdev.rst

View file
diff --git a/Documentation/driver-api/surface_aggregator/clients/cdev.rst b/Documentation/driver-api/surface_aggregator/clients/cdev.rst
new file mode 100644
index 0000000..248c137
--- /dev/null
+++ b/Documentation/driver-api/surface_aggregator/clients/cdev.rst
@@ -0,0 +1,87 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+.. |u8| replace:: :c:type:`u8 <u8>`
+.. |u16| replace:: :c:type:`u16 <u16>`
+.. |ssam_cdev_request| replace:: :c:type:`struct ssam_cdev_request <ssam_cdev_request>`
+.. |ssam_cdev_request_flags| replace:: :c:type:`enum ssam_cdev_request_flags <ssam_cdev_request_flags>`
+
+==============================
+User-Space EC Interface (cdev)
+==============================
+
+The ``surface_aggregator_cdev`` module provides a misc-device for the SSAM
+controller to allow for a (more or less) direct connection from user-space to
+the SAM EC. It is intended to be used for development and debugging, and
+therefore should not be used or relied upon in any other way. Note that this
+module is not loaded automatically, but instead must be loaded manually.
+
+The provided interface is accessible through the ``/dev/surface/aggregator``
+device-file. All functionality of this interface is provided via IOCTLs.
+These IOCTLs and their respective input/output parameter structs are defined in
+``include/uapi/linux/surface_aggregator/cdev.h``.
+
+A small python library and scripts for accessing this interface can be found
+at https://github.com/linux-surface/surface-aggregator-module/tree/master/scripts/ssam.
+
+
+Controller IOCTLs
+=================
+
+The following IOCTLs are provided:
+
+.. flat-table:: Controller IOCTLs
+ :widths: 1 1 1 1 4
+ :header-rows: 1
+
+ * - Type
+ - Number
+ - Direction

This diff is incomplete. Download the complete patch.

Documentation/driver-api/surface_aggregator/clients/index.rst

View file

This diff is incomplete. Download the complete patch.

Documentation/driver-api/surface_aggregator/clients/san.rst

View file

This diff is incomplete. Download the complete patch.

Documentation/driver-api/surface_aggregator/index.rst

View file

This diff is incomplete. Download the complete patch.

Documentation/driver-api/surface_aggregator/internal-api.rst

View file

This diff is incomplete. Download the complete patch.

Documentation/driver-api/surface_aggregator/internal.rst

View file

This diff is incomplete. Download the complete patch.

Documentation/driver-api/surface_aggregator/overview.rst

View file

This diff is incomplete. Download the complete patch.

Documentation/driver-api/surface_aggregator/ssh.rst

View file

This diff is incomplete. Download the complete patch.

Documentation/userspace-api/ioctl/ioctl-number.rst

View file

This diff is incomplete. Download the complete patch.

MAINTAINERS

View file

This diff is incomplete. Download the complete patch.

arch/x86/platform/intel-mid/device_libs/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/gpio/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/gpio/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/gpio/TODO

View file

This diff is incomplete. Download the complete patch.

drivers/gpio/gpio-intel-mid.c

View before deletion

This diff is incomplete. Download the complete patch.

drivers/gpio/gpio-msic.c

View before deletion

This diff is incomplete. Download the complete patch.

drivers/gpu/drm/gma500/oaktrail_device.c

View file

This diff is incomplete. Download the complete patch.

drivers/gpu/drm/gma500/psb_drv.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/olpc/olpc-ec.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/bus.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/bus.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/controller.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/controller.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/core.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/ssh_msgb.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/ssh_packet_layer.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/ssh_packet_layer.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/ssh_parser.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/ssh_parser.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/ssh_request_layer.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/ssh_request_layer.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/aggregator/trace.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/surface3-wmi.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/surface_acpi_notify.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/surface_aggregator_cdev.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/surface/surface_hotplug.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/acer-wmi.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/amd-pmc.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/alienware-wmi.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dcdbas.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dcdbas.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-laptop.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-rbtn.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-rbtn.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-smbios-base.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-smbios-smm.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-smbios-wmi.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-smbios.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-smo8800.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-aio.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-descriptor.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-descriptor.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-led.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-sysman/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-sysman/biosattr-interface.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-sysman/passwordattr-interface.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell-wmi.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/dell/dell_rbu.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/ideapad-laptop.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/intel-uncore-frequency.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/intel-vbtn.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/intel_mid_powerbtn.c

View before deletion

This diff is incomplete. Download the complete patch.

drivers/platform/x86/intel_mid_thermal.c

View before deletion

This diff is incomplete. Download the complete patch.

drivers/platform/x86/intel_scu_ipc.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/intel_scu_wdt.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/msi-wmi.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/thinkpad_acpi.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/touchscreen_dmi.c

View file

This diff is incomplete. Download the complete patch.

drivers/rtc/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/rtc/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/rtc/rtc-mrst.c

View before deletion

This diff is incomplete. Download the complete patch.

drivers/watchdog/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/watchdog/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/watchdog/intel-mid_wdt.c

View file

This diff is incomplete. Download the complete patch.

drivers/watchdog/intel_scu_watchdog.c

View before deletion

This diff is incomplete. Download the complete patch.

drivers/watchdog/intel_scu_watchdog.h

View before deletion

This diff is incomplete. Download the complete patch.

include/linux/mod_devicetable.h

View file

This diff is incomplete. Download the complete patch.

include/linux/sony-laptop.h

View file

This diff is incomplete. Download the complete patch.

include/linux/surface_acpi_notify.h

View file

This diff is incomplete. Download the complete patch.

include/linux/surface_aggregator/controller.h

View file

This diff is incomplete. Download the complete patch.

include/linux/surface_aggregator/device.h

View file

This diff is incomplete. Download the complete patch.

include/linux/surface_aggregator/serial_hub.h

View file

This diff is incomplete. Download the complete patch.

include/uapi/linux/surface_aggregator/cdev.h

View file

This diff is incomplete. Download the complete patch.

scripts/mod/devicetable-offsets.c

View file

This diff is incomplete. Download the complete patch.

scripts/mod/file2alias.c

View file

This diff is incomplete. Download the complete patch.

tools/power/x86/intel-speed-select/isst-config.c

View file

This diff is incomplete. Download the complete patch.

tools/power/x86/intel-speed-select/isst-core.c

View file

This diff is incomplete. Download the complete patch.

tools/power/x86/intel-speed-select/isst-display.c

View file

This diff is incomplete. Download the complete patch.

tools/power/x86/intel-speed-select/isst.h

View file

This diff is incomplete. Download the complete patch.