blob: 7c6011df80a85ab66235202949ab0f28a3b66443 [file] [log] [blame]
Sumit Semwalb7ee79a2011-01-24 06:21:54 +00001/*
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
Tomi Valkeinena0b38cc2011-05-11 14:05:07 +030025#include <video/omapdss.h>
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +000026#include <plat/omap_hwmod.h>
27#include <plat/omap_device.h>
Tomi Valkeinen700dee72011-05-23 15:50:47 +030028#include <plat/omap-pm.h>
Sumit Semwalb7ee79a2011-01-24 06:21:54 +000029
30static struct platform_device omap_display_device = {
31 .name = "omapdss",
32 .id = -1,
33 .dev = {
34 .platform_data = NULL,
35 },
36};
37
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +000038static struct omap_device_pm_latency omap_dss_latency[] = {
39 [0] = {
40 .deactivate_func = omap_device_idle_hwmods,
41 .activate_func = omap_device_enable_hwmods,
42 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
43 },
44};
45
Archit Taneja179e0452011-04-18 09:32:13 +053046struct omap_dss_hwmod_data {
47 const char *oh_name;
48 const char *dev_name;
49 const int id;
50};
51
52static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = {
53 { "dss_core", "omapdss_dss", -1 },
54 { "dss_dispc", "omapdss_dispc", -1 },
55 { "dss_rfbi", "omapdss_rfbi", -1 },
56 { "dss_venc", "omapdss_venc", -1 },
57};
58
59static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initdata = {
60 { "dss_core", "omapdss_dss", -1 },
61 { "dss_dispc", "omapdss_dispc", -1 },
62 { "dss_rfbi", "omapdss_rfbi", -1 },
63 { "dss_venc", "omapdss_venc", -1 },
Tomi Valkeinen7c68dd92011-08-03 14:00:57 +030064 { "dss_dsi1", "omapdss_dsi", 0 },
Archit Taneja179e0452011-04-18 09:32:13 +053065};
66
67static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initdata = {
68 { "dss_core", "omapdss_dss", -1 },
69 { "dss_dispc", "omapdss_dispc", -1 },
70 { "dss_rfbi", "omapdss_rfbi", -1 },
71 { "dss_venc", "omapdss_venc", -1 },
Tomi Valkeinen7c68dd92011-08-03 14:00:57 +030072 { "dss_dsi1", "omapdss_dsi", 0 },
73 { "dss_dsi2", "omapdss_dsi", 1 },
Archit Taneja179e0452011-04-18 09:32:13 +053074 { "dss_hdmi", "omapdss_hdmi", -1 },
75};
76
Tomi Valkeinen5bc416c2011-06-15 15:21:12 +030077static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask)
78{
79 return 0;
80}
81
82static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask)
83{
84}
85
Sumit Semwalb7ee79a2011-01-24 06:21:54 +000086int __init omap_display_init(struct omap_dss_board_info *board_data)
87{
88 int r = 0;
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +000089 struct omap_hwmod *oh;
90 struct omap_device *od;
Archit Taneja179e0452011-04-18 09:32:13 +053091 int i, oh_count;
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +000092 struct omap_display_platform_data pdata;
Archit Taneja179e0452011-04-18 09:32:13 +053093 const struct omap_dss_hwmod_data *curr_dss_hwmod;
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +000094
95 memset(&pdata, 0, sizeof(pdata));
96
Archit Taneja179e0452011-04-18 09:32:13 +053097 if (cpu_is_omap24xx()) {
98 curr_dss_hwmod = omap2_dss_hwmod_data;
99 oh_count = ARRAY_SIZE(omap2_dss_hwmod_data);
100 } else if (cpu_is_omap34xx()) {
101 curr_dss_hwmod = omap3_dss_hwmod_data;
102 oh_count = ARRAY_SIZE(omap3_dss_hwmod_data);
103 } else {
104 curr_dss_hwmod = omap4_dss_hwmod_data;
105 oh_count = ARRAY_SIZE(omap4_dss_hwmod_data);
106 }
Mayuresh Janorkar545376e2011-01-27 11:17:04 +0000107
Tomi Valkeinen5bc416c2011-06-15 15:21:12 +0300108 if (board_data->dsi_enable_pads == NULL)
109 board_data->dsi_enable_pads = omap_dsi_enable_pads;
110 if (board_data->dsi_disable_pads == NULL)
111 board_data->dsi_disable_pads = omap_dsi_disable_pads;
112
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +0000113 pdata.board_data = board_data;
Tomi Valkeinen700dee72011-05-23 15:50:47 +0300114 pdata.board_data->get_context_loss_count =
115 omap_pm_get_dev_context_loss_count;
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +0000116
117 for (i = 0; i < oh_count; i++) {
Archit Taneja179e0452011-04-18 09:32:13 +0530118 oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name);
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +0000119 if (!oh) {
Archit Taneja179e0452011-04-18 09:32:13 +0530120 pr_err("Could not look up %s\n",
121 curr_dss_hwmod[i].oh_name);
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +0000122 return -ENODEV;
123 }
Semwal, Sumitfd4b34f2011-03-01 02:42:13 -0600124
Archit Taneja179e0452011-04-18 09:32:13 +0530125 od = omap_device_build(curr_dss_hwmod[i].dev_name,
126 curr_dss_hwmod[i].id, oh, &pdata,
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +0000127 sizeof(struct omap_display_platform_data),
128 omap_dss_latency,
129 ARRAY_SIZE(omap_dss_latency), 0);
130
131 if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n",
Archit Taneja179e0452011-04-18 09:32:13 +0530132 curr_dss_hwmod[i].oh_name))
Senthilvadivu Guruswamycf07f532011-01-24 06:21:56 +0000133 return -ENODEV;
134 }
Sumit Semwalb7ee79a2011-01-24 06:21:54 +0000135 omap_display_device.dev.platform_data = board_data;
136
137 r = platform_device_register(&omap_display_device);
138 if (r < 0)
139 printk(KERN_ERR "Unable to register OMAP-Display device\n");
140
141 return r;
142}