Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 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> |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 26 | #include <plat/omap_hwmod.h> |
| 27 | #include <plat/omap_device.h> |
Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 28 | |
| 29 | static struct platform_device omap_display_device = { |
| 30 | .name = "omapdss", |
| 31 | .id = -1, |
| 32 | .dev = { |
| 33 | .platform_data = NULL, |
| 34 | }, |
| 35 | }; |
| 36 | |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 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 | |
Semwal, Sumit | fd4b34f | 2011-03-01 02:42:13 -0600 | [diff] [blame] | 45 | /* oh_core is used for getting opt-clocks */ |
| 46 | static struct omap_hwmod *oh_core; |
| 47 | |
| 48 | static bool opt_clock_available(const char *clk_role) |
| 49 | { |
| 50 | int i; |
| 51 | |
| 52 | for (i = 0; i < oh_core->opt_clks_cnt; i++) { |
| 53 | if (!strcmp(oh_core->opt_clks[i].role, clk_role)) |
| 54 | return true; |
| 55 | } |
| 56 | return false; |
| 57 | } |
| 58 | |
Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 59 | int __init omap_display_init(struct omap_dss_board_info *board_data) |
| 60 | { |
| 61 | int r = 0; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 62 | struct omap_hwmod *oh; |
| 63 | struct omap_device *od; |
| 64 | int i; |
| 65 | struct omap_display_platform_data pdata; |
| 66 | |
| 67 | /* |
| 68 | * omap: valid DSS hwmod names |
Mayuresh Janorkar | 545376e | 2011-01-27 11:17:04 +0000 | [diff] [blame] | 69 | * omap2,3,4: dss_core, dss_dispc, dss_rfbi, dss_venc |
| 70 | * omap3,4: dss_dsi1 |
| 71 | * omap4: dss_dsi2, dss_hdmi |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 72 | */ |
| 73 | char *oh_name[] = { "dss_core", "dss_dispc", "dss_rfbi", "dss_venc", |
Mayuresh Janorkar | 545376e | 2011-01-27 11:17:04 +0000 | [diff] [blame] | 74 | "dss_dsi1", "dss_dsi2", "dss_hdmi" }; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 75 | char *dev_name[] = { "omapdss_dss", "omapdss_dispc", "omapdss_rfbi", |
Mayuresh Janorkar | 545376e | 2011-01-27 11:17:04 +0000 | [diff] [blame] | 76 | "omapdss_venc", "omapdss_dsi1", "omapdss_dsi2", |
| 77 | "omapdss_hdmi" }; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 78 | int oh_count; |
| 79 | |
| 80 | memset(&pdata, 0, sizeof(pdata)); |
| 81 | |
| 82 | if (cpu_is_omap24xx()) |
Mayuresh Janorkar | 545376e | 2011-01-27 11:17:04 +0000 | [diff] [blame] | 83 | oh_count = ARRAY_SIZE(oh_name) - 3; |
| 84 | /* last 3 hwmod dev in oh_name are not available for omap2 */ |
| 85 | else if (cpu_is_omap44xx()) |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 86 | oh_count = ARRAY_SIZE(oh_name); |
Mayuresh Janorkar | 545376e | 2011-01-27 11:17:04 +0000 | [diff] [blame] | 87 | else |
| 88 | oh_count = ARRAY_SIZE(oh_name) - 2; |
| 89 | /* last 2 hwmod dev in oh_name are not available for omap3 */ |
| 90 | |
Semwal, Sumit | fd4b34f | 2011-03-01 02:42:13 -0600 | [diff] [blame] | 91 | /* opt_clks are always associated with dss hwmod */ |
| 92 | oh_core = omap_hwmod_lookup("dss_core"); |
| 93 | if (!oh_core) { |
| 94 | pr_err("Could not look up dss_core.\n"); |
| 95 | return -ENODEV; |
| 96 | } |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 97 | |
| 98 | pdata.board_data = board_data; |
| 99 | pdata.board_data->get_last_off_on_transaction_id = NULL; |
Semwal, Sumit | fd4b34f | 2011-03-01 02:42:13 -0600 | [diff] [blame] | 100 | pdata.opt_clock_available = opt_clock_available; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 101 | |
| 102 | for (i = 0; i < oh_count; i++) { |
| 103 | oh = omap_hwmod_lookup(oh_name[i]); |
| 104 | if (!oh) { |
| 105 | pr_err("Could not look up %s\n", oh_name[i]); |
| 106 | return -ENODEV; |
| 107 | } |
Semwal, Sumit | fd4b34f | 2011-03-01 02:42:13 -0600 | [diff] [blame] | 108 | |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 109 | od = omap_device_build(dev_name[i], -1, oh, &pdata, |
| 110 | sizeof(struct omap_display_platform_data), |
| 111 | omap_dss_latency, |
| 112 | ARRAY_SIZE(omap_dss_latency), 0); |
| 113 | |
| 114 | if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n", |
| 115 | oh_name[i])) |
| 116 | return -ENODEV; |
| 117 | } |
Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 118 | omap_display_device.dev.platform_data = board_data; |
| 119 | |
| 120 | r = platform_device_register(&omap_display_device); |
| 121 | if (r < 0) |
| 122 | printk(KERN_ERR "Unable to register OMAP-Display device\n"); |
| 123 | |
| 124 | return r; |
| 125 | } |