2022-07-13 03:45:39

by allen

[permalink] [raw]
Subject: [PATCH v2] drm/bridge: it6505: Add i2c api power on check

From: allen chen <[email protected]>

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: Pin-Yen Lin <[email protected]>
Signed-off-by: Allen Chen <[email protected]>
Reviewed-by: Robert Foss <[email protected]>
---
drivers/gpu/drm/bridge/ite-it6505.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index aa5e0aa1af85..cfd2c3275dc5 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -518,6 +518,9 @@ static int it6505_read(struct it6505 *it6505, unsigned int reg_addr)
int err;
struct device *dev = &it6505->client->dev;

+ if (!it6505->powered)
+ return -ENODEV;
+
err = regmap_read(it6505->regmap, reg_addr, &value);
if (err < 0) {
dev_err(dev, "read failed reg[0x%x] err: %d", reg_addr, err);
@@ -533,6 +536,9 @@ static int it6505_write(struct it6505 *it6505, unsigned int reg_addr,
int err;
struct device *dev = &it6505->client->dev;

+ if (!it6505->powered)
+ return -ENODEV;
+
err = regmap_write(it6505->regmap, reg_addr, reg_val);

if (err < 0) {
@@ -550,6 +556,9 @@ static int it6505_set_bits(struct it6505 *it6505, unsigned int reg,
int err;
struct device *dev = &it6505->client->dev;

+ if (!it6505->powered)
+ return -ENODEV;
+
err = regmap_update_bits(it6505->regmap, reg, mask, value);
if (err < 0) {
dev_err(dev, "write reg[0x%x] = 0x%x mask = 0x%x failed err %d",
@@ -2553,13 +2562,12 @@ static int it6505_poweron(struct it6505 *it6505)
usleep_range(10000, 20000);
}

+ it6505->powered = true;
it6505_reset_logic(it6505);
it6505_int_mask_enable(it6505);
it6505_init(it6505);
it6505_lane_off(it6505);

- it6505->powered = true;
-
return 0;
}

--
2.25.1


2022-07-19 15:34:27

by Robert Foss

[permalink] [raw]
Subject: Re: [PATCH v2] drm/bridge: it6505: Add i2c api power on check

On Wed, 13 Jul 2022 at 05:16, allen <[email protected]> wrote:
>
> From: allen chen <[email protected]>
>
> 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: Pin-Yen Lin <[email protected]>
> Signed-off-by: Allen Chen <[email protected]>
> Reviewed-by: Robert Foss <[email protected]>
> ---
> drivers/gpu/drm/bridge/ite-it6505.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index aa5e0aa1af85..cfd2c3275dc5 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -518,6 +518,9 @@ static int it6505_read(struct it6505 *it6505, unsigned int reg_addr)
> int err;
> struct device *dev = &it6505->client->dev;
>
> + if (!it6505->powered)
> + return -ENODEV;
> +
> err = regmap_read(it6505->regmap, reg_addr, &value);
> if (err < 0) {
> dev_err(dev, "read failed reg[0x%x] err: %d", reg_addr, err);
> @@ -533,6 +536,9 @@ static int it6505_write(struct it6505 *it6505, unsigned int reg_addr,
> int err;
> struct device *dev = &it6505->client->dev;
>
> + if (!it6505->powered)
> + return -ENODEV;
> +
> err = regmap_write(it6505->regmap, reg_addr, reg_val);
>
> if (err < 0) {
> @@ -550,6 +556,9 @@ static int it6505_set_bits(struct it6505 *it6505, unsigned int reg,
> int err;
> struct device *dev = &it6505->client->dev;
>
> + if (!it6505->powered)
> + return -ENODEV;
> +
> err = regmap_update_bits(it6505->regmap, reg, mask, value);
> if (err < 0) {
> dev_err(dev, "write reg[0x%x] = 0x%x mask = 0x%x failed err %d",
> @@ -2553,13 +2562,12 @@ static int it6505_poweron(struct it6505 *it6505)
> usleep_range(10000, 20000);
> }
>
> + it6505->powered = true;
> it6505_reset_logic(it6505);
> it6505_int_mask_enable(it6505);
> it6505_init(it6505);
> it6505_lane_off(it6505);
>
> - it6505->powered = true;
> -
> return 0;
> }
>
> --
> 2.25.1
>

This patch no longer applies to the drm-misc-next tree, could you
rebase it and send out a v3?

2022-07-21 03:34:45

by Pin-yen Lin

[permalink] [raw]
Subject: Re: [PATCH v2] drm/bridge: it6505: Add i2c api power on check

Hi Robert,

The same patch has been reviewed and applied as
86088f88a25c76baac304b6f887e5da2c30c4e07 in "drm/bridge: it6505: Fixes
bugs" series.

We accidentally sent this out as an individual patch and forgot to
revoke this after sending out the complete series.

Sorry about that.

Regards,
Pin-yen

On Tue, Jul 19, 2022 at 11:26 PM Robert Foss <[email protected]> wrote:
>
> On Wed, 13 Jul 2022 at 05:16, allen <[email protected]> wrote:
> >
> > From: allen chen <[email protected]>
> >
> > 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: Pin-Yen Lin <[email protected]>
> > Signed-off-by: Allen Chen <[email protected]>
> > Reviewed-by: Robert Foss <[email protected]>
> > ---
> > drivers/gpu/drm/bridge/ite-it6505.c | 12 ++++++++++--
> > 1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> > index aa5e0aa1af85..cfd2c3275dc5 100644
> > --- a/drivers/gpu/drm/bridge/ite-it6505.c
> > +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> > @@ -518,6 +518,9 @@ static int it6505_read(struct it6505 *it6505, unsigned int reg_addr)
> > int err;
> > struct device *dev = &it6505->client->dev;
> >
> > + if (!it6505->powered)
> > + return -ENODEV;
> > +
> > err = regmap_read(it6505->regmap, reg_addr, &value);
> > if (err < 0) {
> > dev_err(dev, "read failed reg[0x%x] err: %d", reg_addr, err);
> > @@ -533,6 +536,9 @@ static int it6505_write(struct it6505 *it6505, unsigned int reg_addr,
> > int err;
> > struct device *dev = &it6505->client->dev;
> >
> > + if (!it6505->powered)
> > + return -ENODEV;
> > +
> > err = regmap_write(it6505->regmap, reg_addr, reg_val);
> >
> > if (err < 0) {
> > @@ -550,6 +556,9 @@ static int it6505_set_bits(struct it6505 *it6505, unsigned int reg,
> > int err;
> > struct device *dev = &it6505->client->dev;
> >
> > + if (!it6505->powered)
> > + return -ENODEV;
> > +
> > err = regmap_update_bits(it6505->regmap, reg, mask, value);
> > if (err < 0) {
> > dev_err(dev, "write reg[0x%x] = 0x%x mask = 0x%x failed err %d",
> > @@ -2553,13 +2562,12 @@ static int it6505_poweron(struct it6505 *it6505)
> > usleep_range(10000, 20000);
> > }
> >
> > + it6505->powered = true;
> > it6505_reset_logic(it6505);
> > it6505_int_mask_enable(it6505);
> > it6505_init(it6505);
> > it6505_lane_off(it6505);
> >
> > - it6505->powered = true;
> > -
> > return 0;
> > }
> >
> > --
> > 2.25.1
> >
>
> This patch no longer applies to the drm-misc-next tree, could you
> rebase it and send out a v3?