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 | |
Tomi Valkeinen | dc35835 | 2011-06-15 15:22:47 +0300 | [diff] [blame^] | 30 | #include "control.h" |
| 31 | |
Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 32 | static struct platform_device omap_display_device = { |
| 33 | .name = "omapdss", |
| 34 | .id = -1, |
| 35 | .dev = { |
| 36 | .platform_data = NULL, |
| 37 | }, |
| 38 | }; |
| 39 | |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 40 | static struct omap_device_pm_latency omap_dss_latency[] = { |
| 41 | [0] = { |
| 42 | .deactivate_func = omap_device_idle_hwmods, |
| 43 | .activate_func = omap_device_enable_hwmods, |
| 44 | .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST, |
| 45 | }, |
| 46 | }; |
| 47 | |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 48 | struct omap_dss_hwmod_data { |
| 49 | const char *oh_name; |
| 50 | const char *dev_name; |
| 51 | const int id; |
| 52 | }; |
| 53 | |
| 54 | static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = { |
| 55 | { "dss_core", "omapdss_dss", -1 }, |
| 56 | { "dss_dispc", "omapdss_dispc", -1 }, |
| 57 | { "dss_rfbi", "omapdss_rfbi", -1 }, |
| 58 | { "dss_venc", "omapdss_venc", -1 }, |
| 59 | }; |
| 60 | |
| 61 | static const struct omap_dss_hwmod_data omap3_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 }, |
Tomi Valkeinen | 7c68dd9 | 2011-08-03 14:00:57 +0300 | [diff] [blame] | 66 | { "dss_dsi1", "omapdss_dsi", 0 }, |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initdata = { |
| 70 | { "dss_core", "omapdss_dss", -1 }, |
| 71 | { "dss_dispc", "omapdss_dispc", -1 }, |
| 72 | { "dss_rfbi", "omapdss_rfbi", -1 }, |
| 73 | { "dss_venc", "omapdss_venc", -1 }, |
Tomi Valkeinen | 7c68dd9 | 2011-08-03 14:00:57 +0300 | [diff] [blame] | 74 | { "dss_dsi1", "omapdss_dsi", 0 }, |
| 75 | { "dss_dsi2", "omapdss_dsi", 1 }, |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 76 | { "dss_hdmi", "omapdss_hdmi", -1 }, |
| 77 | }; |
| 78 | |
Tomi Valkeinen | dc35835 | 2011-06-15 15:22:47 +0300 | [diff] [blame^] | 79 | static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes) |
| 80 | { |
| 81 | u32 enable_mask, enable_shift; |
| 82 | u32 pipd_mask, pipd_shift; |
| 83 | u32 reg; |
| 84 | |
| 85 | if (dsi_id == 0) { |
| 86 | enable_mask = OMAP4_DSI1_LANEENABLE_MASK; |
| 87 | enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT; |
| 88 | pipd_mask = OMAP4_DSI1_PIPD_MASK; |
| 89 | pipd_shift = OMAP4_DSI1_PIPD_SHIFT; |
| 90 | } else if (dsi_id == 1) { |
| 91 | enable_mask = OMAP4_DSI2_LANEENABLE_MASK; |
| 92 | enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT; |
| 93 | pipd_mask = OMAP4_DSI2_PIPD_MASK; |
| 94 | pipd_shift = OMAP4_DSI2_PIPD_SHIFT; |
| 95 | } else { |
| 96 | return -ENODEV; |
| 97 | } |
| 98 | |
| 99 | reg = omap4_ctrl_pad_readl(OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY); |
| 100 | |
| 101 | reg &= ~enable_mask; |
| 102 | reg &= ~pipd_mask; |
| 103 | |
| 104 | reg |= (lanes << enable_shift) & enable_mask; |
| 105 | reg |= (lanes << pipd_shift) & pipd_mask; |
| 106 | |
| 107 | omap4_ctrl_pad_writel(reg, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY); |
| 108 | |
| 109 | return 0; |
| 110 | } |
| 111 | |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 112 | static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask) |
| 113 | { |
Tomi Valkeinen | dc35835 | 2011-06-15 15:22:47 +0300 | [diff] [blame^] | 114 | if (cpu_is_omap44xx()) |
| 115 | return omap4_dsi_mux_pads(dsi_id, lane_mask); |
| 116 | |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask) |
| 121 | { |
Tomi Valkeinen | dc35835 | 2011-06-15 15:22:47 +0300 | [diff] [blame^] | 122 | if (cpu_is_omap44xx()) |
| 123 | omap4_dsi_mux_pads(dsi_id, 0); |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 124 | } |
| 125 | |
Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 126 | int __init omap_display_init(struct omap_dss_board_info *board_data) |
| 127 | { |
| 128 | int r = 0; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 129 | struct omap_hwmod *oh; |
| 130 | struct omap_device *od; |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 131 | int i, oh_count; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 132 | struct omap_display_platform_data pdata; |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 133 | const struct omap_dss_hwmod_data *curr_dss_hwmod; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 134 | |
| 135 | memset(&pdata, 0, sizeof(pdata)); |
| 136 | |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 137 | if (cpu_is_omap24xx()) { |
| 138 | curr_dss_hwmod = omap2_dss_hwmod_data; |
| 139 | oh_count = ARRAY_SIZE(omap2_dss_hwmod_data); |
| 140 | } else if (cpu_is_omap34xx()) { |
| 141 | curr_dss_hwmod = omap3_dss_hwmod_data; |
| 142 | oh_count = ARRAY_SIZE(omap3_dss_hwmod_data); |
| 143 | } else { |
| 144 | curr_dss_hwmod = omap4_dss_hwmod_data; |
| 145 | oh_count = ARRAY_SIZE(omap4_dss_hwmod_data); |
| 146 | } |
Mayuresh Janorkar | 545376e | 2011-01-27 11:17:04 +0000 | [diff] [blame] | 147 | |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 148 | if (board_data->dsi_enable_pads == NULL) |
| 149 | board_data->dsi_enable_pads = omap_dsi_enable_pads; |
| 150 | if (board_data->dsi_disable_pads == NULL) |
| 151 | board_data->dsi_disable_pads = omap_dsi_disable_pads; |
| 152 | |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 153 | pdata.board_data = board_data; |
Tomi Valkeinen | 700dee7 | 2011-05-23 15:50:47 +0300 | [diff] [blame] | 154 | pdata.board_data->get_context_loss_count = |
| 155 | omap_pm_get_dev_context_loss_count; |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 156 | |
| 157 | for (i = 0; i < oh_count; i++) { |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 158 | oh = omap_hwmod_lookup(curr_dss_hwmod[i].oh_name); |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 159 | if (!oh) { |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 160 | pr_err("Could not look up %s\n", |
| 161 | curr_dss_hwmod[i].oh_name); |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 162 | return -ENODEV; |
| 163 | } |
Semwal, Sumit | fd4b34f | 2011-03-01 02:42:13 -0600 | [diff] [blame] | 164 | |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 165 | od = omap_device_build(curr_dss_hwmod[i].dev_name, |
| 166 | curr_dss_hwmod[i].id, oh, &pdata, |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 167 | sizeof(struct omap_display_platform_data), |
| 168 | omap_dss_latency, |
| 169 | ARRAY_SIZE(omap_dss_latency), 0); |
| 170 | |
| 171 | if (WARN((IS_ERR(od)), "Could not build omap_device for %s\n", |
Archit Taneja | 179e045 | 2011-04-18 09:32:13 +0530 | [diff] [blame] | 172 | curr_dss_hwmod[i].oh_name)) |
Senthilvadivu Guruswamy | cf07f53 | 2011-01-24 06:21:56 +0000 | [diff] [blame] | 173 | return -ENODEV; |
| 174 | } |
Sumit Semwal | b7ee79a | 2011-01-24 06:21:54 +0000 | [diff] [blame] | 175 | omap_display_device.dev.platform_data = board_data; |
| 176 | |
| 177 | r = platform_device_register(&omap_display_device); |
| 178 | if (r < 0) |
| 179 | printk(KERN_ERR "Unable to register OMAP-Display device\n"); |
| 180 | |
| 181 | return r; |
| 182 | } |