Lines Matching refs:th_sel

165 static inline void adc_npcx_enable_threshold_detect(const struct device *dev, uint8_t th_sel,  in adc_npcx_enable_threshold_detect()  argument
172 THEN(config->base) |= BIT(th_sel); in adc_npcx_enable_threshold_detect()
174 THRCTL(config->base, th_sel) |= BIT(NPCX_THRCTL_THEN); in adc_npcx_enable_threshold_detect()
179 THEN(config->base) &= ~BIT(th_sel); in adc_npcx_enable_threshold_detect()
181 THRCTL(config->base, th_sel) &= ~BIT(NPCX_THRCTL_THEN); in adc_npcx_enable_threshold_detect()
510 const uint8_t th_sel, in adc_npcx_threshold_ctrl_set_param() argument
518 &t_data->control[th_sel]; in adc_npcx_threshold_ctrl_set_param()
525 if (!param || th_sel >= config->threshold_count) { in adc_npcx_threshold_ctrl_set_param()
566 const uint8_t th_sel) in adc_npcx_threshold_ctrl_setup() argument
573 &t_data->control[th_sel]; in adc_npcx_threshold_ctrl_setup()
575 if (th_sel >= config->threshold_count) { in adc_npcx_threshold_ctrl_setup()
581 if (t_data->active_thresholds & BIT(th_sel)) { in adc_npcx_threshold_ctrl_setup()
584 LOG_ERR("Threshold selected (%d) is active!", th_sel); in adc_npcx_threshold_ctrl_setup()
592 LOG_ERR("Threshold selected (%d) is not configured!", th_sel); in adc_npcx_threshold_ctrl_setup()
596 SET_FIELD(THRCTL(config->base, th_sel), in adc_npcx_threshold_ctrl_setup()
600 THRCTL(config->base, th_sel) |= BIT(NPCX_THRCTL_L_H); in adc_npcx_threshold_ctrl_setup()
602 THRCTL(config->base, th_sel) &= ~BIT(NPCX_THRCTL_L_H); in adc_npcx_threshold_ctrl_setup()
605 SET_FIELD(THRCTL(config->base, th_sel), NPCX_THRCTL_THRVAL, in adc_npcx_threshold_ctrl_setup()
613 const uint8_t th_sel) in adc_npcx_threshold_enable_irq() argument
621 &t_data->control[th_sel]; in adc_npcx_threshold_enable_irq()
624 if (th_sel >= config->threshold_count) { in adc_npcx_threshold_enable_irq()
625 LOG_ERR("Invalid ADC threshold selection! (%d)", th_sel); in adc_npcx_threshold_enable_irq()
634 LOG_ERR("Threshold selected (%d) is not configured!", th_sel); in adc_npcx_threshold_enable_irq()
639 t_data->active_thresholds |= BIT(th_sel); in adc_npcx_threshold_enable_irq()
645 adc_npcx_enable_threshold_detect(dev, th_sel, true); in adc_npcx_threshold_enable_irq()
648 thrcts |= BIT(th_sel); in adc_npcx_threshold_enable_irq()
651 thrcts |= BIT(NPCX_THRCTS_THR1_IEN + th_sel); in adc_npcx_threshold_enable_irq()
655 adc_npcx_set_repetitive(dev, t_data->control[th_sel].chnsel, true); in adc_npcx_threshold_enable_irq()
662 const uint8_t th_sel) in adc_npcx_threshold_disable_irq() argument
674 if (th_sel >= config->threshold_count) { in adc_npcx_threshold_disable_irq()
675 LOG_ERR("Invalid ADC threshold selection! (%d)", th_sel); in adc_npcx_threshold_disable_irq()
680 if (!(t_data->active_thresholds & BIT(th_sel))) { in adc_npcx_threshold_disable_irq()
682 LOG_ERR("Threshold selection (%d) is not enabled", th_sel); in adc_npcx_threshold_disable_irq()
689 thrcts &= ~BIT(NPCX_THRCTS_THR1_IEN + th_sel); in adc_npcx_threshold_disable_irq()
693 adc_npcx_enable_threshold_detect(dev, th_sel, false); in adc_npcx_threshold_disable_irq()
696 t_data->active_thresholds &= ~BIT(th_sel); in adc_npcx_threshold_disable_irq()
698 adc_npcx_set_repetitive(dev, t_data->control[th_sel].chnsel, false); in adc_npcx_threshold_disable_irq()
705 int adc_npcx_threshold_ctrl_enable(const struct device *dev, uint8_t th_sel, in adc_npcx_threshold_ctrl_enable() argument
717 ret = adc_npcx_threshold_ctrl_setup(dev, th_sel); in adc_npcx_threshold_ctrl_enable()
721 ret = adc_npcx_threshold_enable_irq(dev, th_sel); in adc_npcx_threshold_ctrl_enable()
723 ret = adc_npcx_threshold_disable_irq(dev, th_sel); in adc_npcx_threshold_ctrl_enable()