Lines Matching refs:cm3605
45 struct cm3605 { struct
58 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_prox_irq() argument
62 IIO_EV_TYPE_THRESH, cm3605->dir); in cm3605_prox_irq()
66 if (cm3605->dir == IIO_EV_DIR_RISING) in cm3605_prox_irq()
67 cm3605->dir = IIO_EV_DIR_FALLING; in cm3605_prox_irq()
69 cm3605->dir = IIO_EV_DIR_RISING; in cm3605_prox_irq()
74 static int cm3605_get_lux(struct cm3605 *cm3605) in cm3605_get_lux() argument
79 ret = iio_read_channel_processed(cm3605->aout, &res); in cm3605_get_lux()
83 dev_dbg(cm3605->dev, "read %d mV from ADC\n", res); in cm3605_get_lux()
94 dev_err(cm3605->dev, "device out of range\n"); in cm3605_get_lux()
100 lux *= cm3605->als_max; in cm3605_get_lux()
110 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_read_raw() local
117 ret = cm3605_get_lux(cm3605); in cm3605_read_raw()
157 struct cm3605 *cm3605; in cm3605_probe() local
165 indio_dev = devm_iio_device_alloc(dev, sizeof(*cm3605)); in cm3605_probe()
170 cm3605 = iio_priv(indio_dev); in cm3605_probe()
171 cm3605->dev = dev; in cm3605_probe()
172 cm3605->dir = IIO_EV_DIR_FALLING; in cm3605_probe()
181 cm3605->als_max = 650; in cm3605_probe()
184 cm3605->als_max = 300; in cm3605_probe()
187 cm3605->als_max = 100; in cm3605_probe()
190 cm3605->als_max = 50; in cm3605_probe()
197 cm3605->aout = devm_iio_channel_get(dev, "aout"); in cm3605_probe()
198 if (IS_ERR(cm3605->aout)) { in cm3605_probe()
199 ret = PTR_ERR(cm3605->aout); in cm3605_probe()
203 ret = iio_get_channel_type(cm3605->aout, &ch_type); in cm3605_probe()
211 cm3605->vdd = devm_regulator_get(dev, "vdd"); in cm3605_probe()
212 if (IS_ERR(cm3605->vdd)) in cm3605_probe()
213 return dev_err_probe(dev, PTR_ERR(cm3605->vdd), in cm3605_probe()
216 ret = regulator_enable(cm3605->vdd); in cm3605_probe()
222 cm3605->aset = devm_gpiod_get(dev, "aset", GPIOD_OUT_HIGH); in cm3605_probe()
223 if (IS_ERR(cm3605->aset)) { in cm3605_probe()
224 ret = dev_err_probe(dev, PTR_ERR(cm3605->aset), "no ASET GPIO\n"); in cm3605_probe()
242 led_trigger_register_simple("cm3605", &cm3605->led); in cm3605_probe()
243 led_trigger_event(cm3605->led, LED_FULL); in cm3605_probe()
255 cm3605->als_max); in cm3605_probe()
260 led_trigger_event(cm3605->led, LED_OFF); in cm3605_probe()
261 led_trigger_unregister_simple(cm3605->led); in cm3605_probe()
263 gpiod_set_value_cansleep(cm3605->aset, 0); in cm3605_probe()
265 regulator_disable(cm3605->vdd); in cm3605_probe()
272 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_remove() local
274 led_trigger_event(cm3605->led, LED_OFF); in cm3605_remove()
275 led_trigger_unregister_simple(cm3605->led); in cm3605_remove()
276 gpiod_set_value_cansleep(cm3605->aset, 0); in cm3605_remove()
278 regulator_disable(cm3605->vdd); in cm3605_remove()
284 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_pm_suspend() local
286 led_trigger_event(cm3605->led, LED_OFF); in cm3605_pm_suspend()
287 regulator_disable(cm3605->vdd); in cm3605_pm_suspend()
295 struct cm3605 *cm3605 = iio_priv(indio_dev); in cm3605_pm_resume() local
298 ret = regulator_enable(cm3605->vdd); in cm3605_pm_resume()
301 led_trigger_event(cm3605->led, LED_FULL); in cm3605_pm_resume()