xref: /linux/Documentation/misc-devices/bh1770glc.rst (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1*0e7ade47SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0
2*0e7ade47SMauro Carvalho Chehab
3*0e7ade47SMauro Carvalho Chehab=======================
43f0f4a3fSSamu OnkaloKernel driver bh1770glc
53f0f4a3fSSamu Onkalo=======================
63f0f4a3fSSamu Onkalo
73f0f4a3fSSamu OnkaloSupported chips:
8*0e7ade47SMauro Carvalho Chehab
9*0e7ade47SMauro Carvalho Chehab- ROHM BH1770GLC
10*0e7ade47SMauro Carvalho Chehab- OSRAM SFH7770
113f0f4a3fSSamu Onkalo
123f0f4a3fSSamu OnkaloData sheet:
133f0f4a3fSSamu OnkaloNot freely available
143f0f4a3fSSamu Onkalo
153f0f4a3fSSamu OnkaloAuthor:
163f0f4a3fSSamu OnkaloSamu Onkalo <samu.p.onkalo@nokia.com>
173f0f4a3fSSamu Onkalo
183f0f4a3fSSamu OnkaloDescription
193f0f4a3fSSamu Onkalo-----------
203f0f4a3fSSamu OnkaloBH1770GLC and SFH7770 are combined ambient light and proximity sensors.
213f0f4a3fSSamu OnkaloALS and proximity parts operates on their own, but they shares common I2C
223f0f4a3fSSamu Onkalointerface and interrupt logic. In principle they can run on their own,
233f0f4a3fSSamu Onkalobut ALS side results are used to estimate reliability of the proximity sensor.
243f0f4a3fSSamu Onkalo
253f0f4a3fSSamu OnkaloALS produces 16 bit lux values. The chip contains interrupt logic to produce
263f0f4a3fSSamu Onkalolow and high threshold interrupts.
273f0f4a3fSSamu Onkalo
283f0f4a3fSSamu OnkaloProximity part contains IR-led driver up to 3 IR leds. The chip measures
293f0f4a3fSSamu Onkaloamount of reflected IR light and produces proximity result. Resolution is
303f0f4a3fSSamu Onkalo8 bit. Driver supports only one channel. Driver uses ALS results to estimate
313f0f4a3fSSamu Onkaloreliability of the proximity results. Thus ALS is always running while
323f0f4a3fSSamu Onkaloproximity detection is needed.
333f0f4a3fSSamu Onkalo
343f0f4a3fSSamu OnkaloDriver uses threshold interrupts to avoid need for polling the values.
353f0f4a3fSSamu OnkaloProximity low interrupt doesn't exists in the chip. This is simulated
363f0f4a3fSSamu Onkaloby using a delayed work. As long as there is proximity threshold above
373f0f4a3fSSamu Onkalointerrupts the delayed work is pushed forward. So, when proximity level goes
383f0f4a3fSSamu Onkalobelow the threshold value, there is no interrupt and the delayed work will
393f0f4a3fSSamu Onkalofinally run. This is handled as no proximity indication.
403f0f4a3fSSamu Onkalo
413f0f4a3fSSamu OnkaloChip state is controlled via runtime pm framework when enabled in config.
423f0f4a3fSSamu Onkalo
433f0f4a3fSSamu OnkaloCalibscale factor is used to hide differences between the chips. By default
443f0f4a3fSSamu Onkalovalue set to neutral state meaning factor of 1.00. To get proper values,
453f0f4a3fSSamu Onkalocalibrated source of light is needed as a reference. Calibscale factor is set
463f0f4a3fSSamu Onkaloso that measurement produces about the expected lux value.
473f0f4a3fSSamu Onkalo
483f0f4a3fSSamu OnkaloSYSFS
493f0f4a3fSSamu Onkalo-----
503f0f4a3fSSamu Onkalo
513f0f4a3fSSamu Onkalochip_id
523f0f4a3fSSamu Onkalo	RO - shows detected chip type and version
533f0f4a3fSSamu Onkalo
543f0f4a3fSSamu Onkalopower_state
55*0e7ade47SMauro Carvalho Chehab	RW - enable / disable chip
56*0e7ade47SMauro Carvalho Chehab
57*0e7ade47SMauro Carvalho Chehab	Uses counting logic
58*0e7ade47SMauro Carvalho Chehab
59*0e7ade47SMauro Carvalho Chehab	     - 1 enables the chip
60*0e7ade47SMauro Carvalho Chehab	     - 0 disables the chip
613f0f4a3fSSamu Onkalo
623f0f4a3fSSamu Onkalolux0_input
633f0f4a3fSSamu Onkalo	RO - measured lux value
64*0e7ade47SMauro Carvalho Chehab
653f0f4a3fSSamu Onkalo	     sysfs_notify called when threshold interrupt occurs
663f0f4a3fSSamu Onkalo
673f0f4a3fSSamu Onkalolux0_sensor_range
683f0f4a3fSSamu Onkalo	RO - lux0_input max value
693f0f4a3fSSamu Onkalo
703f0f4a3fSSamu Onkalolux0_rate
713f0f4a3fSSamu Onkalo	RW - measurement rate in Hz
723f0f4a3fSSamu Onkalo
733f0f4a3fSSamu Onkalolux0_rate_avail
743f0f4a3fSSamu Onkalo	RO - supported measurement rates
753f0f4a3fSSamu Onkalo
763f0f4a3fSSamu Onkalolux0_thresh_above_value
77*0e7ade47SMauro Carvalho Chehab	RW - HI level threshold value
78*0e7ade47SMauro Carvalho Chehab
79*0e7ade47SMauro Carvalho Chehab	     All results above the value
803f0f4a3fSSamu Onkalo	     trigs an interrupt. 65535 (i.e. sensor_range) disables the above
813f0f4a3fSSamu Onkalo	     interrupt.
823f0f4a3fSSamu Onkalo
833f0f4a3fSSamu Onkalolux0_thresh_below_value
84*0e7ade47SMauro Carvalho Chehab	RW - LO level threshold value
85*0e7ade47SMauro Carvalho Chehab
86*0e7ade47SMauro Carvalho Chehab	     All results below the value
873f0f4a3fSSamu Onkalo	     trigs an interrupt. 0 disables the below interrupt.
883f0f4a3fSSamu Onkalo
893f0f4a3fSSamu Onkalolux0_calibscale
90*0e7ade47SMauro Carvalho Chehab	RW - calibration value
91*0e7ade47SMauro Carvalho Chehab
92*0e7ade47SMauro Carvalho Chehab	     Set to neutral value by default.
933f0f4a3fSSamu Onkalo	     Output results are multiplied with calibscale / calibscale_default
943f0f4a3fSSamu Onkalo	     value.
953f0f4a3fSSamu Onkalo
963f0f4a3fSSamu Onkalolux0_calibscale_default
973f0f4a3fSSamu Onkalo	RO - neutral calibration value
983f0f4a3fSSamu Onkalo
993f0f4a3fSSamu Onkaloprox0_raw
1003f0f4a3fSSamu Onkalo	RO - measured proximity value
101*0e7ade47SMauro Carvalho Chehab
1023f0f4a3fSSamu Onkalo	     sysfs_notify called when threshold interrupt occurs
1033f0f4a3fSSamu Onkalo
1043f0f4a3fSSamu Onkaloprox0_sensor_range
1053f0f4a3fSSamu Onkalo	RO - prox0_raw max value
1063f0f4a3fSSamu Onkalo
1073f0f4a3fSSamu Onkaloprox0_raw_en
108*0e7ade47SMauro Carvalho Chehab	RW - enable / disable proximity
109*0e7ade47SMauro Carvalho Chehab
110*0e7ade47SMauro Carvalho Chehab	     Uses counting logic
111*0e7ade47SMauro Carvalho Chehab
112*0e7ade47SMauro Carvalho Chehab	     - 1 enables the proximity
113*0e7ade47SMauro Carvalho Chehab	     - 0 disables the proximity
1143f0f4a3fSSamu Onkalo
1153f0f4a3fSSamu Onkaloprox0_thresh_above_count
1163f0f4a3fSSamu Onkalo	RW - number of proximity interrupts needed before triggering the event
1173f0f4a3fSSamu Onkalo
1183f0f4a3fSSamu Onkaloprox0_rate_above
1193f0f4a3fSSamu Onkalo	RW - Measurement rate (in Hz) when the level is above threshold
1203f0f4a3fSSamu Onkalo	i.e. when proximity on has been reported.
1213f0f4a3fSSamu Onkalo
1223f0f4a3fSSamu Onkaloprox0_rate_below
1233f0f4a3fSSamu Onkalo	RW - Measurement rate (in Hz) when the level is below threshold
1243f0f4a3fSSamu Onkalo	i.e. when proximity off has been reported.
1253f0f4a3fSSamu Onkalo
1263f0f4a3fSSamu Onkaloprox0_rate_avail
1273f0f4a3fSSamu Onkalo	RO - Supported proximity measurement rates in Hz
1283f0f4a3fSSamu Onkalo
1293f0f4a3fSSamu Onkaloprox0_thresh_above0_value
1303f0f4a3fSSamu Onkalo	RW - threshold level which trigs proximity events.
131*0e7ade47SMauro Carvalho Chehab
1323f0f4a3fSSamu Onkalo	     Filtered by persistence filter (prox0_thresh_above_count)
1333f0f4a3fSSamu Onkalo
1343f0f4a3fSSamu Onkaloprox0_thresh_above1_value
1353f0f4a3fSSamu Onkalo	RW - threshold level which trigs event immediately
136