Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 9 | * Designware High-Definition Multimedia Interface (HDMI) driver |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 10 | * |
| 11 | * Copyright (C) 2010, Guennadi Liakhovetski <g.liakhovetski@gmx.de> |
| 12 | */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 13 | #include <linux/module.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 14 | #include <linux/irq.h> |
| 15 | #include <linux/delay.h> |
| 16 | #include <linux/err.h> |
| 17 | #include <linux/clk.h> |
Sachin Kamat | 5a819ed | 2014-01-28 10:33:16 +0530 | [diff] [blame] | 18 | #include <linux/hdmi.h> |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 19 | #include <linux/mutex.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 20 | #include <linux/of_device.h> |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 21 | #include <linux/spinlock.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 22 | |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 23 | #include <drm/drm_of.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 24 | #include <drm/drmP.h> |
| 25 | #include <drm/drm_crtc_helper.h> |
| 26 | #include <drm/drm_edid.h> |
| 27 | #include <drm/drm_encoder_slave.h> |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 28 | #include <drm/bridge/dw_hdmi.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 29 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 30 | #include "dw_hdmi.h" |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 31 | #include "dw_hdmi-audio.h" |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 32 | |
| 33 | #define HDMI_EDID_LEN 512 |
| 34 | |
| 35 | #define RGB 0 |
| 36 | #define YCBCR444 1 |
| 37 | #define YCBCR422_16BITS 2 |
| 38 | #define YCBCR422_8BITS 3 |
| 39 | #define XVYCC444 4 |
| 40 | |
| 41 | enum hdmi_datamap { |
| 42 | RGB444_8B = 0x01, |
| 43 | RGB444_10B = 0x03, |
| 44 | RGB444_12B = 0x05, |
| 45 | RGB444_16B = 0x07, |
| 46 | YCbCr444_8B = 0x09, |
| 47 | YCbCr444_10B = 0x0B, |
| 48 | YCbCr444_12B = 0x0D, |
| 49 | YCbCr444_16B = 0x0F, |
| 50 | YCbCr422_8B = 0x16, |
| 51 | YCbCr422_10B = 0x14, |
| 52 | YCbCr422_12B = 0x12, |
| 53 | }; |
| 54 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 55 | static const u16 csc_coeff_default[3][4] = { |
| 56 | { 0x2000, 0x0000, 0x0000, 0x0000 }, |
| 57 | { 0x0000, 0x2000, 0x0000, 0x0000 }, |
| 58 | { 0x0000, 0x0000, 0x2000, 0x0000 } |
| 59 | }; |
| 60 | |
| 61 | static const u16 csc_coeff_rgb_out_eitu601[3][4] = { |
| 62 | { 0x2000, 0x6926, 0x74fd, 0x010e }, |
| 63 | { 0x2000, 0x2cdd, 0x0000, 0x7e9a }, |
| 64 | { 0x2000, 0x0000, 0x38b4, 0x7e3b } |
| 65 | }; |
| 66 | |
| 67 | static const u16 csc_coeff_rgb_out_eitu709[3][4] = { |
| 68 | { 0x2000, 0x7106, 0x7a02, 0x00a7 }, |
| 69 | { 0x2000, 0x3264, 0x0000, 0x7e6d }, |
| 70 | { 0x2000, 0x0000, 0x3b61, 0x7e25 } |
| 71 | }; |
| 72 | |
| 73 | static const u16 csc_coeff_rgb_in_eitu601[3][4] = { |
| 74 | { 0x2591, 0x1322, 0x074b, 0x0000 }, |
| 75 | { 0x6535, 0x2000, 0x7acc, 0x0200 }, |
| 76 | { 0x6acd, 0x7534, 0x2000, 0x0200 } |
| 77 | }; |
| 78 | |
| 79 | static const u16 csc_coeff_rgb_in_eitu709[3][4] = { |
| 80 | { 0x2dc5, 0x0d9b, 0x049e, 0x0000 }, |
| 81 | { 0x62f0, 0x2000, 0x7d11, 0x0200 }, |
| 82 | { 0x6756, 0x78ab, 0x2000, 0x0200 } |
| 83 | }; |
| 84 | |
| 85 | struct hdmi_vmode { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 86 | bool mdataenablepolarity; |
| 87 | |
| 88 | unsigned int mpixelclock; |
| 89 | unsigned int mpixelrepetitioninput; |
| 90 | unsigned int mpixelrepetitionoutput; |
| 91 | }; |
| 92 | |
| 93 | struct hdmi_data_info { |
| 94 | unsigned int enc_in_format; |
| 95 | unsigned int enc_out_format; |
| 96 | unsigned int enc_color_depth; |
| 97 | unsigned int colorimetry; |
| 98 | unsigned int pix_repet_factor; |
| 99 | unsigned int hdcp_enable; |
| 100 | struct hdmi_vmode video_mode; |
| 101 | }; |
| 102 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 103 | struct dw_hdmi { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 104 | struct drm_connector connector; |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 105 | struct drm_encoder *encoder; |
| 106 | struct drm_bridge *bridge; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 107 | |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 108 | struct platform_device *audio; |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 109 | enum dw_hdmi_devtype dev_type; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 110 | struct device *dev; |
| 111 | struct clk *isfr_clk; |
| 112 | struct clk *iahb_clk; |
| 113 | |
| 114 | struct hdmi_data_info hdmi_data; |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 115 | const struct dw_hdmi_plat_data *plat_data; |
| 116 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 117 | int vic; |
| 118 | |
| 119 | u8 edid[HDMI_EDID_LEN]; |
| 120 | bool cable_plugin; |
| 121 | |
| 122 | bool phy_enabled; |
| 123 | struct drm_display_mode previous_mode; |
| 124 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 125 | struct i2c_adapter *ddc; |
| 126 | void __iomem *regs; |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 127 | bool sink_is_hdmi; |
Russell King | f709ec0 | 2015-07-21 16:09:39 +0100 | [diff] [blame] | 128 | bool sink_has_audio; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 129 | |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 130 | struct mutex mutex; /* for state below and previous_mode */ |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 131 | enum drm_connector_force force; /* mutex-protected force state */ |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 132 | bool disabled; /* DRM has disabled our bridge */ |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 133 | bool bridge_is_on; /* indicates the bridge is on */ |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 134 | bool rxsense; /* rxsense state */ |
| 135 | u8 phy_mask; /* desired phy int mask settings */ |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 136 | |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 137 | spinlock_t audio_lock; |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 138 | struct mutex audio_mutex; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 139 | unsigned int sample_rate; |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 140 | unsigned int audio_cts; |
| 141 | unsigned int audio_n; |
| 142 | bool audio_enable; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 143 | int ratio; |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 144 | |
| 145 | void (*write)(struct dw_hdmi *hdmi, u8 val, int offset); |
| 146 | u8 (*read)(struct dw_hdmi *hdmi, int offset); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 147 | }; |
| 148 | |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 149 | #define HDMI_IH_PHY_STAT0_RX_SENSE \ |
| 150 | (HDMI_IH_PHY_STAT0_RX_SENSE0 | HDMI_IH_PHY_STAT0_RX_SENSE1 | \ |
| 151 | HDMI_IH_PHY_STAT0_RX_SENSE2 | HDMI_IH_PHY_STAT0_RX_SENSE3) |
| 152 | |
| 153 | #define HDMI_PHY_RX_SENSE \ |
| 154 | (HDMI_PHY_RX_SENSE0 | HDMI_PHY_RX_SENSE1 | \ |
| 155 | HDMI_PHY_RX_SENSE2 | HDMI_PHY_RX_SENSE3) |
| 156 | |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 157 | static void dw_hdmi_writel(struct dw_hdmi *hdmi, u8 val, int offset) |
| 158 | { |
| 159 | writel(val, hdmi->regs + (offset << 2)); |
| 160 | } |
| 161 | |
| 162 | static u8 dw_hdmi_readl(struct dw_hdmi *hdmi, int offset) |
| 163 | { |
| 164 | return readl(hdmi->regs + (offset << 2)); |
| 165 | } |
| 166 | |
| 167 | static void dw_hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 168 | { |
| 169 | writeb(val, hdmi->regs + offset); |
| 170 | } |
| 171 | |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 172 | static u8 dw_hdmi_readb(struct dw_hdmi *hdmi, int offset) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 173 | { |
| 174 | return readb(hdmi->regs + offset); |
| 175 | } |
| 176 | |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 177 | static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset) |
| 178 | { |
| 179 | hdmi->write(hdmi, val, offset); |
| 180 | } |
| 181 | |
| 182 | static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset) |
| 183 | { |
| 184 | return hdmi->read(hdmi, offset); |
| 185 | } |
| 186 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 187 | static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg) |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 188 | { |
| 189 | u8 val = hdmi_readb(hdmi, reg) & ~mask; |
Fabio Estevam | b44ab1b | 2014-04-28 08:01:07 -0300 | [diff] [blame] | 190 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 191 | val |= data & mask; |
| 192 | hdmi_writeb(hdmi, val, reg); |
| 193 | } |
| 194 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 195 | static void hdmi_mask_writeb(struct dw_hdmi *hdmi, u8 data, unsigned int reg, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 196 | u8 shift, u8 mask) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 197 | { |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 198 | hdmi_modb(hdmi, data << shift, mask, reg); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 199 | } |
| 200 | |
Russell King | 351e135 | 2015-01-31 14:50:23 +0000 | [diff] [blame] | 201 | static void hdmi_set_cts_n(struct dw_hdmi *hdmi, unsigned int cts, |
| 202 | unsigned int n) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 203 | { |
Russell King | 622494a | 2015-02-02 10:55:38 +0000 | [diff] [blame] | 204 | /* Must be set/cleared first */ |
| 205 | hdmi_modb(hdmi, 0, HDMI_AUD_CTS3_CTS_MANUAL, HDMI_AUD_CTS3); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 206 | |
| 207 | /* nshift factor = 0 */ |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 208 | hdmi_modb(hdmi, 0, HDMI_AUD_CTS3_N_SHIFT_MASK, HDMI_AUD_CTS3); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 209 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 210 | hdmi_writeb(hdmi, ((cts >> 16) & HDMI_AUD_CTS3_AUDCTS19_16_MASK) | |
| 211 | HDMI_AUD_CTS3_CTS_MANUAL, HDMI_AUD_CTS3); |
Russell King | 622494a | 2015-02-02 10:55:38 +0000 | [diff] [blame] | 212 | hdmi_writeb(hdmi, (cts >> 8) & 0xff, HDMI_AUD_CTS2); |
| 213 | hdmi_writeb(hdmi, cts & 0xff, HDMI_AUD_CTS1); |
| 214 | |
| 215 | hdmi_writeb(hdmi, (n >> 16) & 0x0f, HDMI_AUD_N3); |
| 216 | hdmi_writeb(hdmi, (n >> 8) & 0xff, HDMI_AUD_N2); |
| 217 | hdmi_writeb(hdmi, n & 0xff, HDMI_AUD_N1); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk, |
| 221 | unsigned int ratio) |
| 222 | { |
| 223 | unsigned int n = (128 * freq) / 1000; |
Russell King | d0c96d1 | 2015-07-22 10:35:41 +0100 | [diff] [blame^] | 224 | unsigned int mult = 1; |
| 225 | |
| 226 | while (freq > 48000) { |
| 227 | mult *= 2; |
| 228 | freq /= 2; |
| 229 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 230 | |
| 231 | switch (freq) { |
| 232 | case 32000: |
| 233 | if (pixel_clk == 25170000) |
| 234 | n = (ratio == 150) ? 9152 : 4576; |
| 235 | else if (pixel_clk == 27020000) |
| 236 | n = (ratio == 150) ? 8192 : 4096; |
| 237 | else if (pixel_clk == 74170000 || pixel_clk == 148350000) |
| 238 | n = 11648; |
| 239 | else |
| 240 | n = 4096; |
Russell King | d0c96d1 | 2015-07-22 10:35:41 +0100 | [diff] [blame^] | 241 | n *= mult; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 242 | break; |
| 243 | |
| 244 | case 44100: |
| 245 | if (pixel_clk == 25170000) |
| 246 | n = 7007; |
| 247 | else if (pixel_clk == 74170000) |
| 248 | n = 17836; |
| 249 | else if (pixel_clk == 148350000) |
| 250 | n = (ratio == 150) ? 17836 : 8918; |
| 251 | else |
| 252 | n = 6272; |
Russell King | d0c96d1 | 2015-07-22 10:35:41 +0100 | [diff] [blame^] | 253 | n *= mult; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 254 | break; |
| 255 | |
| 256 | case 48000: |
| 257 | if (pixel_clk == 25170000) |
| 258 | n = (ratio == 150) ? 9152 : 6864; |
| 259 | else if (pixel_clk == 27020000) |
| 260 | n = (ratio == 150) ? 8192 : 6144; |
| 261 | else if (pixel_clk == 74170000) |
| 262 | n = 11648; |
| 263 | else if (pixel_clk == 148350000) |
| 264 | n = (ratio == 150) ? 11648 : 5824; |
| 265 | else |
| 266 | n = 6144; |
Russell King | d0c96d1 | 2015-07-22 10:35:41 +0100 | [diff] [blame^] | 267 | n *= mult; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 268 | break; |
| 269 | |
| 270 | default: |
| 271 | break; |
| 272 | } |
| 273 | |
| 274 | return n; |
| 275 | } |
| 276 | |
| 277 | static unsigned int hdmi_compute_cts(unsigned int freq, unsigned long pixel_clk, |
| 278 | unsigned int ratio) |
| 279 | { |
| 280 | unsigned int cts = 0; |
| 281 | |
| 282 | pr_debug("%s: freq: %d pixel_clk: %ld ratio: %d\n", __func__, freq, |
| 283 | pixel_clk, ratio); |
| 284 | |
| 285 | switch (freq) { |
| 286 | case 32000: |
| 287 | if (pixel_clk == 297000000) { |
| 288 | cts = 222750; |
| 289 | break; |
| 290 | } |
| 291 | case 48000: |
| 292 | case 96000: |
| 293 | case 192000: |
| 294 | switch (pixel_clk) { |
| 295 | case 25200000: |
| 296 | case 27000000: |
| 297 | case 54000000: |
| 298 | case 74250000: |
| 299 | case 148500000: |
| 300 | cts = pixel_clk / 1000; |
| 301 | break; |
| 302 | case 297000000: |
| 303 | cts = 247500; |
| 304 | break; |
| 305 | /* |
| 306 | * All other TMDS clocks are not supported by |
| 307 | * DWC_hdmi_tx. The TMDS clocks divided or |
| 308 | * multiplied by 1,001 coefficients are not |
| 309 | * supported. |
| 310 | */ |
| 311 | default: |
| 312 | break; |
| 313 | } |
| 314 | break; |
| 315 | case 44100: |
| 316 | case 88200: |
| 317 | case 176400: |
| 318 | switch (pixel_clk) { |
| 319 | case 25200000: |
| 320 | cts = 28000; |
| 321 | break; |
| 322 | case 27000000: |
| 323 | cts = 30000; |
| 324 | break; |
| 325 | case 54000000: |
| 326 | cts = 60000; |
| 327 | break; |
| 328 | case 74250000: |
| 329 | cts = 82500; |
| 330 | break; |
| 331 | case 148500000: |
| 332 | cts = 165000; |
| 333 | break; |
| 334 | case 297000000: |
| 335 | cts = 247500; |
| 336 | break; |
| 337 | default: |
| 338 | break; |
| 339 | } |
| 340 | break; |
| 341 | default: |
| 342 | break; |
| 343 | } |
| 344 | if (ratio == 100) |
| 345 | return cts; |
Catalina Mocanu | 7557b6e | 2014-09-24 14:27:36 -0700 | [diff] [blame] | 346 | return (cts * ratio) / 100; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 347 | } |
| 348 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 349 | static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, |
Russell King | f879b38 | 2015-03-27 12:53:29 +0000 | [diff] [blame] | 350 | unsigned long pixel_clk, unsigned int sample_rate, unsigned int ratio) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 351 | { |
Russell King | f879b38 | 2015-03-27 12:53:29 +0000 | [diff] [blame] | 352 | unsigned int n, cts; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 353 | |
Russell King | f879b38 | 2015-03-27 12:53:29 +0000 | [diff] [blame] | 354 | n = hdmi_compute_n(sample_rate, pixel_clk, ratio); |
| 355 | cts = hdmi_compute_cts(sample_rate, pixel_clk, ratio); |
| 356 | if (!cts) { |
| 357 | dev_err(hdmi->dev, |
| 358 | "%s: pixel clock/sample rate not supported: %luMHz / %ukHz\n", |
| 359 | __func__, pixel_clk, sample_rate); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 360 | } |
| 361 | |
Russell King | f879b38 | 2015-03-27 12:53:29 +0000 | [diff] [blame] | 362 | dev_dbg(hdmi->dev, "%s: samplerate=%ukHz ratio=%d pixelclk=%luMHz N=%d cts=%d\n", |
| 363 | __func__, sample_rate, ratio, pixel_clk, n, cts); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 364 | |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 365 | spin_lock_irq(&hdmi->audio_lock); |
| 366 | hdmi->audio_n = n; |
| 367 | hdmi->audio_cts = cts; |
| 368 | hdmi_set_cts_n(hdmi, cts, hdmi->audio_enable ? n : 0); |
| 369 | spin_unlock_irq(&hdmi->audio_lock); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 370 | } |
| 371 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 372 | static void hdmi_init_clk_regenerator(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 373 | { |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 374 | mutex_lock(&hdmi->audio_mutex); |
Russell King | f879b38 | 2015-03-27 12:53:29 +0000 | [diff] [blame] | 375 | hdmi_set_clk_regenerator(hdmi, 74250000, hdmi->sample_rate, |
| 376 | hdmi->ratio); |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 377 | mutex_unlock(&hdmi->audio_mutex); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 378 | } |
| 379 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 380 | static void hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 381 | { |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 382 | mutex_lock(&hdmi->audio_mutex); |
Russell King | f879b38 | 2015-03-27 12:53:29 +0000 | [diff] [blame] | 383 | hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock, |
| 384 | hdmi->sample_rate, hdmi->ratio); |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 385 | mutex_unlock(&hdmi->audio_mutex); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 386 | } |
| 387 | |
Russell King | b5814ff | 2015-03-27 12:50:58 +0000 | [diff] [blame] | 388 | void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate) |
| 389 | { |
| 390 | mutex_lock(&hdmi->audio_mutex); |
| 391 | hdmi->sample_rate = rate; |
| 392 | hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock, |
| 393 | hdmi->sample_rate, hdmi->ratio); |
| 394 | mutex_unlock(&hdmi->audio_mutex); |
| 395 | } |
| 396 | EXPORT_SYMBOL_GPL(dw_hdmi_set_sample_rate); |
| 397 | |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 398 | void dw_hdmi_audio_enable(struct dw_hdmi *hdmi) |
| 399 | { |
| 400 | unsigned long flags; |
| 401 | |
| 402 | spin_lock_irqsave(&hdmi->audio_lock, flags); |
| 403 | hdmi->audio_enable = true; |
| 404 | hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); |
| 405 | spin_unlock_irqrestore(&hdmi->audio_lock, flags); |
| 406 | } |
| 407 | EXPORT_SYMBOL_GPL(dw_hdmi_audio_enable); |
| 408 | |
| 409 | void dw_hdmi_audio_disable(struct dw_hdmi *hdmi) |
| 410 | { |
| 411 | unsigned long flags; |
| 412 | |
| 413 | spin_lock_irqsave(&hdmi->audio_lock, flags); |
| 414 | hdmi->audio_enable = false; |
| 415 | hdmi_set_cts_n(hdmi, hdmi->audio_cts, 0); |
| 416 | spin_unlock_irqrestore(&hdmi->audio_lock, flags); |
| 417 | } |
| 418 | EXPORT_SYMBOL_GPL(dw_hdmi_audio_disable); |
| 419 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 420 | /* |
| 421 | * this submodule is responsible for the video data synchronization. |
| 422 | * for example, for RGB 4:4:4 input, the data map is defined as |
| 423 | * pin{47~40} <==> R[7:0] |
| 424 | * pin{31~24} <==> G[7:0] |
| 425 | * pin{15~8} <==> B[7:0] |
| 426 | */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 427 | static void hdmi_video_sample(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 428 | { |
| 429 | int color_format = 0; |
| 430 | u8 val; |
| 431 | |
| 432 | if (hdmi->hdmi_data.enc_in_format == RGB) { |
| 433 | if (hdmi->hdmi_data.enc_color_depth == 8) |
| 434 | color_format = 0x01; |
| 435 | else if (hdmi->hdmi_data.enc_color_depth == 10) |
| 436 | color_format = 0x03; |
| 437 | else if (hdmi->hdmi_data.enc_color_depth == 12) |
| 438 | color_format = 0x05; |
| 439 | else if (hdmi->hdmi_data.enc_color_depth == 16) |
| 440 | color_format = 0x07; |
| 441 | else |
| 442 | return; |
| 443 | } else if (hdmi->hdmi_data.enc_in_format == YCBCR444) { |
| 444 | if (hdmi->hdmi_data.enc_color_depth == 8) |
| 445 | color_format = 0x09; |
| 446 | else if (hdmi->hdmi_data.enc_color_depth == 10) |
| 447 | color_format = 0x0B; |
| 448 | else if (hdmi->hdmi_data.enc_color_depth == 12) |
| 449 | color_format = 0x0D; |
| 450 | else if (hdmi->hdmi_data.enc_color_depth == 16) |
| 451 | color_format = 0x0F; |
| 452 | else |
| 453 | return; |
| 454 | } else if (hdmi->hdmi_data.enc_in_format == YCBCR422_8BITS) { |
| 455 | if (hdmi->hdmi_data.enc_color_depth == 8) |
| 456 | color_format = 0x16; |
| 457 | else if (hdmi->hdmi_data.enc_color_depth == 10) |
| 458 | color_format = 0x14; |
| 459 | else if (hdmi->hdmi_data.enc_color_depth == 12) |
| 460 | color_format = 0x12; |
| 461 | else |
| 462 | return; |
| 463 | } |
| 464 | |
| 465 | val = HDMI_TX_INVID0_INTERNAL_DE_GENERATOR_DISABLE | |
| 466 | ((color_format << HDMI_TX_INVID0_VIDEO_MAPPING_OFFSET) & |
| 467 | HDMI_TX_INVID0_VIDEO_MAPPING_MASK); |
| 468 | hdmi_writeb(hdmi, val, HDMI_TX_INVID0); |
| 469 | |
| 470 | /* Enable TX stuffing: When DE is inactive, fix the output data to 0 */ |
| 471 | val = HDMI_TX_INSTUFFING_BDBDATA_STUFFING_ENABLE | |
| 472 | HDMI_TX_INSTUFFING_RCRDATA_STUFFING_ENABLE | |
| 473 | HDMI_TX_INSTUFFING_GYDATA_STUFFING_ENABLE; |
| 474 | hdmi_writeb(hdmi, val, HDMI_TX_INSTUFFING); |
| 475 | hdmi_writeb(hdmi, 0x0, HDMI_TX_GYDATA0); |
| 476 | hdmi_writeb(hdmi, 0x0, HDMI_TX_GYDATA1); |
| 477 | hdmi_writeb(hdmi, 0x0, HDMI_TX_RCRDATA0); |
| 478 | hdmi_writeb(hdmi, 0x0, HDMI_TX_RCRDATA1); |
| 479 | hdmi_writeb(hdmi, 0x0, HDMI_TX_BCBDATA0); |
| 480 | hdmi_writeb(hdmi, 0x0, HDMI_TX_BCBDATA1); |
| 481 | } |
| 482 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 483 | static int is_color_space_conversion(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 484 | { |
Fabio Estevam | ba92b22 | 2014-02-06 10:12:03 -0200 | [diff] [blame] | 485 | return hdmi->hdmi_data.enc_in_format != hdmi->hdmi_data.enc_out_format; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 486 | } |
| 487 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 488 | static int is_color_space_decimation(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 489 | { |
Fabio Estevam | ba92b22 | 2014-02-06 10:12:03 -0200 | [diff] [blame] | 490 | if (hdmi->hdmi_data.enc_out_format != YCBCR422_8BITS) |
| 491 | return 0; |
| 492 | if (hdmi->hdmi_data.enc_in_format == RGB || |
| 493 | hdmi->hdmi_data.enc_in_format == YCBCR444) |
| 494 | return 1; |
| 495 | return 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 496 | } |
| 497 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 498 | static int is_color_space_interpolation(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 499 | { |
Fabio Estevam | ba92b22 | 2014-02-06 10:12:03 -0200 | [diff] [blame] | 500 | if (hdmi->hdmi_data.enc_in_format != YCBCR422_8BITS) |
| 501 | return 0; |
| 502 | if (hdmi->hdmi_data.enc_out_format == RGB || |
| 503 | hdmi->hdmi_data.enc_out_format == YCBCR444) |
| 504 | return 1; |
| 505 | return 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 506 | } |
| 507 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 508 | static void dw_hdmi_update_csc_coeffs(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 509 | { |
| 510 | const u16 (*csc_coeff)[3][4] = &csc_coeff_default; |
Russell King | c082f9d | 2013-11-04 12:10:40 +0000 | [diff] [blame] | 511 | unsigned i; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 512 | u32 csc_scale = 1; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 513 | |
| 514 | if (is_color_space_conversion(hdmi)) { |
| 515 | if (hdmi->hdmi_data.enc_out_format == RGB) { |
Gulsah Kose | 256a38b | 2014-03-09 20:11:07 +0200 | [diff] [blame] | 516 | if (hdmi->hdmi_data.colorimetry == |
| 517 | HDMI_COLORIMETRY_ITU_601) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 518 | csc_coeff = &csc_coeff_rgb_out_eitu601; |
| 519 | else |
| 520 | csc_coeff = &csc_coeff_rgb_out_eitu709; |
| 521 | } else if (hdmi->hdmi_data.enc_in_format == RGB) { |
Gulsah Kose | 256a38b | 2014-03-09 20:11:07 +0200 | [diff] [blame] | 522 | if (hdmi->hdmi_data.colorimetry == |
| 523 | HDMI_COLORIMETRY_ITU_601) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 524 | csc_coeff = &csc_coeff_rgb_in_eitu601; |
| 525 | else |
| 526 | csc_coeff = &csc_coeff_rgb_in_eitu709; |
| 527 | csc_scale = 0; |
| 528 | } |
| 529 | } |
| 530 | |
Russell King | c082f9d | 2013-11-04 12:10:40 +0000 | [diff] [blame] | 531 | /* The CSC registers are sequential, alternating MSB then LSB */ |
| 532 | for (i = 0; i < ARRAY_SIZE(csc_coeff_default[0]); i++) { |
| 533 | u16 coeff_a = (*csc_coeff)[0][i]; |
| 534 | u16 coeff_b = (*csc_coeff)[1][i]; |
| 535 | u16 coeff_c = (*csc_coeff)[2][i]; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 536 | |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 537 | hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * 2); |
Russell King | c082f9d | 2013-11-04 12:10:40 +0000 | [diff] [blame] | 538 | hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2); |
| 539 | hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2); |
| 540 | hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2); |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 541 | hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * 2); |
Russell King | c082f9d | 2013-11-04 12:10:40 +0000 | [diff] [blame] | 542 | hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2); |
| 543 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 544 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 545 | hdmi_modb(hdmi, csc_scale, HDMI_CSC_SCALE_CSCSCALE_MASK, |
| 546 | HDMI_CSC_SCALE); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 547 | } |
| 548 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 549 | static void hdmi_video_csc(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 550 | { |
| 551 | int color_depth = 0; |
| 552 | int interpolation = HDMI_CSC_CFG_INTMODE_DISABLE; |
| 553 | int decimation = 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 554 | |
| 555 | /* YCC422 interpolation to 444 mode */ |
| 556 | if (is_color_space_interpolation(hdmi)) |
| 557 | interpolation = HDMI_CSC_CFG_INTMODE_CHROMA_INT_FORMULA1; |
| 558 | else if (is_color_space_decimation(hdmi)) |
| 559 | decimation = HDMI_CSC_CFG_DECMODE_CHROMA_INT_FORMULA3; |
| 560 | |
| 561 | if (hdmi->hdmi_data.enc_color_depth == 8) |
| 562 | color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_24BPP; |
| 563 | else if (hdmi->hdmi_data.enc_color_depth == 10) |
| 564 | color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_30BPP; |
| 565 | else if (hdmi->hdmi_data.enc_color_depth == 12) |
| 566 | color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_36BPP; |
| 567 | else if (hdmi->hdmi_data.enc_color_depth == 16) |
| 568 | color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_48BPP; |
| 569 | else |
| 570 | return; |
| 571 | |
| 572 | /* Configure the CSC registers */ |
| 573 | hdmi_writeb(hdmi, interpolation | decimation, HDMI_CSC_CFG); |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 574 | hdmi_modb(hdmi, color_depth, HDMI_CSC_SCALE_CSC_COLORDE_PTH_MASK, |
| 575 | HDMI_CSC_SCALE); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 576 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 577 | dw_hdmi_update_csc_coeffs(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | /* |
| 581 | * HDMI video packetizer is used to packetize the data. |
| 582 | * for example, if input is YCC422 mode or repeater is used, |
| 583 | * data should be repacked this module can be bypassed. |
| 584 | */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 585 | static void hdmi_video_packetize(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 586 | { |
| 587 | unsigned int color_depth = 0; |
| 588 | unsigned int remap_size = HDMI_VP_REMAP_YCC422_16bit; |
| 589 | unsigned int output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_PP; |
| 590 | struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 591 | u8 val, vp_conf; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 592 | |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 593 | if (hdmi_data->enc_out_format == RGB || |
| 594 | hdmi_data->enc_out_format == YCBCR444) { |
| 595 | if (!hdmi_data->enc_color_depth) { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 596 | output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 597 | } else if (hdmi_data->enc_color_depth == 8) { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 598 | color_depth = 4; |
| 599 | output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 600 | } else if (hdmi_data->enc_color_depth == 10) { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 601 | color_depth = 5; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 602 | } else if (hdmi_data->enc_color_depth == 12) { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 603 | color_depth = 6; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 604 | } else if (hdmi_data->enc_color_depth == 16) { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 605 | color_depth = 7; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 606 | } else { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 607 | return; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 608 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 609 | } else if (hdmi_data->enc_out_format == YCBCR422_8BITS) { |
| 610 | if (!hdmi_data->enc_color_depth || |
| 611 | hdmi_data->enc_color_depth == 8) |
| 612 | remap_size = HDMI_VP_REMAP_YCC422_16bit; |
| 613 | else if (hdmi_data->enc_color_depth == 10) |
| 614 | remap_size = HDMI_VP_REMAP_YCC422_20bit; |
| 615 | else if (hdmi_data->enc_color_depth == 12) |
| 616 | remap_size = HDMI_VP_REMAP_YCC422_24bit; |
| 617 | else |
| 618 | return; |
| 619 | output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 620 | } else { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 621 | return; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 622 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 623 | |
| 624 | /* set the packetizer registers */ |
| 625 | val = ((color_depth << HDMI_VP_PR_CD_COLOR_DEPTH_OFFSET) & |
| 626 | HDMI_VP_PR_CD_COLOR_DEPTH_MASK) | |
| 627 | ((hdmi_data->pix_repet_factor << |
| 628 | HDMI_VP_PR_CD_DESIRED_PR_FACTOR_OFFSET) & |
| 629 | HDMI_VP_PR_CD_DESIRED_PR_FACTOR_MASK); |
| 630 | hdmi_writeb(hdmi, val, HDMI_VP_PR_CD); |
| 631 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 632 | hdmi_modb(hdmi, HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE, |
| 633 | HDMI_VP_STUFF_PR_STUFFING_MASK, HDMI_VP_STUFF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 634 | |
| 635 | /* Data from pixel repeater block */ |
| 636 | if (hdmi_data->pix_repet_factor > 1) { |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 637 | vp_conf = HDMI_VP_CONF_PR_EN_ENABLE | |
| 638 | HDMI_VP_CONF_BYPASS_SELECT_PIX_REPEATER; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 639 | } else { /* data from packetizer block */ |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 640 | vp_conf = HDMI_VP_CONF_PR_EN_DISABLE | |
| 641 | HDMI_VP_CONF_BYPASS_SELECT_VID_PACKETIZER; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 642 | } |
| 643 | |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 644 | hdmi_modb(hdmi, vp_conf, |
| 645 | HDMI_VP_CONF_PR_EN_MASK | |
| 646 | HDMI_VP_CONF_BYPASS_SELECT_MASK, HDMI_VP_CONF); |
| 647 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 648 | hdmi_modb(hdmi, 1 << HDMI_VP_STUFF_IDEFAULT_PHASE_OFFSET, |
| 649 | HDMI_VP_STUFF_IDEFAULT_PHASE_MASK, HDMI_VP_STUFF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 650 | |
| 651 | hdmi_writeb(hdmi, remap_size, HDMI_VP_REMAP); |
| 652 | |
| 653 | if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_PP) { |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 654 | vp_conf = HDMI_VP_CONF_BYPASS_EN_DISABLE | |
| 655 | HDMI_VP_CONF_PP_EN_ENABLE | |
| 656 | HDMI_VP_CONF_YCC422_EN_DISABLE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 657 | } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422) { |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 658 | vp_conf = HDMI_VP_CONF_BYPASS_EN_DISABLE | |
| 659 | HDMI_VP_CONF_PP_EN_DISABLE | |
| 660 | HDMI_VP_CONF_YCC422_EN_ENABLE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 661 | } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS) { |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 662 | vp_conf = HDMI_VP_CONF_BYPASS_EN_ENABLE | |
| 663 | HDMI_VP_CONF_PP_EN_DISABLE | |
| 664 | HDMI_VP_CONF_YCC422_EN_DISABLE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 665 | } else { |
| 666 | return; |
| 667 | } |
| 668 | |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 669 | hdmi_modb(hdmi, vp_conf, |
| 670 | HDMI_VP_CONF_BYPASS_EN_MASK | HDMI_VP_CONF_PP_EN_ENMASK | |
| 671 | HDMI_VP_CONF_YCC422_EN_MASK, HDMI_VP_CONF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 672 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 673 | hdmi_modb(hdmi, HDMI_VP_STUFF_PP_STUFFING_STUFFING_MODE | |
| 674 | HDMI_VP_STUFF_YCC422_STUFFING_STUFFING_MODE, |
| 675 | HDMI_VP_STUFF_PP_STUFFING_MASK | |
| 676 | HDMI_VP_STUFF_YCC422_STUFFING_MASK, HDMI_VP_STUFF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 677 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 678 | hdmi_modb(hdmi, output_select, HDMI_VP_CONF_OUTPUT_SELECTOR_MASK, |
| 679 | HDMI_VP_CONF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 680 | } |
| 681 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 682 | static inline void hdmi_phy_test_clear(struct dw_hdmi *hdmi, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 683 | unsigned char bit) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 684 | { |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 685 | hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTCLR_OFFSET, |
| 686 | HDMI_PHY_TST0_TSTCLR_MASK, HDMI_PHY_TST0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 687 | } |
| 688 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 689 | static inline void hdmi_phy_test_enable(struct dw_hdmi *hdmi, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 690 | unsigned char bit) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 691 | { |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 692 | hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTEN_OFFSET, |
| 693 | HDMI_PHY_TST0_TSTEN_MASK, HDMI_PHY_TST0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 694 | } |
| 695 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 696 | static inline void hdmi_phy_test_clock(struct dw_hdmi *hdmi, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 697 | unsigned char bit) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 698 | { |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 699 | hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTCLK_OFFSET, |
| 700 | HDMI_PHY_TST0_TSTCLK_MASK, HDMI_PHY_TST0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 701 | } |
| 702 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 703 | static inline void hdmi_phy_test_din(struct dw_hdmi *hdmi, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 704 | unsigned char bit) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 705 | { |
| 706 | hdmi_writeb(hdmi, bit, HDMI_PHY_TST1); |
| 707 | } |
| 708 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 709 | static inline void hdmi_phy_test_dout(struct dw_hdmi *hdmi, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 710 | unsigned char bit) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 711 | { |
| 712 | hdmi_writeb(hdmi, bit, HDMI_PHY_TST2); |
| 713 | } |
| 714 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 715 | static bool hdmi_phy_wait_i2c_done(struct dw_hdmi *hdmi, int msec) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 716 | { |
Andy Yan | a4d3b8b | 2014-12-05 14:31:09 +0800 | [diff] [blame] | 717 | u32 val; |
| 718 | |
| 719 | while ((val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 720 | if (msec-- == 0) |
| 721 | return false; |
Emil Renner Berthing | 0e6bcf3 | 2014-03-30 00:21:21 +0100 | [diff] [blame] | 722 | udelay(1000); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 723 | } |
Andy Yan | a4d3b8b | 2014-12-05 14:31:09 +0800 | [diff] [blame] | 724 | hdmi_writeb(hdmi, val, HDMI_IH_I2CMPHY_STAT0); |
| 725 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 726 | return true; |
| 727 | } |
| 728 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 729 | static void __hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 730 | unsigned char addr) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 731 | { |
| 732 | hdmi_writeb(hdmi, 0xFF, HDMI_IH_I2CMPHY_STAT0); |
| 733 | hdmi_writeb(hdmi, addr, HDMI_PHY_I2CM_ADDRESS_ADDR); |
| 734 | hdmi_writeb(hdmi, (unsigned char)(data >> 8), |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 735 | HDMI_PHY_I2CM_DATAO_1_ADDR); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 736 | hdmi_writeb(hdmi, (unsigned char)(data >> 0), |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 737 | HDMI_PHY_I2CM_DATAO_0_ADDR); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 738 | hdmi_writeb(hdmi, HDMI_PHY_I2CM_OPERATION_ADDR_WRITE, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 739 | HDMI_PHY_I2CM_OPERATION_ADDR); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 740 | hdmi_phy_wait_i2c_done(hdmi, 1000); |
| 741 | } |
| 742 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 743 | static int hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 744 | unsigned char addr) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 745 | { |
| 746 | __hdmi_phy_i2c_write(hdmi, data, addr); |
| 747 | return 0; |
| 748 | } |
| 749 | |
Russell King | 2fada10 | 2015-07-28 12:21:34 +0100 | [diff] [blame] | 750 | static void dw_hdmi_phy_enable_powerdown(struct dw_hdmi *hdmi, bool enable) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 751 | { |
Russell King | 2fada10 | 2015-07-28 12:21:34 +0100 | [diff] [blame] | 752 | hdmi_mask_writeb(hdmi, !enable, HDMI_PHY_CONF0, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 753 | HDMI_PHY_CONF0_PDZ_OFFSET, |
| 754 | HDMI_PHY_CONF0_PDZ_MASK); |
| 755 | } |
| 756 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 757 | static void dw_hdmi_phy_enable_tmds(struct dw_hdmi *hdmi, u8 enable) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 758 | { |
| 759 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 760 | HDMI_PHY_CONF0_ENTMDS_OFFSET, |
| 761 | HDMI_PHY_CONF0_ENTMDS_MASK); |
| 762 | } |
| 763 | |
Andy Yan | d346c14 | 2014-12-05 14:31:53 +0800 | [diff] [blame] | 764 | static void dw_hdmi_phy_enable_spare(struct dw_hdmi *hdmi, u8 enable) |
| 765 | { |
| 766 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 767 | HDMI_PHY_CONF0_SPARECTRL_OFFSET, |
| 768 | HDMI_PHY_CONF0_SPARECTRL_MASK); |
| 769 | } |
| 770 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 771 | static void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 772 | { |
| 773 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 774 | HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET, |
| 775 | HDMI_PHY_CONF0_GEN2_PDDQ_MASK); |
| 776 | } |
| 777 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 778 | static void dw_hdmi_phy_gen2_txpwron(struct dw_hdmi *hdmi, u8 enable) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 779 | { |
| 780 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 781 | HDMI_PHY_CONF0_GEN2_TXPWRON_OFFSET, |
| 782 | HDMI_PHY_CONF0_GEN2_TXPWRON_MASK); |
| 783 | } |
| 784 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 785 | static void dw_hdmi_phy_sel_data_en_pol(struct dw_hdmi *hdmi, u8 enable) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 786 | { |
| 787 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 788 | HDMI_PHY_CONF0_SELDATAENPOL_OFFSET, |
| 789 | HDMI_PHY_CONF0_SELDATAENPOL_MASK); |
| 790 | } |
| 791 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 792 | static void dw_hdmi_phy_sel_interface_control(struct dw_hdmi *hdmi, u8 enable) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 793 | { |
| 794 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 795 | HDMI_PHY_CONF0_SELDIPIF_OFFSET, |
| 796 | HDMI_PHY_CONF0_SELDIPIF_MASK); |
| 797 | } |
| 798 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 799 | static int hdmi_phy_configure(struct dw_hdmi *hdmi, unsigned char prep, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 800 | unsigned char res, int cscon) |
| 801 | { |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 802 | unsigned res_idx; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 803 | u8 val, msec; |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 804 | const struct dw_hdmi_plat_data *pdata = hdmi->plat_data; |
| 805 | const struct dw_hdmi_mpll_config *mpll_config = pdata->mpll_cfg; |
| 806 | const struct dw_hdmi_curr_ctrl *curr_ctrl = pdata->cur_ctr; |
| 807 | const struct dw_hdmi_phy_config *phy_config = pdata->phy_config; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 808 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 809 | if (prep) |
| 810 | return -EINVAL; |
Russell King | 3e46f15 | 2013-11-04 11:24:00 +0000 | [diff] [blame] | 811 | |
| 812 | switch (res) { |
| 813 | case 0: /* color resolution 0 is 8 bit colour depth */ |
| 814 | case 8: |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 815 | res_idx = DW_HDMI_RES_8; |
Russell King | 3e46f15 | 2013-11-04 11:24:00 +0000 | [diff] [blame] | 816 | break; |
| 817 | case 10: |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 818 | res_idx = DW_HDMI_RES_10; |
Russell King | 3e46f15 | 2013-11-04 11:24:00 +0000 | [diff] [blame] | 819 | break; |
| 820 | case 12: |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 821 | res_idx = DW_HDMI_RES_12; |
Russell King | 3e46f15 | 2013-11-04 11:24:00 +0000 | [diff] [blame] | 822 | break; |
| 823 | default: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 824 | return -EINVAL; |
Russell King | 3e46f15 | 2013-11-04 11:24:00 +0000 | [diff] [blame] | 825 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 826 | |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 827 | /* PLL/MPLL Cfg - always match on final entry */ |
| 828 | for (; mpll_config->mpixelclock != ~0UL; mpll_config++) |
| 829 | if (hdmi->hdmi_data.video_mode.mpixelclock <= |
| 830 | mpll_config->mpixelclock) |
| 831 | break; |
| 832 | |
| 833 | for (; curr_ctrl->mpixelclock != ~0UL; curr_ctrl++) |
| 834 | if (hdmi->hdmi_data.video_mode.mpixelclock <= |
| 835 | curr_ctrl->mpixelclock) |
| 836 | break; |
| 837 | |
| 838 | for (; phy_config->mpixelclock != ~0UL; phy_config++) |
| 839 | if (hdmi->hdmi_data.video_mode.mpixelclock <= |
| 840 | phy_config->mpixelclock) |
| 841 | break; |
| 842 | |
| 843 | if (mpll_config->mpixelclock == ~0UL || |
| 844 | curr_ctrl->mpixelclock == ~0UL || |
| 845 | phy_config->mpixelclock == ~0UL) { |
| 846 | dev_err(hdmi->dev, "Pixel clock %d - unsupported by HDMI\n", |
| 847 | hdmi->hdmi_data.video_mode.mpixelclock); |
| 848 | return -EINVAL; |
| 849 | } |
| 850 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 851 | /* Enable csc path */ |
| 852 | if (cscon) |
| 853 | val = HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_IN_PATH; |
| 854 | else |
| 855 | val = HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_BYPASS; |
| 856 | |
| 857 | hdmi_writeb(hdmi, val, HDMI_MC_FLOWCTRL); |
| 858 | |
| 859 | /* gen2 tx power off */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 860 | dw_hdmi_phy_gen2_txpwron(hdmi, 0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 861 | |
| 862 | /* gen2 pddq */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 863 | dw_hdmi_phy_gen2_pddq(hdmi, 1); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 864 | |
| 865 | /* PHY reset */ |
| 866 | hdmi_writeb(hdmi, HDMI_MC_PHYRSTZ_DEASSERT, HDMI_MC_PHYRSTZ); |
| 867 | hdmi_writeb(hdmi, HDMI_MC_PHYRSTZ_ASSERT, HDMI_MC_PHYRSTZ); |
| 868 | |
| 869 | hdmi_writeb(hdmi, HDMI_MC_HEACPHY_RST_ASSERT, HDMI_MC_HEACPHY_RST); |
| 870 | |
| 871 | hdmi_phy_test_clear(hdmi, 1); |
| 872 | hdmi_writeb(hdmi, HDMI_PHY_I2CM_SLAVE_ADDR_PHY_GEN2, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 873 | HDMI_PHY_I2CM_SLAVE_ADDR); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 874 | hdmi_phy_test_clear(hdmi, 0); |
| 875 | |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 876 | hdmi_phy_i2c_write(hdmi, mpll_config->res[res_idx].cpce, 0x06); |
| 877 | hdmi_phy_i2c_write(hdmi, mpll_config->res[res_idx].gmp, 0x15); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 878 | |
Russell King | 3e46f15 | 2013-11-04 11:24:00 +0000 | [diff] [blame] | 879 | /* CURRCTRL */ |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 880 | hdmi_phy_i2c_write(hdmi, curr_ctrl->curr[res_idx], 0x10); |
Russell King | 3e46f15 | 2013-11-04 11:24:00 +0000 | [diff] [blame] | 881 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 882 | hdmi_phy_i2c_write(hdmi, 0x0000, 0x13); /* PLLPHBYCTRL */ |
| 883 | hdmi_phy_i2c_write(hdmi, 0x0006, 0x17); |
Andy Yan | aaa757a | 2014-12-05 14:25:50 +0800 | [diff] [blame] | 884 | |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 885 | hdmi_phy_i2c_write(hdmi, phy_config->term, 0x19); /* TXTERM */ |
| 886 | hdmi_phy_i2c_write(hdmi, phy_config->sym_ctr, 0x09); /* CKSYMTXCTRL */ |
| 887 | hdmi_phy_i2c_write(hdmi, phy_config->vlev_ctr, 0x0E); /* VLEVCTRL */ |
Yakir Yang | 034705a | 2015-03-31 23:56:10 -0400 | [diff] [blame] | 888 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 889 | /* REMOVE CLK TERM */ |
| 890 | hdmi_phy_i2c_write(hdmi, 0x8000, 0x05); /* CKCALCTRL */ |
| 891 | |
Russell King | 2fada10 | 2015-07-28 12:21:34 +0100 | [diff] [blame] | 892 | dw_hdmi_phy_enable_powerdown(hdmi, false); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 893 | |
| 894 | /* toggle TMDS enable */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 895 | dw_hdmi_phy_enable_tmds(hdmi, 0); |
| 896 | dw_hdmi_phy_enable_tmds(hdmi, 1); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 897 | |
| 898 | /* gen2 tx power on */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 899 | dw_hdmi_phy_gen2_txpwron(hdmi, 1); |
| 900 | dw_hdmi_phy_gen2_pddq(hdmi, 0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 901 | |
Andy Yan | 12b9f20 | 2015-01-07 15:48:27 +0800 | [diff] [blame] | 902 | if (hdmi->dev_type == RK3288_HDMI) |
| 903 | dw_hdmi_phy_enable_spare(hdmi, 1); |
| 904 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 905 | /*Wait for PHY PLL lock */ |
| 906 | msec = 5; |
| 907 | do { |
| 908 | val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK; |
| 909 | if (!val) |
| 910 | break; |
| 911 | |
| 912 | if (msec == 0) { |
| 913 | dev_err(hdmi->dev, "PHY PLL not locked\n"); |
| 914 | return -ETIMEDOUT; |
| 915 | } |
| 916 | |
| 917 | udelay(1000); |
| 918 | msec--; |
| 919 | } while (1); |
| 920 | |
| 921 | return 0; |
| 922 | } |
| 923 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 924 | static int dw_hdmi_phy_init(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 925 | { |
| 926 | int i, ret; |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 927 | bool cscon; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 928 | |
| 929 | /*check csc whether needed activated in HDMI mode */ |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 930 | cscon = hdmi->sink_is_hdmi && is_color_space_conversion(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 931 | |
| 932 | /* HDMI Phy spec says to do the phy initialization sequence twice */ |
| 933 | for (i = 0; i < 2; i++) { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 934 | dw_hdmi_phy_sel_data_en_pol(hdmi, 1); |
| 935 | dw_hdmi_phy_sel_interface_control(hdmi, 0); |
| 936 | dw_hdmi_phy_enable_tmds(hdmi, 0); |
Russell King | 2fada10 | 2015-07-28 12:21:34 +0100 | [diff] [blame] | 937 | dw_hdmi_phy_enable_powerdown(hdmi, true); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 938 | |
| 939 | /* Enable CSC */ |
| 940 | ret = hdmi_phy_configure(hdmi, 0, 8, cscon); |
| 941 | if (ret) |
| 942 | return ret; |
| 943 | } |
| 944 | |
| 945 | hdmi->phy_enabled = true; |
| 946 | return 0; |
| 947 | } |
| 948 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 949 | static void hdmi_tx_hdcp_config(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 950 | { |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 951 | u8 de; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 952 | |
| 953 | if (hdmi->hdmi_data.video_mode.mdataenablepolarity) |
| 954 | de = HDMI_A_VIDPOLCFG_DATAENPOL_ACTIVE_HIGH; |
| 955 | else |
| 956 | de = HDMI_A_VIDPOLCFG_DATAENPOL_ACTIVE_LOW; |
| 957 | |
| 958 | /* disable rx detect */ |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 959 | hdmi_modb(hdmi, HDMI_A_HDCPCFG0_RXDETECT_DISABLE, |
| 960 | HDMI_A_HDCPCFG0_RXDETECT_MASK, HDMI_A_HDCPCFG0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 961 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 962 | hdmi_modb(hdmi, de, HDMI_A_VIDPOLCFG_DATAENPOL_MASK, HDMI_A_VIDPOLCFG); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 963 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 964 | hdmi_modb(hdmi, HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_DISABLE, |
| 965 | HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_MASK, HDMI_A_HDCPCFG1); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 966 | } |
| 967 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 968 | static void hdmi_config_AVI(struct dw_hdmi *hdmi, struct drm_display_mode *mode) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 969 | { |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 970 | struct hdmi_avi_infoframe frame; |
| 971 | u8 val; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 972 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 973 | /* Initialise info frame from DRM mode */ |
| 974 | drm_hdmi_avi_infoframe_from_display_mode(&frame, mode); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 975 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 976 | if (hdmi->hdmi_data.enc_out_format == YCBCR444) |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 977 | frame.colorspace = HDMI_COLORSPACE_YUV444; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 978 | else if (hdmi->hdmi_data.enc_out_format == YCBCR422_8BITS) |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 979 | frame.colorspace = HDMI_COLORSPACE_YUV422; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 980 | else |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 981 | frame.colorspace = HDMI_COLORSPACE_RGB; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 982 | |
| 983 | /* Set up colorimetry */ |
| 984 | if (hdmi->hdmi_data.enc_out_format == XVYCC444) { |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 985 | frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; |
Sachin Kamat | 5a819ed | 2014-01-28 10:33:16 +0530 | [diff] [blame] | 986 | if (hdmi->hdmi_data.colorimetry == HDMI_COLORIMETRY_ITU_601) |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 987 | frame.extended_colorimetry = |
| 988 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; |
Sachin Kamat | 5a819ed | 2014-01-28 10:33:16 +0530 | [diff] [blame] | 989 | else /*hdmi->hdmi_data.colorimetry == HDMI_COLORIMETRY_ITU_709*/ |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 990 | frame.extended_colorimetry = |
| 991 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_709; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 992 | } else if (hdmi->hdmi_data.enc_out_format != RGB) { |
Russell King | d083c31 | 2015-03-27 23:14:16 +0000 | [diff] [blame] | 993 | frame.colorimetry = hdmi->hdmi_data.colorimetry; |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 994 | frame.extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 995 | } else { /* Carries no data */ |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 996 | frame.colorimetry = HDMI_COLORIMETRY_NONE; |
| 997 | frame.extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 998 | } |
| 999 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1000 | frame.scan_mode = HDMI_SCAN_MODE_NONE; |
| 1001 | |
| 1002 | /* |
| 1003 | * The Designware IP uses a different byte format from standard |
| 1004 | * AVI info frames, though generally the bits are in the correct |
| 1005 | * bytes. |
| 1006 | */ |
| 1007 | |
| 1008 | /* |
| 1009 | * AVI data byte 1 differences: Colorspace in bits 4,5 rather than 5,6, |
| 1010 | * active aspect present in bit 6 rather than 4. |
| 1011 | */ |
| 1012 | val = (frame.colorspace & 3) << 4 | (frame.scan_mode & 0x3); |
| 1013 | if (frame.active_aspect & 15) |
| 1014 | val |= HDMI_FC_AVICONF0_ACTIVE_FMT_INFO_PRESENT; |
| 1015 | if (frame.top_bar || frame.bottom_bar) |
| 1016 | val |= HDMI_FC_AVICONF0_BAR_DATA_HORIZ_BAR; |
| 1017 | if (frame.left_bar || frame.right_bar) |
| 1018 | val |= HDMI_FC_AVICONF0_BAR_DATA_VERT_BAR; |
| 1019 | hdmi_writeb(hdmi, val, HDMI_FC_AVICONF0); |
| 1020 | |
| 1021 | /* AVI data byte 2 differences: none */ |
| 1022 | val = ((frame.colorimetry & 0x3) << 6) | |
| 1023 | ((frame.picture_aspect & 0x3) << 4) | |
| 1024 | (frame.active_aspect & 0xf); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1025 | hdmi_writeb(hdmi, val, HDMI_FC_AVICONF1); |
| 1026 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1027 | /* AVI data byte 3 differences: none */ |
| 1028 | val = ((frame.extended_colorimetry & 0x7) << 4) | |
| 1029 | ((frame.quantization_range & 0x3) << 2) | |
| 1030 | (frame.nups & 0x3); |
| 1031 | if (frame.itc) |
| 1032 | val |= HDMI_FC_AVICONF2_IT_CONTENT_VALID; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1033 | hdmi_writeb(hdmi, val, HDMI_FC_AVICONF2); |
| 1034 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1035 | /* AVI data byte 4 differences: none */ |
| 1036 | val = frame.video_code & 0x7f; |
| 1037 | hdmi_writeb(hdmi, val, HDMI_FC_AVIVID); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1038 | |
| 1039 | /* AVI Data Byte 5- set up input and output pixel repetition */ |
| 1040 | val = (((hdmi->hdmi_data.video_mode.mpixelrepetitioninput + 1) << |
| 1041 | HDMI_FC_PRCONF_INCOMING_PR_FACTOR_OFFSET) & |
| 1042 | HDMI_FC_PRCONF_INCOMING_PR_FACTOR_MASK) | |
| 1043 | ((hdmi->hdmi_data.video_mode.mpixelrepetitionoutput << |
| 1044 | HDMI_FC_PRCONF_OUTPUT_PR_FACTOR_OFFSET) & |
| 1045 | HDMI_FC_PRCONF_OUTPUT_PR_FACTOR_MASK); |
| 1046 | hdmi_writeb(hdmi, val, HDMI_FC_PRCONF); |
| 1047 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1048 | /* |
| 1049 | * AVI data byte 5 differences: content type in 0,1 rather than 4,5, |
| 1050 | * ycc range in bits 2,3 rather than 6,7 |
| 1051 | */ |
| 1052 | val = ((frame.ycc_quantization_range & 0x3) << 2) | |
| 1053 | (frame.content_type & 0x3); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1054 | hdmi_writeb(hdmi, val, HDMI_FC_AVICONF3); |
| 1055 | |
| 1056 | /* AVI Data Bytes 6-13 */ |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1057 | hdmi_writeb(hdmi, frame.top_bar & 0xff, HDMI_FC_AVIETB0); |
| 1058 | hdmi_writeb(hdmi, (frame.top_bar >> 8) & 0xff, HDMI_FC_AVIETB1); |
| 1059 | hdmi_writeb(hdmi, frame.bottom_bar & 0xff, HDMI_FC_AVISBB0); |
| 1060 | hdmi_writeb(hdmi, (frame.bottom_bar >> 8) & 0xff, HDMI_FC_AVISBB1); |
| 1061 | hdmi_writeb(hdmi, frame.left_bar & 0xff, HDMI_FC_AVIELB0); |
| 1062 | hdmi_writeb(hdmi, (frame.left_bar >> 8) & 0xff, HDMI_FC_AVIELB1); |
| 1063 | hdmi_writeb(hdmi, frame.right_bar & 0xff, HDMI_FC_AVISRB0); |
| 1064 | hdmi_writeb(hdmi, (frame.right_bar >> 8) & 0xff, HDMI_FC_AVISRB1); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1065 | } |
| 1066 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1067 | static void hdmi_av_composer(struct dw_hdmi *hdmi, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1068 | const struct drm_display_mode *mode) |
| 1069 | { |
| 1070 | u8 inv_val; |
| 1071 | struct hdmi_vmode *vmode = &hdmi->hdmi_data.video_mode; |
| 1072 | int hblank, vblank, h_de_hs, v_de_vs, hsync_len, vsync_len; |
Russell King | e80b9f4 | 2015-07-21 11:08:25 +0100 | [diff] [blame] | 1073 | unsigned int vdisplay; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1074 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1075 | vmode->mpixelclock = mode->clock * 1000; |
| 1076 | |
| 1077 | dev_dbg(hdmi->dev, "final pixclk = %d\n", vmode->mpixelclock); |
| 1078 | |
| 1079 | /* Set up HDMI_FC_INVIDCONF */ |
| 1080 | inv_val = (hdmi->hdmi_data.hdcp_enable ? |
| 1081 | HDMI_FC_INVIDCONF_HDCP_KEEPOUT_ACTIVE : |
| 1082 | HDMI_FC_INVIDCONF_HDCP_KEEPOUT_INACTIVE); |
| 1083 | |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1084 | inv_val |= mode->flags & DRM_MODE_FLAG_PVSYNC ? |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1085 | HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_HIGH : |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1086 | HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_LOW; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1087 | |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1088 | inv_val |= mode->flags & DRM_MODE_FLAG_PHSYNC ? |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1089 | HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_HIGH : |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1090 | HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_LOW; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1091 | |
| 1092 | inv_val |= (vmode->mdataenablepolarity ? |
| 1093 | HDMI_FC_INVIDCONF_DE_IN_POLARITY_ACTIVE_HIGH : |
| 1094 | HDMI_FC_INVIDCONF_DE_IN_POLARITY_ACTIVE_LOW); |
| 1095 | |
| 1096 | if (hdmi->vic == 39) |
| 1097 | inv_val |= HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_HIGH; |
| 1098 | else |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1099 | inv_val |= mode->flags & DRM_MODE_FLAG_INTERLACE ? |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1100 | HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_HIGH : |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1101 | HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_LOW; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1102 | |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1103 | inv_val |= mode->flags & DRM_MODE_FLAG_INTERLACE ? |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1104 | HDMI_FC_INVIDCONF_IN_I_P_INTERLACED : |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1105 | HDMI_FC_INVIDCONF_IN_I_P_PROGRESSIVE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1106 | |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 1107 | inv_val |= hdmi->sink_is_hdmi ? |
| 1108 | HDMI_FC_INVIDCONF_DVI_MODEZ_HDMI_MODE : |
| 1109 | HDMI_FC_INVIDCONF_DVI_MODEZ_DVI_MODE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1110 | |
| 1111 | hdmi_writeb(hdmi, inv_val, HDMI_FC_INVIDCONF); |
| 1112 | |
Russell King | e80b9f4 | 2015-07-21 11:08:25 +0100 | [diff] [blame] | 1113 | vdisplay = mode->vdisplay; |
| 1114 | vblank = mode->vtotal - mode->vdisplay; |
| 1115 | v_de_vs = mode->vsync_start - mode->vdisplay; |
| 1116 | vsync_len = mode->vsync_end - mode->vsync_start; |
| 1117 | |
| 1118 | /* |
| 1119 | * When we're setting an interlaced mode, we need |
| 1120 | * to adjust the vertical timing to suit. |
| 1121 | */ |
| 1122 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
| 1123 | vdisplay /= 2; |
| 1124 | vblank /= 2; |
| 1125 | v_de_vs /= 2; |
| 1126 | vsync_len /= 2; |
| 1127 | } |
| 1128 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1129 | /* Set up horizontal active pixel width */ |
| 1130 | hdmi_writeb(hdmi, mode->hdisplay >> 8, HDMI_FC_INHACTV1); |
| 1131 | hdmi_writeb(hdmi, mode->hdisplay, HDMI_FC_INHACTV0); |
| 1132 | |
| 1133 | /* Set up vertical active lines */ |
Russell King | e80b9f4 | 2015-07-21 11:08:25 +0100 | [diff] [blame] | 1134 | hdmi_writeb(hdmi, vdisplay >> 8, HDMI_FC_INVACTV1); |
| 1135 | hdmi_writeb(hdmi, vdisplay, HDMI_FC_INVACTV0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1136 | |
| 1137 | /* Set up horizontal blanking pixel region width */ |
| 1138 | hblank = mode->htotal - mode->hdisplay; |
| 1139 | hdmi_writeb(hdmi, hblank >> 8, HDMI_FC_INHBLANK1); |
| 1140 | hdmi_writeb(hdmi, hblank, HDMI_FC_INHBLANK0); |
| 1141 | |
| 1142 | /* Set up vertical blanking pixel region width */ |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1143 | hdmi_writeb(hdmi, vblank, HDMI_FC_INVBLANK); |
| 1144 | |
| 1145 | /* Set up HSYNC active edge delay width (in pixel clks) */ |
| 1146 | h_de_hs = mode->hsync_start - mode->hdisplay; |
| 1147 | hdmi_writeb(hdmi, h_de_hs >> 8, HDMI_FC_HSYNCINDELAY1); |
| 1148 | hdmi_writeb(hdmi, h_de_hs, HDMI_FC_HSYNCINDELAY0); |
| 1149 | |
| 1150 | /* Set up VSYNC active edge delay (in lines) */ |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1151 | hdmi_writeb(hdmi, v_de_vs, HDMI_FC_VSYNCINDELAY); |
| 1152 | |
| 1153 | /* Set up HSYNC active pulse width (in pixel clks) */ |
| 1154 | hsync_len = mode->hsync_end - mode->hsync_start; |
| 1155 | hdmi_writeb(hdmi, hsync_len >> 8, HDMI_FC_HSYNCINWIDTH1); |
| 1156 | hdmi_writeb(hdmi, hsync_len, HDMI_FC_HSYNCINWIDTH0); |
| 1157 | |
| 1158 | /* Set up VSYNC active edge delay (in lines) */ |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1159 | hdmi_writeb(hdmi, vsync_len, HDMI_FC_VSYNCINWIDTH); |
| 1160 | } |
| 1161 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1162 | static void dw_hdmi_phy_disable(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1163 | { |
| 1164 | if (!hdmi->phy_enabled) |
| 1165 | return; |
| 1166 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1167 | dw_hdmi_phy_enable_tmds(hdmi, 0); |
Russell King | 2fada10 | 2015-07-28 12:21:34 +0100 | [diff] [blame] | 1168 | dw_hdmi_phy_enable_powerdown(hdmi, true); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1169 | |
| 1170 | hdmi->phy_enabled = false; |
| 1171 | } |
| 1172 | |
| 1173 | /* HDMI Initialization Step B.4 */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1174 | static void dw_hdmi_enable_video_path(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1175 | { |
| 1176 | u8 clkdis; |
| 1177 | |
| 1178 | /* control period minimum duration */ |
| 1179 | hdmi_writeb(hdmi, 12, HDMI_FC_CTRLDUR); |
| 1180 | hdmi_writeb(hdmi, 32, HDMI_FC_EXCTRLDUR); |
| 1181 | hdmi_writeb(hdmi, 1, HDMI_FC_EXCTRLSPAC); |
| 1182 | |
| 1183 | /* Set to fill TMDS data channels */ |
| 1184 | hdmi_writeb(hdmi, 0x0B, HDMI_FC_CH0PREAM); |
| 1185 | hdmi_writeb(hdmi, 0x16, HDMI_FC_CH1PREAM); |
| 1186 | hdmi_writeb(hdmi, 0x21, HDMI_FC_CH2PREAM); |
| 1187 | |
| 1188 | /* Enable pixel clock and tmds data path */ |
| 1189 | clkdis = 0x7F; |
| 1190 | clkdis &= ~HDMI_MC_CLKDIS_PIXELCLK_DISABLE; |
| 1191 | hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS); |
| 1192 | |
| 1193 | clkdis &= ~HDMI_MC_CLKDIS_TMDSCLK_DISABLE; |
| 1194 | hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS); |
| 1195 | |
| 1196 | /* Enable csc path */ |
| 1197 | if (is_color_space_conversion(hdmi)) { |
| 1198 | clkdis &= ~HDMI_MC_CLKDIS_CSCCLK_DISABLE; |
| 1199 | hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS); |
| 1200 | } |
| 1201 | } |
| 1202 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1203 | static void hdmi_enable_audio_clk(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1204 | { |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 1205 | hdmi_modb(hdmi, 0, HDMI_MC_CLKDIS_AUDCLK_DISABLE, HDMI_MC_CLKDIS); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1206 | } |
| 1207 | |
| 1208 | /* Workaround to clear the overflow condition */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1209 | static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1210 | { |
| 1211 | int count; |
| 1212 | u8 val; |
| 1213 | |
| 1214 | /* TMDS software reset */ |
| 1215 | hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, HDMI_MC_SWRSTZ); |
| 1216 | |
| 1217 | val = hdmi_readb(hdmi, HDMI_FC_INVIDCONF); |
| 1218 | if (hdmi->dev_type == IMX6DL_HDMI) { |
| 1219 | hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF); |
| 1220 | return; |
| 1221 | } |
| 1222 | |
| 1223 | for (count = 0; count < 4; count++) |
| 1224 | hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF); |
| 1225 | } |
| 1226 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1227 | static void hdmi_enable_overflow_interrupts(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1228 | { |
| 1229 | hdmi_writeb(hdmi, 0, HDMI_FC_MASK2); |
| 1230 | hdmi_writeb(hdmi, 0, HDMI_IH_MUTE_FC_STAT2); |
| 1231 | } |
| 1232 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1233 | static void hdmi_disable_overflow_interrupts(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1234 | { |
| 1235 | hdmi_writeb(hdmi, HDMI_IH_MUTE_FC_STAT2_OVERFLOW_MASK, |
| 1236 | HDMI_IH_MUTE_FC_STAT2); |
| 1237 | } |
| 1238 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1239 | static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1240 | { |
| 1241 | int ret; |
| 1242 | |
| 1243 | hdmi_disable_overflow_interrupts(hdmi); |
| 1244 | |
| 1245 | hdmi->vic = drm_match_cea_mode(mode); |
| 1246 | |
| 1247 | if (!hdmi->vic) { |
| 1248 | dev_dbg(hdmi->dev, "Non-CEA mode used in HDMI\n"); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1249 | } else { |
| 1250 | dev_dbg(hdmi->dev, "CEA mode used vic=%d\n", hdmi->vic); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1251 | } |
| 1252 | |
| 1253 | if ((hdmi->vic == 6) || (hdmi->vic == 7) || |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1254 | (hdmi->vic == 21) || (hdmi->vic == 22) || |
| 1255 | (hdmi->vic == 2) || (hdmi->vic == 3) || |
| 1256 | (hdmi->vic == 17) || (hdmi->vic == 18)) |
Sachin Kamat | 5a819ed | 2014-01-28 10:33:16 +0530 | [diff] [blame] | 1257 | hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_601; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1258 | else |
Sachin Kamat | 5a819ed | 2014-01-28 10:33:16 +0530 | [diff] [blame] | 1259 | hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1260 | |
Russell King | d10ca82 | 2015-07-21 11:25:00 +0100 | [diff] [blame] | 1261 | hdmi->hdmi_data.video_mode.mpixelrepetitionoutput = 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1262 | hdmi->hdmi_data.video_mode.mpixelrepetitioninput = 0; |
| 1263 | |
| 1264 | /* TODO: Get input format from IPU (via FB driver interface) */ |
| 1265 | hdmi->hdmi_data.enc_in_format = RGB; |
| 1266 | |
| 1267 | hdmi->hdmi_data.enc_out_format = RGB; |
| 1268 | |
| 1269 | hdmi->hdmi_data.enc_color_depth = 8; |
| 1270 | hdmi->hdmi_data.pix_repet_factor = 0; |
| 1271 | hdmi->hdmi_data.hdcp_enable = 0; |
| 1272 | hdmi->hdmi_data.video_mode.mdataenablepolarity = true; |
| 1273 | |
| 1274 | /* HDMI Initialization Step B.1 */ |
| 1275 | hdmi_av_composer(hdmi, mode); |
| 1276 | |
| 1277 | /* HDMI Initializateion Step B.2 */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1278 | ret = dw_hdmi_phy_init(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1279 | if (ret) |
| 1280 | return ret; |
| 1281 | |
| 1282 | /* HDMI Initialization Step B.3 */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1283 | dw_hdmi_enable_video_path(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1284 | |
Russell King | f709ec0 | 2015-07-21 16:09:39 +0100 | [diff] [blame] | 1285 | if (hdmi->sink_has_audio) { |
| 1286 | dev_dbg(hdmi->dev, "sink has audio support\n"); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1287 | |
| 1288 | /* HDMI Initialization Step E - Configure audio */ |
| 1289 | hdmi_clk_regenerator_update_pixel_clock(hdmi); |
| 1290 | hdmi_enable_audio_clk(hdmi); |
Russell King | f709ec0 | 2015-07-21 16:09:39 +0100 | [diff] [blame] | 1291 | } |
| 1292 | |
| 1293 | /* not for DVI mode */ |
| 1294 | if (hdmi->sink_is_hdmi) { |
| 1295 | dev_dbg(hdmi->dev, "%s HDMI mode\n", __func__); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1296 | |
| 1297 | /* HDMI Initialization Step F - Configure AVI InfoFrame */ |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1298 | hdmi_config_AVI(hdmi, mode); |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 1299 | } else { |
| 1300 | dev_dbg(hdmi->dev, "%s DVI mode\n", __func__); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1301 | } |
| 1302 | |
| 1303 | hdmi_video_packetize(hdmi); |
| 1304 | hdmi_video_csc(hdmi); |
| 1305 | hdmi_video_sample(hdmi); |
| 1306 | hdmi_tx_hdcp_config(hdmi); |
| 1307 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1308 | dw_hdmi_clear_overflow(hdmi); |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 1309 | if (hdmi->cable_plugin && hdmi->sink_is_hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1310 | hdmi_enable_overflow_interrupts(hdmi); |
| 1311 | |
| 1312 | return 0; |
| 1313 | } |
| 1314 | |
| 1315 | /* Wait until we are registered to enable interrupts */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1316 | static int dw_hdmi_fb_registered(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1317 | { |
| 1318 | hdmi_writeb(hdmi, HDMI_PHY_I2CM_INT_ADDR_DONE_POL, |
| 1319 | HDMI_PHY_I2CM_INT_ADDR); |
| 1320 | |
| 1321 | hdmi_writeb(hdmi, HDMI_PHY_I2CM_CTLINT_ADDR_NAC_POL | |
| 1322 | HDMI_PHY_I2CM_CTLINT_ADDR_ARBITRATION_POL, |
| 1323 | HDMI_PHY_I2CM_CTLINT_ADDR); |
| 1324 | |
| 1325 | /* enable cable hot plug irq */ |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1326 | hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1327 | |
| 1328 | /* Clear Hotplug interrupts */ |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1329 | hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, |
| 1330 | HDMI_IH_PHY_STAT0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1331 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1332 | return 0; |
| 1333 | } |
| 1334 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1335 | static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1336 | { |
| 1337 | u8 ih_mute; |
| 1338 | |
| 1339 | /* |
| 1340 | * Boot up defaults are: |
| 1341 | * HDMI_IH_MUTE = 0x03 (disabled) |
| 1342 | * HDMI_IH_MUTE_* = 0x00 (enabled) |
| 1343 | * |
| 1344 | * Disable top level interrupt bits in HDMI block |
| 1345 | */ |
| 1346 | ih_mute = hdmi_readb(hdmi, HDMI_IH_MUTE) | |
| 1347 | HDMI_IH_MUTE_MUTE_WAKEUP_INTERRUPT | |
| 1348 | HDMI_IH_MUTE_MUTE_ALL_INTERRUPT; |
| 1349 | |
| 1350 | hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE); |
| 1351 | |
| 1352 | /* by default mask all interrupts */ |
| 1353 | hdmi_writeb(hdmi, 0xff, HDMI_VP_MASK); |
| 1354 | hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK0); |
| 1355 | hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK1); |
| 1356 | hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK2); |
| 1357 | hdmi_writeb(hdmi, 0xff, HDMI_PHY_MASK0); |
| 1358 | hdmi_writeb(hdmi, 0xff, HDMI_PHY_I2CM_INT_ADDR); |
| 1359 | hdmi_writeb(hdmi, 0xff, HDMI_PHY_I2CM_CTLINT_ADDR); |
| 1360 | hdmi_writeb(hdmi, 0xff, HDMI_AUD_INT); |
| 1361 | hdmi_writeb(hdmi, 0xff, HDMI_AUD_SPDIFINT); |
| 1362 | hdmi_writeb(hdmi, 0xff, HDMI_AUD_HBR_MASK); |
| 1363 | hdmi_writeb(hdmi, 0xff, HDMI_GP_MASK); |
| 1364 | hdmi_writeb(hdmi, 0xff, HDMI_A_APIINTMSK); |
| 1365 | hdmi_writeb(hdmi, 0xff, HDMI_CEC_MASK); |
| 1366 | hdmi_writeb(hdmi, 0xff, HDMI_I2CM_INT); |
| 1367 | hdmi_writeb(hdmi, 0xff, HDMI_I2CM_CTLINT); |
| 1368 | |
| 1369 | /* Disable interrupts in the IH_MUTE_* registers */ |
| 1370 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT0); |
| 1371 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT1); |
| 1372 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT2); |
| 1373 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_AS_STAT0); |
| 1374 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_PHY_STAT0); |
| 1375 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_I2CM_STAT0); |
| 1376 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_CEC_STAT0); |
| 1377 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_VP_STAT0); |
| 1378 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_I2CMPHY_STAT0); |
| 1379 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_AHBDMAAUD_STAT0); |
| 1380 | |
| 1381 | /* Enable top level interrupt bits in HDMI block */ |
| 1382 | ih_mute &= ~(HDMI_IH_MUTE_MUTE_WAKEUP_INTERRUPT | |
| 1383 | HDMI_IH_MUTE_MUTE_ALL_INTERRUPT); |
| 1384 | hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE); |
| 1385 | } |
| 1386 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1387 | static void dw_hdmi_poweron(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1388 | { |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1389 | hdmi->bridge_is_on = true; |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1390 | dw_hdmi_setup(hdmi, &hdmi->previous_mode); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1391 | } |
| 1392 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1393 | static void dw_hdmi_poweroff(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1394 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1395 | dw_hdmi_phy_disable(hdmi); |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1396 | hdmi->bridge_is_on = false; |
| 1397 | } |
| 1398 | |
| 1399 | static void dw_hdmi_update_power(struct dw_hdmi *hdmi) |
| 1400 | { |
| 1401 | int force = hdmi->force; |
| 1402 | |
| 1403 | if (hdmi->disabled) { |
| 1404 | force = DRM_FORCE_OFF; |
| 1405 | } else if (force == DRM_FORCE_UNSPECIFIED) { |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1406 | if (hdmi->rxsense) |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1407 | force = DRM_FORCE_ON; |
| 1408 | else |
| 1409 | force = DRM_FORCE_OFF; |
| 1410 | } |
| 1411 | |
| 1412 | if (force == DRM_FORCE_OFF) { |
| 1413 | if (hdmi->bridge_is_on) |
| 1414 | dw_hdmi_poweroff(hdmi); |
| 1415 | } else { |
| 1416 | if (!hdmi->bridge_is_on) |
| 1417 | dw_hdmi_poweron(hdmi); |
| 1418 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1419 | } |
| 1420 | |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1421 | /* |
| 1422 | * Adjust the detection of RXSENSE according to whether we have a forced |
| 1423 | * connection mode enabled, or whether we have been disabled. There is |
| 1424 | * no point processing RXSENSE interrupts if we have a forced connection |
| 1425 | * state, or DRM has us disabled. |
| 1426 | * |
| 1427 | * We also disable rxsense interrupts when we think we're disconnected |
| 1428 | * to avoid floating TDMS signals giving false rxsense interrupts. |
| 1429 | * |
| 1430 | * Note: we still need to listen for HPD interrupts even when DRM has us |
| 1431 | * disabled so that we can detect a connect event. |
| 1432 | */ |
| 1433 | static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi) |
| 1434 | { |
| 1435 | u8 old_mask = hdmi->phy_mask; |
| 1436 | |
| 1437 | if (hdmi->force || hdmi->disabled || !hdmi->rxsense) |
| 1438 | hdmi->phy_mask |= HDMI_PHY_RX_SENSE; |
| 1439 | else |
| 1440 | hdmi->phy_mask &= ~HDMI_PHY_RX_SENSE; |
| 1441 | |
| 1442 | if (old_mask != hdmi->phy_mask) |
| 1443 | hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); |
| 1444 | } |
| 1445 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1446 | static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge, |
Steve Longerbeam | eb10d63 | 2014-12-18 18:00:24 -0800 | [diff] [blame] | 1447 | struct drm_display_mode *orig_mode, |
| 1448 | struct drm_display_mode *mode) |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1449 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1450 | struct dw_hdmi *hdmi = bridge->driver_private; |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1451 | |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1452 | mutex_lock(&hdmi->mutex); |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1453 | |
| 1454 | /* Store the display mode for plugin/DKMS poweron events */ |
| 1455 | memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode)); |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1456 | |
| 1457 | mutex_unlock(&hdmi->mutex); |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1458 | } |
| 1459 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1460 | static bool dw_hdmi_bridge_mode_fixup(struct drm_bridge *bridge, |
| 1461 | const struct drm_display_mode *mode, |
| 1462 | struct drm_display_mode *adjusted_mode) |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1463 | { |
| 1464 | return true; |
| 1465 | } |
| 1466 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1467 | static void dw_hdmi_bridge_disable(struct drm_bridge *bridge) |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1468 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1469 | struct dw_hdmi *hdmi = bridge->driver_private; |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1470 | |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1471 | mutex_lock(&hdmi->mutex); |
| 1472 | hdmi->disabled = true; |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1473 | dw_hdmi_update_power(hdmi); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1474 | dw_hdmi_update_phy_mask(hdmi); |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1475 | mutex_unlock(&hdmi->mutex); |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1476 | } |
| 1477 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1478 | static void dw_hdmi_bridge_enable(struct drm_bridge *bridge) |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1479 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1480 | struct dw_hdmi *hdmi = bridge->driver_private; |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1481 | |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1482 | mutex_lock(&hdmi->mutex); |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1483 | hdmi->disabled = false; |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1484 | dw_hdmi_update_power(hdmi); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1485 | dw_hdmi_update_phy_mask(hdmi); |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1486 | mutex_unlock(&hdmi->mutex); |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1487 | } |
| 1488 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1489 | static void dw_hdmi_bridge_nop(struct drm_bridge *bridge) |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1490 | { |
| 1491 | /* do nothing */ |
| 1492 | } |
| 1493 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1494 | static enum drm_connector_status |
| 1495 | dw_hdmi_connector_detect(struct drm_connector *connector, bool force) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1496 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1497 | struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 1498 | connector); |
Russell King | 98dbead | 2014-04-18 10:46:45 +0100 | [diff] [blame] | 1499 | |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1500 | mutex_lock(&hdmi->mutex); |
| 1501 | hdmi->force = DRM_FORCE_UNSPECIFIED; |
| 1502 | dw_hdmi_update_power(hdmi); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1503 | dw_hdmi_update_phy_mask(hdmi); |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1504 | mutex_unlock(&hdmi->mutex); |
| 1505 | |
Russell King | 98dbead | 2014-04-18 10:46:45 +0100 | [diff] [blame] | 1506 | return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ? |
| 1507 | connector_status_connected : connector_status_disconnected; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1508 | } |
| 1509 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1510 | static int dw_hdmi_connector_get_modes(struct drm_connector *connector) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1511 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1512 | struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1513 | connector); |
| 1514 | struct edid *edid; |
Doug Anderson | 6c7e66e | 2015-06-04 11:04:36 -0700 | [diff] [blame] | 1515 | int ret = 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1516 | |
| 1517 | if (!hdmi->ddc) |
| 1518 | return 0; |
| 1519 | |
| 1520 | edid = drm_get_edid(connector, hdmi->ddc); |
| 1521 | if (edid) { |
| 1522 | dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n", |
| 1523 | edid->width_cm, edid->height_cm); |
| 1524 | |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 1525 | hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid); |
Russell King | f709ec0 | 2015-07-21 16:09:39 +0100 | [diff] [blame] | 1526 | hdmi->sink_has_audio = drm_detect_monitor_audio(edid); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1527 | drm_mode_connector_update_edid_property(connector, edid); |
| 1528 | ret = drm_add_edid_modes(connector, edid); |
Russell King | f5ce405 | 2013-11-07 16:06:01 +0000 | [diff] [blame] | 1529 | /* Store the ELD */ |
| 1530 | drm_edid_to_eld(connector, edid); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1531 | kfree(edid); |
| 1532 | } else { |
| 1533 | dev_dbg(hdmi->dev, "failed to get edid\n"); |
| 1534 | } |
| 1535 | |
Doug Anderson | 6c7e66e | 2015-06-04 11:04:36 -0700 | [diff] [blame] | 1536 | return ret; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1537 | } |
| 1538 | |
Andy Yan | 632d035 | 2014-12-05 14:30:21 +0800 | [diff] [blame] | 1539 | static enum drm_mode_status |
| 1540 | dw_hdmi_connector_mode_valid(struct drm_connector *connector, |
| 1541 | struct drm_display_mode *mode) |
| 1542 | { |
| 1543 | struct dw_hdmi *hdmi = container_of(connector, |
| 1544 | struct dw_hdmi, connector); |
| 1545 | enum drm_mode_status mode_status = MODE_OK; |
| 1546 | |
Russell King | 8add419 | 2015-07-22 11:14:00 +0100 | [diff] [blame] | 1547 | /* We don't support double-clocked modes */ |
| 1548 | if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
| 1549 | return MODE_BAD; |
| 1550 | |
Andy Yan | 632d035 | 2014-12-05 14:30:21 +0800 | [diff] [blame] | 1551 | if (hdmi->plat_data->mode_valid) |
| 1552 | mode_status = hdmi->plat_data->mode_valid(connector, mode); |
| 1553 | |
| 1554 | return mode_status; |
| 1555 | } |
| 1556 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1557 | static struct drm_encoder *dw_hdmi_connector_best_encoder(struct drm_connector |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1558 | *connector) |
| 1559 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1560 | struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1561 | connector); |
| 1562 | |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1563 | return hdmi->encoder; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1564 | } |
| 1565 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1566 | static void dw_hdmi_connector_destroy(struct drm_connector *connector) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1567 | { |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1568 | drm_connector_unregister(connector); |
| 1569 | drm_connector_cleanup(connector); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1570 | } |
| 1571 | |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1572 | static void dw_hdmi_connector_force(struct drm_connector *connector) |
| 1573 | { |
| 1574 | struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, |
| 1575 | connector); |
| 1576 | |
| 1577 | mutex_lock(&hdmi->mutex); |
| 1578 | hdmi->force = connector->force; |
| 1579 | dw_hdmi_update_power(hdmi); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1580 | dw_hdmi_update_phy_mask(hdmi); |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1581 | mutex_unlock(&hdmi->mutex); |
| 1582 | } |
| 1583 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1584 | static struct drm_connector_funcs dw_hdmi_connector_funcs = { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1585 | .dpms = drm_helper_connector_dpms, |
| 1586 | .fill_modes = drm_helper_probe_single_connector_modes, |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1587 | .detect = dw_hdmi_connector_detect, |
| 1588 | .destroy = dw_hdmi_connector_destroy, |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1589 | .force = dw_hdmi_connector_force, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1590 | }; |
| 1591 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1592 | static struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = { |
| 1593 | .get_modes = dw_hdmi_connector_get_modes, |
Andy Yan | 632d035 | 2014-12-05 14:30:21 +0800 | [diff] [blame] | 1594 | .mode_valid = dw_hdmi_connector_mode_valid, |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1595 | .best_encoder = dw_hdmi_connector_best_encoder, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1596 | }; |
| 1597 | |
Fabio Estevam | cf88fca | 2015-04-02 19:11:04 -0300 | [diff] [blame] | 1598 | static struct drm_bridge_funcs dw_hdmi_bridge_funcs = { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1599 | .enable = dw_hdmi_bridge_enable, |
| 1600 | .disable = dw_hdmi_bridge_disable, |
| 1601 | .pre_enable = dw_hdmi_bridge_nop, |
| 1602 | .post_disable = dw_hdmi_bridge_nop, |
| 1603 | .mode_set = dw_hdmi_bridge_mode_set, |
| 1604 | .mode_fixup = dw_hdmi_bridge_mode_fixup, |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1605 | }; |
| 1606 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1607 | static irqreturn_t dw_hdmi_hardirq(int irq, void *dev_id) |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 1608 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1609 | struct dw_hdmi *hdmi = dev_id; |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 1610 | u8 intr_stat; |
| 1611 | |
| 1612 | intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); |
| 1613 | if (intr_stat) |
| 1614 | hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); |
| 1615 | |
| 1616 | return intr_stat ? IRQ_WAKE_THREAD : IRQ_NONE; |
| 1617 | } |
| 1618 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1619 | static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1620 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1621 | struct dw_hdmi *hdmi = dev_id; |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1622 | u8 intr_stat, phy_int_pol, phy_pol_mask, phy_stat; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1623 | |
| 1624 | intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1625 | phy_int_pol = hdmi_readb(hdmi, HDMI_PHY_POL0); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1626 | phy_stat = hdmi_readb(hdmi, HDMI_PHY_STAT0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1627 | |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1628 | phy_pol_mask = 0; |
| 1629 | if (intr_stat & HDMI_IH_PHY_STAT0_HPD) |
| 1630 | phy_pol_mask |= HDMI_PHY_HPD; |
| 1631 | if (intr_stat & HDMI_IH_PHY_STAT0_RX_SENSE0) |
| 1632 | phy_pol_mask |= HDMI_PHY_RX_SENSE0; |
| 1633 | if (intr_stat & HDMI_IH_PHY_STAT0_RX_SENSE1) |
| 1634 | phy_pol_mask |= HDMI_PHY_RX_SENSE1; |
| 1635 | if (intr_stat & HDMI_IH_PHY_STAT0_RX_SENSE2) |
| 1636 | phy_pol_mask |= HDMI_PHY_RX_SENSE2; |
| 1637 | if (intr_stat & HDMI_IH_PHY_STAT0_RX_SENSE3) |
| 1638 | phy_pol_mask |= HDMI_PHY_RX_SENSE3; |
| 1639 | |
| 1640 | if (phy_pol_mask) |
| 1641 | hdmi_modb(hdmi, ~phy_int_pol, phy_pol_mask, HDMI_PHY_POL0); |
| 1642 | |
| 1643 | /* |
| 1644 | * RX sense tells us whether the TDMS transmitters are detecting |
| 1645 | * load - in other words, there's something listening on the |
| 1646 | * other end of the link. Use this to decide whether we should |
| 1647 | * power on the phy as HPD may be toggled by the sink to merely |
| 1648 | * ask the source to re-read the EDID. |
| 1649 | */ |
| 1650 | if (intr_stat & |
| 1651 | (HDMI_IH_PHY_STAT0_RX_SENSE | HDMI_IH_PHY_STAT0_HPD)) { |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1652 | mutex_lock(&hdmi->mutex); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1653 | if (!hdmi->disabled && !hdmi->force) { |
| 1654 | /* |
| 1655 | * If the RX sense status indicates we're disconnected, |
| 1656 | * clear the software rxsense status. |
| 1657 | */ |
| 1658 | if (!(phy_stat & HDMI_PHY_RX_SENSE)) |
| 1659 | hdmi->rxsense = false; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1660 | |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1661 | /* |
| 1662 | * Only set the software rxsense status when both |
| 1663 | * rxsense and hpd indicates we're connected. |
| 1664 | * This avoids what seems to be bad behaviour in |
| 1665 | * at least iMX6S versions of the phy. |
| 1666 | */ |
| 1667 | if (phy_stat & HDMI_PHY_HPD) |
| 1668 | hdmi->rxsense = true; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1669 | |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1670 | dw_hdmi_update_power(hdmi); |
| 1671 | dw_hdmi_update_phy_mask(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1672 | } |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1673 | mutex_unlock(&hdmi->mutex); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1674 | } |
| 1675 | |
| 1676 | if (intr_stat & HDMI_IH_PHY_STAT0_HPD) { |
| 1677 | dev_dbg(hdmi->dev, "EVENT=%s\n", |
| 1678 | phy_int_pol & HDMI_PHY_HPD ? "plugin" : "plugout"); |
Russell King | 4b9bcaa | 2015-06-06 00:12:41 +0100 | [diff] [blame] | 1679 | drm_helper_hpd_irq_event(hdmi->bridge->dev); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1680 | } |
| 1681 | |
| 1682 | hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1683 | hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), |
| 1684 | HDMI_IH_MUTE_PHY_STAT0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1685 | |
| 1686 | return IRQ_HANDLED; |
| 1687 | } |
| 1688 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1689 | static int dw_hdmi_register(struct drm_device *drm, struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1690 | { |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1691 | struct drm_encoder *encoder = hdmi->encoder; |
| 1692 | struct drm_bridge *bridge; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1693 | int ret; |
| 1694 | |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1695 | bridge = devm_kzalloc(drm->dev, sizeof(*bridge), GFP_KERNEL); |
| 1696 | if (!bridge) { |
| 1697 | DRM_ERROR("Failed to allocate drm bridge\n"); |
| 1698 | return -ENOMEM; |
| 1699 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1700 | |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1701 | hdmi->bridge = bridge; |
| 1702 | bridge->driver_private = hdmi; |
Fabio Estevam | b5217bf | 2015-01-27 10:21:49 -0200 | [diff] [blame] | 1703 | bridge->funcs = &dw_hdmi_bridge_funcs; |
| 1704 | ret = drm_bridge_attach(drm, bridge); |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1705 | if (ret) { |
| 1706 | DRM_ERROR("Failed to initialize bridge with drm\n"); |
| 1707 | return -EINVAL; |
| 1708 | } |
| 1709 | |
| 1710 | encoder->bridge = bridge; |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 1711 | hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1712 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1713 | drm_connector_helper_add(&hdmi->connector, |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1714 | &dw_hdmi_connector_helper_funcs); |
| 1715 | drm_connector_init(drm, &hdmi->connector, &dw_hdmi_connector_funcs, |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 1716 | DRM_MODE_CONNECTOR_HDMIA); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1717 | |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1718 | hdmi->connector.encoder = encoder; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1719 | |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1720 | drm_mode_connector_attach_encoder(&hdmi->connector, encoder); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1721 | |
| 1722 | return 0; |
| 1723 | } |
| 1724 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1725 | int dw_hdmi_bind(struct device *dev, struct device *master, |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1726 | void *data, struct drm_encoder *encoder, |
| 1727 | struct resource *iores, int irq, |
| 1728 | const struct dw_hdmi_plat_data *plat_data) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1729 | { |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 1730 | struct drm_device *drm = data; |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 1731 | struct device_node *np = dev->of_node; |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 1732 | struct platform_device_info pdevinfo; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1733 | struct device_node *ddc_node; |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 1734 | struct dw_hdmi_audio_data audio; |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1735 | struct dw_hdmi *hdmi; |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1736 | int ret; |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 1737 | u32 val = 1; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1738 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 1739 | hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1740 | if (!hdmi) |
| 1741 | return -ENOMEM; |
| 1742 | |
Russell King | e80b9f4 | 2015-07-21 11:08:25 +0100 | [diff] [blame] | 1743 | hdmi->connector.interlace_allowed = 1; |
| 1744 | |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1745 | hdmi->plat_data = plat_data; |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 1746 | hdmi->dev = dev; |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1747 | hdmi->dev_type = plat_data->dev_type; |
Russell King | 4067838 | 2013-11-07 15:35:06 +0000 | [diff] [blame] | 1748 | hdmi->sample_rate = 48000; |
| 1749 | hdmi->ratio = 100; |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1750 | hdmi->encoder = encoder; |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1751 | hdmi->disabled = true; |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1752 | hdmi->rxsense = true; |
| 1753 | hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1754 | |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 1755 | mutex_init(&hdmi->mutex); |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 1756 | mutex_init(&hdmi->audio_mutex); |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 1757 | spin_lock_init(&hdmi->audio_lock); |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 1758 | |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 1759 | of_property_read_u32(np, "reg-io-width", &val); |
| 1760 | |
| 1761 | switch (val) { |
| 1762 | case 4: |
| 1763 | hdmi->write = dw_hdmi_writel; |
| 1764 | hdmi->read = dw_hdmi_readl; |
| 1765 | break; |
| 1766 | case 1: |
| 1767 | hdmi->write = dw_hdmi_writeb; |
| 1768 | hdmi->read = dw_hdmi_readb; |
| 1769 | break; |
| 1770 | default: |
| 1771 | dev_err(dev, "reg-io-width must be 1 or 4\n"); |
| 1772 | return -EINVAL; |
| 1773 | } |
| 1774 | |
Philipp Zabel | b5d4590 | 2014-03-05 10:20:56 +0100 | [diff] [blame] | 1775 | ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1776 | if (ddc_node) { |
| 1777 | hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1778 | of_node_put(ddc_node); |
Andy Yan | c2c3848 | 2014-12-05 14:24:28 +0800 | [diff] [blame] | 1779 | if (!hdmi->ddc) { |
| 1780 | dev_dbg(hdmi->dev, "failed to read ddc node\n"); |
| 1781 | return -EPROBE_DEFER; |
| 1782 | } |
| 1783 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1784 | } else { |
| 1785 | dev_dbg(hdmi->dev, "no ddc property found\n"); |
| 1786 | } |
| 1787 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 1788 | hdmi->regs = devm_ioremap_resource(dev, iores); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1789 | if (IS_ERR(hdmi->regs)) |
| 1790 | return PTR_ERR(hdmi->regs); |
| 1791 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1792 | hdmi->isfr_clk = devm_clk_get(hdmi->dev, "isfr"); |
| 1793 | if (IS_ERR(hdmi->isfr_clk)) { |
| 1794 | ret = PTR_ERR(hdmi->isfr_clk); |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1795 | dev_err(hdmi->dev, "Unable to get HDMI isfr clk: %d\n", ret); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1796 | return ret; |
| 1797 | } |
| 1798 | |
| 1799 | ret = clk_prepare_enable(hdmi->isfr_clk); |
| 1800 | if (ret) { |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1801 | dev_err(hdmi->dev, "Cannot enable HDMI isfr clock: %d\n", ret); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1802 | return ret; |
| 1803 | } |
| 1804 | |
| 1805 | hdmi->iahb_clk = devm_clk_get(hdmi->dev, "iahb"); |
| 1806 | if (IS_ERR(hdmi->iahb_clk)) { |
| 1807 | ret = PTR_ERR(hdmi->iahb_clk); |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1808 | dev_err(hdmi->dev, "Unable to get HDMI iahb clk: %d\n", ret); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1809 | goto err_isfr; |
| 1810 | } |
| 1811 | |
| 1812 | ret = clk_prepare_enable(hdmi->iahb_clk); |
| 1813 | if (ret) { |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1814 | dev_err(hdmi->dev, "Cannot enable HDMI iahb clock: %d\n", ret); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1815 | goto err_isfr; |
| 1816 | } |
| 1817 | |
| 1818 | /* Product and revision IDs */ |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 1819 | dev_info(dev, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1820 | "Detected HDMI controller 0x%x:0x%x:0x%x:0x%x\n", |
| 1821 | hdmi_readb(hdmi, HDMI_DESIGN_ID), |
| 1822 | hdmi_readb(hdmi, HDMI_REVISION_ID), |
| 1823 | hdmi_readb(hdmi, HDMI_PRODUCT_ID0), |
| 1824 | hdmi_readb(hdmi, HDMI_PRODUCT_ID1)); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1825 | |
| 1826 | initialize_hdmi_ih_mutes(hdmi); |
| 1827 | |
Philipp Zabel | 639a202 | 2015-01-07 13:43:50 +0100 | [diff] [blame] | 1828 | ret = devm_request_threaded_irq(dev, irq, dw_hdmi_hardirq, |
| 1829 | dw_hdmi_irq, IRQF_SHARED, |
| 1830 | dev_name(dev), hdmi); |
| 1831 | if (ret) |
Fabio Estevam | b33ef61 | 2015-01-27 10:54:12 -0200 | [diff] [blame] | 1832 | goto err_iahb; |
Philipp Zabel | 639a202 | 2015-01-07 13:43:50 +0100 | [diff] [blame] | 1833 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1834 | /* |
| 1835 | * To prevent overflows in HDMI_IH_FC_STAT2, set the clk regenerator |
| 1836 | * N and cts values before enabling phy |
| 1837 | */ |
| 1838 | hdmi_init_clk_regenerator(hdmi); |
| 1839 | |
| 1840 | /* |
| 1841 | * Configure registers related to HDMI interrupt |
| 1842 | * generation before registering IRQ. |
| 1843 | */ |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1844 | hdmi_writeb(hdmi, HDMI_PHY_HPD | HDMI_PHY_RX_SENSE, HDMI_PHY_POL0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1845 | |
| 1846 | /* Clear Hotplug interrupts */ |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1847 | hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, |
| 1848 | HDMI_IH_PHY_STAT0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1849 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1850 | ret = dw_hdmi_fb_registered(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1851 | if (ret) |
| 1852 | goto err_iahb; |
| 1853 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1854 | ret = dw_hdmi_register(drm, hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1855 | if (ret) |
| 1856 | goto err_iahb; |
| 1857 | |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 1858 | /* Unmute interrupts */ |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1859 | hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), |
| 1860 | HDMI_IH_MUTE_PHY_STAT0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1861 | |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 1862 | memset(&pdevinfo, 0, sizeof(pdevinfo)); |
| 1863 | pdevinfo.parent = dev; |
| 1864 | pdevinfo.id = PLATFORM_DEVID_AUTO; |
| 1865 | |
| 1866 | if (hdmi_readb(hdmi, HDMI_CONFIG1_ID) & HDMI_CONFIG1_AHB) { |
| 1867 | audio.phys = iores->start; |
| 1868 | audio.base = hdmi->regs; |
| 1869 | audio.irq = irq; |
| 1870 | audio.hdmi = hdmi; |
Russell King | f5ce405 | 2013-11-07 16:06:01 +0000 | [diff] [blame] | 1871 | audio.eld = hdmi->connector.eld; |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 1872 | |
| 1873 | pdevinfo.name = "dw-hdmi-ahb-audio"; |
| 1874 | pdevinfo.data = &audio; |
| 1875 | pdevinfo.size_data = sizeof(audio); |
| 1876 | pdevinfo.dma_mask = DMA_BIT_MASK(32); |
| 1877 | hdmi->audio = platform_device_register_full(&pdevinfo); |
| 1878 | } |
| 1879 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 1880 | dev_set_drvdata(dev, hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1881 | |
| 1882 | return 0; |
| 1883 | |
| 1884 | err_iahb: |
| 1885 | clk_disable_unprepare(hdmi->iahb_clk); |
| 1886 | err_isfr: |
| 1887 | clk_disable_unprepare(hdmi->isfr_clk); |
| 1888 | |
| 1889 | return ret; |
| 1890 | } |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1891 | EXPORT_SYMBOL_GPL(dw_hdmi_bind); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1892 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1893 | void dw_hdmi_unbind(struct device *dev, struct device *master, void *data) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1894 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1895 | struct dw_hdmi *hdmi = dev_get_drvdata(dev); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1896 | |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 1897 | if (hdmi->audio && !IS_ERR(hdmi->audio)) |
| 1898 | platform_device_unregister(hdmi->audio); |
| 1899 | |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 1900 | /* Disable all interrupts */ |
| 1901 | hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); |
| 1902 | |
Russell King | 1b3f767 | 2013-11-03 13:30:48 +0000 | [diff] [blame] | 1903 | hdmi->connector.funcs->destroy(&hdmi->connector); |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1904 | hdmi->encoder->funcs->destroy(hdmi->encoder); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1905 | |
| 1906 | clk_disable_unprepare(hdmi->iahb_clk); |
| 1907 | clk_disable_unprepare(hdmi->isfr_clk); |
| 1908 | i2c_put_adapter(hdmi->ddc); |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 1909 | } |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1910 | EXPORT_SYMBOL_GPL(dw_hdmi_unbind); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1911 | |
| 1912 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 1913 | MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com>"); |
| 1914 | MODULE_AUTHOR("Yakir Yang <ykk@rock-chips.com>"); |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1915 | MODULE_DESCRIPTION("DW HDMI transmitter driver"); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1916 | MODULE_LICENSE("GPL"); |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1917 | MODULE_ALIAS("platform:dw-hdmi"); |