Skip to contentSkip to conversation

drm/bridge: it6505: Fixes bugs

PATCH Superseded allen 4 participants 10 messages Jul 7, 2022 – Jul 12, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

allen

author
#0 lore raw

cover drm/bridge: it6505: Fixes bugs

From: allen chen <[email protected]>

This series fixes some it6505 driver bugs and improve computing time.

allen chen (3):
drm/bridge: it6505: Modified power sequence
drm/bridge: it6505: Add i2c api power on check drm/bridge: it6505: Modified video clock calculation and video debug
message

 drivers/gpu/drm/bridge/ite-it6505.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/3 drm/bridge: it6505: Modified power sequence

From: allen chen <[email protected]>

Change power sequence to meet it6505 data sheet requirement when boot on.

---
 drivers/gpu/drm/bridge/ite-it6505.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it6505.c +1 -1
index 2d119e3016b3..aa5e0aa1af85 100644
@@ -3029,7 +3029,7 @@ static int it6505_init_pdata(struct it6505 *it6505)
 		return PTR_ERR(pdata->ovdd);
 	}
 
-	pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+	pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(pdata->gpiod_reset)) {
 		dev_err(dev, "gpiod_reset gpio not found");
 		return PTR_ERR(pdata->gpiod_reset);
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/3] drm/bridge: it6505: Modified power sequence

Hi Allen,

Quoted 17 lines · allen

From: allen chen <[email protected]>

Change power sequence to meet it6505 data sheet requirement when boot on.

---
 drivers/gpu/drm/bridge/ite-it6505.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it6505.c +0 -0
index 2d119e3016b3..aa5e0aa1af85 100644

drivers/gpu/drm/bridge/ite-it6505.c static int it6505_init_pdata(struct it6505 *it6505) · line 3032

Quoted 5 lines
drivers/gpu/drm/bridge/ite-it6505.c +1 -1
@@ -3029,7 +3029,7 @@ static int it6505_init_pdata(struct it6505 *it6505)
                return PTR_ERR(pdata->ovdd);
        }
 
-       pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+       pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);

Making this change is problematic since it requires a corresponding change in all of the device trees that use this device. It's against policy to change this interface after it has been introduced.

Unless anyone thinks otherwise, I would like to see this patch dropped.

Quoted 6 lines
drivers/gpu/drm/bridge/ite-it6505.c +0 -1
        if (IS_ERR(pdata->gpiod_reset)) {
                dev_err(dev, "gpiod_reset gpio not found");
                return PTR_ERR(pdata->gpiod_reset);
--

2.25.1

#3 lore raw

Re: [PATCH 1/3] drm/bridge: it6505: Modified power sequence

Hi Robert,

Quoted 24 lines · Robert Foss

Hi Allen,

Quoted 20 lines · allen

From: allen chen <[email protected]>

Change power sequence to meet it6505 data sheet requirement when boot on.

---
 drivers/gpu/drm/bridge/ite-it6505.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it6505.c +0 -0
index 2d119e3016b3..aa5e0aa1af85 100644
@@ -3029,7 +3029,7 @@ static int it6505_init_pdata(struct it6505 *it6505)
                return PTR_ERR(pdata->ovdd);
        }
 
Quoted 8 lines

drivers/gpu/drm/bridge/ite-it6505.c static int it6505_init_pdata(struct it6505 *it6505) · line 3032

Quoted 2 lines
drivers/gpu/drm/bridge/ite-it6505.c +1 -1
-       pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+       pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);

Making this change is problematic since it requires a corresponding change in all of the device trees that use this device. It's against policy to change this interface after it has been introduced.

Unless anyone thinks otherwise, I would like to see this patch dropped.

I don't really understand why this would require corresponding change in device trees.

Currently there's no real it6505 user on upstream. Also, the GPIO value will be changed
in it6505_poweron, so this change only affects the power on sequence of it6505.

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/bridge/ite-it6505.c +0 -1
        if (IS_ERR(pdata->gpiod_reset)) {
                dev_err(dev, "gpiod_reset gpio not found");
                return PTR_ERR(pdata->gpiod_reset);
--

2.25.1

#4 lore raw

Re: [PATCH 1/3] drm/bridge: it6505: Modified power sequence

In reply to Robert Foss
Quoted 24 lines · Robert Foss

Hi Allen,

Quoted 20 lines · allen

From: allen chen <[email protected]>

Change power sequence to meet it6505 data sheet requirement when boot on.

---
 drivers/gpu/drm/bridge/ite-it6505.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it6505.c +0 -0
index 2d119e3016b3..aa5e0aa1af85 100644
@@ -3029,7 +3029,7 @@ static int it6505_init_pdata(struct it6505 *it6505)
                return PTR_ERR(pdata->ovdd);
        }
 
Quoted 8 lines

drivers/gpu/drm/bridge/ite-it6505.c static int it6505_init_pdata(struct it6505 *it6505) · line 3032

Quoted 2 lines
drivers/gpu/drm/bridge/ite-it6505.c +1 -1
-       pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+       pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);

Making this change is problematic since it requires a corresponding change in all of the device trees that use this device. It's against policy to change this interface after it has been introduced.

Unless anyone thinks otherwise, I would like to see this patch dropped.

I think you're confusing GPIO_ACTIVE_{LOW,HIGH} flags in the device tree vs GPIOD_OUT_{LOW,HIGH}, which just sets the "default" state the GPIO should be in when it is requested.

This change doesn't impact the device tree.

Regards
ChenYu

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/bridge/ite-it6505.c +0 -1
        if (IS_ERR(pdata->gpiod_reset)) {
                dev_err(dev, "gpiod_reset gpio not found");
                return PTR_ERR(pdata->gpiod_reset);
--

2.25.1

Reviewed-by
#5 lore raw

Re: [PATCH 1/3] drm/bridge: it6505: Modified power sequence

Hi,

Quoted 38 lines · On Tue, Jul 12, 2022, 11:41 Chen-Yu Tsai <[email protected]> wrote:
Quoted 8 lines · Robert Foss

Hi Allen,

Quoted 4 lines · allen

From: allen chen <[email protected]>

Change power sequence to meet it6505 data sheet requirement when boot

on.

Quoted 9 lines

Review

Quoted 9 lines
---
 drivers/gpu/drm/bridge/ite-it6505.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/ite-it6505.c

Quoted 4 lines

drivers/gpu/drm/bridge/ite-it6505.c static int it6505_init_pdata(struct it6505

Quoted 4 lines

index 2d119e3016b3..aa5e0aa1af85 100644

drivers/gpu/drm/bridge/ite-it6505.c +0 -0
@@ -3029,7 +3029,7 @@ static int it6505_init_pdata(struct it6505

*it6505)

Quoted 4 lines

drivers/gpu/drm/bridge/ite-it6505.c static int it6505_init_pdata(struct it6505 *it6505)

Quoted 4 lines
drivers/gpu/drm/bridge/ite-it6505.c +0 -1
                return PTR_ERR(pdata->ovdd);
        }
 
-       pdata->gpiod_reset = devm_gpiod_get(dev, "reset",

GPIOD_OUT_HIGH);

Quoted 1 line

drivers/gpu/drm/bridge/ite-it6505.c static int it6505_init_pdata(struct it6505 · line 3032

Quoted 1 line
drivers/gpu/drm/bridge/ite-it6505.c +1 -0
+       pdata->gpiod_reset = devm_gpiod_get(dev, "reset",

GPIOD_OUT_LOW);

Quoted 5 lines

Making this change is problematic since it requires a corresponding change in all of the device trees that use this device. It's against policy to change this interface after it has been introduced.

Quoted 8 lines
Quoted 1 line

Unless anyone thinks otherwise, I would like to see this patch dropped.

I think you're confusing GPIO_ACTIVE_{LOW,HIGH} flags in the device tree vs GPIOD_OUT_{LOW,HIGH}, which just sets the "default" state the GPIO should be in when it is requested.

This change doesn't impact the device tree.

Thanks ChenYu, you are 100% right.

Quoted 11 lines

Regards
ChenYu

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/bridge/ite-it6505.c +0 -1
        if (IS_ERR(pdata->gpiod_reset)) {
                dev_err(dev, "gpiod_reset gpio not found");
                return PTR_ERR(pdata->gpiod_reset);
--

2.25.1

author
#6 lore raw

PATCH 2/3 drm/bridge: it6505: Add i2c api power on check

In reply to allen

From: allen chen <[email protected]>

Use i2c bus to read/write when it6505 power off will occure i2c error. Add this check will prevent i2c error when it6505 power off.

---
 drivers/gpu/drm/bridge/ite-it6505.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +10 -2
index aa5e0aa1af85..cfd2c3275dc5 100644
@@ -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;
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v1 2/3
#7 lore raw

Re: [PATCH 2/3] drm/bridge: it6505: Add i2c api power on check

Quoted 4 lines · allen

From: allen chen <[email protected]>

Use i2c bus to read/write when it6505 power off will occure i2c error.

^^^ typ-o
Change occure to occur.

This is an issue that would have been caught by running checkpatch --strict, please try to run it on all patches before submission.

Quoted 59 lines

Add this check will prevent i2c error when it6505 power off.

---
 drivers/gpu/drm/bridge/ite-it6505.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +10 -3
index aa5e0aa1af85..cfd2c3275dc5 100644
@@ -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;
 }
 
--
Quoted 2 lines

2.25.1

With that fixed:

author
#8 lore raw

PATCH 3/3 drm/bridge: it6505: Modified video clock calculation and video debug message

In reply to allen

From: allen chen <[email protected]>

Speed up video clock calculation and remove redundant video debug message.

---
 drivers/gpu/drm/bridge/ite-it6505.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +2 -4
index cfd2c3275dc5..11a34ddb60a1 100644
@@ -703,7 +703,7 @@ static void it6505_calc_video_info(struct it6505 *it6505)
 	DRM_DEV_DEBUG_DRIVER(dev, "hactive_start:%d, vactive_start:%d",
 			     hdes, vdes);
 
-	for (i = 0; i < 10; i++) {
+	for (i = 0; i < 3; i++) {
 		it6505_set_bits(it6505, REG_DATA_CTRL0, ENABLE_PCLK_COUNTER,
 				ENABLE_PCLK_COUNTER);
 		usleep_range(10000, 15000);
@@ -720,7 +720,7 @@ static void it6505_calc_video_info(struct it6505 *it6505)
 		return;
 	}
 
-	sum /= 10;
+	sum /= 3;
 	pclk = 13500 * 2048 / sum;
 	it6505->video_info.clock = pclk;
 	it6505->video_info.hdisplay = hdew;
@@ -2344,8 +2344,6 @@ static void it6505_irq_hpd(struct it6505 *it6505)
 
 		if (!it6505_get_video_status(it6505))
 			it6505_video_reset(it6505);
-
-		it6505_calc_video_info(it6505);
 	} else {
 		memset(it6505->dpcd, 0, sizeof(it6505->dpcd));
 
Signature · 1 line
2.25.1
Reviewed-by on v1 3/3
#9 lore raw

Re: [PATCH 3/3] drm/bridge: it6505: Modified video clock calculation and video debug message

Quoted 44 lines · allen

From: allen chen <[email protected]>

Speed up video clock calculation and remove redundant video debug message.

---
 drivers/gpu/drm/bridge/ite-it6505.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +2 -5
index cfd2c3275dc5..11a34ddb60a1 100644
@@ -703,7 +703,7 @@ static void it6505_calc_video_info(struct it6505 *it6505)
        DRM_DEV_DEBUG_DRIVER(dev, "hactive_start:%d, vactive_start:%d",
                             hdes, vdes);
 
-       for (i = 0; i < 10; i++) {
+       for (i = 0; i < 3; i++) {
                it6505_set_bits(it6505, REG_DATA_CTRL0, ENABLE_PCLK_COUNTER,
                                ENABLE_PCLK_COUNTER);
                usleep_range(10000, 15000);
@@ -720,7 +720,7 @@ static void it6505_calc_video_info(struct it6505 *it6505)
                return;
        }
 
-       sum /= 10;
+       sum /= 3;
        pclk = 13500 * 2048 / sum;
        it6505->video_info.clock = pclk;
        it6505->video_info.hdisplay = hdew;
@@ -2344,8 +2344,6 @@ static void it6505_irq_hpd(struct it6505 *it6505)
 
                if (!it6505_get_video_status(it6505))
                        it6505_video_reset(it6505);
-
-               it6505_calc_video_info(it6505);
        } else {
                memset(it6505->dpcd, 0, sizeof(it6505->dpcd));
 
--
Quoted 2 lines

2.25.1