Commit 86088f88 authored by allen chen's avatar allen chen Committed by Robert Foss

drm/bridge: it6505: Add i2c api power on check

Use i2c bus to read/write when it6505 power off will occur i2c error.
Add this check will prevent i2c error when it6505 power off.
Signed-off-by: default avatarPin-Yen Lin <treapking@chromium.org>
Signed-off-by: default avatarAllen Chen <allen.chen@ite.com.tw>
Reviewed-by: default avatarRobert Foss <robert.foss@linaro.org>
Signed-off-by: default avatarRobert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220715024910.12578-3-allen.chen@ite.com.tw
parent 899e90cf
...@@ -506,6 +506,9 @@ static int it6505_read(struct it6505 *it6505, unsigned int reg_addr) ...@@ -506,6 +506,9 @@ static int it6505_read(struct it6505 *it6505, unsigned int reg_addr)
int err; int err;
struct device *dev = &it6505->client->dev; struct device *dev = &it6505->client->dev;
if (!it6505->powered)
return -ENODEV;
err = regmap_read(it6505->regmap, reg_addr, &value); err = regmap_read(it6505->regmap, reg_addr, &value);
if (err < 0) { if (err < 0) {
dev_err(dev, "read failed reg[0x%x] err: %d", reg_addr, err); dev_err(dev, "read failed reg[0x%x] err: %d", reg_addr, err);
...@@ -521,6 +524,9 @@ static int it6505_write(struct it6505 *it6505, unsigned int reg_addr, ...@@ -521,6 +524,9 @@ static int it6505_write(struct it6505 *it6505, unsigned int reg_addr,
int err; int err;
struct device *dev = &it6505->client->dev; struct device *dev = &it6505->client->dev;
if (!it6505->powered)
return -ENODEV;
err = regmap_write(it6505->regmap, reg_addr, reg_val); err = regmap_write(it6505->regmap, reg_addr, reg_val);
if (err < 0) { if (err < 0) {
...@@ -538,6 +544,9 @@ static int it6505_set_bits(struct it6505 *it6505, unsigned int reg, ...@@ -538,6 +544,9 @@ static int it6505_set_bits(struct it6505 *it6505, unsigned int reg,
int err; int err;
struct device *dev = &it6505->client->dev; struct device *dev = &it6505->client->dev;
if (!it6505->powered)
return -ENODEV;
err = regmap_update_bits(it6505->regmap, reg, mask, value); err = regmap_update_bits(it6505->regmap, reg, mask, value);
if (err < 0) { if (err < 0) {
dev_err(dev, "write reg[0x%x] = 0x%x mask = 0x%x failed err %d", dev_err(dev, "write reg[0x%x] = 0x%x mask = 0x%x failed err %d",
...@@ -2559,13 +2568,12 @@ static int it6505_poweron(struct it6505 *it6505) ...@@ -2559,13 +2568,12 @@ static int it6505_poweron(struct it6505 *it6505)
usleep_range(10000, 20000); usleep_range(10000, 20000);
} }
it6505->powered = true;
it6505_reset_logic(it6505); it6505_reset_logic(it6505);
it6505_int_mask_enable(it6505); it6505_int_mask_enable(it6505);
it6505_init(it6505); it6505_init(it6505);
it6505_lane_off(it6505); it6505_lane_off(it6505);
it6505->powered = true;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment