2 * OMAP2plus display device setup / initialization.
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 * Senthilvadivu Guruswamy
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/kernel.h>
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
22 #include <linux/clk.h>
23 #include <linux/err.h>
25 #include <video/omapdss.h>
26 #include <plat/omap_hwmod.h>
27 #include <plat/omap_device.h>
28 #include <plat/omap-pm.h>
32 static struct platform_device omap_display_device = {
36 .platform_data = NULL,
40 static struct omap_device_pm_latency omap_dss_latency[] = {
42 .deactivate_func = omap_device_idle_hwmods,
43 .activate_func = omap_device_enable_hwmods,
44 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
48 struct omap_dss_hwmod_data {
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 },
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 },
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 },
79 static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)
81 u32 enable_mask, enable_shift;
82 u32 pipd_mask, pipd_shift;
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;
99 reg = omap4_ctrl_pad_readl(OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);
104 reg |= (lanes << enable_shift) & enable_mask;
105 reg |= (lanes << pipd_shift) & pipd_mask;
107 omap4_ctrl_pad_writel(reg, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);
112 static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask)
114 if (cpu_is_omap44xx())
115 return omap4_dsi_mux_pads(dsi_id, lane_mask);
120 static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask)
122 if (cpu_is_omap44xx())
123 omap4_dsi_mux_pads(dsi_id, 0);
126 int __init omap_display_init(struct omap_dss_board_info *board_data)
129 struct omap_hwmod *oh;
130 struct platform_device *pdev;
132 struct omap_display_platform_data pdata;
133 const struct omap_dss_hwmod_data *curr_dss_hwmod;
135 memset(&pdata, 0, sizeof(pdata));
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);
144 curr_dss_hwmod = omap4_dss_hwmod_data;
145 oh_count = ARRAY_SIZE(omap4_dss_hwmod_data);
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;
153 pdata.board_data = board_data;
154 pdata.board_data->get_context_loss_count =
155 omap_pm_get_dev_context_loss_count;
157 for (i = 0; i < oh_count; i++) {
158 oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name);
160 pr_err("Could not look up %s\n",
161 curr_dss_hwmod[i].oh_name);
165 pdev = omap_device_build(curr_dss_hwmod[i].dev_name,
166 curr_dss_hwmod[i].id, oh, &pdata,
167 sizeof(struct omap_display_platform_data),
169 ARRAY_SIZE(omap_dss_latency), 0);
171 if (WARN((IS_ERR(pdev)), "Could not build omap_device for %s\n",
172 curr_dss_hwmod[i].oh_name))
175 omap_display_device.dev.platform_data = board_data;
177 r = platform_device_register(&omap_display_device);
179 printk(KERN_ERR "Unable to register OMAP-Display device\n");