Lines Matching full:cm3605
3 * CM3605 Ambient Light and Proximity Sensor
35 * struct cm3605 - CM3605 state
44 struct cm3605 { struct
57 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_prox_irq() argument
61 IIO_EV_TYPE_THRESH, cm3605->dir); in cm3605_prox_irq()
65 if (cm3605->dir == IIO_EV_DIR_RISING) in cm3605_prox_irq()
66 cm3605->dir = IIO_EV_DIR_FALLING; in cm3605_prox_irq()
68 cm3605->dir = IIO_EV_DIR_RISING; in cm3605_prox_irq()
73 static int cm3605_get_lux(struct cm3605 *cm3605) in cm3605_get_lux() argument
78 ret = iio_read_channel_processed(cm3605->aout, &res); in cm3605_get_lux()
82 dev_dbg(cm3605->dev, "read %d mV from ADC\n", res); in cm3605_get_lux()
93 dev_err(cm3605->dev, "device out of range\n"); in cm3605_get_lux()
99 lux *= cm3605->als_max; in cm3605_get_lux()
109 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_read_raw() local
116 ret = cm3605_get_lux(cm3605); in cm3605_read_raw()
156 struct cm3605 *cm3605; in cm3605_probe() local
164 indio_dev = devm_iio_device_alloc(dev, sizeof(*cm3605)); in cm3605_probe()
169 cm3605 = iio_priv(indio_dev); in cm3605_probe()
170 cm3605->dev = dev; in cm3605_probe()
171 cm3605->dir = IIO_EV_DIR_FALLING; in cm3605_probe()
180 cm3605->als_max = 650; in cm3605_probe()
183 cm3605->als_max = 300; in cm3605_probe()
186 cm3605->als_max = 100; in cm3605_probe()
189 cm3605->als_max = 50; in cm3605_probe()
196 cm3605->aout = devm_iio_channel_get(dev, "aout"); in cm3605_probe()
197 if (IS_ERR(cm3605->aout)) { in cm3605_probe()
198 if (PTR_ERR(cm3605->aout) == -ENODEV) { in cm3605_probe()
203 return PTR_ERR(cm3605->aout); in cm3605_probe()
205 ret = iio_get_channel_type(cm3605->aout, &ch_type); in cm3605_probe()
213 cm3605->vdd = devm_regulator_get(dev, "vdd"); in cm3605_probe()
214 if (IS_ERR(cm3605->vdd)) { in cm3605_probe()
216 return PTR_ERR(cm3605->vdd); in cm3605_probe()
218 ret = regulator_enable(cm3605->vdd); in cm3605_probe()
224 cm3605->aset = devm_gpiod_get(dev, "aset", GPIOD_OUT_HIGH); in cm3605_probe()
225 if (IS_ERR(cm3605->aset)) { in cm3605_probe()
227 ret = PTR_ERR(cm3605->aset); in cm3605_probe()
232 cm3605_prox_irq, NULL, 0, "cm3605", indio_dev); in cm3605_probe()
239 led_trigger_register_simple("cm3605", &cm3605->led); in cm3605_probe()
240 led_trigger_event(cm3605->led, LED_FULL); in cm3605_probe()
243 indio_dev->name = "cm3605"; in cm3605_probe()
251 dev_info(dev, "Capella Microsystems CM3605 enabled range 0..%d LUX\n", in cm3605_probe()
252 cm3605->als_max); in cm3605_probe()
257 led_trigger_event(cm3605->led, LED_OFF); in cm3605_probe()
258 led_trigger_unregister_simple(cm3605->led); in cm3605_probe()
260 gpiod_set_value_cansleep(cm3605->aset, 0); in cm3605_probe()
262 regulator_disable(cm3605->vdd); in cm3605_probe()
269 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_remove() local
271 led_trigger_event(cm3605->led, LED_OFF); in cm3605_remove()
272 led_trigger_unregister_simple(cm3605->led); in cm3605_remove()
273 gpiod_set_value_cansleep(cm3605->aset, 0); in cm3605_remove()
275 regulator_disable(cm3605->vdd); in cm3605_remove()
283 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_pm_suspend() local
285 led_trigger_event(cm3605->led, LED_OFF); in cm3605_pm_suspend()
286 regulator_disable(cm3605->vdd); in cm3605_pm_suspend()
294 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_pm_resume() local
297 ret = regulator_enable(cm3605->vdd); in cm3605_pm_resume()
300 led_trigger_event(cm3605->led, LED_FULL); in cm3605_pm_resume()
311 {.compatible = "capella,cm3605"},
318 .name = "cm3605",
328 MODULE_DESCRIPTION("CM3605 ambient light and proximity sensor driver");