Skip to content

Commit 9bf3797

Browse files
Saravana Kannanmripard
authored andcommitted
drm/sun4i: dw-hdmi: Make HDMI PHY into a platform device
On sunxi boards that use HDMI output, HDMI device probe keeps being avoided indefinitely with these repeated messages in dmesg: platform 1ee0000.hdmi: probe deferral - supplier 1ef0000.hdmi-phy not ready There's a fwnode_link being created with fw_devlink=on between hdmi and hdmi-phy nodes, because both nodes have 'compatible' property set. Fw_devlink code assumes that nodes that have compatible property set will also have a device associated with them by some driver eventually. This is not the case with the current sun8i-hdmi driver. This commit makes sun8i-hdmi-phy into a proper platform device and fixes the display pipeline probe on sunxi boards that use HDMI. More context: https://lkml.org/lkml/2021/5/16/203 Signed-off-by: Saravana Kannan <[email protected]> Signed-off-by: Ondrej Jirman <[email protected]> Tested-by: Andre Przywara <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 0b78f8b commit 9bf3797

File tree

3 files changed

+66
-11
lines changed

3 files changed

+66
-11
lines changed

drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
209209
goto err_disable_clk_tmds;
210210
}
211211

212-
ret = sun8i_hdmi_phy_probe(hdmi, phy_node);
212+
ret = sun8i_hdmi_phy_get(hdmi, phy_node);
213213
of_node_put(phy_node);
214214
if (ret) {
215215
dev_err(dev, "Couldn't get the HDMI PHY\n");
@@ -242,7 +242,6 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
242242

243243
cleanup_encoder:
244244
drm_encoder_cleanup(encoder);
245-
sun8i_hdmi_phy_remove(hdmi);
246245
err_disable_clk_tmds:
247246
clk_disable_unprepare(hdmi->clk_tmds);
248247
err_assert_ctrl_reset:
@@ -263,7 +262,6 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master,
263262
struct sun8i_dw_hdmi *hdmi = dev_get_drvdata(dev);
264263

265264
dw_hdmi_unbind(hdmi->hdmi);
266-
sun8i_hdmi_phy_remove(hdmi);
267265
clk_disable_unprepare(hdmi->clk_tmds);
268266
reset_control_assert(hdmi->rst_ctrl);
269267
gpiod_set_value(hdmi->ddc_en, 0);
@@ -320,7 +318,32 @@ static struct platform_driver sun8i_dw_hdmi_pltfm_driver = {
320318
.of_match_table = sun8i_dw_hdmi_dt_ids,
321319
},
322320
};
323-
module_platform_driver(sun8i_dw_hdmi_pltfm_driver);
321+
322+
static int __init sun8i_dw_hdmi_init(void)
323+
{
324+
int ret;
325+
326+
ret = platform_driver_register(&sun8i_dw_hdmi_pltfm_driver);
327+
if (ret)
328+
return ret;
329+
330+
ret = platform_driver_register(&sun8i_hdmi_phy_driver);
331+
if (ret) {
332+
platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver);
333+
return ret;
334+
}
335+
336+
return ret;
337+
}
338+
339+
static void __exit sun8i_dw_hdmi_exit(void)
340+
{
341+
platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver);
342+
platform_driver_unregister(&sun8i_hdmi_phy_driver);
343+
}
344+
345+
module_init(sun8i_dw_hdmi_init);
346+
module_exit(sun8i_dw_hdmi_exit);
324347

325348
MODULE_AUTHOR("Jernej Skrabec <[email protected]>");
326349
MODULE_DESCRIPTION("Allwinner DW HDMI bridge");

drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,15 @@ struct sun8i_dw_hdmi {
195195
struct gpio_desc *ddc_en;
196196
};
197197

198+
extern struct platform_driver sun8i_hdmi_phy_driver;
199+
198200
static inline struct sun8i_dw_hdmi *
199201
encoder_to_sun8i_dw_hdmi(struct drm_encoder *encoder)
200202
{
201203
return container_of(encoder, struct sun8i_dw_hdmi, encoder);
202204
}
203205

204-
int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node);
205-
void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi);
206+
int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node);
206207

207208
void sun8i_hdmi_phy_init(struct sun8i_hdmi_phy *phy);
208209
void sun8i_hdmi_phy_set_ops(struct sun8i_hdmi_phy *phy,

drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <linux/delay.h>
77
#include <linux/of_address.h>
8+
#include <linux/of_platform.h>
89

910
#include "sun8i_dw_hdmi.h"
1011

@@ -597,10 +598,30 @@ static const struct of_device_id sun8i_hdmi_phy_of_table[] = {
597598
{ /* sentinel */ }
598599
};
599600

600-
int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
601+
int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
602+
{
603+
struct platform_device *pdev = of_find_device_by_node(node);
604+
struct sun8i_hdmi_phy *phy;
605+
606+
if (!pdev)
607+
return -EPROBE_DEFER;
608+
609+
phy = platform_get_drvdata(pdev);
610+
if (!phy)
611+
return -EPROBE_DEFER;
612+
613+
hdmi->phy = phy;
614+
615+
put_device(&pdev->dev);
616+
617+
return 0;
618+
}
619+
620+
static int sun8i_hdmi_phy_probe(struct platform_device *pdev)
601621
{
602622
const struct of_device_id *match;
603-
struct device *dev = hdmi->dev;
623+
struct device *dev = &pdev->dev;
624+
struct device_node *node = dev->of_node;
604625
struct sun8i_hdmi_phy *phy;
605626
struct resource res;
606627
void __iomem *regs;
@@ -704,7 +725,7 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
704725
clk_prepare_enable(phy->clk_phy);
705726
}
706727

707-
hdmi->phy = phy;
728+
platform_set_drvdata(pdev, phy);
708729

709730
return 0;
710731

@@ -728,9 +749,9 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
728749
return ret;
729750
}
730751

731-
void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi)
752+
static int sun8i_hdmi_phy_remove(struct platform_device *pdev)
732753
{
733-
struct sun8i_hdmi_phy *phy = hdmi->phy;
754+
struct sun8i_hdmi_phy *phy = platform_get_drvdata(pdev);
734755

735756
clk_disable_unprepare(phy->clk_mod);
736757
clk_disable_unprepare(phy->clk_bus);
@@ -744,4 +765,14 @@ void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi)
744765
clk_put(phy->clk_pll1);
745766
clk_put(phy->clk_mod);
746767
clk_put(phy->clk_bus);
768+
return 0;
747769
}
770+
771+
struct platform_driver sun8i_hdmi_phy_driver = {
772+
.probe = sun8i_hdmi_phy_probe,
773+
.remove = sun8i_hdmi_phy_remove,
774+
.driver = {
775+
.name = "sun8i-hdmi-phy",
776+
.of_match_table = sun8i_hdmi_phy_of_table,
777+
},
778+
};

0 commit comments

Comments
 (0)