Commit | Line | Data |
---|---|---|
b7ee79ab SS |
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 <plat/display.h> | |
cf07f531 SG |
26 | #include <plat/omap_hwmod.h> |
27 | #include <plat/omap_device.h> | |
b7ee79ab SS |
28 | |
29 | static struct platform_device omap_display_device = { | |
30 | .name = "omapdss", | |
31 | .id = -1, | |
32 | .dev = { | |
33 | .platform_data = NULL, | |
34 | }, | |
35 | }; | |
36 | ||
cf07f531 SG |
37 | static struct omap_device_pm_latency omap_dss_latency[] = { |
38 | [0] = { | |
39 | .deactivate_func = omap_device_idle_hwmods, | |
40 | .activate_func = omap_device_enable_hwmods, | |
41 | .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST, | |
42 | }, | |
43 | }; | |
44 | ||
b7ee79ab SS |
45 | int __init omap_display_init(struct omap_dss_board_info *board_data) |
46 | { | |
47 | int r = 0; | |
cf07f531 SG |
48 | struct omap_hwmod *oh; |
49 | struct omap_device *od; | |
50 | int i; | |
51 | struct omap_display_platform_data pdata; | |
52 | ||
53 | /* | |
54 | * omap: valid DSS hwmod names | |
545376e7 MJ |
55 | * omap2,3,4: dss_core, dss_dispc, dss_rfbi, dss_venc |
56 | * omap3,4: dss_dsi1 | |
57 | * omap4: dss_dsi2, dss_hdmi | |
cf07f531 SG |
58 | */ |
59 | char *oh_name[] = { "dss_core", "dss_dispc", "dss_rfbi", "dss_venc", | |
545376e7 | 60 | "dss_dsi1", "dss_dsi2", "dss_hdmi" }; |
cf07f531 | 61 | char *dev_name[] = { "omapdss_dss", "omapdss_dispc", "omapdss_rfbi", |
545376e7 MJ |
62 | "omapdss_venc", "omapdss_dsi1", "omapdss_dsi2", |
63 | "omapdss_hdmi" }; | |
cf07f531 SG |
64 | int oh_count; |
65 | ||
66 | memset(&pdata, 0, sizeof(pdata)); | |
67 | ||
68 | if (cpu_is_omap24xx()) | |
545376e7 MJ |
69 | oh_count = ARRAY_SIZE(oh_name) - 3; |
70 | /* last 3 hwmod dev in oh_name are not available for omap2 */ | |
71 | else if (cpu_is_omap44xx()) | |
cf07f531 | 72 | oh_count = ARRAY_SIZE(oh_name); |
545376e7 MJ |
73 | else |
74 | oh_count = ARRAY_SIZE(oh_name) - 2; | |
75 | /* last 2 hwmod dev in oh_name are not available for omap3 */ | |
76 | ||
cf07f531 SG |
77 | |
78 | pdata.board_data = board_data; | |
79 | pdata.board_data->get_last_off_on_transaction_id = NULL; | |
80 | ||
81 | for (i = 0; i < oh_count; i++) { | |
82 | oh = omap_hwmod_lookup(oh_name[i]); | |
83 | if (!oh) { | |
84 | pr_err("Could not look up %s\n", oh_name[i]); | |
85 | return -ENODEV; | |
86 | } | |
87 | od = omap_device_build(dev_name[i], -1, oh, &pdata, | |
88 | sizeof(struct omap_display_platform_data), | |
89 | omap_dss_latency, | |
90 | ARRAY_SIZE(omap_dss_latency), 0); | |
91 | ||
92 | if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n", | |
93 | oh_name[i])) | |
94 | return -ENODEV; | |
95 | } | |
b7ee79ab SS |
96 | omap_display_device.dev.platform_data = board_data; |
97 | ||
98 | r = platform_device_register(&omap_display_device); | |
99 | if (r < 0) | |
100 | printk(KERN_ERR "Unable to register OMAP-Display device\n"); | |
101 | ||
102 | return r; | |
103 | } |