Lines Matching refs:ad714x
126 static void ad714x_use_com_int(struct ad714x_chip *ad714x, in ad714x_use_com_int() argument
134 ad714x->read(ad714x, STG_COM_INT_EN_REG, &data, 1); in ad714x_use_com_int()
136 ad714x->write(ad714x, STG_COM_INT_EN_REG, data); in ad714x_use_com_int()
138 ad714x->read(ad714x, STG_HIGH_INT_EN_REG, &data, 1); in ad714x_use_com_int()
140 ad714x->write(ad714x, STG_HIGH_INT_EN_REG, data); in ad714x_use_com_int()
143 static void ad714x_use_thr_int(struct ad714x_chip *ad714x, in ad714x_use_thr_int() argument
151 ad714x->read(ad714x, STG_COM_INT_EN_REG, &data, 1); in ad714x_use_thr_int()
153 ad714x->write(ad714x, STG_COM_INT_EN_REG, data); in ad714x_use_thr_int()
155 ad714x->read(ad714x, STG_HIGH_INT_EN_REG, &data, 1); in ad714x_use_thr_int()
157 ad714x->write(ad714x, STG_HIGH_INT_EN_REG, data); in ad714x_use_thr_int()
160 static int ad714x_cal_highest_stage(struct ad714x_chip *ad714x, in ad714x_cal_highest_stage() argument
168 if (ad714x->sensor_val[i] > max_res) { in ad714x_cal_highest_stage()
169 max_res = ad714x->sensor_val[i]; in ad714x_cal_highest_stage()
177 static int ad714x_cal_abs_pos(struct ad714x_chip *ad714x, in ad714x_cal_abs_pos() argument
184 a_param = ad714x->sensor_val[start_stage + 1]; in ad714x_cal_abs_pos()
185 b_param = ad714x->sensor_val[start_stage] + in ad714x_cal_abs_pos()
186 ad714x->sensor_val[start_stage + 1]; in ad714x_cal_abs_pos()
188 a_param = ad714x->sensor_val[end_stage] * in ad714x_cal_abs_pos()
190 ad714x->sensor_val[end_stage - 1] * in ad714x_cal_abs_pos()
192 b_param = ad714x->sensor_val[end_stage] + in ad714x_cal_abs_pos()
193 ad714x->sensor_val[end_stage - 1]; in ad714x_cal_abs_pos()
195 a_param = ad714x->sensor_val[highest_stage] * in ad714x_cal_abs_pos()
197 ad714x->sensor_val[highest_stage - 1] * in ad714x_cal_abs_pos()
199 ad714x->sensor_val[highest_stage + 1] * in ad714x_cal_abs_pos()
201 b_param = ad714x->sensor_val[highest_stage] + in ad714x_cal_abs_pos()
202 ad714x->sensor_val[highest_stage - 1] + in ad714x_cal_abs_pos()
203 ad714x->sensor_val[highest_stage + 1]; in ad714x_cal_abs_pos()
213 static void ad714x_button_state_machine(struct ad714x_chip *ad714x, int idx) in ad714x_button_state_machine() argument
215 struct ad714x_button_plat *hw = &ad714x->hw->button[idx]; in ad714x_button_state_machine()
216 struct ad714x_button_drv *sw = &ad714x->sw->button[idx]; in ad714x_button_state_machine()
220 if (((ad714x->h_state & hw->h_mask) == hw->h_mask) && in ad714x_button_state_machine()
221 ((ad714x->l_state & hw->l_mask) == hw->l_mask)) { in ad714x_button_state_machine()
222 dev_dbg(ad714x->dev, "button %d touched\n", idx); in ad714x_button_state_machine()
230 if (((ad714x->h_state & hw->h_mask) != hw->h_mask) || in ad714x_button_state_machine()
231 ((ad714x->l_state & hw->l_mask) != hw->l_mask)) { in ad714x_button_state_machine()
232 dev_dbg(ad714x->dev, "button %d released\n", idx); in ad714x_button_state_machine()
248 static void ad714x_slider_cal_sensor_val(struct ad714x_chip *ad714x, int idx) in ad714x_slider_cal_sensor_val() argument
250 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; in ad714x_slider_cal_sensor_val()
253 ad714x->read(ad714x, CDC_RESULT_S0 + hw->start_stage, in ad714x_slider_cal_sensor_val()
254 &ad714x->adc_reg[hw->start_stage], in ad714x_slider_cal_sensor_val()
258 ad714x->read(ad714x, STAGE0_AMBIENT + i * PER_STAGE_REG_NUM, in ad714x_slider_cal_sensor_val()
259 &ad714x->amb_reg[i], 1); in ad714x_slider_cal_sensor_val()
261 ad714x->sensor_val[i] = in ad714x_slider_cal_sensor_val()
262 abs(ad714x->adc_reg[i] - ad714x->amb_reg[i]); in ad714x_slider_cal_sensor_val()
266 static void ad714x_slider_cal_highest_stage(struct ad714x_chip *ad714x, int idx) in ad714x_slider_cal_highest_stage() argument
268 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; in ad714x_slider_cal_highest_stage()
269 struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx]; in ad714x_slider_cal_highest_stage()
271 sw->highest_stage = ad714x_cal_highest_stage(ad714x, hw->start_stage, in ad714x_slider_cal_highest_stage()
274 dev_dbg(ad714x->dev, "slider %d highest_stage:%d\n", idx, in ad714x_slider_cal_highest_stage()
291 static void ad714x_slider_cal_abs_pos(struct ad714x_chip *ad714x, int idx) in ad714x_slider_cal_abs_pos() argument
293 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; in ad714x_slider_cal_abs_pos()
294 struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx]; in ad714x_slider_cal_abs_pos()
296 sw->abs_pos = ad714x_cal_abs_pos(ad714x, hw->start_stage, hw->end_stage, in ad714x_slider_cal_abs_pos()
299 dev_dbg(ad714x->dev, "slider %d absolute position:%d\n", idx, in ad714x_slider_cal_abs_pos()
313 static void ad714x_slider_cal_flt_pos(struct ad714x_chip *ad714x, int idx) in ad714x_slider_cal_flt_pos() argument
315 struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx]; in ad714x_slider_cal_flt_pos()
320 dev_dbg(ad714x->dev, "slider %d filter position:%d\n", idx, in ad714x_slider_cal_flt_pos()
324 static void ad714x_slider_use_com_int(struct ad714x_chip *ad714x, int idx) in ad714x_slider_use_com_int() argument
326 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; in ad714x_slider_use_com_int()
328 ad714x_use_com_int(ad714x, hw->start_stage, hw->end_stage); in ad714x_slider_use_com_int()
331 static void ad714x_slider_use_thr_int(struct ad714x_chip *ad714x, int idx) in ad714x_slider_use_thr_int() argument
333 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; in ad714x_slider_use_thr_int()
335 ad714x_use_thr_int(ad714x, hw->start_stage, hw->end_stage); in ad714x_slider_use_thr_int()
338 static void ad714x_slider_state_machine(struct ad714x_chip *ad714x, int idx) in ad714x_slider_state_machine() argument
340 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; in ad714x_slider_state_machine()
341 struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx]; in ad714x_slider_state_machine()
347 h_state = ad714x->h_state & mask; in ad714x_slider_state_machine()
348 c_state = ad714x->c_state & mask; in ad714x_slider_state_machine()
357 ad714x_slider_use_com_int(ad714x, idx); in ad714x_slider_state_machine()
358 dev_dbg(ad714x->dev, "slider %d touched\n", idx); in ad714x_slider_state_machine()
364 ad714x_slider_cal_sensor_val(ad714x, idx); in ad714x_slider_state_machine()
365 ad714x_slider_cal_highest_stage(ad714x, idx); in ad714x_slider_state_machine()
366 ad714x_slider_cal_abs_pos(ad714x, idx); in ad714x_slider_state_machine()
375 ad714x_slider_cal_sensor_val(ad714x, idx); in ad714x_slider_state_machine()
376 ad714x_slider_cal_highest_stage(ad714x, idx); in ad714x_slider_state_machine()
377 ad714x_slider_cal_abs_pos(ad714x, idx); in ad714x_slider_state_machine()
378 ad714x_slider_cal_flt_pos(ad714x, idx); in ad714x_slider_state_machine()
385 ad714x_slider_use_thr_int(ad714x, idx); in ad714x_slider_state_machine()
388 dev_dbg(ad714x->dev, "slider %d released\n", in ad714x_slider_state_machine()
407 static void ad714x_wheel_cal_highest_stage(struct ad714x_chip *ad714x, int idx) in ad714x_wheel_cal_highest_stage() argument
409 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; in ad714x_wheel_cal_highest_stage()
410 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; in ad714x_wheel_cal_highest_stage()
413 sw->highest_stage = ad714x_cal_highest_stage(ad714x, hw->start_stage, in ad714x_wheel_cal_highest_stage()
416 dev_dbg(ad714x->dev, "wheel %d highest_stage:%d\n", idx, in ad714x_wheel_cal_highest_stage()
420 static void ad714x_wheel_cal_sensor_val(struct ad714x_chip *ad714x, int idx) in ad714x_wheel_cal_sensor_val() argument
422 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; in ad714x_wheel_cal_sensor_val()
425 ad714x->read(ad714x, CDC_RESULT_S0 + hw->start_stage, in ad714x_wheel_cal_sensor_val()
426 &ad714x->adc_reg[hw->start_stage], in ad714x_wheel_cal_sensor_val()
430 ad714x->read(ad714x, STAGE0_AMBIENT + i * PER_STAGE_REG_NUM, in ad714x_wheel_cal_sensor_val()
431 &ad714x->amb_reg[i], 1); in ad714x_wheel_cal_sensor_val()
432 if (ad714x->adc_reg[i] > ad714x->amb_reg[i]) in ad714x_wheel_cal_sensor_val()
433 ad714x->sensor_val[i] = in ad714x_wheel_cal_sensor_val()
434 ad714x->adc_reg[i] - ad714x->amb_reg[i]; in ad714x_wheel_cal_sensor_val()
436 ad714x->sensor_val[i] = 0; in ad714x_wheel_cal_sensor_val()
449 static void ad714x_wheel_cal_abs_pos(struct ad714x_chip *ad714x, int idx) in ad714x_wheel_cal_abs_pos() argument
451 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; in ad714x_wheel_cal_abs_pos()
452 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; in ad714x_wheel_cal_abs_pos()
461 a_param = ad714x->sensor_val[highest] * in ad714x_wheel_cal_abs_pos()
463 ad714x->sensor_val[first_before] * in ad714x_wheel_cal_abs_pos()
465 ad714x->sensor_val[first_after] * in ad714x_wheel_cal_abs_pos()
467 b_param = ad714x->sensor_val[highest] + in ad714x_wheel_cal_abs_pos()
468 ad714x->sensor_val[first_before] + in ad714x_wheel_cal_abs_pos()
469 ad714x->sensor_val[first_after]; in ad714x_wheel_cal_abs_pos()
480 static void ad714x_wheel_cal_flt_pos(struct ad714x_chip *ad714x, int idx) in ad714x_wheel_cal_flt_pos() argument
482 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; in ad714x_wheel_cal_flt_pos()
483 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; in ad714x_wheel_cal_flt_pos()
496 static void ad714x_wheel_use_com_int(struct ad714x_chip *ad714x, int idx) in ad714x_wheel_use_com_int() argument
498 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; in ad714x_wheel_use_com_int()
500 ad714x_use_com_int(ad714x, hw->start_stage, hw->end_stage); in ad714x_wheel_use_com_int()
503 static void ad714x_wheel_use_thr_int(struct ad714x_chip *ad714x, int idx) in ad714x_wheel_use_thr_int() argument
505 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; in ad714x_wheel_use_thr_int()
507 ad714x_use_thr_int(ad714x, hw->start_stage, hw->end_stage); in ad714x_wheel_use_thr_int()
510 static void ad714x_wheel_state_machine(struct ad714x_chip *ad714x, int idx) in ad714x_wheel_state_machine() argument
512 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; in ad714x_wheel_state_machine()
513 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; in ad714x_wheel_state_machine()
519 h_state = ad714x->h_state & mask; in ad714x_wheel_state_machine()
520 c_state = ad714x->c_state & mask; in ad714x_wheel_state_machine()
529 ad714x_wheel_use_com_int(ad714x, idx); in ad714x_wheel_state_machine()
530 dev_dbg(ad714x->dev, "wheel %d touched\n", idx); in ad714x_wheel_state_machine()
536 ad714x_wheel_cal_sensor_val(ad714x, idx); in ad714x_wheel_state_machine()
537 ad714x_wheel_cal_highest_stage(ad714x, idx); in ad714x_wheel_state_machine()
538 ad714x_wheel_cal_abs_pos(ad714x, idx); in ad714x_wheel_state_machine()
547 ad714x_wheel_cal_sensor_val(ad714x, idx); in ad714x_wheel_state_machine()
548 ad714x_wheel_cal_highest_stage(ad714x, idx); in ad714x_wheel_state_machine()
549 ad714x_wheel_cal_abs_pos(ad714x, idx); in ad714x_wheel_state_machine()
550 ad714x_wheel_cal_flt_pos(ad714x, idx); in ad714x_wheel_state_machine()
558 ad714x_wheel_use_thr_int(ad714x, idx); in ad714x_wheel_state_machine()
562 dev_dbg(ad714x->dev, "wheel %d released\n", in ad714x_wheel_state_machine()
574 static void touchpad_cal_sensor_val(struct ad714x_chip *ad714x, int idx) in touchpad_cal_sensor_val() argument
576 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; in touchpad_cal_sensor_val()
579 ad714x->read(ad714x, CDC_RESULT_S0 + hw->x_start_stage, in touchpad_cal_sensor_val()
580 &ad714x->adc_reg[hw->x_start_stage], in touchpad_cal_sensor_val()
584 ad714x->read(ad714x, STAGE0_AMBIENT + i * PER_STAGE_REG_NUM, in touchpad_cal_sensor_val()
585 &ad714x->amb_reg[i], 1); in touchpad_cal_sensor_val()
586 if (ad714x->adc_reg[i] > ad714x->amb_reg[i]) in touchpad_cal_sensor_val()
587 ad714x->sensor_val[i] = in touchpad_cal_sensor_val()
588 ad714x->adc_reg[i] - ad714x->amb_reg[i]; in touchpad_cal_sensor_val()
590 ad714x->sensor_val[i] = 0; in touchpad_cal_sensor_val()
594 static void touchpad_cal_highest_stage(struct ad714x_chip *ad714x, int idx) in touchpad_cal_highest_stage() argument
596 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; in touchpad_cal_highest_stage()
597 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; in touchpad_cal_highest_stage()
599 sw->x_highest_stage = ad714x_cal_highest_stage(ad714x, in touchpad_cal_highest_stage()
601 sw->y_highest_stage = ad714x_cal_highest_stage(ad714x, in touchpad_cal_highest_stage()
604 dev_dbg(ad714x->dev, in touchpad_cal_highest_stage()
615 static int touchpad_check_second_peak(struct ad714x_chip *ad714x, int idx) in touchpad_check_second_peak() argument
617 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; in touchpad_check_second_peak()
618 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; in touchpad_check_second_peak()
622 if ((ad714x->sensor_val[i] - ad714x->sensor_val[i + 1]) in touchpad_check_second_peak()
623 > (ad714x->sensor_val[i + 1] / 10)) in touchpad_check_second_peak()
628 if ((ad714x->sensor_val[i + 1] - ad714x->sensor_val[i]) in touchpad_check_second_peak()
629 > (ad714x->sensor_val[i] / 10)) in touchpad_check_second_peak()
634 if ((ad714x->sensor_val[i] - ad714x->sensor_val[i + 1]) in touchpad_check_second_peak()
635 > (ad714x->sensor_val[i + 1] / 10)) in touchpad_check_second_peak()
640 if ((ad714x->sensor_val[i + 1] - ad714x->sensor_val[i]) in touchpad_check_second_peak()
641 > (ad714x->sensor_val[i] / 10)) in touchpad_check_second_peak()
654 static void touchpad_cal_abs_pos(struct ad714x_chip *ad714x, int idx) in touchpad_cal_abs_pos() argument
656 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; in touchpad_cal_abs_pos()
657 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; in touchpad_cal_abs_pos()
659 sw->x_abs_pos = ad714x_cal_abs_pos(ad714x, hw->x_start_stage, in touchpad_cal_abs_pos()
661 sw->y_abs_pos = ad714x_cal_abs_pos(ad714x, hw->y_start_stage, in touchpad_cal_abs_pos()
664 dev_dbg(ad714x->dev, "touchpad %d absolute position:(%d, %d)\n", idx, in touchpad_cal_abs_pos()
668 static void touchpad_cal_flt_pos(struct ad714x_chip *ad714x, int idx) in touchpad_cal_flt_pos() argument
670 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; in touchpad_cal_flt_pos()
677 dev_dbg(ad714x->dev, "touchpad %d filter position:(%d, %d)\n", in touchpad_cal_flt_pos()
699 static int touchpad_check_endpoint(struct ad714x_chip *ad714x, int idx) in touchpad_check_endpoint() argument
701 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; in touchpad_check_endpoint()
702 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; in touchpad_check_endpoint()
706 percent_sensor_diff = (ad714x->sensor_val[hw->x_start_stage] - in touchpad_check_endpoint()
707 ad714x->sensor_val[hw->x_start_stage + 1]) * 100 / in touchpad_check_endpoint()
708 ad714x->sensor_val[hw->x_start_stage + 1]; in touchpad_check_endpoint()
713 ad714x->sensor_val[hw->x_start_stage + 1]; in touchpad_check_endpoint()
717 (ad714x->sensor_val[hw->x_start_stage + 1] > in touchpad_check_endpoint()
723 percent_sensor_diff = (ad714x->sensor_val[hw->x_end_stage] - in touchpad_check_endpoint()
724 ad714x->sensor_val[hw->x_end_stage - 1]) * 100 / in touchpad_check_endpoint()
725 ad714x->sensor_val[hw->x_end_stage - 1]; in touchpad_check_endpoint()
730 ad714x->sensor_val[hw->x_end_stage - 1]; in touchpad_check_endpoint()
734 (ad714x->sensor_val[hw->x_end_stage - 1] > in touchpad_check_endpoint()
740 percent_sensor_diff = (ad714x->sensor_val[hw->y_start_stage] - in touchpad_check_endpoint()
741 ad714x->sensor_val[hw->y_start_stage + 1]) * 100 / in touchpad_check_endpoint()
742 ad714x->sensor_val[hw->y_start_stage + 1]; in touchpad_check_endpoint()
747 ad714x->sensor_val[hw->y_start_stage + 1]; in touchpad_check_endpoint()
751 (ad714x->sensor_val[hw->y_start_stage + 1] > in touchpad_check_endpoint()
757 percent_sensor_diff = (ad714x->sensor_val[hw->y_end_stage] - in touchpad_check_endpoint()
758 ad714x->sensor_val[hw->y_end_stage - 1]) * 100 / in touchpad_check_endpoint()
759 ad714x->sensor_val[hw->y_end_stage - 1]; in touchpad_check_endpoint()
764 ad714x->sensor_val[hw->y_end_stage - 1]; in touchpad_check_endpoint()
768 (ad714x->sensor_val[hw->y_end_stage - 1] > in touchpad_check_endpoint()
776 static void touchpad_use_com_int(struct ad714x_chip *ad714x, int idx) in touchpad_use_com_int() argument
778 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; in touchpad_use_com_int()
780 ad714x_use_com_int(ad714x, hw->x_start_stage, hw->x_end_stage); in touchpad_use_com_int()
783 static void touchpad_use_thr_int(struct ad714x_chip *ad714x, int idx) in touchpad_use_thr_int() argument
785 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; in touchpad_use_thr_int()
787 ad714x_use_thr_int(ad714x, hw->x_start_stage, hw->x_end_stage); in touchpad_use_thr_int()
788 ad714x_use_thr_int(ad714x, hw->y_start_stage, hw->y_end_stage); in touchpad_use_thr_int()
791 static void ad714x_touchpad_state_machine(struct ad714x_chip *ad714x, int idx) in ad714x_touchpad_state_machine() argument
793 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; in ad714x_touchpad_state_machine()
794 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; in ad714x_touchpad_state_machine()
803 h_state = ad714x->h_state & mask; in ad714x_touchpad_state_machine()
804 c_state = ad714x->c_state & mask; in ad714x_touchpad_state_machine()
813 touchpad_use_com_int(ad714x, idx); in ad714x_touchpad_state_machine()
814 dev_dbg(ad714x->dev, "touchpad %d touched\n", idx); in ad714x_touchpad_state_machine()
820 touchpad_cal_sensor_val(ad714x, idx); in ad714x_touchpad_state_machine()
821 touchpad_cal_highest_stage(ad714x, idx); in ad714x_touchpad_state_machine()
822 if ((!touchpad_check_second_peak(ad714x, idx)) && in ad714x_touchpad_state_machine()
823 (!touchpad_check_endpoint(ad714x, idx))) { in ad714x_touchpad_state_machine()
824 dev_dbg(ad714x->dev, in ad714x_touchpad_state_machine()
827 touchpad_cal_abs_pos(ad714x, idx); in ad714x_touchpad_state_machine()
838 touchpad_cal_sensor_val(ad714x, idx); in ad714x_touchpad_state_machine()
839 touchpad_cal_highest_stage(ad714x, idx); in ad714x_touchpad_state_machine()
840 if ((!touchpad_check_second_peak(ad714x, idx)) in ad714x_touchpad_state_machine()
841 && (!touchpad_check_endpoint(ad714x, idx))) { in ad714x_touchpad_state_machine()
842 touchpad_cal_abs_pos(ad714x, idx); in ad714x_touchpad_state_machine()
843 touchpad_cal_flt_pos(ad714x, idx); in ad714x_touchpad_state_machine()
855 touchpad_use_thr_int(ad714x, idx); in ad714x_touchpad_state_machine()
858 dev_dbg(ad714x->dev, "touchpad %d released\n", in ad714x_touchpad_state_machine()
870 static int ad714x_hw_detect(struct ad714x_chip *ad714x) in ad714x_hw_detect() argument
874 ad714x->read(ad714x, AD714X_PARTID_REG, &data, 1); in ad714x_hw_detect()
877 ad714x->product = 0x7142; in ad714x_hw_detect()
878 ad714x->version = data & 0xF; in ad714x_hw_detect()
879 dev_info(ad714x->dev, "found AD7142 captouch, rev:%d\n", in ad714x_hw_detect()
880 ad714x->version); in ad714x_hw_detect()
884 ad714x->product = 0x7143; in ad714x_hw_detect()
885 ad714x->version = data & 0xF; in ad714x_hw_detect()
886 dev_info(ad714x->dev, "found AD7143 captouch, rev:%d\n", in ad714x_hw_detect()
887 ad714x->version); in ad714x_hw_detect()
891 ad714x->product = 0x7147; in ad714x_hw_detect()
892 ad714x->version = data & 0xF; in ad714x_hw_detect()
893 dev_info(ad714x->dev, "found AD7147(A) captouch, rev:%d\n", in ad714x_hw_detect()
894 ad714x->version); in ad714x_hw_detect()
898 ad714x->product = 0x7148; in ad714x_hw_detect()
899 ad714x->version = data & 0xF; in ad714x_hw_detect()
900 dev_info(ad714x->dev, "found AD7148 captouch, rev:%d\n", in ad714x_hw_detect()
901 ad714x->version); in ad714x_hw_detect()
905 dev_err(ad714x->dev, in ad714x_hw_detect()
912 static void ad714x_hw_init(struct ad714x_chip *ad714x) in ad714x_hw_init() argument
923 ad714x->write(ad714x, reg_base + j, in ad714x_hw_init()
924 ad714x->hw->stage_cfg_reg[i][j]); in ad714x_hw_init()
928 ad714x->write(ad714x, AD714X_SYSCFG_REG + i, in ad714x_hw_init()
929 ad714x->hw->sys_cfg_reg[i]); in ad714x_hw_init()
931 ad714x->read(ad714x, AD714X_SYSCFG_REG + i, &data, 1); in ad714x_hw_init()
933 ad714x->write(ad714x, AD714X_STG_CAL_EN_REG, 0xFFF); in ad714x_hw_init()
936 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); in ad714x_hw_init()
941 struct ad714x_chip *ad714x = data; in ad714x_interrupt_thread() local
944 guard(mutex)(&ad714x->mutex); in ad714x_interrupt_thread()
946 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); in ad714x_interrupt_thread()
948 for (i = 0; i < ad714x->hw->button_num; i++) in ad714x_interrupt_thread()
949 ad714x_button_state_machine(ad714x, i); in ad714x_interrupt_thread()
950 for (i = 0; i < ad714x->hw->slider_num; i++) in ad714x_interrupt_thread()
951 ad714x_slider_state_machine(ad714x, i); in ad714x_interrupt_thread()
952 for (i = 0; i < ad714x->hw->wheel_num; i++) in ad714x_interrupt_thread()
953 ad714x_wheel_state_machine(ad714x, i); in ad714x_interrupt_thread()
954 for (i = 0; i < ad714x->hw->touchpad_num; i++) in ad714x_interrupt_thread()
955 ad714x_touchpad_state_machine(ad714x, i); in ad714x_interrupt_thread()
968 struct ad714x_chip *ad714x; in ad714x_probe() local
990 ad714x = devm_kzalloc(dev, sizeof(*ad714x) + sizeof(*ad714x->sw) + in ad714x_probe()
996 if (!ad714x) { in ad714x_probe()
1000 ad714x->hw = plat_data; in ad714x_probe()
1002 drv_mem = ad714x + 1; in ad714x_probe()
1003 ad714x->sw = drv_mem; in ad714x_probe()
1004 drv_mem += sizeof(*ad714x->sw); in ad714x_probe()
1005 ad714x->sw->slider = sd_drv = drv_mem; in ad714x_probe()
1006 drv_mem += sizeof(*sd_drv) * ad714x->hw->slider_num; in ad714x_probe()
1007 ad714x->sw->wheel = wl_drv = drv_mem; in ad714x_probe()
1008 drv_mem += sizeof(*wl_drv) * ad714x->hw->wheel_num; in ad714x_probe()
1009 ad714x->sw->touchpad = tp_drv = drv_mem; in ad714x_probe()
1010 drv_mem += sizeof(*tp_drv) * ad714x->hw->touchpad_num; in ad714x_probe()
1011 ad714x->sw->button = bt_drv = drv_mem; in ad714x_probe()
1012 drv_mem += sizeof(*bt_drv) * ad714x->hw->button_num; in ad714x_probe()
1014 ad714x->read = read; in ad714x_probe()
1015 ad714x->write = write; in ad714x_probe()
1016 ad714x->irq = irq; in ad714x_probe()
1017 ad714x->dev = dev; in ad714x_probe()
1019 error = ad714x_hw_detect(ad714x); in ad714x_probe()
1025 ad714x_hw_init(ad714x); in ad714x_probe()
1026 mutex_init(&ad714x->mutex); in ad714x_probe()
1029 if (ad714x->hw->slider_num > 0) { in ad714x_probe()
1030 struct ad714x_slider_plat *sd_plat = ad714x->hw->slider; in ad714x_probe()
1032 for (i = 0; i < ad714x->hw->slider_num; i++) { in ad714x_probe()
1045 input->id.product = ad714x->product; in ad714x_probe()
1046 input->id.version = ad714x->version; in ad714x_probe()
1059 if (ad714x->hw->wheel_num > 0) { in ad714x_probe()
1060 struct ad714x_wheel_plat *wl_plat = ad714x->hw->wheel; in ad714x_probe()
1062 for (i = 0; i < ad714x->hw->wheel_num; i++) { in ad714x_probe()
1075 input->id.product = ad714x->product; in ad714x_probe()
1076 input->id.version = ad714x->version; in ad714x_probe()
1089 if (ad714x->hw->touchpad_num > 0) { in ad714x_probe()
1090 struct ad714x_touchpad_plat *tp_plat = ad714x->hw->touchpad; in ad714x_probe()
1092 for (i = 0; i < ad714x->hw->touchpad_num; i++) { in ad714x_probe()
1108 input->id.product = ad714x->product; in ad714x_probe()
1109 input->id.version = ad714x->version; in ad714x_probe()
1122 if (ad714x->hw->button_num > 0) { in ad714x_probe()
1123 struct ad714x_button_plat *bt_plat = ad714x->hw->button; in ad714x_probe()
1132 for (i = 0; i < ad714x->hw->button_num; i++) { in ad714x_probe()
1138 input->id.product = ad714x->product; in ad714x_probe()
1139 input->id.version = ad714x->version; in ad714x_probe()
1151 error = devm_request_threaded_irq(dev, ad714x->irq, NULL, in ad714x_probe()
1153 irqflags, "ad714x_captouch", ad714x); in ad714x_probe()
1155 dev_err(dev, "can't allocate irq %d\n", ad714x->irq); in ad714x_probe()
1159 return ad714x; in ad714x_probe()
1165 struct ad714x_chip *ad714x = dev_get_drvdata(dev); in ad714x_suspend() local
1168 dev_dbg(ad714x->dev, "%s enter\n", __func__); in ad714x_suspend()
1170 guard(mutex)(&ad714x->mutex); in ad714x_suspend()
1172 data = ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL] | 0x3; in ad714x_suspend()
1173 ad714x->write(ad714x, AD714X_PWR_CTRL, data); in ad714x_suspend()
1180 struct ad714x_chip *ad714x = dev_get_drvdata(dev); in ad714x_resume() local
1181 dev_dbg(ad714x->dev, "%s enter\n", __func__); in ad714x_resume()
1183 guard(mutex)(&ad714x->mutex); in ad714x_resume()
1187 ad714x->write(ad714x, AD714X_PWR_CTRL, in ad714x_resume()
1188 ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL]); in ad714x_resume()
1194 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); in ad714x_resume()