xref: /OK3568_Linux_fs/kernel/Documentation/misc-devices/bh1770glc.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun=======================
4*4882a593SmuzhiyunKernel driver bh1770glc
5*4882a593Smuzhiyun=======================
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunSupported chips:
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun- ROHM BH1770GLC
10*4882a593Smuzhiyun- OSRAM SFH7770
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunData sheet:
13*4882a593SmuzhiyunNot freely available
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunAuthor:
16*4882a593SmuzhiyunSamu Onkalo <samu.p.onkalo@nokia.com>
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunDescription
19*4882a593Smuzhiyun-----------
20*4882a593SmuzhiyunBH1770GLC and SFH7770 are combined ambient light and proximity sensors.
21*4882a593SmuzhiyunALS and proximity parts operates on their own, but they shares common I2C
22*4882a593Smuzhiyuninterface and interrupt logic. In principle they can run on their own,
23*4882a593Smuzhiyunbut ALS side results are used to estimate reliability of the proximity sensor.
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunALS produces 16 bit lux values. The chip contains interrupt logic to produce
26*4882a593Smuzhiyunlow and high threshold interrupts.
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunProximity part contains IR-led driver up to 3 IR leds. The chip measures
29*4882a593Smuzhiyunamount of reflected IR light and produces proximity result. Resolution is
30*4882a593Smuzhiyun8 bit. Driver supports only one channel. Driver uses ALS results to estimate
31*4882a593Smuzhiyunreliability of the proximity results. Thus ALS is always running while
32*4882a593Smuzhiyunproximity detection is needed.
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunDriver uses threshold interrupts to avoid need for polling the values.
35*4882a593SmuzhiyunProximity low interrupt doesn't exists in the chip. This is simulated
36*4882a593Smuzhiyunby using a delayed work. As long as there is proximity threshold above
37*4882a593Smuzhiyuninterrupts the delayed work is pushed forward. So, when proximity level goes
38*4882a593Smuzhiyunbelow the threshold value, there is no interrupt and the delayed work will
39*4882a593Smuzhiyunfinally run. This is handled as no proximity indication.
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunChip state is controlled via runtime pm framework when enabled in config.
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunCalibscale factor is used to hide differences between the chips. By default
44*4882a593Smuzhiyunvalue set to neutral state meaning factor of 1.00. To get proper values,
45*4882a593Smuzhiyuncalibrated source of light is needed as a reference. Calibscale factor is set
46*4882a593Smuzhiyunso that measurement produces about the expected lux value.
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunSYSFS
49*4882a593Smuzhiyun-----
50*4882a593Smuzhiyun
51*4882a593Smuzhiyunchip_id
52*4882a593Smuzhiyun	RO - shows detected chip type and version
53*4882a593Smuzhiyun
54*4882a593Smuzhiyunpower_state
55*4882a593Smuzhiyun	RW - enable / disable chip
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun	Uses counting logic
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun	     - 1 enables the chip
60*4882a593Smuzhiyun	     - 0 disables the chip
61*4882a593Smuzhiyun
62*4882a593Smuzhiyunlux0_input
63*4882a593Smuzhiyun	RO - measured lux value
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun	     sysfs_notify called when threshold interrupt occurs
66*4882a593Smuzhiyun
67*4882a593Smuzhiyunlux0_sensor_range
68*4882a593Smuzhiyun	RO - lux0_input max value
69*4882a593Smuzhiyun
70*4882a593Smuzhiyunlux0_rate
71*4882a593Smuzhiyun	RW - measurement rate in Hz
72*4882a593Smuzhiyun
73*4882a593Smuzhiyunlux0_rate_avail
74*4882a593Smuzhiyun	RO - supported measurement rates
75*4882a593Smuzhiyun
76*4882a593Smuzhiyunlux0_thresh_above_value
77*4882a593Smuzhiyun	RW - HI level threshold value
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun	     All results above the value
80*4882a593Smuzhiyun	     trigs an interrupt. 65535 (i.e. sensor_range) disables the above
81*4882a593Smuzhiyun	     interrupt.
82*4882a593Smuzhiyun
83*4882a593Smuzhiyunlux0_thresh_below_value
84*4882a593Smuzhiyun	RW - LO level threshold value
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun	     All results below the value
87*4882a593Smuzhiyun	     trigs an interrupt. 0 disables the below interrupt.
88*4882a593Smuzhiyun
89*4882a593Smuzhiyunlux0_calibscale
90*4882a593Smuzhiyun	RW - calibration value
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun	     Set to neutral value by default.
93*4882a593Smuzhiyun	     Output results are multiplied with calibscale / calibscale_default
94*4882a593Smuzhiyun	     value.
95*4882a593Smuzhiyun
96*4882a593Smuzhiyunlux0_calibscale_default
97*4882a593Smuzhiyun	RO - neutral calibration value
98*4882a593Smuzhiyun
99*4882a593Smuzhiyunprox0_raw
100*4882a593Smuzhiyun	RO - measured proximity value
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun	     sysfs_notify called when threshold interrupt occurs
103*4882a593Smuzhiyun
104*4882a593Smuzhiyunprox0_sensor_range
105*4882a593Smuzhiyun	RO - prox0_raw max value
106*4882a593Smuzhiyun
107*4882a593Smuzhiyunprox0_raw_en
108*4882a593Smuzhiyun	RW - enable / disable proximity
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun	     Uses counting logic
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun	     - 1 enables the proximity
113*4882a593Smuzhiyun	     - 0 disables the proximity
114*4882a593Smuzhiyun
115*4882a593Smuzhiyunprox0_thresh_above_count
116*4882a593Smuzhiyun	RW - number of proximity interrupts needed before triggering the event
117*4882a593Smuzhiyun
118*4882a593Smuzhiyunprox0_rate_above
119*4882a593Smuzhiyun	RW - Measurement rate (in Hz) when the level is above threshold
120*4882a593Smuzhiyun	i.e. when proximity on has been reported.
121*4882a593Smuzhiyun
122*4882a593Smuzhiyunprox0_rate_below
123*4882a593Smuzhiyun	RW - Measurement rate (in Hz) when the level is below threshold
124*4882a593Smuzhiyun	i.e. when proximity off has been reported.
125*4882a593Smuzhiyun
126*4882a593Smuzhiyunprox0_rate_avail
127*4882a593Smuzhiyun	RO - Supported proximity measurement rates in Hz
128*4882a593Smuzhiyun
129*4882a593Smuzhiyunprox0_thresh_above0_value
130*4882a593Smuzhiyun	RW - threshold level which trigs proximity events.
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun	     Filtered by persistence filter (prox0_thresh_above_count)
133*4882a593Smuzhiyun
134*4882a593Smuzhiyunprox0_thresh_above1_value
135*4882a593Smuzhiyun	RW - threshold level which trigs event immediately
136