Lines Matching refs:aw96103

107 struct aw96103 {  struct
247 static int aw96103_get_diff_raw(struct aw96103 *aw96103, unsigned int chan, in aw96103_get_diff_raw() argument
253 ret = regmap_read(aw96103->regmap, in aw96103_get_diff_raw()
266 struct aw96103 *aw96103 = iio_priv(indio_dev); in aw96103_read_raw() local
271 ret = aw96103_get_diff_raw(aw96103, chan->channel, val); in aw96103_read_raw()
281 static int aw96103_read_thresh(struct aw96103 *aw96103, in aw96103_read_thresh() argument
286 ret = regmap_read(aw96103->regmap, in aw96103_read_thresh()
294 static int aw96103_read_out_debounce(struct aw96103 *aw96103, in aw96103_read_out_debounce() argument
301 ret = regmap_read(aw96103->regmap, in aw96103_read_out_debounce()
310 static int aw96103_read_in_debounce(struct aw96103 *aw96103, in aw96103_read_in_debounce() argument
316 ret = regmap_read(aw96103->regmap, in aw96103_read_in_debounce()
325 static int aw96103_read_hysteresis(struct aw96103 *aw96103, in aw96103_read_hysteresis() argument
331 ret = regmap_read(aw96103->regmap, in aw96103_read_hysteresis()
347 struct aw96103 *aw96103 = iio_priv(indio_dev); in aw96103_read_event_val() local
354 return aw96103_read_thresh(aw96103, chan, val); in aw96103_read_event_val()
358 return aw96103_read_out_debounce(aw96103, chan, val); in aw96103_read_event_val()
360 return aw96103_read_in_debounce(aw96103, chan, val); in aw96103_read_event_val()
365 return aw96103_read_hysteresis(aw96103, chan, val); in aw96103_read_event_val()
377 struct aw96103 *aw96103 = iio_priv(indio_dev); in aw96103_write_event_val() local
384 return regmap_write(aw96103->regmap, in aw96103_write_event_val()
389 return regmap_update_bits(aw96103->regmap, in aw96103_write_event_val()
395 return regmap_update_bits(aw96103->regmap, in aw96103_write_event_val()
403 return regmap_update_bits(aw96103->regmap, in aw96103_write_event_val()
417 struct aw96103 *aw96103 = iio_priv(indio_dev); in aw96103_read_event_config() local
419 return aw96103->channels_arr[chan->channel].used; in aw96103_read_event_config()
427 struct aw96103 *aw96103 = iio_priv(indio_dev); in aw96103_write_event_config() local
429 aw96103->channels_arr[chan->channel].used = !!state; in aw96103_write_event_config()
431 return regmap_update_bits(aw96103->regmap, AW96103_REG_SCANCTRL0, in aw96103_write_event_config()
444 static int aw96103_channel_scan_start(struct aw96103 *aw96103) in aw96103_channel_scan_start() argument
448 ret = regmap_write(aw96103->regmap, AW96103_REG_CMD, in aw96103_channel_scan_start()
453 return regmap_write(aw96103->regmap, AW96103_REG_IRQEN, in aw96103_channel_scan_start()
454 aw96103->hostirqen); in aw96103_channel_scan_start()
457 static int aw96103_reg_version_comp(struct aw96103 *aw96103, in aw96103_reg_version_comp() argument
464 ret = regmap_read(aw96103->regmap, AW96103_REG_FWVER2, &fw_ver); in aw96103_reg_version_comp()
475 for (i = 0; i < aw96103->max_channels; i++) { in aw96103_reg_version_comp()
476 ret = regmap_read(aw96103->regmap, in aw96103_reg_version_comp()
484 ret = regmap_update_bits(aw96103->regmap, in aw96103_reg_version_comp()
494 static int aw96103_bin_valid_loaded(struct aw96103 *aw96103, in aw96103_bin_valid_loaded() argument
511 aw96103->hostirqen = reg_data; in aw96103_bin_valid_loaded()
515 aw96103->chan_en = FIELD_GET(AW96103_CHAN_EN_MASK, in aw96103_bin_valid_loaded()
518 ret = regmap_write(aw96103->regmap, reg_addr, reg_data); in aw96103_bin_valid_loaded()
523 ret = aw96103_reg_version_comp(aw96103, aw_bin_data_s); in aw96103_bin_valid_loaded()
527 return aw96103_channel_scan_start(aw96103); in aw96103_bin_valid_loaded()
530 static int aw96103_para_loaded(struct aw96103 *aw96103) in aw96103_para_loaded() argument
535 ret = regmap_write(aw96103->regmap, in aw96103_para_loaded()
541 aw96103->hostirqen = aw96103_reg_default[i + 1]; in aw96103_para_loaded()
543 aw96103->chan_en = FIELD_GET(AW96103_CHAN_EN_MASK, in aw96103_para_loaded()
547 return aw96103_channel_scan_start(aw96103); in aw96103_para_loaded()
551 struct aw96103 *aw96103) in aw96103_cfg_all_loaded() argument
566 return aw96103_bin_valid_loaded(aw96103, aw_bin); in aw96103_cfg_all_loaded()
571 struct aw96103 *aw96103 = data; in aw96103_cfg_update() local
575 dev_err(aw96103->dev, "No firmware.\n"); in aw96103_cfg_update()
579 ret = aw96103_cfg_all_loaded(fw, aw96103); in aw96103_cfg_update()
586 ret = aw96103_para_loaded(aw96103); in aw96103_cfg_update()
588 dev_err(aw96103->dev, "load param error.\n"); in aw96103_cfg_update()
593 for (i = 0; i < aw96103->max_channels; i++) { in aw96103_cfg_update()
594 if ((aw96103->chan_en >> i) & 0x01) in aw96103_cfg_update()
595 aw96103->channels_arr[i].used = true; in aw96103_cfg_update()
597 aw96103->channels_arr[i].used = false; in aw96103_cfg_update()
601 static int aw96103_sw_reset(struct aw96103 *aw96103) in aw96103_sw_reset() argument
605 ret = regmap_write(aw96103->regmap, AW96103_REG_RESET, 0); in aw96103_sw_reset()
627 struct aw96103 *aw96103 = iio_priv(indio_dev); in aw96103_irq() local
630 ret = regmap_read(aw96103->regmap, AW96103_REG_IRQSRC, &irq_status); in aw96103_irq()
634 ret = regmap_read(aw96103->regmap, AW96103_REG_STAT0, &curr_status_val); in aw96103_irq()
642 for (i = 0; i < aw96103->max_channels; i++) { in aw96103_irq()
643 if (!aw96103->channels_arr[i].used) in aw96103_irq()
650 if (aw96103->channels_arr[i].old_irq_status == curr_status) in aw96103_irq()
674 aw96103->channels_arr[i].old_irq_status = curr_status; in aw96103_irq()
683 struct aw96103 *aw96103 = iio_priv(indio_dev); in aw96103_interrupt_init() local
687 ret = regmap_write(aw96103->regmap, AW96103_REG_IRQEN, 0); in aw96103_interrupt_init()
690 ret = regmap_read(aw96103->regmap, AW96103_REG_IRQSRC, &irq_status); in aw96103_interrupt_init()
693 ret = devm_request_threaded_irq(aw96103->dev, i2c->irq, NULL, in aw96103_interrupt_init()
699 return regmap_write(aw96103->regmap, AW96103_REG_IRQEN, in aw96103_interrupt_init()
700 aw96103->hostirqen); in aw96103_interrupt_init()
703 static int aw96103_wait_chip_init(struct aw96103 *aw96103) in aw96103_wait_chip_init() argument
714 ret = regmap_read(aw96103->regmap, AW96103_REG_IRQSRC, in aw96103_wait_chip_init()
727 static int aw96103_read_chipid(struct aw96103 *aw96103) in aw96103_read_chipid() argument
740 ret = regmap_read(aw96103->regmap, AW96103_REG_CHIPID, in aw96103_read_chipid()
753 dev_info(aw96103->dev, in aw96103_read_chipid()
763 struct aw96103 *aw96103; in aw96103_i2c_probe() local
766 indio_dev = devm_iio_device_alloc(&i2c->dev, sizeof(*aw96103)); in aw96103_i2c_probe()
770 aw96103 = iio_priv(indio_dev); in aw96103_i2c_probe()
771 aw96103->dev = &i2c->dev; in aw96103_i2c_probe()
773 aw96103->max_channels = chip_info->num_channels; in aw96103_i2c_probe()
775 aw96103->regmap = devm_regmap_init_i2c(i2c, &aw96103_regmap_confg); in aw96103_i2c_probe()
776 if (IS_ERR(aw96103->regmap)) in aw96103_i2c_probe()
777 return PTR_ERR(aw96103->regmap); in aw96103_i2c_probe()
779 ret = devm_regulator_get_enable(aw96103->dev, "vcc"); in aw96103_i2c_probe()
783 ret = aw96103_read_chipid(aw96103); in aw96103_i2c_probe()
787 ret = aw96103_sw_reset(aw96103); in aw96103_i2c_probe()
791 ret = aw96103_wait_chip_init(aw96103); in aw96103_i2c_probe()
796 aw96103->dev, GFP_KERNEL, aw96103, in aw96103_i2c_probe()
811 return devm_iio_device_register(aw96103->dev, indio_dev); in aw96103_i2c_probe()