From b0473a6acf188e316ed975acab2d660b652b7c37 Mon Sep 17 00:00:00 2001 From: jiabinhe Date: Mon, 11 Nov 2024 15:25:36 +0800 Subject: [PATCH] media: reduce ti960 init time Signed-off-by: jiabinhe --- drivers/media/i2c/ti953.h | 1 + drivers/media/i2c/ti960-des.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ti953.h b/drivers/media/i2c/ti953.h index f06f899251ab..bdd50b1098e2 100644 --- a/drivers/media/i2c/ti953.h +++ b/drivers/media/i2c/ti953.h @@ -15,6 +15,7 @@ struct ti953_register_devid { }; /* register definition */ +#define TI953_DEVICE_ID 0x0U #define TI953_RESET_CTL 0x1 #define TI953_GENERAL_CFG 0x2 #define TI953_LOCAL_GPIO_DATA 0xd diff --git a/drivers/media/i2c/ti960-des.c b/drivers/media/i2c/ti960-des.c index 1e910db62882..7bea626826e5 100644 --- a/drivers/media/i2c/ti960-des.c +++ b/drivers/media/i2c/ti960-des.c @@ -664,7 +664,7 @@ static int gpio_exp_reset_sensor(struct i2c_client *client, int reset) gpio_out = i2c_smbus_read_byte_data(client, 0x01); gpio_out &= ~(1u << reset); i2c_smbus_write_byte_data(client, 0x01, gpio_out); - msleep(500); + msleep(50); gpio_out |= (1u << reset); i2c_smbus_write_byte_data(client, 0x01, gpio_out); @@ -694,7 +694,7 @@ static int ti953_reset_sensor(struct i2c_client *client, int reset) gpio_data |= TI953_GPIO0_OUT << reset; ti953_reg_write(client, TI953_LOCAL_GPIO_DATA, gpio_data); - msleep(500); + msleep(50); return 0; } @@ -729,6 +729,7 @@ static int ti960_config_ser(struct ti960 *va, struct i2c_client *client, int k, int i, rval; unsigned char val; bool speed_detect_fail; + int timeout = 50; rx_port = subdev->rx_port; phy_i2c_addr = subdev->phy_i2c_addr; @@ -779,7 +780,23 @@ static int ti960_config_ser(struct ti960 *va, struct i2c_client *client, int k, ti953_reg_write(subdev->serializer, TI953_RESET_CTL, TI953_DIGITAL_RESET_1); - msleep(50); + + /* + * ti953 pull down time is at least 3ms + * add 2ms more as buffer + */ + while (timeout--) { + rval = ti953_reg_read(subdev->serializer, TI953_DEVICE_ID, &val); + if ((val == 0x30) || (val == 0x32)) + break; + + usleep_range(100, 110); + } + if (timeout == 0) { + dev_err(va->sd.dev, "ti953 pull down timeout.\n"); + } else { + dev_info(va->sd.dev, "ti953 pull down succeed, loop time %d.\n", (50 - timeout)); + } if (pdata->module_flags & TI960_FL_INIT_SER) { rval = ti953_init(subdev->serializer); @@ -804,7 +821,6 @@ static int ti960_config_ser(struct ti960 *va, struct i2c_client *client, int k, ti953_reg_write(subdev->serializer, TI953_LOCAL_GPIO_DATA, pdata->gpio_powerup_seq[i]); - msleep(50); } } @@ -1657,8 +1673,6 @@ static int ti960_init(struct ti960 *va) return rval; } } - /* wait for ti953 ready */ - msleep(200); rval = ti960_map_subdevs_addr(va); if (rval)