summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Pan <gspj@google.com>2022-07-01 04:47:40 +0000
committerHarry Pan <gspj@google.com>2022-07-01 06:20:31 +0000
commit6af4422bbbc1324339524eaf6acab110cc2aa54a (patch)
tree02830931c35c93bcd517079147f38ad935a83421
parent1b331b2ddab782e381eb99dee647ddbe31814d8d (diff)
downloadrotary-encoders-6af4422bbbc1324339524eaf6acab110cc2aa54a.tar.gz
Fix the probing when the crown chip is disconnected
A bunch of i2c errors along with pat9126_read failure spam when it comes to device without crown chip mounted, this could happen during manufacturing tests in partially assembled devices. To address this odd, refine the probing to align with the interface call. Bug: 237238777 Test: Emulate P11 as Eos, examine probing failed, no lot of i2c spam. Signed-off-by: Harry Pan <gspj@google.com> Change-Id: I7afd8263cfbc3f77cc3f23de35e1841409662c34
-rw-r--r--ots_pat9126/pat9126.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/ots_pat9126/pat9126.c b/ots_pat9126/pat9126.c
index 2c62d5d..c0f558f 100644
--- a/ots_pat9126/pat9126.c
+++ b/ots_pat9126/pat9126.c
@@ -134,9 +134,9 @@ void delay(int ms)
msleep(ms);
}
-bool pat9126_sensor_init(struct i2c_client *client)
+int pat9126_sensor_init(struct i2c_client *client)
{
- u8 id;
+ u8 id = 0;
int ret = 0;
/*
@@ -145,7 +145,8 @@ bool pat9126_sensor_init(struct i2c_client *client)
*/
pat9126_read(client, PIXART_PAT9126_PRODUCT_ID1_REG, &id);
if (id != PIXART_PAT9126_SENSOR_ID) {
- return false;
+ pr_err("[PAT9126]: PID mismatch (id = 0x%x)", id);
+ return (-1);
}
/*
@@ -168,23 +169,23 @@ bool pat9126_sensor_init(struct i2c_client *client)
/* disable write protect */
if (pat9126_write_verified(client, PIXART_PAT9126_WRITE_PROTECT_REG,
PIXART_PAT9126_DISABLE_WRITE_PROTECT) < 0)
- return false;
+ return (-1);
/* set X-axis resolution (depends on application) */
if (pat9126_write_verified(client, PIXART_PAT9126_SET_CPI_RES_X_REG,
PIXART_PAT9126_CPI_RESOLUTION_X) < 0)
- return false;
+ return (-1);
/* set Y-axis resolution (depends on application) */
if (pat9126_write_verified(client, PIXART_PAT9126_SET_CPI_RES_Y_REG,
PIXART_PAT9126_CPI_RESOLUTION_Y) < 0)
- return false;
+ return (-1);
/* set 12-bit X/Y data format (depends on application) */
if (pat9126_write_verified(client, PIXART_PAT9126_ORIENTATION_REG,
PIXART_PAT9126_MOTION_DATA_LENGTH) < 0)
- return false;
+ return (-1);
/* ONLY for VDD=VDDA=1.7~1.9V: for power saving */
if (pat9126_write_verified(client, PIXART_PAT9126_VOLTAGE_SEGMENT_SEL_REG,
PIXART_PAT9126_LOW_VOLTAGE_SEGMENT) < 0)
- return false;
+ return (-1);
pat9126_write_verified(client, PIXART_PAT9126_SENSOR_MODE_SELECT_REG,
PIXART_PAT9126_SENSOR_SET_MODE2);