Changes in v3:
- Added DPTX AUX block initialization before trying to communicate
to stop relying on the bootloader keeping it initialized before
booting Linux.
- Fixed commit description for patch [09/09] and removed commented
out code (that slipped from dev phase.. sorry!).
This series adds "real" support for eDP in the mtk-dp DisplayPort driver.
Explaining the "real":
Before this change, the DisplayPort driver did support eDP to some
extent, but it was treating it entirely like a regular DP interface
which is partially fine, after all, embedded DisplayPort *is* actually
DisplayPort, but there might be some differences to account for... and
this is for both small performance improvements and, more importantly,
for correct functionality in some systems.
Functionality first:
One of the common differences found in various boards implementing eDP
and machines using an eDP panel is that many times the HPD line is not
connected. This *must* be accounted for: at startup, this specific IP
will raise a HPD interrupt (which should maybe be ignored... as it does
not appear to be a "real" event...) that will make the eDP panel to be
detected and to actually work but, after a suspend-resume cycle, there
will be no HPD interrupt (as there's no HPD line in my case!) producing
a functionality issue - specifically, the DP Link Training fails because
the panel doesn't get powered up, then it stays black and won't work
until rebooting the machine (or removing and reinserting the module I
think, but I haven't tried that).
Now for.. both:
eDP panels are *e*DP because they are *not* removable (in the sense that
you can't unplug the cable without disassembling the machine, in which
case, the machine shall be powered down..!): this (correct) assumption
makes us able to solve some issues and to also gain a little performance
during PM operations.
What was done here is:
- Caching the EDID if the panel is eDP: we're always going to read the
same data everytime, so we can just cache that (as it's small enough)
shortening PM resume times for the eDP driver instance;
- Always return connector_status_connected if it's eDP: non-removable
means connector_status_disconnected can't happen during runtime...
this also saves us some time and even power, as we won't have to
perform yet another power cycle of the HW;
- Added aux-bus support!
This makes us able to rely on panel autodetection from the EDID,
avoiding to add more and more panel timings to panel-edp and, even
better, allowing to use one panel node in devicetrees for multiple
variants of the same machine since, at that point, it's not important
to "preventively know" what panel we have (eh, it's autodetected...!).
This was tested on a MT8195 Cherry Tomato Chromebook (panel-edp on aux-bus)
P.S.: For your own testing commodity, here's a reference devicetree:
&edp_tx {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&edptx_pins_default>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
edp_in: endpoint {
remote-endpoint = <&dp_intf0_out>;
};
};
port@1 {
reg = <1>;
edp_out: endpoint {
data-lanes = <0 1 2 3>;
remote-endpoint = <&panel_in>;
};
};
};
aux-bus {
panel: panel {
compatible = "edp-panel";
power-supply = <&pp3300_disp_x>;
backlight = <&backlight_lcd0>;
port {
panel_in: endpoint {
remote-endpoint = <&edp_out>;
};
};
};
};
};
AngeloGioacchino Del Regno (9):
drm/mediatek: dp: Cache EDID for eDP panel
drm/mediatek: dp: Move AUX and panel poweron/off sequence to function
drm/mediatek: dp: Always return connected status for eDP in .detect()
drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel
drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer()
drm/mediatek: dp: Enable event interrupt only when bridge attached
drm/mediatek: dp: Use devm variant of drm_bridge_add()
drm/mediatek: dp: Move AUX_P0 setting to
mtk_dp_initialize_aux_settings()
drm/mediatek: dp: Add support for embedded DisplayPort aux-bus
drivers/gpu/drm/mediatek/mtk_dp.c | 186 +++++++++++++++++++-----------
1 file changed, 116 insertions(+), 70 deletions(-)
--
2.40.0
In preparation for adding support for aux-bus, which will add a code
path that may fail after the drm_bridge_add() call, change that to
devm_drm_bridge_add() to simplify failure paths later.
Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_dp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index 6aaf162a6bfe..62d53c4b3feb 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -2565,7 +2565,7 @@ static int mtk_dp_probe(struct platform_device *pdev)
DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD;
mtk_dp->bridge.type = mtk_dp->data->bridge_type;
- drm_bridge_add(&mtk_dp->bridge);
+ devm_drm_bridge_add(dev, &mtk_dp->bridge);
mtk_dp->need_debounce = true;
timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0);
--
2.40.0
Move the register write to MTK_DP_AUX_P0_3690 to set the AUX reply mode
to function mtk_dp_initialize_aux_settings(), as this is effectively
part of the DPTX AUX setup sequence.
Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_dp.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index 62d53c4b3feb..a67143c22024 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -1012,6 +1012,11 @@ static void mtk_dp_initialize_aux_settings(struct mtk_dp *mtk_dp)
mtk_dp_update_bits(mtk_dp, MTK_DP_AUX_P0_37C8,
MTK_ATOP_EN_AUX_TX_P0,
MTK_ATOP_EN_AUX_TX_P0);
+
+ /* Set complete reply mode for AUX */
+ mtk_dp_update_bits(mtk_dp, MTK_DP_AUX_P0_3690,
+ RX_REPLY_COMPLETE_MODE_AUX_TX_P0,
+ RX_REPLY_COMPLETE_MODE_AUX_TX_P0);
}
static void mtk_dp_initialize_digital_settings(struct mtk_dp *mtk_dp)
@@ -1824,10 +1829,6 @@ static void mtk_dp_init_port(struct mtk_dp *mtk_dp)
mtk_dp_initialize_settings(mtk_dp);
mtk_dp_initialize_aux_settings(mtk_dp);
mtk_dp_initialize_digital_settings(mtk_dp);
-
- mtk_dp_update_bits(mtk_dp, MTK_DP_AUX_P0_3690,
- RX_REPLY_COMPLETE_MODE_AUX_TX_P0,
- RX_REPLY_COMPLETE_MODE_AUX_TX_P0);
mtk_dp_initialize_hpd_detect_settings(mtk_dp);
mtk_dp_digital_sw_reset(mtk_dp);
--
2.40.0
For the eDP case we can support using aux-bus on MediaTek DP: this
gives us the possibility to declare our panel as generic "panel-edp"
which will automatically configure the timings and available modes
via the EDID that we read from it.
To do this, move the panel parsing at the end of the probe function
so that the hardware is initialized beforehand and also initialize
the DPTX AUX block and power both on as, when we populate the
aux-bus, the panel driver will trigger an EDID read to perform
panel detection.
Last but not least, since now the AUX transfers can happen in the
separated aux-bus, it was necessary to add an exclusion for the
cable_plugged_in check in `mtk_dp_aux_transfer()` and the easiest
way to do this is to simply ignore checking that when the bridge
type is eDP.
Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_dp.c | 61 ++++++++++++++++++++++++++-----
1 file changed, 51 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index a67143c22024..8109f5b4392b 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -4,6 +4,7 @@
* Copyright (c) 2022 BayLibre
*/
+#include <drm/display/drm_dp_aux_bus.h>
#include <drm/display/drm_dp.h>
#include <drm/display/drm_dp_helper.h>
#include <drm/drm_atomic_helper.h>
@@ -2042,7 +2043,8 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux,
mtk_dp = container_of(mtk_aux, struct mtk_dp, aux);
- if (!mtk_dp->train_info.cable_plugged_in) {
+ if (mtk_dp->bridge.type != DRM_MODE_CONNECTOR_eDP &&
+ !mtk_dp->train_info.cable_plugged_in) {
ret = -EAGAIN;
goto err;
}
@@ -2154,6 +2156,11 @@ static int mtk_dp_bridge_attach(struct drm_bridge *bridge,
enable_irq(mtk_dp->irq);
mtk_dp_hwirq_enable(mtk_dp, true);
+ if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) {
+ mtk_dp->train_info.cable_plugged_in = true;
+ drm_helper_hpd_irq_event(mtk_dp->drm_dev);
+ }
+
return 0;
err_bridge_attach:
@@ -2483,6 +2490,20 @@ static int mtk_dp_register_audio_driver(struct device *dev)
return PTR_ERR_OR_ZERO(mtk_dp->audio_pdev);
}
+static int mtk_dp_edp_link_panel(struct drm_dp_aux *mtk_aux)
+{
+ struct mtk_dp *mtk_dp = container_of(mtk_aux, struct mtk_dp, aux);
+ struct device *dev = mtk_aux->dev;
+ struct drm_bridge *panel_aux_bridge;
+
+ panel_aux_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0);
+ if (IS_ERR(panel_aux_bridge))
+ return PTR_ERR(panel_aux_bridge);
+
+ mtk_dp->next_bridge = panel_aux_bridge;
+ return 0;
+}
+
static int mtk_dp_probe(struct platform_device *pdev)
{
struct mtk_dp *mtk_dp;
@@ -2501,21 +2522,14 @@ static int mtk_dp_probe(struct platform_device *pdev)
return dev_err_probe(dev, mtk_dp->irq,
"failed to request dp irq resource\n");
- mtk_dp->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0);
- if (IS_ERR(mtk_dp->next_bridge) &&
- PTR_ERR(mtk_dp->next_bridge) == -ENODEV)
- mtk_dp->next_bridge = NULL;
- else if (IS_ERR(mtk_dp->next_bridge))
- return dev_err_probe(dev, PTR_ERR(mtk_dp->next_bridge),
- "Failed to get bridge\n");
-
ret = mtk_dp_dt_parse(mtk_dp, pdev);
if (ret)
return dev_err_probe(dev, ret, "Failed to parse dt\n");
- drm_dp_aux_init(&mtk_dp->aux);
mtk_dp->aux.name = "aux_mtk_dp";
+ mtk_dp->aux.dev = dev;
mtk_dp->aux.transfer = mtk_dp_aux_transfer;
+ drm_dp_aux_init(&mtk_dp->aux);
spin_lock_init(&mtk_dp->irq_thread_lock);
@@ -2571,6 +2585,33 @@ static int mtk_dp_probe(struct platform_device *pdev)
mtk_dp->need_debounce = true;
timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0);
+ if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) {
+ /* Initialize, reset and poweron the DPTX AUX block */
+ mtk_dp_initialize_aux_settings(mtk_dp);
+ mtk_dp_power_enable(mtk_dp);
+
+ /* Power on the panel to allow EDID read from aux-bus */
+ mtk_dp_aux_panel_poweron(mtk_dp, true);
+
+ ret = devm_of_dp_aux_populate_bus(&mtk_dp->aux, NULL);
+
+ /* If the panel is present, detection is done: power off! */
+ mtk_dp_aux_panel_poweron(mtk_dp, false);
+ mtk_dp_power_disable(mtk_dp);
+
+ /* We ignore -ENODEV error, as the panel may not be on aux-bus */
+ if (ret && ret != -ENODEV)
+ return ret;
+
+ /*
+ * Here we don't ignore any error, as if there's no panel to
+ * link, eDP is not configured correctly and will be unusable.
+ */
+ ret = mtk_dp_edp_link_panel(&mtk_dp->aux);
+ if (ret)
+ return ret;
+ }
+
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
--
2.40.0
On Tue, Apr 4, 2023 at 6:48 PM AngeloGioacchino Del Regno
<[email protected]> wrote:
>
> Changes in v3:
> - Added DPTX AUX block initialization before trying to communicate
> to stop relying on the bootloader keeping it initialized before
> booting Linux.
> - Fixed commit description for patch [09/09] and removed commented
> out code (that slipped from dev phase.. sorry!).
>
> This series adds "real" support for eDP in the mtk-dp DisplayPort driver.
>
> Explaining the "real":
> Before this change, the DisplayPort driver did support eDP to some
> extent, but it was treating it entirely like a regular DP interface
> which is partially fine, after all, embedded DisplayPort *is* actually
> DisplayPort, but there might be some differences to account for... and
> this is for both small performance improvements and, more importantly,
> for correct functionality in some systems.
>
> Functionality first:
>
> One of the common differences found in various boards implementing eDP
> and machines using an eDP panel is that many times the HPD line is not
> connected. This *must* be accounted for: at startup, this specific IP
> will raise a HPD interrupt (which should maybe be ignored... as it does
> not appear to be a "real" event...) that will make the eDP panel to be
> detected and to actually work but, after a suspend-resume cycle, there
> will be no HPD interrupt (as there's no HPD line in my case!) producing
> a functionality issue - specifically, the DP Link Training fails because
> the panel doesn't get powered up, then it stays black and won't work
> until rebooting the machine (or removing and reinserting the module I
> think, but I haven't tried that).
>
> Now for.. both:
> eDP panels are *e*DP because they are *not* removable (in the sense that
> you can't unplug the cable without disassembling the machine, in which
> case, the machine shall be powered down..!): this (correct) assumption
> makes us able to solve some issues and to also gain a little performance
> during PM operations.
>
> What was done here is:
> - Caching the EDID if the panel is eDP: we're always going to read the
> same data everytime, so we can just cache that (as it's small enough)
> shortening PM resume times for the eDP driver instance;
> - Always return connector_status_connected if it's eDP: non-removable
> means connector_status_disconnected can't happen during runtime...
> this also saves us some time and even power, as we won't have to
> perform yet another power cycle of the HW;
> - Added aux-bus support!
> This makes us able to rely on panel autodetection from the EDID,
> avoiding to add more and more panel timings to panel-edp and, even
> better, allowing to use one panel node in devicetrees for multiple
> variants of the same machine since, at that point, it's not important
> to "preventively know" what panel we have (eh, it's autodetected...!).
>
> This was tested on a MT8195 Cherry Tomato Chromebook (panel-edp on aux-bus)
>
>
> P.S.: For your own testing commodity, here's a reference devicetree:
> &edp_tx {
> status = "okay";
>
> pinctrl-names = "default";
> pinctrl-0 = <&edptx_pins_default>;
>
> ports {
> #address-cells = <1>;
> #size-cells = <0>;
>
> port@0 {
> reg = <0>;
> edp_in: endpoint {
> remote-endpoint = <&dp_intf0_out>;
> };
> };
>
> port@1 {
> reg = <1>;
> edp_out: endpoint {
> data-lanes = <0 1 2 3>;
> remote-endpoint = <&panel_in>;
> };
> };
> };
>
> aux-bus {
> panel: panel {
> compatible = "edp-panel";
> power-supply = <&pp3300_disp_x>;
> backlight = <&backlight_lcd0>;
> port {
> panel_in: endpoint {
> remote-endpoint = <&edp_out>;
> };
> };
> };
> };
> };
>
> AngeloGioacchino Del Regno (9):
> drm/mediatek: dp: Cache EDID for eDP panel
> drm/mediatek: dp: Move AUX and panel poweron/off sequence to function
> drm/mediatek: dp: Always return connected status for eDP in .detect()
> drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel
> drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer()
> drm/mediatek: dp: Enable event interrupt only when bridge attached
> drm/mediatek: dp: Use devm variant of drm_bridge_add()
> drm/mediatek: dp: Move AUX_P0 setting to
> mtk_dp_initialize_aux_settings()
> drm/mediatek: dp: Add support for embedded DisplayPort aux-bus
Tested-by: Chen-Yu Tsai <[email protected]>
on MT8195 Tomato: eDP panel works if the display panel regulator is always
on. External DP works.
Maybe it has something to do with the driver not supporting .wait_hpd_asserted
and not using a GPIO for HPD?
Il 06/04/23 09:20, Chen-Yu Tsai ha scritto:
> On Tue, Apr 4, 2023 at 6:48 PM AngeloGioacchino Del Regno
> <[email protected]> wrote:
>>
>> Changes in v3:
>> - Added DPTX AUX block initialization before trying to communicate
>> to stop relying on the bootloader keeping it initialized before
>> booting Linux.
>> - Fixed commit description for patch [09/09] and removed commented
>> out code (that slipped from dev phase.. sorry!).
>>
>> This series adds "real" support for eDP in the mtk-dp DisplayPort driver.
>>
>> Explaining the "real":
>> Before this change, the DisplayPort driver did support eDP to some
>> extent, but it was treating it entirely like a regular DP interface
>> which is partially fine, after all, embedded DisplayPort *is* actually
>> DisplayPort, but there might be some differences to account for... and
>> this is for both small performance improvements and, more importantly,
>> for correct functionality in some systems.
>>
>> Functionality first:
>>
>> One of the common differences found in various boards implementing eDP
>> and machines using an eDP panel is that many times the HPD line is not
>> connected. This *must* be accounted for: at startup, this specific IP
>> will raise a HPD interrupt (which should maybe be ignored... as it does
>> not appear to be a "real" event...) that will make the eDP panel to be
>> detected and to actually work but, after a suspend-resume cycle, there
>> will be no HPD interrupt (as there's no HPD line in my case!) producing
>> a functionality issue - specifically, the DP Link Training fails because
>> the panel doesn't get powered up, then it stays black and won't work
>> until rebooting the machine (or removing and reinserting the module I
>> think, but I haven't tried that).
>>
>> Now for.. both:
>> eDP panels are *e*DP because they are *not* removable (in the sense that
>> you can't unplug the cable without disassembling the machine, in which
>> case, the machine shall be powered down..!): this (correct) assumption
>> makes us able to solve some issues and to also gain a little performance
>> during PM operations.
>>
>> What was done here is:
>> - Caching the EDID if the panel is eDP: we're always going to read the
>> same data everytime, so we can just cache that (as it's small enough)
>> shortening PM resume times for the eDP driver instance;
>> - Always return connector_status_connected if it's eDP: non-removable
>> means connector_status_disconnected can't happen during runtime...
>> this also saves us some time and even power, as we won't have to
>> perform yet another power cycle of the HW;
>> - Added aux-bus support!
>> This makes us able to rely on panel autodetection from the EDID,
>> avoiding to add more and more panel timings to panel-edp and, even
>> better, allowing to use one panel node in devicetrees for multiple
>> variants of the same machine since, at that point, it's not important
>> to "preventively know" what panel we have (eh, it's autodetected...!).
>>
>> This was tested on a MT8195 Cherry Tomato Chromebook (panel-edp on aux-bus)
>>
>>
>> P.S.: For your own testing commodity, here's a reference devicetree:
>> &edp_tx {
>> status = "okay";
>>
>> pinctrl-names = "default";
>> pinctrl-0 = <&edptx_pins_default>;
>>
>> ports {
>> #address-cells = <1>;
>> #size-cells = <0>;
>>
>> port@0 {
>> reg = <0>;
>> edp_in: endpoint {
>> remote-endpoint = <&dp_intf0_out>;
>> };
>> };
>>
>> port@1 {
>> reg = <1>;
>> edp_out: endpoint {
>> data-lanes = <0 1 2 3>;
>> remote-endpoint = <&panel_in>;
>> };
>> };
>> };
>>
>> aux-bus {
>> panel: panel {
>> compatible = "edp-panel";
>> power-supply = <&pp3300_disp_x>;
>> backlight = <&backlight_lcd0>;
>> port {
>> panel_in: endpoint {
>> remote-endpoint = <&edp_out>;
>> };
>> };
>> };
>> };
>> };
>>
>> AngeloGioacchino Del Regno (9):
>> drm/mediatek: dp: Cache EDID for eDP panel
>> drm/mediatek: dp: Move AUX and panel poweron/off sequence to function
>> drm/mediatek: dp: Always return connected status for eDP in .detect()
>> drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel
>> drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer()
>> drm/mediatek: dp: Enable event interrupt only when bridge attached
>> drm/mediatek: dp: Use devm variant of drm_bridge_add()
>> drm/mediatek: dp: Move AUX_P0 setting to
>> mtk_dp_initialize_aux_settings()
>> drm/mediatek: dp: Add support for embedded DisplayPort aux-bus
>
> Tested-by: Chen-Yu Tsai <[email protected]>
>
> on MT8195 Tomato: eDP panel works if the display panel regulator is always
> on. External DP works.
>
> Maybe it has something to do with the driver not supporting .wait_hpd_asserted
> and not using a GPIO for HPD?
Even before this change I couldn't get the panel to reliably work without keeping
the regulator always on (just to point out that I'm not introducing regressions).
I am already trying to understand why this happens... and I'm still researching...
but there's what I've seen for now:
* Set the panel regulator as regulator-boot-on;
* Boot: edp-panel will correctly read the EDID, then will run the PM suspend
handler
* mtk-dp's .get_edid() callback gets called but, at that time, edp-panel will
still be suspended (PM resume handler didn't get called)
* Regulator is still down
* Failure.
That's not right and probably the .get_edid() callback in mtk-dp has an abuse:
there, mtk_dp_parse_capabilities() gets called, which performs initialization
of some variables for DP link training (essential to get the DP going!).
The question that I am making to myself is whether I should move that elsewhere,
if so, what's the right place (making me able to remove the DRM_BRIDGE_OP_EDID
bridge flag when eDP + aux-bus), or if I should leave that and make sure that the
panel-edp's resume callback is called before .get_edid() from mtk-dp gets called.
That can get done in a separated series (or single patch?)... so that if we get
this one picked sooner than later, we can start upstreaming the panel nodes in
the Cherry devicetrees and only remove the regulator-always-on later.
Thoughts?
Cheers,
Angelo
On Thu, Apr 6, 2023 at 4:25 PM AngeloGioacchino Del Regno
<[email protected]> wrote:
>
> Il 06/04/23 09:20, Chen-Yu Tsai ha scritto:
> > On Tue, Apr 4, 2023 at 6:48 PM AngeloGioacchino Del Regno
> > <[email protected]> wrote:
> >>
> >> Changes in v3:
> >> - Added DPTX AUX block initialization before trying to communicate
> >> to stop relying on the bootloader keeping it initialized before
> >> booting Linux.
> >> - Fixed commit description for patch [09/09] and removed commented
> >> out code (that slipped from dev phase.. sorry!).
> >>
> >> This series adds "real" support for eDP in the mtk-dp DisplayPort driver.
> >>
> >> Explaining the "real":
> >> Before this change, the DisplayPort driver did support eDP to some
> >> extent, but it was treating it entirely like a regular DP interface
> >> which is partially fine, after all, embedded DisplayPort *is* actually
> >> DisplayPort, but there might be some differences to account for... and
> >> this is for both small performance improvements and, more importantly,
> >> for correct functionality in some systems.
> >>
> >> Functionality first:
> >>
> >> One of the common differences found in various boards implementing eDP
> >> and machines using an eDP panel is that many times the HPD line is not
> >> connected. This *must* be accounted for: at startup, this specific IP
> >> will raise a HPD interrupt (which should maybe be ignored... as it does
> >> not appear to be a "real" event...) that will make the eDP panel to be
> >> detected and to actually work but, after a suspend-resume cycle, there
> >> will be no HPD interrupt (as there's no HPD line in my case!) producing
> >> a functionality issue - specifically, the DP Link Training fails because
> >> the panel doesn't get powered up, then it stays black and won't work
> >> until rebooting the machine (or removing and reinserting the module I
> >> think, but I haven't tried that).
> >>
> >> Now for.. both:
> >> eDP panels are *e*DP because they are *not* removable (in the sense that
> >> you can't unplug the cable without disassembling the machine, in which
> >> case, the machine shall be powered down..!): this (correct) assumption
> >> makes us able to solve some issues and to also gain a little performance
> >> during PM operations.
> >>
> >> What was done here is:
> >> - Caching the EDID if the panel is eDP: we're always going to read the
> >> same data everytime, so we can just cache that (as it's small enough)
> >> shortening PM resume times for the eDP driver instance;
> >> - Always return connector_status_connected if it's eDP: non-removable
> >> means connector_status_disconnected can't happen during runtime...
> >> this also saves us some time and even power, as we won't have to
> >> perform yet another power cycle of the HW;
> >> - Added aux-bus support!
> >> This makes us able to rely on panel autodetection from the EDID,
> >> avoiding to add more and more panel timings to panel-edp and, even
> >> better, allowing to use one panel node in devicetrees for multiple
> >> variants of the same machine since, at that point, it's not important
> >> to "preventively know" what panel we have (eh, it's autodetected...!).
> >>
> >> This was tested on a MT8195 Cherry Tomato Chromebook (panel-edp on aux-bus)
> >>
> >>
> >> P.S.: For your own testing commodity, here's a reference devicetree:
> >> &edp_tx {
> >> status = "okay";
> >>
> >> pinctrl-names = "default";
> >> pinctrl-0 = <&edptx_pins_default>;
> >>
> >> ports {
> >> #address-cells = <1>;
> >> #size-cells = <0>;
> >>
> >> port@0 {
> >> reg = <0>;
> >> edp_in: endpoint {
> >> remote-endpoint = <&dp_intf0_out>;
> >> };
> >> };
> >>
> >> port@1 {
> >> reg = <1>;
> >> edp_out: endpoint {
> >> data-lanes = <0 1 2 3>;
> >> remote-endpoint = <&panel_in>;
> >> };
> >> };
> >> };
> >>
> >> aux-bus {
> >> panel: panel {
> >> compatible = "edp-panel";
> >> power-supply = <&pp3300_disp_x>;
> >> backlight = <&backlight_lcd0>;
> >> port {
> >> panel_in: endpoint {
> >> remote-endpoint = <&edp_out>;
> >> };
> >> };
> >> };
> >> };
> >> };
> >>
> >> AngeloGioacchino Del Regno (9):
> >> drm/mediatek: dp: Cache EDID for eDP panel
> >> drm/mediatek: dp: Move AUX and panel poweron/off sequence to function
> >> drm/mediatek: dp: Always return connected status for eDP in .detect()
> >> drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel
> >> drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer()
> >> drm/mediatek: dp: Enable event interrupt only when bridge attached
> >> drm/mediatek: dp: Use devm variant of drm_bridge_add()
> >> drm/mediatek: dp: Move AUX_P0 setting to
> >> mtk_dp_initialize_aux_settings()
> >> drm/mediatek: dp: Add support for embedded DisplayPort aux-bus
> >
> > Tested-by: Chen-Yu Tsai <[email protected]>
> >
> > on MT8195 Tomato: eDP panel works if the display panel regulator is always
> > on. External DP works.
> >
> > Maybe it has something to do with the driver not supporting .wait_hpd_asserted
> > and not using a GPIO for HPD?
>
> Even before this change I couldn't get the panel to reliably work without keeping
> the regulator always on (just to point out that I'm not introducing regressions).
>
> I am already trying to understand why this happens... and I'm still researching...
> but there's what I've seen for now:
> * Set the panel regulator as regulator-boot-on;
This simply means when the regulator driver grabs the GPIO, it will grab it
with output high. It will make no attempt to keep it on.
> * Boot: edp-panel will correctly read the EDID, then will run the PM suspend
> handler
> * mtk-dp's .get_edid() callback gets called but, at that time, edp-panel will
> still be suspended (PM resume handler didn't get called)
> * Regulator is still down
> * Failure.
> That's not right and probably the .get_edid() callback in mtk-dp has an abuse:
> there, mtk_dp_parse_capabilities() gets called, which performs initialization
> of some variables for DP link training (essential to get the DP going!).
I think that's wrong.
> The question that I am making to myself is whether I should move that elsewhere,
> if so, what's the right place (making me able to remove the DRM_BRIDGE_OP_EDID
> bridge flag when eDP + aux-bus), or if I should leave that and make sure that the
> panel-edp's resume callback is called before .get_edid() from mtk-dp gets called.
I think that's a proper change. Some of the callbacks in the DP driver are
doing suspicious things, as if the driver came from an era without bridge
drivers, and was not properly split up to fit the new bridge semantics.
Same probably goes for the HPD detection.
> That can get done in a separated series (or single patch?)... so that if we get
> this one picked sooner than later, we can start upstreaming the panel nodes in
> the Cherry devicetrees and only remove the regulator-always-on later.
I guess that works? Except for battery life lol. It's really up to CK.
And it's probably too late to upstream the panel nodes for the upcoming
cycle.
ChenYu
Il 04/04/23 12:47, AngeloGioacchino Del Regno ha scritto:
Hello CK,
Gentle ping for this series.
Thanks,
Angelo
> Changes in v3:
> - Added DPTX AUX block initialization before trying to communicate
> to stop relying on the bootloader keeping it initialized before
> booting Linux.
> - Fixed commit description for patch [09/09] and removed commented
> out code (that slipped from dev phase.. sorry!).
>
> This series adds "real" support for eDP in the mtk-dp DisplayPort driver.
>
> Explaining the "real":
> Before this change, the DisplayPort driver did support eDP to some
> extent, but it was treating it entirely like a regular DP interface
> which is partially fine, after all, embedded DisplayPort *is* actually
> DisplayPort, but there might be some differences to account for... and
> this is for both small performance improvements and, more importantly,
> for correct functionality in some systems.
>
> Functionality first:
>
> One of the common differences found in various boards implementing eDP
> and machines using an eDP panel is that many times the HPD line is not
> connected. This *must* be accounted for: at startup, this specific IP
> will raise a HPD interrupt (which should maybe be ignored... as it does
> not appear to be a "real" event...) that will make the eDP panel to be
> detected and to actually work but, after a suspend-resume cycle, there
> will be no HPD interrupt (as there's no HPD line in my case!) producing
> a functionality issue - specifically, the DP Link Training fails because
> the panel doesn't get powered up, then it stays black and won't work
> until rebooting the machine (or removing and reinserting the module I
> think, but I haven't tried that).
>
> Now for.. both:
> eDP panels are *e*DP because they are *not* removable (in the sense that
> you can't unplug the cable without disassembling the machine, in which
> case, the machine shall be powered down..!): this (correct) assumption
> makes us able to solve some issues and to also gain a little performance
> during PM operations.
>
> What was done here is:
> - Caching the EDID if the panel is eDP: we're always going to read the
> same data everytime, so we can just cache that (as it's small enough)
> shortening PM resume times for the eDP driver instance;
> - Always return connector_status_connected if it's eDP: non-removable
> means connector_status_disconnected can't happen during runtime...
> this also saves us some time and even power, as we won't have to
> perform yet another power cycle of the HW;
> - Added aux-bus support!
> This makes us able to rely on panel autodetection from the EDID,
> avoiding to add more and more panel timings to panel-edp and, even
> better, allowing to use one panel node in devicetrees for multiple
> variants of the same machine since, at that point, it's not important
> to "preventively know" what panel we have (eh, it's autodetected...!).
>
> This was tested on a MT8195 Cherry Tomato Chromebook (panel-edp on aux-bus)
>
>
> P.S.: For your own testing commodity, here's a reference devicetree:
> &edp_tx {
> status = "okay";
>
> pinctrl-names = "default";
> pinctrl-0 = <&edptx_pins_default>;
>
> ports {
> #address-cells = <1>;
> #size-cells = <0>;
>
> port@0 {
> reg = <0>;
> edp_in: endpoint {
> remote-endpoint = <&dp_intf0_out>;
> };
> };
>
> port@1 {
> reg = <1>;
> edp_out: endpoint {
> data-lanes = <0 1 2 3>;
> remote-endpoint = <&panel_in>;
> };
> };
> };
>
> aux-bus {
> panel: panel {
> compatible = "edp-panel";
> power-supply = <&pp3300_disp_x>;
> backlight = <&backlight_lcd0>;
> port {
> panel_in: endpoint {
> remote-endpoint = <&edp_out>;
> };
> };
> };
> };
> };
>
> AngeloGioacchino Del Regno (9):
> drm/mediatek: dp: Cache EDID for eDP panel
> drm/mediatek: dp: Move AUX and panel poweron/off sequence to function
> drm/mediatek: dp: Always return connected status for eDP in .detect()
> drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel
> drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer()
> drm/mediatek: dp: Enable event interrupt only when bridge attached
> drm/mediatek: dp: Use devm variant of drm_bridge_add()
> drm/mediatek: dp: Move AUX_P0 setting to
> mtk_dp_initialize_aux_settings()
> drm/mediatek: dp: Add support for embedded DisplayPort aux-bus
>
> drivers/gpu/drm/mediatek/mtk_dp.c | 186 +++++++++++++++++++-----------
> 1 file changed, 116 insertions(+), 70 deletions(-)
>
On Tue, Apr 04, 2023 at 12:48:00PM +0200, AngeloGioacchino Del Regno wrote:
> For the eDP case we can support using aux-bus on MediaTek DP: this
> gives us the possibility to declare our panel as generic "panel-edp"
> which will automatically configure the timings and available modes
> via the EDID that we read from it.
>
> To do this, move the panel parsing at the end of the probe function
> so that the hardware is initialized beforehand and also initialize
> the DPTX AUX block and power both on as, when we populate the
> aux-bus, the panel driver will trigger an EDID read to perform
> panel detection.
>
> Last but not least, since now the AUX transfers can happen in the
> separated aux-bus, it was necessary to add an exclusion for the
> cable_plugged_in check in `mtk_dp_aux_transfer()` and the easiest
> way to do this is to simply ignore checking that when the bridge
> type is eDP.
>
> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
> ---
> drivers/gpu/drm/mediatek/mtk_dp.c | 61 ++++++++++++++++++++++++++-----
> 1 file changed, 51 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
> index a67143c22024..8109f5b4392b 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
[..]
> @@ -2571,6 +2585,33 @@ static int mtk_dp_probe(struct platform_device *pdev)
> mtk_dp->need_debounce = true;
> timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0);
>
> + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) {
> + /* Initialize, reset and poweron the DPTX AUX block */
> + mtk_dp_initialize_aux_settings(mtk_dp);
> + mtk_dp_power_enable(mtk_dp);
> +
> + /* Power on the panel to allow EDID read from aux-bus */
> + mtk_dp_aux_panel_poweron(mtk_dp, true);
> +
> + ret = devm_of_dp_aux_populate_bus(&mtk_dp->aux, NULL);
This patch causes
.../bin/aarch64-none-linux-gnu-ld: Unexpected GOT/PLT entries detected!
.../bin/aarch64-none-linux-gnu-ld: Unexpected run-time procedure linkages detected!
.../bin/aarch64-none-linux-gnu-ld: drivers/gpu/drm/mediatek/mtk_dp.o: in function `mtk_dp_probe':
.../drivers/gpu/drm/mediatek/mtk_dp.c:2595: undefined reference to `devm_of_dp_aux_populate_bus'
You need
diff --git a/drivers/gpu/drm/mediatek/Kconfig b/drivers/gpu/drm/mediatek/Kconfig
index b451dee64d34..76cab28e010c 100644
--- a/drivers/gpu/drm/mediatek/Kconfig
+++ b/drivers/gpu/drm/mediatek/Kconfig
@@ -26,6 +26,7 @@ config DRM_MEDIATEK_DP
select PHY_MTK_DP
select DRM_DISPLAY_HELPER
select DRM_DISPLAY_DP_HELPER
+ select DRM_DP_AUX_BUS
help
DRM/KMS Display Port driver for MediaTek SoCs.
Thanks,
N?colas
On Tue, Apr 04, 2023 at 12:48:00PM +0200, AngeloGioacchino Del Regno wrote:
> For the eDP case we can support using aux-bus on MediaTek DP: this
> gives us the possibility to declare our panel as generic "panel-edp"
> which will automatically configure the timings and available modes
> via the EDID that we read from it.
>
> To do this, move the panel parsing at the end of the probe function
> so that the hardware is initialized beforehand and also initialize
> the DPTX AUX block and power both on as, when we populate the
> aux-bus, the panel driver will trigger an EDID read to perform
> panel detection.
>
> Last but not least, since now the AUX transfers can happen in the
> separated aux-bus, it was necessary to add an exclusion for the
> cable_plugged_in check in `mtk_dp_aux_transfer()` and the easiest
> way to do this is to simply ignore checking that when the bridge
> type is eDP.
>
> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
> ---
> drivers/gpu/drm/mediatek/mtk_dp.c | 61 ++++++++++++++++++++++++++-----
> 1 file changed, 51 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
> index a67143c22024..8109f5b4392b 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
[..]
> @@ -2571,6 +2585,33 @@ static int mtk_dp_probe(struct platform_device *pdev)
> mtk_dp->need_debounce = true;
> timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0);
>
> + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) {
> + /* Initialize, reset and poweron the DPTX AUX block */
> + mtk_dp_initialize_aux_settings(mtk_dp);
> + mtk_dp_power_enable(mtk_dp);
> +
> + /* Power on the panel to allow EDID read from aux-bus */
> + mtk_dp_aux_panel_poweron(mtk_dp, true);
> +
> + ret = devm_of_dp_aux_populate_bus(&mtk_dp->aux, NULL);
> +
> + /* If the panel is present, detection is done: power off! */
> + mtk_dp_aux_panel_poweron(mtk_dp, false);
> + mtk_dp_power_disable(mtk_dp);
> +
> + /* We ignore -ENODEV error, as the panel may not be on aux-bus */
> + if (ret && ret != -ENODEV)
> + return ret;
> +
> + /*
> + * Here we don't ignore any error, as if there's no panel to
> + * link, eDP is not configured correctly and will be unusable.
> + */
> + ret = mtk_dp_edp_link_panel(&mtk_dp->aux);
This call might return EDEFER_PROBE if the panel hasn't probed yet. That's a
problem, because during this probe you register a device for the dp-phy, so
you'll be retriggering defer probes every time you probe until the panel probes.
But if this driver was builtin and the panel a module, then this loop will go on
forever.
You should make use of the done_probing callback in
devm_of_dp_aux_populate_bus() and do the panel linking there. This way you can
exit successfully from this probe and avoid the loop. I had to do the same thing
for anx7625.c [1].
Thanks,
N?colas
[1] https://lore.kernel.org/all/[email protected]/