]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
OMAPDSS: componentize omapdss
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 4 Jun 2015 12:22:23 +0000 (15:22 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 17 Jun 2015 10:44:53 +0000 (13:44 +0300)
omapdss kernel module contains drivers for multiple devices, one for
each DSS submodule. The probing we have at the moment is a mess, and
doesn't give us proper deferred probing nor ensure that all the devices
are probed before omapfb/omapdrm start using omapdss.

This patch solves the mess by using the component system for DSS
submodules.

The changes to all DSS submodules (dispc, dpi, dsi, hdmi4/5, rfbi, sdi,
venc) are the same: probe & remove functions are changed to bind &
unbind, and new probe & remove functions are added which call
component_add/del.

The dss_core driver (dss.c) acts as a component master. Adding and
matching the components is simple: all dss device's child devices are
added as components.

However, we do have some dependencies between the drivers. The order in
which they should be probed is reflected by the list in core.c
(dss_output_drv_reg_funcs). The drivers are registered in that order,
which causes the components to be added in that order, which makes the
components to be bound in that order. This feels a bit fragile, and we
probably should improve the code to manage binds in random order.
However, for now, this works fine.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drivers/video/fbdev/omap2/dss/dispc.c
drivers/video/fbdev/omap2/dss/dpi.c
drivers/video/fbdev/omap2/dss/dsi.c
drivers/video/fbdev/omap2/dss/dss.c
drivers/video/fbdev/omap2/dss/hdmi4.c
drivers/video/fbdev/omap2/dss/hdmi5.c
drivers/video/fbdev/omap2/dss/rfbi.c
drivers/video/fbdev/omap2/dss/sdi.c
drivers/video/fbdev/omap2/dss/venc.c

index e3417af63451a434a918d05da9674ca2c8256451..c8e34163211ae3b81af11dfdf19c58e3e324da0c 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 #include <linux/of.h>
+#include <linux/component.h>
 
 #include <video/omapdss.h>
 
@@ -3882,8 +3883,9 @@ void dispc_free_irq(void *dev_id)
 EXPORT_SYMBOL(dispc_free_irq);
 
 /* DISPC HW IP initialisation */
-static int omap_dispchw_probe(struct platform_device *pdev)
+static int dispc_bind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
        u32 rev;
        int r = 0;
        struct resource *dispc_mem;
@@ -3955,12 +3957,27 @@ static int omap_dispchw_probe(struct platform_device *pdev)
        return r;
 }
 
-static int omap_dispchw_remove(struct platform_device *pdev)
+static void dispc_unbind(struct device *dev, struct device *master,
+                              void *data)
 {
-       pm_runtime_disable(&pdev->dev);
+       pm_runtime_disable(dev);
 
        dss_uninit_overlay_managers();
+}
+
+static const struct component_ops dispc_component_ops = {
+       .bind   = dispc_bind,
+       .unbind = dispc_unbind,
+};
 
+static int dispc_probe(struct platform_device *pdev)
+{
+       return component_add(&pdev->dev, &dispc_component_ops);
+}
+
+static int dispc_remove(struct platform_device *pdev)
+{
+       component_del(&pdev->dev, &dispc_component_ops);
        return 0;
 }
 
@@ -4013,7 +4030,8 @@ static const struct of_device_id dispc_of_match[] = {
 };
 
 static struct platform_driver omap_dispchw_driver = {
-       .remove         = omap_dispchw_remove,
+       .probe          = dispc_probe,
+       .remove         = dispc_remove,
        .driver         = {
                .name   = "omapdss_dispc",
                .pm     = &dispc_pm_ops,
@@ -4024,7 +4042,7 @@ static struct platform_driver omap_dispchw_driver = {
 
 int __init dispc_init_platform_driver(void)
 {
-       return platform_driver_probe(&omap_dispchw_driver, omap_dispchw_probe);
+       return platform_driver_register(&omap_dispchw_driver);
 }
 
 void dispc_uninit_platform_driver(void)
index a06e7558280fe757dac874488916a3405bfe97f1..fb45b6432968e0ab73277497392729f5b5c3cdad 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/string.h>
 #include <linux/of.h>
 #include <linux/clk.h>
+#include <linux/component.h>
 
 #include <video/omapdss.h>
 
@@ -783,8 +784,9 @@ static void dpi_uninit_output_port(struct device_node *port)
        omapdss_unregister_output(out);
 }
 
-static int omap_dpi_probe(struct platform_device *pdev)
+static int dpi_bind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
        struct dpi_data *dpi;
 
        dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL);
@@ -802,16 +804,32 @@ static int omap_dpi_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int omap_dpi_remove(struct platform_device *pdev)
+static void dpi_unbind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
+
        dpi_uninit_output(pdev);
+}
+
+static const struct component_ops dpi_component_ops = {
+       .bind   = dpi_bind,
+       .unbind = dpi_unbind,
+};
 
+static int dpi_probe(struct platform_device *pdev)
+{
+       return component_add(&pdev->dev, &dpi_component_ops);
+}
+
+static int dpi_remove(struct platform_device *pdev)
+{
+       component_del(&pdev->dev, &dpi_component_ops);
        return 0;
 }
 
 static struct platform_driver omap_dpi_driver = {
-       .probe          = omap_dpi_probe,
-       .remove         = omap_dpi_remove,
+       .probe          = dpi_probe,
+       .remove         = dpi_remove,
        .driver         = {
                .name   = "omapdss_dpi",
                .suppress_bind_attrs = true,
index c4c27c09c62f8e2eaed2d95bc100116c25f70272..b3606def5b7ba7e853397ce223cedfb5d481027a 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/component.h>
 
 #include <video/omapdss.h>
 #include <video/mipi_display.h>
@@ -5274,8 +5275,9 @@ static int dsi_init_pll_data(struct platform_device *dsidev)
 }
 
 /* DSI1 HW IP initialisation */
-static int omap_dsihw_probe(struct platform_device *dsidev)
+static int dsi_bind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *dsidev = to_platform_device(dev);
        u32 rev;
        int r, i;
        struct dsi_data *dsi;
@@ -5484,8 +5486,9 @@ static int omap_dsihw_probe(struct platform_device *dsidev)
        return r;
 }
 
-static int omap_dsihw_remove(struct platform_device *dsidev)
+static void dsi_unbind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *dsidev = to_platform_device(dev);
        struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
        of_platform_depopulate(&dsidev->dev);
@@ -5502,7 +5505,21 @@ static int omap_dsihw_remove(struct platform_device *dsidev)
                regulator_disable(dsi->vdds_dsi_reg);
                dsi->vdds_dsi_enabled = false;
        }
+}
+
+static const struct component_ops dsi_component_ops = {
+       .bind   = dsi_bind,
+       .unbind = dsi_unbind,
+};
 
+static int dsi_probe(struct platform_device *pdev)
+{
+       return component_add(&pdev->dev, &dsi_component_ops);
+}
+
+static int dsi_remove(struct platform_device *pdev)
+{
+       component_del(&pdev->dev, &dsi_component_ops);
        return 0;
 }
 
@@ -5569,8 +5586,8 @@ static const struct of_device_id dsi_of_match[] = {
 };
 
 static struct platform_driver omap_dsihw_driver = {
-       .probe          = omap_dsihw_probe,
-       .remove         = omap_dsihw_remove,
+       .probe          = dsi_probe,
+       .remove         = dsi_remove,
        .driver         = {
                .name   = "omapdss_dsi",
                .pm     = &dsi_pm_ops,
index 3397cbf484b0c175d10b347b2c682b7cefb10f92..612b093831d52be7040bcefeb279eaf9f4dd9700 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/of.h>
 #include <linux/regulator/consumer.h>
 #include <linux/suspend.h>
+#include <linux/component.h>
 
 #include <video/omapdss.h>
 
@@ -1088,8 +1089,9 @@ static int dss_video_pll_probe(struct platform_device *pdev)
 }
 
 /* DSS HW IP initialisation */
-static int omap_dsshw_probe(struct platform_device *pdev)
+static int dss_bind(struct device *dev)
 {
+       struct platform_device *pdev = to_platform_device(dev);
        struct resource *dss_mem;
        u32 rev;
        int r;
@@ -1159,6 +1161,10 @@ static int omap_dsshw_probe(struct platform_device *pdev)
 
        dss_runtime_put();
 
+       r = component_bind_all(&pdev->dev, NULL);
+       if (r)
+               goto err_component;
+
        dss_debugfs_create_file("dss", dss_dump_regs);
 
        pm_set_vt_switch(0);
@@ -1167,6 +1173,7 @@ static int omap_dsshw_probe(struct platform_device *pdev)
 
        return 0;
 
+err_component:
 err_runtime_get:
        pm_runtime_disable(&pdev->dev);
        dss_uninit_ports(pdev);
@@ -1182,10 +1189,14 @@ static int omap_dsshw_probe(struct platform_device *pdev)
        return r;
 }
 
-static int omap_dsshw_remove(struct platform_device *pdev)
+static void dss_unbind(struct device *dev)
 {
+       struct platform_device *pdev = to_platform_device(dev);
+
        dss_initialized = false;
 
+       component_unbind_all(&pdev->dev, NULL);
+
        if (dss.video1_pll)
                dss_video_pll_uninit(dss.video1_pll);
 
@@ -1197,7 +1208,46 @@ static int omap_dsshw_remove(struct platform_device *pdev)
        pm_runtime_disable(&pdev->dev);
 
        dss_put_clocks();
+}
+
+static const struct component_master_ops dss_component_ops = {
+       .bind = dss_bind,
+       .unbind = dss_unbind,
+};
 
+static int dss_component_compare(struct device *dev, void *data)
+{
+       struct device *child = data;
+       return dev == child;
+}
+
+static int dss_add_child_component(struct device *dev, void *data)
+{
+       struct component_match **match = data;
+
+       component_match_add(dev->parent, match, dss_component_compare, dev);
+
+       return 0;
+}
+
+static int dss_probe(struct platform_device *pdev)
+{
+       struct component_match *match = NULL;
+       int r;
+
+       /* add all the child devices as components */
+       device_for_each_child(&pdev->dev, &match, dss_add_child_component);
+
+       r = component_master_add_with_match(&pdev->dev, &dss_component_ops, match);
+       if (r)
+               return r;
+
+       return 0;
+}
+
+static int dss_remove(struct platform_device *pdev)
+{
+       component_master_del(&pdev->dev, &dss_component_ops);
        return 0;
 }
 
@@ -1243,7 +1293,8 @@ static const struct of_device_id dss_of_match[] = {
 MODULE_DEVICE_TABLE(of, dss_of_match);
 
 static struct platform_driver omap_dsshw_driver = {
-       .remove         = omap_dsshw_remove,
+       .probe          = dss_probe,
+       .remove         = dss_remove,
        .driver         = {
                .name   = "omapdss_dss",
                .pm     = &dss_pm_ops,
@@ -1254,7 +1305,7 @@ static struct platform_driver omap_dsshw_driver = {
 
 int __init dss_init_platform_driver(void)
 {
-       return platform_driver_probe(&omap_dsshw_driver, omap_dsshw_probe);
+       return platform_driver_register(&omap_dsshw_driver);
 }
 
 void dss_uninit_platform_driver(void)
index 31deebbc32dc50d6da637b09dec91ba3e986e826..d35312d6902534eb9caee2e8f111f54367fb853e 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/clk.h>
 #include <linux/gpio.h>
 #include <linux/regulator/consumer.h>
+#include <linux/component.h>
 #include <video/omapdss.h>
 #include <sound/omap-hdmi-audio.h>
 
@@ -646,8 +647,9 @@ static int hdmi_audio_register(struct device *dev)
 }
 
 /* HDMI HW IP initialisation */
-static int omapdss_hdmihw_probe(struct platform_device *pdev)
+static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
        int r;
        int irq;
 
@@ -713,8 +715,10 @@ static int omapdss_hdmihw_probe(struct platform_device *pdev)
        return r;
 }
 
-static int omapdss_hdmihw_remove(struct platform_device *pdev)
+static void hdmi4_unbind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
+
        if (hdmi.audio_pdev)
                platform_device_unregister(hdmi.audio_pdev);
 
@@ -723,7 +727,21 @@ static int omapdss_hdmihw_remove(struct platform_device *pdev)
        hdmi_pll_uninit(&hdmi.pll);
 
        pm_runtime_disable(&pdev->dev);
+}
+
+static const struct component_ops hdmi4_component_ops = {
+       .bind   = hdmi4_bind,
+       .unbind = hdmi4_unbind,
+};
 
+static int hdmi4_probe(struct platform_device *pdev)
+{
+       return component_add(&pdev->dev, &hdmi4_component_ops);
+}
+
+static int hdmi4_remove(struct platform_device *pdev)
+{
+       component_del(&pdev->dev, &hdmi4_component_ops);
        return 0;
 }
 
@@ -756,8 +774,8 @@ static const struct of_device_id hdmi_of_match[] = {
 };
 
 static struct platform_driver omapdss_hdmihw_driver = {
-       .probe          = omapdss_hdmihw_probe,
-       .remove         = omapdss_hdmihw_remove,
+       .probe          = hdmi4_probe,
+       .remove         = hdmi4_remove,
        .driver         = {
                .name   = "omapdss_hdmi",
                .pm     = &hdmi_pm_ops,
index a57f5e8f9aea43be29220a437ca463e9737fb10d..7f875788edbc9f97e0fec729fb7122e2164dcfa3 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/clk.h>
 #include <linux/gpio.h>
 #include <linux/regulator/consumer.h>
+#include <linux/component.h>
 #include <video/omapdss.h>
 #include <sound/omap-hdmi-audio.h>
 
@@ -681,8 +682,9 @@ static int hdmi_audio_register(struct device *dev)
 }
 
 /* HDMI HW IP initialisation */
-static int omapdss_hdmihw_probe(struct platform_device *pdev)
+static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
        int r;
        int irq;
 
@@ -748,8 +750,10 @@ static int omapdss_hdmihw_probe(struct platform_device *pdev)
        return r;
 }
 
-static int omapdss_hdmihw_remove(struct platform_device *pdev)
+static void hdmi5_unbind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
+
        if (hdmi.audio_pdev)
                platform_device_unregister(hdmi.audio_pdev);
 
@@ -758,7 +762,21 @@ static int omapdss_hdmihw_remove(struct platform_device *pdev)
        hdmi_pll_uninit(&hdmi.pll);
 
        pm_runtime_disable(&pdev->dev);
+}
+
+static const struct component_ops hdmi5_component_ops = {
+       .bind   = hdmi5_bind,
+       .unbind = hdmi5_unbind,
+};
 
+static int hdmi5_probe(struct platform_device *pdev)
+{
+       return component_add(&pdev->dev, &hdmi5_component_ops);
+}
+
+static int hdmi5_remove(struct platform_device *pdev)
+{
+       component_del(&pdev->dev, &hdmi5_component_ops);
        return 0;
 }
 
@@ -792,8 +810,8 @@ static const struct of_device_id hdmi_of_match[] = {
 };
 
 static struct platform_driver omapdss_hdmihw_driver = {
-       .probe          = omapdss_hdmihw_probe,
-       .remove         = omapdss_hdmihw_remove,
+       .probe          = hdmi5_probe,
+       .remove         = hdmi5_remove,
        .driver         = {
                .name   = "omapdss_hdmi5",
                .pm     = &hdmi_pm_ops,
index 8ec810bce0b66f539a6f2af26f55f366b06340b4..1525a494d057a552ba86b900c43afbd253c0f883 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/semaphore.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/component.h>
 
 #include <video/omapdss.h>
 #include "dss.h"
@@ -946,8 +947,9 @@ static void rfbi_uninit_output(struct platform_device *pdev)
 }
 
 /* RFBI HW IP initialisation */
-static int omap_rfbihw_probe(struct platform_device *pdev)
+static int rfbi_bind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
        u32 rev;
        struct resource *rfbi_mem;
        struct clk *clk;
@@ -1005,8 +1007,10 @@ static int omap_rfbihw_probe(struct platform_device *pdev)
        return r;
 }
 
-static int omap_rfbihw_remove(struct platform_device *pdev)
+static void rfbi_unbind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
+
        rfbi_uninit_output(pdev);
 
        pm_runtime_disable(&pdev->dev);
@@ -1014,6 +1018,22 @@ static int omap_rfbihw_remove(struct platform_device *pdev)
        return 0;
 }
 
+static const struct component_ops rfbi_component_ops = {
+       .bind   = rfbi_bind,
+       .unbind = rfbi_unbind,
+};
+
+static int rfbi_probe(struct platform_device *pdev)
+{
+       return component_add(&pdev->dev, &rfbi_component_ops);
+}
+
+static int rfbi_remove(struct platform_device *pdev)
+{
+       component_del(&pdev->dev, &rfbi_component_ops);
+       return 0;
+}
+
 static int rfbi_runtime_suspend(struct device *dev)
 {
        dispc_runtime_put();
@@ -1038,8 +1058,8 @@ static const struct dev_pm_ops rfbi_pm_ops = {
 };
 
 static struct platform_driver omap_rfbihw_driver = {
-       .probe          = omap_rfbihw_probe,
-       .remove         = omap_rfbihw_remove,
+       .probe          = rfbi_probe,
+       .remove         = rfbi_remove,
        .driver         = {
                .name   = "omapdss_rfbi",
                .pm     = &rfbi_pm_ops,
index a873118f1e0ec7929f986ae59372c0591aaaec2e..5843580a1deb89c115c4a44939069776e8349f2f 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/platform_device.h>
 #include <linux/string.h>
 #include <linux/of.h>
+#include <linux/component.h>
 
 #include <video/omapdss.h>
 #include "dss.h"
@@ -357,8 +358,10 @@ static void sdi_uninit_output(struct platform_device *pdev)
        omapdss_unregister_output(out);
 }
 
-static int omap_sdi_probe(struct platform_device *pdev)
+static int sdi_bind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
+
        sdi.pdev = pdev;
 
        sdi_init_output(pdev);
@@ -366,16 +369,32 @@ static int omap_sdi_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int omap_sdi_remove(struct platform_device *pdev)
+static void sdi_unbind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
+
        sdi_uninit_output(pdev);
+}
+
+static const struct component_ops sdi_component_ops = {
+       .bind   = sdi_bind,
+       .unbind = sdi_unbind,
+};
 
+static int sdi_probe(struct platform_device *pdev)
+{
+       return component_add(&pdev->dev, &sdi_component_ops);
+}
+
+static int sdi_remove(struct platform_device *pdev)
+{
+       component_del(&pdev->dev, &sdi_component_ops);
        return 0;
 }
 
 static struct platform_driver omap_sdi_driver = {
-       .probe          = omap_sdi_probe,
-       .remove         = omap_sdi_remove,
+       .probe          = sdi_probe,
+       .remove         = sdi_remove,
        .driver         = {
                .name   = "omapdss_sdi",
                .suppress_bind_attrs = true,
index e7fad0e19d4315a7f4aec8f6a1ae8421ceba3e1e..99ca268c1cddf24332308b58fbeb051d565b8dca 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
+#include <linux/component.h>
 
 #include <video/omapdss.h>
 
@@ -852,8 +853,9 @@ static int venc_probe_of(struct platform_device *pdev)
 }
 
 /* VENC HW IP initialisation */
-static int omap_venchw_probe(struct platform_device *pdev)
+static int venc_bind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
        u8 rev_id;
        struct resource *venc_mem;
        int r;
@@ -912,12 +914,28 @@ static int omap_venchw_probe(struct platform_device *pdev)
        return r;
 }
 
-static int omap_venchw_remove(struct platform_device *pdev)
+static void venc_unbind(struct device *dev, struct device *master, void *data)
 {
+       struct platform_device *pdev = to_platform_device(dev);
+
        venc_uninit_output(pdev);
 
        pm_runtime_disable(&pdev->dev);
+}
 
+static const struct component_ops venc_component_ops = {
+       .bind   = venc_bind,
+       .unbind = venc_unbind,
+};
+
+static int venc_probe(struct platform_device *pdev)
+{
+       return component_add(&pdev->dev, &venc_component_ops);
+}
+
+static int venc_remove(struct platform_device *pdev)
+{
+       component_del(&pdev->dev, &venc_component_ops);
        return 0;
 }
 
@@ -950,7 +968,6 @@ static const struct dev_pm_ops venc_pm_ops = {
        .runtime_resume = venc_runtime_resume,
 };
 
-
 static const struct of_device_id venc_of_match[] = {
        { .compatible = "ti,omap2-venc", },
        { .compatible = "ti,omap3-venc", },
@@ -959,8 +976,8 @@ static const struct of_device_id venc_of_match[] = {
 };
 
 static struct platform_driver omap_venchw_driver = {
-       .probe          = omap_venchw_probe,
-       .remove         = omap_venchw_remove,
+       .probe          = venc_probe,
+       .remove         = venc_remove,
        .driver         = {
                .name   = "omapdss_venc",
                .pm     = &venc_pm_ops,