Commit 8820b68b authored by Jeffy Chen's avatar Jeffy Chen Committed by Sean Paul

drm/rockchip: Refactor the component match logic.

Currently we are adding all components from the dts, if one of their
drivers been disabled, we would not be able to bring up others.

Refactor component match logic, follow exynos drm.
Signed-off-by: default avatarJeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Acked-by: default avatarMark Yao <mark.yao@rock-chips.com>
Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1490152880-21855-1-git-send-email-jeffy.chen@rock-chips.com
parent 0cad7f71
...@@ -13,7 +13,7 @@ config DRM_ROCKCHIP ...@@ -13,7 +13,7 @@ config DRM_ROCKCHIP
IP found on the SoC. IP found on the SoC.
config ROCKCHIP_ANALOGIX_DP config ROCKCHIP_ANALOGIX_DP
tristate "Rockchip specific extensions for Analogix DP driver" bool "Rockchip specific extensions for Analogix DP driver"
depends on DRM_ROCKCHIP depends on DRM_ROCKCHIP
select DRM_ANALOGIX_DP select DRM_ANALOGIX_DP
help help
...@@ -22,7 +22,7 @@ config ROCKCHIP_ANALOGIX_DP ...@@ -22,7 +22,7 @@ config ROCKCHIP_ANALOGIX_DP
on RK3288 based SoC, you should selet this option. on RK3288 based SoC, you should selet this option.
config ROCKCHIP_CDN_DP config ROCKCHIP_CDN_DP
tristate "Rockchip cdn DP" bool "Rockchip cdn DP"
depends on DRM_ROCKCHIP depends on DRM_ROCKCHIP
depends on EXTCON depends on EXTCON
select SND_SOC_HDMI_CODEC if SND_SOC select SND_SOC_HDMI_CODEC if SND_SOC
...@@ -33,7 +33,7 @@ config ROCKCHIP_CDN_DP ...@@ -33,7 +33,7 @@ config ROCKCHIP_CDN_DP
option. option.
config ROCKCHIP_DW_HDMI config ROCKCHIP_DW_HDMI
tristate "Rockchip specific extensions for Synopsys DW HDMI" bool "Rockchip specific extensions for Synopsys DW HDMI"
depends on DRM_ROCKCHIP depends on DRM_ROCKCHIP
select DRM_DW_HDMI select DRM_DW_HDMI
help help
...@@ -43,7 +43,7 @@ config ROCKCHIP_DW_HDMI ...@@ -43,7 +43,7 @@ config ROCKCHIP_DW_HDMI
option. option.
config ROCKCHIP_DW_MIPI_DSI config ROCKCHIP_DW_MIPI_DSI
tristate "Rockchip specific extensions for Synopsys DW MIPI DSI" bool "Rockchip specific extensions for Synopsys DW MIPI DSI"
depends on DRM_ROCKCHIP depends on DRM_ROCKCHIP
select DRM_MIPI_DSI select DRM_MIPI_DSI
help help
...@@ -53,7 +53,7 @@ config ROCKCHIP_DW_MIPI_DSI ...@@ -53,7 +53,7 @@ config ROCKCHIP_DW_MIPI_DSI
option. option.
config ROCKCHIP_INNO_HDMI config ROCKCHIP_INNO_HDMI
tristate "Rockchip specific extensions for Innosilicon HDMI" bool "Rockchip specific extensions for Innosilicon HDMI"
depends on DRM_ROCKCHIP depends on DRM_ROCKCHIP
help help
This selects support for Rockchip SoC specific extensions This selects support for Rockchip SoC specific extensions
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \ rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \
rockchip_drm_gem.o rockchip_drm_psr.o rockchip_drm_vop.o rockchip_drm_gem.o rockchip_drm_psr.o \
rockchip_drm_vop.o rockchip_vop_reg.o
rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o
obj-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
obj-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp.o rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
cdn-dp-objs := cdn-dp-core.o cdn-dp-reg.o rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
obj-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
obj-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
obj-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o
obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_vop_reg.o obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o
...@@ -507,7 +507,7 @@ static const struct of_device_id rockchip_dp_dt_ids[] = { ...@@ -507,7 +507,7 @@ static const struct of_device_id rockchip_dp_dt_ids[] = {
}; };
MODULE_DEVICE_TABLE(of, rockchip_dp_dt_ids); MODULE_DEVICE_TABLE(of, rockchip_dp_dt_ids);
static struct platform_driver rockchip_dp_driver = { struct platform_driver rockchip_dp_driver = {
.probe = rockchip_dp_probe, .probe = rockchip_dp_probe,
.remove = rockchip_dp_remove, .remove = rockchip_dp_remove,
.driver = { .driver = {
...@@ -516,10 +516,3 @@ static struct platform_driver rockchip_dp_driver = { ...@@ -516,10 +516,3 @@ static struct platform_driver rockchip_dp_driver = {
.of_match_table = of_match_ptr(rockchip_dp_dt_ids), .of_match_table = of_match_ptr(rockchip_dp_dt_ids),
}, },
}; };
module_platform_driver(rockchip_dp_driver);
MODULE_AUTHOR("Yakir Yang <ykk@rock-chips.com>");
MODULE_AUTHOR("Jeff chen <jeff.chen@rock-chips.com>");
MODULE_DESCRIPTION("Rockchip Specific Analogix-DP Driver Extension");
MODULE_LICENSE("GPL v2");
...@@ -1244,7 +1244,7 @@ static const struct dev_pm_ops cdn_dp_pm_ops = { ...@@ -1244,7 +1244,7 @@ static const struct dev_pm_ops cdn_dp_pm_ops = {
cdn_dp_resume) cdn_dp_resume)
}; };
static struct platform_driver cdn_dp_driver = { struct platform_driver cdn_dp_driver = {
.probe = cdn_dp_probe, .probe = cdn_dp_probe,
.remove = cdn_dp_remove, .remove = cdn_dp_remove,
.shutdown = cdn_dp_shutdown, .shutdown = cdn_dp_shutdown,
...@@ -1255,9 +1255,3 @@ static struct platform_driver cdn_dp_driver = { ...@@ -1255,9 +1255,3 @@ static struct platform_driver cdn_dp_driver = {
.pm = &cdn_dp_pm_ops, .pm = &cdn_dp_pm_ops,
}, },
}; };
module_platform_driver(cdn_dp_driver);
MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
MODULE_DESCRIPTION("cdn DP Driver");
MODULE_LICENSE("GPL v2");
...@@ -1304,7 +1304,7 @@ static int dw_mipi_dsi_remove(struct platform_device *pdev) ...@@ -1304,7 +1304,7 @@ static int dw_mipi_dsi_remove(struct platform_device *pdev)
return 0; return 0;
} }
static struct platform_driver dw_mipi_dsi_driver = { struct platform_driver dw_mipi_dsi_driver = {
.probe = dw_mipi_dsi_probe, .probe = dw_mipi_dsi_probe,
.remove = dw_mipi_dsi_remove, .remove = dw_mipi_dsi_remove,
.driver = { .driver = {
...@@ -1312,9 +1312,3 @@ static struct platform_driver dw_mipi_dsi_driver = { ...@@ -1312,9 +1312,3 @@ static struct platform_driver dw_mipi_dsi_driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
}, },
}; };
module_platform_driver(dw_mipi_dsi_driver);
MODULE_DESCRIPTION("ROCKCHIP MIPI DSI host controller driver");
MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:" DRIVER_NAME);
...@@ -325,7 +325,7 @@ static int dw_hdmi_rockchip_remove(struct platform_device *pdev) ...@@ -325,7 +325,7 @@ static int dw_hdmi_rockchip_remove(struct platform_device *pdev)
return 0; return 0;
} }
static struct platform_driver dw_hdmi_rockchip_pltfm_driver = { struct platform_driver dw_hdmi_rockchip_pltfm_driver = {
.probe = dw_hdmi_rockchip_probe, .probe = dw_hdmi_rockchip_probe,
.remove = dw_hdmi_rockchip_remove, .remove = dw_hdmi_rockchip_remove,
.driver = { .driver = {
...@@ -333,11 +333,3 @@ static struct platform_driver dw_hdmi_rockchip_pltfm_driver = { ...@@ -333,11 +333,3 @@ static struct platform_driver dw_hdmi_rockchip_pltfm_driver = {
.of_match_table = dw_hdmi_rockchip_dt_ids, .of_match_table = dw_hdmi_rockchip_dt_ids,
}, },
}; };
module_platform_driver(dw_hdmi_rockchip_pltfm_driver);
MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com>");
MODULE_AUTHOR("Yakir Yang <ykk@rock-chips.com>");
MODULE_DESCRIPTION("Rockchip Specific DW-HDMI Driver Extension");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:dwhdmi-rockchip");
...@@ -923,7 +923,7 @@ static const struct of_device_id inno_hdmi_dt_ids[] = { ...@@ -923,7 +923,7 @@ static const struct of_device_id inno_hdmi_dt_ids[] = {
}; };
MODULE_DEVICE_TABLE(of, inno_hdmi_dt_ids); MODULE_DEVICE_TABLE(of, inno_hdmi_dt_ids);
static struct platform_driver inno_hdmi_driver = { struct platform_driver inno_hdmi_driver = {
.probe = inno_hdmi_probe, .probe = inno_hdmi_probe,
.remove = inno_hdmi_remove, .remove = inno_hdmi_remove,
.driver = { .driver = {
...@@ -931,11 +931,3 @@ static struct platform_driver inno_hdmi_driver = { ...@@ -931,11 +931,3 @@ static struct platform_driver inno_hdmi_driver = {
.of_match_table = inno_hdmi_dt_ids, .of_match_table = inno_hdmi_dt_ids,
}, },
}; };
module_platform_driver(inno_hdmi_driver);
MODULE_AUTHOR("Zheng Yang <zhengyang@rock-chips.com>");
MODULE_AUTHOR("Yakir Yang <ykk@rock-chips.com>");
MODULE_DESCRIPTION("Rockchip Specific INNO-HDMI Driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:innohdmi-rockchip");
...@@ -304,34 +304,37 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = { ...@@ -304,34 +304,37 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
rockchip_drm_sys_resume) rockchip_drm_sys_resume)
}; };
static int compare_of(struct device *dev, void *data) #define MAX_ROCKCHIP_SUB_DRIVERS 16
{ static struct platform_driver *rockchip_sub_drivers[MAX_ROCKCHIP_SUB_DRIVERS];
struct device_node *np = data; static int num_rockchip_sub_drivers;
return dev->of_node == np; static int compare_dev(struct device *dev, void *data)
{
return dev == (struct device *)data;
} }
static void rockchip_add_endpoints(struct device *dev, static struct component_match *rockchip_drm_match_add(struct device *dev)
struct component_match **match,
struct device_node *port)
{ {
struct device_node *ep, *remote; struct component_match *match = NULL;
int i;
for_each_child_of_node(port, ep) { for (i = 0; i < num_rockchip_sub_drivers; i++) {
remote = of_graph_get_remote_port_parent(ep); struct platform_driver *drv = rockchip_sub_drivers[i];
if (!remote || !of_device_is_available(remote)) { struct device *p = NULL, *d;
of_node_put(remote);
continue; do {
} else if (!of_device_is_available(remote->parent)) { d = bus_find_device(&platform_bus_type, p, &drv->driver,
dev_warn(dev, "parent device of %s is not available\n", (void *)platform_bus_type.match);
remote->full_name); put_device(p);
of_node_put(remote); p = d;
continue;
}
drm_of_component_match_add(dev, match, compare_of, remote); if (!d)
of_node_put(remote); break;
component_match_add(dev, &match, compare_dev, d);
} while (true);
} }
return match ?: ERR_PTR(-ENODEV);
} }
static const struct component_master_ops rockchip_drm_ops = { static const struct component_master_ops rockchip_drm_ops = {
...@@ -339,21 +342,16 @@ static const struct component_master_ops rockchip_drm_ops = { ...@@ -339,21 +342,16 @@ static const struct component_master_ops rockchip_drm_ops = {
.unbind = rockchip_drm_unbind, .unbind = rockchip_drm_unbind,
}; };
static int rockchip_drm_platform_probe(struct platform_device *pdev) static int rockchip_drm_platform_of_probe(struct device *dev)
{ {
struct device *dev = &pdev->dev;
struct component_match *match = NULL;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct device_node *port; struct device_node *port;
bool found = false;
int i; int i;
if (!np) if (!np)
return -ENODEV; return -ENODEV;
/*
* Bind the crtc ports first, so that
* drm_of_find_possible_crtcs called from encoder .bind callbacks
* works as expected.
*/
for (i = 0;; i++) { for (i = 0;; i++) {
struct device_node *iommu; struct device_node *iommu;
...@@ -377,9 +375,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev) ...@@ -377,9 +375,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
is_support_iommu = false; is_support_iommu = false;
} }
found = true;
of_node_put(iommu); of_node_put(iommu);
drm_of_component_match_add(dev, &match, compare_of,
port->parent);
of_node_put(port); of_node_put(port);
} }
...@@ -388,27 +386,27 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev) ...@@ -388,27 +386,27 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
if (!match) { if (!found) {
dev_err(dev, "No available vop found for display-subsystem.\n"); dev_err(dev, "No available vop found for display-subsystem.\n");
return -ENODEV; return -ENODEV;
} }
/*
* For each bound crtc, bind the encoders attached to its
* remote endpoint.
*/
for (i = 0;; i++) {
port = of_parse_phandle(np, "ports", i);
if (!port)
break;
if (!of_device_is_available(port->parent)) { return 0;
of_node_put(port); }
continue;
}
rockchip_add_endpoints(dev, &match, port); static int rockchip_drm_platform_probe(struct platform_device *pdev)
of_node_put(port); {
} struct device *dev = &pdev->dev;
struct component_match *match = NULL;
int ret;
ret = rockchip_drm_platform_of_probe(dev);
if (ret)
return ret;
match = rockchip_drm_match_add(dev);
if (IS_ERR(match))
return PTR_ERR(match);
return component_master_add_with_match(dev, &rockchip_drm_ops, match); return component_master_add_with_match(dev, &rockchip_drm_ops, match);
} }
...@@ -436,7 +434,54 @@ static struct platform_driver rockchip_drm_platform_driver = { ...@@ -436,7 +434,54 @@ static struct platform_driver rockchip_drm_platform_driver = {
}, },
}; };
module_platform_driver(rockchip_drm_platform_driver); #define ADD_ROCKCHIP_SUB_DRIVER(drv, cond) { \
if (IS_ENABLED(cond) && \
!WARN_ON(num_rockchip_sub_drivers >= MAX_ROCKCHIP_SUB_DRIVERS)) \
rockchip_sub_drivers[num_rockchip_sub_drivers++] = &drv; \
}
static int __init rockchip_drm_init(void)
{
int ret;
num_rockchip_sub_drivers = 0;
ADD_ROCKCHIP_SUB_DRIVER(vop_platform_driver, CONFIG_DRM_ROCKCHIP);
ADD_ROCKCHIP_SUB_DRIVER(rockchip_dp_driver,
CONFIG_ROCKCHIP_ANALOGIX_DP);
ADD_ROCKCHIP_SUB_DRIVER(cdn_dp_driver, CONFIG_ROCKCHIP_CDN_DP);
ADD_ROCKCHIP_SUB_DRIVER(dw_hdmi_rockchip_pltfm_driver,
CONFIG_ROCKCHIP_DW_HDMI);
ADD_ROCKCHIP_SUB_DRIVER(dw_mipi_dsi_driver,
CONFIG_ROCKCHIP_DW_MIPI_DSI);
ADD_ROCKCHIP_SUB_DRIVER(inno_hdmi_driver, CONFIG_ROCKCHIP_INNO_HDMI);
ret = platform_register_drivers(rockchip_sub_drivers,
num_rockchip_sub_drivers);
if (ret)
return ret;
ret = platform_driver_register(&rockchip_drm_platform_driver);
if (ret)
goto err_unreg_drivers;
return 0;
err_unreg_drivers:
platform_unregister_drivers(rockchip_sub_drivers,
num_rockchip_sub_drivers);
return ret;
}
static void __exit rockchip_drm_fini(void)
{
platform_driver_unregister(&rockchip_drm_platform_driver);
platform_unregister_drivers(rockchip_sub_drivers,
num_rockchip_sub_drivers);
}
module_init(rockchip_drm_init);
module_exit(rockchip_drm_fini);
MODULE_AUTHOR("Mark Yao <mark.yao@rock-chips.com>"); MODULE_AUTHOR("Mark Yao <mark.yao@rock-chips.com>");
MODULE_DESCRIPTION("ROCKCHIP DRM Driver"); MODULE_DESCRIPTION("ROCKCHIP DRM Driver");
......
...@@ -65,4 +65,10 @@ void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, ...@@ -65,4 +65,10 @@ void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
int rockchip_drm_wait_line_flag(struct drm_crtc *crtc, unsigned int line_num, int rockchip_drm_wait_line_flag(struct drm_crtc *crtc, unsigned int line_num,
unsigned int mstimeout); unsigned int mstimeout);
extern struct platform_driver cdn_dp_driver;
extern struct platform_driver dw_hdmi_rockchip_pltfm_driver;
extern struct platform_driver dw_mipi_dsi_driver;
extern struct platform_driver inno_hdmi_driver;
extern struct platform_driver rockchip_dp_driver;
extern struct platform_driver vop_platform_driver;
#endif /* _ROCKCHIP_DRM_DRV_H_ */ #endif /* _ROCKCHIP_DRM_DRV_H_ */
...@@ -404,7 +404,7 @@ static int vop_remove(struct platform_device *pdev) ...@@ -404,7 +404,7 @@ static int vop_remove(struct platform_device *pdev)
return 0; return 0;
} }
static struct platform_driver vop_platform_driver = { struct platform_driver vop_platform_driver = {
.probe = vop_probe, .probe = vop_probe,
.remove = vop_remove, .remove = vop_remove,
.driver = { .driver = {
...@@ -412,9 +412,3 @@ static struct platform_driver vop_platform_driver = { ...@@ -412,9 +412,3 @@ static struct platform_driver vop_platform_driver = {
.of_match_table = of_match_ptr(vop_driver_dt_match), .of_match_table = of_match_ptr(vop_driver_dt_match),
}, },
}; };
module_platform_driver(vop_platform_driver);
MODULE_AUTHOR("Mark Yao <mark.yao@rock-chips.com>");
MODULE_DESCRIPTION("ROCKCHIP VOP Driver");
MODULE_LICENSE("GPL v2");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment