H A D | ad714x.c | 13 #include <linux/input/ad714x.h> 15 #include "ad714x.h" 127 static void ad714x_use_com_int(struct ad714x_chip *ad714x, ad714x_use_com_int() argument 135 ad714x->read(ad714x, STG_COM_INT_EN_REG, &data, 1); ad714x_use_com_int() 137 ad714x->write(ad714x, STG_COM_INT_EN_REG, data); ad714x_use_com_int() 139 ad714x->read(ad714x, STG_HIGH_INT_EN_REG, &data, 1); ad714x_use_com_int() 141 ad714x->write(ad714x, STG_HIGH_INT_EN_REG, data); ad714x_use_com_int() 144 static void ad714x_use_thr_int(struct ad714x_chip *ad714x, ad714x_use_thr_int() argument 152 ad714x->read(ad714x, STG_COM_INT_EN_REG, &data, 1); ad714x_use_thr_int() 154 ad714x->write(ad714x, STG_COM_INT_EN_REG, data); ad714x_use_thr_int() 156 ad714x->read(ad714x, STG_HIGH_INT_EN_REG, &data, 1); ad714x_use_thr_int() 158 ad714x->write(ad714x, STG_HIGH_INT_EN_REG, data); ad714x_use_thr_int() 161 static int ad714x_cal_highest_stage(struct ad714x_chip *ad714x, ad714x_cal_highest_stage() argument 169 if (ad714x->sensor_val[i] > max_res) { ad714x_cal_highest_stage() 170 max_res = ad714x->sensor_val[i]; ad714x_cal_highest_stage() 178 static int ad714x_cal_abs_pos(struct ad714x_chip *ad714x, ad714x_cal_abs_pos() argument 185 a_param = ad714x->sensor_val[start_stage + 1]; ad714x_cal_abs_pos() 186 b_param = ad714x->sensor_val[start_stage] + ad714x_cal_abs_pos() 187 ad714x->sensor_val[start_stage + 1]; ad714x_cal_abs_pos() 189 a_param = ad714x->sensor_val[end_stage] * ad714x_cal_abs_pos() 191 ad714x->sensor_val[end_stage - 1] * ad714x_cal_abs_pos() 193 b_param = ad714x->sensor_val[end_stage] + ad714x_cal_abs_pos() 194 ad714x->sensor_val[end_stage - 1]; ad714x_cal_abs_pos() 196 a_param = ad714x->sensor_val[highest_stage] * ad714x_cal_abs_pos() 198 ad714x->sensor_val[highest_stage - 1] * ad714x_cal_abs_pos() 200 ad714x->sensor_val[highest_stage + 1] * ad714x_cal_abs_pos() 202 b_param = ad714x->sensor_val[highest_stage] + ad714x_cal_abs_pos() 203 ad714x->sensor_val[highest_stage - 1] + ad714x_cal_abs_pos() 204 ad714x->sensor_val[highest_stage + 1]; ad714x_cal_abs_pos() 214 static void ad714x_button_state_machine(struct ad714x_chip *ad714x, int idx) ad714x_button_state_machine() argument 216 struct ad714x_button_plat *hw = &ad714x->hw->button[idx]; ad714x_button_state_machine() 217 struct ad714x_button_drv *sw = &ad714x->sw->button[idx]; ad714x_button_state_machine() 221 if (((ad714x->h_state & hw->h_mask) == hw->h_mask) && ad714x_button_state_machine() 222 ((ad714x->l_state & hw->l_mask) == hw->l_mask)) { ad714x_button_state_machine() 223 dev_dbg(ad714x->dev, "button %d touched\n", idx); ad714x_button_state_machine() 231 if (((ad714x->h_state & hw->h_mask) != hw->h_mask) || ad714x_button_state_machine() 232 ((ad714x->l_state & hw->l_mask) != hw->l_mask)) { ad714x_button_state_machine() 233 dev_dbg(ad714x->dev, "button %d released\n", idx); ad714x_button_state_machine() 249 static void ad714x_slider_cal_sensor_val(struct ad714x_chip *ad714x, int idx) ad714x_slider_cal_sensor_val() argument 251 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; ad714x_slider_cal_sensor_val() 254 ad714x->read(ad714x, CDC_RESULT_S0 + hw->start_stage, ad714x_slider_cal_sensor_val() 255 &ad714x->adc_reg[hw->start_stage], ad714x_slider_cal_sensor_val() 259 ad714x->read(ad714x, STAGE0_AMBIENT + i * PER_STAGE_REG_NUM, ad714x_slider_cal_sensor_val() 260 &ad714x->amb_reg[i], 1); ad714x_slider_cal_sensor_val() 262 ad714x->sensor_val[i] = ad714x_slider_cal_sensor_val() 263 abs(ad714x->adc_reg[i] - ad714x->amb_reg[i]); ad714x_slider_cal_sensor_val() 267 static void ad714x_slider_cal_highest_stage(struct ad714x_chip *ad714x, int idx) ad714x_slider_cal_highest_stage() argument 269 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; ad714x_slider_cal_highest_stage() 270 struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx]; ad714x_slider_cal_highest_stage() 272 sw->highest_stage = ad714x_cal_highest_stage(ad714x, hw->start_stage, ad714x_slider_cal_highest_stage() 275 dev_dbg(ad714x->dev, "slider %d highest_stage:%d\n", idx, ad714x_slider_cal_highest_stage() 292 static void ad714x_slider_cal_abs_pos(struct ad714x_chip *ad714x, int idx) ad714x_slider_cal_abs_pos() argument 294 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; ad714x_slider_cal_abs_pos() 295 struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx]; ad714x_slider_cal_abs_pos() 297 sw->abs_pos = ad714x_cal_abs_pos(ad714x, hw->start_stage, hw->end_stage, ad714x_slider_cal_abs_pos() 300 dev_dbg(ad714x->dev, "slider %d absolute position:%d\n", idx, ad714x_slider_cal_abs_pos() 314 static void ad714x_slider_cal_flt_pos(struct ad714x_chip *ad714x, int idx) ad714x_slider_cal_flt_pos() argument 316 struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx]; ad714x_slider_cal_flt_pos() 321 dev_dbg(ad714x->dev, "slider %d filter position:%d\n", idx, ad714x_slider_cal_flt_pos() 325 static void ad714x_slider_use_com_int(struct ad714x_chip *ad714x, int idx) ad714x_slider_use_com_int() argument 327 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; ad714x_slider_use_com_int() 329 ad714x_use_com_int(ad714x, hw->start_stage, hw->end_stage); ad714x_slider_use_com_int() 332 static void ad714x_slider_use_thr_int(struct ad714x_chip *ad714x, int idx) ad714x_slider_use_thr_int() argument 334 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; ad714x_slider_use_thr_int() 336 ad714x_use_thr_int(ad714x, hw->start_stage, hw->end_stage); ad714x_slider_use_thr_int() 339 static void ad714x_slider_state_machine(struct ad714x_chip *ad714x, int idx) ad714x_slider_state_machine() argument 341 struct ad714x_slider_plat *hw = &ad714x->hw->slider[idx]; ad714x_slider_state_machine() 342 struct ad714x_slider_drv *sw = &ad714x->sw->slider[idx]; ad714x_slider_state_machine() 348 h_state = ad714x->h_state & mask; ad714x_slider_state_machine() 349 c_state = ad714x->c_state & mask; ad714x_slider_state_machine() 358 ad714x_slider_use_com_int(ad714x, idx); ad714x_slider_state_machine() 359 dev_dbg(ad714x->dev, "slider %d touched\n", idx); ad714x_slider_state_machine() 365 ad714x_slider_cal_sensor_val(ad714x, idx); ad714x_slider_state_machine() 366 ad714x_slider_cal_highest_stage(ad714x, idx); ad714x_slider_state_machine() 367 ad714x_slider_cal_abs_pos(ad714x, idx); ad714x_slider_state_machine() 376 ad714x_slider_cal_sensor_val(ad714x, idx); ad714x_slider_state_machine() 377 ad714x_slider_cal_highest_stage(ad714x, idx); ad714x_slider_state_machine() 378 ad714x_slider_cal_abs_pos(ad714x, idx); ad714x_slider_state_machine() 379 ad714x_slider_cal_flt_pos(ad714x, idx); ad714x_slider_state_machine() 386 ad714x_slider_use_thr_int(ad714x, idx); ad714x_slider_state_machine() 389 dev_dbg(ad714x->dev, "slider %d released\n", ad714x_slider_state_machine() 408 static void ad714x_wheel_cal_highest_stage(struct ad714x_chip *ad714x, int idx) ad714x_wheel_cal_highest_stage() argument 410 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; ad714x_wheel_cal_highest_stage() 411 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; ad714x_wheel_cal_highest_stage() 414 sw->highest_stage = ad714x_cal_highest_stage(ad714x, hw->start_stage, ad714x_wheel_cal_highest_stage() 417 dev_dbg(ad714x->dev, "wheel %d highest_stage:%d\n", idx, ad714x_wheel_cal_highest_stage() 421 static void ad714x_wheel_cal_sensor_val(struct ad714x_chip *ad714x, int idx) ad714x_wheel_cal_sensor_val() argument 423 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; ad714x_wheel_cal_sensor_val() 426 ad714x->read(ad714x, CDC_RESULT_S0 + hw->start_stage, ad714x_wheel_cal_sensor_val() 427 &ad714x->adc_reg[hw->start_stage], ad714x_wheel_cal_sensor_val() 431 ad714x->read(ad714x, STAGE0_AMBIENT + i * PER_STAGE_REG_NUM, ad714x_wheel_cal_sensor_val() 432 &ad714x->amb_reg[i], 1); ad714x_wheel_cal_sensor_val() 433 if (ad714x->adc_reg[i] > ad714x->amb_reg[i]) ad714x_wheel_cal_sensor_val() 434 ad714x->sensor_val[i] = ad714x_wheel_cal_sensor_val() 435 ad714x->adc_reg[i] - ad714x->amb_reg[i]; ad714x_wheel_cal_sensor_val() 437 ad714x->sensor_val[i] = 0; ad714x_wheel_cal_sensor_val() 450 static void ad714x_wheel_cal_abs_pos(struct ad714x_chip *ad714x, int idx) ad714x_wheel_cal_abs_pos() argument 452 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; ad714x_wheel_cal_abs_pos() 453 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; ad714x_wheel_cal_abs_pos() 462 a_param = ad714x->sensor_val[highest] * ad714x_wheel_cal_abs_pos() 464 ad714x->sensor_val[first_before] * ad714x_wheel_cal_abs_pos() 466 ad714x->sensor_val[first_after] * ad714x_wheel_cal_abs_pos() 468 b_param = ad714x->sensor_val[highest] + ad714x_wheel_cal_abs_pos() 469 ad714x->sensor_val[first_before] + ad714x_wheel_cal_abs_pos() 470 ad714x->sensor_val[first_after]; ad714x_wheel_cal_abs_pos() 481 static void ad714x_wheel_cal_flt_pos(struct ad714x_chip *ad714x, int idx) ad714x_wheel_cal_flt_pos() argument 483 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; ad714x_wheel_cal_flt_pos() 484 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; ad714x_wheel_cal_flt_pos() 497 static void ad714x_wheel_use_com_int(struct ad714x_chip *ad714x, int idx) ad714x_wheel_use_com_int() argument 499 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; ad714x_wheel_use_com_int() 501 ad714x_use_com_int(ad714x, hw->start_stage, hw->end_stage); ad714x_wheel_use_com_int() 504 static void ad714x_wheel_use_thr_int(struct ad714x_chip *ad714x, int idx) ad714x_wheel_use_thr_int() argument 506 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; ad714x_wheel_use_thr_int() 508 ad714x_use_thr_int(ad714x, hw->start_stage, hw->end_stage); ad714x_wheel_use_thr_int() 511 static void ad714x_wheel_state_machine(struct ad714x_chip *ad714x, int idx) ad714x_wheel_state_machine() argument 513 struct ad714x_wheel_plat *hw = &ad714x->hw->wheel[idx]; ad714x_wheel_state_machine() 514 struct ad714x_wheel_drv *sw = &ad714x->sw->wheel[idx]; ad714x_wheel_state_machine() 520 h_state = ad714x->h_state & mask; ad714x_wheel_state_machine() 521 c_state = ad714x->c_state & mask; ad714x_wheel_state_machine() 530 ad714x_wheel_use_com_int(ad714x, idx); ad714x_wheel_state_machine() 531 dev_dbg(ad714x->dev, "wheel %d touched\n", idx); ad714x_wheel_state_machine() 537 ad714x_wheel_cal_sensor_val(ad714x, idx); ad714x_wheel_state_machine() 538 ad714x_wheel_cal_highest_stage(ad714x, idx); ad714x_wheel_state_machine() 539 ad714x_wheel_cal_abs_pos(ad714x, idx); ad714x_wheel_state_machine() 548 ad714x_wheel_cal_sensor_val(ad714x, idx); ad714x_wheel_state_machine() 549 ad714x_wheel_cal_highest_stage(ad714x, idx); ad714x_wheel_state_machine() 550 ad714x_wheel_cal_abs_pos(ad714x, idx); ad714x_wheel_state_machine() 551 ad714x_wheel_cal_flt_pos(ad714x, idx); ad714x_wheel_state_machine() 559 ad714x_wheel_use_thr_int(ad714x, idx); ad714x_wheel_state_machine() 563 dev_dbg(ad714x->dev, "wheel %d released\n", ad714x_wheel_state_machine() 575 static void touchpad_cal_sensor_val(struct ad714x_chip *ad714x, int idx) touchpad_cal_sensor_val() argument 577 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; touchpad_cal_sensor_val() 580 ad714x->read(ad714x, CDC_RESULT_S0 + hw->x_start_stage, touchpad_cal_sensor_val() 581 &ad714x->adc_reg[hw->x_start_stage], touchpad_cal_sensor_val() 585 ad714x->read(ad714x, STAGE0_AMBIENT + i * PER_STAGE_REG_NUM, touchpad_cal_sensor_val() 586 &ad714x->amb_reg[i], 1); touchpad_cal_sensor_val() 587 if (ad714x->adc_reg[i] > ad714x->amb_reg[i]) touchpad_cal_sensor_val() 588 ad714x->sensor_val[i] = touchpad_cal_sensor_val() 589 ad714x->adc_reg[i] - ad714x->amb_reg[i]; touchpad_cal_sensor_val() 591 ad714x->sensor_val[i] = 0; touchpad_cal_sensor_val() 595 static void touchpad_cal_highest_stage(struct ad714x_chip *ad714x, int idx) touchpad_cal_highest_stage() argument 597 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; touchpad_cal_highest_stage() 598 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; touchpad_cal_highest_stage() 600 sw->x_highest_stage = ad714x_cal_highest_stage(ad714x, touchpad_cal_highest_stage() 602 sw->y_highest_stage = ad714x_cal_highest_stage(ad714x, touchpad_cal_highest_stage() 605 dev_dbg(ad714x->dev, touchpad_cal_highest_stage() 616 static int touchpad_check_second_peak(struct ad714x_chip *ad714x, int idx) touchpad_check_second_peak() argument 618 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; touchpad_check_second_peak() 619 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; touchpad_check_second_peak() 623 if ((ad714x->sensor_val[i] - ad714x->sensor_val[i + 1]) touchpad_check_second_peak() 624 > (ad714x->sensor_val[i + 1] / 10)) touchpad_check_second_peak() 629 if ((ad714x->sensor_val[i + 1] - ad714x->sensor_val[i]) touchpad_check_second_peak() 630 > (ad714x->sensor_val[i] / 10)) touchpad_check_second_peak() 635 if ((ad714x->sensor_val[i] - ad714x->sensor_val[i + 1]) touchpad_check_second_peak() 636 > (ad714x->sensor_val[i + 1] / 10)) touchpad_check_second_peak() 641 if ((ad714x->sensor_val[i + 1] - ad714x->sensor_val[i]) touchpad_check_second_peak() 642 > (ad714x->sensor_val[i] / 10)) touchpad_check_second_peak() 655 static void touchpad_cal_abs_pos(struct ad714x_chip *ad714x, int idx) touchpad_cal_abs_pos() argument 657 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; touchpad_cal_abs_pos() 658 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; touchpad_cal_abs_pos() 660 sw->x_abs_pos = ad714x_cal_abs_pos(ad714x, hw->x_start_stage, touchpad_cal_abs_pos() 662 sw->y_abs_pos = ad714x_cal_abs_pos(ad714x, hw->y_start_stage, touchpad_cal_abs_pos() 665 dev_dbg(ad714x->dev, "touchpad %d absolute position:(%d, %d)\n", idx, touchpad_cal_abs_pos() 669 static void touchpad_cal_flt_pos(struct ad714x_chip *ad714x, int idx) touchpad_cal_flt_pos() argument 671 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; touchpad_cal_flt_pos() 678 dev_dbg(ad714x->dev, "touchpad %d filter position:(%d, %d)\n", touchpad_cal_flt_pos() 700 static int touchpad_check_endpoint(struct ad714x_chip *ad714x, int idx) touchpad_check_endpoint() argument 702 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; touchpad_check_endpoint() 703 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; touchpad_check_endpoint() 707 percent_sensor_diff = (ad714x->sensor_val[hw->x_start_stage] - touchpad_check_endpoint() 708 ad714x->sensor_val[hw->x_start_stage + 1]) * 100 / touchpad_check_endpoint() 709 ad714x->sensor_val[hw->x_start_stage + 1]; touchpad_check_endpoint() 714 ad714x->sensor_val[hw->x_start_stage + 1]; touchpad_check_endpoint() 718 (ad714x->sensor_val[hw->x_start_stage + 1] > touchpad_check_endpoint() 724 percent_sensor_diff = (ad714x->sensor_val[hw->x_end_stage] - touchpad_check_endpoint() 725 ad714x->sensor_val[hw->x_end_stage - 1]) * 100 / touchpad_check_endpoint() 726 ad714x->sensor_val[hw->x_end_stage - 1]; touchpad_check_endpoint() 731 ad714x->sensor_val[hw->x_end_stage - 1]; touchpad_check_endpoint() 735 (ad714x->sensor_val[hw->x_end_stage - 1] > touchpad_check_endpoint() 741 percent_sensor_diff = (ad714x->sensor_val[hw->y_start_stage] - touchpad_check_endpoint() 742 ad714x->sensor_val[hw->y_start_stage + 1]) * 100 / touchpad_check_endpoint() 743 ad714x->sensor_val[hw->y_start_stage + 1]; touchpad_check_endpoint() 748 ad714x->sensor_val[hw->y_start_stage + 1]; touchpad_check_endpoint() 752 (ad714x->sensor_val[hw->y_start_stage + 1] > touchpad_check_endpoint() 758 percent_sensor_diff = (ad714x->sensor_val[hw->y_end_stage] - touchpad_check_endpoint() 759 ad714x->sensor_val[hw->y_end_stage - 1]) * 100 / touchpad_check_endpoint() 760 ad714x->sensor_val[hw->y_end_stage - 1]; touchpad_check_endpoint() 765 ad714x->sensor_val[hw->y_end_stage - 1]; touchpad_check_endpoint() 769 (ad714x->sensor_val[hw->y_end_stage - 1] > touchpad_check_endpoint() 777 static void touchpad_use_com_int(struct ad714x_chip *ad714x, int idx) touchpad_use_com_int() argument 779 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; touchpad_use_com_int() 781 ad714x_use_com_int(ad714x, hw->x_start_stage, hw->x_end_stage); touchpad_use_com_int() 784 static void touchpad_use_thr_int(struct ad714x_chip *ad714x, int idx) touchpad_use_thr_int() argument 786 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; touchpad_use_thr_int() 788 ad714x_use_thr_int(ad714x, hw->x_start_stage, hw->x_end_stage); touchpad_use_thr_int() 789 ad714x_use_thr_int(ad714x, hw->y_start_stage, hw->y_end_stage); touchpad_use_thr_int() 792 static void ad714x_touchpad_state_machine(struct ad714x_chip *ad714x, int idx) ad714x_touchpad_state_machine() argument 794 struct ad714x_touchpad_plat *hw = &ad714x->hw->touchpad[idx]; ad714x_touchpad_state_machine() 795 struct ad714x_touchpad_drv *sw = &ad714x->sw->touchpad[idx]; ad714x_touchpad_state_machine() 804 h_state = ad714x->h_state & mask; ad714x_touchpad_state_machine() 805 c_state = ad714x->c_state & mask; ad714x_touchpad_state_machine() 814 touchpad_use_com_int(ad714x, idx); ad714x_touchpad_state_machine() 815 dev_dbg(ad714x->dev, "touchpad %d touched\n", idx); ad714x_touchpad_state_machine() 821 touchpad_cal_sensor_val(ad714x, idx); ad714x_touchpad_state_machine() 822 touchpad_cal_highest_stage(ad714x, idx); ad714x_touchpad_state_machine() 823 if ((!touchpad_check_second_peak(ad714x, idx)) && ad714x_touchpad_state_machine() 824 (!touchpad_check_endpoint(ad714x, idx))) { ad714x_touchpad_state_machine() 825 dev_dbg(ad714x->dev, ad714x_touchpad_state_machine() 828 touchpad_cal_abs_pos(ad714x, idx); ad714x_touchpad_state_machine() 839 touchpad_cal_sensor_val(ad714x, idx); ad714x_touchpad_state_machine() 840 touchpad_cal_highest_stage(ad714x, idx); ad714x_touchpad_state_machine() 841 if ((!touchpad_check_second_peak(ad714x, idx)) ad714x_touchpad_state_machine() 842 && (!touchpad_check_endpoint(ad714x, idx))) { ad714x_touchpad_state_machine() 843 touchpad_cal_abs_pos(ad714x, idx); ad714x_touchpad_state_machine() 844 touchpad_cal_flt_pos(ad714x, idx); ad714x_touchpad_state_machine() 856 touchpad_use_thr_int(ad714x, idx); ad714x_touchpad_state_machine() 859 dev_dbg(ad714x->dev, "touchpad %d released\n", ad714x_touchpad_state_machine() 871 static int ad714x_hw_detect(struct ad714x_chip *ad714x) ad714x_hw_detect() argument 875 ad714x->read(ad714x, AD714X_PARTID_REG, &data, 1); ad714x_hw_detect() 878 ad714x->product = 0x7142; ad714x_hw_detect() 879 ad714x->version = data & 0xF; ad714x_hw_detect() 880 dev_info(ad714x->dev, "found AD7142 captouch, rev:%d\n", ad714x_hw_detect() 881 ad714x->version); ad714x_hw_detect() 885 ad714x->product = 0x7143; ad714x_hw_detect() 886 ad714x->version = data & 0xF; ad714x_hw_detect() 887 dev_info(ad714x->dev, "found AD7143 captouch, rev:%d\n", ad714x_hw_detect() 888 ad714x->version); ad714x_hw_detect() 892 ad714x->product = 0x7147; ad714x_hw_detect() 893 ad714x->version = data & 0xF; ad714x_hw_detect() 894 dev_info(ad714x->dev, "found AD7147(A) captouch, rev:%d\n", ad714x_hw_detect() 895 ad714x->version); ad714x_hw_detect() 899 ad714x->product = 0x7148; ad714x_hw_detect() 900 ad714x->version = data & 0xF; ad714x_hw_detect() 901 dev_info(ad714x->dev, "found AD7148 captouch, rev:%d\n", ad714x_hw_detect() 902 ad714x->version); ad714x_hw_detect() 906 dev_err(ad714x->dev, ad714x_hw_detect() 913 static void ad714x_hw_init(struct ad714x_chip *ad714x) ad714x_hw_init() argument 924 ad714x->write(ad714x, reg_base + j, ad714x_hw_init() 925 ad714x->hw->stage_cfg_reg[i][j]); ad714x_hw_init() 929 ad714x->write(ad714x, AD714X_SYSCFG_REG + i, ad714x_hw_init() 930 ad714x->hw->sys_cfg_reg[i]); ad714x_hw_init() 932 ad714x->read(ad714x, AD714X_SYSCFG_REG + i, &data, 1); ad714x_hw_init() 934 ad714x->write(ad714x, AD714X_STG_CAL_EN_REG, 0xFFF); ad714x_hw_init() 937 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); ad714x_hw_init() 942 struct ad714x_chip *ad714x = data; ad714x_interrupt_thread() local 945 mutex_lock(&ad714x->mutex); ad714x_interrupt_thread() 947 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); ad714x_interrupt_thread() 949 for (i = 0; i < ad714x->hw->button_num; i++) ad714x_interrupt_thread() 950 ad714x_button_state_machine(ad714x, i); ad714x_interrupt_thread() 951 for (i = 0; i < ad714x->hw->slider_num; i++) ad714x_interrupt_thread() 952 ad714x_slider_state_machine(ad714x, i); ad714x_interrupt_thread() 953 for (i = 0; i < ad714x->hw->wheel_num; i++) ad714x_interrupt_thread() 954 ad714x_wheel_state_machine(ad714x, i); ad714x_interrupt_thread() 955 for (i = 0; i < ad714x->hw->touchpad_num; i++) ad714x_interrupt_thread() 956 ad714x_touchpad_state_machine(ad714x, i); ad714x_interrupt_thread() 958 mutex_unlock(&ad714x->mutex); ad714x_interrupt_thread() 972 struct ad714x_chip *ad714x; ad714x_probe() local 989 dev_err(dev, "platform data for ad714x doesn't exist\n"); ad714x_probe() 994 ad714x = kzalloc(sizeof(*ad714x) + sizeof(*ad714x->sw) + ad714x_probe() 999 if (!ad714x) { ad714x_probe() 1004 ad714x->hw = plat_data; ad714x_probe() 1006 drv_mem = ad714x + 1; ad714x_probe() 1007 ad714x->sw = drv_mem; ad714x_probe() 1008 drv_mem += sizeof(*ad714x->sw); ad714x_probe() 1009 ad714x->sw->slider = sd_drv = drv_mem; ad714x_probe() 1010 drv_mem += sizeof(*sd_drv) * ad714x->hw->slider_num; ad714x_probe() 1011 ad714x->sw->wheel = wl_drv = drv_mem; ad714x_probe() 1012 drv_mem += sizeof(*wl_drv) * ad714x->hw->wheel_num; ad714x_probe() 1013 ad714x->sw->touchpad = tp_drv = drv_mem; ad714x_probe() 1014 drv_mem += sizeof(*tp_drv) * ad714x->hw->touchpad_num; ad714x_probe() 1015 ad714x->sw->button = bt_drv = drv_mem; ad714x_probe() 1016 drv_mem += sizeof(*bt_drv) * ad714x->hw->button_num; ad714x_probe() 1018 ad714x->read = read; ad714x_probe() 1019 ad714x->write = write; ad714x_probe() 1020 ad714x->irq = irq; ad714x_probe() 1021 ad714x->dev = dev; ad714x_probe() 1023 error = ad714x_hw_detect(ad714x); ad714x_probe() 1029 ad714x_hw_init(ad714x); ad714x_probe() 1030 mutex_init(&ad714x->mutex); ad714x_probe() 1038 if (ad714x->hw->slider_num > 0) { ad714x_probe() 1039 struct ad714x_slider_plat *sd_plat = ad714x->hw->slider; ad714x_probe() 1041 for (i = 0; i < ad714x->hw->slider_num; i++) { ad714x_probe() 1056 input[alloc_idx]->id.product = ad714x->product; ad714x_probe() 1057 input[alloc_idx]->id.version = ad714x->version; ad714x_probe() 1070 if (ad714x->hw->wheel_num > 0) { ad714x_probe() 1071 struct ad714x_wheel_plat *wl_plat = ad714x->hw->wheel; ad714x_probe() 1073 for (i = 0; i < ad714x->hw->wheel_num; i++) { ad714x_probe() 1088 input[alloc_idx]->id.product = ad714x->product; ad714x_probe() 1089 input[alloc_idx]->id.version = ad714x->version; ad714x_probe() 1102 if (ad714x->hw->touchpad_num > 0) { ad714x_probe() 1103 struct ad714x_touchpad_plat *tp_plat = ad714x->hw->touchpad; ad714x_probe() 1105 for (i = 0; i < ad714x->hw->touchpad_num; i++) { ad714x_probe() 1123 input[alloc_idx]->id.product = ad714x->product; ad714x_probe() 1124 input[alloc_idx]->id.version = ad714x->version; ad714x_probe() 1137 if (ad714x->hw->button_num > 0) { ad714x_probe() 1138 struct ad714x_button_plat *bt_plat = ad714x->hw->button; ad714x_probe() 1147 for (i = 0; i < ad714x->hw->button_num; i++) { ad714x_probe() 1153 input[alloc_idx]->id.product = ad714x->product; ad714x_probe() 1154 input[alloc_idx]->id.version = ad714x->version; ad714x_probe() 1168 error = request_threaded_irq(ad714x->irq, NULL, ad714x_interrupt_thread, ad714x_probe() 1169 irqflags, "ad714x_captouch", ad714x); ad714x_probe() 1171 dev_err(dev, "can't allocate irq %d\n", ad714x->irq); ad714x_probe() 1175 return ad714x; ad714x_probe() 1184 kfree(ad714x); ad714x_probe() 1190 void ad714x_remove(struct ad714x_chip *ad714x) ad714x_remove() argument 1192 struct ad714x_platform_data *hw = ad714x->hw; ad714x_remove() 1193 struct ad714x_driver_data *sw = ad714x->sw; ad714x_remove() 1196 free_irq(ad714x->irq, ad714x); ad714x_remove() 1212 kfree(ad714x); ad714x_remove() 1217 int ad714x_disable(struct ad714x_chip *ad714x) ad714x_disable() argument 1221 dev_dbg(ad714x->dev, "%s enter\n", __func__); ad714x_disable() 1223 mutex_lock(&ad714x->mutex); ad714x_disable() 1225 data = ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL] | 0x3; ad714x_disable() 1226 ad714x->write(ad714x, AD714X_PWR_CTRL, data); ad714x_disable() 1228 mutex_unlock(&ad714x->mutex); ad714x_disable() 1234 int ad714x_enable(struct ad714x_chip *ad714x) ad714x_enable() argument 1236 dev_dbg(ad714x->dev, "%s enter\n", __func__); ad714x_enable() 1238 mutex_lock(&ad714x->mutex); ad714x_enable() 1242 ad714x->write(ad714x, AD714X_PWR_CTRL, ad714x_enable() 1243 ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL]); ad714x_enable() 1249 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); ad714x_enable() 1251 mutex_unlock(&ad714x->mutex); ad714x_enable()
|