Lines Matching refs:cyapa
229 static int cyapa_gen3_try_poll_handler(struct cyapa *cyapa);
244 ssize_t cyapa_smbus_read_block(struct cyapa *cyapa, u8 cmd, size_t len, in cyapa_smbus_read_block() argument
251 struct i2c_client *client = cyapa->client; in cyapa_smbus_read_block()
277 static s32 cyapa_read_byte(struct cyapa *cyapa, u8 cmd_idx) in cyapa_read_byte() argument
281 if (cyapa->smbus) { in cyapa_read_byte()
287 return i2c_smbus_read_byte_data(cyapa->client, cmd); in cyapa_read_byte()
290 static s32 cyapa_write_byte(struct cyapa *cyapa, u8 cmd_idx, u8 value) in cyapa_write_byte() argument
294 if (cyapa->smbus) { in cyapa_write_byte()
300 return i2c_smbus_write_byte_data(cyapa->client, cmd, value); in cyapa_write_byte()
303 ssize_t cyapa_i2c_reg_read_block(struct cyapa *cyapa, u8 reg, size_t len, in cyapa_i2c_reg_read_block() argument
306 return i2c_smbus_read_i2c_block_data(cyapa->client, reg, len, values); in cyapa_i2c_reg_read_block()
309 static ssize_t cyapa_i2c_reg_write_block(struct cyapa *cyapa, u8 reg, in cyapa_i2c_reg_write_block() argument
312 return i2c_smbus_write_i2c_block_data(cyapa->client, reg, len, values); in cyapa_i2c_reg_write_block()
315 ssize_t cyapa_read_block(struct cyapa *cyapa, u8 cmd_idx, u8 *values) in cyapa_read_block() argument
320 if (cyapa->smbus) { in cyapa_read_block()
323 return cyapa_smbus_read_block(cyapa, cmd, len, values); in cyapa_read_block()
327 return cyapa_i2c_reg_read_block(cyapa, cmd, len, values); in cyapa_read_block()
334 static int cyapa_gen3_state_parse(struct cyapa *cyapa, u8 *reg_data, int len) in cyapa_gen3_state_parse() argument
336 cyapa->state = CYAPA_STATE_NO_DEVICE; in cyapa_gen3_state_parse()
349 cyapa->gen = CYAPA_GEN3; in cyapa_gen3_state_parse()
350 cyapa->state = CYAPA_STATE_BL_IDLE; in cyapa_gen3_state_parse()
354 cyapa->gen = CYAPA_GEN3; in cyapa_gen3_state_parse()
356 cyapa->state = CYAPA_STATE_BL_BUSY; in cyapa_gen3_state_parse()
360 cyapa->state = CYAPA_STATE_BL_ACTIVE; in cyapa_gen3_state_parse()
362 cyapa->state = CYAPA_STATE_BL_IDLE; in cyapa_gen3_state_parse()
374 cyapa->gen = CYAPA_GEN3; in cyapa_gen3_state_parse()
375 cyapa->state = CYAPA_STATE_OP; in cyapa_gen3_state_parse()
380 cyapa->gen = CYAPA_GEN3; in cyapa_gen3_state_parse()
381 cyapa->state = CYAPA_STATE_OP; in cyapa_gen3_state_parse()
384 cyapa->gen = CYAPA_GEN3; in cyapa_gen3_state_parse()
385 cyapa->state = CYAPA_STATE_BL_BUSY; in cyapa_gen3_state_parse()
388 if (cyapa->gen == CYAPA_GEN3 && (cyapa->state == CYAPA_STATE_OP || in cyapa_gen3_state_parse()
389 cyapa->state == CYAPA_STATE_BL_IDLE || in cyapa_gen3_state_parse()
390 cyapa->state == CYAPA_STATE_BL_ACTIVE || in cyapa_gen3_state_parse()
391 cyapa->state == CYAPA_STATE_BL_BUSY)) in cyapa_gen3_state_parse()
409 static int cyapa_gen3_bl_enter(struct cyapa *cyapa) in cyapa_gen3_bl_enter() argument
414 error = cyapa_poll_state(cyapa, 500); in cyapa_gen3_bl_enter()
417 if (cyapa->state == CYAPA_STATE_BL_IDLE) { in cyapa_gen3_bl_enter()
422 if (cyapa->state != CYAPA_STATE_OP) in cyapa_gen3_bl_enter()
425 cyapa->operational = false; in cyapa_gen3_bl_enter()
426 cyapa->state = CYAPA_STATE_NO_DEVICE; in cyapa_gen3_bl_enter()
427 error = cyapa_write_byte(cyapa, CYAPA_CMD_SOFT_RESET, 0x01); in cyapa_gen3_bl_enter()
434 error = cyapa_poll_state(cyapa, 500); in cyapa_gen3_bl_enter()
443 if ((cyapa->state == CYAPA_STATE_BL_IDLE) && in cyapa_gen3_bl_enter()
444 !(cyapa->status[REG_BL_STATUS] & BL_STATUS_WATCHDOG)) in cyapa_gen3_bl_enter()
451 if ((cyapa->state != CYAPA_STATE_BL_IDLE) || in cyapa_gen3_bl_enter()
452 (cyapa->status[REG_BL_STATUS] & BL_STATUS_WATCHDOG)) in cyapa_gen3_bl_enter()
458 static int cyapa_gen3_bl_activate(struct cyapa *cyapa) in cyapa_gen3_bl_activate() argument
462 error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_activate), in cyapa_gen3_bl_activate()
469 error = cyapa_poll_state(cyapa, 11000); in cyapa_gen3_bl_activate()
472 if (cyapa->state != CYAPA_STATE_BL_ACTIVE) in cyapa_gen3_bl_activate()
478 static int cyapa_gen3_bl_deactivate(struct cyapa *cyapa) in cyapa_gen3_bl_deactivate() argument
482 error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_deactivate), in cyapa_gen3_bl_deactivate()
489 error = cyapa_poll_state(cyapa, 500); in cyapa_gen3_bl_deactivate()
492 if (cyapa->state != CYAPA_STATE_BL_IDLE) in cyapa_gen3_bl_deactivate()
510 static int cyapa_gen3_bl_exit(struct cyapa *cyapa) in cyapa_gen3_bl_exit() argument
514 error = cyapa_i2c_reg_write_block(cyapa, 0, sizeof(bl_exit), bl_exit); in cyapa_gen3_bl_exit()
529 error = cyapa_poll_state(cyapa, 4000); in cyapa_gen3_bl_exit()
532 if (cyapa->state != CYAPA_STATE_OP) in cyapa_gen3_bl_exit()
564 static int cyapa_gen3_check_fw(struct cyapa *cyapa, const struct firmware *fw) in cyapa_gen3_check_fw() argument
566 struct device *dev = &cyapa->client->dev; in cyapa_gen3_check_fw()
608 static int cyapa_gen3_write_buffer(struct cyapa *cyapa, in cyapa_gen3_write_buffer() argument
623 error = cyapa_i2c_reg_write_block(cyapa, 0, cmd_len + 1, cmd); in cyapa_gen3_write_buffer()
646 static int cyapa_gen3_write_fw_block(struct cyapa *cyapa, in cyapa_gen3_write_fw_block() argument
666 ret = cyapa_gen3_write_buffer(cyapa, (u8 *)&write_block_cmd, in cyapa_gen3_write_fw_block()
677 ret = cyapa_i2c_reg_read_block(cyapa, BL_HEAD_OFFSET, in cyapa_gen3_write_fw_block()
698 static int cyapa_gen3_write_blocks(struct cyapa *cyapa, in cyapa_gen3_write_blocks() argument
710 error = cyapa_gen3_write_fw_block(cyapa, block, data); in cyapa_gen3_write_blocks()
717 static int cyapa_gen3_do_fw_update(struct cyapa *cyapa, in cyapa_gen3_do_fw_update() argument
720 struct device *dev = &cyapa->client->dev; in cyapa_gen3_do_fw_update()
724 error = cyapa_gen3_write_blocks(cyapa, in cyapa_gen3_do_fw_update()
733 error = cyapa_gen3_write_blocks(cyapa, in cyapa_gen3_do_fw_update()
748 struct cyapa *cyapa = dev_get_drvdata(dev); in cyapa_gen3_do_calibrate() local
752 ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); in cyapa_gen3_do_calibrate()
764 ret = cyapa_write_byte(cyapa, CYAPA_CMD_SOFT_RESET, in cyapa_gen3_do_calibrate()
781 ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); in cyapa_gen3_do_calibrate()
802 struct cyapa *cyapa = dev_get_drvdata(dev); in cyapa_gen3_show_baseline() local
807 ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); in cyapa_gen3_show_baseline()
819 ret = cyapa_write_byte(cyapa, CYAPA_CMD_SOFT_RESET, in cyapa_gen3_show_baseline()
831 ret = cyapa_read_byte(cyapa, CYAPA_CMD_DEV_STATUS); in cyapa_gen3_show_baseline()
847 ret = cyapa_read_byte(cyapa, CYAPA_CMD_MAX_BASELINE); in cyapa_gen3_show_baseline()
854 ret = cyapa_read_byte(cyapa, CYAPA_CMD_MIN_BASELINE); in cyapa_gen3_show_baseline()
907 static int cyapa_gen3_set_power_mode(struct cyapa *cyapa, u8 power_mode, in cyapa_gen3_set_power_mode() argument
910 struct input_dev *input = cyapa->input; in cyapa_gen3_set_power_mode()
917 if (cyapa->state != CYAPA_STATE_OP) in cyapa_gen3_set_power_mode()
922 ret = cyapa_read_byte(cyapa, CYAPA_CMD_POWER_MODE); in cyapa_gen3_set_power_mode()
943 ret = cyapa_write_byte(cyapa, CYAPA_CMD_POWER_MODE, power); in cyapa_gen3_set_power_mode()
955 if (cyapa->operational && in cyapa_gen3_set_power_mode()
967 cyapa_gen3_try_poll_handler(cyapa); in cyapa_gen3_set_power_mode()
976 static int cyapa_gen3_set_proximity(struct cyapa *cyapa, bool enable) in cyapa_gen3_set_proximity() argument
981 static int cyapa_gen3_get_query_data(struct cyapa *cyapa) in cyapa_gen3_get_query_data() argument
986 if (cyapa->state != CYAPA_STATE_OP) in cyapa_gen3_get_query_data()
989 ret = cyapa_read_block(cyapa, CYAPA_CMD_GROUP_QUERY, query_data); in cyapa_gen3_get_query_data()
993 memcpy(&cyapa->product_id[0], &query_data[0], 5); in cyapa_gen3_get_query_data()
994 cyapa->product_id[5] = '-'; in cyapa_gen3_get_query_data()
995 memcpy(&cyapa->product_id[6], &query_data[5], 6); in cyapa_gen3_get_query_data()
996 cyapa->product_id[12] = '-'; in cyapa_gen3_get_query_data()
997 memcpy(&cyapa->product_id[13], &query_data[11], 2); in cyapa_gen3_get_query_data()
998 cyapa->product_id[15] = '\0'; in cyapa_gen3_get_query_data()
1000 cyapa->fw_maj_ver = query_data[15]; in cyapa_gen3_get_query_data()
1001 cyapa->fw_min_ver = query_data[16]; in cyapa_gen3_get_query_data()
1003 cyapa->btn_capability = query_data[19] & CAPABILITY_BTN_MASK; in cyapa_gen3_get_query_data()
1005 cyapa->gen = query_data[20] & 0x0f; in cyapa_gen3_get_query_data()
1007 cyapa->max_abs_x = ((query_data[21] & 0xf0) << 4) | query_data[22]; in cyapa_gen3_get_query_data()
1008 cyapa->max_abs_y = ((query_data[21] & 0x0f) << 8) | query_data[23]; in cyapa_gen3_get_query_data()
1010 cyapa->physical_size_x = in cyapa_gen3_get_query_data()
1012 cyapa->physical_size_y = in cyapa_gen3_get_query_data()
1015 cyapa->max_z = 255; in cyapa_gen3_get_query_data()
1020 static int cyapa_gen3_bl_query_data(struct cyapa *cyapa) in cyapa_gen3_bl_query_data() argument
1025 ret = cyapa_i2c_reg_read_block(cyapa, 0, CYAPA_CMD_LEN, bl_data); in cyapa_gen3_bl_query_data()
1037 cyapa->fw_maj_ver = bl_data[GEN3_BL_IDLE_FW_MAJ_VER_OFFSET]; in cyapa_gen3_bl_query_data()
1038 cyapa->fw_min_ver = bl_data[GEN3_BL_IDLE_FW_MIN_VER_OFFSET]; in cyapa_gen3_bl_query_data()
1058 static int cyapa_gen3_do_operational_check(struct cyapa *cyapa) in cyapa_gen3_do_operational_check() argument
1060 struct device *dev = &cyapa->client->dev; in cyapa_gen3_do_operational_check()
1063 switch (cyapa->state) { in cyapa_gen3_do_operational_check()
1065 error = cyapa_gen3_bl_deactivate(cyapa); in cyapa_gen3_do_operational_check()
1074 cyapa_gen3_bl_query_data(cyapa); in cyapa_gen3_do_operational_check()
1076 error = cyapa_gen3_bl_exit(cyapa); in cyapa_gen3_do_operational_check()
1088 error = cyapa_gen3_set_power_mode(cyapa, in cyapa_gen3_do_operational_check()
1093 error = cyapa_gen3_get_query_data(cyapa); in cyapa_gen3_do_operational_check()
1098 if (cyapa->gen != CYAPA_GEN3) { in cyapa_gen3_do_operational_check()
1100 cyapa->gen); in cyapa_gen3_do_operational_check()
1105 if (memcmp(cyapa->product_id, product_id, in cyapa_gen3_do_operational_check()
1108 cyapa->product_id); in cyapa_gen3_do_operational_check()
1124 static bool cyapa_gen3_irq_cmd_handler(struct cyapa *cyapa) in cyapa_gen3_irq_cmd_handler() argument
1127 if (cyapa->gen != CYAPA_GEN3) in cyapa_gen3_irq_cmd_handler()
1130 if (cyapa->operational) in cyapa_gen3_irq_cmd_handler()
1145 static int cyapa_gen3_event_process(struct cyapa *cyapa, in cyapa_gen3_event_process() argument
1148 struct input_dev *input = cyapa->input; in cyapa_gen3_event_process()
1169 if (cyapa->btn_capability & CAPABILITY_LEFT_BTN_MASK) in cyapa_gen3_event_process()
1172 if (cyapa->btn_capability & CAPABILITY_MIDDLE_BTN_MASK) in cyapa_gen3_event_process()
1175 if (cyapa->btn_capability & CAPABILITY_RIGHT_BTN_MASK) in cyapa_gen3_event_process()
1183 static int cyapa_gen3_irq_handler(struct cyapa *cyapa) in cyapa_gen3_irq_handler() argument
1185 struct device *dev = &cyapa->client->dev; in cyapa_gen3_irq_handler()
1189 ret = cyapa_read_block(cyapa, CYAPA_CMD_GROUP_DATA, (u8 *)&data); in cyapa_gen3_irq_handler()
1203 return cyapa_gen3_event_process(cyapa, &data); in cyapa_gen3_irq_handler()
1212 static int cyapa_gen3_try_poll_handler(struct cyapa *cyapa) in cyapa_gen3_try_poll_handler() argument
1217 ret = cyapa_read_block(cyapa, CYAPA_CMD_GROUP_DATA, (u8 *)&data); in cyapa_gen3_try_poll_handler()
1226 return cyapa_gen3_event_process(cyapa, &data); in cyapa_gen3_try_poll_handler()
1230 static int cyapa_gen3_initialize(struct cyapa *cyapa) { return 0; } in cyapa_gen3_initialize() argument
1231 static int cyapa_gen3_bl_initiate(struct cyapa *cyapa, in cyapa_gen3_bl_initiate() argument
1233 static int cyapa_gen3_empty_output_data(struct cyapa *cyapa, in cyapa_gen3_empty_output_data() argument