Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1 | /* |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2 | * DesignWare High-Definition Multimedia Interface (HDMI) driver |
| 3 | * |
| 4 | * Copyright (C) 2013-2015 Mentor Graphics Inc. |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 5 | * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 6 | * Copyright (C) 2010, Guennadi Liakhovetski <g.liakhovetski@gmx.de> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 13 | */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 14 | #include <linux/module.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 15 | #include <linux/irq.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/err.h> |
| 18 | #include <linux/clk.h> |
Sachin Kamat | 5a819ed | 2014-01-28 10:33:16 +0530 | [diff] [blame] | 19 | #include <linux/hdmi.h> |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 20 | #include <linux/mutex.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 21 | #include <linux/of_device.h> |
Neil Armstrong | 80e2f97 | 2017-03-03 19:20:06 +0200 | [diff] [blame] | 22 | #include <linux/regmap.h> |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 23 | #include <linux/spinlock.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 24 | |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 25 | #include <drm/drm_of.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 26 | #include <drm/drmP.h> |
Mark Yao | 2c5b2cc | 2015-11-30 18:33:40 +0800 | [diff] [blame] | 27 | #include <drm/drm_atomic_helper.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 28 | #include <drm/drm_crtc_helper.h> |
| 29 | #include <drm/drm_edid.h> |
| 30 | #include <drm/drm_encoder_slave.h> |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 31 | #include <drm/bridge/dw_hdmi.h> |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 32 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 33 | #include <uapi/linux/media-bus-format.h> |
| 34 | #include <uapi/linux/videodev2.h> |
| 35 | |
Thierry Reding | 248a86f | 2015-11-24 17:52:58 +0100 | [diff] [blame] | 36 | #include "dw-hdmi.h" |
| 37 | #include "dw-hdmi-audio.h" |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 38 | |
Russell King | e84b8d7 | 2017-07-31 15:29:41 +0100 | [diff] [blame] | 39 | #include <media/cec-notifier.h> |
| 40 | |
Nickey Yang | 94bb4dc | 2017-03-20 10:57:31 +0800 | [diff] [blame] | 41 | #define DDC_SEGMENT_ADDR 0x30 |
Russell King | e84b8d7 | 2017-07-31 15:29:41 +0100 | [diff] [blame] | 42 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 43 | #define HDMI_EDID_LEN 512 |
| 44 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 45 | enum hdmi_datamap { |
| 46 | RGB444_8B = 0x01, |
| 47 | RGB444_10B = 0x03, |
| 48 | RGB444_12B = 0x05, |
| 49 | RGB444_16B = 0x07, |
| 50 | YCbCr444_8B = 0x09, |
| 51 | YCbCr444_10B = 0x0B, |
| 52 | YCbCr444_12B = 0x0D, |
| 53 | YCbCr444_16B = 0x0F, |
| 54 | YCbCr422_8B = 0x16, |
| 55 | YCbCr422_10B = 0x14, |
| 56 | YCbCr422_12B = 0x12, |
| 57 | }; |
| 58 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 59 | static const u16 csc_coeff_default[3][4] = { |
| 60 | { 0x2000, 0x0000, 0x0000, 0x0000 }, |
| 61 | { 0x0000, 0x2000, 0x0000, 0x0000 }, |
| 62 | { 0x0000, 0x0000, 0x2000, 0x0000 } |
| 63 | }; |
| 64 | |
| 65 | static const u16 csc_coeff_rgb_out_eitu601[3][4] = { |
| 66 | { 0x2000, 0x6926, 0x74fd, 0x010e }, |
| 67 | { 0x2000, 0x2cdd, 0x0000, 0x7e9a }, |
| 68 | { 0x2000, 0x0000, 0x38b4, 0x7e3b } |
| 69 | }; |
| 70 | |
| 71 | static const u16 csc_coeff_rgb_out_eitu709[3][4] = { |
| 72 | { 0x2000, 0x7106, 0x7a02, 0x00a7 }, |
| 73 | { 0x2000, 0x3264, 0x0000, 0x7e6d }, |
| 74 | { 0x2000, 0x0000, 0x3b61, 0x7e25 } |
| 75 | }; |
| 76 | |
| 77 | static const u16 csc_coeff_rgb_in_eitu601[3][4] = { |
| 78 | { 0x2591, 0x1322, 0x074b, 0x0000 }, |
| 79 | { 0x6535, 0x2000, 0x7acc, 0x0200 }, |
| 80 | { 0x6acd, 0x7534, 0x2000, 0x0200 } |
| 81 | }; |
| 82 | |
| 83 | static const u16 csc_coeff_rgb_in_eitu709[3][4] = { |
| 84 | { 0x2dc5, 0x0d9b, 0x049e, 0x0000 }, |
| 85 | { 0x62f0, 0x2000, 0x7d11, 0x0200 }, |
| 86 | { 0x6756, 0x78ab, 0x2000, 0x0200 } |
| 87 | }; |
| 88 | |
| 89 | struct hdmi_vmode { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 90 | bool mdataenablepolarity; |
| 91 | |
| 92 | unsigned int mpixelclock; |
| 93 | unsigned int mpixelrepetitioninput; |
| 94 | unsigned int mpixelrepetitionoutput; |
| 95 | }; |
| 96 | |
| 97 | struct hdmi_data_info { |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 98 | unsigned int enc_in_bus_format; |
| 99 | unsigned int enc_out_bus_format; |
| 100 | unsigned int enc_in_encoding; |
| 101 | unsigned int enc_out_encoding; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 102 | unsigned int pix_repet_factor; |
| 103 | unsigned int hdcp_enable; |
| 104 | struct hdmi_vmode video_mode; |
| 105 | }; |
| 106 | |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 107 | struct dw_hdmi_i2c { |
| 108 | struct i2c_adapter adap; |
| 109 | |
| 110 | struct mutex lock; /* used to serialize data transfers */ |
| 111 | struct completion cmp; |
| 112 | u8 stat; |
| 113 | |
| 114 | u8 slave_reg; |
| 115 | bool is_regaddr; |
Nickey Yang | 94bb4dc | 2017-03-20 10:57:31 +0800 | [diff] [blame] | 116 | bool is_segment; |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 117 | }; |
| 118 | |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 119 | struct dw_hdmi_phy_data { |
| 120 | enum dw_hdmi_phy_type type; |
| 121 | const char *name; |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 122 | unsigned int gen; |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 123 | bool has_svsret; |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 124 | int (*configure)(struct dw_hdmi *hdmi, |
| 125 | const struct dw_hdmi_plat_data *pdata, |
| 126 | unsigned long mpixelclock); |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 127 | }; |
| 128 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 129 | struct dw_hdmi { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 130 | struct drm_connector connector; |
Laurent Pinchart | 70c963e | 2017-01-17 10:28:54 +0200 | [diff] [blame] | 131 | struct drm_bridge bridge; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 132 | |
Laurent Pinchart | be41fc5 | 2017-01-17 10:29:05 +0200 | [diff] [blame] | 133 | unsigned int version; |
| 134 | |
| 135 | struct platform_device *audio; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 136 | struct device *dev; |
| 137 | struct clk *isfr_clk; |
| 138 | struct clk *iahb_clk; |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 139 | struct dw_hdmi_i2c *i2c; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 140 | |
| 141 | struct hdmi_data_info hdmi_data; |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 142 | const struct dw_hdmi_plat_data *plat_data; |
| 143 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 144 | int vic; |
| 145 | |
| 146 | u8 edid[HDMI_EDID_LEN]; |
| 147 | bool cable_plugin; |
| 148 | |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 149 | struct { |
| 150 | const struct dw_hdmi_phy_ops *ops; |
| 151 | const char *name; |
| 152 | void *data; |
| 153 | bool enabled; |
| 154 | } phy; |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 155 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 156 | struct drm_display_mode previous_mode; |
| 157 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 158 | struct i2c_adapter *ddc; |
| 159 | void __iomem *regs; |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 160 | bool sink_is_hdmi; |
Russell King | f709ec0 | 2015-07-21 16:09:39 +0100 | [diff] [blame] | 161 | bool sink_has_audio; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 162 | |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 163 | struct mutex mutex; /* for state below and previous_mode */ |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 164 | enum drm_connector_force force; /* mutex-protected force state */ |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 165 | bool disabled; /* DRM has disabled our bridge */ |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 166 | bool bridge_is_on; /* indicates the bridge is on */ |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 167 | bool rxsense; /* rxsense state */ |
| 168 | u8 phy_mask; /* desired phy int mask settings */ |
Russell King | 7cc4ab2 | 2017-07-31 15:29:46 +0100 | [diff] [blame] | 169 | u8 mc_clkdis; /* clock disable register */ |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 170 | |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 171 | spinlock_t audio_lock; |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 172 | struct mutex audio_mutex; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 173 | unsigned int sample_rate; |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 174 | unsigned int audio_cts; |
| 175 | unsigned int audio_n; |
| 176 | bool audio_enable; |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 177 | |
Neil Armstrong | 80e2f97 | 2017-03-03 19:20:06 +0200 | [diff] [blame] | 178 | unsigned int reg_shift; |
| 179 | struct regmap *regm; |
Romain Perier | a7d555d | 2017-04-14 10:31:12 +0200 | [diff] [blame] | 180 | void (*enable_audio)(struct dw_hdmi *hdmi); |
| 181 | void (*disable_audio)(struct dw_hdmi *hdmi); |
Russell King | e84b8d7 | 2017-07-31 15:29:41 +0100 | [diff] [blame] | 182 | |
| 183 | struct cec_notifier *cec_notifier; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 184 | }; |
| 185 | |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 186 | #define HDMI_IH_PHY_STAT0_RX_SENSE \ |
| 187 | (HDMI_IH_PHY_STAT0_RX_SENSE0 | HDMI_IH_PHY_STAT0_RX_SENSE1 | \ |
| 188 | HDMI_IH_PHY_STAT0_RX_SENSE2 | HDMI_IH_PHY_STAT0_RX_SENSE3) |
| 189 | |
| 190 | #define HDMI_PHY_RX_SENSE \ |
| 191 | (HDMI_PHY_RX_SENSE0 | HDMI_PHY_RX_SENSE1 | \ |
| 192 | HDMI_PHY_RX_SENSE2 | HDMI_PHY_RX_SENSE3) |
| 193 | |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 194 | static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset) |
| 195 | { |
Neil Armstrong | 80e2f97 | 2017-03-03 19:20:06 +0200 | [diff] [blame] | 196 | regmap_write(hdmi->regm, offset << hdmi->reg_shift, val); |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset) |
| 200 | { |
Neil Armstrong | 80e2f97 | 2017-03-03 19:20:06 +0200 | [diff] [blame] | 201 | unsigned int val = 0; |
| 202 | |
| 203 | regmap_read(hdmi->regm, offset << hdmi->reg_shift, &val); |
| 204 | |
| 205 | return val; |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 206 | } |
| 207 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 208 | 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] | 209 | { |
Neil Armstrong | 80e2f97 | 2017-03-03 19:20:06 +0200 | [diff] [blame] | 210 | regmap_update_bits(hdmi->regm, reg << hdmi->reg_shift, mask, data); |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 213 | 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] | 214 | u8 shift, u8 mask) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 215 | { |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 216 | hdmi_modb(hdmi, data << shift, mask, reg); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 217 | } |
| 218 | |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 219 | static void dw_hdmi_i2c_init(struct dw_hdmi *hdmi) |
| 220 | { |
| 221 | /* Software reset */ |
| 222 | hdmi_writeb(hdmi, 0x00, HDMI_I2CM_SOFTRSTZ); |
| 223 | |
| 224 | /* Set Standard Mode speed (determined to be 100KHz on iMX6) */ |
| 225 | hdmi_writeb(hdmi, 0x00, HDMI_I2CM_DIV); |
| 226 | |
| 227 | /* Set done, not acknowledged and arbitration interrupt polarities */ |
| 228 | hdmi_writeb(hdmi, HDMI_I2CM_INT_DONE_POL, HDMI_I2CM_INT); |
| 229 | hdmi_writeb(hdmi, HDMI_I2CM_CTLINT_NAC_POL | HDMI_I2CM_CTLINT_ARB_POL, |
| 230 | HDMI_I2CM_CTLINT); |
| 231 | |
| 232 | /* Clear DONE and ERROR interrupts */ |
| 233 | hdmi_writeb(hdmi, HDMI_IH_I2CM_STAT0_ERROR | HDMI_IH_I2CM_STAT0_DONE, |
| 234 | HDMI_IH_I2CM_STAT0); |
| 235 | |
| 236 | /* Mute DONE and ERROR interrupts */ |
| 237 | hdmi_writeb(hdmi, HDMI_IH_I2CM_STAT0_ERROR | HDMI_IH_I2CM_STAT0_DONE, |
| 238 | HDMI_IH_MUTE_I2CM_STAT0); |
| 239 | } |
| 240 | |
| 241 | static int dw_hdmi_i2c_read(struct dw_hdmi *hdmi, |
| 242 | unsigned char *buf, unsigned int length) |
| 243 | { |
| 244 | struct dw_hdmi_i2c *i2c = hdmi->i2c; |
| 245 | int stat; |
| 246 | |
| 247 | if (!i2c->is_regaddr) { |
| 248 | dev_dbg(hdmi->dev, "set read register address to 0\n"); |
| 249 | i2c->slave_reg = 0x00; |
| 250 | i2c->is_regaddr = true; |
| 251 | } |
| 252 | |
| 253 | while (length--) { |
| 254 | reinit_completion(&i2c->cmp); |
| 255 | |
| 256 | hdmi_writeb(hdmi, i2c->slave_reg++, HDMI_I2CM_ADDRESS); |
Nickey Yang | 94bb4dc | 2017-03-20 10:57:31 +0800 | [diff] [blame] | 257 | if (i2c->is_segment) |
| 258 | hdmi_writeb(hdmi, HDMI_I2CM_OPERATION_READ_EXT, |
| 259 | HDMI_I2CM_OPERATION); |
| 260 | else |
| 261 | hdmi_writeb(hdmi, HDMI_I2CM_OPERATION_READ, |
| 262 | HDMI_I2CM_OPERATION); |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 263 | |
| 264 | stat = wait_for_completion_timeout(&i2c->cmp, HZ / 10); |
| 265 | if (!stat) |
| 266 | return -EAGAIN; |
| 267 | |
| 268 | /* Check for error condition on the bus */ |
| 269 | if (i2c->stat & HDMI_IH_I2CM_STAT0_ERROR) |
| 270 | return -EIO; |
| 271 | |
| 272 | *buf++ = hdmi_readb(hdmi, HDMI_I2CM_DATAI); |
| 273 | } |
Nickey Yang | 94bb4dc | 2017-03-20 10:57:31 +0800 | [diff] [blame] | 274 | i2c->is_segment = false; |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 275 | |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | static int dw_hdmi_i2c_write(struct dw_hdmi *hdmi, |
| 280 | unsigned char *buf, unsigned int length) |
| 281 | { |
| 282 | struct dw_hdmi_i2c *i2c = hdmi->i2c; |
| 283 | int stat; |
| 284 | |
| 285 | if (!i2c->is_regaddr) { |
| 286 | /* Use the first write byte as register address */ |
| 287 | i2c->slave_reg = buf[0]; |
| 288 | length--; |
| 289 | buf++; |
| 290 | i2c->is_regaddr = true; |
| 291 | } |
| 292 | |
| 293 | while (length--) { |
| 294 | reinit_completion(&i2c->cmp); |
| 295 | |
| 296 | hdmi_writeb(hdmi, *buf++, HDMI_I2CM_DATAO); |
| 297 | hdmi_writeb(hdmi, i2c->slave_reg++, HDMI_I2CM_ADDRESS); |
| 298 | hdmi_writeb(hdmi, HDMI_I2CM_OPERATION_WRITE, |
| 299 | HDMI_I2CM_OPERATION); |
| 300 | |
| 301 | stat = wait_for_completion_timeout(&i2c->cmp, HZ / 10); |
| 302 | if (!stat) |
| 303 | return -EAGAIN; |
| 304 | |
| 305 | /* Check for error condition on the bus */ |
| 306 | if (i2c->stat & HDMI_IH_I2CM_STAT0_ERROR) |
| 307 | return -EIO; |
| 308 | } |
| 309 | |
| 310 | return 0; |
| 311 | } |
| 312 | |
| 313 | static int dw_hdmi_i2c_xfer(struct i2c_adapter *adap, |
| 314 | struct i2c_msg *msgs, int num) |
| 315 | { |
| 316 | struct dw_hdmi *hdmi = i2c_get_adapdata(adap); |
| 317 | struct dw_hdmi_i2c *i2c = hdmi->i2c; |
| 318 | u8 addr = msgs[0].addr; |
| 319 | int i, ret = 0; |
| 320 | |
| 321 | dev_dbg(hdmi->dev, "xfer: num: %d, addr: %#x\n", num, addr); |
| 322 | |
| 323 | for (i = 0; i < num; i++) { |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 324 | if (msgs[i].len == 0) { |
| 325 | dev_dbg(hdmi->dev, |
| 326 | "unsupported transfer %d/%d, no data\n", |
| 327 | i + 1, num); |
| 328 | return -EOPNOTSUPP; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | mutex_lock(&i2c->lock); |
| 333 | |
| 334 | /* Unmute DONE and ERROR interrupts */ |
| 335 | hdmi_writeb(hdmi, 0x00, HDMI_IH_MUTE_I2CM_STAT0); |
| 336 | |
| 337 | /* Set slave device address taken from the first I2C message */ |
| 338 | hdmi_writeb(hdmi, addr, HDMI_I2CM_SLAVE); |
| 339 | |
| 340 | /* Set slave device register address on transfer */ |
| 341 | i2c->is_regaddr = false; |
| 342 | |
Nickey Yang | 94bb4dc | 2017-03-20 10:57:31 +0800 | [diff] [blame] | 343 | /* Set segment pointer for I2C extended read mode operation */ |
| 344 | i2c->is_segment = false; |
| 345 | |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 346 | for (i = 0; i < num; i++) { |
| 347 | dev_dbg(hdmi->dev, "xfer: num: %d/%d, len: %d, flags: %#x\n", |
| 348 | i + 1, num, msgs[i].len, msgs[i].flags); |
Nickey Yang | 94bb4dc | 2017-03-20 10:57:31 +0800 | [diff] [blame] | 349 | if (msgs[i].addr == DDC_SEGMENT_ADDR && msgs[i].len == 1) { |
| 350 | i2c->is_segment = true; |
| 351 | hdmi_writeb(hdmi, DDC_SEGMENT_ADDR, HDMI_I2CM_SEGADDR); |
| 352 | hdmi_writeb(hdmi, *msgs[i].buf, HDMI_I2CM_SEGPTR); |
| 353 | } else { |
| 354 | if (msgs[i].flags & I2C_M_RD) |
| 355 | ret = dw_hdmi_i2c_read(hdmi, msgs[i].buf, |
| 356 | msgs[i].len); |
| 357 | else |
| 358 | ret = dw_hdmi_i2c_write(hdmi, msgs[i].buf, |
| 359 | msgs[i].len); |
| 360 | } |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 361 | if (ret < 0) |
| 362 | break; |
| 363 | } |
| 364 | |
| 365 | if (!ret) |
| 366 | ret = num; |
| 367 | |
| 368 | /* Mute DONE and ERROR interrupts */ |
| 369 | hdmi_writeb(hdmi, HDMI_IH_I2CM_STAT0_ERROR | HDMI_IH_I2CM_STAT0_DONE, |
| 370 | HDMI_IH_MUTE_I2CM_STAT0); |
| 371 | |
| 372 | mutex_unlock(&i2c->lock); |
| 373 | |
| 374 | return ret; |
| 375 | } |
| 376 | |
| 377 | static u32 dw_hdmi_i2c_func(struct i2c_adapter *adapter) |
| 378 | { |
| 379 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; |
| 380 | } |
| 381 | |
| 382 | static const struct i2c_algorithm dw_hdmi_algorithm = { |
| 383 | .master_xfer = dw_hdmi_i2c_xfer, |
| 384 | .functionality = dw_hdmi_i2c_func, |
| 385 | }; |
| 386 | |
| 387 | static struct i2c_adapter *dw_hdmi_i2c_adapter(struct dw_hdmi *hdmi) |
| 388 | { |
| 389 | struct i2c_adapter *adap; |
| 390 | struct dw_hdmi_i2c *i2c; |
| 391 | int ret; |
| 392 | |
| 393 | i2c = devm_kzalloc(hdmi->dev, sizeof(*i2c), GFP_KERNEL); |
| 394 | if (!i2c) |
| 395 | return ERR_PTR(-ENOMEM); |
| 396 | |
| 397 | mutex_init(&i2c->lock); |
| 398 | init_completion(&i2c->cmp); |
| 399 | |
| 400 | adap = &i2c->adap; |
| 401 | adap->class = I2C_CLASS_DDC; |
| 402 | adap->owner = THIS_MODULE; |
| 403 | adap->dev.parent = hdmi->dev; |
| 404 | adap->algo = &dw_hdmi_algorithm; |
| 405 | strlcpy(adap->name, "DesignWare HDMI", sizeof(adap->name)); |
| 406 | i2c_set_adapdata(adap, hdmi); |
| 407 | |
| 408 | ret = i2c_add_adapter(adap); |
| 409 | if (ret) { |
| 410 | dev_warn(hdmi->dev, "cannot add %s I2C adapter\n", adap->name); |
| 411 | devm_kfree(hdmi->dev, i2c); |
| 412 | return ERR_PTR(ret); |
| 413 | } |
| 414 | |
| 415 | hdmi->i2c = i2c; |
| 416 | |
| 417 | dev_info(hdmi->dev, "registered %s I2C bus driver\n", adap->name); |
| 418 | |
| 419 | return adap; |
| 420 | } |
| 421 | |
Russell King | 351e135 | 2015-01-31 14:50:23 +0000 | [diff] [blame] | 422 | static void hdmi_set_cts_n(struct dw_hdmi *hdmi, unsigned int cts, |
| 423 | unsigned int n) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 424 | { |
Russell King | 622494a | 2015-02-02 10:55:38 +0000 | [diff] [blame] | 425 | /* Must be set/cleared first */ |
| 426 | hdmi_modb(hdmi, 0, HDMI_AUD_CTS3_CTS_MANUAL, HDMI_AUD_CTS3); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 427 | |
| 428 | /* nshift factor = 0 */ |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 429 | 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] | 430 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 431 | hdmi_writeb(hdmi, ((cts >> 16) & HDMI_AUD_CTS3_AUDCTS19_16_MASK) | |
| 432 | HDMI_AUD_CTS3_CTS_MANUAL, HDMI_AUD_CTS3); |
Russell King | 622494a | 2015-02-02 10:55:38 +0000 | [diff] [blame] | 433 | hdmi_writeb(hdmi, (cts >> 8) & 0xff, HDMI_AUD_CTS2); |
| 434 | hdmi_writeb(hdmi, cts & 0xff, HDMI_AUD_CTS1); |
| 435 | |
| 436 | hdmi_writeb(hdmi, (n >> 16) & 0x0f, HDMI_AUD_N3); |
| 437 | hdmi_writeb(hdmi, (n >> 8) & 0xff, HDMI_AUD_N2); |
| 438 | hdmi_writeb(hdmi, n & 0xff, HDMI_AUD_N1); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 439 | } |
| 440 | |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 441 | static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 442 | { |
| 443 | unsigned int n = (128 * freq) / 1000; |
Russell King | d0c96d1 | 2015-07-22 10:35:41 +0100 | [diff] [blame] | 444 | unsigned int mult = 1; |
| 445 | |
| 446 | while (freq > 48000) { |
| 447 | mult *= 2; |
| 448 | freq /= 2; |
| 449 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 450 | |
| 451 | switch (freq) { |
| 452 | case 32000: |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 453 | if (pixel_clk == 25175000) |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 454 | n = 4576; |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 455 | else if (pixel_clk == 27027000) |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 456 | n = 4096; |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 457 | else if (pixel_clk == 74176000 || pixel_clk == 148352000) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 458 | n = 11648; |
| 459 | else |
| 460 | n = 4096; |
Russell King | d0c96d1 | 2015-07-22 10:35:41 +0100 | [diff] [blame] | 461 | n *= mult; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 462 | break; |
| 463 | |
| 464 | case 44100: |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 465 | if (pixel_clk == 25175000) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 466 | n = 7007; |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 467 | else if (pixel_clk == 74176000) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 468 | n = 17836; |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 469 | else if (pixel_clk == 148352000) |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 470 | n = 8918; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 471 | else |
| 472 | n = 6272; |
Russell King | d0c96d1 | 2015-07-22 10:35:41 +0100 | [diff] [blame] | 473 | n *= mult; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 474 | break; |
| 475 | |
| 476 | case 48000: |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 477 | if (pixel_clk == 25175000) |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 478 | n = 6864; |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 479 | else if (pixel_clk == 27027000) |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 480 | n = 6144; |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 481 | else if (pixel_clk == 74176000) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 482 | n = 11648; |
Russell King | 426701d | 2015-07-22 10:39:27 +0100 | [diff] [blame] | 483 | else if (pixel_clk == 148352000) |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 484 | n = 5824; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 485 | else |
| 486 | n = 6144; |
Russell King | d0c96d1 | 2015-07-22 10:35:41 +0100 | [diff] [blame] | 487 | n *= mult; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 488 | break; |
| 489 | |
| 490 | default: |
| 491 | break; |
| 492 | } |
| 493 | |
| 494 | return n; |
| 495 | } |
| 496 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 497 | static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 498 | unsigned long pixel_clk, unsigned int sample_rate) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 499 | { |
Russell King | dfbdaf5 | 2015-07-22 16:54:37 +0100 | [diff] [blame] | 500 | unsigned long ftdms = pixel_clk; |
Russell King | f879b38 | 2015-03-27 12:53:29 +0000 | [diff] [blame] | 501 | unsigned int n, cts; |
Russell King | dfbdaf5 | 2015-07-22 16:54:37 +0100 | [diff] [blame] | 502 | u64 tmp; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 503 | |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 504 | n = hdmi_compute_n(sample_rate, pixel_clk); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 505 | |
Russell King | dfbdaf5 | 2015-07-22 16:54:37 +0100 | [diff] [blame] | 506 | /* |
| 507 | * Compute the CTS value from the N value. Note that CTS and N |
| 508 | * can be up to 20 bits in total, so we need 64-bit math. Also |
| 509 | * note that our TDMS clock is not fully accurate; it is accurate |
| 510 | * to kHz. This can introduce an unnecessary remainder in the |
| 511 | * calculation below, so we don't try to warn about that. |
| 512 | */ |
| 513 | tmp = (u64)ftdms * n; |
| 514 | do_div(tmp, 128 * sample_rate); |
| 515 | cts = tmp; |
| 516 | |
| 517 | dev_dbg(hdmi->dev, "%s: fs=%uHz ftdms=%lu.%03luMHz N=%d cts=%d\n", |
| 518 | __func__, sample_rate, ftdms / 1000000, (ftdms / 1000) % 1000, |
| 519 | n, cts); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 520 | |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 521 | spin_lock_irq(&hdmi->audio_lock); |
| 522 | hdmi->audio_n = n; |
| 523 | hdmi->audio_cts = cts; |
| 524 | hdmi_set_cts_n(hdmi, cts, hdmi->audio_enable ? n : 0); |
| 525 | spin_unlock_irq(&hdmi->audio_lock); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 526 | } |
| 527 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 528 | static void hdmi_init_clk_regenerator(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 529 | { |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 530 | mutex_lock(&hdmi->audio_mutex); |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 531 | hdmi_set_clk_regenerator(hdmi, 74250000, hdmi->sample_rate); |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 532 | mutex_unlock(&hdmi->audio_mutex); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 533 | } |
| 534 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 535 | static void hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 536 | { |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 537 | mutex_lock(&hdmi->audio_mutex); |
Russell King | f879b38 | 2015-03-27 12:53:29 +0000 | [diff] [blame] | 538 | hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock, |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 539 | hdmi->sample_rate); |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 540 | mutex_unlock(&hdmi->audio_mutex); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 541 | } |
| 542 | |
Russell King | b5814ff | 2015-03-27 12:50:58 +0000 | [diff] [blame] | 543 | void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate) |
| 544 | { |
| 545 | mutex_lock(&hdmi->audio_mutex); |
| 546 | hdmi->sample_rate = rate; |
| 547 | hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock, |
Russell King | b195fbd | 2015-07-22 11:28:16 +0100 | [diff] [blame] | 548 | hdmi->sample_rate); |
Russell King | b5814ff | 2015-03-27 12:50:58 +0000 | [diff] [blame] | 549 | mutex_unlock(&hdmi->audio_mutex); |
| 550 | } |
| 551 | EXPORT_SYMBOL_GPL(dw_hdmi_set_sample_rate); |
| 552 | |
Romain Perier | 57fbc05 | 2017-04-20 14:34:34 +0530 | [diff] [blame] | 553 | static void hdmi_enable_audio_clk(struct dw_hdmi *hdmi, bool enable) |
| 554 | { |
Russell King | 7cc4ab2 | 2017-07-31 15:29:46 +0100 | [diff] [blame] | 555 | if (enable) |
| 556 | hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_AUDCLK_DISABLE; |
| 557 | else |
| 558 | hdmi->mc_clkdis |= HDMI_MC_CLKDIS_AUDCLK_DISABLE; |
| 559 | hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); |
Romain Perier | 57fbc05 | 2017-04-20 14:34:34 +0530 | [diff] [blame] | 560 | } |
| 561 | |
Romain Perier | a7d555d | 2017-04-14 10:31:12 +0200 | [diff] [blame] | 562 | static void dw_hdmi_ahb_audio_enable(struct dw_hdmi *hdmi) |
| 563 | { |
| 564 | hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); |
| 565 | } |
| 566 | |
| 567 | static void dw_hdmi_ahb_audio_disable(struct dw_hdmi *hdmi) |
| 568 | { |
| 569 | hdmi_set_cts_n(hdmi, hdmi->audio_cts, 0); |
| 570 | } |
| 571 | |
| 572 | static void dw_hdmi_i2s_audio_enable(struct dw_hdmi *hdmi) |
| 573 | { |
| 574 | hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); |
Romain Perier | 57fbc05 | 2017-04-20 14:34:34 +0530 | [diff] [blame] | 575 | hdmi_enable_audio_clk(hdmi, true); |
| 576 | } |
| 577 | |
| 578 | static void dw_hdmi_i2s_audio_disable(struct dw_hdmi *hdmi) |
| 579 | { |
| 580 | hdmi_enable_audio_clk(hdmi, false); |
Romain Perier | a7d555d | 2017-04-14 10:31:12 +0200 | [diff] [blame] | 581 | } |
| 582 | |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 583 | void dw_hdmi_audio_enable(struct dw_hdmi *hdmi) |
| 584 | { |
| 585 | unsigned long flags; |
| 586 | |
| 587 | spin_lock_irqsave(&hdmi->audio_lock, flags); |
| 588 | hdmi->audio_enable = true; |
Romain Perier | a7d555d | 2017-04-14 10:31:12 +0200 | [diff] [blame] | 589 | if (hdmi->enable_audio) |
| 590 | hdmi->enable_audio(hdmi); |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 591 | spin_unlock_irqrestore(&hdmi->audio_lock, flags); |
| 592 | } |
| 593 | EXPORT_SYMBOL_GPL(dw_hdmi_audio_enable); |
| 594 | |
| 595 | void dw_hdmi_audio_disable(struct dw_hdmi *hdmi) |
| 596 | { |
| 597 | unsigned long flags; |
| 598 | |
| 599 | spin_lock_irqsave(&hdmi->audio_lock, flags); |
| 600 | hdmi->audio_enable = false; |
Romain Perier | a7d555d | 2017-04-14 10:31:12 +0200 | [diff] [blame] | 601 | if (hdmi->disable_audio) |
| 602 | hdmi->disable_audio(hdmi); |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 603 | spin_unlock_irqrestore(&hdmi->audio_lock, flags); |
| 604 | } |
| 605 | EXPORT_SYMBOL_GPL(dw_hdmi_audio_disable); |
| 606 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 607 | static bool hdmi_bus_fmt_is_rgb(unsigned int bus_format) |
| 608 | { |
| 609 | switch (bus_format) { |
| 610 | case MEDIA_BUS_FMT_RGB888_1X24: |
| 611 | case MEDIA_BUS_FMT_RGB101010_1X30: |
| 612 | case MEDIA_BUS_FMT_RGB121212_1X36: |
| 613 | case MEDIA_BUS_FMT_RGB161616_1X48: |
| 614 | return true; |
| 615 | |
| 616 | default: |
| 617 | return false; |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | static bool hdmi_bus_fmt_is_yuv444(unsigned int bus_format) |
| 622 | { |
| 623 | switch (bus_format) { |
| 624 | case MEDIA_BUS_FMT_YUV8_1X24: |
| 625 | case MEDIA_BUS_FMT_YUV10_1X30: |
| 626 | case MEDIA_BUS_FMT_YUV12_1X36: |
| 627 | case MEDIA_BUS_FMT_YUV16_1X48: |
| 628 | return true; |
| 629 | |
| 630 | default: |
| 631 | return false; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | static bool hdmi_bus_fmt_is_yuv422(unsigned int bus_format) |
| 636 | { |
| 637 | switch (bus_format) { |
| 638 | case MEDIA_BUS_FMT_UYVY8_1X16: |
| 639 | case MEDIA_BUS_FMT_UYVY10_1X20: |
| 640 | case MEDIA_BUS_FMT_UYVY12_1X24: |
| 641 | return true; |
| 642 | |
| 643 | default: |
| 644 | return false; |
| 645 | } |
| 646 | } |
| 647 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 648 | static int hdmi_bus_fmt_color_depth(unsigned int bus_format) |
| 649 | { |
| 650 | switch (bus_format) { |
| 651 | case MEDIA_BUS_FMT_RGB888_1X24: |
| 652 | case MEDIA_BUS_FMT_YUV8_1X24: |
| 653 | case MEDIA_BUS_FMT_UYVY8_1X16: |
| 654 | case MEDIA_BUS_FMT_UYYVYY8_0_5X24: |
| 655 | return 8; |
| 656 | |
| 657 | case MEDIA_BUS_FMT_RGB101010_1X30: |
| 658 | case MEDIA_BUS_FMT_YUV10_1X30: |
| 659 | case MEDIA_BUS_FMT_UYVY10_1X20: |
| 660 | case MEDIA_BUS_FMT_UYYVYY10_0_5X30: |
| 661 | return 10; |
| 662 | |
| 663 | case MEDIA_BUS_FMT_RGB121212_1X36: |
| 664 | case MEDIA_BUS_FMT_YUV12_1X36: |
| 665 | case MEDIA_BUS_FMT_UYVY12_1X24: |
| 666 | case MEDIA_BUS_FMT_UYYVYY12_0_5X36: |
| 667 | return 12; |
| 668 | |
| 669 | case MEDIA_BUS_FMT_RGB161616_1X48: |
| 670 | case MEDIA_BUS_FMT_YUV16_1X48: |
| 671 | case MEDIA_BUS_FMT_UYYVYY16_0_5X48: |
| 672 | return 16; |
| 673 | |
| 674 | default: |
| 675 | return 0; |
| 676 | } |
| 677 | } |
| 678 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 679 | /* |
| 680 | * this submodule is responsible for the video data synchronization. |
| 681 | * for example, for RGB 4:4:4 input, the data map is defined as |
| 682 | * pin{47~40} <==> R[7:0] |
| 683 | * pin{31~24} <==> G[7:0] |
| 684 | * pin{15~8} <==> B[7:0] |
| 685 | */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 686 | static void hdmi_video_sample(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 687 | { |
| 688 | int color_format = 0; |
| 689 | u8 val; |
| 690 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 691 | switch (hdmi->hdmi_data.enc_in_bus_format) { |
| 692 | case MEDIA_BUS_FMT_RGB888_1X24: |
| 693 | color_format = 0x01; |
| 694 | break; |
| 695 | case MEDIA_BUS_FMT_RGB101010_1X30: |
| 696 | color_format = 0x03; |
| 697 | break; |
| 698 | case MEDIA_BUS_FMT_RGB121212_1X36: |
| 699 | color_format = 0x05; |
| 700 | break; |
| 701 | case MEDIA_BUS_FMT_RGB161616_1X48: |
| 702 | color_format = 0x07; |
| 703 | break; |
| 704 | |
| 705 | case MEDIA_BUS_FMT_YUV8_1X24: |
| 706 | case MEDIA_BUS_FMT_UYYVYY8_0_5X24: |
| 707 | color_format = 0x09; |
| 708 | break; |
| 709 | case MEDIA_BUS_FMT_YUV10_1X30: |
| 710 | case MEDIA_BUS_FMT_UYYVYY10_0_5X30: |
| 711 | color_format = 0x0B; |
| 712 | break; |
| 713 | case MEDIA_BUS_FMT_YUV12_1X36: |
| 714 | case MEDIA_BUS_FMT_UYYVYY12_0_5X36: |
| 715 | color_format = 0x0D; |
| 716 | break; |
| 717 | case MEDIA_BUS_FMT_YUV16_1X48: |
| 718 | case MEDIA_BUS_FMT_UYYVYY16_0_5X48: |
| 719 | color_format = 0x0F; |
| 720 | break; |
| 721 | |
| 722 | case MEDIA_BUS_FMT_UYVY8_1X16: |
| 723 | color_format = 0x16; |
| 724 | break; |
| 725 | case MEDIA_BUS_FMT_UYVY10_1X20: |
| 726 | color_format = 0x14; |
| 727 | break; |
| 728 | case MEDIA_BUS_FMT_UYVY12_1X24: |
| 729 | color_format = 0x12; |
| 730 | break; |
| 731 | |
| 732 | default: |
| 733 | return; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | val = HDMI_TX_INVID0_INTERNAL_DE_GENERATOR_DISABLE | |
| 737 | ((color_format << HDMI_TX_INVID0_VIDEO_MAPPING_OFFSET) & |
| 738 | HDMI_TX_INVID0_VIDEO_MAPPING_MASK); |
| 739 | hdmi_writeb(hdmi, val, HDMI_TX_INVID0); |
| 740 | |
| 741 | /* Enable TX stuffing: When DE is inactive, fix the output data to 0 */ |
| 742 | val = HDMI_TX_INSTUFFING_BDBDATA_STUFFING_ENABLE | |
| 743 | HDMI_TX_INSTUFFING_RCRDATA_STUFFING_ENABLE | |
| 744 | HDMI_TX_INSTUFFING_GYDATA_STUFFING_ENABLE; |
| 745 | hdmi_writeb(hdmi, val, HDMI_TX_INSTUFFING); |
| 746 | hdmi_writeb(hdmi, 0x0, HDMI_TX_GYDATA0); |
| 747 | hdmi_writeb(hdmi, 0x0, HDMI_TX_GYDATA1); |
| 748 | hdmi_writeb(hdmi, 0x0, HDMI_TX_RCRDATA0); |
| 749 | hdmi_writeb(hdmi, 0x0, HDMI_TX_RCRDATA1); |
| 750 | hdmi_writeb(hdmi, 0x0, HDMI_TX_BCBDATA0); |
| 751 | hdmi_writeb(hdmi, 0x0, HDMI_TX_BCBDATA1); |
| 752 | } |
| 753 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 754 | static int is_color_space_conversion(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 755 | { |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 756 | return hdmi->hdmi_data.enc_in_bus_format != hdmi->hdmi_data.enc_out_bus_format; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 757 | } |
| 758 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 759 | static int is_color_space_decimation(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 760 | { |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 761 | if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) |
Fabio Estevam | ba92b22 | 2014-02-06 10:12:03 -0200 | [diff] [blame] | 762 | return 0; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 763 | |
| 764 | if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_in_bus_format) || |
| 765 | hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_in_bus_format)) |
Fabio Estevam | ba92b22 | 2014-02-06 10:12:03 -0200 | [diff] [blame] | 766 | return 1; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 767 | |
Fabio Estevam | ba92b22 | 2014-02-06 10:12:03 -0200 | [diff] [blame] | 768 | return 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 769 | } |
| 770 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 771 | static int is_color_space_interpolation(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 772 | { |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 773 | if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_in_bus_format)) |
Fabio Estevam | ba92b22 | 2014-02-06 10:12:03 -0200 | [diff] [blame] | 774 | return 0; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 775 | |
| 776 | if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) || |
| 777 | hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format)) |
Fabio Estevam | ba92b22 | 2014-02-06 10:12:03 -0200 | [diff] [blame] | 778 | return 1; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 779 | |
Fabio Estevam | ba92b22 | 2014-02-06 10:12:03 -0200 | [diff] [blame] | 780 | return 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 781 | } |
| 782 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 783 | static void dw_hdmi_update_csc_coeffs(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 784 | { |
| 785 | const u16 (*csc_coeff)[3][4] = &csc_coeff_default; |
Russell King | c082f9d | 2013-11-04 12:10:40 +0000 | [diff] [blame] | 786 | unsigned i; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 787 | u32 csc_scale = 1; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 788 | |
| 789 | if (is_color_space_conversion(hdmi)) { |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 790 | if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format)) { |
| 791 | if (hdmi->hdmi_data.enc_out_encoding == |
| 792 | V4L2_YCBCR_ENC_601) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 793 | csc_coeff = &csc_coeff_rgb_out_eitu601; |
| 794 | else |
| 795 | csc_coeff = &csc_coeff_rgb_out_eitu709; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 796 | } else if (hdmi_bus_fmt_is_rgb( |
| 797 | hdmi->hdmi_data.enc_in_bus_format)) { |
| 798 | if (hdmi->hdmi_data.enc_out_encoding == |
| 799 | V4L2_YCBCR_ENC_601) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 800 | csc_coeff = &csc_coeff_rgb_in_eitu601; |
| 801 | else |
| 802 | csc_coeff = &csc_coeff_rgb_in_eitu709; |
| 803 | csc_scale = 0; |
| 804 | } |
| 805 | } |
| 806 | |
Russell King | c082f9d | 2013-11-04 12:10:40 +0000 | [diff] [blame] | 807 | /* The CSC registers are sequential, alternating MSB then LSB */ |
| 808 | for (i = 0; i < ARRAY_SIZE(csc_coeff_default[0]); i++) { |
| 809 | u16 coeff_a = (*csc_coeff)[0][i]; |
| 810 | u16 coeff_b = (*csc_coeff)[1][i]; |
| 811 | u16 coeff_c = (*csc_coeff)[2][i]; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 812 | |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 813 | 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] | 814 | hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2); |
| 815 | hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2); |
| 816 | 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] | 817 | 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] | 818 | hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2); |
| 819 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 820 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 821 | hdmi_modb(hdmi, csc_scale, HDMI_CSC_SCALE_CSCSCALE_MASK, |
| 822 | HDMI_CSC_SCALE); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 823 | } |
| 824 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 825 | static void hdmi_video_csc(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 826 | { |
| 827 | int color_depth = 0; |
| 828 | int interpolation = HDMI_CSC_CFG_INTMODE_DISABLE; |
| 829 | int decimation = 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 830 | |
| 831 | /* YCC422 interpolation to 444 mode */ |
| 832 | if (is_color_space_interpolation(hdmi)) |
| 833 | interpolation = HDMI_CSC_CFG_INTMODE_CHROMA_INT_FORMULA1; |
| 834 | else if (is_color_space_decimation(hdmi)) |
| 835 | decimation = HDMI_CSC_CFG_DECMODE_CHROMA_INT_FORMULA3; |
| 836 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 837 | switch (hdmi_bus_fmt_color_depth(hdmi->hdmi_data.enc_out_bus_format)) { |
| 838 | case 8: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 839 | color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_24BPP; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 840 | break; |
| 841 | case 10: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 842 | color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_30BPP; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 843 | break; |
| 844 | case 12: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 845 | color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_36BPP; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 846 | break; |
| 847 | case 16: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 848 | color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_48BPP; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 849 | break; |
| 850 | |
| 851 | default: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 852 | return; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 853 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 854 | |
| 855 | /* Configure the CSC registers */ |
| 856 | hdmi_writeb(hdmi, interpolation | decimation, HDMI_CSC_CFG); |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 857 | hdmi_modb(hdmi, color_depth, HDMI_CSC_SCALE_CSC_COLORDE_PTH_MASK, |
| 858 | HDMI_CSC_SCALE); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 859 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 860 | dw_hdmi_update_csc_coeffs(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 861 | } |
| 862 | |
| 863 | /* |
| 864 | * HDMI video packetizer is used to packetize the data. |
| 865 | * for example, if input is YCC422 mode or repeater is used, |
| 866 | * data should be repacked this module can be bypassed. |
| 867 | */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 868 | static void hdmi_video_packetize(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 869 | { |
| 870 | unsigned int color_depth = 0; |
| 871 | unsigned int remap_size = HDMI_VP_REMAP_YCC422_16bit; |
| 872 | unsigned int output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_PP; |
| 873 | struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 874 | u8 val, vp_conf; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 875 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 876 | if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) || |
| 877 | hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format)) { |
| 878 | switch (hdmi_bus_fmt_color_depth( |
| 879 | hdmi->hdmi_data.enc_out_bus_format)) { |
| 880 | case 8: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 881 | color_depth = 4; |
| 882 | output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 883 | break; |
| 884 | case 10: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 885 | color_depth = 5; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 886 | break; |
| 887 | case 12: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 888 | color_depth = 6; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 889 | break; |
| 890 | case 16: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 891 | color_depth = 7; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 892 | break; |
| 893 | default: |
| 894 | output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; |
| 895 | } |
| 896 | } else if (hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) { |
| 897 | switch (hdmi_bus_fmt_color_depth( |
| 898 | hdmi->hdmi_data.enc_out_bus_format)) { |
| 899 | case 0: |
| 900 | case 8: |
| 901 | remap_size = HDMI_VP_REMAP_YCC422_16bit; |
| 902 | break; |
| 903 | case 10: |
| 904 | remap_size = HDMI_VP_REMAP_YCC422_20bit; |
| 905 | break; |
| 906 | case 12: |
| 907 | remap_size = HDMI_VP_REMAP_YCC422_24bit; |
| 908 | break; |
| 909 | |
| 910 | default: |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 911 | return; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 912 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 913 | output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 914 | } else { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 915 | return; |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 916 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 917 | |
| 918 | /* set the packetizer registers */ |
| 919 | val = ((color_depth << HDMI_VP_PR_CD_COLOR_DEPTH_OFFSET) & |
| 920 | HDMI_VP_PR_CD_COLOR_DEPTH_MASK) | |
| 921 | ((hdmi_data->pix_repet_factor << |
| 922 | HDMI_VP_PR_CD_DESIRED_PR_FACTOR_OFFSET) & |
| 923 | HDMI_VP_PR_CD_DESIRED_PR_FACTOR_MASK); |
| 924 | hdmi_writeb(hdmi, val, HDMI_VP_PR_CD); |
| 925 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 926 | hdmi_modb(hdmi, HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE, |
| 927 | HDMI_VP_STUFF_PR_STUFFING_MASK, HDMI_VP_STUFF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 928 | |
| 929 | /* Data from pixel repeater block */ |
| 930 | if (hdmi_data->pix_repet_factor > 1) { |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 931 | vp_conf = HDMI_VP_CONF_PR_EN_ENABLE | |
| 932 | HDMI_VP_CONF_BYPASS_SELECT_PIX_REPEATER; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 933 | } else { /* data from packetizer block */ |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 934 | vp_conf = HDMI_VP_CONF_PR_EN_DISABLE | |
| 935 | HDMI_VP_CONF_BYPASS_SELECT_VID_PACKETIZER; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 936 | } |
| 937 | |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 938 | hdmi_modb(hdmi, vp_conf, |
| 939 | HDMI_VP_CONF_PR_EN_MASK | |
| 940 | HDMI_VP_CONF_BYPASS_SELECT_MASK, HDMI_VP_CONF); |
| 941 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 942 | hdmi_modb(hdmi, 1 << HDMI_VP_STUFF_IDEFAULT_PHASE_OFFSET, |
| 943 | HDMI_VP_STUFF_IDEFAULT_PHASE_MASK, HDMI_VP_STUFF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 944 | |
| 945 | hdmi_writeb(hdmi, remap_size, HDMI_VP_REMAP); |
| 946 | |
| 947 | if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_PP) { |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 948 | vp_conf = HDMI_VP_CONF_BYPASS_EN_DISABLE | |
| 949 | HDMI_VP_CONF_PP_EN_ENABLE | |
| 950 | HDMI_VP_CONF_YCC422_EN_DISABLE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 951 | } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422) { |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 952 | vp_conf = HDMI_VP_CONF_BYPASS_EN_DISABLE | |
| 953 | HDMI_VP_CONF_PP_EN_DISABLE | |
| 954 | HDMI_VP_CONF_YCC422_EN_ENABLE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 955 | } else if (output_select == HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS) { |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 956 | vp_conf = HDMI_VP_CONF_BYPASS_EN_ENABLE | |
| 957 | HDMI_VP_CONF_PP_EN_DISABLE | |
| 958 | HDMI_VP_CONF_YCC422_EN_DISABLE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 959 | } else { |
| 960 | return; |
| 961 | } |
| 962 | |
Russell King | bebdf66 | 2013-11-04 12:55:30 +0000 | [diff] [blame] | 963 | hdmi_modb(hdmi, vp_conf, |
| 964 | HDMI_VP_CONF_BYPASS_EN_MASK | HDMI_VP_CONF_PP_EN_ENMASK | |
| 965 | HDMI_VP_CONF_YCC422_EN_MASK, HDMI_VP_CONF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 966 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 967 | hdmi_modb(hdmi, HDMI_VP_STUFF_PP_STUFFING_STUFFING_MODE | |
| 968 | HDMI_VP_STUFF_YCC422_STUFFING_STUFFING_MODE, |
| 969 | HDMI_VP_STUFF_PP_STUFFING_MASK | |
| 970 | HDMI_VP_STUFF_YCC422_STUFFING_MASK, HDMI_VP_STUFF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 971 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 972 | hdmi_modb(hdmi, output_select, HDMI_VP_CONF_OUTPUT_SELECTOR_MASK, |
| 973 | HDMI_VP_CONF); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 974 | } |
| 975 | |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 976 | /* ----------------------------------------------------------------------------- |
| 977 | * Synopsys PHY Handling |
| 978 | */ |
| 979 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 980 | static inline void hdmi_phy_test_clear(struct dw_hdmi *hdmi, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 981 | unsigned char bit) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 982 | { |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 983 | hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTCLR_OFFSET, |
| 984 | HDMI_PHY_TST0_TSTCLR_MASK, HDMI_PHY_TST0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 985 | } |
| 986 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 987 | 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] | 988 | { |
Andy Yan | a4d3b8b | 2014-12-05 14:31:09 +0800 | [diff] [blame] | 989 | u32 val; |
| 990 | |
| 991 | while ((val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 992 | if (msec-- == 0) |
| 993 | return false; |
Emil Renner Berthing | 0e6bcf3 | 2014-03-30 00:21:21 +0100 | [diff] [blame] | 994 | udelay(1000); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 995 | } |
Andy Yan | a4d3b8b | 2014-12-05 14:31:09 +0800 | [diff] [blame] | 996 | hdmi_writeb(hdmi, val, HDMI_IH_I2CMPHY_STAT0); |
| 997 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 998 | return true; |
| 999 | } |
| 1000 | |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 1001 | void dw_hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data, |
| 1002 | unsigned char addr) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1003 | { |
| 1004 | hdmi_writeb(hdmi, 0xFF, HDMI_IH_I2CMPHY_STAT0); |
| 1005 | hdmi_writeb(hdmi, addr, HDMI_PHY_I2CM_ADDRESS_ADDR); |
| 1006 | hdmi_writeb(hdmi, (unsigned char)(data >> 8), |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1007 | HDMI_PHY_I2CM_DATAO_1_ADDR); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1008 | hdmi_writeb(hdmi, (unsigned char)(data >> 0), |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1009 | HDMI_PHY_I2CM_DATAO_0_ADDR); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1010 | hdmi_writeb(hdmi, HDMI_PHY_I2CM_OPERATION_ADDR_WRITE, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1011 | HDMI_PHY_I2CM_OPERATION_ADDR); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1012 | hdmi_phy_wait_i2c_done(hdmi, 1000); |
| 1013 | } |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 1014 | EXPORT_SYMBOL_GPL(dw_hdmi_phy_i2c_write); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1015 | |
Russell King | 2fada10 | 2015-07-28 12:21:34 +0100 | [diff] [blame] | 1016 | 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] | 1017 | { |
Russell King | 2fada10 | 2015-07-28 12:21:34 +0100 | [diff] [blame] | 1018 | hdmi_mask_writeb(hdmi, !enable, HDMI_PHY_CONF0, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1019 | HDMI_PHY_CONF0_PDZ_OFFSET, |
| 1020 | HDMI_PHY_CONF0_PDZ_MASK); |
| 1021 | } |
| 1022 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1023 | 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] | 1024 | { |
| 1025 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 1026 | HDMI_PHY_CONF0_ENTMDS_OFFSET, |
| 1027 | HDMI_PHY_CONF0_ENTMDS_MASK); |
| 1028 | } |
| 1029 | |
Laurent Pinchart | f4104e8 | 2017-01-17 10:29:02 +0200 | [diff] [blame] | 1030 | static void dw_hdmi_phy_enable_svsret(struct dw_hdmi *hdmi, u8 enable) |
Andy Yan | d346c14 | 2014-12-05 14:31:53 +0800 | [diff] [blame] | 1031 | { |
| 1032 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
Laurent Pinchart | f4104e8 | 2017-01-17 10:29:02 +0200 | [diff] [blame] | 1033 | HDMI_PHY_CONF0_SVSRET_OFFSET, |
| 1034 | HDMI_PHY_CONF0_SVSRET_MASK); |
Andy Yan | d346c14 | 2014-12-05 14:31:53 +0800 | [diff] [blame] | 1035 | } |
| 1036 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1037 | 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] | 1038 | { |
| 1039 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 1040 | HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET, |
| 1041 | HDMI_PHY_CONF0_GEN2_PDDQ_MASK); |
| 1042 | } |
| 1043 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1044 | 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] | 1045 | { |
| 1046 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 1047 | HDMI_PHY_CONF0_GEN2_TXPWRON_OFFSET, |
| 1048 | HDMI_PHY_CONF0_GEN2_TXPWRON_MASK); |
| 1049 | } |
| 1050 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1051 | 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] | 1052 | { |
| 1053 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 1054 | HDMI_PHY_CONF0_SELDATAENPOL_OFFSET, |
| 1055 | HDMI_PHY_CONF0_SELDATAENPOL_MASK); |
| 1056 | } |
| 1057 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1058 | 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] | 1059 | { |
| 1060 | hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, |
| 1061 | HDMI_PHY_CONF0_SELDIPIF_OFFSET, |
| 1062 | HDMI_PHY_CONF0_SELDIPIF_MASK); |
| 1063 | } |
| 1064 | |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 1065 | static void dw_hdmi_phy_power_off(struct dw_hdmi *hdmi) |
| 1066 | { |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1067 | const struct dw_hdmi_phy_data *phy = hdmi->phy.data; |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 1068 | unsigned int i; |
| 1069 | u16 val; |
| 1070 | |
| 1071 | if (phy->gen == 1) { |
| 1072 | dw_hdmi_phy_enable_tmds(hdmi, 0); |
| 1073 | dw_hdmi_phy_enable_powerdown(hdmi, true); |
| 1074 | return; |
| 1075 | } |
| 1076 | |
| 1077 | dw_hdmi_phy_gen2_txpwron(hdmi, 0); |
| 1078 | |
| 1079 | /* |
| 1080 | * Wait for TX_PHY_LOCK to be deasserted to indicate that the PHY went |
| 1081 | * to low power mode. |
| 1082 | */ |
| 1083 | for (i = 0; i < 5; ++i) { |
| 1084 | val = hdmi_readb(hdmi, HDMI_PHY_STAT0); |
| 1085 | if (!(val & HDMI_PHY_TX_PHY_LOCK)) |
| 1086 | break; |
| 1087 | |
| 1088 | usleep_range(1000, 2000); |
| 1089 | } |
| 1090 | |
| 1091 | if (val & HDMI_PHY_TX_PHY_LOCK) |
| 1092 | dev_warn(hdmi->dev, "PHY failed to power down\n"); |
| 1093 | else |
| 1094 | dev_dbg(hdmi->dev, "PHY powered down in %u iterations\n", i); |
| 1095 | |
| 1096 | dw_hdmi_phy_gen2_pddq(hdmi, 1); |
| 1097 | } |
| 1098 | |
Laurent Pinchart | 181e0ef | 2017-03-06 01:35:57 +0200 | [diff] [blame] | 1099 | static int dw_hdmi_phy_power_on(struct dw_hdmi *hdmi) |
| 1100 | { |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1101 | const struct dw_hdmi_phy_data *phy = hdmi->phy.data; |
Laurent Pinchart | 181e0ef | 2017-03-06 01:35:57 +0200 | [diff] [blame] | 1102 | unsigned int i; |
| 1103 | u8 val; |
| 1104 | |
| 1105 | if (phy->gen == 1) { |
| 1106 | dw_hdmi_phy_enable_powerdown(hdmi, false); |
| 1107 | |
| 1108 | /* Toggle TMDS enable. */ |
| 1109 | dw_hdmi_phy_enable_tmds(hdmi, 0); |
| 1110 | dw_hdmi_phy_enable_tmds(hdmi, 1); |
| 1111 | return 0; |
| 1112 | } |
| 1113 | |
| 1114 | dw_hdmi_phy_gen2_txpwron(hdmi, 1); |
| 1115 | dw_hdmi_phy_gen2_pddq(hdmi, 0); |
| 1116 | |
| 1117 | /* Wait for PHY PLL lock */ |
| 1118 | for (i = 0; i < 5; ++i) { |
| 1119 | val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK; |
| 1120 | if (val) |
| 1121 | break; |
| 1122 | |
| 1123 | usleep_range(1000, 2000); |
| 1124 | } |
| 1125 | |
| 1126 | if (!val) { |
| 1127 | dev_err(hdmi->dev, "PHY PLL failed to lock\n"); |
| 1128 | return -ETIMEDOUT; |
| 1129 | } |
| 1130 | |
| 1131 | dev_dbg(hdmi->dev, "PHY PLL locked %u iterations\n", i); |
| 1132 | return 0; |
| 1133 | } |
| 1134 | |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 1135 | /* |
| 1136 | * PHY configuration function for the DWC HDMI 3D TX PHY. Based on the available |
| 1137 | * information the DWC MHL PHY has the same register layout and is thus also |
| 1138 | * supported by this function. |
| 1139 | */ |
| 1140 | static int hdmi_phy_configure_dwc_hdmi_3d_tx(struct dw_hdmi *hdmi, |
| 1141 | const struct dw_hdmi_plat_data *pdata, |
| 1142 | unsigned long mpixelclock) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1143 | { |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 1144 | const struct dw_hdmi_mpll_config *mpll_config = pdata->mpll_cfg; |
| 1145 | const struct dw_hdmi_curr_ctrl *curr_ctrl = pdata->cur_ctr; |
| 1146 | const struct dw_hdmi_phy_config *phy_config = pdata->phy_config; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1147 | |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 1148 | /* PLL/MPLL Cfg - always match on final entry */ |
| 1149 | for (; mpll_config->mpixelclock != ~0UL; mpll_config++) |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 1150 | if (mpixelclock <= mpll_config->mpixelclock) |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 1151 | break; |
| 1152 | |
| 1153 | for (; curr_ctrl->mpixelclock != ~0UL; curr_ctrl++) |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 1154 | if (mpixelclock <= curr_ctrl->mpixelclock) |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 1155 | break; |
| 1156 | |
| 1157 | for (; phy_config->mpixelclock != ~0UL; phy_config++) |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 1158 | if (mpixelclock <= phy_config->mpixelclock) |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 1159 | break; |
| 1160 | |
| 1161 | if (mpll_config->mpixelclock == ~0UL || |
| 1162 | curr_ctrl->mpixelclock == ~0UL || |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 1163 | phy_config->mpixelclock == ~0UL) |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 1164 | return -EINVAL; |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 1165 | |
| 1166 | dw_hdmi_phy_i2c_write(hdmi, mpll_config->res[0].cpce, |
| 1167 | HDMI_3D_TX_PHY_CPCE_CTRL); |
| 1168 | dw_hdmi_phy_i2c_write(hdmi, mpll_config->res[0].gmp, |
| 1169 | HDMI_3D_TX_PHY_GMPCTRL); |
| 1170 | dw_hdmi_phy_i2c_write(hdmi, curr_ctrl->curr[0], |
| 1171 | HDMI_3D_TX_PHY_CURRCTRL); |
| 1172 | |
| 1173 | dw_hdmi_phy_i2c_write(hdmi, 0, HDMI_3D_TX_PHY_PLLPHBYCTRL); |
| 1174 | dw_hdmi_phy_i2c_write(hdmi, HDMI_3D_TX_PHY_MSM_CTRL_CKO_SEL_FB_CLK, |
| 1175 | HDMI_3D_TX_PHY_MSM_CTRL); |
| 1176 | |
| 1177 | dw_hdmi_phy_i2c_write(hdmi, phy_config->term, HDMI_3D_TX_PHY_TXTERM); |
| 1178 | dw_hdmi_phy_i2c_write(hdmi, phy_config->sym_ctr, |
| 1179 | HDMI_3D_TX_PHY_CKSYMTXCTRL); |
| 1180 | dw_hdmi_phy_i2c_write(hdmi, phy_config->vlev_ctr, |
| 1181 | HDMI_3D_TX_PHY_VLEVCTRL); |
| 1182 | |
| 1183 | /* Override and disable clock termination. */ |
| 1184 | dw_hdmi_phy_i2c_write(hdmi, HDMI_3D_TX_PHY_CKCALCTRL_OVERRIDE, |
| 1185 | HDMI_3D_TX_PHY_CKCALCTRL); |
| 1186 | |
| 1187 | return 0; |
| 1188 | } |
| 1189 | |
| 1190 | static int hdmi_phy_configure(struct dw_hdmi *hdmi) |
| 1191 | { |
| 1192 | const struct dw_hdmi_phy_data *phy = hdmi->phy.data; |
| 1193 | const struct dw_hdmi_plat_data *pdata = hdmi->plat_data; |
| 1194 | unsigned long mpixelclock = hdmi->hdmi_data.video_mode.mpixelclock; |
| 1195 | int ret; |
Russell King | 39cc153 | 2015-03-31 18:34:11 +0100 | [diff] [blame] | 1196 | |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 1197 | dw_hdmi_phy_power_off(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1198 | |
Laurent Pinchart | 2668db3 | 2017-01-17 10:29:09 +0200 | [diff] [blame] | 1199 | /* Leave low power consumption mode by asserting SVSRET. */ |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1200 | if (phy->has_svsret) |
Laurent Pinchart | 2668db3 | 2017-01-17 10:29:09 +0200 | [diff] [blame] | 1201 | dw_hdmi_phy_enable_svsret(hdmi, 1); |
| 1202 | |
Laurent Pinchart | 54d7273 | 2017-01-17 10:29:08 +0200 | [diff] [blame] | 1203 | /* PHY reset. The reset signal is active high on Gen2 PHYs. */ |
| 1204 | hdmi_writeb(hdmi, HDMI_MC_PHYRSTZ_PHYRSTZ, HDMI_MC_PHYRSTZ); |
| 1205 | hdmi_writeb(hdmi, 0, HDMI_MC_PHYRSTZ); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1206 | |
| 1207 | hdmi_writeb(hdmi, HDMI_MC_HEACPHY_RST_ASSERT, HDMI_MC_HEACPHY_RST); |
| 1208 | |
| 1209 | hdmi_phy_test_clear(hdmi, 1); |
| 1210 | hdmi_writeb(hdmi, HDMI_PHY_I2CM_SLAVE_ADDR_PHY_GEN2, |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1211 | HDMI_PHY_I2CM_SLAVE_ADDR); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1212 | hdmi_phy_test_clear(hdmi, 0); |
| 1213 | |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 1214 | /* Write to the PHY as configured by the platform */ |
| 1215 | if (pdata->configure_phy) |
| 1216 | ret = pdata->configure_phy(hdmi, pdata, mpixelclock); |
| 1217 | else |
| 1218 | ret = phy->configure(hdmi, pdata, mpixelclock); |
| 1219 | if (ret) { |
| 1220 | dev_err(hdmi->dev, "PHY configuration failed (clock %lu)\n", |
| 1221 | mpixelclock); |
| 1222 | return ret; |
| 1223 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1224 | |
Laurent Pinchart | 181e0ef | 2017-03-06 01:35:57 +0200 | [diff] [blame] | 1225 | return dw_hdmi_phy_power_on(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1226 | } |
| 1227 | |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1228 | static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data, |
| 1229 | struct drm_display_mode *mode) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1230 | { |
| 1231 | int i, ret; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1232 | |
| 1233 | /* HDMI Phy spec says to do the phy initialization sequence twice */ |
| 1234 | for (i = 0; i < 2; i++) { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1235 | dw_hdmi_phy_sel_data_en_pol(hdmi, 1); |
| 1236 | dw_hdmi_phy_sel_interface_control(hdmi, 0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1237 | |
Laurent Pinchart | 8b9e1c0 | 2017-03-03 19:19:59 +0200 | [diff] [blame] | 1238 | ret = hdmi_phy_configure(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1239 | if (ret) |
| 1240 | return ret; |
| 1241 | } |
| 1242 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1243 | return 0; |
| 1244 | } |
| 1245 | |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1246 | static void dw_hdmi_phy_disable(struct dw_hdmi *hdmi, void *data) |
| 1247 | { |
| 1248 | dw_hdmi_phy_power_off(hdmi); |
| 1249 | } |
| 1250 | |
| 1251 | static enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi, |
| 1252 | void *data) |
| 1253 | { |
| 1254 | return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ? |
| 1255 | connector_status_connected : connector_status_disconnected; |
| 1256 | } |
| 1257 | |
Neil Armstrong | 386d329 | 2017-04-04 14:31:59 +0200 | [diff] [blame] | 1258 | static void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data, |
| 1259 | bool force, bool disabled, bool rxsense) |
| 1260 | { |
| 1261 | u8 old_mask = hdmi->phy_mask; |
| 1262 | |
| 1263 | if (force || disabled || !rxsense) |
| 1264 | hdmi->phy_mask |= HDMI_PHY_RX_SENSE; |
| 1265 | else |
| 1266 | hdmi->phy_mask &= ~HDMI_PHY_RX_SENSE; |
| 1267 | |
| 1268 | if (old_mask != hdmi->phy_mask) |
| 1269 | hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); |
| 1270 | } |
| 1271 | |
| 1272 | static void dw_hdmi_phy_setup_hpd(struct dw_hdmi *hdmi, void *data) |
| 1273 | { |
| 1274 | /* |
| 1275 | * Configure the PHY RX SENSE and HPD interrupts polarities and clear |
| 1276 | * any pending interrupt. |
| 1277 | */ |
| 1278 | hdmi_writeb(hdmi, HDMI_PHY_HPD | HDMI_PHY_RX_SENSE, HDMI_PHY_POL0); |
| 1279 | hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, |
| 1280 | HDMI_IH_PHY_STAT0); |
| 1281 | |
| 1282 | /* Enable cable hot plug irq. */ |
| 1283 | hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); |
| 1284 | |
| 1285 | /* Clear and unmute interrupts. */ |
| 1286 | hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, |
| 1287 | HDMI_IH_PHY_STAT0); |
| 1288 | hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), |
| 1289 | HDMI_IH_MUTE_PHY_STAT0); |
| 1290 | } |
| 1291 | |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1292 | static const struct dw_hdmi_phy_ops dw_hdmi_synopsys_phy_ops = { |
| 1293 | .init = dw_hdmi_phy_init, |
| 1294 | .disable = dw_hdmi_phy_disable, |
| 1295 | .read_hpd = dw_hdmi_phy_read_hpd, |
Neil Armstrong | 386d329 | 2017-04-04 14:31:59 +0200 | [diff] [blame] | 1296 | .update_hpd = dw_hdmi_phy_update_hpd, |
| 1297 | .setup_hpd = dw_hdmi_phy_setup_hpd, |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1298 | }; |
| 1299 | |
| 1300 | /* ----------------------------------------------------------------------------- |
| 1301 | * HDMI TX Setup |
| 1302 | */ |
| 1303 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1304 | static void hdmi_tx_hdcp_config(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1305 | { |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 1306 | u8 de; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1307 | |
| 1308 | if (hdmi->hdmi_data.video_mode.mdataenablepolarity) |
| 1309 | de = HDMI_A_VIDPOLCFG_DATAENPOL_ACTIVE_HIGH; |
| 1310 | else |
| 1311 | de = HDMI_A_VIDPOLCFG_DATAENPOL_ACTIVE_LOW; |
| 1312 | |
| 1313 | /* disable rx detect */ |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 1314 | hdmi_modb(hdmi, HDMI_A_HDCPCFG0_RXDETECT_DISABLE, |
| 1315 | HDMI_A_HDCPCFG0_RXDETECT_MASK, HDMI_A_HDCPCFG0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1316 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 1317 | hdmi_modb(hdmi, de, HDMI_A_VIDPOLCFG_DATAENPOL_MASK, HDMI_A_VIDPOLCFG); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1318 | |
Russell King | 812bc61 | 2013-11-04 12:42:02 +0000 | [diff] [blame] | 1319 | hdmi_modb(hdmi, HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_DISABLE, |
| 1320 | HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_MASK, HDMI_A_HDCPCFG1); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1321 | } |
| 1322 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1323 | 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] | 1324 | { |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1325 | struct hdmi_avi_infoframe frame; |
| 1326 | u8 val; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1327 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1328 | /* Initialise info frame from DRM mode */ |
Shashank Sharma | 0c1f528 | 2017-07-13 21:03:07 +0530 | [diff] [blame] | 1329 | drm_hdmi_avi_infoframe_from_display_mode(&frame, mode, false); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1330 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1331 | if (hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format)) |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1332 | frame.colorspace = HDMI_COLORSPACE_YUV444; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1333 | else if (hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1334 | frame.colorspace = HDMI_COLORSPACE_YUV422; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1335 | else |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1336 | frame.colorspace = HDMI_COLORSPACE_RGB; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1337 | |
| 1338 | /* Set up colorimetry */ |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1339 | switch (hdmi->hdmi_data.enc_out_encoding) { |
| 1340 | case V4L2_YCBCR_ENC_601: |
| 1341 | if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV601) |
| 1342 | frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; |
| 1343 | else |
| 1344 | frame.colorimetry = HDMI_COLORIMETRY_ITU_601; |
| 1345 | frame.extended_colorimetry = |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1346 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; |
Dan Carpenter | f40d656 | 2017-04-06 08:21:32 +0300 | [diff] [blame] | 1347 | break; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1348 | case V4L2_YCBCR_ENC_709: |
| 1349 | if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV709) |
| 1350 | frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; |
| 1351 | else |
| 1352 | frame.colorimetry = HDMI_COLORIMETRY_ITU_709; |
| 1353 | frame.extended_colorimetry = |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1354 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_709; |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1355 | break; |
| 1356 | default: /* Carries no data */ |
| 1357 | frame.colorimetry = HDMI_COLORIMETRY_ITU_601; |
| 1358 | frame.extended_colorimetry = |
| 1359 | HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; |
| 1360 | break; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1361 | } |
| 1362 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1363 | frame.scan_mode = HDMI_SCAN_MODE_NONE; |
| 1364 | |
| 1365 | /* |
| 1366 | * The Designware IP uses a different byte format from standard |
| 1367 | * AVI info frames, though generally the bits are in the correct |
| 1368 | * bytes. |
| 1369 | */ |
| 1370 | |
| 1371 | /* |
Jose Abreu | b0118e7 | 2016-08-29 10:30:51 +0100 | [diff] [blame] | 1372 | * AVI data byte 1 differences: Colorspace in bits 0,1 rather than 5,6, |
| 1373 | * scan info in bits 4,5 rather than 0,1 and active aspect present in |
| 1374 | * bit 6 rather than 4. |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1375 | */ |
Jose Abreu | b0118e7 | 2016-08-29 10:30:51 +0100 | [diff] [blame] | 1376 | val = (frame.scan_mode & 3) << 4 | (frame.colorspace & 3); |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1377 | if (frame.active_aspect & 15) |
| 1378 | val |= HDMI_FC_AVICONF0_ACTIVE_FMT_INFO_PRESENT; |
| 1379 | if (frame.top_bar || frame.bottom_bar) |
| 1380 | val |= HDMI_FC_AVICONF0_BAR_DATA_HORIZ_BAR; |
| 1381 | if (frame.left_bar || frame.right_bar) |
| 1382 | val |= HDMI_FC_AVICONF0_BAR_DATA_VERT_BAR; |
| 1383 | hdmi_writeb(hdmi, val, HDMI_FC_AVICONF0); |
| 1384 | |
| 1385 | /* AVI data byte 2 differences: none */ |
| 1386 | val = ((frame.colorimetry & 0x3) << 6) | |
| 1387 | ((frame.picture_aspect & 0x3) << 4) | |
| 1388 | (frame.active_aspect & 0xf); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1389 | hdmi_writeb(hdmi, val, HDMI_FC_AVICONF1); |
| 1390 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1391 | /* AVI data byte 3 differences: none */ |
| 1392 | val = ((frame.extended_colorimetry & 0x7) << 4) | |
| 1393 | ((frame.quantization_range & 0x3) << 2) | |
| 1394 | (frame.nups & 0x3); |
| 1395 | if (frame.itc) |
| 1396 | val |= HDMI_FC_AVICONF2_IT_CONTENT_VALID; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1397 | hdmi_writeb(hdmi, val, HDMI_FC_AVICONF2); |
| 1398 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1399 | /* AVI data byte 4 differences: none */ |
| 1400 | val = frame.video_code & 0x7f; |
| 1401 | hdmi_writeb(hdmi, val, HDMI_FC_AVIVID); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1402 | |
| 1403 | /* AVI Data Byte 5- set up input and output pixel repetition */ |
| 1404 | val = (((hdmi->hdmi_data.video_mode.mpixelrepetitioninput + 1) << |
| 1405 | HDMI_FC_PRCONF_INCOMING_PR_FACTOR_OFFSET) & |
| 1406 | HDMI_FC_PRCONF_INCOMING_PR_FACTOR_MASK) | |
| 1407 | ((hdmi->hdmi_data.video_mode.mpixelrepetitionoutput << |
| 1408 | HDMI_FC_PRCONF_OUTPUT_PR_FACTOR_OFFSET) & |
| 1409 | HDMI_FC_PRCONF_OUTPUT_PR_FACTOR_MASK); |
| 1410 | hdmi_writeb(hdmi, val, HDMI_FC_PRCONF); |
| 1411 | |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1412 | /* |
| 1413 | * AVI data byte 5 differences: content type in 0,1 rather than 4,5, |
| 1414 | * ycc range in bits 2,3 rather than 6,7 |
| 1415 | */ |
| 1416 | val = ((frame.ycc_quantization_range & 0x3) << 2) | |
| 1417 | (frame.content_type & 0x3); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1418 | hdmi_writeb(hdmi, val, HDMI_FC_AVICONF3); |
| 1419 | |
| 1420 | /* AVI Data Bytes 6-13 */ |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1421 | hdmi_writeb(hdmi, frame.top_bar & 0xff, HDMI_FC_AVIETB0); |
| 1422 | hdmi_writeb(hdmi, (frame.top_bar >> 8) & 0xff, HDMI_FC_AVIETB1); |
| 1423 | hdmi_writeb(hdmi, frame.bottom_bar & 0xff, HDMI_FC_AVISBB0); |
| 1424 | hdmi_writeb(hdmi, (frame.bottom_bar >> 8) & 0xff, HDMI_FC_AVISBB1); |
| 1425 | hdmi_writeb(hdmi, frame.left_bar & 0xff, HDMI_FC_AVIELB0); |
| 1426 | hdmi_writeb(hdmi, (frame.left_bar >> 8) & 0xff, HDMI_FC_AVIELB1); |
| 1427 | hdmi_writeb(hdmi, frame.right_bar & 0xff, HDMI_FC_AVISRB0); |
| 1428 | hdmi_writeb(hdmi, (frame.right_bar >> 8) & 0xff, HDMI_FC_AVISRB1); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1429 | } |
| 1430 | |
Nickey Yang | 9aa1eca | 2017-03-21 15:36:17 +0800 | [diff] [blame] | 1431 | static void hdmi_config_vendor_specific_infoframe(struct dw_hdmi *hdmi, |
| 1432 | struct drm_display_mode *mode) |
| 1433 | { |
| 1434 | struct hdmi_vendor_infoframe frame; |
| 1435 | u8 buffer[10]; |
| 1436 | ssize_t err; |
| 1437 | |
| 1438 | err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode); |
| 1439 | if (err < 0) |
| 1440 | /* |
| 1441 | * Going into that statement does not means vendor infoframe |
| 1442 | * fails. It just informed us that vendor infoframe is not |
| 1443 | * needed for the selected mode. Only 4k or stereoscopic 3D |
| 1444 | * mode requires vendor infoframe. So just simply return. |
| 1445 | */ |
| 1446 | return; |
| 1447 | |
| 1448 | err = hdmi_vendor_infoframe_pack(&frame, buffer, sizeof(buffer)); |
| 1449 | if (err < 0) { |
| 1450 | dev_err(hdmi->dev, "Failed to pack vendor infoframe: %zd\n", |
| 1451 | err); |
| 1452 | return; |
| 1453 | } |
| 1454 | hdmi_mask_writeb(hdmi, 0, HDMI_FC_DATAUTO0, HDMI_FC_DATAUTO0_VSD_OFFSET, |
| 1455 | HDMI_FC_DATAUTO0_VSD_MASK); |
| 1456 | |
| 1457 | /* Set the length of HDMI vendor specific InfoFrame payload */ |
| 1458 | hdmi_writeb(hdmi, buffer[2], HDMI_FC_VSDSIZE); |
| 1459 | |
| 1460 | /* Set 24bit IEEE Registration Identifier */ |
| 1461 | hdmi_writeb(hdmi, buffer[4], HDMI_FC_VSDIEEEID0); |
| 1462 | hdmi_writeb(hdmi, buffer[5], HDMI_FC_VSDIEEEID1); |
| 1463 | hdmi_writeb(hdmi, buffer[6], HDMI_FC_VSDIEEEID2); |
| 1464 | |
| 1465 | /* Set HDMI_Video_Format and HDMI_VIC/3D_Structure */ |
| 1466 | hdmi_writeb(hdmi, buffer[7], HDMI_FC_VSDPAYLOAD0); |
| 1467 | hdmi_writeb(hdmi, buffer[8], HDMI_FC_VSDPAYLOAD1); |
| 1468 | |
| 1469 | if (frame.s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) |
| 1470 | hdmi_writeb(hdmi, buffer[9], HDMI_FC_VSDPAYLOAD2); |
| 1471 | |
| 1472 | /* Packet frame interpolation */ |
| 1473 | hdmi_writeb(hdmi, 1, HDMI_FC_DATAUTO1); |
| 1474 | |
| 1475 | /* Auto packets per frame and line spacing */ |
| 1476 | hdmi_writeb(hdmi, 0x11, HDMI_FC_DATAUTO2); |
| 1477 | |
| 1478 | /* Configures the Frame Composer On RDRB mode */ |
| 1479 | hdmi_mask_writeb(hdmi, 1, HDMI_FC_DATAUTO0, HDMI_FC_DATAUTO0_VSD_OFFSET, |
| 1480 | HDMI_FC_DATAUTO0_VSD_MASK); |
| 1481 | } |
| 1482 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1483 | static void hdmi_av_composer(struct dw_hdmi *hdmi, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1484 | const struct drm_display_mode *mode) |
| 1485 | { |
| 1486 | u8 inv_val; |
| 1487 | struct hdmi_vmode *vmode = &hdmi->hdmi_data.video_mode; |
| 1488 | 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] | 1489 | unsigned int vdisplay; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1490 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1491 | vmode->mpixelclock = mode->clock * 1000; |
| 1492 | |
| 1493 | dev_dbg(hdmi->dev, "final pixclk = %d\n", vmode->mpixelclock); |
| 1494 | |
| 1495 | /* Set up HDMI_FC_INVIDCONF */ |
| 1496 | inv_val = (hdmi->hdmi_data.hdcp_enable ? |
| 1497 | HDMI_FC_INVIDCONF_HDCP_KEEPOUT_ACTIVE : |
| 1498 | HDMI_FC_INVIDCONF_HDCP_KEEPOUT_INACTIVE); |
| 1499 | |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1500 | inv_val |= mode->flags & DRM_MODE_FLAG_PVSYNC ? |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1501 | HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_HIGH : |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1502 | HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_LOW; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1503 | |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1504 | inv_val |= mode->flags & DRM_MODE_FLAG_PHSYNC ? |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1505 | HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_HIGH : |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1506 | HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_LOW; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1507 | |
| 1508 | inv_val |= (vmode->mdataenablepolarity ? |
| 1509 | HDMI_FC_INVIDCONF_DE_IN_POLARITY_ACTIVE_HIGH : |
| 1510 | HDMI_FC_INVIDCONF_DE_IN_POLARITY_ACTIVE_LOW); |
| 1511 | |
| 1512 | if (hdmi->vic == 39) |
| 1513 | inv_val |= HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_HIGH; |
| 1514 | else |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1515 | inv_val |= mode->flags & DRM_MODE_FLAG_INTERLACE ? |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1516 | HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_HIGH : |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1517 | HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_LOW; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1518 | |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1519 | inv_val |= mode->flags & DRM_MODE_FLAG_INTERLACE ? |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1520 | HDMI_FC_INVIDCONF_IN_I_P_INTERLACED : |
Russell King | b91eee8 | 2015-03-27 23:27:17 +0000 | [diff] [blame] | 1521 | HDMI_FC_INVIDCONF_IN_I_P_PROGRESSIVE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1522 | |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 1523 | inv_val |= hdmi->sink_is_hdmi ? |
| 1524 | HDMI_FC_INVIDCONF_DVI_MODEZ_HDMI_MODE : |
| 1525 | HDMI_FC_INVIDCONF_DVI_MODEZ_DVI_MODE; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1526 | |
| 1527 | hdmi_writeb(hdmi, inv_val, HDMI_FC_INVIDCONF); |
| 1528 | |
Russell King | e80b9f4 | 2015-07-21 11:08:25 +0100 | [diff] [blame] | 1529 | vdisplay = mode->vdisplay; |
| 1530 | vblank = mode->vtotal - mode->vdisplay; |
| 1531 | v_de_vs = mode->vsync_start - mode->vdisplay; |
| 1532 | vsync_len = mode->vsync_end - mode->vsync_start; |
| 1533 | |
| 1534 | /* |
| 1535 | * When we're setting an interlaced mode, we need |
| 1536 | * to adjust the vertical timing to suit. |
| 1537 | */ |
| 1538 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
| 1539 | vdisplay /= 2; |
| 1540 | vblank /= 2; |
| 1541 | v_de_vs /= 2; |
| 1542 | vsync_len /= 2; |
| 1543 | } |
| 1544 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1545 | /* Set up horizontal active pixel width */ |
| 1546 | hdmi_writeb(hdmi, mode->hdisplay >> 8, HDMI_FC_INHACTV1); |
| 1547 | hdmi_writeb(hdmi, mode->hdisplay, HDMI_FC_INHACTV0); |
| 1548 | |
| 1549 | /* Set up vertical active lines */ |
Russell King | e80b9f4 | 2015-07-21 11:08:25 +0100 | [diff] [blame] | 1550 | hdmi_writeb(hdmi, vdisplay >> 8, HDMI_FC_INVACTV1); |
| 1551 | hdmi_writeb(hdmi, vdisplay, HDMI_FC_INVACTV0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1552 | |
| 1553 | /* Set up horizontal blanking pixel region width */ |
| 1554 | hblank = mode->htotal - mode->hdisplay; |
| 1555 | hdmi_writeb(hdmi, hblank >> 8, HDMI_FC_INHBLANK1); |
| 1556 | hdmi_writeb(hdmi, hblank, HDMI_FC_INHBLANK0); |
| 1557 | |
| 1558 | /* Set up vertical blanking pixel region width */ |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1559 | hdmi_writeb(hdmi, vblank, HDMI_FC_INVBLANK); |
| 1560 | |
| 1561 | /* Set up HSYNC active edge delay width (in pixel clks) */ |
| 1562 | h_de_hs = mode->hsync_start - mode->hdisplay; |
| 1563 | hdmi_writeb(hdmi, h_de_hs >> 8, HDMI_FC_HSYNCINDELAY1); |
| 1564 | hdmi_writeb(hdmi, h_de_hs, HDMI_FC_HSYNCINDELAY0); |
| 1565 | |
| 1566 | /* Set up VSYNC active edge delay (in lines) */ |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1567 | hdmi_writeb(hdmi, v_de_vs, HDMI_FC_VSYNCINDELAY); |
| 1568 | |
| 1569 | /* Set up HSYNC active pulse width (in pixel clks) */ |
| 1570 | hsync_len = mode->hsync_end - mode->hsync_start; |
| 1571 | hdmi_writeb(hdmi, hsync_len >> 8, HDMI_FC_HSYNCINWIDTH1); |
| 1572 | hdmi_writeb(hdmi, hsync_len, HDMI_FC_HSYNCINWIDTH0); |
| 1573 | |
| 1574 | /* Set up VSYNC active edge delay (in lines) */ |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1575 | hdmi_writeb(hdmi, vsync_len, HDMI_FC_VSYNCINWIDTH); |
| 1576 | } |
| 1577 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1578 | /* HDMI Initialization Step B.4 */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1579 | static void dw_hdmi_enable_video_path(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1580 | { |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1581 | /* control period minimum duration */ |
| 1582 | hdmi_writeb(hdmi, 12, HDMI_FC_CTRLDUR); |
| 1583 | hdmi_writeb(hdmi, 32, HDMI_FC_EXCTRLDUR); |
| 1584 | hdmi_writeb(hdmi, 1, HDMI_FC_EXCTRLSPAC); |
| 1585 | |
| 1586 | /* Set to fill TMDS data channels */ |
| 1587 | hdmi_writeb(hdmi, 0x0B, HDMI_FC_CH0PREAM); |
| 1588 | hdmi_writeb(hdmi, 0x16, HDMI_FC_CH1PREAM); |
| 1589 | hdmi_writeb(hdmi, 0x21, HDMI_FC_CH2PREAM); |
| 1590 | |
| 1591 | /* Enable pixel clock and tmds data path */ |
Russell King | 7cc4ab2 | 2017-07-31 15:29:46 +0100 | [diff] [blame] | 1592 | hdmi->mc_clkdis |= HDMI_MC_CLKDIS_HDCPCLK_DISABLE | |
| 1593 | HDMI_MC_CLKDIS_CSCCLK_DISABLE | |
| 1594 | HDMI_MC_CLKDIS_AUDCLK_DISABLE | |
| 1595 | HDMI_MC_CLKDIS_PREPCLK_DISABLE | |
| 1596 | HDMI_MC_CLKDIS_TMDSCLK_DISABLE; |
| 1597 | hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_PIXELCLK_DISABLE; |
| 1598 | hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1599 | |
Russell King | 7cc4ab2 | 2017-07-31 15:29:46 +0100 | [diff] [blame] | 1600 | hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_TMDSCLK_DISABLE; |
| 1601 | hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1602 | |
| 1603 | /* Enable csc path */ |
| 1604 | if (is_color_space_conversion(hdmi)) { |
Russell King | 7cc4ab2 | 2017-07-31 15:29:46 +0100 | [diff] [blame] | 1605 | hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_CSCCLK_DISABLE; |
| 1606 | hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1607 | } |
Laurent Pinchart | 8b9e1c0 | 2017-03-03 19:19:59 +0200 | [diff] [blame] | 1608 | |
Neil Armstrong | 14247d7 | 2017-03-03 19:20:00 +0200 | [diff] [blame] | 1609 | /* Enable color space conversion if needed */ |
| 1610 | if (is_color_space_conversion(hdmi)) |
Laurent Pinchart | 8b9e1c0 | 2017-03-03 19:19:59 +0200 | [diff] [blame] | 1611 | hdmi_writeb(hdmi, HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_IN_PATH, |
| 1612 | HDMI_MC_FLOWCTRL); |
| 1613 | else |
| 1614 | hdmi_writeb(hdmi, HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_BYPASS, |
| 1615 | HDMI_MC_FLOWCTRL); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1616 | } |
| 1617 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1618 | /* Workaround to clear the overflow condition */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1619 | static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1620 | { |
Laurent Pinchart | be41fc5 | 2017-01-17 10:29:05 +0200 | [diff] [blame] | 1621 | unsigned int count; |
| 1622 | unsigned int i; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1623 | u8 val; |
| 1624 | |
Laurent Pinchart | be41fc5 | 2017-01-17 10:29:05 +0200 | [diff] [blame] | 1625 | /* |
| 1626 | * Under some circumstances the Frame Composer arithmetic unit can miss |
| 1627 | * an FC register write due to being busy processing the previous one. |
| 1628 | * The issue can be worked around by issuing a TMDS software reset and |
| 1629 | * then write one of the FC registers several times. |
| 1630 | * |
| 1631 | * The number of iterations matters and depends on the HDMI TX revision |
| 1632 | * (and possibly on the platform). So far only i.MX6Q (v1.30a) and |
| 1633 | * i.MX6DL (v1.31a) have been identified as needing the workaround, with |
| 1634 | * 4 and 1 iterations respectively. |
| 1635 | */ |
| 1636 | |
| 1637 | switch (hdmi->version) { |
| 1638 | case 0x130a: |
| 1639 | count = 4; |
| 1640 | break; |
| 1641 | case 0x131a: |
| 1642 | count = 1; |
| 1643 | break; |
| 1644 | default: |
| 1645 | return; |
| 1646 | } |
| 1647 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1648 | /* TMDS software reset */ |
| 1649 | hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, HDMI_MC_SWRSTZ); |
| 1650 | |
| 1651 | val = hdmi_readb(hdmi, HDMI_FC_INVIDCONF); |
Laurent Pinchart | be41fc5 | 2017-01-17 10:29:05 +0200 | [diff] [blame] | 1652 | for (i = 0; i < count; i++) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1653 | hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF); |
| 1654 | } |
| 1655 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1656 | static void hdmi_enable_overflow_interrupts(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1657 | { |
| 1658 | hdmi_writeb(hdmi, 0, HDMI_FC_MASK2); |
| 1659 | hdmi_writeb(hdmi, 0, HDMI_IH_MUTE_FC_STAT2); |
| 1660 | } |
| 1661 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1662 | static void hdmi_disable_overflow_interrupts(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1663 | { |
| 1664 | hdmi_writeb(hdmi, HDMI_IH_MUTE_FC_STAT2_OVERFLOW_MASK, |
| 1665 | HDMI_IH_MUTE_FC_STAT2); |
| 1666 | } |
| 1667 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1668 | 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] | 1669 | { |
| 1670 | int ret; |
| 1671 | |
| 1672 | hdmi_disable_overflow_interrupts(hdmi); |
| 1673 | |
| 1674 | hdmi->vic = drm_match_cea_mode(mode); |
| 1675 | |
| 1676 | if (!hdmi->vic) { |
| 1677 | dev_dbg(hdmi->dev, "Non-CEA mode used in HDMI\n"); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1678 | } else { |
| 1679 | dev_dbg(hdmi->dev, "CEA mode used vic=%d\n", hdmi->vic); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1680 | } |
| 1681 | |
| 1682 | if ((hdmi->vic == 6) || (hdmi->vic == 7) || |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 1683 | (hdmi->vic == 21) || (hdmi->vic == 22) || |
| 1684 | (hdmi->vic == 2) || (hdmi->vic == 3) || |
| 1685 | (hdmi->vic == 17) || (hdmi->vic == 18)) |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1686 | hdmi->hdmi_data.enc_out_encoding = V4L2_YCBCR_ENC_601; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1687 | else |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1688 | hdmi->hdmi_data.enc_out_encoding = V4L2_YCBCR_ENC_709; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1689 | |
Russell King | d10ca82 | 2015-07-21 11:25:00 +0100 | [diff] [blame] | 1690 | hdmi->hdmi_data.video_mode.mpixelrepetitionoutput = 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1691 | hdmi->hdmi_data.video_mode.mpixelrepetitioninput = 0; |
| 1692 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1693 | /* TOFIX: Get input format from plat data or fallback to RGB888 */ |
Neil Armstrong | e20c29a | 2017-04-06 11:34:04 +0200 | [diff] [blame] | 1694 | if (hdmi->plat_data->input_bus_format) |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1695 | hdmi->hdmi_data.enc_in_bus_format = |
| 1696 | hdmi->plat_data->input_bus_format; |
| 1697 | else |
| 1698 | hdmi->hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_RGB888_1X24; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1699 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1700 | /* TOFIX: Get input encoding from plat data or fallback to none */ |
Neil Armstrong | e20c29a | 2017-04-06 11:34:04 +0200 | [diff] [blame] | 1701 | if (hdmi->plat_data->input_bus_encoding) |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1702 | hdmi->hdmi_data.enc_in_encoding = |
| 1703 | hdmi->plat_data->input_bus_encoding; |
| 1704 | else |
| 1705 | hdmi->hdmi_data.enc_in_encoding = V4L2_YCBCR_ENC_DEFAULT; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1706 | |
Neil Armstrong | def23aa | 2017-04-04 14:31:57 +0200 | [diff] [blame] | 1707 | /* TOFIX: Default to RGB888 output format */ |
| 1708 | hdmi->hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24; |
| 1709 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1710 | hdmi->hdmi_data.pix_repet_factor = 0; |
| 1711 | hdmi->hdmi_data.hdcp_enable = 0; |
| 1712 | hdmi->hdmi_data.video_mode.mdataenablepolarity = true; |
| 1713 | |
| 1714 | /* HDMI Initialization Step B.1 */ |
| 1715 | hdmi_av_composer(hdmi, mode); |
| 1716 | |
| 1717 | /* HDMI Initializateion Step B.2 */ |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1718 | ret = hdmi->phy.ops->init(hdmi, hdmi->phy.data, &hdmi->previous_mode); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1719 | if (ret) |
| 1720 | return ret; |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1721 | hdmi->phy.enabled = true; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1722 | |
| 1723 | /* HDMI Initialization Step B.3 */ |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1724 | dw_hdmi_enable_video_path(hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1725 | |
Russell King | f709ec0 | 2015-07-21 16:09:39 +0100 | [diff] [blame] | 1726 | if (hdmi->sink_has_audio) { |
| 1727 | dev_dbg(hdmi->dev, "sink has audio support\n"); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1728 | |
| 1729 | /* HDMI Initialization Step E - Configure audio */ |
| 1730 | hdmi_clk_regenerator_update_pixel_clock(hdmi); |
Romain Perier | 57fbc05 | 2017-04-20 14:34:34 +0530 | [diff] [blame] | 1731 | hdmi_enable_audio_clk(hdmi, true); |
Russell King | f709ec0 | 2015-07-21 16:09:39 +0100 | [diff] [blame] | 1732 | } |
| 1733 | |
| 1734 | /* not for DVI mode */ |
| 1735 | if (hdmi->sink_is_hdmi) { |
| 1736 | dev_dbg(hdmi->dev, "%s HDMI mode\n", __func__); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1737 | |
| 1738 | /* HDMI Initialization Step F - Configure AVI InfoFrame */ |
Russell King | d4ac4cb | 2015-03-27 20:06:50 +0000 | [diff] [blame] | 1739 | hdmi_config_AVI(hdmi, mode); |
Nickey Yang | 9aa1eca | 2017-03-21 15:36:17 +0800 | [diff] [blame] | 1740 | hdmi_config_vendor_specific_infoframe(hdmi, mode); |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 1741 | } else { |
| 1742 | dev_dbg(hdmi->dev, "%s DVI mode\n", __func__); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1743 | } |
| 1744 | |
| 1745 | hdmi_video_packetize(hdmi); |
| 1746 | hdmi_video_csc(hdmi); |
| 1747 | hdmi_video_sample(hdmi); |
| 1748 | hdmi_tx_hdcp_config(hdmi); |
| 1749 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1750 | dw_hdmi_clear_overflow(hdmi); |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 1751 | if (hdmi->cable_plugin && hdmi->sink_is_hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1752 | hdmi_enable_overflow_interrupts(hdmi); |
| 1753 | |
| 1754 | return 0; |
| 1755 | } |
| 1756 | |
Laurent Pinchart | a23d626 | 2017-04-04 14:31:56 +0200 | [diff] [blame] | 1757 | static void dw_hdmi_setup_i2c(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1758 | { |
| 1759 | hdmi_writeb(hdmi, HDMI_PHY_I2CM_INT_ADDR_DONE_POL, |
| 1760 | HDMI_PHY_I2CM_INT_ADDR); |
| 1761 | |
| 1762 | hdmi_writeb(hdmi, HDMI_PHY_I2CM_CTLINT_ADDR_NAC_POL | |
| 1763 | HDMI_PHY_I2CM_CTLINT_ADDR_ARBITRATION_POL, |
| 1764 | HDMI_PHY_I2CM_CTLINT_ADDR); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1765 | } |
| 1766 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1767 | static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1768 | { |
| 1769 | u8 ih_mute; |
| 1770 | |
| 1771 | /* |
| 1772 | * Boot up defaults are: |
| 1773 | * HDMI_IH_MUTE = 0x03 (disabled) |
| 1774 | * HDMI_IH_MUTE_* = 0x00 (enabled) |
| 1775 | * |
| 1776 | * Disable top level interrupt bits in HDMI block |
| 1777 | */ |
| 1778 | ih_mute = hdmi_readb(hdmi, HDMI_IH_MUTE) | |
| 1779 | HDMI_IH_MUTE_MUTE_WAKEUP_INTERRUPT | |
| 1780 | HDMI_IH_MUTE_MUTE_ALL_INTERRUPT; |
| 1781 | |
| 1782 | hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE); |
| 1783 | |
| 1784 | /* by default mask all interrupts */ |
| 1785 | hdmi_writeb(hdmi, 0xff, HDMI_VP_MASK); |
| 1786 | hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK0); |
| 1787 | hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK1); |
| 1788 | hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK2); |
| 1789 | hdmi_writeb(hdmi, 0xff, HDMI_PHY_MASK0); |
| 1790 | hdmi_writeb(hdmi, 0xff, HDMI_PHY_I2CM_INT_ADDR); |
| 1791 | hdmi_writeb(hdmi, 0xff, HDMI_PHY_I2CM_CTLINT_ADDR); |
| 1792 | hdmi_writeb(hdmi, 0xff, HDMI_AUD_INT); |
| 1793 | hdmi_writeb(hdmi, 0xff, HDMI_AUD_SPDIFINT); |
| 1794 | hdmi_writeb(hdmi, 0xff, HDMI_AUD_HBR_MASK); |
| 1795 | hdmi_writeb(hdmi, 0xff, HDMI_GP_MASK); |
| 1796 | hdmi_writeb(hdmi, 0xff, HDMI_A_APIINTMSK); |
| 1797 | hdmi_writeb(hdmi, 0xff, HDMI_CEC_MASK); |
| 1798 | hdmi_writeb(hdmi, 0xff, HDMI_I2CM_INT); |
| 1799 | hdmi_writeb(hdmi, 0xff, HDMI_I2CM_CTLINT); |
| 1800 | |
| 1801 | /* Disable interrupts in the IH_MUTE_* registers */ |
| 1802 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT0); |
| 1803 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT1); |
| 1804 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT2); |
| 1805 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_AS_STAT0); |
| 1806 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_PHY_STAT0); |
| 1807 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_I2CM_STAT0); |
| 1808 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_CEC_STAT0); |
| 1809 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_VP_STAT0); |
| 1810 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_I2CMPHY_STAT0); |
| 1811 | hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_AHBDMAAUD_STAT0); |
| 1812 | |
| 1813 | /* Enable top level interrupt bits in HDMI block */ |
| 1814 | ih_mute &= ~(HDMI_IH_MUTE_MUTE_WAKEUP_INTERRUPT | |
| 1815 | HDMI_IH_MUTE_MUTE_ALL_INTERRUPT); |
| 1816 | hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE); |
| 1817 | } |
| 1818 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1819 | static void dw_hdmi_poweron(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1820 | { |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1821 | hdmi->bridge_is_on = true; |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1822 | dw_hdmi_setup(hdmi, &hdmi->previous_mode); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1823 | } |
| 1824 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1825 | static void dw_hdmi_poweroff(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1826 | { |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1827 | if (hdmi->phy.enabled) { |
| 1828 | hdmi->phy.ops->disable(hdmi, hdmi->phy.data); |
| 1829 | hdmi->phy.enabled = false; |
| 1830 | } |
| 1831 | |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1832 | hdmi->bridge_is_on = false; |
| 1833 | } |
| 1834 | |
| 1835 | static void dw_hdmi_update_power(struct dw_hdmi *hdmi) |
| 1836 | { |
| 1837 | int force = hdmi->force; |
| 1838 | |
| 1839 | if (hdmi->disabled) { |
| 1840 | force = DRM_FORCE_OFF; |
| 1841 | } else if (force == DRM_FORCE_UNSPECIFIED) { |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1842 | if (hdmi->rxsense) |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1843 | force = DRM_FORCE_ON; |
| 1844 | else |
| 1845 | force = DRM_FORCE_OFF; |
| 1846 | } |
| 1847 | |
| 1848 | if (force == DRM_FORCE_OFF) { |
| 1849 | if (hdmi->bridge_is_on) |
| 1850 | dw_hdmi_poweroff(hdmi); |
| 1851 | } else { |
| 1852 | if (!hdmi->bridge_is_on) |
| 1853 | dw_hdmi_poweron(hdmi); |
| 1854 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1855 | } |
| 1856 | |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1857 | /* |
| 1858 | * Adjust the detection of RXSENSE according to whether we have a forced |
| 1859 | * connection mode enabled, or whether we have been disabled. There is |
| 1860 | * no point processing RXSENSE interrupts if we have a forced connection |
| 1861 | * state, or DRM has us disabled. |
| 1862 | * |
| 1863 | * We also disable rxsense interrupts when we think we're disconnected |
| 1864 | * to avoid floating TDMS signals giving false rxsense interrupts. |
| 1865 | * |
| 1866 | * Note: we still need to listen for HPD interrupts even when DRM has us |
| 1867 | * disabled so that we can detect a connect event. |
| 1868 | */ |
| 1869 | static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi) |
| 1870 | { |
Neil Armstrong | 386d329 | 2017-04-04 14:31:59 +0200 | [diff] [blame] | 1871 | if (hdmi->phy.ops->update_hpd) |
| 1872 | hdmi->phy.ops->update_hpd(hdmi, hdmi->phy.data, |
| 1873 | hdmi->force, hdmi->disabled, |
| 1874 | hdmi->rxsense); |
Laurent Pinchart | a23d626 | 2017-04-04 14:31:56 +0200 | [diff] [blame] | 1875 | } |
| 1876 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1877 | static enum drm_connector_status |
| 1878 | dw_hdmi_connector_detect(struct drm_connector *connector, bool force) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1879 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1880 | struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 1881 | connector); |
Russell King | 98dbead | 2014-04-18 10:46:45 +0100 | [diff] [blame] | 1882 | |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1883 | mutex_lock(&hdmi->mutex); |
| 1884 | hdmi->force = DRM_FORCE_UNSPECIFIED; |
| 1885 | dw_hdmi_update_power(hdmi); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1886 | dw_hdmi_update_phy_mask(hdmi); |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1887 | mutex_unlock(&hdmi->mutex); |
| 1888 | |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 1889 | return hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1890 | } |
| 1891 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1892 | static int dw_hdmi_connector_get_modes(struct drm_connector *connector) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1893 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1894 | struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1895 | connector); |
| 1896 | struct edid *edid; |
Doug Anderson | 6c7e66e | 2015-06-04 11:04:36 -0700 | [diff] [blame] | 1897 | int ret = 0; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1898 | |
| 1899 | if (!hdmi->ddc) |
| 1900 | return 0; |
| 1901 | |
| 1902 | edid = drm_get_edid(connector, hdmi->ddc); |
| 1903 | if (edid) { |
| 1904 | dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n", |
| 1905 | edid->width_cm, edid->height_cm); |
| 1906 | |
Russell King | 05b1342 | 2015-07-21 15:35:52 +0100 | [diff] [blame] | 1907 | hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid); |
Russell King | f709ec0 | 2015-07-21 16:09:39 +0100 | [diff] [blame] | 1908 | hdmi->sink_has_audio = drm_detect_monitor_audio(edid); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1909 | drm_mode_connector_update_edid_property(connector, edid); |
Russell King | e84b8d7 | 2017-07-31 15:29:41 +0100 | [diff] [blame] | 1910 | cec_notifier_set_phys_addr_from_edid(hdmi->cec_notifier, edid); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1911 | ret = drm_add_edid_modes(connector, edid); |
Russell King | f5ce405 | 2013-11-07 16:06:01 +0000 | [diff] [blame] | 1912 | /* Store the ELD */ |
| 1913 | drm_edid_to_eld(connector, edid); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1914 | kfree(edid); |
| 1915 | } else { |
| 1916 | dev_dbg(hdmi->dev, "failed to get edid\n"); |
| 1917 | } |
| 1918 | |
Doug Anderson | 6c7e66e | 2015-06-04 11:04:36 -0700 | [diff] [blame] | 1919 | return ret; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1920 | } |
| 1921 | |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1922 | static void dw_hdmi_connector_force(struct drm_connector *connector) |
| 1923 | { |
| 1924 | struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, |
| 1925 | connector); |
| 1926 | |
| 1927 | mutex_lock(&hdmi->mutex); |
| 1928 | hdmi->force = connector->force; |
| 1929 | dw_hdmi_update_power(hdmi); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 1930 | dw_hdmi_update_phy_mask(hdmi); |
Russell King | 381f05a | 2015-06-05 15:25:08 +0100 | [diff] [blame] | 1931 | mutex_unlock(&hdmi->mutex); |
| 1932 | } |
| 1933 | |
Ville Syrjälä | dae91e4 | 2015-12-15 12:21:02 +0100 | [diff] [blame] | 1934 | static const struct drm_connector_funcs dw_hdmi_connector_funcs = { |
Mark Yao | 2c5b2cc | 2015-11-30 18:33:40 +0800 | [diff] [blame] | 1935 | .dpms = drm_atomic_helper_connector_dpms, |
| 1936 | .fill_modes = drm_helper_probe_single_connector_modes, |
| 1937 | .detect = dw_hdmi_connector_detect, |
Marek Vasut | fdd8326 | 2016-10-05 16:31:33 +0200 | [diff] [blame] | 1938 | .destroy = drm_connector_cleanup, |
Mark Yao | 2c5b2cc | 2015-11-30 18:33:40 +0800 | [diff] [blame] | 1939 | .force = dw_hdmi_connector_force, |
| 1940 | .reset = drm_atomic_helper_connector_reset, |
| 1941 | .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, |
| 1942 | .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, |
| 1943 | }; |
| 1944 | |
Ville Syrjälä | dae91e4 | 2015-12-15 12:21:02 +0100 | [diff] [blame] | 1945 | static const struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 1946 | .get_modes = dw_hdmi_connector_get_modes, |
Boris Brezillon | c2a441f | 2016-06-07 13:48:15 +0200 | [diff] [blame] | 1947 | .best_encoder = drm_atomic_helper_best_encoder, |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 1948 | }; |
| 1949 | |
Laurent Pinchart | d2ae94a | 2017-01-17 10:28:59 +0200 | [diff] [blame] | 1950 | static int dw_hdmi_bridge_attach(struct drm_bridge *bridge) |
| 1951 | { |
| 1952 | struct dw_hdmi *hdmi = bridge->driver_private; |
| 1953 | struct drm_encoder *encoder = bridge->encoder; |
| 1954 | struct drm_connector *connector = &hdmi->connector; |
| 1955 | |
| 1956 | connector->interlace_allowed = 1; |
| 1957 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
| 1958 | |
| 1959 | drm_connector_helper_add(connector, &dw_hdmi_connector_helper_funcs); |
| 1960 | |
| 1961 | drm_connector_init(bridge->dev, connector, &dw_hdmi_connector_funcs, |
| 1962 | DRM_MODE_CONNECTOR_HDMIA); |
| 1963 | |
| 1964 | drm_mode_connector_attach_encoder(connector, encoder); |
| 1965 | |
| 1966 | return 0; |
| 1967 | } |
| 1968 | |
Jose Abreu | b0febde | 2017-05-25 15:19:19 +0100 | [diff] [blame] | 1969 | static enum drm_mode_status |
| 1970 | dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge, |
| 1971 | const struct drm_display_mode *mode) |
Romain Perier | 6ce2ca5 | 2017-04-07 14:17:43 +0200 | [diff] [blame] | 1972 | { |
| 1973 | struct dw_hdmi *hdmi = bridge->driver_private; |
| 1974 | struct drm_connector *connector = &hdmi->connector; |
Jose Abreu | b0febde | 2017-05-25 15:19:19 +0100 | [diff] [blame] | 1975 | enum drm_mode_status mode_status = MODE_OK; |
Romain Perier | 6ce2ca5 | 2017-04-07 14:17:43 +0200 | [diff] [blame] | 1976 | |
Jose Abreu | b0febde | 2017-05-25 15:19:19 +0100 | [diff] [blame] | 1977 | /* We don't support double-clocked modes */ |
| 1978 | if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
| 1979 | return MODE_BAD; |
| 1980 | |
| 1981 | if (hdmi->plat_data->mode_valid) |
| 1982 | mode_status = hdmi->plat_data->mode_valid(connector, mode); |
| 1983 | |
| 1984 | return mode_status; |
Romain Perier | 6ce2ca5 | 2017-04-07 14:17:43 +0200 | [diff] [blame] | 1985 | } |
| 1986 | |
Laurent Pinchart | fd30b38 | 2017-01-17 10:28:58 +0200 | [diff] [blame] | 1987 | static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge, |
| 1988 | struct drm_display_mode *orig_mode, |
| 1989 | struct drm_display_mode *mode) |
| 1990 | { |
| 1991 | struct dw_hdmi *hdmi = bridge->driver_private; |
| 1992 | |
| 1993 | mutex_lock(&hdmi->mutex); |
| 1994 | |
| 1995 | /* Store the display mode for plugin/DKMS poweron events */ |
| 1996 | memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode)); |
| 1997 | |
| 1998 | mutex_unlock(&hdmi->mutex); |
| 1999 | } |
| 2000 | |
| 2001 | static void dw_hdmi_bridge_disable(struct drm_bridge *bridge) |
| 2002 | { |
| 2003 | struct dw_hdmi *hdmi = bridge->driver_private; |
| 2004 | |
| 2005 | mutex_lock(&hdmi->mutex); |
| 2006 | hdmi->disabled = true; |
| 2007 | dw_hdmi_update_power(hdmi); |
| 2008 | dw_hdmi_update_phy_mask(hdmi); |
| 2009 | mutex_unlock(&hdmi->mutex); |
| 2010 | } |
| 2011 | |
| 2012 | static void dw_hdmi_bridge_enable(struct drm_bridge *bridge) |
| 2013 | { |
| 2014 | struct dw_hdmi *hdmi = bridge->driver_private; |
| 2015 | |
| 2016 | mutex_lock(&hdmi->mutex); |
| 2017 | hdmi->disabled = false; |
| 2018 | dw_hdmi_update_power(hdmi); |
| 2019 | dw_hdmi_update_phy_mask(hdmi); |
| 2020 | mutex_unlock(&hdmi->mutex); |
| 2021 | } |
| 2022 | |
Ville Syrjälä | dae91e4 | 2015-12-15 12:21:02 +0100 | [diff] [blame] | 2023 | static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = { |
Laurent Pinchart | d2ae94a | 2017-01-17 10:28:59 +0200 | [diff] [blame] | 2024 | .attach = dw_hdmi_bridge_attach, |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2025 | .enable = dw_hdmi_bridge_enable, |
| 2026 | .disable = dw_hdmi_bridge_disable, |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2027 | .mode_set = dw_hdmi_bridge_mode_set, |
Jose Abreu | b0febde | 2017-05-25 15:19:19 +0100 | [diff] [blame] | 2028 | .mode_valid = dw_hdmi_bridge_mode_valid, |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 2029 | }; |
| 2030 | |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2031 | static irqreturn_t dw_hdmi_i2c_irq(struct dw_hdmi *hdmi) |
| 2032 | { |
| 2033 | struct dw_hdmi_i2c *i2c = hdmi->i2c; |
| 2034 | unsigned int stat; |
| 2035 | |
| 2036 | stat = hdmi_readb(hdmi, HDMI_IH_I2CM_STAT0); |
| 2037 | if (!stat) |
| 2038 | return IRQ_NONE; |
| 2039 | |
| 2040 | hdmi_writeb(hdmi, stat, HDMI_IH_I2CM_STAT0); |
| 2041 | |
| 2042 | i2c->stat = stat; |
| 2043 | |
| 2044 | complete(&i2c->cmp); |
| 2045 | |
| 2046 | return IRQ_HANDLED; |
| 2047 | } |
| 2048 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2049 | static irqreturn_t dw_hdmi_hardirq(int irq, void *dev_id) |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 2050 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2051 | struct dw_hdmi *hdmi = dev_id; |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 2052 | u8 intr_stat; |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2053 | irqreturn_t ret = IRQ_NONE; |
| 2054 | |
| 2055 | if (hdmi->i2c) |
| 2056 | ret = dw_hdmi_i2c_irq(hdmi); |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 2057 | |
| 2058 | intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2059 | if (intr_stat) { |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 2060 | hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2061 | return IRQ_WAKE_THREAD; |
| 2062 | } |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 2063 | |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2064 | return ret; |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 2065 | } |
| 2066 | |
Neil Armstrong | 386d329 | 2017-04-04 14:31:59 +0200 | [diff] [blame] | 2067 | void __dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense) |
| 2068 | { |
| 2069 | mutex_lock(&hdmi->mutex); |
| 2070 | |
| 2071 | if (!hdmi->force) { |
| 2072 | /* |
| 2073 | * If the RX sense status indicates we're disconnected, |
| 2074 | * clear the software rxsense status. |
| 2075 | */ |
| 2076 | if (!rx_sense) |
| 2077 | hdmi->rxsense = false; |
| 2078 | |
| 2079 | /* |
| 2080 | * Only set the software rxsense status when both |
| 2081 | * rxsense and hpd indicates we're connected. |
| 2082 | * This avoids what seems to be bad behaviour in |
| 2083 | * at least iMX6S versions of the phy. |
| 2084 | */ |
| 2085 | if (hpd) |
| 2086 | hdmi->rxsense = true; |
| 2087 | |
| 2088 | dw_hdmi_update_power(hdmi); |
| 2089 | dw_hdmi_update_phy_mask(hdmi); |
| 2090 | } |
| 2091 | mutex_unlock(&hdmi->mutex); |
| 2092 | } |
| 2093 | |
| 2094 | void dw_hdmi_setup_rx_sense(struct device *dev, bool hpd, bool rx_sense) |
| 2095 | { |
| 2096 | struct dw_hdmi *hdmi = dev_get_drvdata(dev); |
| 2097 | |
| 2098 | __dw_hdmi_setup_rx_sense(hdmi, hpd, rx_sense); |
| 2099 | } |
| 2100 | EXPORT_SYMBOL_GPL(dw_hdmi_setup_rx_sense); |
| 2101 | |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2102 | static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2103 | { |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2104 | struct dw_hdmi *hdmi = dev_id; |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 2105 | u8 intr_stat, phy_int_pol, phy_pol_mask, phy_stat; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2106 | |
| 2107 | intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2108 | phy_int_pol = hdmi_readb(hdmi, HDMI_PHY_POL0); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 2109 | phy_stat = hdmi_readb(hdmi, HDMI_PHY_STAT0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2110 | |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 2111 | phy_pol_mask = 0; |
| 2112 | if (intr_stat & HDMI_IH_PHY_STAT0_HPD) |
| 2113 | phy_pol_mask |= HDMI_PHY_HPD; |
| 2114 | if (intr_stat & HDMI_IH_PHY_STAT0_RX_SENSE0) |
| 2115 | phy_pol_mask |= HDMI_PHY_RX_SENSE0; |
| 2116 | if (intr_stat & HDMI_IH_PHY_STAT0_RX_SENSE1) |
| 2117 | phy_pol_mask |= HDMI_PHY_RX_SENSE1; |
| 2118 | if (intr_stat & HDMI_IH_PHY_STAT0_RX_SENSE2) |
| 2119 | phy_pol_mask |= HDMI_PHY_RX_SENSE2; |
| 2120 | if (intr_stat & HDMI_IH_PHY_STAT0_RX_SENSE3) |
| 2121 | phy_pol_mask |= HDMI_PHY_RX_SENSE3; |
| 2122 | |
| 2123 | if (phy_pol_mask) |
| 2124 | hdmi_modb(hdmi, ~phy_int_pol, phy_pol_mask, HDMI_PHY_POL0); |
| 2125 | |
| 2126 | /* |
| 2127 | * RX sense tells us whether the TDMS transmitters are detecting |
| 2128 | * load - in other words, there's something listening on the |
| 2129 | * other end of the link. Use this to decide whether we should |
| 2130 | * power on the phy as HPD may be toggled by the sink to merely |
| 2131 | * ask the source to re-read the EDID. |
| 2132 | */ |
| 2133 | if (intr_stat & |
Russell King | e84b8d7 | 2017-07-31 15:29:41 +0100 | [diff] [blame] | 2134 | (HDMI_IH_PHY_STAT0_RX_SENSE | HDMI_IH_PHY_STAT0_HPD)) { |
Neil Armstrong | 386d329 | 2017-04-04 14:31:59 +0200 | [diff] [blame] | 2135 | __dw_hdmi_setup_rx_sense(hdmi, |
| 2136 | phy_stat & HDMI_PHY_HPD, |
| 2137 | phy_stat & HDMI_PHY_RX_SENSE); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 2138 | |
Russell King | e84b8d7 | 2017-07-31 15:29:41 +0100 | [diff] [blame] | 2139 | if ((phy_stat & (HDMI_PHY_RX_SENSE | HDMI_PHY_HPD)) == 0) |
| 2140 | cec_notifier_set_phys_addr(hdmi->cec_notifier, |
| 2141 | CEC_PHYS_ADDR_INVALID); |
| 2142 | } |
| 2143 | |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 2144 | if (intr_stat & HDMI_IH_PHY_STAT0_HPD) { |
| 2145 | dev_dbg(hdmi->dev, "EVENT=%s\n", |
| 2146 | phy_int_pol & HDMI_PHY_HPD ? "plugin" : "plugout"); |
Laurent Pinchart | ba5d7e6 | 2017-01-17 10:28:56 +0200 | [diff] [blame] | 2147 | if (hdmi->bridge.dev) |
| 2148 | drm_helper_hpd_irq_event(hdmi->bridge.dev); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2149 | } |
| 2150 | |
| 2151 | hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0); |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 2152 | hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), |
| 2153 | HDMI_IH_MUTE_PHY_STAT0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2154 | |
| 2155 | return IRQ_HANDLED; |
| 2156 | } |
| 2157 | |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2158 | static const struct dw_hdmi_phy_data dw_hdmi_phys[] = { |
| 2159 | { |
| 2160 | .type = DW_HDMI_PHY_DWC_HDMI_TX_PHY, |
| 2161 | .name = "DWC HDMI TX PHY", |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 2162 | .gen = 1, |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2163 | }, { |
| 2164 | .type = DW_HDMI_PHY_DWC_MHL_PHY_HEAC, |
| 2165 | .name = "DWC MHL PHY + HEAC PHY", |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 2166 | .gen = 2, |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2167 | .has_svsret = true, |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 2168 | .configure = hdmi_phy_configure_dwc_hdmi_3d_tx, |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2169 | }, { |
| 2170 | .type = DW_HDMI_PHY_DWC_MHL_PHY, |
| 2171 | .name = "DWC MHL PHY", |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 2172 | .gen = 2, |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2173 | .has_svsret = true, |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 2174 | .configure = hdmi_phy_configure_dwc_hdmi_3d_tx, |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2175 | }, { |
| 2176 | .type = DW_HDMI_PHY_DWC_HDMI_3D_TX_PHY_HEAC, |
| 2177 | .name = "DWC HDMI 3D TX PHY + HEAC PHY", |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 2178 | .gen = 2, |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 2179 | .configure = hdmi_phy_configure_dwc_hdmi_3d_tx, |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2180 | }, { |
| 2181 | .type = DW_HDMI_PHY_DWC_HDMI_3D_TX_PHY, |
| 2182 | .name = "DWC HDMI 3D TX PHY", |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 2183 | .gen = 2, |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 2184 | .configure = hdmi_phy_configure_dwc_hdmi_3d_tx, |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2185 | }, { |
| 2186 | .type = DW_HDMI_PHY_DWC_HDMI20_TX_PHY, |
| 2187 | .name = "DWC HDMI 2.0 TX PHY", |
Laurent Pinchart | b0e583e | 2017-03-06 01:35:39 +0200 | [diff] [blame] | 2188 | .gen = 2, |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2189 | .has_svsret = true, |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 2190 | }, { |
| 2191 | .type = DW_HDMI_PHY_VENDOR_PHY, |
| 2192 | .name = "Vendor PHY", |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2193 | } |
| 2194 | }; |
| 2195 | |
| 2196 | static int dw_hdmi_detect_phy(struct dw_hdmi *hdmi) |
| 2197 | { |
| 2198 | unsigned int i; |
| 2199 | u8 phy_type; |
| 2200 | |
| 2201 | phy_type = hdmi_readb(hdmi, HDMI_CONFIG2_ID); |
| 2202 | |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 2203 | if (phy_type == DW_HDMI_PHY_VENDOR_PHY) { |
| 2204 | /* Vendor PHYs require support from the glue layer. */ |
| 2205 | if (!hdmi->plat_data->phy_ops || !hdmi->plat_data->phy_name) { |
| 2206 | dev_err(hdmi->dev, |
| 2207 | "Vendor HDMI PHY not supported by glue layer\n"); |
| 2208 | return -ENODEV; |
| 2209 | } |
| 2210 | |
| 2211 | hdmi->phy.ops = hdmi->plat_data->phy_ops; |
| 2212 | hdmi->phy.data = hdmi->plat_data->phy_data; |
| 2213 | hdmi->phy.name = hdmi->plat_data->phy_name; |
| 2214 | return 0; |
| 2215 | } |
| 2216 | |
| 2217 | /* Synopsys PHYs are handled internally. */ |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2218 | for (i = 0; i < ARRAY_SIZE(dw_hdmi_phys); ++i) { |
| 2219 | if (dw_hdmi_phys[i].type == phy_type) { |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 2220 | hdmi->phy.ops = &dw_hdmi_synopsys_phy_ops; |
| 2221 | hdmi->phy.name = dw_hdmi_phys[i].name; |
| 2222 | hdmi->phy.data = (void *)&dw_hdmi_phys[i]; |
Kieran Bingham | 2ef9dfe | 2017-03-03 19:20:04 +0200 | [diff] [blame] | 2223 | |
| 2224 | if (!dw_hdmi_phys[i].configure && |
| 2225 | !hdmi->plat_data->configure_phy) { |
| 2226 | dev_err(hdmi->dev, "%s requires platform support\n", |
| 2227 | hdmi->phy.name); |
| 2228 | return -ENODEV; |
| 2229 | } |
| 2230 | |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2231 | return 0; |
| 2232 | } |
| 2233 | } |
| 2234 | |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 2235 | dev_err(hdmi->dev, "Unsupported HDMI PHY type (%02x)\n", phy_type); |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2236 | return -ENODEV; |
| 2237 | } |
| 2238 | |
Neil Armstrong | 80e2f97 | 2017-03-03 19:20:06 +0200 | [diff] [blame] | 2239 | static const struct regmap_config hdmi_regmap_8bit_config = { |
| 2240 | .reg_bits = 32, |
| 2241 | .val_bits = 8, |
| 2242 | .reg_stride = 1, |
| 2243 | .max_register = HDMI_I2CM_FS_SCL_LCNT_0_ADDR, |
| 2244 | }; |
| 2245 | |
| 2246 | static const struct regmap_config hdmi_regmap_32bit_config = { |
| 2247 | .reg_bits = 32, |
| 2248 | .val_bits = 32, |
| 2249 | .reg_stride = 4, |
| 2250 | .max_register = HDMI_I2CM_FS_SCL_LCNT_0_ADDR << 2, |
| 2251 | }; |
| 2252 | |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2253 | static struct dw_hdmi * |
| 2254 | __dw_hdmi_probe(struct platform_device *pdev, |
| 2255 | const struct dw_hdmi_plat_data *plat_data) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2256 | { |
Laurent Pinchart | c608119 | 2017-01-17 10:28:57 +0200 | [diff] [blame] | 2257 | struct device *dev = &pdev->dev; |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 2258 | struct device_node *np = dev->of_node; |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 2259 | struct platform_device_info pdevinfo; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2260 | struct device_node *ddc_node; |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2261 | struct dw_hdmi *hdmi; |
Neil Armstrong | 80e2f97 | 2017-03-03 19:20:06 +0200 | [diff] [blame] | 2262 | struct resource *iores = NULL; |
Laurent Pinchart | c608119 | 2017-01-17 10:28:57 +0200 | [diff] [blame] | 2263 | int irq; |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 2264 | int ret; |
Andy Yan | 0cd9d14 | 2014-12-05 14:28:24 +0800 | [diff] [blame] | 2265 | u32 val = 1; |
Laurent Pinchart | 0527e12 | 2017-01-17 10:29:03 +0200 | [diff] [blame] | 2266 | u8 prod_id0; |
| 2267 | u8 prod_id1; |
Kuninori Morimoto | 2761ba6 | 2016-11-08 01:00:57 +0000 | [diff] [blame] | 2268 | u8 config0; |
Laurent Pinchart | 0c67494 | 2017-01-17 10:29:04 +0200 | [diff] [blame] | 2269 | u8 config3; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2270 | |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 2271 | hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2272 | if (!hdmi) |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2273 | return ERR_PTR(-ENOMEM); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2274 | |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 2275 | hdmi->plat_data = plat_data; |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 2276 | hdmi->dev = dev; |
Russell King | 4067838 | 2013-11-07 15:35:06 +0000 | [diff] [blame] | 2277 | hdmi->sample_rate = 48000; |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 2278 | hdmi->disabled = true; |
Russell King | aeac23b | 2015-06-05 13:46:22 +0100 | [diff] [blame] | 2279 | hdmi->rxsense = true; |
| 2280 | hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE); |
Russell King | 7cc4ab2 | 2017-07-31 15:29:46 +0100 | [diff] [blame] | 2281 | hdmi->mc_clkdis = 0x7f; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2282 | |
Russell King | b872a8e | 2015-06-05 12:22:46 +0100 | [diff] [blame] | 2283 | mutex_init(&hdmi->mutex); |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 2284 | mutex_init(&hdmi->audio_mutex); |
Russell King | b90120a | 2015-03-27 12:59:58 +0000 | [diff] [blame] | 2285 | spin_lock_init(&hdmi->audio_lock); |
Russell King | 6bcf495 | 2015-02-02 11:01:08 +0000 | [diff] [blame] | 2286 | |
Philipp Zabel | b5d4590 | 2014-03-05 10:20:56 +0100 | [diff] [blame] | 2287 | ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2288 | if (ddc_node) { |
Vladimir Zapolskiy | 9f04a1f | 2016-08-16 23:26:43 +0300 | [diff] [blame] | 2289 | hdmi->ddc = of_get_i2c_adapter_by_node(ddc_node); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2290 | of_node_put(ddc_node); |
Andy Yan | c2c3848 | 2014-12-05 14:24:28 +0800 | [diff] [blame] | 2291 | if (!hdmi->ddc) { |
| 2292 | dev_dbg(hdmi->dev, "failed to read ddc node\n"); |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2293 | return ERR_PTR(-EPROBE_DEFER); |
Andy Yan | c2c3848 | 2014-12-05 14:24:28 +0800 | [diff] [blame] | 2294 | } |
| 2295 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2296 | } else { |
| 2297 | dev_dbg(hdmi->dev, "no ddc property found\n"); |
| 2298 | } |
| 2299 | |
Neil Armstrong | 80e2f97 | 2017-03-03 19:20:06 +0200 | [diff] [blame] | 2300 | if (!plat_data->regm) { |
| 2301 | const struct regmap_config *reg_config; |
| 2302 | |
| 2303 | of_property_read_u32(np, "reg-io-width", &val); |
| 2304 | switch (val) { |
| 2305 | case 4: |
| 2306 | reg_config = &hdmi_regmap_32bit_config; |
| 2307 | hdmi->reg_shift = 2; |
| 2308 | break; |
| 2309 | case 1: |
| 2310 | reg_config = &hdmi_regmap_8bit_config; |
| 2311 | break; |
| 2312 | default: |
| 2313 | dev_err(dev, "reg-io-width must be 1 or 4\n"); |
| 2314 | return ERR_PTR(-EINVAL); |
| 2315 | } |
| 2316 | |
| 2317 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 2318 | hdmi->regs = devm_ioremap_resource(dev, iores); |
| 2319 | if (IS_ERR(hdmi->regs)) { |
| 2320 | ret = PTR_ERR(hdmi->regs); |
| 2321 | goto err_res; |
| 2322 | } |
| 2323 | |
| 2324 | hdmi->regm = devm_regmap_init_mmio(dev, hdmi->regs, reg_config); |
| 2325 | if (IS_ERR(hdmi->regm)) { |
| 2326 | dev_err(dev, "Failed to configure regmap\n"); |
| 2327 | ret = PTR_ERR(hdmi->regm); |
| 2328 | goto err_res; |
| 2329 | } |
| 2330 | } else { |
| 2331 | hdmi->regm = plat_data->regm; |
Vladimir Zapolskiy | 9f04a1f | 2016-08-16 23:26:43 +0300 | [diff] [blame] | 2332 | } |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2333 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2334 | hdmi->isfr_clk = devm_clk_get(hdmi->dev, "isfr"); |
| 2335 | if (IS_ERR(hdmi->isfr_clk)) { |
| 2336 | ret = PTR_ERR(hdmi->isfr_clk); |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 2337 | dev_err(hdmi->dev, "Unable to get HDMI isfr clk: %d\n", ret); |
Vladimir Zapolskiy | 9f04a1f | 2016-08-16 23:26:43 +0300 | [diff] [blame] | 2338 | goto err_res; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2339 | } |
| 2340 | |
| 2341 | ret = clk_prepare_enable(hdmi->isfr_clk); |
| 2342 | if (ret) { |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 2343 | dev_err(hdmi->dev, "Cannot enable HDMI isfr clock: %d\n", ret); |
Vladimir Zapolskiy | 9f04a1f | 2016-08-16 23:26:43 +0300 | [diff] [blame] | 2344 | goto err_res; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | hdmi->iahb_clk = devm_clk_get(hdmi->dev, "iahb"); |
| 2348 | if (IS_ERR(hdmi->iahb_clk)) { |
| 2349 | ret = PTR_ERR(hdmi->iahb_clk); |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 2350 | 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] | 2351 | goto err_isfr; |
| 2352 | } |
| 2353 | |
| 2354 | ret = clk_prepare_enable(hdmi->iahb_clk); |
| 2355 | if (ret) { |
Andy Yan | b587833 | 2014-12-05 14:23:52 +0800 | [diff] [blame] | 2356 | dev_err(hdmi->dev, "Cannot enable HDMI iahb clock: %d\n", ret); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2357 | goto err_isfr; |
| 2358 | } |
| 2359 | |
| 2360 | /* Product and revision IDs */ |
Laurent Pinchart | be41fc5 | 2017-01-17 10:29:05 +0200 | [diff] [blame] | 2361 | hdmi->version = (hdmi_readb(hdmi, HDMI_DESIGN_ID) << 8) |
| 2362 | | (hdmi_readb(hdmi, HDMI_REVISION_ID) << 0); |
Laurent Pinchart | 0527e12 | 2017-01-17 10:29:03 +0200 | [diff] [blame] | 2363 | prod_id0 = hdmi_readb(hdmi, HDMI_PRODUCT_ID0); |
| 2364 | prod_id1 = hdmi_readb(hdmi, HDMI_PRODUCT_ID1); |
| 2365 | |
| 2366 | if (prod_id0 != HDMI_PRODUCT_ID0_HDMI_TX || |
| 2367 | (prod_id1 & ~HDMI_PRODUCT_ID1_HDCP) != HDMI_PRODUCT_ID1_HDMI_TX) { |
| 2368 | dev_err(dev, "Unsupported HDMI controller (%04x:%02x:%02x)\n", |
Laurent Pinchart | be41fc5 | 2017-01-17 10:29:05 +0200 | [diff] [blame] | 2369 | hdmi->version, prod_id0, prod_id1); |
Laurent Pinchart | 0527e12 | 2017-01-17 10:29:03 +0200 | [diff] [blame] | 2370 | ret = -ENODEV; |
| 2371 | goto err_iahb; |
| 2372 | } |
| 2373 | |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2374 | ret = dw_hdmi_detect_phy(hdmi); |
| 2375 | if (ret < 0) |
| 2376 | goto err_iahb; |
| 2377 | |
| 2378 | dev_info(dev, "Detected HDMI TX controller v%x.%03x %s HDCP (%s)\n", |
Laurent Pinchart | be41fc5 | 2017-01-17 10:29:05 +0200 | [diff] [blame] | 2379 | hdmi->version >> 12, hdmi->version & 0xfff, |
Laurent Pinchart | faba6c3 | 2017-01-17 10:29:06 +0200 | [diff] [blame] | 2380 | prod_id1 & HDMI_PRODUCT_ID1_HDCP ? "with" : "without", |
Laurent Pinchart | f1585f6 | 2017-03-06 01:36:15 +0200 | [diff] [blame] | 2381 | hdmi->phy.name); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2382 | |
| 2383 | initialize_hdmi_ih_mutes(hdmi); |
| 2384 | |
Laurent Pinchart | c608119 | 2017-01-17 10:28:57 +0200 | [diff] [blame] | 2385 | irq = platform_get_irq(pdev, 0); |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2386 | if (irq < 0) { |
| 2387 | ret = irq; |
Laurent Pinchart | c608119 | 2017-01-17 10:28:57 +0200 | [diff] [blame] | 2388 | goto err_iahb; |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2389 | } |
Laurent Pinchart | c608119 | 2017-01-17 10:28:57 +0200 | [diff] [blame] | 2390 | |
Philipp Zabel | 639a202 | 2015-01-07 13:43:50 +0100 | [diff] [blame] | 2391 | ret = devm_request_threaded_irq(dev, irq, dw_hdmi_hardirq, |
| 2392 | dw_hdmi_irq, IRQF_SHARED, |
| 2393 | dev_name(dev), hdmi); |
| 2394 | if (ret) |
Fabio Estevam | b33ef61 | 2015-01-27 10:54:12 -0200 | [diff] [blame] | 2395 | goto err_iahb; |
Philipp Zabel | 639a202 | 2015-01-07 13:43:50 +0100 | [diff] [blame] | 2396 | |
Russell King | e84b8d7 | 2017-07-31 15:29:41 +0100 | [diff] [blame] | 2397 | hdmi->cec_notifier = cec_notifier_get(dev); |
| 2398 | if (!hdmi->cec_notifier) { |
| 2399 | ret = -ENOMEM; |
| 2400 | goto err_iahb; |
| 2401 | } |
| 2402 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2403 | /* |
| 2404 | * To prevent overflows in HDMI_IH_FC_STAT2, set the clk regenerator |
| 2405 | * N and cts values before enabling phy |
| 2406 | */ |
| 2407 | hdmi_init_clk_regenerator(hdmi); |
| 2408 | |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2409 | /* If DDC bus is not specified, try to register HDMI I2C bus */ |
| 2410 | if (!hdmi->ddc) { |
| 2411 | hdmi->ddc = dw_hdmi_i2c_adapter(hdmi); |
| 2412 | if (IS_ERR(hdmi->ddc)) |
| 2413 | hdmi->ddc = NULL; |
| 2414 | } |
| 2415 | |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2416 | hdmi->bridge.driver_private = hdmi; |
| 2417 | hdmi->bridge.funcs = &dw_hdmi_bridge_funcs; |
Arnd Bergmann | d5ad784 | 2017-01-23 13:20:38 +0100 | [diff] [blame] | 2418 | #ifdef CONFIG_OF |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2419 | hdmi->bridge.of_node = pdev->dev.of_node; |
Arnd Bergmann | d5ad784 | 2017-01-23 13:20:38 +0100 | [diff] [blame] | 2420 | #endif |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2421 | |
Laurent Pinchart | a23d626 | 2017-04-04 14:31:56 +0200 | [diff] [blame] | 2422 | dw_hdmi_setup_i2c(hdmi); |
Neil Armstrong | 386d329 | 2017-04-04 14:31:59 +0200 | [diff] [blame] | 2423 | if (hdmi->phy.ops->setup_hpd) |
| 2424 | hdmi->phy.ops->setup_hpd(hdmi, hdmi->phy.data); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2425 | |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 2426 | memset(&pdevinfo, 0, sizeof(pdevinfo)); |
| 2427 | pdevinfo.parent = dev; |
| 2428 | pdevinfo.id = PLATFORM_DEVID_AUTO; |
| 2429 | |
Kuninori Morimoto | 2761ba6 | 2016-11-08 01:00:57 +0000 | [diff] [blame] | 2430 | config0 = hdmi_readb(hdmi, HDMI_CONFIG0_ID); |
Laurent Pinchart | 0c67494 | 2017-01-17 10:29:04 +0200 | [diff] [blame] | 2431 | config3 = hdmi_readb(hdmi, HDMI_CONFIG3_ID); |
Kuninori Morimoto | 2761ba6 | 2016-11-08 01:00:57 +0000 | [diff] [blame] | 2432 | |
Neil Armstrong | 80e2f97 | 2017-03-03 19:20:06 +0200 | [diff] [blame] | 2433 | if (iores && config3 & HDMI_CONFIG3_AHBAUDDMA) { |
Kuninori Morimoto | 2761ba6 | 2016-11-08 01:00:57 +0000 | [diff] [blame] | 2434 | struct dw_hdmi_audio_data audio; |
| 2435 | |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 2436 | audio.phys = iores->start; |
| 2437 | audio.base = hdmi->regs; |
| 2438 | audio.irq = irq; |
| 2439 | audio.hdmi = hdmi; |
Russell King | f5ce405 | 2013-11-07 16:06:01 +0000 | [diff] [blame] | 2440 | audio.eld = hdmi->connector.eld; |
Romain Perier | a7d555d | 2017-04-14 10:31:12 +0200 | [diff] [blame] | 2441 | hdmi->enable_audio = dw_hdmi_ahb_audio_enable; |
| 2442 | hdmi->disable_audio = dw_hdmi_ahb_audio_disable; |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 2443 | |
| 2444 | pdevinfo.name = "dw-hdmi-ahb-audio"; |
| 2445 | pdevinfo.data = &audio; |
| 2446 | pdevinfo.size_data = sizeof(audio); |
| 2447 | pdevinfo.dma_mask = DMA_BIT_MASK(32); |
| 2448 | hdmi->audio = platform_device_register_full(&pdevinfo); |
Kuninori Morimoto | 2761ba6 | 2016-11-08 01:00:57 +0000 | [diff] [blame] | 2449 | } else if (config0 & HDMI_CONFIG0_I2S) { |
| 2450 | struct dw_hdmi_i2s_audio_data audio; |
| 2451 | |
| 2452 | audio.hdmi = hdmi; |
| 2453 | audio.write = hdmi_writeb; |
| 2454 | audio.read = hdmi_readb; |
Romain Perier | a7d555d | 2017-04-14 10:31:12 +0200 | [diff] [blame] | 2455 | hdmi->enable_audio = dw_hdmi_i2s_audio_enable; |
Romain Perier | 57fbc05 | 2017-04-20 14:34:34 +0530 | [diff] [blame] | 2456 | hdmi->disable_audio = dw_hdmi_i2s_audio_disable; |
Kuninori Morimoto | 2761ba6 | 2016-11-08 01:00:57 +0000 | [diff] [blame] | 2457 | |
| 2458 | pdevinfo.name = "dw-hdmi-i2s-audio"; |
| 2459 | pdevinfo.data = &audio; |
| 2460 | pdevinfo.size_data = sizeof(audio); |
| 2461 | pdevinfo.dma_mask = DMA_BIT_MASK(32); |
| 2462 | hdmi->audio = platform_device_register_full(&pdevinfo); |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 2463 | } |
| 2464 | |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2465 | /* Reset HDMI DDC I2C master controller and mute I2CM interrupts */ |
| 2466 | if (hdmi->i2c) |
| 2467 | dw_hdmi_i2c_init(hdmi); |
| 2468 | |
Laurent Pinchart | c608119 | 2017-01-17 10:28:57 +0200 | [diff] [blame] | 2469 | platform_set_drvdata(pdev, hdmi); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2470 | |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2471 | return hdmi; |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2472 | |
| 2473 | err_iahb: |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2474 | if (hdmi->i2c) { |
| 2475 | i2c_del_adapter(&hdmi->i2c->adap); |
| 2476 | hdmi->ddc = NULL; |
| 2477 | } |
| 2478 | |
Russell King | e84b8d7 | 2017-07-31 15:29:41 +0100 | [diff] [blame] | 2479 | if (hdmi->cec_notifier) |
| 2480 | cec_notifier_put(hdmi->cec_notifier); |
| 2481 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2482 | clk_disable_unprepare(hdmi->iahb_clk); |
| 2483 | err_isfr: |
| 2484 | clk_disable_unprepare(hdmi->isfr_clk); |
Vladimir Zapolskiy | 9f04a1f | 2016-08-16 23:26:43 +0300 | [diff] [blame] | 2485 | err_res: |
| 2486 | i2c_put_adapter(hdmi->ddc); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2487 | |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2488 | return ERR_PTR(ret); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2489 | } |
| 2490 | |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2491 | static void __dw_hdmi_remove(struct dw_hdmi *hdmi) |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2492 | { |
Russell King | 7ed6c66 | 2013-11-07 16:01:45 +0000 | [diff] [blame] | 2493 | if (hdmi->audio && !IS_ERR(hdmi->audio)) |
| 2494 | platform_device_unregister(hdmi->audio); |
| 2495 | |
Russell King | d94905e | 2013-11-03 22:23:24 +0000 | [diff] [blame] | 2496 | /* Disable all interrupts */ |
| 2497 | hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); |
| 2498 | |
Hans Verkuil | e383bf8 | 2017-08-07 09:20:35 +0200 | [diff] [blame^] | 2499 | if (hdmi->cec_notifier) |
| 2500 | cec_notifier_put(hdmi->cec_notifier); |
| 2501 | |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2502 | clk_disable_unprepare(hdmi->iahb_clk); |
| 2503 | clk_disable_unprepare(hdmi->isfr_clk); |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2504 | |
| 2505 | if (hdmi->i2c) |
| 2506 | i2c_del_adapter(&hdmi->i2c->adap); |
| 2507 | else |
| 2508 | i2c_put_adapter(hdmi->ddc); |
Russell King | 17b5001 | 2013-11-03 11:23:34 +0000 | [diff] [blame] | 2509 | } |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2510 | |
| 2511 | /* ----------------------------------------------------------------------------- |
| 2512 | * Probe/remove API, used from platforms based on the DRM bridge API. |
| 2513 | */ |
| 2514 | int dw_hdmi_probe(struct platform_device *pdev, |
| 2515 | const struct dw_hdmi_plat_data *plat_data) |
| 2516 | { |
| 2517 | struct dw_hdmi *hdmi; |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2518 | |
| 2519 | hdmi = __dw_hdmi_probe(pdev, plat_data); |
| 2520 | if (IS_ERR(hdmi)) |
| 2521 | return PTR_ERR(hdmi); |
| 2522 | |
Inki Dae | b678682 | 2017-07-03 17:42:25 +0900 | [diff] [blame] | 2523 | drm_bridge_add(&hdmi->bridge); |
Laurent Pinchart | 69497eb | 2017-01-17 10:29:00 +0200 | [diff] [blame] | 2524 | |
| 2525 | return 0; |
| 2526 | } |
| 2527 | EXPORT_SYMBOL_GPL(dw_hdmi_probe); |
| 2528 | |
| 2529 | void dw_hdmi_remove(struct platform_device *pdev) |
| 2530 | { |
| 2531 | struct dw_hdmi *hdmi = platform_get_drvdata(pdev); |
| 2532 | |
| 2533 | drm_bridge_remove(&hdmi->bridge); |
| 2534 | |
| 2535 | __dw_hdmi_remove(hdmi); |
| 2536 | } |
| 2537 | EXPORT_SYMBOL_GPL(dw_hdmi_remove); |
| 2538 | |
| 2539 | /* ----------------------------------------------------------------------------- |
| 2540 | * Bind/unbind API, used from platforms based on the component framework. |
| 2541 | */ |
| 2542 | int dw_hdmi_bind(struct platform_device *pdev, struct drm_encoder *encoder, |
| 2543 | const struct dw_hdmi_plat_data *plat_data) |
| 2544 | { |
| 2545 | struct dw_hdmi *hdmi; |
| 2546 | int ret; |
| 2547 | |
| 2548 | hdmi = __dw_hdmi_probe(pdev, plat_data); |
| 2549 | if (IS_ERR(hdmi)) |
| 2550 | return PTR_ERR(hdmi); |
| 2551 | |
| 2552 | ret = drm_bridge_attach(encoder, &hdmi->bridge, NULL); |
| 2553 | if (ret) { |
| 2554 | dw_hdmi_remove(pdev); |
| 2555 | DRM_ERROR("Failed to initialize bridge with drm\n"); |
| 2556 | return ret; |
| 2557 | } |
| 2558 | |
| 2559 | return 0; |
| 2560 | } |
| 2561 | EXPORT_SYMBOL_GPL(dw_hdmi_bind); |
| 2562 | |
| 2563 | void dw_hdmi_unbind(struct device *dev) |
| 2564 | { |
| 2565 | struct dw_hdmi *hdmi = dev_get_drvdata(dev); |
| 2566 | |
| 2567 | __dw_hdmi_remove(hdmi); |
| 2568 | } |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2569 | EXPORT_SYMBOL_GPL(dw_hdmi_unbind); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2570 | |
| 2571 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
Andy Yan | 3d1b35a | 2014-12-05 14:25:05 +0800 | [diff] [blame] | 2572 | MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com>"); |
| 2573 | MODULE_AUTHOR("Yakir Yang <ykk@rock-chips.com>"); |
Vladimir Zapolskiy | 3efc2fa | 2016-08-24 08:46:37 +0300 | [diff] [blame] | 2574 | MODULE_AUTHOR("Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>"); |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2575 | MODULE_DESCRIPTION("DW HDMI transmitter driver"); |
Fabio Estevam | 9aaf880 | 2013-11-29 08:46:32 -0200 | [diff] [blame] | 2576 | MODULE_LICENSE("GPL"); |
Andy Yan | b21f4b6 | 2014-12-05 14:26:31 +0800 | [diff] [blame] | 2577 | MODULE_ALIAS("platform:dw-hdmi"); |