Add linux-next specific files for 20110831
[linux-2.6/next.git] / arch / arm / mach-omap2 / display.c
blob2f122234412f8ec794a810a31548d0675873d59d
1 /*
2 * OMAP2plus display device setup / initialization.
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 * Senthilvadivu Guruswamy
6 * Sumit Semwal
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
13 * kind, whether express or implied; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/string.h>
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/io.h>
23 #include <linux/clk.h>
24 #include <linux/err.h>
26 #include <video/omapdss.h>
27 #include <plat/omap_hwmod.h>
28 #include <plat/omap_device.h>
29 #include <plat/omap-pm.h>
31 static struct platform_device omap_display_device = {
32 .name = "omapdss",
33 .id = -1,
34 .dev = {
35 .platform_data = NULL,
39 static struct omap_device_pm_latency omap_dss_latency[] = {
40 [0] = {
41 .deactivate_func = omap_device_idle_hwmods,
42 .activate_func = omap_device_enable_hwmods,
43 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
47 struct omap_dss_hwmod_data {
48 const char *oh_name;
49 const char *dev_name;
50 const int id;
53 static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = {
54 { "dss_core", "omapdss_dss", -1 },
55 { "dss_dispc", "omapdss_dispc", -1 },
56 { "dss_rfbi", "omapdss_rfbi", -1 },
57 { "dss_venc", "omapdss_venc", -1 },
60 static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initdata = {
61 { "dss_core", "omapdss_dss", -1 },
62 { "dss_dispc", "omapdss_dispc", -1 },
63 { "dss_rfbi", "omapdss_rfbi", -1 },
64 { "dss_venc", "omapdss_venc", -1 },
65 { "dss_dsi1", "omapdss_dsi1", -1 },
68 static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initdata = {
69 { "dss_core", "omapdss_dss", -1 },
70 { "dss_dispc", "omapdss_dispc", -1 },
71 { "dss_rfbi", "omapdss_rfbi", -1 },
72 { "dss_venc", "omapdss_venc", -1 },
73 { "dss_dsi1", "omapdss_dsi1", -1 },
74 { "dss_dsi2", "omapdss_dsi2", -1 },
75 { "dss_hdmi", "omapdss_hdmi", -1 },
78 int __init omap_display_init(struct omap_dss_board_info *board_data)
80 int r = 0;
81 struct omap_hwmod *oh;
82 struct omap_device *od;
83 int i, oh_count;
84 struct omap_display_platform_data pdata;
85 const struct omap_dss_hwmod_data *curr_dss_hwmod;
87 memset(&pdata, 0, sizeof(pdata));
89 if (cpu_is_omap24xx()) {
90 curr_dss_hwmod = omap2_dss_hwmod_data;
91 oh_count = ARRAY_SIZE(omap2_dss_hwmod_data);
92 } else if (cpu_is_omap34xx()) {
93 curr_dss_hwmod = omap3_dss_hwmod_data;
94 oh_count = ARRAY_SIZE(omap3_dss_hwmod_data);
95 } else {
96 curr_dss_hwmod = omap4_dss_hwmod_data;
97 oh_count = ARRAY_SIZE(omap4_dss_hwmod_data);
100 pdata.board_data = board_data;
101 pdata.board_data->get_context_loss_count =
102 omap_pm_get_dev_context_loss_count;
104 for (i = 0; i < oh_count; i++) {
105 oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name);
106 if (!oh) {
107 pr_err("Could not look up %s\n",
108 curr_dss_hwmod[i].oh_name);
109 return -ENODEV;
112 od = omap_device_build(curr_dss_hwmod[i].dev_name,
113 curr_dss_hwmod[i].id, oh, &pdata,
114 sizeof(struct omap_display_platform_data),
115 omap_dss_latency,
116 ARRAY_SIZE(omap_dss_latency), 0);
118 if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n",
119 curr_dss_hwmod[i].oh_name))
120 return -ENODEV;
122 omap_display_device.dev.platform_data = board_data;
124 r = platform_device_register(&omap_display_device);
125 if (r < 0)
126 printk(KERN_ERR "Unable to register OMAP-Display device\n");
128 return r;