1919#define GOODIX_HID_DESC_ADDR 0x1058C
2020#define GOODIX_HID_REPORT_DESC_ADDR 0x105AA
2121#define GOODIX_HID_SIGN_ADDR 0x10D32
22+ #define GOODIX_HID_CMD_ADDR 0x10364
23+ #define GOODIX_HID_REPORT_ADDR 0x22C8C
2224
2325#define GOODIX_HID_GET_REPORT_CMD 0x02
2426#define GOODIX_HID_SET_REPORT_CMD 0x03
@@ -348,15 +350,15 @@ static int goodix_hid_check_ack_status(struct goodix_ts_data *ts, u32 *resp_len)
348350 * - byte 0: Ack flag, value of 1 for data ready
349351 * - bytes 1-2: Response data length
350352 */
351- error = goodix_spi_read (ts , ts -> hid_report_addr ,
353+ error = goodix_spi_read (ts , GOODIX_HID_CMD_ADDR ,
352354 & hdr , sizeof (hdr ));
353355 if (!error && (hdr .flag & GOODIX_HID_ACK_READY_FLAG )) {
354356 len = le16_to_cpu (hdr .size );
355357 if (len < GOODIX_HID_PKG_LEN_SIZE ) {
356358 dev_err (ts -> dev , "hrd.size too short: %d" , len );
357359 return - EINVAL ;
358360 }
359- * resp_len = len ;
361+ * resp_len = len - GOODIX_HID_PKG_LEN_SIZE ;
360362 return 0 ;
361363 }
362364
@@ -431,7 +433,7 @@ static int goodix_hid_get_raw_report(struct hid_device *hid,
431433 tx_len += args_len ;
432434
433435 /* Step1: write report request info */
434- error = goodix_spi_write (ts , ts -> hid_report_addr , tmp_buf , tx_len );
436+ error = goodix_spi_write (ts , GOODIX_HID_CMD_ADDR , tmp_buf , tx_len );
435437 if (error ) {
436438 dev_err (ts -> dev , "failed send read feature cmd, %d" , error );
437439 return error ;
@@ -446,9 +448,12 @@ static int goodix_hid_get_raw_report(struct hid_device *hid,
446448 if (error )
447449 return error ;
448450
449- len = min (len , response_data_len - GOODIX_HID_PKG_LEN_SIZE );
451+ /* Empty reprot response */
452+ if (!response_data_len )
453+ return 0 ;
454+ len = min (len , response_data_len );
450455 /* Step3: read response data(skip 2bytes of hid pkg length) */
451- error = goodix_spi_read (ts , ts -> hid_report_addr +
456+ error = goodix_spi_read (ts , GOODIX_HID_CMD_ADDR +
452457 GOODIX_HID_ACK_HEADER_SIZE +
453458 GOODIX_HID_PKG_LEN_SIZE , buf , len );
454459 if (error ) {
@@ -518,7 +523,7 @@ static int goodix_hid_set_raw_report(struct hid_device *hid,
518523 memcpy (tmp_buf + tx_len , buf , len );
519524 tx_len += len ;
520525
521- error = goodix_spi_write (ts , ts -> hid_report_addr , tmp_buf , tx_len );
526+ error = goodix_spi_write (ts , GOODIX_HID_CMD_ADDR , tmp_buf , tx_len );
522527 if (error ) {
523528 dev_err (ts -> dev , "failed send report: %*ph" , tx_len , tmp_buf );
524529 return error ;
@@ -697,12 +702,7 @@ static int goodix_spi_probe(struct spi_device *spi)
697702 return dev_err_probe (dev , PTR_ERR (ts -> reset_gpio ),
698703 "failed to request reset gpio\n" );
699704
700- error = device_property_read_u32 (dev , "goodix,hid-report-addr" ,
701- & ts -> hid_report_addr );
702- if (error )
703- return dev_err_probe (dev , error ,
704- "failed get hid report addr\n" );
705-
705+ ts -> hid_report_addr = GOODIX_HID_REPORT_ADDR ;
706706 error = goodix_dev_confirm (ts );
707707 if (error )
708708 return error ;
@@ -749,7 +749,7 @@ static int goodix_spi_set_power(struct goodix_ts_data *ts, int power_state)
749749 power_control_cmd [5 ] = power_state ;
750750
751751 guard (mutex )(& ts -> hid_request_lock );
752- error = goodix_spi_write (ts , ts -> hid_report_addr , power_control_cmd ,
752+ error = goodix_spi_write (ts , GOODIX_HID_CMD_ADDR , power_control_cmd ,
753753 sizeof (power_control_cmd ));
754754 if (error ) {
755755 dev_err (ts -> dev , "failed set power mode: %s" ,
@@ -786,6 +786,14 @@ static const struct acpi_device_id goodix_spi_acpi_match[] = {
786786MODULE_DEVICE_TABLE (acpi , goodix_spi_acpi_match );
787787#endif
788788
789+ #ifdef CONFIG_OF
790+ static const struct of_device_id goodix_spi_of_match [] = {
791+ { .compatible = "goodix,gt7986u-spifw" , },
792+ { }
793+ };
794+ MODULE_DEVICE_TABLE (of , goodix_spi_of_match );
795+ #endif
796+
789797static const struct spi_device_id goodix_spi_ids [] = {
790798 { "gt7986u" },
791799 { },
@@ -796,6 +804,7 @@ static struct spi_driver goodix_spi_driver = {
796804 .driver = {
797805 .name = "goodix-spi-hid" ,
798806 .acpi_match_table = ACPI_PTR (goodix_spi_acpi_match ),
807+ .of_match_table = of_match_ptr (goodix_spi_of_match ),
799808 .pm = pm_sleep_ptr (& goodix_spi_pm_ops ),
800809 },
801810 .probe = goodix_spi_probe ,
0 commit comments