drm/bridge: adv7511: Allow IRQ to share GPIO pins
Subsystems (5)
PATCH 1/2 drm/bridge: adv7511: Allow IRQ to share GPIO pins
The IRQ registration currently assumes that the GPIO is dedicated to it, but that may not necessarily be the case. If the board has another device sharing the IRQ, it won't be registered and the hot-plug detect fails. This is easily fixed by add the IRQF_SHARED flag.
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +2 -1
@@ -1318,7 +1318,8 @@ static int adv7511_probe(struct i2c_client *i2c) ret =devm_request_threaded_irq (dev, i2c->irq,NULL , adv7511_irq_handler, -IRQF_ONESHOT ,dev_name (dev), +IRQF_ONESHOT |IRQF_SHARED , +dev_name (dev), adv7511);if (ret) goto err_unregister_audio;
Signature · 1 line
2.43.0
PATCH 2/2 arm64: dts: imx8mp-beacon-kit: Enable HDMI bridge HPD
The DSI to HDMI bridge supports hot-plut-detect, but the driver didn't previously support a shared IRQ GPIO. With the driver updated, the interrupt can be added to the bridge.
arch/arm64/boot/dts/freescale/imx8mp-beacon-kit.dts +2 -0
@@ -405,6 +405,8 @@ adv_bridge: hdmi@3d { compatible = "adi,adv7535"; reg = <0x3d>, <0x3c>, <0x3e>, <0x3f>; reg-names = "main", "cec", "edid", "packet"; + interrupt-parent = <&gpio4>; + interrupts = <27 IRQ_TYPE_EDGE_FALLING>; adi,dsi-lanes = <4>; #sound-dai-cells = <0>;
Signature · 1 line
2.43.0
Re: [PATCH 2/2] arm64: dts: imx8mp-beacon-kit: Enable HDMI bridge HPD
Hi Adam,
Thank you for the patch.
Quoted 3 lines · Adam Ford
The DSI to HDMI bridge supports hot-plut-detect, but the driver didn't previously support a shared IRQ GPIO. With the driver updated, the interrupt can be added to the bridge.
You can reflow the commit message to 72 columns.
Quoted 1 line
Signed-off-by Adam Ford <[email protected]>
Quoted 13 lines
arch/arm64/boot/dts/freescale/imx8mp-beacon-kit.dts +2
-0@@ -405,6 +405,8 @@ adv_bridge: hdmi@3d { compatible = "adi,adv7535"; reg = <0x3d>, <0x3c>, <0x3e>, <0x3f>; reg-names = "main", "cec", "edid", "packet"; + interrupt-parent = <&gpio4>; + interrupts = <27 IRQ_TYPE_EDGE_FALLING>; adi,dsi-lanes = <4>; #sound-dai-cells = <0>;
Signature · 3 lines
Regards, Laurent Pinchart
Laurent Pinchart
reviewerHi Adam,
Thank you for the patch.
Quoted 13 lines · Adam Ford
The IRQ registration currently assumes that the GPIO is dedicated to it, but that may not necessarily be the case. If the board has another device sharing the IRQ, it won't be registered and the hot-plug detect fails. This is easily fixed by add the
IRQF_SHAREDflag.Signed-off-by Adam Ford <[email protected]>drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +0
-0
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_probe(struct i2c_client *i2c) · line 1322
Quoted 6 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +2
-1@@ -1318,7 +1318,8 @@ static int adv7511_probe(struct i2c_client *i2c) ret = devm_request_threaded_irq(dev, i2c->irq, NULL, adv7511_irq_handler, - IRQF_ONESHOT, dev_name(dev), + IRQF_ONESHOT | IRQF_SHARED, + dev_name(dev),
This looks fine, but the IRQ handler doesn't.
static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)
{
unsigned int irq0, irq1;
int ret;
ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0);
if (ret < 0)
return ret;
ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(1), &irq1);
if (ret < 0)
return ret;
regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0);
regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);
if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder)
schedule_work(&adv7511->hpd_work);
if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) {
adv7511->edid_read = true;
if (adv7511->i2c_main->irq)
wake_up_all(&adv7511->wq);
}#ifdef CONFIG_DRM_I2C_ADV7511_CEC adv7511_cec_irq_process(adv7511, irq1);
#endif
return 0; }
static irqreturn_t adv7511_irq_handler(int irq, void *devid)
{
struct adv7511 *adv7511 = devid;
int ret;
ret = adv7511_irq_process(adv7511, true);
return ret < 0 ? IRQ_NONE : IRQ_HANDLED;
}The function will return IRQ_HANDLED as long as the registers can be read, even if they don't report any interrupt.
Quoted 3 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +0
-0adv7511);if (ret) goto err_unregister_audio;
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 20 lines · Laurent Pinchart
Hi Adam,
Thank you for the patch.
Quoted 14 lines · Adam Ford
The IRQ registration currently assumes that the GPIO is dedicated to it, but that may not necessarily be the case. If the board has another device sharing the IRQ, it won't be registered and the hot-plug detect fails. This is easily fixed by add the
IRQF_SHAREDflag.Signed-off-by Adam Ford <[email protected]>drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +0
-0@@ -1318,7 +1318,8 @@ static int adv7511_probe(struct i2c_client *i2c)
Quoted 7 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_probe(struct i2c_client *i2c) · line 1322
Quoted 5 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +2
-1ret = devm_request_threaded_irq(dev, i2c->irq, NULL, adv7511_irq_handler, - IRQF_ONESHOT, dev_name(dev), + IRQF_ONESHOT | IRQF_SHARED, + dev_name(dev),This looks fine, but the IRQ handler doesn't.
Thanks for the review.
Quoted 13 lines
static int
adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd){ unsigned int irq0, irq1; int ret; ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); if (ret < 0) return ret; ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(1), &irq1); if (ret < 0) return ret;
If I did a check here and returned if there was no IRQ to handle, would that be sufficient?
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +0 -0
@@ -477,6 +477,11 @@ static int adv7511_irq_process(struct adv7511
*adv7511, bool process_hpd)
if (ret < 0)
return ret;+ /* If there is no IRQ to handle, exit indicating no IRQ handled */
+ if (!(irq0 & (ADV7511_INT0_HPD | ADV7511_INT0_EDID_READY)) &&
+ !(irq1 & ADV7511_INT1_DDC_ERROR))
+ return -1;
+
regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0);
regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);With this, I would expect adv7511_irq_handler to return IRQ_NONE. If you're OK with that approach, I can do that. If you want me to merge adv7511_irq_handler, and adv7511_irq_process, I can do that too to make the return codes a little more intuitive.
adam
Quoted 41 lines
regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0); regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1); if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder) schedule_work(&adv7511->hpd_work); if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) { adv7511->edid_read = true; if (adv7511->i2c_main->irq) wake_up_all(&adv7511->wq); }#ifdef CONFIG_DRM_I2C_ADV7511_CEC adv7511_cec_irq_process(adv7511, irq1);#endif
return 0; }static
irqreturn_tadv7511_irq_handler(int irq, void *devid){ struct adv7511 *adv7511 = devid; int ret; ret = adv7511_irq_process(adv7511, true); return ret < 0 ? IRQ_NONE : IRQ_HANDLED; }The function will return
IRQ_HANDLEDas long as the registers can be read, even if they don't report any interrupt.drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_probe(struct i2c_client *i2c) · line 1325
Quoted 3 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +0
-0adv7511);if (ret) goto err_unregister_audio;--
Regards,Laurent Pinchart
Laurent Pinchart
reviewerQuoted 45 lines · Adam Ford
Quoted 15 lines · Laurent Pinchart
Quoted 14 lines · Adam Ford
The IRQ registration currently assumes that the GPIO is dedicated to it, but that may not necessarily be the case. If the board has another device sharing the IRQ, it won't be registered and the hot-plug detect fails. This is easily fixed by add the
IRQF_SHAREDflag.Signed-off-by Adam Ford <[email protected]>drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +0
-0@@ -1318,7 +1318,8 @@ static int adv7511_probe(struct i2c_client *i2c)Quoted 7 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_probe(struct i2c_client *i2c) · line 1322
Quoted 5 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +2
-1ret = devm_request_threaded_irq(dev, i2c->irq, NULL, adv7511_irq_handler, - IRQF_ONESHOT, dev_name(dev), + IRQF_ONESHOT | IRQF_SHARED, + dev_name(dev),This looks fine, but the IRQ handler doesn't.
Thanks for the review.
Quoted 12 lines
static int
adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd){ unsigned int irq0, irq1; int ret; ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); if (ret < 0) return ret; ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(1), &irq1); if (ret < 0) return ret;If I did a check here and returned if there was no IRQ to handle, would that be sufficient?
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_irq_process(struct adv7511 · line 483
Quoted 7 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +3
-0@@ -477,6 +477,11 @@ static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)if (ret <0 )return ret; +/* If there is no IRQ to handle, exit indicating no IRQ handled */ +if (!(irq0 & (ADV7511_INT0_HPD |ADV7511_INT0_EDID_READY )) && + !(irq1 &ADV7511_INT1_DDC_ERROR ))
If these are the only interrupt sources that the driver enables, this is fine.
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_irq_process(struct adv7511 · line 484
Quoted 1 line
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +1
-0+return -1 ;
Maybe a defined error code instead ?
Quoted 45 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +1
-0+regmap_write (adv7511->regmap,ADV7511_REG_INT (0 ), irq0);regmap_write (adv7511->regmap,ADV7511_REG_INT (1 ), irq1);With this, I would expect
adv7511_irq_handlerto returnIRQ_NONE. If you're OK with that approach, I can do that. If you want me to mergeadv7511_irq_handler, andadv7511_irq_process, I can do that too to make the return codes a little more intuitive.Quoted 36 lines
regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0); regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1); if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder) schedule_work(&adv7511->hpd_work); if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) { adv7511->edid_read = true; if (adv7511->i2c_main->irq) wake_up_all(&adv7511->wq); }#ifdef CONFIG_DRM_I2C_ADV7511_CEC adv7511_cec_irq_process(adv7511, irq1);#endif
return 0; }static
irqreturn_tadv7511_irq_handler(int irq, void *devid){ struct adv7511 *adv7511 = devid; int ret; ret = adv7511_irq_process(adv7511, true); return ret < 0 ? IRQ_NONE : IRQ_HANDLED; }The function will return
IRQ_HANDLEDas long as the registers can be read, even if they don't report any interrupt.Quoted 3 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +0
-0adv7511);if (ret) goto err_unregister_audio;
Signature · 3 lines
Regards, Laurent Pinchart