2 * linux/drivers/video/omap2/dss/core.c
4 * Copyright (C) 2009 Nokia Corporation
7 * Some code and ideas taken from drivers/video/omap/ driver
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.
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
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/>.
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>
33 #include <linux/device.h>
34 #include <linux/regulator/consumer.h>
35 #include <linux/suspend.h>
36 #include <linux/slab.h>
40 #include "dss_features.h"
43 struct platform_device *pdev;
45 const char *default_display_name;
48 static char *def_disp_name;
49 module_param_named(def_disp, def_disp_name, charp, 0);
50 MODULE_PARM_DESC(def_disp, "default display name");
52 const char *omapdss_get_default_display_name(void)
54 return core.default_display_name;
56 EXPORT_SYMBOL(omapdss_get_default_display_name);
58 enum omapdss_version omapdss_get_version(void)
60 struct omap_dss_board_info *pdata = core.pdev->dev.platform_data;
61 return pdata->version;
63 EXPORT_SYMBOL(omapdss_get_version);
65 struct platform_device *dss_get_core_pdev(void)
70 int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask)
72 struct omap_dss_board_info *board_data = core.pdev->dev.platform_data;
74 if (!board_data->dsi_enable_pads)
77 return board_data->dsi_enable_pads(dsi_id, lane_mask);
80 void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask)
82 struct omap_dss_board_info *board_data = core.pdev->dev.platform_data;
84 if (!board_data->dsi_disable_pads)
87 return board_data->dsi_disable_pads(dsi_id, lane_mask);
90 int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
92 struct omap_dss_board_info *pdata = core.pdev->dev.platform_data;
94 if (pdata->set_min_bus_tput)
95 return pdata->set_min_bus_tput(dev, tput);
100 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
101 static int dss_debug_show(struct seq_file *s, void *unused)
103 void (*func)(struct seq_file *) = s->private;
108 static int dss_debug_open(struct inode *inode, struct file *file)
110 return single_open(file, dss_debug_show, inode->i_private);
113 static const struct file_operations dss_debug_fops = {
114 .open = dss_debug_open,
117 .release = single_release,
120 static struct dentry *dss_debugfs_dir;
122 static int dss_initialize_debugfs(void)
124 dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
125 if (IS_ERR(dss_debugfs_dir)) {
126 int err = PTR_ERR(dss_debugfs_dir);
127 dss_debugfs_dir = NULL;
131 debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir,
132 &dss_debug_dump_clocks, &dss_debug_fops);
137 static void dss_uninitialize_debugfs(void)
140 debugfs_remove_recursive(dss_debugfs_dir);
143 int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
147 d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir,
148 write, &dss_debug_fops);
150 return PTR_ERR_OR_ZERO(d);
152 #else /* CONFIG_OMAP2_DSS_DEBUGFS */
153 static inline int dss_initialize_debugfs(void)
157 static inline void dss_uninitialize_debugfs(void)
160 int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
164 #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
166 /* PLATFORM DEVICE */
168 static void dss_disable_all_devices(void)
170 struct omap_dss_device *dssdev = NULL;
172 for_each_dss_dev(dssdev) {
176 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
177 dssdev->driver->disable(dssdev);
181 static int __init omap_dss_probe(struct platform_device *pdev)
183 struct omap_dss_board_info *pdata = pdev->dev.platform_data;
188 dss_features_init(omapdss_get_version());
190 r = dss_initialize_debugfs();
195 core.default_display_name = def_disp_name;
196 else if (pdata->default_display_name)
197 core.default_display_name = pdata->default_display_name;
206 static int omap_dss_remove(struct platform_device *pdev)
208 dss_uninitialize_debugfs();
213 static void omap_dss_shutdown(struct platform_device *pdev)
215 DSSDBG("shutdown\n");
216 dss_disable_all_devices();
219 static struct platform_driver omap_dss_driver = {
220 .remove = omap_dss_remove,
221 .shutdown = omap_dss_shutdown,
228 static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
229 dss_init_platform_driver,
230 dispc_init_platform_driver,
231 #ifdef CONFIG_OMAP2_DSS_DSI
232 dsi_init_platform_driver,
234 #ifdef CONFIG_OMAP2_DSS_DPI
235 dpi_init_platform_driver,
237 #ifdef CONFIG_OMAP2_DSS_SDI
238 sdi_init_platform_driver,
240 #ifdef CONFIG_OMAP2_DSS_RFBI
241 rfbi_init_platform_driver,
243 #ifdef CONFIG_OMAP2_DSS_VENC
244 venc_init_platform_driver,
246 #ifdef CONFIG_OMAP4_DSS_HDMI
247 hdmi4_init_platform_driver,
249 #ifdef CONFIG_OMAP5_DSS_HDMI
250 hdmi5_init_platform_driver,
254 static void (*dss_output_drv_unreg_funcs[])(void) = {
255 #ifdef CONFIG_OMAP5_DSS_HDMI
256 hdmi5_uninit_platform_driver,
258 #ifdef CONFIG_OMAP4_DSS_HDMI
259 hdmi4_uninit_platform_driver,
261 #ifdef CONFIG_OMAP2_DSS_VENC
262 venc_uninit_platform_driver,
264 #ifdef CONFIG_OMAP2_DSS_RFBI
265 rfbi_uninit_platform_driver,
267 #ifdef CONFIG_OMAP2_DSS_SDI
268 sdi_uninit_platform_driver,
270 #ifdef CONFIG_OMAP2_DSS_DPI
271 dpi_uninit_platform_driver,
273 #ifdef CONFIG_OMAP2_DSS_DSI
274 dsi_uninit_platform_driver,
276 dispc_uninit_platform_driver,
277 dss_uninit_platform_driver,
280 static int __init omap_dss_init(void)
285 r = platform_driver_probe(&omap_dss_driver, omap_dss_probe);
289 for (i = 0; i < ARRAY_SIZE(dss_output_drv_reg_funcs); ++i) {
290 r = dss_output_drv_reg_funcs[i]();
298 for (i = ARRAY_SIZE(dss_output_drv_reg_funcs) - i;
299 i < ARRAY_SIZE(dss_output_drv_reg_funcs);
301 dss_output_drv_unreg_funcs[i]();
303 platform_driver_unregister(&omap_dss_driver);
308 static void __exit omap_dss_exit(void)
312 for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i)
313 dss_output_drv_unreg_funcs[i]();
315 platform_driver_unregister(&omap_dss_driver);
318 module_init(omap_dss_init);
319 module_exit(omap_dss_exit);
322 MODULE_DESCRIPTION("OMAP2/3 Display Subsystem");
323 MODULE_LICENSE("GPL v2");