Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1 | /* |
| 2 | * hdmi.c |
| 3 | * |
| 4 | * HDMI interface DSS driver setting for TI's OMAP4 family of processor. |
| 5 | * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/ |
| 6 | * Authors: Yong Zhi |
| 7 | * Mythri pk <mythripk@ti.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License version 2 as published by |
| 11 | * the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 16 | * more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #define DSS_SUBSYS_NAME "HDMI" |
| 23 | |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/err.h> |
| 27 | #include <linux/io.h> |
| 28 | #include <linux/interrupt.h> |
| 29 | #include <linux/mutex.h> |
| 30 | #include <linux/delay.h> |
| 31 | #include <linux/string.h> |
Tomi Valkeinen | 24e6289 | 2011-05-23 11:51:18 +0300 | [diff] [blame] | 32 | #include <linux/platform_device.h> |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 33 | #include <linux/pm_runtime.h> |
| 34 | #include <linux/clk.h> |
Tomi Valkeinen | a0b38cc | 2011-05-11 14:05:07 +0300 | [diff] [blame] | 35 | #include <video/omapdss.h> |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 36 | #if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \ |
| 37 | defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE) |
| 38 | #include <sound/soc.h> |
| 39 | #include <sound/pcm_params.h> |
| 40 | #endif |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 41 | |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 42 | #include "ti_hdmi.h" |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 43 | #include "dss.h" |
| 44 | #include "hdmi.h" |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 45 | #include "dss_features.h" |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 46 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 47 | #define HDMI_WP 0x0 |
| 48 | #define HDMI_CORE_SYS 0x400 |
| 49 | #define HDMI_CORE_AV 0x900 |
| 50 | #define HDMI_PLLCTRL 0x200 |
| 51 | #define HDMI_PHY 0x300 |
| 52 | |
Mythri P K | 7c1f1ec | 2011-09-08 19:06:22 +0530 | [diff] [blame^] | 53 | /* HDMI EDID Length move this */ |
| 54 | #define HDMI_EDID_MAX_LENGTH 256 |
| 55 | #define EDID_TIMING_DESCRIPTOR_SIZE 0x12 |
| 56 | #define EDID_DESCRIPTOR_BLOCK0_ADDRESS 0x36 |
| 57 | #define EDID_DESCRIPTOR_BLOCK1_ADDRESS 0x80 |
| 58 | #define EDID_SIZE_BLOCK0_TIMING_DESCRIPTOR 4 |
| 59 | #define EDID_SIZE_BLOCK1_TIMING_DESCRIPTOR 4 |
| 60 | |
| 61 | #define OMAP_HDMI_TIMINGS_NB 34 |
| 62 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 63 | static struct { |
| 64 | struct mutex lock; |
| 65 | struct omap_display_platform_data *pdata; |
| 66 | struct platform_device *pdev; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 67 | struct hdmi_ip_data ip_data; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 68 | int code; |
| 69 | int mode; |
| 70 | u8 edid[HDMI_EDID_MAX_LENGTH]; |
| 71 | u8 edid_set; |
| 72 | bool custom_set; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 73 | |
| 74 | struct clk *sys_clk; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 75 | } hdmi; |
| 76 | |
| 77 | /* |
| 78 | * Logic for the below structure : |
| 79 | * user enters the CEA or VESA timings by specifying the HDMI/DVI code. |
| 80 | * There is a correspondence between CEA/VESA timing and code, please |
| 81 | * refer to section 6.3 in HDMI 1.3 specification for timing code. |
| 82 | * |
| 83 | * In the below structure, cea_vesa_timings corresponds to all OMAP4 |
| 84 | * supported CEA and VESA timing values.code_cea corresponds to the CEA |
| 85 | * code, It is used to get the timing from cea_vesa_timing array.Similarly |
| 86 | * with code_vesa. Code_index is used for back mapping, that is once EDID |
| 87 | * is read from the TV, EDID is parsed to find the timing values and then |
| 88 | * map it to corresponding CEA or VESA index. |
| 89 | */ |
| 90 | |
| 91 | static const struct hdmi_timings cea_vesa_timings[OMAP_HDMI_TIMINGS_NB] = { |
| 92 | { {640, 480, 25200, 96, 16, 48, 2, 10, 33} , 0 , 0}, |
| 93 | { {1280, 720, 74250, 40, 440, 220, 5, 5, 20}, 1, 1}, |
| 94 | { {1280, 720, 74250, 40, 110, 220, 5, 5, 20}, 1, 1}, |
| 95 | { {720, 480, 27027, 62, 16, 60, 6, 9, 30}, 0, 0}, |
| 96 | { {2880, 576, 108000, 256, 48, 272, 5, 5, 39}, 0, 0}, |
| 97 | { {1440, 240, 27027, 124, 38, 114, 3, 4, 15}, 0, 0}, |
| 98 | { {1440, 288, 27000, 126, 24, 138, 3, 2, 19}, 0, 0}, |
| 99 | { {1920, 540, 74250, 44, 528, 148, 5, 2, 15}, 1, 1}, |
| 100 | { {1920, 540, 74250, 44, 88, 148, 5, 2, 15}, 1, 1}, |
| 101 | { {1920, 1080, 148500, 44, 88, 148, 5, 4, 36}, 1, 1}, |
| 102 | { {720, 576, 27000, 64, 12, 68, 5, 5, 39}, 0, 0}, |
| 103 | { {1440, 576, 54000, 128, 24, 136, 5, 5, 39}, 0, 0}, |
| 104 | { {1920, 1080, 148500, 44, 528, 148, 5, 4, 36}, 1, 1}, |
| 105 | { {2880, 480, 108108, 248, 64, 240, 6, 9, 30}, 0, 0}, |
| 106 | { {1920, 1080, 74250, 44, 638, 148, 5, 4, 36}, 1, 1}, |
| 107 | /* VESA From Here */ |
| 108 | { {640, 480, 25175, 96, 16, 48, 2 , 11, 31}, 0, 0}, |
| 109 | { {800, 600, 40000, 128, 40, 88, 4 , 1, 23}, 1, 1}, |
| 110 | { {848, 480, 33750, 112, 16, 112, 8 , 6, 23}, 1, 1}, |
| 111 | { {1280, 768, 79500, 128, 64, 192, 7 , 3, 20}, 1, 0}, |
| 112 | { {1280, 800, 83500, 128, 72, 200, 6 , 3, 22}, 1, 0}, |
| 113 | { {1360, 768, 85500, 112, 64, 256, 6 , 3, 18}, 1, 1}, |
| 114 | { {1280, 960, 108000, 112, 96, 312, 3 , 1, 36}, 1, 1}, |
| 115 | { {1280, 1024, 108000, 112, 48, 248, 3 , 1, 38}, 1, 1}, |
| 116 | { {1024, 768, 65000, 136, 24, 160, 6, 3, 29}, 0, 0}, |
| 117 | { {1400, 1050, 121750, 144, 88, 232, 4, 3, 32}, 1, 0}, |
| 118 | { {1440, 900, 106500, 152, 80, 232, 6, 3, 25}, 1, 0}, |
| 119 | { {1680, 1050, 146250, 176 , 104, 280, 6, 3, 30}, 1, 0}, |
| 120 | { {1366, 768, 85500, 143, 70, 213, 3, 3, 24}, 1, 1}, |
| 121 | { {1920, 1080, 148500, 44, 148, 80, 5, 4, 36}, 1, 1}, |
| 122 | { {1280, 768, 68250, 32, 48, 80, 7, 3, 12}, 0, 1}, |
| 123 | { {1400, 1050, 101000, 32, 48, 80, 4, 3, 23}, 0, 1}, |
| 124 | { {1680, 1050, 119000, 32, 48, 80, 6, 3, 21}, 0, 1}, |
| 125 | { {1280, 800, 79500, 32, 48, 80, 6, 3, 14}, 0, 1}, |
| 126 | { {1280, 720, 74250, 40, 110, 220, 5, 5, 20}, 1, 1} |
| 127 | }; |
| 128 | |
| 129 | /* |
| 130 | * This is a static mapping array which maps the timing values |
| 131 | * with corresponding CEA / VESA code |
| 132 | */ |
| 133 | static const int code_index[OMAP_HDMI_TIMINGS_NB] = { |
| 134 | 1, 19, 4, 2, 37, 6, 21, 20, 5, 16, 17, 29, 31, 35, 32, |
| 135 | /* <--15 CEA 17--> vesa*/ |
| 136 | 4, 9, 0xE, 0x17, 0x1C, 0x27, 0x20, 0x23, 0x10, 0x2A, |
| 137 | 0X2F, 0x3A, 0X51, 0X52, 0x16, 0x29, 0x39, 0x1B |
| 138 | }; |
| 139 | |
| 140 | /* |
| 141 | * This is reverse static mapping which maps the CEA / VESA code |
| 142 | * to the corresponding timing values |
| 143 | */ |
| 144 | static const int code_cea[39] = { |
| 145 | -1, 0, 3, 3, 2, 8, 5, 5, -1, -1, |
| 146 | -1, -1, -1, -1, -1, -1, 9, 10, 10, 1, |
| 147 | 7, 6, 6, -1, -1, -1, -1, -1, -1, 11, |
| 148 | 11, 12, 14, -1, -1, 13, 13, 4, 4 |
| 149 | }; |
| 150 | |
| 151 | static const int code_vesa[85] = { |
| 152 | -1, -1, -1, -1, 15, -1, -1, -1, -1, 16, |
| 153 | -1, -1, -1, -1, 17, -1, 23, -1, -1, -1, |
| 154 | -1, -1, 29, 18, -1, -1, -1, 32, 19, -1, |
| 155 | -1, -1, 21, -1, -1, 22, -1, -1, -1, 20, |
| 156 | -1, 30, 24, -1, -1, -1, -1, 25, -1, -1, |
| 157 | -1, -1, -1, -1, -1, -1, -1, 31, 26, -1, |
| 158 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 159 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 160 | -1, 27, 28, -1, 33}; |
| 161 | |
| 162 | static const u8 edid_header[8] = {0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0}; |
| 163 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 164 | static inline void hdmi_write_reg(void __iomem *base_addr, |
| 165 | const struct hdmi_reg idx, u32 val) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 166 | { |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 167 | __raw_writel(val, base_addr + idx.idx); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 168 | } |
| 169 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 170 | static inline u32 hdmi_read_reg(void __iomem *base_addr, |
| 171 | const struct hdmi_reg idx) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 172 | { |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 173 | return __raw_readl(base_addr + idx.idx); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 174 | } |
| 175 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 176 | static inline void __iomem *hdmi_wp_base(struct hdmi_ip_data *ip_data) |
| 177 | { |
| 178 | return ip_data->base_wp; |
| 179 | } |
| 180 | |
| 181 | static inline void __iomem *hdmi_phy_base(struct hdmi_ip_data *ip_data) |
| 182 | { |
| 183 | return ip_data->base_wp + ip_data->phy_offset; |
| 184 | } |
| 185 | |
| 186 | static inline void __iomem *hdmi_pll_base(struct hdmi_ip_data *ip_data) |
| 187 | { |
| 188 | return ip_data->base_wp + ip_data->pll_offset; |
| 189 | } |
| 190 | |
| 191 | static inline void __iomem *hdmi_av_base(struct hdmi_ip_data *ip_data) |
| 192 | { |
| 193 | return ip_data->base_wp + ip_data->core_av_offset; |
| 194 | } |
| 195 | |
| 196 | static inline void __iomem *hdmi_core_sys_base(struct hdmi_ip_data *ip_data) |
| 197 | { |
| 198 | return ip_data->base_wp + ip_data->core_sys_offset; |
| 199 | } |
| 200 | |
| 201 | static inline int hdmi_wait_for_bit_change(void __iomem *base_addr, |
| 202 | const struct hdmi_reg idx, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 203 | int b2, int b1, u32 val) |
| 204 | { |
| 205 | u32 t = 0; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 206 | while (val != REG_GET(base_addr, idx, b2, b1)) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 207 | udelay(1); |
| 208 | if (t++ > 10000) |
| 209 | return !val; |
| 210 | } |
| 211 | return val; |
| 212 | } |
| 213 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 214 | static int hdmi_runtime_get(void) |
| 215 | { |
| 216 | int r; |
| 217 | |
| 218 | DSSDBG("hdmi_runtime_get\n"); |
| 219 | |
| 220 | r = pm_runtime_get_sync(&hdmi.pdev->dev); |
| 221 | WARN_ON(r < 0); |
| 222 | return r < 0 ? r : 0; |
| 223 | } |
| 224 | |
| 225 | static void hdmi_runtime_put(void) |
| 226 | { |
| 227 | int r; |
| 228 | |
| 229 | DSSDBG("hdmi_runtime_put\n"); |
| 230 | |
| 231 | r = pm_runtime_put(&hdmi.pdev->dev); |
| 232 | WARN_ON(r < 0); |
| 233 | } |
| 234 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 235 | int hdmi_init_display(struct omap_dss_device *dssdev) |
| 236 | { |
| 237 | DSSDBG("init_display\n"); |
| 238 | |
| 239 | return 0; |
| 240 | } |
| 241 | |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 242 | static int hdmi_pll_init(struct hdmi_ip_data *ip_data) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 243 | { |
| 244 | u32 r; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 245 | void __iomem *pll_base = hdmi_pll_base(ip_data); |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 246 | struct hdmi_pll_info *fmt = &ip_data->pll_data; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 247 | |
| 248 | /* PLL start always use manual mode */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 249 | REG_FLD_MOD(pll_base, PLLCTRL_PLL_CONTROL, 0x0, 0, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 250 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 251 | r = hdmi_read_reg(pll_base, PLLCTRL_CFG1); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 252 | r = FLD_MOD(r, fmt->regm, 20, 9); /* CFG1_PLL_REGM */ |
| 253 | r = FLD_MOD(r, fmt->regn, 8, 1); /* CFG1_PLL_REGN */ |
| 254 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 255 | hdmi_write_reg(pll_base, PLLCTRL_CFG1, r); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 256 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 257 | r = hdmi_read_reg(pll_base, PLLCTRL_CFG2); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 258 | |
| 259 | r = FLD_MOD(r, 0x0, 12, 12); /* PLL_HIGHFREQ divide by 2 */ |
| 260 | r = FLD_MOD(r, 0x1, 13, 13); /* PLL_REFEN */ |
| 261 | r = FLD_MOD(r, 0x0, 14, 14); /* PHY_CLKINEN de-assert during locking */ |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 262 | r = FLD_MOD(r, fmt->refsel, 22, 21); /* REFSEL */ |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 263 | |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 264 | if (fmt->dcofreq) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 265 | /* divider programming for frequency beyond 1000Mhz */ |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 266 | REG_FLD_MOD(pll_base, PLLCTRL_CFG3, fmt->regsd, 17, 10); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 267 | r = FLD_MOD(r, 0x4, 3, 1); /* 1000MHz and 2000MHz */ |
| 268 | } else { |
| 269 | r = FLD_MOD(r, 0x2, 3, 1); /* 500MHz and 1000MHz */ |
| 270 | } |
| 271 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 272 | hdmi_write_reg(pll_base, PLLCTRL_CFG2, r); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 273 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 274 | r = hdmi_read_reg(pll_base, PLLCTRL_CFG4); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 275 | r = FLD_MOD(r, fmt->regm2, 24, 18); |
| 276 | r = FLD_MOD(r, fmt->regmf, 17, 0); |
| 277 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 278 | hdmi_write_reg(pll_base, PLLCTRL_CFG4, r); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 279 | |
| 280 | /* go now */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 281 | REG_FLD_MOD(pll_base, PLLCTRL_PLL_GO, 0x1, 0, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 282 | |
| 283 | /* wait for bit change */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 284 | if (hdmi_wait_for_bit_change(pll_base, PLLCTRL_PLL_GO, |
| 285 | 0, 0, 1) != 1) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 286 | DSSERR("PLL GO bit not set\n"); |
| 287 | return -ETIMEDOUT; |
| 288 | } |
| 289 | |
| 290 | /* Wait till the lock bit is set in PLL status */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 291 | if (hdmi_wait_for_bit_change(pll_base, |
| 292 | PLLCTRL_PLL_STATUS, 1, 1, 1) != 1) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 293 | DSSWARN("cannot lock PLL\n"); |
| 294 | DSSWARN("CFG1 0x%x\n", |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 295 | hdmi_read_reg(pll_base, PLLCTRL_CFG1)); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 296 | DSSWARN("CFG2 0x%x\n", |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 297 | hdmi_read_reg(pll_base, PLLCTRL_CFG2)); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 298 | DSSWARN("CFG4 0x%x\n", |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 299 | hdmi_read_reg(pll_base, PLLCTRL_CFG4)); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 300 | return -ETIMEDOUT; |
| 301 | } |
| 302 | |
| 303 | DSSDBG("PLL locked!\n"); |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | /* PHY_PWR_CMD */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 309 | static int hdmi_set_phy_pwr(struct hdmi_ip_data *ip_data, enum hdmi_phy_pwr val) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 310 | { |
| 311 | /* Command for power control of HDMI PHY */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 312 | REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL, val, 7, 6); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 313 | |
| 314 | /* Status of the power control of HDMI PHY */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 315 | if (hdmi_wait_for_bit_change(hdmi_wp_base(ip_data), |
| 316 | HDMI_WP_PWR_CTRL, 5, 4, val) != val) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 317 | DSSERR("Failed to set PHY power mode to %d\n", val); |
| 318 | return -ETIMEDOUT; |
| 319 | } |
| 320 | |
| 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | /* PLL_PWR_CMD */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 325 | int hdmi_set_pll_pwr(struct hdmi_ip_data *ip_data, enum hdmi_pll_pwr val) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 326 | { |
| 327 | /* Command for power control of HDMI PLL */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 328 | REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL, val, 3, 2); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 329 | |
| 330 | /* wait till PHY_PWR_STATUS is set */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 331 | if (hdmi_wait_for_bit_change(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL, |
| 332 | 1, 0, val) != val) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 333 | DSSERR("Failed to set PHY_PWR_STATUS\n"); |
| 334 | return -ETIMEDOUT; |
| 335 | } |
| 336 | |
| 337 | return 0; |
| 338 | } |
| 339 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 340 | static int hdmi_pll_reset(struct hdmi_ip_data *ip_data) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 341 | { |
| 342 | /* SYSRESET controlled by power FSM */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 343 | REG_FLD_MOD(hdmi_pll_base(ip_data), PLLCTRL_PLL_CONTROL, 0x0, 3, 3); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 344 | |
| 345 | /* READ 0x0 reset is in progress */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 346 | if (hdmi_wait_for_bit_change(hdmi_pll_base(ip_data), |
| 347 | PLLCTRL_PLL_STATUS, 0, 0, 1) != 1) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 348 | DSSERR("Failed to sysreset PLL\n"); |
| 349 | return -ETIMEDOUT; |
| 350 | } |
| 351 | |
| 352 | return 0; |
| 353 | } |
| 354 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 355 | static int hdmi_phy_init(struct hdmi_ip_data *ip_data) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 356 | { |
| 357 | u16 r = 0; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 358 | void __iomem *phy_base = hdmi_phy_base(ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 359 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 360 | r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_LDOON); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 361 | if (r) |
| 362 | return r; |
| 363 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 364 | r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_TXON); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 365 | if (r) |
| 366 | return r; |
| 367 | |
| 368 | /* |
| 369 | * Read address 0 in order to get the SCP reset done completed |
| 370 | * Dummy access performed to make sure reset is done |
| 371 | */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 372 | hdmi_read_reg(phy_base, HDMI_TXPHY_TX_CTRL); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 373 | |
| 374 | /* |
| 375 | * Write to phy address 0 to configure the clock |
| 376 | * use HFBITCLK write HDMI_TXPHY_TX_CONTROL_FREQOUT field |
| 377 | */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 378 | REG_FLD_MOD(phy_base, HDMI_TXPHY_TX_CTRL, 0x1, 31, 30); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 379 | |
| 380 | /* Write to phy address 1 to start HDMI line (TXVALID and TMDSCLKEN) */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 381 | hdmi_write_reg(phy_base, HDMI_TXPHY_DIGITAL_CTRL, 0xF0000000); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 382 | |
| 383 | /* Setup max LDO voltage */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 384 | REG_FLD_MOD(phy_base, HDMI_TXPHY_POWER_CTRL, 0xB, 3, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 385 | |
| 386 | /* Write to phy address 3 to change the polarity control */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 387 | REG_FLD_MOD(phy_base, HDMI_TXPHY_PAD_CFG_CTRL, 0x1, 27, 27); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 392 | static int hdmi_pll_program(struct hdmi_ip_data *ip_data) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 393 | { |
| 394 | u16 r = 0; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 395 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 396 | r = hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_ALLOFF); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 397 | if (r) |
| 398 | return r; |
| 399 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 400 | r = hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_BOTHON_ALLCLKS); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 401 | if (r) |
| 402 | return r; |
| 403 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 404 | r = hdmi_pll_reset(ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 405 | if (r) |
| 406 | return r; |
| 407 | |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 408 | r = hdmi_pll_init(ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 409 | if (r) |
| 410 | return r; |
| 411 | |
| 412 | return 0; |
| 413 | } |
| 414 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 415 | static void hdmi_phy_off(struct hdmi_ip_data *ip_data) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 416 | { |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 417 | hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 418 | } |
| 419 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 420 | static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data, |
| 421 | u8 *pedid, int ext) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 422 | { |
| 423 | u32 i, j; |
| 424 | char checksum = 0; |
| 425 | u32 offset = 0; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 426 | void __iomem *core_sys_base = hdmi_core_sys_base(ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 427 | |
| 428 | /* Turn on CLK for DDC */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 429 | REG_FLD_MOD(hdmi_av_base(ip_data), HDMI_CORE_AV_DPD, 0x7, 2, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 430 | |
| 431 | /* |
| 432 | * SW HACK : Without the Delay DDC(i2c bus) reads 0 values / |
| 433 | * right shifted values( The behavior is not consistent and seen only |
| 434 | * with some TV's) |
| 435 | */ |
| 436 | usleep_range(800, 1000); |
| 437 | |
| 438 | if (!ext) { |
| 439 | /* Clk SCL Devices */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 440 | REG_FLD_MOD(core_sys_base, HDMI_CORE_DDC_CMD, 0xA, 3, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 441 | |
| 442 | /* HDMI_CORE_DDC_STATUS_IN_PROG */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 443 | if (hdmi_wait_for_bit_change(core_sys_base, |
| 444 | HDMI_CORE_DDC_STATUS, 4, 4, 0) != 0) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 445 | DSSERR("Failed to program DDC\n"); |
| 446 | return -ETIMEDOUT; |
| 447 | } |
| 448 | |
| 449 | /* Clear FIFO */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 450 | REG_FLD_MOD(core_sys_base, HDMI_CORE_DDC_CMD, 0x9, 3, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 451 | |
| 452 | /* HDMI_CORE_DDC_STATUS_IN_PROG */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 453 | if (hdmi_wait_for_bit_change(core_sys_base, |
| 454 | HDMI_CORE_DDC_STATUS, 4, 4, 0) != 0) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 455 | DSSERR("Failed to program DDC\n"); |
| 456 | return -ETIMEDOUT; |
| 457 | } |
| 458 | |
| 459 | } else { |
| 460 | if (ext % 2 != 0) |
| 461 | offset = 0x80; |
| 462 | } |
| 463 | |
| 464 | /* Load Segment Address Register */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 465 | REG_FLD_MOD(core_sys_base, HDMI_CORE_DDC_SEGM, ext/2, 7, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 466 | |
| 467 | /* Load Slave Address Register */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 468 | REG_FLD_MOD(core_sys_base, HDMI_CORE_DDC_ADDR, 0xA0 >> 1, 7, 1); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 469 | |
| 470 | /* Load Offset Address Register */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 471 | REG_FLD_MOD(core_sys_base, HDMI_CORE_DDC_OFFSET, offset, 7, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 472 | |
| 473 | /* Load Byte Count */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 474 | REG_FLD_MOD(core_sys_base, HDMI_CORE_DDC_COUNT1, 0x80, 7, 0); |
| 475 | REG_FLD_MOD(core_sys_base, HDMI_CORE_DDC_COUNT2, 0x0, 1, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 476 | |
| 477 | /* Set DDC_CMD */ |
| 478 | if (ext) |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 479 | REG_FLD_MOD(core_sys_base, HDMI_CORE_DDC_CMD, 0x4, 3, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 480 | else |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 481 | REG_FLD_MOD(core_sys_base, HDMI_CORE_DDC_CMD, 0x2, 3, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 482 | |
| 483 | /* HDMI_CORE_DDC_STATUS_BUS_LOW */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 484 | if (REG_GET(core_sys_base, HDMI_CORE_DDC_STATUS, 6, 6) == 1) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 485 | DSSWARN("I2C Bus Low?\n"); |
| 486 | return -EIO; |
| 487 | } |
| 488 | /* HDMI_CORE_DDC_STATUS_NO_ACK */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 489 | if (REG_GET(core_sys_base, HDMI_CORE_DDC_STATUS, 5, 5) == 1) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 490 | DSSWARN("I2C No Ack\n"); |
| 491 | return -EIO; |
| 492 | } |
| 493 | |
| 494 | i = ext * 128; |
| 495 | j = 0; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 496 | while (((REG_GET(core_sys_base, HDMI_CORE_DDC_STATUS, 4, 4) == 1) || |
| 497 | (REG_GET(core_sys_base, |
| 498 | HDMI_CORE_DDC_STATUS, 2, 2) == 0)) && j < 128) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 499 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 500 | if (REG_GET(core_sys_base, HDMI_CORE_DDC_STATUS, 2, 2) == 0) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 501 | /* FIFO not empty */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 502 | pedid[i++] = REG_GET(core_sys_base, |
| 503 | HDMI_CORE_DDC_DATA, 7, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 504 | j++; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | for (j = 0; j < 128; j++) |
| 509 | checksum += pedid[j]; |
| 510 | |
| 511 | if (checksum != 0) { |
| 512 | DSSERR("E-EDID checksum failed!!\n"); |
| 513 | return -EIO; |
| 514 | } |
| 515 | |
| 516 | return 0; |
| 517 | } |
| 518 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 519 | static int read_edid(struct hdmi_ip_data *ip_data, u8 *pedid, u16 max_length) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 520 | { |
| 521 | int r = 0, n = 0, i = 0; |
| 522 | int max_ext_blocks = (max_length / 128) - 1; |
| 523 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 524 | r = hdmi_core_ddc_edid(ip_data, pedid, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 525 | if (r) { |
| 526 | return r; |
| 527 | } else { |
| 528 | n = pedid[0x7e]; |
| 529 | |
| 530 | /* |
| 531 | * README: need to comply with max_length set by the caller. |
| 532 | * Better implementation should be to allocate necessary |
| 533 | * memory to store EDID according to nb_block field found |
| 534 | * in first block |
| 535 | */ |
| 536 | if (n > max_ext_blocks) |
| 537 | n = max_ext_blocks; |
| 538 | |
| 539 | for (i = 1; i <= n; i++) { |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 540 | r = hdmi_core_ddc_edid(ip_data, pedid, i); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 541 | if (r) |
| 542 | return r; |
| 543 | } |
| 544 | } |
| 545 | return 0; |
| 546 | } |
| 547 | |
Mythri P K | 38863b7 | 2011-09-08 19:06:20 +0530 | [diff] [blame] | 548 | static void copy_hdmi_to_dss_timings( |
| 549 | const struct hdmi_video_timings *hdmi_timings, |
| 550 | struct omap_video_timings *timings) |
| 551 | { |
| 552 | timings->x_res = hdmi_timings->x_res; |
| 553 | timings->y_res = hdmi_timings->y_res; |
| 554 | timings->pixel_clock = hdmi_timings->pixel_clock; |
| 555 | timings->hbp = hdmi_timings->hbp; |
| 556 | timings->hfp = hdmi_timings->hfp; |
| 557 | timings->hsw = hdmi_timings->hsw; |
| 558 | timings->vbp = hdmi_timings->vbp; |
| 559 | timings->vfp = hdmi_timings->vfp; |
| 560 | timings->vsw = hdmi_timings->vsw; |
| 561 | } |
| 562 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 563 | static int get_timings_index(void) |
| 564 | { |
| 565 | int code; |
| 566 | |
| 567 | if (hdmi.mode == 0) |
| 568 | code = code_vesa[hdmi.code]; |
| 569 | else |
| 570 | code = code_cea[hdmi.code]; |
| 571 | |
| 572 | if (code == -1) { |
| 573 | /* HDMI code 4 corresponds to 640 * 480 VGA */ |
| 574 | hdmi.code = 4; |
| 575 | /* DVI mode 1 corresponds to HDMI 0 to DVI */ |
| 576 | hdmi.mode = HDMI_DVI; |
| 577 | |
| 578 | code = code_vesa[hdmi.code]; |
| 579 | } |
| 580 | return code; |
| 581 | } |
| 582 | |
| 583 | static struct hdmi_cm hdmi_get_code(struct omap_video_timings *timing) |
| 584 | { |
| 585 | int i = 0, code = -1, temp_vsync = 0, temp_hsync = 0; |
| 586 | int timing_vsync = 0, timing_hsync = 0; |
Mythri P K | 38863b7 | 2011-09-08 19:06:20 +0530 | [diff] [blame] | 587 | struct hdmi_video_timings temp; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 588 | struct hdmi_cm cm = {-1}; |
| 589 | DSSDBG("hdmi_get_code\n"); |
| 590 | |
| 591 | for (i = 0; i < OMAP_HDMI_TIMINGS_NB; i++) { |
| 592 | temp = cea_vesa_timings[i].timings; |
| 593 | if ((temp.pixel_clock == timing->pixel_clock) && |
| 594 | (temp.x_res == timing->x_res) && |
| 595 | (temp.y_res == timing->y_res)) { |
| 596 | |
| 597 | temp_hsync = temp.hfp + temp.hsw + temp.hbp; |
| 598 | timing_hsync = timing->hfp + timing->hsw + timing->hbp; |
| 599 | temp_vsync = temp.vfp + temp.vsw + temp.vbp; |
| 600 | timing_vsync = timing->vfp + timing->vsw + timing->vbp; |
| 601 | |
| 602 | DSSDBG("temp_hsync = %d , temp_vsync = %d" |
| 603 | "timing_hsync = %d, timing_vsync = %d\n", |
| 604 | temp_hsync, temp_hsync, |
| 605 | timing_hsync, timing_vsync); |
| 606 | |
| 607 | if ((temp_hsync == timing_hsync) && |
| 608 | (temp_vsync == timing_vsync)) { |
| 609 | code = i; |
| 610 | cm.code = code_index[i]; |
| 611 | if (code < 14) |
| 612 | cm.mode = HDMI_HDMI; |
| 613 | else |
| 614 | cm.mode = HDMI_DVI; |
| 615 | DSSDBG("Hdmi_code = %d mode = %d\n", |
| 616 | cm.code, cm.mode); |
| 617 | break; |
| 618 | } |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | return cm; |
| 623 | } |
| 624 | |
| 625 | static void get_horz_vert_timing_info(int current_descriptor_addrs, u8 *edid , |
| 626 | struct omap_video_timings *timings) |
| 627 | { |
| 628 | /* X and Y resolution */ |
| 629 | timings->x_res = (((edid[current_descriptor_addrs + 4] & 0xF0) << 4) | |
| 630 | edid[current_descriptor_addrs + 2]); |
| 631 | timings->y_res = (((edid[current_descriptor_addrs + 7] & 0xF0) << 4) | |
| 632 | edid[current_descriptor_addrs + 5]); |
| 633 | |
| 634 | timings->pixel_clock = ((edid[current_descriptor_addrs + 1] << 8) | |
| 635 | edid[current_descriptor_addrs]); |
| 636 | |
| 637 | timings->pixel_clock = 10 * timings->pixel_clock; |
| 638 | |
| 639 | /* HORIZONTAL FRONT PORCH */ |
| 640 | timings->hfp = edid[current_descriptor_addrs + 8] | |
| 641 | ((edid[current_descriptor_addrs + 11] & 0xc0) << 2); |
| 642 | /* HORIZONTAL SYNC WIDTH */ |
| 643 | timings->hsw = edid[current_descriptor_addrs + 9] | |
| 644 | ((edid[current_descriptor_addrs + 11] & 0x30) << 4); |
| 645 | /* HORIZONTAL BACK PORCH */ |
| 646 | timings->hbp = (((edid[current_descriptor_addrs + 4] & 0x0F) << 8) | |
| 647 | edid[current_descriptor_addrs + 3]) - |
| 648 | (timings->hfp + timings->hsw); |
| 649 | /* VERTICAL FRONT PORCH */ |
| 650 | timings->vfp = ((edid[current_descriptor_addrs + 10] & 0xF0) >> 4) | |
| 651 | ((edid[current_descriptor_addrs + 11] & 0x0f) << 2); |
| 652 | /* VERTICAL SYNC WIDTH */ |
| 653 | timings->vsw = (edid[current_descriptor_addrs + 10] & 0x0F) | |
| 654 | ((edid[current_descriptor_addrs + 11] & 0x03) << 4); |
| 655 | /* VERTICAL BACK PORCH */ |
| 656 | timings->vbp = (((edid[current_descriptor_addrs + 7] & 0x0F) << 8) | |
| 657 | edid[current_descriptor_addrs + 6]) - |
| 658 | (timings->vfp + timings->vsw); |
| 659 | |
| 660 | } |
| 661 | |
| 662 | /* Description : This function gets the resolution information from EDID */ |
| 663 | static void get_edid_timing_data(u8 *edid) |
| 664 | { |
| 665 | u8 count; |
| 666 | u16 current_descriptor_addrs; |
| 667 | struct hdmi_cm cm; |
| 668 | struct omap_video_timings edid_timings; |
| 669 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 670 | /* search block 0, there are 4 DTDs arranged in priority order */ |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 671 | for (count = 0; count < EDID_SIZE_BLOCK0_TIMING_DESCRIPTOR; count++) { |
| 672 | current_descriptor_addrs = |
| 673 | EDID_DESCRIPTOR_BLOCK0_ADDRESS + |
| 674 | count * EDID_TIMING_DESCRIPTOR_SIZE; |
| 675 | get_horz_vert_timing_info(current_descriptor_addrs, |
| 676 | edid, &edid_timings); |
| 677 | cm = hdmi_get_code(&edid_timings); |
| 678 | DSSDBG("Block0[%d] value matches code = %d , mode = %d\n", |
| 679 | count, cm.code, cm.mode); |
| 680 | if (cm.code == -1) { |
| 681 | continue; |
| 682 | } else { |
| 683 | hdmi.code = cm.code; |
| 684 | hdmi.mode = cm.mode; |
| 685 | DSSDBG("code = %d , mode = %d\n", |
| 686 | hdmi.code, hdmi.mode); |
| 687 | return; |
| 688 | } |
| 689 | } |
| 690 | if (edid[0x7e] != 0x00) { |
| 691 | for (count = 0; count < EDID_SIZE_BLOCK1_TIMING_DESCRIPTOR; |
| 692 | count++) { |
| 693 | current_descriptor_addrs = |
| 694 | EDID_DESCRIPTOR_BLOCK1_ADDRESS + |
| 695 | count * EDID_TIMING_DESCRIPTOR_SIZE; |
| 696 | get_horz_vert_timing_info(current_descriptor_addrs, |
| 697 | edid, &edid_timings); |
| 698 | cm = hdmi_get_code(&edid_timings); |
| 699 | DSSDBG("Block1[%d] value matches code = %d, mode = %d", |
| 700 | count, cm.code, cm.mode); |
| 701 | if (cm.code == -1) { |
| 702 | continue; |
| 703 | } else { |
| 704 | hdmi.code = cm.code; |
| 705 | hdmi.mode = cm.mode; |
| 706 | DSSDBG("code = %d , mode = %d\n", |
| 707 | hdmi.code, hdmi.mode); |
| 708 | return; |
| 709 | } |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | DSSINFO("no valid timing found , falling back to VGA\n"); |
| 714 | hdmi.code = 4; /* setting default value of 640 480 VGA */ |
| 715 | hdmi.mode = HDMI_DVI; |
| 716 | } |
| 717 | |
| 718 | static void hdmi_read_edid(struct omap_video_timings *dp) |
| 719 | { |
| 720 | int ret = 0, code; |
| 721 | |
| 722 | memset(hdmi.edid, 0, HDMI_EDID_MAX_LENGTH); |
| 723 | |
| 724 | if (!hdmi.edid_set) |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 725 | ret = read_edid(&hdmi.ip_data, hdmi.edid, |
| 726 | HDMI_EDID_MAX_LENGTH); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 727 | if (!ret) { |
| 728 | if (!memcmp(hdmi.edid, edid_header, sizeof(edid_header))) { |
| 729 | /* search for timings of default resolution */ |
| 730 | get_edid_timing_data(hdmi.edid); |
| 731 | hdmi.edid_set = true; |
| 732 | } |
| 733 | } else { |
| 734 | DSSWARN("failed to read E-EDID\n"); |
| 735 | } |
| 736 | |
| 737 | if (!hdmi.edid_set) { |
| 738 | DSSINFO("fallback to VGA\n"); |
| 739 | hdmi.code = 4; /* setting default value of 640 480 VGA */ |
| 740 | hdmi.mode = HDMI_DVI; |
| 741 | } |
| 742 | |
| 743 | code = get_timings_index(); |
| 744 | |
Mythri P K | 38863b7 | 2011-09-08 19:06:20 +0530 | [diff] [blame] | 745 | copy_hdmi_to_dss_timings(&cea_vesa_timings[code].timings, dp); |
| 746 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | static void hdmi_core_init(struct hdmi_core_video_config *video_cfg, |
| 750 | struct hdmi_core_infoframe_avi *avi_cfg, |
| 751 | struct hdmi_core_packet_enable_repeat *repeat_cfg) |
| 752 | { |
| 753 | DSSDBG("Enter hdmi_core_init\n"); |
| 754 | |
| 755 | /* video core */ |
| 756 | video_cfg->ip_bus_width = HDMI_INPUT_8BIT; |
| 757 | video_cfg->op_dither_truc = HDMI_OUTPUTTRUNCATION_8BIT; |
| 758 | video_cfg->deep_color_pkt = HDMI_DEEPCOLORPACKECTDISABLE; |
| 759 | video_cfg->pkt_mode = HDMI_PACKETMODERESERVEDVALUE; |
| 760 | video_cfg->hdmi_dvi = HDMI_DVI; |
| 761 | video_cfg->tclk_sel_clkmult = HDMI_FPLL10IDCK; |
| 762 | |
| 763 | /* info frame */ |
| 764 | avi_cfg->db1_format = 0; |
| 765 | avi_cfg->db1_active_info = 0; |
| 766 | avi_cfg->db1_bar_info_dv = 0; |
| 767 | avi_cfg->db1_scan_info = 0; |
| 768 | avi_cfg->db2_colorimetry = 0; |
| 769 | avi_cfg->db2_aspect_ratio = 0; |
| 770 | avi_cfg->db2_active_fmt_ar = 0; |
| 771 | avi_cfg->db3_itc = 0; |
| 772 | avi_cfg->db3_ec = 0; |
| 773 | avi_cfg->db3_q_range = 0; |
| 774 | avi_cfg->db3_nup_scaling = 0; |
| 775 | avi_cfg->db4_videocode = 0; |
| 776 | avi_cfg->db5_pixel_repeat = 0; |
| 777 | avi_cfg->db6_7_line_eoftop = 0 ; |
| 778 | avi_cfg->db8_9_line_sofbottom = 0; |
| 779 | avi_cfg->db10_11_pixel_eofleft = 0; |
| 780 | avi_cfg->db12_13_pixel_sofright = 0; |
| 781 | |
| 782 | /* packet enable and repeat */ |
| 783 | repeat_cfg->audio_pkt = 0; |
| 784 | repeat_cfg->audio_pkt_repeat = 0; |
| 785 | repeat_cfg->avi_infoframe = 0; |
| 786 | repeat_cfg->avi_infoframe_repeat = 0; |
| 787 | repeat_cfg->gen_cntrl_pkt = 0; |
| 788 | repeat_cfg->gen_cntrl_pkt_repeat = 0; |
| 789 | repeat_cfg->generic_pkt = 0; |
| 790 | repeat_cfg->generic_pkt_repeat = 0; |
| 791 | } |
| 792 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 793 | static void hdmi_core_powerdown_disable(struct hdmi_ip_data *ip_data) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 794 | { |
| 795 | DSSDBG("Enter hdmi_core_powerdown_disable\n"); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 796 | REG_FLD_MOD(hdmi_core_sys_base(ip_data), HDMI_CORE_CTRL1, 0x0, 0, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 797 | } |
| 798 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 799 | static void hdmi_core_swreset_release(struct hdmi_ip_data *ip_data) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 800 | { |
| 801 | DSSDBG("Enter hdmi_core_swreset_release\n"); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 802 | REG_FLD_MOD(hdmi_core_sys_base(ip_data), HDMI_CORE_SYS_SRST, 0x0, 0, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 803 | } |
| 804 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 805 | static void hdmi_core_swreset_assert(struct hdmi_ip_data *ip_data) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 806 | { |
| 807 | DSSDBG("Enter hdmi_core_swreset_assert\n"); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 808 | REG_FLD_MOD(hdmi_core_sys_base(ip_data), HDMI_CORE_SYS_SRST, 0x1, 0, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 809 | } |
| 810 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 811 | /* HDMI_CORE_VIDEO_CONFIG */ |
| 812 | static void hdmi_core_video_config(struct hdmi_ip_data *ip_data, |
| 813 | struct hdmi_core_video_config *cfg) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 814 | { |
| 815 | u32 r = 0; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 816 | void __iomem *core_sys_base = hdmi_core_sys_base(ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 817 | |
| 818 | /* sys_ctrl1 default configuration not tunable */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 819 | r = hdmi_read_reg(core_sys_base, HDMI_CORE_CTRL1); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 820 | r = FLD_MOD(r, HDMI_CORE_CTRL1_VEN_FOLLOWVSYNC, 5, 5); |
| 821 | r = FLD_MOD(r, HDMI_CORE_CTRL1_HEN_FOLLOWHSYNC, 4, 4); |
| 822 | r = FLD_MOD(r, HDMI_CORE_CTRL1_BSEL_24BITBUS, 2, 2); |
| 823 | r = FLD_MOD(r, HDMI_CORE_CTRL1_EDGE_RISINGEDGE, 1, 1); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 824 | hdmi_write_reg(core_sys_base, HDMI_CORE_CTRL1, r); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 825 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 826 | REG_FLD_MOD(core_sys_base, |
| 827 | HDMI_CORE_SYS_VID_ACEN, cfg->ip_bus_width, 7, 6); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 828 | |
| 829 | /* Vid_Mode */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 830 | r = hdmi_read_reg(core_sys_base, HDMI_CORE_SYS_VID_MODE); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 831 | |
| 832 | /* dither truncation configuration */ |
| 833 | if (cfg->op_dither_truc > HDMI_OUTPUTTRUNCATION_12BIT) { |
| 834 | r = FLD_MOD(r, cfg->op_dither_truc - 3, 7, 6); |
| 835 | r = FLD_MOD(r, 1, 5, 5); |
| 836 | } else { |
| 837 | r = FLD_MOD(r, cfg->op_dither_truc, 7, 6); |
| 838 | r = FLD_MOD(r, 0, 5, 5); |
| 839 | } |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 840 | hdmi_write_reg(core_sys_base, HDMI_CORE_SYS_VID_MODE, r); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 841 | |
| 842 | /* HDMI_Ctrl */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 843 | r = hdmi_read_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_HDMI_CTRL); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 844 | r = FLD_MOD(r, cfg->deep_color_pkt, 6, 6); |
| 845 | r = FLD_MOD(r, cfg->pkt_mode, 5, 3); |
| 846 | r = FLD_MOD(r, cfg->hdmi_dvi, 0, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 847 | hdmi_write_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_HDMI_CTRL, r); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 848 | |
| 849 | /* TMDS_CTRL */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 850 | REG_FLD_MOD(core_sys_base, |
| 851 | HDMI_CORE_SYS_TMDS_CTRL, cfg->tclk_sel_clkmult, 6, 5); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 852 | } |
| 853 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 854 | static void hdmi_core_aux_infoframe_avi_config(struct hdmi_ip_data *ip_data, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 855 | struct hdmi_core_infoframe_avi info_avi) |
| 856 | { |
| 857 | u32 val; |
| 858 | char sum = 0, checksum = 0; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 859 | void __iomem *av_base = hdmi_av_base(ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 860 | |
| 861 | sum += 0x82 + 0x002 + 0x00D; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 862 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_TYPE, 0x082); |
| 863 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_VERS, 0x002); |
| 864 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_LEN, 0x00D); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 865 | |
| 866 | val = (info_avi.db1_format << 5) | |
| 867 | (info_avi.db1_active_info << 4) | |
| 868 | (info_avi.db1_bar_info_dv << 2) | |
| 869 | (info_avi.db1_scan_info); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 870 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(0), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 871 | sum += val; |
| 872 | |
| 873 | val = (info_avi.db2_colorimetry << 6) | |
| 874 | (info_avi.db2_aspect_ratio << 4) | |
| 875 | (info_avi.db2_active_fmt_ar); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 876 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(1), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 877 | sum += val; |
| 878 | |
| 879 | val = (info_avi.db3_itc << 7) | |
| 880 | (info_avi.db3_ec << 4) | |
| 881 | (info_avi.db3_q_range << 2) | |
| 882 | (info_avi.db3_nup_scaling); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 883 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(2), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 884 | sum += val; |
| 885 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 886 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(3), |
| 887 | info_avi.db4_videocode); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 888 | sum += info_avi.db4_videocode; |
| 889 | |
| 890 | val = info_avi.db5_pixel_repeat; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 891 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(4), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 892 | sum += val; |
| 893 | |
| 894 | val = info_avi.db6_7_line_eoftop & 0x00FF; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 895 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(5), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 896 | sum += val; |
| 897 | |
| 898 | val = ((info_avi.db6_7_line_eoftop >> 8) & 0x00FF); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 899 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(6), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 900 | sum += val; |
| 901 | |
| 902 | val = info_avi.db8_9_line_sofbottom & 0x00FF; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 903 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(7), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 904 | sum += val; |
| 905 | |
| 906 | val = ((info_avi.db8_9_line_sofbottom >> 8) & 0x00FF); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 907 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(8), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 908 | sum += val; |
| 909 | |
| 910 | val = info_avi.db10_11_pixel_eofleft & 0x00FF; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 911 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(9), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 912 | sum += val; |
| 913 | |
| 914 | val = ((info_avi.db10_11_pixel_eofleft >> 8) & 0x00FF); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 915 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(10), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 916 | sum += val; |
| 917 | |
| 918 | val = info_avi.db12_13_pixel_sofright & 0x00FF; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 919 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(11), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 920 | sum += val; |
| 921 | |
| 922 | val = ((info_avi.db12_13_pixel_sofright >> 8) & 0x00FF); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 923 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(12), val); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 924 | sum += val; |
| 925 | |
| 926 | checksum = 0x100 - sum; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 927 | hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_CHSUM, checksum); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 928 | } |
| 929 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 930 | static void hdmi_core_av_packet_config(struct hdmi_ip_data *ip_data, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 931 | struct hdmi_core_packet_enable_repeat repeat_cfg) |
| 932 | { |
| 933 | /* enable/repeat the infoframe */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 934 | hdmi_write_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_PB_CTRL1, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 935 | (repeat_cfg.audio_pkt << 5) | |
| 936 | (repeat_cfg.audio_pkt_repeat << 4) | |
| 937 | (repeat_cfg.avi_infoframe << 1) | |
| 938 | (repeat_cfg.avi_infoframe_repeat)); |
| 939 | |
| 940 | /* enable/repeat the packet */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 941 | hdmi_write_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_PB_CTRL2, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 942 | (repeat_cfg.gen_cntrl_pkt << 3) | |
| 943 | (repeat_cfg.gen_cntrl_pkt_repeat << 2) | |
| 944 | (repeat_cfg.generic_pkt << 1) | |
| 945 | (repeat_cfg.generic_pkt_repeat)); |
| 946 | } |
| 947 | |
| 948 | static void hdmi_wp_init(struct omap_video_timings *timings, |
| 949 | struct hdmi_video_format *video_fmt, |
| 950 | struct hdmi_video_interface *video_int) |
| 951 | { |
| 952 | DSSDBG("Enter hdmi_wp_init\n"); |
| 953 | |
| 954 | timings->hbp = 0; |
| 955 | timings->hfp = 0; |
| 956 | timings->hsw = 0; |
| 957 | timings->vbp = 0; |
| 958 | timings->vfp = 0; |
| 959 | timings->vsw = 0; |
| 960 | |
| 961 | video_fmt->packing_mode = HDMI_PACK_10b_RGB_YUV444; |
| 962 | video_fmt->y_res = 0; |
| 963 | video_fmt->x_res = 0; |
| 964 | |
| 965 | video_int->vsp = 0; |
| 966 | video_int->hsp = 0; |
| 967 | |
| 968 | video_int->interlacing = 0; |
| 969 | video_int->tm = 0; /* HDMI_TIMING_SLAVE */ |
| 970 | |
| 971 | } |
| 972 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 973 | static void hdmi_wp_video_start(struct hdmi_ip_data *ip_data, bool start) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 974 | { |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 975 | REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, start, 31, 31); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 976 | } |
| 977 | |
| 978 | static void hdmi_wp_video_init_format(struct hdmi_video_format *video_fmt, |
| 979 | struct omap_video_timings *timings, struct hdmi_config *param) |
| 980 | { |
| 981 | DSSDBG("Enter hdmi_wp_video_init_format\n"); |
| 982 | |
| 983 | video_fmt->y_res = param->timings.timings.y_res; |
| 984 | video_fmt->x_res = param->timings.timings.x_res; |
| 985 | |
| 986 | timings->hbp = param->timings.timings.hbp; |
| 987 | timings->hfp = param->timings.timings.hfp; |
| 988 | timings->hsw = param->timings.timings.hsw; |
| 989 | timings->vbp = param->timings.timings.vbp; |
| 990 | timings->vfp = param->timings.timings.vfp; |
| 991 | timings->vsw = param->timings.timings.vsw; |
| 992 | } |
| 993 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 994 | static void hdmi_wp_video_config_format(struct hdmi_ip_data *ip_data, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 995 | struct hdmi_video_format *video_fmt) |
| 996 | { |
| 997 | u32 l = 0; |
| 998 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 999 | REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, |
| 1000 | video_fmt->packing_mode, 10, 8); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1001 | |
| 1002 | l |= FLD_VAL(video_fmt->y_res, 31, 16); |
| 1003 | l |= FLD_VAL(video_fmt->x_res, 15, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1004 | hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_SIZE, l); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1005 | } |
| 1006 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1007 | static void hdmi_wp_video_config_interface(struct hdmi_ip_data *ip_data, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1008 | struct hdmi_video_interface *video_int) |
| 1009 | { |
| 1010 | u32 r; |
| 1011 | DSSDBG("Enter hdmi_wp_video_config_interface\n"); |
| 1012 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1013 | r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1014 | r = FLD_MOD(r, video_int->vsp, 7, 7); |
| 1015 | r = FLD_MOD(r, video_int->hsp, 6, 6); |
| 1016 | r = FLD_MOD(r, video_int->interlacing, 3, 3); |
| 1017 | r = FLD_MOD(r, video_int->tm, 1, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1018 | hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, r); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1019 | } |
| 1020 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1021 | static void hdmi_wp_video_config_timing(struct hdmi_ip_data *ip_data, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1022 | struct omap_video_timings *timings) |
| 1023 | { |
| 1024 | u32 timing_h = 0; |
| 1025 | u32 timing_v = 0; |
| 1026 | |
| 1027 | DSSDBG("Enter hdmi_wp_video_config_timing\n"); |
| 1028 | |
| 1029 | timing_h |= FLD_VAL(timings->hbp, 31, 20); |
| 1030 | timing_h |= FLD_VAL(timings->hfp, 19, 8); |
| 1031 | timing_h |= FLD_VAL(timings->hsw, 7, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1032 | hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_TIMING_H, timing_h); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1033 | |
| 1034 | timing_v |= FLD_VAL(timings->vbp, 31, 20); |
| 1035 | timing_v |= FLD_VAL(timings->vfp, 19, 8); |
| 1036 | timing_v |= FLD_VAL(timings->vsw, 7, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1037 | hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_TIMING_V, timing_v); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1038 | } |
| 1039 | |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 1040 | static void hdmi_basic_configure(struct hdmi_ip_data *ip_data) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1041 | { |
| 1042 | /* HDMI */ |
| 1043 | struct omap_video_timings video_timing; |
| 1044 | struct hdmi_video_format video_format; |
| 1045 | struct hdmi_video_interface video_interface; |
| 1046 | /* HDMI core */ |
| 1047 | struct hdmi_core_infoframe_avi avi_cfg; |
| 1048 | struct hdmi_core_video_config v_core_cfg; |
| 1049 | struct hdmi_core_packet_enable_repeat repeat_cfg; |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 1050 | struct hdmi_config *cfg = &ip_data->cfg; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1051 | |
| 1052 | hdmi_wp_init(&video_timing, &video_format, |
| 1053 | &video_interface); |
| 1054 | |
| 1055 | hdmi_core_init(&v_core_cfg, |
| 1056 | &avi_cfg, |
| 1057 | &repeat_cfg); |
| 1058 | |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 1059 | hdmi_wp_video_init_format(&video_format, &video_timing, cfg); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1060 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1061 | hdmi_wp_video_config_timing(ip_data, &video_timing); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1062 | |
| 1063 | /* video config */ |
| 1064 | video_format.packing_mode = HDMI_PACK_24b_RGB_YUV444_YUV422; |
| 1065 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1066 | hdmi_wp_video_config_format(ip_data, &video_format); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1067 | |
| 1068 | video_interface.vsp = cfg->timings.vsync_pol; |
| 1069 | video_interface.hsp = cfg->timings.hsync_pol; |
| 1070 | video_interface.interlacing = cfg->interlace; |
| 1071 | video_interface.tm = 1 ; /* HDMI_TIMING_MASTER_24BIT */ |
| 1072 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1073 | hdmi_wp_video_config_interface(ip_data, &video_interface); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1074 | |
| 1075 | /* |
| 1076 | * configure core video part |
| 1077 | * set software reset in the core |
| 1078 | */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1079 | hdmi_core_swreset_assert(ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1080 | |
| 1081 | /* power down off */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1082 | hdmi_core_powerdown_disable(ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1083 | |
| 1084 | v_core_cfg.pkt_mode = HDMI_PACKETMODE24BITPERPIXEL; |
| 1085 | v_core_cfg.hdmi_dvi = cfg->cm.mode; |
| 1086 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1087 | hdmi_core_video_config(ip_data, &v_core_cfg); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1088 | |
| 1089 | /* release software reset in the core */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1090 | hdmi_core_swreset_release(ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1091 | |
| 1092 | /* |
| 1093 | * configure packet |
| 1094 | * info frame video see doc CEA861-D page 65 |
| 1095 | */ |
| 1096 | avi_cfg.db1_format = HDMI_INFOFRAME_AVI_DB1Y_RGB; |
| 1097 | avi_cfg.db1_active_info = |
| 1098 | HDMI_INFOFRAME_AVI_DB1A_ACTIVE_FORMAT_OFF; |
| 1099 | avi_cfg.db1_bar_info_dv = HDMI_INFOFRAME_AVI_DB1B_NO; |
| 1100 | avi_cfg.db1_scan_info = HDMI_INFOFRAME_AVI_DB1S_0; |
| 1101 | avi_cfg.db2_colorimetry = HDMI_INFOFRAME_AVI_DB2C_NO; |
| 1102 | avi_cfg.db2_aspect_ratio = HDMI_INFOFRAME_AVI_DB2M_NO; |
| 1103 | avi_cfg.db2_active_fmt_ar = HDMI_INFOFRAME_AVI_DB2R_SAME; |
| 1104 | avi_cfg.db3_itc = HDMI_INFOFRAME_AVI_DB3ITC_NO; |
| 1105 | avi_cfg.db3_ec = HDMI_INFOFRAME_AVI_DB3EC_XVYUV601; |
| 1106 | avi_cfg.db3_q_range = HDMI_INFOFRAME_AVI_DB3Q_DEFAULT; |
| 1107 | avi_cfg.db3_nup_scaling = HDMI_INFOFRAME_AVI_DB3SC_NO; |
| 1108 | avi_cfg.db4_videocode = cfg->cm.code; |
| 1109 | avi_cfg.db5_pixel_repeat = HDMI_INFOFRAME_AVI_DB5PR_NO; |
| 1110 | avi_cfg.db6_7_line_eoftop = 0; |
| 1111 | avi_cfg.db8_9_line_sofbottom = 0; |
| 1112 | avi_cfg.db10_11_pixel_eofleft = 0; |
| 1113 | avi_cfg.db12_13_pixel_sofright = 0; |
| 1114 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1115 | hdmi_core_aux_infoframe_avi_config(ip_data, avi_cfg); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1116 | |
| 1117 | /* enable/repeat the infoframe */ |
| 1118 | repeat_cfg.avi_infoframe = HDMI_PACKETENABLE; |
| 1119 | repeat_cfg.avi_infoframe_repeat = HDMI_PACKETREPEATON; |
| 1120 | /* wakeup */ |
| 1121 | repeat_cfg.audio_pkt = HDMI_PACKETENABLE; |
| 1122 | repeat_cfg.audio_pkt_repeat = HDMI_PACKETREPEATON; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1123 | hdmi_core_av_packet_config(ip_data, repeat_cfg); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | static void update_hdmi_timings(struct hdmi_config *cfg, |
| 1127 | struct omap_video_timings *timings, int code) |
| 1128 | { |
| 1129 | cfg->timings.timings.x_res = timings->x_res; |
| 1130 | cfg->timings.timings.y_res = timings->y_res; |
| 1131 | cfg->timings.timings.hbp = timings->hbp; |
| 1132 | cfg->timings.timings.hfp = timings->hfp; |
| 1133 | cfg->timings.timings.hsw = timings->hsw; |
| 1134 | cfg->timings.timings.vbp = timings->vbp; |
| 1135 | cfg->timings.timings.vfp = timings->vfp; |
| 1136 | cfg->timings.timings.vsw = timings->vsw; |
| 1137 | cfg->timings.timings.pixel_clock = timings->pixel_clock; |
| 1138 | cfg->timings.vsync_pol = cea_vesa_timings[code].vsync_pol; |
| 1139 | cfg->timings.hsync_pol = cea_vesa_timings[code].hsync_pol; |
| 1140 | } |
| 1141 | |
Archit Taneja | 6cb07b2 | 2011-04-12 13:52:25 +0530 | [diff] [blame] | 1142 | static void hdmi_compute_pll(struct omap_dss_device *dssdev, int phy, |
| 1143 | struct hdmi_pll_info *pi) |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1144 | { |
Archit Taneja | 6cb07b2 | 2011-04-12 13:52:25 +0530 | [diff] [blame] | 1145 | unsigned long clkin, refclk; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1146 | u32 mf; |
| 1147 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1148 | clkin = clk_get_rate(hdmi.sys_clk) / 10000; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1149 | /* |
| 1150 | * Input clock is predivided by N + 1 |
| 1151 | * out put of which is reference clk |
| 1152 | */ |
Archit Taneja | 6cb07b2 | 2011-04-12 13:52:25 +0530 | [diff] [blame] | 1153 | pi->regn = dssdev->clocks.hdmi.regn; |
| 1154 | refclk = clkin / (pi->regn + 1); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1155 | |
| 1156 | /* |
| 1157 | * multiplier is pixel_clk/ref_clk |
| 1158 | * Multiplying by 100 to avoid fractional part removal |
| 1159 | */ |
Archit Taneja | 6cb07b2 | 2011-04-12 13:52:25 +0530 | [diff] [blame] | 1160 | pi->regm = (phy * 100 / (refclk)) / 100; |
| 1161 | pi->regm2 = dssdev->clocks.hdmi.regm2; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1162 | |
| 1163 | /* |
| 1164 | * fractional multiplier is remainder of the difference between |
| 1165 | * multiplier and actual phy(required pixel clock thus should be |
| 1166 | * multiplied by 2^18(262144) divided by the reference clock |
| 1167 | */ |
| 1168 | mf = (phy - pi->regm * refclk) * 262144; |
Archit Taneja | 6cb07b2 | 2011-04-12 13:52:25 +0530 | [diff] [blame] | 1169 | pi->regmf = mf / (refclk); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1170 | |
| 1171 | /* |
| 1172 | * Dcofreq should be set to 1 if required pixel clock |
| 1173 | * is greater than 1000MHz |
| 1174 | */ |
| 1175 | pi->dcofreq = phy > 1000 * 100; |
Archit Taneja | 6cb07b2 | 2011-04-12 13:52:25 +0530 | [diff] [blame] | 1176 | pi->regsd = ((pi->regm * clkin / 10) / ((pi->regn + 1) * 250) + 5) / 10; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1177 | |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 1178 | /* Set the reference clock to sysclk reference */ |
| 1179 | pi->refsel = HDMI_REFSEL_SYSCLK; |
| 1180 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1181 | DSSDBG("M = %d Mf = %d\n", pi->regm, pi->regmf); |
| 1182 | DSSDBG("range = %d sd = %d\n", pi->dcofreq, pi->regsd); |
| 1183 | } |
| 1184 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1185 | static int hdmi_power_on(struct omap_dss_device *dssdev) |
| 1186 | { |
| 1187 | int r, code = 0; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1188 | struct omap_video_timings *p; |
Archit Taneja | 6cb07b2 | 2011-04-12 13:52:25 +0530 | [diff] [blame] | 1189 | unsigned long phy; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1190 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1191 | r = hdmi_runtime_get(); |
| 1192 | if (r) |
| 1193 | return r; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1194 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 1195 | dispc_mgr_enable(OMAP_DSS_CHANNEL_DIGIT, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1196 | |
| 1197 | p = &dssdev->panel.timings; |
| 1198 | |
| 1199 | DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", |
| 1200 | dssdev->panel.timings.x_res, |
| 1201 | dssdev->panel.timings.y_res); |
| 1202 | |
| 1203 | if (!hdmi.custom_set) { |
| 1204 | DSSDBG("Read EDID as no EDID is not set on poweron\n"); |
| 1205 | hdmi_read_edid(p); |
| 1206 | } |
| 1207 | code = get_timings_index(); |
Mythri P K | 38863b7 | 2011-09-08 19:06:20 +0530 | [diff] [blame] | 1208 | copy_hdmi_to_dss_timings(&cea_vesa_timings[code].timings, |
| 1209 | &dssdev->panel.timings); |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 1210 | update_hdmi_timings(&hdmi.ip_data.cfg, p, code); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1211 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1212 | phy = p->pixel_clock; |
| 1213 | |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 1214 | hdmi_compute_pll(dssdev, phy, &hdmi.ip_data.pll_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1215 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1216 | hdmi_wp_video_start(&hdmi.ip_data, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1217 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1218 | /* config the PLL and PHY hdmi_set_pll_pwrfirst */ |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 1219 | r = hdmi_pll_program(&hdmi.ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1220 | if (r) { |
| 1221 | DSSDBG("Failed to lock PLL\n"); |
| 1222 | goto err; |
| 1223 | } |
| 1224 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1225 | r = hdmi_phy_init(&hdmi.ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1226 | if (r) { |
| 1227 | DSSDBG("Failed to start PHY\n"); |
| 1228 | goto err; |
| 1229 | } |
| 1230 | |
Mythri P K | 7b27da5 | 2011-09-08 19:06:19 +0530 | [diff] [blame] | 1231 | hdmi.ip_data.cfg.cm.mode = hdmi.mode; |
| 1232 | hdmi.ip_data.cfg.cm.code = hdmi.code; |
| 1233 | hdmi_basic_configure(&hdmi.ip_data); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1234 | |
| 1235 | /* Make selection of HDMI in DSS */ |
| 1236 | dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK); |
| 1237 | |
| 1238 | /* Select the dispc clock source as PRCM clock, to ensure that it is not |
| 1239 | * DSI PLL source as the clock selected by DSI PLL might not be |
| 1240 | * sufficient for the resolution selected / that can be changed |
| 1241 | * dynamically by user. This can be moved to single location , say |
| 1242 | * Boardfile. |
| 1243 | */ |
Archit Taneja | 6cb07b2 | 2011-04-12 13:52:25 +0530 | [diff] [blame] | 1244 | dss_select_dispc_clk_source(dssdev->clocks.dispc.dispc_fclk_src); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1245 | |
| 1246 | /* bypass TV gamma table */ |
| 1247 | dispc_enable_gamma_table(0); |
| 1248 | |
| 1249 | /* tv size */ |
| 1250 | dispc_set_digit_size(dssdev->panel.timings.x_res, |
| 1251 | dssdev->panel.timings.y_res); |
| 1252 | |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 1253 | dispc_mgr_enable(OMAP_DSS_CHANNEL_DIGIT, 1); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1254 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1255 | hdmi_wp_video_start(&hdmi.ip_data, 1); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1256 | |
| 1257 | return 0; |
| 1258 | err: |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1259 | hdmi_runtime_put(); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1260 | return -EIO; |
| 1261 | } |
| 1262 | |
| 1263 | static void hdmi_power_off(struct omap_dss_device *dssdev) |
| 1264 | { |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 1265 | dispc_mgr_enable(OMAP_DSS_CHANNEL_DIGIT, 0); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1266 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1267 | hdmi_wp_video_start(&hdmi.ip_data, 0); |
| 1268 | hdmi_phy_off(&hdmi.ip_data); |
| 1269 | hdmi_set_pll_pwr(&hdmi.ip_data, HDMI_PLLPWRCMD_ALLOFF); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1270 | hdmi_runtime_put(); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1271 | |
| 1272 | hdmi.edid_set = 0; |
| 1273 | } |
| 1274 | |
| 1275 | int omapdss_hdmi_display_check_timing(struct omap_dss_device *dssdev, |
| 1276 | struct omap_video_timings *timings) |
| 1277 | { |
| 1278 | struct hdmi_cm cm; |
| 1279 | |
| 1280 | cm = hdmi_get_code(timings); |
| 1281 | if (cm.code == -1) { |
| 1282 | DSSERR("Invalid timing entered\n"); |
| 1283 | return -EINVAL; |
| 1284 | } |
| 1285 | |
| 1286 | return 0; |
| 1287 | |
| 1288 | } |
| 1289 | |
| 1290 | void omapdss_hdmi_display_set_timing(struct omap_dss_device *dssdev) |
| 1291 | { |
| 1292 | struct hdmi_cm cm; |
| 1293 | |
| 1294 | hdmi.custom_set = 1; |
| 1295 | cm = hdmi_get_code(&dssdev->panel.timings); |
| 1296 | hdmi.code = cm.code; |
| 1297 | hdmi.mode = cm.mode; |
| 1298 | omapdss_hdmi_display_enable(dssdev); |
| 1299 | hdmi.custom_set = 0; |
| 1300 | } |
| 1301 | |
| 1302 | int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev) |
| 1303 | { |
| 1304 | int r = 0; |
| 1305 | |
| 1306 | DSSDBG("ENTER hdmi_display_enable\n"); |
| 1307 | |
| 1308 | mutex_lock(&hdmi.lock); |
| 1309 | |
Tomi Valkeinen | 05e1d60 | 2011-06-23 16:38:21 +0300 | [diff] [blame] | 1310 | if (dssdev->manager == NULL) { |
| 1311 | DSSERR("failed to enable display: no manager\n"); |
| 1312 | r = -ENODEV; |
| 1313 | goto err0; |
| 1314 | } |
| 1315 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1316 | r = omap_dss_start_device(dssdev); |
| 1317 | if (r) { |
| 1318 | DSSERR("failed to start device\n"); |
| 1319 | goto err0; |
| 1320 | } |
| 1321 | |
| 1322 | if (dssdev->platform_enable) { |
| 1323 | r = dssdev->platform_enable(dssdev); |
| 1324 | if (r) { |
| 1325 | DSSERR("failed to enable GPIO's\n"); |
| 1326 | goto err1; |
| 1327 | } |
| 1328 | } |
| 1329 | |
| 1330 | r = hdmi_power_on(dssdev); |
| 1331 | if (r) { |
| 1332 | DSSERR("failed to power on device\n"); |
| 1333 | goto err2; |
| 1334 | } |
| 1335 | |
| 1336 | mutex_unlock(&hdmi.lock); |
| 1337 | return 0; |
| 1338 | |
| 1339 | err2: |
| 1340 | if (dssdev->platform_disable) |
| 1341 | dssdev->platform_disable(dssdev); |
| 1342 | err1: |
| 1343 | omap_dss_stop_device(dssdev); |
| 1344 | err0: |
| 1345 | mutex_unlock(&hdmi.lock); |
| 1346 | return r; |
| 1347 | } |
| 1348 | |
| 1349 | void omapdss_hdmi_display_disable(struct omap_dss_device *dssdev) |
| 1350 | { |
| 1351 | DSSDBG("Enter hdmi_display_disable\n"); |
| 1352 | |
| 1353 | mutex_lock(&hdmi.lock); |
| 1354 | |
| 1355 | hdmi_power_off(dssdev); |
| 1356 | |
| 1357 | if (dssdev->platform_disable) |
| 1358 | dssdev->platform_disable(dssdev); |
| 1359 | |
| 1360 | omap_dss_stop_device(dssdev); |
| 1361 | |
| 1362 | mutex_unlock(&hdmi.lock); |
| 1363 | } |
| 1364 | |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1365 | #if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \ |
| 1366 | defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE) |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1367 | static void hdmi_wp_audio_config_format(struct hdmi_ip_data *ip_data, |
| 1368 | struct hdmi_audio_format *aud_fmt) |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1369 | { |
| 1370 | u32 r; |
| 1371 | |
| 1372 | DSSDBG("Enter hdmi_wp_audio_config_format\n"); |
| 1373 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1374 | r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1375 | r = FLD_MOD(r, aud_fmt->stereo_channels, 26, 24); |
| 1376 | r = FLD_MOD(r, aud_fmt->active_chnnls_msk, 23, 16); |
| 1377 | r = FLD_MOD(r, aud_fmt->en_sig_blk_strt_end, 5, 5); |
| 1378 | r = FLD_MOD(r, aud_fmt->type, 4, 4); |
| 1379 | r = FLD_MOD(r, aud_fmt->justification, 3, 3); |
| 1380 | r = FLD_MOD(r, aud_fmt->sample_order, 2, 2); |
| 1381 | r = FLD_MOD(r, aud_fmt->samples_per_word, 1, 1); |
| 1382 | r = FLD_MOD(r, aud_fmt->sample_size, 0, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1383 | hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG, r); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1384 | } |
| 1385 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1386 | static void hdmi_wp_audio_config_dma(struct hdmi_ip_data *ip_data, |
| 1387 | struct hdmi_audio_dma *aud_dma) |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1388 | { |
| 1389 | u32 r; |
| 1390 | |
| 1391 | DSSDBG("Enter hdmi_wp_audio_config_dma\n"); |
| 1392 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1393 | r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG2); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1394 | r = FLD_MOD(r, aud_dma->transfer_size, 15, 8); |
| 1395 | r = FLD_MOD(r, aud_dma->block_size, 7, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1396 | hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG2, r); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1397 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1398 | r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CTRL); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1399 | r = FLD_MOD(r, aud_dma->mode, 9, 9); |
| 1400 | r = FLD_MOD(r, aud_dma->fifo_threshold, 8, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1401 | hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CTRL, r); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1402 | } |
| 1403 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1404 | static void hdmi_core_audio_config(struct hdmi_ip_data *ip_data, |
| 1405 | struct hdmi_core_audio_config *cfg) |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1406 | { |
| 1407 | u32 r; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1408 | void __iomem *av_base = hdmi_av_base(ip_data); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1409 | |
| 1410 | /* audio clock recovery parameters */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1411 | r = hdmi_read_reg(av_base, HDMI_CORE_AV_ACR_CTRL); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1412 | r = FLD_MOD(r, cfg->use_mclk, 2, 2); |
| 1413 | r = FLD_MOD(r, cfg->en_acr_pkt, 1, 1); |
| 1414 | r = FLD_MOD(r, cfg->cts_mode, 0, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1415 | hdmi_write_reg(av_base, HDMI_CORE_AV_ACR_CTRL, r); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1416 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1417 | REG_FLD_MOD(av_base, HDMI_CORE_AV_N_SVAL1, cfg->n, 7, 0); |
| 1418 | REG_FLD_MOD(av_base, HDMI_CORE_AV_N_SVAL2, cfg->n >> 8, 7, 0); |
| 1419 | REG_FLD_MOD(av_base, HDMI_CORE_AV_N_SVAL3, cfg->n >> 16, 7, 0); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1420 | |
| 1421 | if (cfg->cts_mode == HDMI_AUDIO_CTS_MODE_SW) { |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1422 | REG_FLD_MOD(av_base, HDMI_CORE_AV_CTS_SVAL1, cfg->cts, 7, 0); |
| 1423 | REG_FLD_MOD(av_base, |
| 1424 | HDMI_CORE_AV_CTS_SVAL2, cfg->cts >> 8, 7, 0); |
| 1425 | REG_FLD_MOD(av_base, |
| 1426 | HDMI_CORE_AV_CTS_SVAL3, cfg->cts >> 16, 7, 0); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1427 | } else { |
| 1428 | /* |
| 1429 | * HDMI IP uses this configuration to divide the MCLK to |
| 1430 | * update CTS value. |
| 1431 | */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1432 | REG_FLD_MOD(av_base, |
| 1433 | HDMI_CORE_AV_FREQ_SVAL, cfg->mclk_mode, 2, 0); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1434 | |
| 1435 | /* Configure clock for audio packets */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1436 | REG_FLD_MOD(av_base, HDMI_CORE_AV_AUD_PAR_BUSCLK_1, |
| 1437 | cfg->aud_par_busclk, 7, 0); |
| 1438 | REG_FLD_MOD(av_base, HDMI_CORE_AV_AUD_PAR_BUSCLK_2, |
| 1439 | (cfg->aud_par_busclk >> 8), 7, 0); |
| 1440 | REG_FLD_MOD(av_base, HDMI_CORE_AV_AUD_PAR_BUSCLK_3, |
| 1441 | (cfg->aud_par_busclk >> 16), 7, 0); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1442 | } |
| 1443 | |
| 1444 | /* Override of SPDIF sample frequency with value in I2S_CHST4 */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1445 | REG_FLD_MOD(av_base, HDMI_CORE_AV_SPDIF_CTRL, |
| 1446 | cfg->fs_override, 1, 1); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1447 | |
| 1448 | /* I2S parameters */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1449 | REG_FLD_MOD(av_base, HDMI_CORE_AV_I2S_CHST4, |
| 1450 | cfg->freq_sample, 3, 0); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1451 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1452 | r = hdmi_read_reg(av_base, HDMI_CORE_AV_I2S_IN_CTRL); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1453 | r = FLD_MOD(r, cfg->i2s_cfg.en_high_bitrate_aud, 7, 7); |
| 1454 | r = FLD_MOD(r, cfg->i2s_cfg.sck_edge_mode, 6, 6); |
| 1455 | r = FLD_MOD(r, cfg->i2s_cfg.cbit_order, 5, 5); |
| 1456 | r = FLD_MOD(r, cfg->i2s_cfg.vbit, 4, 4); |
| 1457 | r = FLD_MOD(r, cfg->i2s_cfg.ws_polarity, 3, 3); |
| 1458 | r = FLD_MOD(r, cfg->i2s_cfg.justification, 2, 2); |
| 1459 | r = FLD_MOD(r, cfg->i2s_cfg.direction, 1, 1); |
| 1460 | r = FLD_MOD(r, cfg->i2s_cfg.shift, 0, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1461 | hdmi_write_reg(av_base, HDMI_CORE_AV_I2S_IN_CTRL, r); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1462 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1463 | r = hdmi_read_reg(av_base, HDMI_CORE_AV_I2S_CHST5); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1464 | r = FLD_MOD(r, cfg->freq_sample, 7, 4); |
| 1465 | r = FLD_MOD(r, cfg->i2s_cfg.word_length, 3, 1); |
| 1466 | r = FLD_MOD(r, cfg->i2s_cfg.word_max_length, 0, 0); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1467 | hdmi_write_reg(av_base, HDMI_CORE_AV_I2S_CHST5, r); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1468 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1469 | REG_FLD_MOD(av_base, HDMI_CORE_AV_I2S_IN_LEN, |
| 1470 | cfg->i2s_cfg.in_length_bits, 3, 0); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1471 | |
| 1472 | /* Audio channels and mode parameters */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1473 | REG_FLD_MOD(av_base, HDMI_CORE_AV_HDMI_CTRL, cfg->layout, 2, 1); |
| 1474 | r = hdmi_read_reg(av_base, HDMI_CORE_AV_AUD_MODE); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1475 | r = FLD_MOD(r, cfg->i2s_cfg.active_sds, 7, 4); |
| 1476 | r = FLD_MOD(r, cfg->en_dsd_audio, 3, 3); |
| 1477 | r = FLD_MOD(r, cfg->en_parallel_aud_input, 2, 2); |
| 1478 | r = FLD_MOD(r, cfg->en_spdif, 1, 1); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1479 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_MODE, r); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1480 | } |
| 1481 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1482 | static void hdmi_core_audio_infoframe_config(struct hdmi_ip_data *ip_data, |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1483 | struct hdmi_core_infoframe_audio *info_aud) |
| 1484 | { |
| 1485 | u8 val; |
| 1486 | u8 sum = 0, checksum = 0; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1487 | void __iomem *av_base = hdmi_av_base(ip_data); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1488 | |
| 1489 | /* |
| 1490 | * Set audio info frame type, version and length as |
| 1491 | * described in HDMI 1.4a Section 8.2.2 specification. |
| 1492 | * Checksum calculation is defined in Section 5.3.5. |
| 1493 | */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1494 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUDIO_TYPE, 0x84); |
| 1495 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUDIO_VERS, 0x01); |
| 1496 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUDIO_LEN, 0x0a); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1497 | sum += 0x84 + 0x001 + 0x00a; |
| 1498 | |
| 1499 | val = (info_aud->db1_coding_type << 4) |
| 1500 | | (info_aud->db1_channel_count - 1); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1501 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(0), val); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1502 | sum += val; |
| 1503 | |
| 1504 | val = (info_aud->db2_sample_freq << 2) | info_aud->db2_sample_size; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1505 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(1), val); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1506 | sum += val; |
| 1507 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1508 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(2), 0x00); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1509 | |
| 1510 | val = info_aud->db4_channel_alloc; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1511 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(3), val); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1512 | sum += val; |
| 1513 | |
| 1514 | val = (info_aud->db5_downmix_inh << 7) | (info_aud->db5_lsv << 3); |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1515 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(4), val); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1516 | sum += val; |
| 1517 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1518 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(5), 0x00); |
| 1519 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(6), 0x00); |
| 1520 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(7), 0x00); |
| 1521 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(8), 0x00); |
| 1522 | hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(9), 0x00); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1523 | |
| 1524 | checksum = 0x100 - sum; |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1525 | hdmi_write_reg(av_base, |
| 1526 | HDMI_CORE_AV_AUDIO_CHSUM, checksum); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1527 | |
| 1528 | /* |
| 1529 | * TODO: Add MPEG and SPD enable and repeat cfg when EDID parsing |
| 1530 | * is available. |
| 1531 | */ |
| 1532 | } |
| 1533 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1534 | static int hdmi_config_audio_acr(struct hdmi_ip_data *ip_data, |
| 1535 | u32 sample_freq, u32 *n, u32 *cts) |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1536 | { |
| 1537 | u32 r; |
| 1538 | u32 deep_color = 0; |
| 1539 | u32 pclk = hdmi.cfg.timings.timings.pixel_clock; |
| 1540 | |
| 1541 | if (n == NULL || cts == NULL) |
| 1542 | return -EINVAL; |
| 1543 | /* |
| 1544 | * Obtain current deep color configuration. This needed |
| 1545 | * to calculate the TMDS clock based on the pixel clock. |
| 1546 | */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1547 | r = REG_GET(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, 1, 0); |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1548 | switch (r) { |
| 1549 | case 1: /* No deep color selected */ |
| 1550 | deep_color = 100; |
| 1551 | break; |
| 1552 | case 2: /* 10-bit deep color selected */ |
| 1553 | deep_color = 125; |
| 1554 | break; |
| 1555 | case 3: /* 12-bit deep color selected */ |
| 1556 | deep_color = 150; |
| 1557 | break; |
| 1558 | default: |
| 1559 | return -EINVAL; |
| 1560 | } |
| 1561 | |
| 1562 | switch (sample_freq) { |
| 1563 | case 32000: |
| 1564 | if ((deep_color == 125) && ((pclk == 54054) |
| 1565 | || (pclk == 74250))) |
| 1566 | *n = 8192; |
| 1567 | else |
| 1568 | *n = 4096; |
| 1569 | break; |
| 1570 | case 44100: |
| 1571 | *n = 6272; |
| 1572 | break; |
| 1573 | case 48000: |
| 1574 | if ((deep_color == 125) && ((pclk == 54054) |
| 1575 | || (pclk == 74250))) |
| 1576 | *n = 8192; |
| 1577 | else |
| 1578 | *n = 6144; |
| 1579 | break; |
| 1580 | default: |
| 1581 | *n = 0; |
| 1582 | return -EINVAL; |
| 1583 | } |
| 1584 | |
| 1585 | /* Calculate CTS. See HDMI 1.3a or 1.4a specifications */ |
| 1586 | *cts = pclk * (*n / 128) * deep_color / (sample_freq / 10); |
| 1587 | |
| 1588 | return 0; |
| 1589 | } |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1590 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1591 | static int hdmi_audio_hw_params(struct hdmi_ip_data *ip_data, |
| 1592 | struct snd_pcm_substream *substream, |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1593 | struct snd_pcm_hw_params *params, |
| 1594 | struct snd_soc_dai *dai) |
| 1595 | { |
| 1596 | struct hdmi_audio_format audio_format; |
| 1597 | struct hdmi_audio_dma audio_dma; |
| 1598 | struct hdmi_core_audio_config core_cfg; |
| 1599 | struct hdmi_core_infoframe_audio aud_if_cfg; |
| 1600 | int err, n, cts; |
| 1601 | enum hdmi_core_audio_sample_freq sample_freq; |
| 1602 | |
| 1603 | switch (params_format(params)) { |
| 1604 | case SNDRV_PCM_FORMAT_S16_LE: |
| 1605 | core_cfg.i2s_cfg.word_max_length = |
| 1606 | HDMI_AUDIO_I2S_MAX_WORD_20BITS; |
| 1607 | core_cfg.i2s_cfg.word_length = HDMI_AUDIO_I2S_CHST_WORD_16_BITS; |
| 1608 | core_cfg.i2s_cfg.in_length_bits = |
| 1609 | HDMI_AUDIO_I2S_INPUT_LENGTH_16; |
| 1610 | core_cfg.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_LEFT; |
| 1611 | audio_format.samples_per_word = HDMI_AUDIO_ONEWORD_TWOSAMPLES; |
| 1612 | audio_format.sample_size = HDMI_AUDIO_SAMPLE_16BITS; |
| 1613 | audio_format.justification = HDMI_AUDIO_JUSTIFY_LEFT; |
| 1614 | audio_dma.transfer_size = 0x10; |
| 1615 | break; |
| 1616 | case SNDRV_PCM_FORMAT_S24_LE: |
| 1617 | core_cfg.i2s_cfg.word_max_length = |
| 1618 | HDMI_AUDIO_I2S_MAX_WORD_24BITS; |
| 1619 | core_cfg.i2s_cfg.word_length = HDMI_AUDIO_I2S_CHST_WORD_24_BITS; |
| 1620 | core_cfg.i2s_cfg.in_length_bits = |
| 1621 | HDMI_AUDIO_I2S_INPUT_LENGTH_24; |
| 1622 | audio_format.samples_per_word = HDMI_AUDIO_ONEWORD_ONESAMPLE; |
| 1623 | audio_format.sample_size = HDMI_AUDIO_SAMPLE_24BITS; |
| 1624 | audio_format.justification = HDMI_AUDIO_JUSTIFY_RIGHT; |
| 1625 | core_cfg.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_RIGHT; |
| 1626 | audio_dma.transfer_size = 0x20; |
| 1627 | break; |
| 1628 | default: |
| 1629 | return -EINVAL; |
| 1630 | } |
| 1631 | |
| 1632 | switch (params_rate(params)) { |
| 1633 | case 32000: |
| 1634 | sample_freq = HDMI_AUDIO_FS_32000; |
| 1635 | break; |
| 1636 | case 44100: |
| 1637 | sample_freq = HDMI_AUDIO_FS_44100; |
| 1638 | break; |
| 1639 | case 48000: |
| 1640 | sample_freq = HDMI_AUDIO_FS_48000; |
| 1641 | break; |
| 1642 | default: |
| 1643 | return -EINVAL; |
| 1644 | } |
| 1645 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1646 | err = hdmi_config_audio_acr(ip_data, params_rate(params), &n, &cts); |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1647 | if (err < 0) |
| 1648 | return err; |
| 1649 | |
| 1650 | /* Audio wrapper config */ |
| 1651 | audio_format.stereo_channels = HDMI_AUDIO_STEREO_ONECHANNEL; |
| 1652 | audio_format.active_chnnls_msk = 0x03; |
| 1653 | audio_format.type = HDMI_AUDIO_TYPE_LPCM; |
| 1654 | audio_format.sample_order = HDMI_AUDIO_SAMPLE_LEFT_FIRST; |
| 1655 | /* Disable start/stop signals of IEC 60958 blocks */ |
| 1656 | audio_format.en_sig_blk_strt_end = HDMI_AUDIO_BLOCK_SIG_STARTEND_OFF; |
| 1657 | |
| 1658 | audio_dma.block_size = 0xC0; |
| 1659 | audio_dma.mode = HDMI_AUDIO_TRANSF_DMA; |
| 1660 | audio_dma.fifo_threshold = 0x20; /* in number of samples */ |
| 1661 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1662 | hdmi_wp_audio_config_dma(ip_data, &audio_dma); |
| 1663 | hdmi_wp_audio_config_format(ip_data, &audio_format); |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1664 | |
| 1665 | /* |
| 1666 | * I2S config |
| 1667 | */ |
| 1668 | core_cfg.i2s_cfg.en_high_bitrate_aud = false; |
| 1669 | /* Only used with high bitrate audio */ |
| 1670 | core_cfg.i2s_cfg.cbit_order = false; |
| 1671 | /* Serial data and word select should change on sck rising edge */ |
| 1672 | core_cfg.i2s_cfg.sck_edge_mode = HDMI_AUDIO_I2S_SCK_EDGE_RISING; |
| 1673 | core_cfg.i2s_cfg.vbit = HDMI_AUDIO_I2S_VBIT_FOR_PCM; |
| 1674 | /* Set I2S word select polarity */ |
| 1675 | core_cfg.i2s_cfg.ws_polarity = HDMI_AUDIO_I2S_WS_POLARITY_LOW_IS_LEFT; |
| 1676 | core_cfg.i2s_cfg.direction = HDMI_AUDIO_I2S_MSB_SHIFTED_FIRST; |
| 1677 | /* Set serial data to word select shift. See Phillips spec. */ |
| 1678 | core_cfg.i2s_cfg.shift = HDMI_AUDIO_I2S_FIRST_BIT_SHIFT; |
| 1679 | /* Enable one of the four available serial data channels */ |
| 1680 | core_cfg.i2s_cfg.active_sds = HDMI_AUDIO_I2S_SD0_EN; |
| 1681 | |
| 1682 | /* Core audio config */ |
| 1683 | core_cfg.freq_sample = sample_freq; |
| 1684 | core_cfg.n = n; |
| 1685 | core_cfg.cts = cts; |
| 1686 | if (dss_has_feature(FEAT_HDMI_CTS_SWMODE)) { |
| 1687 | core_cfg.aud_par_busclk = 0; |
| 1688 | core_cfg.cts_mode = HDMI_AUDIO_CTS_MODE_SW; |
| 1689 | core_cfg.use_mclk = false; |
| 1690 | } else { |
| 1691 | core_cfg.aud_par_busclk = (((128 * 31) - 1) << 8); |
| 1692 | core_cfg.cts_mode = HDMI_AUDIO_CTS_MODE_HW; |
| 1693 | core_cfg.use_mclk = true; |
| 1694 | core_cfg.mclk_mode = HDMI_AUDIO_MCLK_128FS; |
| 1695 | } |
| 1696 | core_cfg.layout = HDMI_AUDIO_LAYOUT_2CH; |
| 1697 | core_cfg.en_spdif = false; |
| 1698 | /* Use sample frequency from channel status word */ |
| 1699 | core_cfg.fs_override = true; |
| 1700 | /* Enable ACR packets */ |
| 1701 | core_cfg.en_acr_pkt = true; |
| 1702 | /* Disable direct streaming digital audio */ |
| 1703 | core_cfg.en_dsd_audio = false; |
| 1704 | /* Use parallel audio interface */ |
| 1705 | core_cfg.en_parallel_aud_input = true; |
| 1706 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1707 | hdmi_core_audio_config(ip_data, &core_cfg); |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1708 | |
| 1709 | /* |
| 1710 | * Configure packet |
| 1711 | * info frame audio see doc CEA861-D page 74 |
| 1712 | */ |
| 1713 | aud_if_cfg.db1_coding_type = HDMI_INFOFRAME_AUDIO_DB1CT_FROM_STREAM; |
| 1714 | aud_if_cfg.db1_channel_count = 2; |
| 1715 | aud_if_cfg.db2_sample_freq = HDMI_INFOFRAME_AUDIO_DB2SF_FROM_STREAM; |
| 1716 | aud_if_cfg.db2_sample_size = HDMI_INFOFRAME_AUDIO_DB2SS_FROM_STREAM; |
| 1717 | aud_if_cfg.db4_channel_alloc = 0x00; |
| 1718 | aud_if_cfg.db5_downmix_inh = false; |
| 1719 | aud_if_cfg.db5_lsv = 0; |
| 1720 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1721 | hdmi_core_audio_infoframe_config(ip_data, &aud_if_cfg); |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1722 | return 0; |
| 1723 | } |
| 1724 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1725 | static int hdmi_audio_trigger(struct hdmi_ip_data *ip_data, |
| 1726 | struct snd_pcm_substream *substream, int cmd, |
| 1727 | struct snd_soc_dai *dai) |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1728 | { |
| 1729 | int err = 0; |
| 1730 | switch (cmd) { |
| 1731 | case SNDRV_PCM_TRIGGER_START: |
| 1732 | case SNDRV_PCM_TRIGGER_RESUME: |
| 1733 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1734 | REG_FLD_MOD(hdmi_av_base(ip_data), |
| 1735 | HDMI_CORE_AV_AUD_MODE, 1, 0, 0); |
| 1736 | REG_FLD_MOD(hdmi_wp_base(ip_data), |
| 1737 | HDMI_WP_AUDIO_CTRL, 1, 31, 31); |
| 1738 | REG_FLD_MOD(hdmi_wp_base(ip_data), |
| 1739 | HDMI_WP_AUDIO_CTRL, 1, 30, 30); |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1740 | break; |
| 1741 | |
| 1742 | case SNDRV_PCM_TRIGGER_STOP: |
| 1743 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| 1744 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1745 | REG_FLD_MOD(hdmi_av_base(ip_data), |
| 1746 | HDMI_CORE_AV_AUD_MODE, 0, 0, 0); |
| 1747 | REG_FLD_MOD(hdmi_wp_base(ip_data), |
| 1748 | HDMI_WP_AUDIO_CTRL, 0, 30, 30); |
| 1749 | REG_FLD_MOD(hdmi_wp_base(ip_data), |
| 1750 | HDMI_WP_AUDIO_CTRL, 0, 31, 31); |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1751 | break; |
| 1752 | default: |
| 1753 | err = -EINVAL; |
| 1754 | } |
| 1755 | return err; |
| 1756 | } |
| 1757 | |
| 1758 | static int hdmi_audio_startup(struct snd_pcm_substream *substream, |
| 1759 | struct snd_soc_dai *dai) |
| 1760 | { |
| 1761 | if (!hdmi.mode) { |
| 1762 | pr_err("Current video settings do not support audio.\n"); |
| 1763 | return -EIO; |
| 1764 | } |
| 1765 | return 0; |
| 1766 | } |
| 1767 | |
| 1768 | static struct snd_soc_codec_driver hdmi_audio_codec_drv = { |
| 1769 | }; |
| 1770 | |
| 1771 | static struct snd_soc_dai_ops hdmi_audio_codec_ops = { |
| 1772 | .hw_params = hdmi_audio_hw_params, |
| 1773 | .trigger = hdmi_audio_trigger, |
| 1774 | .startup = hdmi_audio_startup, |
| 1775 | }; |
| 1776 | |
| 1777 | static struct snd_soc_dai_driver hdmi_codec_dai_drv = { |
| 1778 | .name = "hdmi-audio-codec", |
| 1779 | .playback = { |
| 1780 | .channels_min = 2, |
| 1781 | .channels_max = 2, |
| 1782 | .rates = SNDRV_PCM_RATE_32000 | |
| 1783 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, |
| 1784 | .formats = SNDRV_PCM_FMTBIT_S16_LE | |
| 1785 | SNDRV_PCM_FMTBIT_S24_LE, |
| 1786 | }, |
| 1787 | .ops = &hdmi_audio_codec_ops, |
| 1788 | }; |
Ricardo Neri | 82335c4 | 2011-04-05 16:05:18 -0500 | [diff] [blame] | 1789 | #endif |
| 1790 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1791 | static int hdmi_get_clocks(struct platform_device *pdev) |
| 1792 | { |
| 1793 | struct clk *clk; |
| 1794 | |
| 1795 | clk = clk_get(&pdev->dev, "sys_clk"); |
| 1796 | if (IS_ERR(clk)) { |
| 1797 | DSSERR("can't get sys_clk\n"); |
| 1798 | return PTR_ERR(clk); |
| 1799 | } |
| 1800 | |
| 1801 | hdmi.sys_clk = clk; |
| 1802 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1803 | return 0; |
| 1804 | } |
| 1805 | |
| 1806 | static void hdmi_put_clocks(void) |
| 1807 | { |
| 1808 | if (hdmi.sys_clk) |
| 1809 | clk_put(hdmi.sys_clk); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1810 | } |
| 1811 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1812 | /* HDMI HW IP initialisation */ |
| 1813 | static int omapdss_hdmihw_probe(struct platform_device *pdev) |
| 1814 | { |
| 1815 | struct resource *hdmi_mem; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1816 | int r; |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1817 | |
| 1818 | hdmi.pdata = pdev->dev.platform_data; |
| 1819 | hdmi.pdev = pdev; |
| 1820 | |
| 1821 | mutex_init(&hdmi.lock); |
| 1822 | |
| 1823 | hdmi_mem = platform_get_resource(hdmi.pdev, IORESOURCE_MEM, 0); |
| 1824 | if (!hdmi_mem) { |
| 1825 | DSSERR("can't get IORESOURCE_MEM HDMI\n"); |
| 1826 | return -EINVAL; |
| 1827 | } |
| 1828 | |
| 1829 | /* Base address taken from platform */ |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1830 | hdmi.ip_data.base_wp = ioremap(hdmi_mem->start, |
| 1831 | resource_size(hdmi_mem)); |
| 1832 | if (!hdmi.ip_data.base_wp) { |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1833 | DSSERR("can't ioremap WP\n"); |
| 1834 | return -ENOMEM; |
| 1835 | } |
| 1836 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1837 | r = hdmi_get_clocks(pdev); |
| 1838 | if (r) { |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1839 | iounmap(hdmi.ip_data.base_wp); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1840 | return r; |
| 1841 | } |
| 1842 | |
| 1843 | pm_runtime_enable(&pdev->dev); |
| 1844 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1845 | hdmi.ip_data.core_sys_offset = HDMI_CORE_SYS; |
| 1846 | hdmi.ip_data.core_av_offset = HDMI_CORE_AV; |
| 1847 | hdmi.ip_data.pll_offset = HDMI_PLLCTRL; |
| 1848 | hdmi.ip_data.phy_offset = HDMI_PHY; |
| 1849 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1850 | hdmi_panel_init(); |
| 1851 | |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1852 | #if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \ |
| 1853 | defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE) |
| 1854 | |
| 1855 | /* Register ASoC codec DAI */ |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1856 | r = snd_soc_register_codec(&pdev->dev, &hdmi_audio_codec_drv, |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1857 | &hdmi_codec_dai_drv, 1); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1858 | if (r) { |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1859 | DSSERR("can't register ASoC HDMI audio codec\n"); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1860 | return r; |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1861 | } |
| 1862 | #endif |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1863 | return 0; |
| 1864 | } |
| 1865 | |
| 1866 | static int omapdss_hdmihw_remove(struct platform_device *pdev) |
| 1867 | { |
| 1868 | hdmi_panel_exit(); |
| 1869 | |
Ricardo Neri | ad44cc3 | 2011-05-18 22:31:56 -0500 | [diff] [blame] | 1870 | #if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \ |
| 1871 | defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE) |
| 1872 | snd_soc_unregister_codec(&pdev->dev); |
| 1873 | #endif |
| 1874 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1875 | pm_runtime_disable(&pdev->dev); |
| 1876 | |
| 1877 | hdmi_put_clocks(); |
| 1878 | |
Mythri P K | 95a8aeb | 2011-09-08 19:06:18 +0530 | [diff] [blame] | 1879 | iounmap(hdmi.ip_data.base_wp); |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1880 | |
| 1881 | return 0; |
| 1882 | } |
| 1883 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1884 | static int hdmi_runtime_suspend(struct device *dev) |
| 1885 | { |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1886 | clk_disable(hdmi.sys_clk); |
| 1887 | |
| 1888 | dispc_runtime_put(); |
| 1889 | dss_runtime_put(); |
| 1890 | |
| 1891 | return 0; |
| 1892 | } |
| 1893 | |
| 1894 | static int hdmi_runtime_resume(struct device *dev) |
| 1895 | { |
| 1896 | int r; |
| 1897 | |
| 1898 | r = dss_runtime_get(); |
| 1899 | if (r < 0) |
| 1900 | goto err_get_dss; |
| 1901 | |
| 1902 | r = dispc_runtime_get(); |
| 1903 | if (r < 0) |
| 1904 | goto err_get_dispc; |
| 1905 | |
| 1906 | |
| 1907 | clk_enable(hdmi.sys_clk); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1908 | |
| 1909 | return 0; |
| 1910 | |
| 1911 | err_get_dispc: |
| 1912 | dss_runtime_put(); |
| 1913 | err_get_dss: |
| 1914 | return r; |
| 1915 | } |
| 1916 | |
| 1917 | static const struct dev_pm_ops hdmi_pm_ops = { |
| 1918 | .runtime_suspend = hdmi_runtime_suspend, |
| 1919 | .runtime_resume = hdmi_runtime_resume, |
| 1920 | }; |
| 1921 | |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1922 | static struct platform_driver omapdss_hdmihw_driver = { |
| 1923 | .probe = omapdss_hdmihw_probe, |
| 1924 | .remove = omapdss_hdmihw_remove, |
| 1925 | .driver = { |
| 1926 | .name = "omapdss_hdmi", |
| 1927 | .owner = THIS_MODULE, |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1928 | .pm = &hdmi_pm_ops, |
Mythri P K | c3198a5 | 2011-03-12 12:04:27 +0530 | [diff] [blame] | 1929 | }, |
| 1930 | }; |
| 1931 | |
| 1932 | int hdmi_init_platform_driver(void) |
| 1933 | { |
| 1934 | return platform_driver_register(&omapdss_hdmihw_driver); |
| 1935 | } |
| 1936 | |
| 1937 | void hdmi_uninit_platform_driver(void) |
| 1938 | { |
| 1939 | return platform_driver_unregister(&omapdss_hdmihw_driver); |
| 1940 | } |