^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Kernel driver apds990x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) Supported chips:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) Avago APDS990X
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Data sheet:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) Not freely available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) Author:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) Samu Onkalo <samu.p.onkalo@nokia.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) -----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) APDS990x is a combined ambient light and proximity sensor. ALS and proximity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) functionality are highly connected. ALS measurement path must be running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) while the proximity functionality is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ALS produces raw measurement values for two channels: Clear channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) (infrared + visible light) and IR only. However, threshold comparisons happen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) using clear channel only. Lux value and the threshold level on the HW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) might vary quite much depending the spectrum of the light source.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Driver makes necessary conversions to both directions so that user handles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) only lux values. Lux value is calculated using information from the both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) channels. HW threshold level is calculated from the given lux value to match
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) with current type of the lightning. Sometimes inaccuracy of the estimations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) lead to false interrupt, but that doesn't harm.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) ALS contains 4 different gain steps. Driver automatically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) selects suitable gain step. After each measurement, reliability of the results
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) is estimated and new measurement is triggered if necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) Platform data can provide tuned values to the conversion formulas if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) values are known. Otherwise plain sensor default values are used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) Proximity side is little bit simpler. There is no need for complex conversions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) It produces directly usable values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) Driver controls chip operational state using pm_runtime framework.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) Voltage regulators are controlled based on chip operational state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) SYSFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) -----
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) chip_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) RO - shows detected chip type and version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) power_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) RW - enable / disable chip. Uses counting logic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 1 enables the chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 0 disables the chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) lux0_input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) RO - measured lux value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) sysfs_notify called when threshold interrupt occurs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) lux0_sensor_range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) RO - lux0_input max value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) Actually never reaches since sensor tends
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) to saturate much before that. Real max value varies depending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) on the light spectrum etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) lux0_rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) RW - measurement rate in Hz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) lux0_rate_avail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) RO - supported measurement rates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) lux0_calibscale
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) RW - calibration value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) Set to neutral value by default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) Output results are multiplied with calibscale / calibscale_default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) lux0_calibscale_default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) RO - neutral calibration value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) lux0_thresh_above_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) RW - HI level threshold value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) All results above the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) trigs an interrupt. 65535 (i.e. sensor_range) disables the above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) lux0_thresh_below_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) RW - LO level threshold value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) All results below the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) trigs an interrupt. 0 disables the below interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) prox0_raw
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) RO - measured proximity value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) sysfs_notify called when threshold interrupt occurs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) prox0_sensor_range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) RO - prox0_raw max value (1023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) prox0_raw_en
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) RW - enable / disable proximity - uses counting logic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) - 1 enables the proximity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) - 0 disables the proximity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) prox0_reporting_mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) RW - trigger / periodic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) In "trigger" mode the driver tells two possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) values: 0 or prox0_sensor_range value. 0 means no proximity,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 1023 means proximity. This causes minimal number of interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) In "periodic" mode the driver reports all values above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) prox0_thresh_above. This causes more interrupts, but it can give
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) _rough_ estimate about the distance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) prox0_reporting_mode_avail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) RO - accepted values to prox0_reporting_mode (trigger, periodic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) prox0_thresh_above_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) RW - threshold level which trigs proximity events.