Appendix · reference

Sensortek STK3311 (ambient light / proximity)

ALS + PS sensor on DTS i2c3; IRQ sysctls work, user policy is opt-in

Identity

PartSensortek STK3311 (ambient light + proximity sensor with on-chip IR LED driver)
RoleScreen-blank / brightness input near the earpiece
Bus / addressi2c3 addr 0x48; chip ID = 0x12
GPIO / IRQINT on GPIO4_D3, edge-falling (DTS: interrupts = <RK_PD3 IRQ_TYPE_EDGE_FALLING>) — wired
DatasheetSensortek STK3311 product page
Pine64 wikiPinePhone Pro — Sensors
Schematicsheet 11 (sensor cluster, PS LED, earpiece area)

Status — ● working

Driver attaches, reports chip ID 0x12, and exposes raw ALS / PS / near sysctls under dev.stk3311.0.*. On the bench it reads proximity raw samples in the 78–80 range with near=0 when nothing’s covering the sensor. The PS near/far transition IRQ is wired via the chip’s STK_REG_INT.PS_NF mode with thresholds at 1500 (high) and 800 (low) raw counts; the taskqueue worker reads + clears FLAG, caches near plus proximity_raw / illuminance_raw. Verified live on 2026-05-03: irq_active=1, flags=193 (FLAG_PS_NF | FLAG_PS_DR), enable=1, IRQ count tracking real near/far transitions during the bench predicate sweep.

What remains for userspace integration

The driver is fully working at the kernel level; everything below is how the proximity / ambient-light signal turns into useful behaviour for the user:

Driver

The STK3311 has an on-chip near/far hysteresis comparator that can raise an interrupt only on threshold crossings, which is what the Linux IIO driver uses. The local driver now programs those threshold registers and updates cached near state from the taskqueue worker, so userland can poll the sysctl without causing continuous I2C reads.

Open work

Parity verification

mise run debug:sensors:phone captures this receipt together with the MPU-6500, magnetometer, TSADC, and eFuse sysctls.