Skip to content

Commit

Permalink
media: reduce ti960 init time
Browse files Browse the repository at this point in the history
Signed-off-by: jiabinhe <jiabin.he@intel.com>
  • Loading branch information
onceforall committed Nov 11, 2024
1 parent 5fcf0c4 commit b0473a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions drivers/media/i2c/ti953.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 20 additions & 6 deletions drivers/media/i2c/ti960-des.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b0473a6

Please sign in to comment.