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 struct omap_dss_hwmod_data {
46 static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = {
47 { "dss_core", "omapdss_dss", -1 },
48 { "dss_dispc", "omapdss_dispc", -1 },
49 { "dss_rfbi", "omapdss_rfbi", -1 },
50 { "dss_venc", "omapdss_venc", -1 },
53 static const struct omap_dss_hwmod_data omap3_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 },
58 { "dss_dsi1", "omapdss_dsi", 0 },
61 static const struct omap_dss_hwmod_data omap4_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 { "dss_dsi2", "omapdss_dsi", 1 },
68 { "dss_hdmi", "omapdss_hdmi", -1 },
71 static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)
73 u32 enable_mask, enable_shift;
74 u32 pipd_mask, pipd_shift;
78 enable_mask = OMAP4_DSI1_LANEENABLE_MASK;
79 enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT;
80 pipd_mask = OMAP4_DSI1_PIPD_MASK;
81 pipd_shift = OMAP4_DSI1_PIPD_SHIFT;
82 } else if (dsi_id == 1) {
83 enable_mask = OMAP4_DSI2_LANEENABLE_MASK;
84 enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT;
85 pipd_mask = OMAP4_DSI2_PIPD_MASK;
86 pipd_shift = OMAP4_DSI2_PIPD_SHIFT;
91 reg = omap4_ctrl_pad_readl(OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);
96 reg |= (lanes << enable_shift) & enable_mask;
97 reg |= (lanes << pipd_shift) & pipd_mask;
99 omap4_ctrl_pad_writel(reg, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);
104 static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask)
106 if (cpu_is_omap44xx())
107 return omap4_dsi_mux_pads(dsi_id, lane_mask);
112 static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask)
114 if (cpu_is_omap44xx())
115 omap4_dsi_mux_pads(dsi_id, 0);
118 int __init omap_display_init(struct omap_dss_board_info *board_data)
121 struct omap_hwmod *oh;
122 struct platform_device *pdev;
124 struct omap_display_platform_data pdata;
125 const struct omap_dss_hwmod_data *curr_dss_hwmod;
127 memset(&pdata, 0, sizeof(pdata));
129 if (cpu_is_omap24xx()) {
130 curr_dss_hwmod = omap2_dss_hwmod_data;
131 oh_count = ARRAY_SIZE(omap2_dss_hwmod_data);
132 } else if (cpu_is_omap34xx()) {
133 curr_dss_hwmod = omap3_dss_hwmod_data;
134 oh_count = ARRAY_SIZE(omap3_dss_hwmod_data);
136 curr_dss_hwmod = omap4_dss_hwmod_data;
137 oh_count = ARRAY_SIZE(omap4_dss_hwmod_data);
140 if (board_data->dsi_enable_pads == NULL)
141 board_data->dsi_enable_pads = omap_dsi_enable_pads;
142 if (board_data->dsi_disable_pads == NULL)
143 board_data->dsi_disable_pads = omap_dsi_disable_pads;
145 pdata.board_data = board_data;
146 pdata.board_data->get_context_loss_count =
147 omap_pm_get_dev_context_loss_count;
149 for (i = 0; i < oh_count; i++) {
150 oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name);
152 pr_err("Could not look up %s\n",
153 curr_dss_hwmod[i].oh_name);
157 pdev = omap_device_build(curr_dss_hwmod[i].dev_name,
158 curr_dss_hwmod[i].id, oh, &pdata,
159 sizeof(struct omap_display_platform_data),
162 if (WARN((IS_ERR(pdev)), "Could not build omap_device for %s\n",
163 curr_dss_hwmod[i].oh_name))
166 omap_display_device.dev.platform_data = board_data;
168 r = platform_device_register(&omap_display_device);
170 printk(KERN_ERR "Unable to register OMAP-Display device\n");