arm: add elf.h to arch/arm/kernel/ptrace.c
[deliverable/linux.git] / arch / arm / mach-omap2 / display.c
1 /*
2 * OMAP2plus display device setup / initialization.
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 * Senthilvadivu Guruswamy
6 * Sumit Semwal
7 *
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.
11 *
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.
16 */
17
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
21 #include <linux/io.h>
22 #include <linux/clk.h>
23 #include <linux/err.h>
24
25 #include <video/omapdss.h>
26 #include <plat/omap_hwmod.h>
27 #include <plat/omap_device.h>
28 #include <plat/omap-pm.h>
29
30 #include "control.h"
31
32 static struct platform_device omap_display_device = {
33 .name = "omapdss",
34 .id = -1,
35 .dev = {
36 .platform_data = NULL,
37 },
38 };
39
40 static struct omap_device_pm_latency omap_dss_latency[] = {
41 [0] = {
42 .deactivate_func = omap_device_idle_hwmods,
43 .activate_func = omap_device_enable_hwmods,
44 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
45 },
46 };
47
48 struct omap_dss_hwmod_data {
49 const char *oh_name;
50 const char *dev_name;
51 const int id;
52 };
53
54 static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = {
55 { "dss_core", "omapdss_dss", -1 },
56 { "dss_dispc", "omapdss_dispc", -1 },
57 { "dss_rfbi", "omapdss_rfbi", -1 },
58 { "dss_venc", "omapdss_venc", -1 },
59 };
60
61 static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initdata = {
62 { "dss_core", "omapdss_dss", -1 },
63 { "dss_dispc", "omapdss_dispc", -1 },
64 { "dss_rfbi", "omapdss_rfbi", -1 },
65 { "dss_venc", "omapdss_venc", -1 },
66 { "dss_dsi1", "omapdss_dsi", 0 },
67 };
68
69 static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initdata = {
70 { "dss_core", "omapdss_dss", -1 },
71 { "dss_dispc", "omapdss_dispc", -1 },
72 { "dss_rfbi", "omapdss_rfbi", -1 },
73 { "dss_venc", "omapdss_venc", -1 },
74 { "dss_dsi1", "omapdss_dsi", 0 },
75 { "dss_dsi2", "omapdss_dsi", 1 },
76 { "dss_hdmi", "omapdss_hdmi", -1 },
77 };
78
79 static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)
80 {
81 u32 enable_mask, enable_shift;
82 u32 pipd_mask, pipd_shift;
83 u32 reg;
84
85 if (dsi_id == 0) {
86 enable_mask = OMAP4_DSI1_LANEENABLE_MASK;
87 enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT;
88 pipd_mask = OMAP4_DSI1_PIPD_MASK;
89 pipd_shift = OMAP4_DSI1_PIPD_SHIFT;
90 } else if (dsi_id == 1) {
91 enable_mask = OMAP4_DSI2_LANEENABLE_MASK;
92 enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT;
93 pipd_mask = OMAP4_DSI2_PIPD_MASK;
94 pipd_shift = OMAP4_DSI2_PIPD_SHIFT;
95 } else {
96 return -ENODEV;
97 }
98
99 reg = omap4_ctrl_pad_readl(OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);
100
101 reg &= ~enable_mask;
102 reg &= ~pipd_mask;
103
104 reg |= (lanes << enable_shift) & enable_mask;
105 reg |= (lanes << pipd_shift) & pipd_mask;
106
107 omap4_ctrl_pad_writel(reg, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);
108
109 return 0;
110 }
111
112 static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask)
113 {
114 if (cpu_is_omap44xx())
115 return omap4_dsi_mux_pads(dsi_id, lane_mask);
116
117 return 0;
118 }
119
120 static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask)
121 {
122 if (cpu_is_omap44xx())
123 omap4_dsi_mux_pads(dsi_id, 0);
124 }
125
126 int __init omap_display_init(struct omap_dss_board_info *board_data)
127 {
128 int r = 0;
129 struct omap_hwmod *oh;
130 struct omap_device *od;
131 int i, oh_count;
132 struct omap_display_platform_data pdata;
133 const struct omap_dss_hwmod_data *curr_dss_hwmod;
134
135 memset(&pdata, 0, sizeof(pdata));
136
137 if (cpu_is_omap24xx()) {
138 curr_dss_hwmod = omap2_dss_hwmod_data;
139 oh_count = ARRAY_SIZE(omap2_dss_hwmod_data);
140 } else if (cpu_is_omap34xx()) {
141 curr_dss_hwmod = omap3_dss_hwmod_data;
142 oh_count = ARRAY_SIZE(omap3_dss_hwmod_data);
143 } else {
144 curr_dss_hwmod = omap4_dss_hwmod_data;
145 oh_count = ARRAY_SIZE(omap4_dss_hwmod_data);
146 }
147
148 if (board_data->dsi_enable_pads == NULL)
149 board_data->dsi_enable_pads = omap_dsi_enable_pads;
150 if (board_data->dsi_disable_pads == NULL)
151 board_data->dsi_disable_pads = omap_dsi_disable_pads;
152
153 pdata.board_data = board_data;
154 pdata.board_data->get_context_loss_count =
155 omap_pm_get_dev_context_loss_count;
156
157 for (i = 0; i < oh_count; i++) {
158 oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name);
159 if (!oh) {
160 pr_err("Could not look up %s\n",
161 curr_dss_hwmod[i].oh_name);
162 return -ENODEV;
163 }
164
165 od = omap_device_build(curr_dss_hwmod[i].dev_name,
166 curr_dss_hwmod[i].id, oh, &pdata,
167 sizeof(struct omap_display_platform_data),
168 omap_dss_latency,
169 ARRAY_SIZE(omap_dss_latency), 0);
170
171 if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n",
172 curr_dss_hwmod[i].oh_name))
173 return -ENODEV;
174 }
175 omap_display_device.dev.platform_data = board_data;
176
177 r = platform_device_register(&omap_display_device);
178 if (r < 0)
179 printk(KERN_ERR "Unable to register OMAP-Display device\n");
180
181 return r;
182 }
This page took 0.044442 seconds and 5 git commands to generate.