Skip to content

Commit

Permalink
ww45 release
Browse files Browse the repository at this point in the history
Signed-off-by: jiabinhe <[email protected]>
  • Loading branch information
onceforall committed Oct 25, 2024
1 parent 963c4b7 commit d1357f5
Show file tree
Hide file tree
Showing 16 changed files with 341 additions and 213 deletions.
2 changes: 1 addition & 1 deletion drivers/media/i2c/ar0234.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019-2024 Intel Corporation.

#include <asm/unaligned.h>
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/gpio.h>
#include <linux/version.h>
#include <asm/unaligned.h>
#include <linux/interrupt.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
Expand Down
29 changes: 16 additions & 13 deletions drivers/media/i2c/imx390.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2021-2024 Intel Corporation.

#include <asm/unaligned.h>
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/version.h>
#include <asm/unaligned.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
#include <linux/version.h>
#include <media/imx390.h>

#define IMX390_LINK_FREQ_360MHZ 360000000ULL
Expand All @@ -26,7 +26,6 @@
#define IMX390_REG_VALUE_16BIT 2

#define IMX390_REG_CHIP_ID 0x0330
#define IMX390_CHIP_ID 0x0

/* vertical-timings from sensor */
#define IMX390_REG_VTS 0x300A
Expand Down Expand Up @@ -1366,6 +1365,10 @@ static int imx390_set_ctrl(struct v4l2_ctrl *ctrl)
struct i2c_client *client = v4l2_get_subdevdata(&imx390->sd);
int ret = 0;

/* V4L2 controls values will be applied only when power is already up */
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;

switch (ctrl->id) {
case IMX390_CID_EXPOSURE_SHS1:
case IMX390_CID_EXPOSURE_SHS2:
Expand Down Expand Up @@ -1895,21 +1898,21 @@ static int imx390_identify_module(struct imx390 *imx390)
{
struct i2c_client *client = v4l2_get_subdevdata(&imx390->sd);
int ret;
int retry = 50;
u32 val;

ret = imx390_read_reg(imx390, IMX390_REG_CHIP_ID,
IMX390_REG_VALUE_08BIT, &val);
while (retry--) {
ret = imx390_read_reg(imx390, IMX390_REG_CHIP_ID,
IMX390_REG_VALUE_16BIT, &val);
if (ret == 0)
break;
usleep_range(10000, 10500);
}

if (ret)
return ret;

return 0;

/* chip id not known yet */
if (val != IMX390_CHIP_ID) {
dev_err(&client->dev, "chip id mismatch: %x!=%x",
IMX390_CHIP_ID, val);
return -ENXIO;
}
dev_info(&client->dev, "chip id: %04x", val);

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/media/i2c/isx031.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2022 Intel Corporation.

#include <asm/unaligned.h>
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/version.h>
#include <asm/unaligned.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/i2c/lt6911uxc.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2022-2023 Intel Corporation.

#include <asm/unaligned.h>
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/i2c.h>
Expand All @@ -12,6 +11,8 @@
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/v4l2-dv-timings.h>
#include <linux/version.h>
#include <asm/unaligned.h>

#include <media/v4l2-dv-timings.h>
#include <media/v4l2-ctrls.h>
Expand All @@ -21,7 +22,6 @@
#include <media/v4l2-fwnode.h>
#include <linux/types.h>

#include <linux/version.h>
#include <media/lt6911uxc.h>

/* v4l2 debug level */
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/i2c/lt6911uxe.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2023 Intel Corporation.

#include <asm/unaligned.h>
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/i2c.h>
Expand All @@ -12,6 +11,8 @@
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/v4l2-dv-timings.h>
#include <linux/version.h>
#include <asm/unaligned.h>

#include <media/v4l2-dv-timings.h>
#include <media/v4l2-ctrls.h>
Expand All @@ -21,7 +22,6 @@
#include <media/v4l2-fwnode.h>
#include <linux/types.h>

#include <linux/version.h>
#include <media/lt6911uxe.h>

/* v4l2 debug level */
Expand Down
72 changes: 24 additions & 48 deletions drivers/media/i2c/ti953-ser.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@
#include "ti960-reg.h"
#include "ti953.h"

int ti953_reg_write(struct v4l2_subdev *sd, unsigned short rx_port,
unsigned short ser_alias, unsigned char reg, unsigned char val)
int ti953_reg_write(struct i2c_client *client, unsigned char reg, unsigned char val)
{
int ret;
int retry, timeout = 10;
struct i2c_client *client = v4l2_get_subdevdata(sd);
unsigned short addr_backup;

dev_dbg(sd->dev, "%s port %d, ser_alias %x, reg %x, val %x",
__func__, rx_port, ser_alias, reg, val);
addr_backup = client->addr;
client->addr = ser_alias;
dev_dbg(&client->dev, "reg %x, val %x", reg, val);
for (retry = 0; retry < timeout; retry++) {
ret = i2c_smbus_write_byte_data(client, reg, val);
if (ret < 0)
Expand All @@ -39,26 +32,19 @@ int ti953_reg_write(struct v4l2_subdev *sd, unsigned short rx_port,
break;
}

client->addr = addr_backup;
if (retry >= timeout) {
dev_err(sd->dev,
"%s:write reg failed: port=%2x, addr=%2x, reg=%2x\n",
__func__, rx_port, ser_alias, reg);
dev_err(&client->dev, "%s:failed: reg=%2x\n", __func__, reg);
return -EREMOTEIO;
}

return 0;
}

int ti953_reg_read(struct v4l2_subdev *sd, unsigned short rx_port,
unsigned short ser_alias, unsigned char reg, unsigned char *val)
int ti953_reg_read(struct i2c_client *client, unsigned char reg, unsigned char *val)
{
int ret, retry, timeout = 10;
struct i2c_client *client = v4l2_get_subdevdata(sd);
unsigned short addr_backup;

addr_backup = client->addr;
client->addr = ser_alias;
for (retry = 0; retry < timeout; retry++) {
ret = i2c_smbus_read_byte_data(client, reg);
if (ret < 0)
Expand All @@ -69,29 +55,25 @@ int ti953_reg_read(struct v4l2_subdev *sd, unsigned short rx_port,
}
}

client->addr = addr_backup;
if (retry >= timeout) {
dev_err(sd->dev,
"%s:read reg failed: port=%2x, addr=%2x, reg=%2x\n",
__func__, rx_port, ser_alias, reg);
dev_err(&client->dev, "%s:failed: reg=%2x\n", __func__, reg);
return -EREMOTEIO;
}

return 0;
}

bool ti953_detect(struct v4l2_subdev *sd, unsigned short rx_port, unsigned short ser_alias)
bool ti953_detect(struct i2c_client *client)
{
bool ret = false;
int i;
int rval;
unsigned char val;

for (i = 0; i < ARRAY_SIZE(ti953_FPD3_RX_ID); i++) {
rval = ti953_reg_read(sd, rx_port, ser_alias,
ti953_FPD3_RX_ID[i].reg, &val);
rval = ti953_reg_read(client, ti953_FPD3_RX_ID[i].reg, &val);
if (rval) {
dev_err(sd->dev, "port %d, ti953 write timeout %d\n", rx_port, rval);
dev_err(&client->dev, "ti953 read timeout %d\n", rval);
break;
}
if (val != ti953_FPD3_RX_ID[i].val_expected)
Expand All @@ -101,48 +83,46 @@ bool ti953_detect(struct v4l2_subdev *sd, unsigned short rx_port, unsigned short
if (i == ARRAY_SIZE(ti953_FPD3_RX_ID))
ret = true;
else
dev_err(sd->dev, "TI953 Probe Failed");
dev_err(&client->dev, "TI953 Probe Failed");

return ret;
}

int ti953_init(struct v4l2_subdev *sd, unsigned short rx_port, unsigned short ser_alias)
int ti953_init(struct i2c_client *client)
{
int i, rval;

for (i = 0; i < ARRAY_SIZE(ti953_init_settings); i++) {
rval = ti953_reg_write(sd, rx_port, ser_alias,
ti953_init_settings[i].reg,
ti953_init_settings[i].val);
rval = ti953_reg_write(client, ti953_init_settings[i].reg,
ti953_init_settings[i].val);
if (rval) {
dev_err(sd->dev, "port %d, ti953 write timeout %d\n", 0, rval);
dev_err(&client->dev, "ti953 write timeout %d\n", rval);
break;
}
}

ti953_init_clk(sd, rx_port, ser_alias);
ti953_init_clk(client);

return 0;
}

int ti953_init_clk(struct v4l2_subdev *sd, unsigned short rx_port, unsigned short ser_alias)
int ti953_init_clk(struct i2c_client *client)
{
int i, rval;

for (i = 0; i < ARRAY_SIZE(ti953_init_settings_clk); i++) {
rval = ti953_reg_write(sd, rx_port, ser_alias,
ti953_init_settings_clk[i].reg,
ti953_init_settings_clk[i].val);
rval = ti953_reg_write(client, ti953_init_settings_clk[i].reg,
ti953_init_settings_clk[i].val);
if (rval) {
dev_err(sd->dev, "port %d, ti953 write timeout %d\n", 0, rval);
dev_err(&client->dev, "ti953 write timeout %d\n", rval);
break;
}
}

return 0;
}

int32_t ti953_bus_speed(struct v4l2_subdev *sd, uint16_t rx_port, uint16_t ser_alias, uint8_t i2c_speed)
int32_t ti953_bus_speed(struct i2c_client *client, uint8_t i2c_speed)
{
struct ti953_register_write scl_high_reg;
struct ti953_register_write scl_low_reg;
Expand All @@ -165,27 +145,23 @@ int32_t ti953_bus_speed(struct v4l2_subdev *sd, uint16_t rx_port, uint16_t ser_a
break;
case TI953_I2C_SPEED_HIGH:
default:
dev_err(sd->dev, "port %u, ti953 unsupported I2C speed mode %u",
rx_port, i2c_speed);
dev_err(&client->dev, "ti953 unsupported I2C speed mode %u", i2c_speed);
scl_high_reg.val = TI953_I2C_SCL_HIGH_TIME_STANDARD;
scl_low_reg.val = TI953_I2C_SCL_LOW_TIME_STANDARD;
ret = -EINVAL;
break;
}
if (ret != 0)
return ret;
ret = ti953_reg_write(sd, rx_port, ser_alias,
scl_high_reg.reg, scl_high_reg.val);
ret = ti953_reg_write(client, scl_high_reg.reg, scl_high_reg.val);
if (ret != 0) {
dev_err(sd->dev, "port %u, ti953 write SCL_HIGH_TIME failed %d",
rx_port, ret);
dev_err(&client->dev, "ti953 write SCL_HIGH_TIME failed %d", ret);
return ret;
}
ret = ti953_reg_write(sd, rx_port, ser_alias,
ret = ti953_reg_write(client,
scl_low_reg.reg, scl_low_reg.val);
if (ret != 0) {
dev_err(sd->dev, "port %u, ti953 write SCL_LOW_TIME failed %d",
rx_port, ret);
dev_err(&client->dev, " ti953 write SCL_LOW_TIME failed %d", ret);
return ret;
}

Expand Down
16 changes: 6 additions & 10 deletions drivers/media/i2c/ti953.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,12 @@ static const struct ti953_register_devid ti953_FPD3_RX_ID[] = {
{0xf5, 0x33},
};

int ti953_reg_write(struct v4l2_subdev *sd, unsigned short rx_port,
unsigned short ser_alias, unsigned char reg, unsigned char val);
int ti953_reg_write(struct i2c_client *client, unsigned char reg, unsigned char val);
int ti953_reg_read(struct i2c_client *client, unsigned char reg, unsigned char *val);

int ti953_reg_read(struct v4l2_subdev *sd, unsigned short rx_port,
unsigned short ser_alias, unsigned char reg, unsigned char *val);

bool ti953_detect(struct v4l2_subdev *sd, unsigned short rx_port, unsigned short ser_alias);

int ti953_init(struct v4l2_subdev *sd, unsigned short rx_port, unsigned short ser_alias);
int ti953_init_clk(struct v4l2_subdev *sd, unsigned short rx_port, unsigned short ser_alias);
int32_t ti953_bus_speed(struct v4l2_subdev *sd, uint16_t rx_port, uint16_t ser_alias, uint8_t i2c_speed);
bool ti953_detect(struct i2c_client *client);
int ti953_init(struct i2c_client *client);
int ti953_init_clk(struct i2c_client *client);
int32_t ti953_bus_speed(struct i2c_client *client, uint8_t i2c_speed);

#endif
Loading

0 comments on commit d1357f5

Please sign in to comment.