162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0+
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci========
462306a36Sopenharmony_ciOverview
562306a36Sopenharmony_ci========
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciThe Surface/System Aggregator Module (SAM, SSAM) is an (arguably *the*)
862306a36Sopenharmony_ciembedded controller (EC) on Microsoft Surface devices. It has been originally
962306a36Sopenharmony_ciintroduced on 4th generation devices (Surface Pro 4, Surface Book 1), but
1062306a36Sopenharmony_ciits responsibilities and feature-set have since been expanded significantly
1162306a36Sopenharmony_ciwith the following generations.
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciFeatures and Integration
1562306a36Sopenharmony_ci========================
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ciNot much is currently known about SAM on 4th generation devices (Surface Pro
1862306a36Sopenharmony_ci4, Surface Book 1), due to the use of a different communication interface
1962306a36Sopenharmony_cibetween host and EC (as detailed below). On 5th (Surface Pro 2017, Surface
2062306a36Sopenharmony_ciBook 2, Surface Laptop 1) and later generation devices, SAM is responsible
2162306a36Sopenharmony_cifor providing battery information (both current status and static values,
2262306a36Sopenharmony_cisuch as maximum capacity etc.), as well as an assortment of temperature
2362306a36Sopenharmony_cisensors (e.g. skin temperature) and cooling/performance-mode setting to the
2462306a36Sopenharmony_cihost. On the Surface Book 2, specifically, it additionally provides an
2562306a36Sopenharmony_ciinterface for properly handling clipboard detachment (i.e. separating the
2662306a36Sopenharmony_cidisplay part from the keyboard part of the device), on the Surface Laptop 1
2762306a36Sopenharmony_ciand 2 it is required for keyboard HID input. This HID subsystem has been
2862306a36Sopenharmony_cirestructured for 7th generation devices and on those, specifically Surface
2962306a36Sopenharmony_ciLaptop 3 and Surface Book 3, is responsible for all major HID input (i.e.
3062306a36Sopenharmony_cikeyboard and touchpad).
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ciWhile features have not changed much on a coarse level since the 5th
3362306a36Sopenharmony_cigeneration, internal interfaces have undergone some rather large changes. On
3462306a36Sopenharmony_ci5th and 6th generation devices, both battery and temperature information is
3562306a36Sopenharmony_ciexposed to ACPI via a shim driver (referred to as Surface ACPI Notify, or
3662306a36Sopenharmony_ciSAN), translating ACPI generic serial bus write-/read-accesses to SAM
3762306a36Sopenharmony_cirequests. On 7th generation devices, this additional layer is gone and these
3862306a36Sopenharmony_cidevices require a driver hooking directly into the SAM interface. Equally,
3962306a36Sopenharmony_cion newer generations, less devices are declared in ACPI, making them a bit
4062306a36Sopenharmony_ciharder to discover and requiring us to hard-code a sort of device registry.
4162306a36Sopenharmony_ciDue to this, a SSAM bus and subsystem with client devices
4262306a36Sopenharmony_ci(:c:type:`struct ssam_device <ssam_device>`) has been implemented.
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciCommunication
4662306a36Sopenharmony_ci=============
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ciThe type of communication interface between host and EC depends on the
4962306a36Sopenharmony_cigeneration of the Surface device. On 4th generation devices, host and EC
5062306a36Sopenharmony_cicommunicate via HID, specifically using a HID-over-I2C device, whereas on
5162306a36Sopenharmony_ci5th and later generations, communication takes place via a USART serial
5262306a36Sopenharmony_cidevice. In accordance to the drivers found on other operating systems, we
5362306a36Sopenharmony_cirefer to the serial device and its driver as Surface Serial Hub (SSH). When
5462306a36Sopenharmony_cineeded, we differentiate between both types of SAM by referring to them as
5562306a36Sopenharmony_ciSAM-over-SSH and SAM-over-HID.
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciCurrently, this subsystem only supports SAM-over-SSH. The SSH communication
5862306a36Sopenharmony_ciinterface is described in more detail below. The HID interface has not been
5962306a36Sopenharmony_cireverse engineered yet and it is, at the moment, unclear how many (and
6062306a36Sopenharmony_ciwhich) concepts of the SSH interface detailed below can be transferred to
6162306a36Sopenharmony_ciit.
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciSurface Serial Hub
6462306a36Sopenharmony_ci------------------
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ciAs already elaborated above, the Surface Serial Hub (SSH) is the
6762306a36Sopenharmony_cicommunication interface for SAM on 5th- and all later-generation Surface
6862306a36Sopenharmony_cidevices. On the highest level, communication can be separated into two main
6962306a36Sopenharmony_citypes: Requests, messages sent from host to EC that may trigger a direct
7062306a36Sopenharmony_ciresponse from the EC (explicitly associated with the request), and events
7162306a36Sopenharmony_ci(sometimes also referred to as notifications), sent from EC to host without
7262306a36Sopenharmony_cibeing a direct response to a previous request. We may also refer to requests
7362306a36Sopenharmony_ciwithout response as commands. In general, events need to be enabled via one
7462306a36Sopenharmony_ciof multiple dedicated requests before they are sent by the EC.
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ciSee Documentation/driver-api/surface_aggregator/ssh.rst for a
7762306a36Sopenharmony_cimore technical protocol documentation and
7862306a36Sopenharmony_ciDocumentation/driver-api/surface_aggregator/internal.rst for an
7962306a36Sopenharmony_cioverview of the internal driver architecture.
80