inno_hdmi_bind() both sets up the bridge and attaches it to a DRM encoder. A platform whose HDMI controller is a child of a larger device needs the first half without the second, since it registers as its own platform driver and lets the DRM core bind the bridge later.
Move the setup into a new exported inno_hdmi_probe(), and reduce inno_hdmi_bind() to a wrapper around it. Like inno_hdmi_probe() and dw_hdmi_bind(), it now takes the platform_device, so the Rockchip glue does the to_platform_device() conversion instead. No functional change intended. Reviewed-by: Joshua Peisach <[email protected]> Tested-by: Byron Stanoszek <[email protected]> Tested-by: OOHehir <[email protected]> Signed-off-by: Michal Wilczynski <[email protected]> --- drivers/gpu/drm/bridge/inno-hdmi.c | 39 +++++++++++++++++++++++---- drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c | 2 +- include/drm/bridge/inno_hdmi.h | 6 ++++- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/inno-hdmi.c b/drivers/gpu/drm/bridge/inno-hdmi.c index d29832249b942dec84fb9d07a0b21ee751fc0486..222f6522844ee60ae9a07ab2dcca748dbf7403e4 100644 --- a/drivers/gpu/drm/bridge/inno-hdmi.c +++ b/drivers/gpu/drm/bridge/inno-hdmi.c @@ -1067,11 +1067,24 @@ static struct i2c_adapter *inno_hdmi_i2c_adapter(struct inno_hdmi *hdmi) return adap; } -struct inno_hdmi *inno_hdmi_bind(struct device *dev, - struct drm_encoder *encoder, - const struct inno_hdmi_plat_data *plat_data) +/** + * inno_hdmi_probe - Internal helper to perform common setup + * @pdev: platform device + * @plat_data: SoC-specific platform data + * + * This function handles all the common hardware setup: allocating the main + * struct, mapping registers, getting clocks, initializing the hardware, + * setting up the IRQ, and initializing the DDC adapter and bridge struct. + * + * It registers the bridge but does not attach it, for glue drivers that probe + * as their own platform device rather than through a component bind. + * + * Return: the inno_hdmi instance on success, or an ERR_PTR() on failure. + */ +struct inno_hdmi *inno_hdmi_probe(struct platform_device *pdev, + const struct inno_hdmi_plat_data *plat_data) { - struct platform_device *pdev = to_platform_device(dev); + struct device *dev = &pdev->dev; struct inno_hdmi *hdmi; int irq; int ret; @@ -1134,7 +1147,23 @@ struct inno_hdmi *inno_hdmi_bind(struct device *dev, if (ret) return ERR_PTR(ret); - ret = drm_bridge_attach(encoder, &hdmi->bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR); + return hdmi; +} +EXPORT_SYMBOL_GPL(inno_hdmi_probe); + +struct inno_hdmi *inno_hdmi_bind(struct platform_device *pdev, + struct drm_encoder *encoder, + const struct inno_hdmi_plat_data *plat_data) +{ + struct inno_hdmi *hdmi; + int ret; + + hdmi = inno_hdmi_probe(pdev, plat_data); + if (IS_ERR(hdmi)) + return hdmi; + + ret = drm_bridge_attach(encoder, &hdmi->bridge, NULL, + DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret) return ERR_PTR(ret); diff --git a/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c index 33ff195bd2e65367792710ed2bcfb2f7c217d8e6..1f04489477e07f61e8793e08e03e73566366c725 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi-rockchip.c @@ -127,7 +127,7 @@ static int inno_hdmi_rockchip_bind(struct device *dev, struct device *master, vo dev_set_drvdata(dev, hdmi); - hdmi->base = inno_hdmi_bind(dev, encoder, plat_data); + hdmi->base = inno_hdmi_bind(to_platform_device(dev), encoder, plat_data); connector = drm_bridge_connector_init(drm, encoder); if (IS_ERR(connector)) { diff --git a/include/drm/bridge/inno_hdmi.h b/include/drm/bridge/inno_hdmi.h index 5bbcaeea94e2a20fd0dc0ae0c6946eb5604bbaf6..507d5e999183ca02e7dcbe4ce7568acc21426a89 100644 --- a/include/drm/bridge/inno_hdmi.h +++ b/include/drm/bridge/inno_hdmi.h @@ -12,6 +12,7 @@ struct device; struct drm_encoder; struct drm_display_mode; struct inno_hdmi; +struct platform_device; struct inno_hdmi_plat_ops { void (*enable)(struct device *pdev, struct drm_display_mode *mode); @@ -29,7 +30,10 @@ struct inno_hdmi_plat_data { struct inno_hdmi_phy_config *default_phy_config; }; -struct inno_hdmi *inno_hdmi_bind(struct device *pdev, +struct inno_hdmi *inno_hdmi_bind(struct platform_device *pdev, struct drm_encoder *encoder, const struct inno_hdmi_plat_data *plat_data); + +struct inno_hdmi *inno_hdmi_probe(struct platform_device *pdev, + const struct inno_hdmi_plat_data *plat_data); #endif /* __INNO_HDMI__ */ -- 2.34.1
