Skip to contentSkip to conversation

Add a driver for the ChromeOS human presence sensor (HPS)

PATCH New Sami Kyöstilä 1 participant 2 messages Feb 11, 2022

Subsystems (2)
lore
Share & tools
lore

Sami Kyöstilä

author reviewer
#0 lore raw

v4 cover Add a driver for the ChromeOS human presence sensor (HPS)

This series adds a driver for the ChromeOS human presence sensor (a.k.a. HPS) device, attached on the I2C bus. The sensor is a hardware-isolated module which reports a high-level presence signal, e.g., whether there is person in front of the computer or not.

The driver exposes the device to userspace as a character device, which can be used to control the power state of the device. The driver automatically turns power off to the sensor unless a process is using it.

More information about HPS, its firmware and communication protocol can be found at
https://chromium.googlesource.com/chromiumos/platform/hps-firmware.

Changes in v4:
- Simplified open/release pm logic.
- Renamed device to "cros-hps".
- Stylistics cleanups.

Changes in v3:
- Moved from drivers/misc to drivers/platform/chrome.

Changes in v2:
- Removed custom ioctl interface.
- Reworked to use miscdev.

Sami Kyöstilä (1):
platform/chrome: add a driver for HPS

 MAINTAINERS                            |   6 +
 drivers/platform/chrome/Kconfig        |  10 ++
 drivers/platform/chrome/Makefile       |   1 +
 drivers/platform/chrome/cros_hps_i2c.c | 151 +++++++++++++++++++++++++
 4 files changed, 168 insertions(+)
 create mode 100644 drivers/platform/chrome/cros_hps_i2c.c
Signature · 1 line
2.35.1.265.g69c8d7142f-goog
author reviewer
#1 lore raw

PATCH v4 1/1 platform/chrome: add a driver for HPS

This patch introduces a driver for the ChromeOS human presence sensor (aka. HPS). The driver supports a sensor connected to the I2C bus and identified as "GOOG0020" in the ACPI tables.

When loaded, the driver exports the sensor to userspace through a character device. This device only supports power management, i.e., communication with the sensor must be done through regular I2C transmissions from userspace.

Power management is implemented by enabling the respective power GPIO while at least one userspace process holds an open fd on the character device. By default, the device is powered down if there are no active clients.

Note that the driver makes no effort to preserve the state of the sensor between power down and power up events. Userspace is responsible for reinitializing any needed state once power has been restored.

The device firmware, I2C protocol and other documentation is available at https://chromium.googlesource.com/chromiumos/platform/hps-firmware.

---

Changes in v4:
- Simplified open/release pm logic.
- Renamed device to "cros-hps".
- Stylistics cleanups.

Changes in v3:
- Moved from drivers/misc to drivers/platform/chrome.

Changes in v2:
- Removed custom ioctl interface.
- Reworked to use miscdev.

 MAINTAINERS                            |   6 +
 drivers/platform/chrome/Kconfig        |  10 ++
 drivers/platform/chrome/Makefile       |   1 +
 drivers/platform/chrome/cros_hps_i2c.c | 151 +++++++++++++++++++++++++
 4 files changed, 168 insertions(+)
 create mode 100644 drivers/platform/chrome/cros_hps_i2c.c
MAINTAINERS +6 -0
index 69a2935daf6c..7896e61e9f7f 100644
@@ -4567,6 +4567,12 @@ S:	Maintained
 F:	drivers/platform/chrome/cros_usbpd_notify.c
 F:	include/linux/platform_data/cros_usbpd_notify.h
 
+CHROMEOS HPS DRIVER
+M:	Sami Kyöstilä <[email protected]>
+R:	Evan Benn <[email protected]>
+S:	Maintained
+F:	drivers/platform/chrome/cros_hps_i2c.c
+
 CHRONTEL CH7322 CEC DRIVER
 M:	Joe Tessler <[email protected]>
 L:	[email protected]
drivers/platform/chrome/Kconfig +10 -0
index ccc23d8686e8..7f33bcb619b0 100644
@@ -217,6 +217,16 @@ config CROS_EC_TYPEC
 	  To compile this driver as a module, choose M here: the module will be
 	  called cros_ec_typec.
 
+config CROS_HPS_I2C
+	tristate "ChromeOS HPS device"
+	depends on HID && I2C && PM
+	help
+	  Say Y here if you want to enable support for the ChromeOS
+	  human presence sensor (HPS), attached via I2C. The driver supports a
+	  sensor connected to the I2C bus and exposes it as a character device.
+	  To save power, the sensor is automatically powered down when no
+	  clients are accessing it.
+
 config CROS_USBPD_LOGGER
 	tristate "Logging driver for USB PD charger"
 	depends on CHARGER_CROS_USBPD
drivers/platform/chrome/Makefile +1 -0
index f901d2e43166..66bd745d5931 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_CROS_EC_DEBUGFS)		+= cros_ec_debugfs.o
 cros-ec-sensorhub-objs			:= cros_ec_sensorhub.o cros_ec_sensorhub_ring.o cros_ec_trace.o
 obj-$(CONFIG_CROS_EC_SENSORHUB)		+= cros-ec-sensorhub.o
 obj-$(CONFIG_CROS_EC_SYSFS)		+= cros_ec_sysfs.o
+obj-$(CONFIG_CROS_HPS_I2C)		+= cros_hps_i2c.o
 obj-$(CONFIG_CROS_USBPD_LOGGER)		+= cros_usbpd_logger.o
 obj-$(CONFIG_CROS_USBPD_NOTIFY)		+= cros_usbpd_notify.o
 
drivers/platform/chrome/cros_hps_i2c.c new file +151 -0

151 lines not on this page · raw message

Signature · 1 line
2.35.1.265.g69c8d7142f-goog