]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/blob - drivers/video/fbdev/omap2/dss/core.c
OMAPDSS: Add methods for skipping display initialization
[android-sdk/kernel-video.git] / drivers / video / fbdev / omap2 / dss / core.c
1 /*
2  * linux/drivers/video/omap2/dss/core.c
3  *
4  * Copyright (C) 2009 Nokia Corporation
5  * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6  *
7  * Some code and ideas taken from drivers/video/omap/ driver
8  * by Imre Deak.
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License version 2 as published by
12  * the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17  * more details.
18  *
19  * You should have received a copy of the GNU General Public License along with
20  * this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
23 #define DSS_SUBSYS_NAME "CORE"
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/clk.h>
28 #include <linux/err.h>
29 #include <linux/platform_device.h>
30 #include <linux/seq_file.h>
31 #include <linux/debugfs.h>
32 #include <linux/io.h>
33 #include <linux/device.h>
34 #include <linux/regulator/consumer.h>
35 #include <linux/suspend.h>
36 #include <linux/slab.h>
37 #include <linux/of.h>
39 #include <video/omapdss.h>
41 #include "dss.h"
42 #include "dss_features.h"
44 static struct {
45         struct platform_device *pdev;
47         const char *default_display_name;
48 } core;
50 static uint g_display_skip_init;
51 static uint g_display_share;
53 static char *def_disp_name;
54 module_param_named(def_disp, def_disp_name, charp, 0);
55 MODULE_PARM_DESC(def_disp, "default display name");
57 static bool dss_initialized;
59 const char *omapdss_get_default_display_name(void)
60 {
61         return core.default_display_name;
62 }
63 EXPORT_SYMBOL(omapdss_get_default_display_name);
65 enum omapdss_version omapdss_get_version(void)
66 {
67         struct omap_dss_board_info *pdata = core.pdev->dev.platform_data;
68         return pdata->version;
69 }
70 EXPORT_SYMBOL(omapdss_get_version);
72 int omapdss_skipinit(void)
73 {
74         return g_display_skip_init;
75 }
76 EXPORT_SYMBOL(omapdss_skipinit);
78 int omapdss_display_share(void)
79 {
80         return g_display_share;
81 }
82 EXPORT_SYMBOL(omapdss_display_share);
84 bool omapdss_is_initialized(void)
85 {
86         return dss_initialized;
87 }
88 EXPORT_SYMBOL(omapdss_is_initialized);
90 struct platform_device *dss_get_core_pdev(void)
91 {
92         return core.pdev;
93 }
95 int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask)
96 {
97         struct omap_dss_board_info *board_data = core.pdev->dev.platform_data;
99         if (!board_data->dsi_enable_pads)
100                 return -ENOENT;
102         return board_data->dsi_enable_pads(dsi_id, lane_mask);
105 void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask)
107         struct omap_dss_board_info *board_data = core.pdev->dev.platform_data;
109         if (!board_data->dsi_disable_pads)
110                 return;
112         return board_data->dsi_disable_pads(dsi_id, lane_mask);
115 int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
117         struct omap_dss_board_info *pdata = core.pdev->dev.platform_data;
119         if (pdata->set_min_bus_tput)
120                 return pdata->set_min_bus_tput(dev, tput);
121         else
122                 return 0;
125 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
126 static int dss_debug_show(struct seq_file *s, void *unused)
128         void (*func)(struct seq_file *) = s->private;
129         func(s);
130         return 0;
133 static int dss_debug_open(struct inode *inode, struct file *file)
135         return single_open(file, dss_debug_show, inode->i_private);
138 static const struct file_operations dss_debug_fops = {
139         .open           = dss_debug_open,
140         .read           = seq_read,
141         .llseek         = seq_lseek,
142         .release        = single_release,
143 };
145 static struct dentry *dss_debugfs_dir;
147 static int dss_initialize_debugfs(void)
149         dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
150         if (IS_ERR(dss_debugfs_dir)) {
151                 int err = PTR_ERR(dss_debugfs_dir);
152                 dss_debugfs_dir = NULL;
153                 return err;
154         }
156         debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir,
157                         &dss_debug_dump_clocks, &dss_debug_fops);
159         return 0;
162 static void dss_uninitialize_debugfs(void)
164         if (dss_debugfs_dir)
165                 debugfs_remove_recursive(dss_debugfs_dir);
168 int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
170         struct dentry *d;
172         d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir,
173                         write, &dss_debug_fops);
175         return PTR_ERR_OR_ZERO(d);
177 #else /* CONFIG_OMAP2_DSS_DEBUGFS */
178 static inline int dss_initialize_debugfs(void)
180         return 0;
182 static inline void dss_uninitialize_debugfs(void)
185 int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
187         return 0;
189 #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
191 /* PLATFORM DEVICE */
192 static int omap_dss_pm_notif(struct notifier_block *b, unsigned long v, void *d)
194         DSSDBG("pm notif %lu\n", v);
196         switch (v) {
197         case PM_SUSPEND_PREPARE:
198                 DSSDBG("suspending displays\n");
199                 return dss_suspend_all_devices();
201         case PM_POST_SUSPEND:
202                 DSSDBG("resuming displays\n");
203                 return dss_resume_all_devices();
205         default:
206                 return 0;
207         }
210 static struct notifier_block omap_dss_pm_notif_block = {
211         .notifier_call = omap_dss_pm_notif,
212 };
214 static int __init omap_dss_probe(struct platform_device *pdev)
216         struct omap_dss_board_info *pdata = pdev->dev.platform_data;
217         struct device_node *node = pdev->dev.of_node;
218         int r;
220         core.pdev = pdev;
222         of_property_read_u32(node, "skip_init",
223                                          &g_display_skip_init);
224         if (g_display_skip_init)
225                 g_display_share = 1;
227         dss_features_init(omapdss_get_version());
229         r = dss_initialize_debugfs();
230         if (r)
231                 goto err_debugfs;
233         if (def_disp_name)
234                 core.default_display_name = def_disp_name;
235         else if (pdata->default_display_name)
236                 core.default_display_name = pdata->default_display_name;
237         else if (pdata->default_device)
238                 core.default_display_name = pdata->default_device->name;
240         register_pm_notifier(&omap_dss_pm_notif_block);
242         return 0;
244 err_debugfs:
246         return r;
249 static int omap_dss_remove(struct platform_device *pdev)
251         unregister_pm_notifier(&omap_dss_pm_notif_block);
253         dss_uninitialize_debugfs();
255         return 0;
258 static void omap_dss_shutdown(struct platform_device *pdev)
260         DSSDBG("shutdown\n");
261         dss_disable_all_devices();
264 static struct platform_driver omap_dss_driver = {
265         .remove         = omap_dss_remove,
266         .shutdown       = omap_dss_shutdown,
267         .driver         = {
268                 .name   = "omapdss",
269                 .owner  = THIS_MODULE,
270         },
271 };
273 /* INIT */
274 static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
275 #ifdef CONFIG_OMAP2_DSS_DSI
276         dsi_init_platform_driver,
277 #endif
278 #ifdef CONFIG_OMAP2_DSS_DPI
279         dpi_init_platform_driver,
280 #endif
281 #ifdef CONFIG_OMAP2_DSS_SDI
282         sdi_init_platform_driver,
283 #endif
284 #ifdef CONFIG_OMAP2_DSS_RFBI
285         rfbi_init_platform_driver,
286 #endif
287 #ifdef CONFIG_OMAP2_DSS_VENC
288         venc_init_platform_driver,
289 #endif
290 #ifdef CONFIG_OMAP4_DSS_HDMI
291         hdmi4_init_platform_driver,
292 #endif
293 #ifdef CONFIG_OMAP5_DSS_HDMI
294         hdmi5_init_platform_driver,
295 #endif
296 };
298 static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = {
299 #ifdef CONFIG_OMAP2_DSS_DSI
300         dsi_uninit_platform_driver,
301 #endif
302 #ifdef CONFIG_OMAP2_DSS_DPI
303         dpi_uninit_platform_driver,
304 #endif
305 #ifdef CONFIG_OMAP2_DSS_SDI
306         sdi_uninit_platform_driver,
307 #endif
308 #ifdef CONFIG_OMAP2_DSS_RFBI
309         rfbi_uninit_platform_driver,
310 #endif
311 #ifdef CONFIG_OMAP2_DSS_VENC
312         venc_uninit_platform_driver,
313 #endif
314 #ifdef CONFIG_OMAP4_DSS_HDMI
315         hdmi4_uninit_platform_driver,
316 #endif
317 #ifdef CONFIG_OMAP5_DSS_HDMI
318         hdmi5_uninit_platform_driver,
319 #endif
320 };
322 static bool dss_output_drv_loaded[ARRAY_SIZE(dss_output_drv_reg_funcs)];
324 static int __init omap_dss_init(void)
326         int r;
327         int i;
329         r = platform_driver_probe(&omap_dss_driver, omap_dss_probe);
330         if (r)
331                 return r;
333         r = dss_init_platform_driver();
334         if (r) {
335                 DSSERR("Failed to initialize DSS platform driver\n");
336                 goto err_dss;
337         }
339         r = dispc_init_platform_driver();
340         if (r) {
341                 DSSERR("Failed to initialize dispc platform driver\n");
342                 goto err_dispc;
343         }
345         /*
346          * It's ok if the output-driver register fails. It happens, for example,
347          * when there is no output-device (e.g. SDI for OMAP4).
348          */
349         for (i = 0; i < ARRAY_SIZE(dss_output_drv_reg_funcs); ++i) {
350                 r = dss_output_drv_reg_funcs[i]();
351                 if (r == 0)
352                         dss_output_drv_loaded[i] = true;
353         }
355         dss_initialized = true;
357         return 0;
359 err_dispc:
360         dss_uninit_platform_driver();
361 err_dss:
362         platform_driver_unregister(&omap_dss_driver);
364         return r;
367 static void __exit omap_dss_exit(void)
369         int i;
371         for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i) {
372                 if (dss_output_drv_loaded[i])
373                         dss_output_drv_unreg_funcs[i]();
374         }
376         dispc_uninit_platform_driver();
377         dss_uninit_platform_driver();
379         platform_driver_unregister(&omap_dss_driver);
382 module_init(omap_dss_init);
383 module_exit(omap_dss_exit);
385 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>");
386 MODULE_DESCRIPTION("OMAP2/3 Display Subsystem");
387 MODULE_LICENSE("GPL v2");