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 | |
Tomi Valkeinen | a0b38cc | 2011-05-11 14:05:07 +0300 | [diff] [blame] | 25 | #include <video/omapdss.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> |
Tomi Valkeinen | 700dee7 | 2011-05-23 15:50:47 +0300 | [diff] [blame] | 28 | #include <plat/omap-pm.h> |
Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 29 | |
| 30 | static struct platform_device omap_display_device = { |
| 31 | .name = "omapdss", |
| 32 | .id = -1, |
| 33 | .dev = { |
| 34 | .platform_data = NULL, |
| 35 | }, |
| 36 | }; |
| 37 | |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 38 | struct omap_dss_hwmod_data { |
| 39 | const char *oh_name; |
| 40 | const char *dev_name; |
| 41 | const int id; |
| 42 | }; |
| 43 | |
| 44 | static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = { |
| 45 | { "dss_core", "omapdss_dss", -1 }, |
| 46 | { "dss_dispc", "omapdss_dispc", -1 }, |
| 47 | { "dss_rfbi", "omapdss_rfbi", -1 }, |
| 48 | { "dss_venc", "omapdss_venc", -1 }, |
| 49 | }; |
| 50 | |
| 51 | static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initdata = { |
| 52 | { "dss_core", "omapdss_dss", -1 }, |
| 53 | { "dss_dispc", "omapdss_dispc", -1 }, |
| 54 | { "dss_rfbi", "omapdss_rfbi", -1 }, |
| 55 | { "dss_venc", "omapdss_venc", -1 }, |
| 56 | { "dss_dsi1", "omapdss_dsi1", -1 }, |
| 57 | }; |
| 58 | |
| 59 | static const struct omap_dss_hwmod_data omap4_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 }, |
| 64 | { "dss_dsi1", "omapdss_dsi1", -1 }, |
| 65 | { "dss_dsi2", "omapdss_dsi2", -1 }, |
| 66 | { "dss_hdmi", "omapdss_hdmi", -1 }, |
| 67 | }; |
| 68 | |
Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 69 | int __init omap_display_init(struct omap_dss_board_info *board_data) |
| 70 | { |
| 71 | int r = 0; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 72 | struct omap_hwmod *oh; |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 73 | struct platform_device *pdev; |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 74 | int i, oh_count; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 75 | struct omap_display_platform_data pdata; |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 76 | const struct omap_dss_hwmod_data *curr_dss_hwmod; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 77 | |
| 78 | memset(&pdata, 0, sizeof(pdata)); |
| 79 | |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 80 | if (cpu_is_omap24xx()) { |
| 81 | curr_dss_hwmod = omap2_dss_hwmod_data; |
| 82 | oh_count = ARRAY_SIZE(omap2_dss_hwmod_data); |
| 83 | } else if (cpu_is_omap34xx()) { |
| 84 | curr_dss_hwmod = omap3_dss_hwmod_data; |
| 85 | oh_count = ARRAY_SIZE(omap3_dss_hwmod_data); |
| 86 | } else { |
| 87 | curr_dss_hwmod = omap4_dss_hwmod_data; |
| 88 | oh_count = ARRAY_SIZE(omap4_dss_hwmod_data); |
| 89 | } |
Mayuresh Janorkar | 545376e | 2011-01-27 11:17:04 +0000 | [diff] [blame] | 90 | |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 91 | pdata.board_data = board_data; |
Tomi Valkeinen | 700dee7 | 2011-05-23 15:50:47 +0300 | [diff] [blame] | 92 | pdata.board_data->get_context_loss_count = |
| 93 | omap_pm_get_dev_context_loss_count; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 94 | |
| 95 | for (i = 0; i < oh_count; i++) { |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 96 | oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name); |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 97 | if (!oh) { |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 98 | pr_err("Could not look up %s\n", |
| 99 | curr_dss_hwmod[i].oh_name); |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 100 | return -ENODEV; |
| 101 | } |
Semwal, Sumit | fd4b34f | 2011-03-01 02:42:13 -0600 | [diff] [blame] | 102 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 103 | pdev = omap_device_build(curr_dss_hwmod[i].dev_name, |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 104 | curr_dss_hwmod[i].id, oh, &pdata, |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 105 | sizeof(struct omap_display_platform_data), |
Benoit Cousson | f718e2c | 2011-08-10 15:30:09 +0200 | [diff] [blame^] | 106 | NULL, 0, 0); |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 107 | |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 108 | if (WARN((IS_ERR(pdev)), "Could not build omap_device for %s\n", |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 109 | curr_dss_hwmod[i].oh_name)) |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 110 | return -ENODEV; |
| 111 | } |
Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 112 | omap_display_device.dev.platform_data = board_data; |
| 113 | |
| 114 | r = platform_device_register(&omap_display_device); |
| 115 | if (r < 0) |
| 116 | printk(KERN_ERR "Unable to register OMAP-Display device\n"); |
| 117 | |
| 118 | return r; |
| 119 | } |