^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 bh1770glc
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) - ROHM BH1770GLC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) - OSRAM SFH7770
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) Data sheet:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) Not freely available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Author:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) Samu Onkalo <samu.p.onkalo@nokia.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) -----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) BH1770GLC and SFH7770 are combined ambient light and proximity sensors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) ALS and proximity parts operates on their own, but they shares common I2C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) interface and interrupt logic. In principle they can run on their own,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) but ALS side results are used to estimate reliability of the proximity sensor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) ALS produces 16 bit lux values. The chip contains interrupt logic to produce
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) low and high threshold interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Proximity part contains IR-led driver up to 3 IR leds. The chip measures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) amount of reflected IR light and produces proximity result. Resolution is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 8 bit. Driver supports only one channel. Driver uses ALS results to estimate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) reliability of the proximity results. Thus ALS is always running while
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) proximity detection is needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) Driver uses threshold interrupts to avoid need for polling the values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Proximity low interrupt doesn't exists in the chip. This is simulated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) by using a delayed work. As long as there is proximity threshold above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) interrupts the delayed work is pushed forward. So, when proximity level goes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) below the threshold value, there is no interrupt and the delayed work will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) finally run. This is handled as no proximity indication.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) Chip state is controlled via runtime pm framework when enabled in config.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) Calibscale factor is used to hide differences between the chips. By default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) value set to neutral state meaning factor of 1.00. To get proper values,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) calibrated source of light is needed as a reference. Calibscale factor is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) so that measurement produces about the expected lux value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) SYSFS
^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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) Uses counting logic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) - 1 enables the chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) - 0 disables the chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) lux0_input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) RO - measured lux value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) sysfs_notify called when threshold interrupt occurs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) lux0_sensor_range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) RO - lux0_input max value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) lux0_rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) RW - measurement rate in Hz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) lux0_rate_avail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) RO - supported measurement rates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) lux0_thresh_above_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) RW - HI level threshold value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) All results above the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) trigs an interrupt. 65535 (i.e. sensor_range) disables the above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) lux0_thresh_below_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) RW - LO level threshold value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) All results below the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) trigs an interrupt. 0 disables the below interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) lux0_calibscale
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) RW - calibration value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) Set to neutral value by default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) Output results are multiplied with calibscale / calibscale_default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) lux0_calibscale_default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) RO - neutral calibration value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) prox0_raw
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) RO - measured proximity value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) sysfs_notify called when threshold interrupt occurs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) prox0_sensor_range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) RO - prox0_raw max value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) prox0_raw_en
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) RW - enable / disable proximity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) Uses counting logic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) - 1 enables the proximity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) - 0 disables the proximity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) prox0_thresh_above_count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) RW - number of proximity interrupts needed before triggering the event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) prox0_rate_above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) RW - Measurement rate (in Hz) when the level is above threshold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) i.e. when proximity on has been reported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) prox0_rate_below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) RW - Measurement rate (in Hz) when the level is below threshold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) i.e. when proximity off has been reported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) prox0_rate_avail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) RO - Supported proximity measurement rates in Hz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) prox0_thresh_above0_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) RW - threshold level which trigs proximity events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) Filtered by persistence filter (prox0_thresh_above_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) prox0_thresh_above1_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) RW - threshold level which trigs event immediately