OMAP2, 3: DSS2: DISPC: create platform_driver, move init, exit to driver
authorSenthilvadivu Guruswamy <svadivu@ti.com>
Mon, 24 Jan 2011 06:22:00 +0000 (06:22 +0000)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 11 Mar 2011 13:46:20 +0000 (15:46 +0200)
Hwmod adaptation design requires each of the DSS HW IP to be a platform driver.
So a platform_driver for DISPC is created and init exit methods are moved from core.c
to its driver probe,remove. pdev member has to be maintained by its own drivers.

DISPC platform driver is registered from inside omap_dss_probe, in the order desired.

Signed-off-by: Senthilvadivu Guruswamy <svadivu@ti.com>
Signed-off-by: Sumit Semwal <sumit.semwal@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/video/omap2/dss/core.c
drivers/video/omap2/dss/dispc.c
drivers/video/omap2/dss/dss.h

index 8eef616fee037c0f3eb7bfaf9519341a4e11cc4e..8b7eab83e41245c4c3ce541d5a6f90b2a5469e8e 100644 (file)
@@ -213,9 +213,9 @@ static int omap_dss_probe(struct platform_device *pdev)
                goto err_dpi;
        }
 
-       r = dispc_init();
+       r = dispc_init_platform_driver();
        if (r) {
-               DSSERR("Failed to initialize dispc\n");
+               DSSERR("Failed to initialize dispc platform driver\n");
                goto err_dispc;
        }
 
@@ -281,7 +281,7 @@ err_dsi:
 err_sdi:
        venc_exit();
 err_venc:
-       dispc_exit();
+       dispc_uninit_platform_driver();
 err_dispc:
        dpi_exit();
 err_dpi:
@@ -301,7 +301,7 @@ static int omap_dss_remove(struct platform_device *pdev)
        dss_uninitialize_debugfs();
 
        venc_exit();
-       dispc_exit();
+       dispc_uninit_platform_driver();
        dpi_exit();
        rfbi_uninit_platform_driver();
        if (cpu_is_omap34xx()) {
index 9f8c69f16e619dd1eec954f5ae5eba13c659ec06..28ad68b6be481cfd4fab30890d308fdbe3bfa375 100644 (file)
@@ -178,6 +178,7 @@ struct dispc_irq_stats {
 };
 
 static struct {
+       struct platform_device *pdev;
        void __iomem    *base;
 
        u32     fifo_size[3];
@@ -3269,47 +3270,6 @@ static void _omap_dispc_initial_config(void)
        dispc_read_plane_fifo_sizes();
 }
 
-int dispc_init(void)
-{
-       u32 rev;
-
-       spin_lock_init(&dispc.irq_lock);
-
-#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-       spin_lock_init(&dispc.irq_stats_lock);
-       dispc.irq_stats.last_reset = jiffies;
-#endif
-
-       INIT_WORK(&dispc.error_work, dispc_error_worker);
-
-       dispc.base = ioremap(DISPC_BASE, DISPC_SZ_REGS);
-       if (!dispc.base) {
-               DSSERR("can't ioremap DISPC\n");
-               return -ENOMEM;
-       }
-
-       enable_clocks(1);
-
-       _omap_dispc_initial_config();
-
-       _omap_dispc_initialize_irq();
-
-       dispc_save_context();
-
-       rev = dispc_read_reg(DISPC_REVISION);
-       printk(KERN_INFO "OMAP DISPC rev %d.%d\n",
-              FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
-
-       enable_clocks(0);
-
-       return 0;
-}
-
-void dispc_exit(void)
-{
-       iounmap(dispc.base);
-}
-
 int dispc_enable_plane(enum omap_plane plane, bool enable)
 {
        DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
@@ -3359,3 +3319,66 @@ int dispc_setup_plane(enum omap_plane plane,
 
        return r;
 }
+
+/* DISPC HW IP initialisation */
+static int omap_dispchw_probe(struct platform_device *pdev)
+{
+       u32 rev;
+       dispc.pdev = pdev;
+
+       spin_lock_init(&dispc.irq_lock);
+
+#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
+       spin_lock_init(&dispc.irq_stats_lock);
+       dispc.irq_stats.last_reset = jiffies;
+#endif
+
+       INIT_WORK(&dispc.error_work, dispc_error_worker);
+
+       dispc.base = ioremap(DISPC_BASE, DISPC_SZ_REGS);
+       if (!dispc.base) {
+               DSSERR("can't ioremap DISPC\n");
+               return -ENOMEM;
+       }
+
+       enable_clocks(1);
+
+       _omap_dispc_initial_config();
+
+       _omap_dispc_initialize_irq();
+
+       dispc_save_context();
+
+       rev = dispc_read_reg(DISPC_REVISION);
+       printk(KERN_INFO "OMAP DISPC rev %d.%d\n",
+              FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
+
+       enable_clocks(0);
+
+       return 0;
+}
+
+static int omap_dispchw_remove(struct platform_device *pdev)
+{
+       iounmap(dispc.base);
+       return 0;
+}
+
+static struct platform_driver omap_dispchw_driver = {
+       .probe          = omap_dispchw_probe,
+       .remove         = omap_dispchw_remove,
+       .driver         = {
+               .name   = "omapdss_dispc",
+               .owner  = THIS_MODULE,
+       },
+};
+
+int dispc_init_platform_driver(void)
+{
+       return platform_driver_register(&omap_dispchw_driver);
+}
+
+void dispc_uninit_platform_driver(void)
+{
+       return platform_driver_unregister(&omap_dispchw_driver);
+}
index 0ba4bdbd6b01a5dd481a0378b856db560c788980..f4835c85db90e077cda59085689d3c3d121451e5 100644 (file)
@@ -319,8 +319,8 @@ static inline void dpi_exit(void)
 #endif
 
 /* DISPC */
-int dispc_init(void);
-void dispc_exit(void);
+int dispc_init_platform_driver(void);
+void dispc_uninit_platform_driver(void);
 void dispc_dump_clocks(struct seq_file *s);
 void dispc_dump_irqs(struct seq_file *s);
 void dispc_dump_regs(struct seq_file *s);