coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
hdmi.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /*
4  * Designware High-Definition Multimedia Interface (HDMI) driveG
5  */
6 
7 #include <device/mmio.h>
8 #include <console/console.h>
9 #include <delay.h>
10 #include <edid.h>
11 #include <gpio.h>
12 #include <stdint.h>
13 #include <soc/addressmap.h>
14 #include <soc/hdmi.h>
15 #include <soc/grf.h>
16 #include <soc/vop.h>
17 #include <timer.h>
18 
19 #include "chip.h"
20 
21 #define AUDIO_SAMPLERATE_DEFAULT (48*KHz)
22 
23 #define hdmi_debug(x...) do { if (0) printk(BIOS_DEBUG, x); } while (0)
24 
25 struct rk3288_hdmi_regs * const hdmi_regs = (void *)HDMI_TX_BASE;
26 
27 struct tmds_n_cts {
30  u32 n;
31 };
32 
33 static const struct tmds_n_cts n_cts_table[] = {
34  {
35  .tmds = 25175, .n = 6144, .cts = 25175,
36  }, {
37  .tmds = 25200, .n = 6144, .cts = 25200,
38  }, {
39  .tmds = 27000, .n = 6144, .cts = 27000,
40  }, {
41  .tmds = 27027, .n = 6144, .cts = 27027,
42  }, {
43  .tmds = 40000, .n = 6144, .cts = 40000,
44  }, {
45  .tmds = 54000, .n = 6144, .cts = 54000,
46  }, {
47  .tmds = 54054, .n = 6144, .cts = 54054,
48  }, {
49  .tmds = 65000, .n = 6144, .cts = 65000,
50  }, {
51  .tmds = 74176, .n = 11648, .cts = 140625,
52  }, {
53  .tmds = 74250, .n = 6144, .cts = 74250,
54  }, {
55  .tmds = 83500, .n = 6144, .cts = 83500,
56  }, {
57  .tmds = 106500, .n = 6144, .cts = 106500,
58  }, {
59  .tmds = 108000, .n = 6144, .cts = 108000,
60  }, {
61  .tmds = 148352, .n = 5824, .cts = 140625,
62  }, {
63  .tmds = 148500, .n = 6144, .cts = 148500,
64  }, {
65  .tmds = 297000, .n = 5120, .cts = 247500,
66  }
67 };
68 
71  /* Mode of Operation and PLL Dividers Control Register */
73  /* PLL Gmp Control Register */
75  /* PLL Current COntrol Register */
77 };
78 
81  u32 sym_ctr; /* clock symbol and transmitter control */
82  u32 term; /* transmission termination value */
83  u32 vlev_ctr; /* voltage level control */
84 };
85 
86 static const struct hdmi_phy_config rockchip_phy_config[] = {
87  {
88  .mpixelclock = 74250,
89  .sym_ctr = 0x8009, .term = 0x0004, .vlev_ctr = 0x0272,
90  }, {
91  .mpixelclock = 148500,
92  .sym_ctr = 0x802b, .term = 0x0004, .vlev_ctr = 0x028d,
93  }, {
94  .mpixelclock = 297000,
95  .sym_ctr = 0x8039, .term = 0x0005, .vlev_ctr = 0x028d,
96  }, {
97  .mpixelclock = ~0ul,
98  .sym_ctr = 0x0000, .term = 0x0000, .vlev_ctr = 0x0000,
99  }
100 };
101 
102 static const struct hdmi_mpll_config rockchip_mpll_cfg[] = {
103  {
104  .mpixelclock = 40000,
105  .cpce = 0x00b3, .gmp = 0x0000, .curr = 0x0018,
106  }, {
107  .mpixelclock = 65000,
108  .cpce = 0x0072, .gmp = 0x0001, .curr = 0x0028,
109  }, {
110  .mpixelclock = 66000,
111  .cpce = 0x013e, .gmp = 0x0003, .curr = 0x0038,
112  }, {
113  .mpixelclock = 83500,
114  .cpce = 0x0072, .gmp = 0x0001, .curr = 0x0028,
115  }, {
116  .mpixelclock = 146250,
117  .cpce = 0x0051, .gmp = 0x0002, .curr = 0x0038,
118  }, {
119  .mpixelclock = 148500,
120  .cpce = 0x0051, .gmp = 0x0003, .curr = 0x0000,
121  }, {
122  .mpixelclock = ~0ul,
123  .cpce = 0x0051, .gmp = 0x0003, .curr = 0x0000,
124  }
125 };
126 
127 static const u32 csc_coeff_default[3][4] = {
128  { 0x2000, 0x0000, 0x0000, 0x0000 },
129  { 0x0000, 0x2000, 0x0000, 0x0000 },
130  { 0x0000, 0x0000, 0x2000, 0x0000 }
131 };
132 
133 static void hdmi_set_clock_regenerator(u32 n, u32 cts)
134 {
135  u8 cts3;
136  u8 n3;
137 
138  /* first set ncts_atomic_write (if present) */
140  write32(&hdmi_regs->aud_n3, n3);
141 
142  /* set cts_manual (if present) */
144 
146  cts3 |= (cts >> 16) & HDMI_AUD_CTS3_AUDCTS19_16_MASK;
147 
148  /* write cts values; cts3 must be written first */
149  write32(&hdmi_regs->aud_cts3, cts3);
150  write32(&hdmi_regs->aud_cts2, (cts >> 8) & 0xff);
151  write32(&hdmi_regs->aud_cts1, cts & 0xff);
152 
153  /* write n values; n1 must be written last */
154  n3 |= (n >> 16) & HDMI_AUD_N3_AUDN19_16_MASK;
155  write32(&hdmi_regs->aud_n3, n3);
156  write32(&hdmi_regs->aud_n2, (n >> 8) & 0xff);
157  write32(&hdmi_regs->aud_n1, n & 0xff);
158 
160 }
161 
162 static int hdmi_lookup_n_cts(u32 pixel_clk)
163 {
164  int i;
165 
166  for (i = 0; i < ARRAY_SIZE(n_cts_table); i++)
167  if (pixel_clk <= n_cts_table[i].tmds)
168  break;
169 
170  if (i >= ARRAY_SIZE(n_cts_table))
171  return -1;
172 
173  return i;
174 }
175 
176 static void hdmi_audio_set_samplerate(u32 pixel_clk)
177 {
178  u32 clk_n, clk_cts;
179  int index;
180 
181  index = hdmi_lookup_n_cts(pixel_clk);
182  if (index == -1) {
183  hdmi_debug("audio not supported for pixel clk %d\n", pixel_clk);
184  return;
185  }
186 
187  clk_n = n_cts_table[index].n;
188  clk_cts = n_cts_table[index].cts;
189  hdmi_set_clock_regenerator(clk_n, clk_cts);
190 }
191 
192 /*
193  * this submodule is responsible for the video data synchronization.
194  * for example, for rgb 4:4:4 input, the data map is defined as
195  * pin{47~40} <==> r[7:0]
196  * pin{31~24} <==> g[7:0]
197  * pin{15~8} <==> b[7:0]
198  */
199 static void hdmi_video_sample(void)
200 {
201  u32 color_format = 0x01;
202  u8 val;
203 
205  ((color_format << HDMI_TX_INVID0_VIDEO_MAPPING_OFFSET) &
207 
209 
210  /* enable tx stuffing: when de is inactive, fix the output data to 0 */
215  write32(&hdmi_regs->tx_gydata0, 0x0);
216  write32(&hdmi_regs->tx_gydata1, 0x0);
217  write32(&hdmi_regs->tx_rcrdata0, 0x0);
218  write32(&hdmi_regs->tx_rcrdata1, 0x0);
219  write32(&hdmi_regs->tx_bcbdata0, 0x0);
220  write32(&hdmi_regs->tx_bcbdata1, 0x0);
221 }
222 
223 static void hdmi_update_csc_coeffs(void)
224 {
225  u32 i, j;
226  u32 csc_scale = 1;
227 
228  /* the csc registers are sequential, alternating msb then lsb */
229  for (i = 0; i < ARRAY_SIZE(csc_coeff_default); i++) {
230  for (j = 0; j < ARRAY_SIZE(csc_coeff_default[0]); j++) {
231  u32 coeff = csc_coeff_default[i][j];
232  write32(&hdmi_regs->csc_coef[i][j].msb, coeff >> 8);
233  write32(&hdmi_regs->csc_coef[i][j].lsb, coeff & 0xff);
234  }
235  }
236 
238  csc_scale);
239 }
240 
241 static void hdmi_video_csc(void)
242 {
244  u32 interpolation = HDMI_CSC_CFG_INTMODE_DISABLE;
245 
246  /* configure the csc registers */
247  write32(&hdmi_regs->csc_cfg, interpolation);
250 
252 }
253 
254 static void hdmi_video_packetize(void)
255 {
257  u32 remap_size = HDMI_VP_REMAP_YCC422_16BIT;
258  u32 color_depth = 0;
259  u8 val, vp_conf;
260 
261  /* set the packetizer registers */
267 
270 
271  /* data from pixel repeater block */
272  vp_conf = HDMI_VP_CONF_PR_EN_DISABLE |
274 
277 
280 
281  write32(&hdmi_regs->vp_remap, remap_size);
282 
286 
289  vp_conf);
290 
295 
297  output_select);
298 }
299 
300 static inline void hdmi_phy_test_clear(u8 bit)
301 {
304 }
305 
306 static int hdmi_phy_wait_i2c_done(u32 msec)
307 {
308  struct stopwatch phyi2c_done;
309  u32 val;
310 
311  stopwatch_init_msecs_expire(&phyi2c_done, msec);
312  do {
314  if (val & 0x3) {
316  return 0;
317  }
318 
319  udelay(100);
320  } while (!stopwatch_expired(&phyi2c_done));
321 
322  return 1;
323 }
324 
325 static void hdmi_phy_i2c_write(u16 data, u8 addr)
326 {
329  write32(&hdmi_regs->phy_i2cm_datao_1_addr, (u8)(data >> 8));
330  write32(&hdmi_regs->phy_i2cm_datao_0_addr, (u8)(data >> 0));
333 
335 }
336 
337 static void hdmi_phy_enable_power(u8 enable)
338 {
340  enable << HDMI_PHY_CONF0_PDZ_OFFSET);
341 }
342 
343 static void hdmi_phy_enable_tmds(u8 enable)
344 {
346  enable << HDMI_PHY_CONF0_ENTMDS_OFFSET);
347 }
348 
349 static void hdmi_phy_enable_spare(u8 enable)
350 {
353 }
354 
355 static void hdmi_phy_gen2_pddq(u8 enable)
356 {
359 }
360 
361 static void hdmi_phy_gen2_txpwron(u8 enable)
362 {
366 }
367 
368 static void hdmi_phy_sel_data_en_pol(u8 enable)
369 {
373 }
374 
376 {
379 }
380 
381 static int hdmi_phy_configure(u32 mpixelclock)
382 {
383  struct stopwatch pll_ready;
384  u8 i, val;
385 
388 
389  /* gen2 tx power off */
391 
392  /* gen2 pddq */
394 
395  /* phy reset */
399 
404 
405  /* pll/mpll cfg - always match on final entry */
406  for (i = 0; rockchip_mpll_cfg[i].mpixelclock != (~0ul); i++)
407  if (mpixelclock <= rockchip_mpll_cfg[i].mpixelclock)
408  break;
409 
413 
416 
417  for (i = 0; rockchip_phy_config[i].mpixelclock != (~0ul); i++)
418  if (mpixelclock <= rockchip_phy_config[i].mpixelclock)
419  break;
420 
421  /*
422  * resistance term 133ohm cfg
423  * preemp cgf 0.00
424  * tx/ck lvl 10
425  */
429 
430  /* remove clk term */
432 
434 
435  /* toggle tmds enable */
438 
439  /* gen2 tx power on */
442 
444 
445  /* wait for phy pll lock */
446  stopwatch_init_msecs_expire(&pll_ready, 5);
447  do {
449  if (!(val & HDMI_PHY_TX_PHY_LOCK))
450  return 0;
451 
452  udelay(100);
453  } while (!stopwatch_expired(&pll_ready));
454 
455  return -1;
456 }
457 
458 static int hdmi_phy_init(u32 mpixelclock)
459 {
460  int i, ret;
461 
462  /* hdmi phy spec says to do the phy initialization sequence twice */
463  for (i = 0; i < 2; i++) {
468 
469  /* enable csc */
470  ret = hdmi_phy_configure(mpixelclock);
471  if (ret) {
472  hdmi_debug("hdmi phy config failure %d\n", ret);
473  return ret;
474  }
475  }
476 
477  return 0;
478 }
479 
480 static void hdmi_av_composer(const struct edid *edid)
481 {
482  u8 mdataenablepolarity = 1;
483  u8 inv_val;
484 
485  /* set up hdmi_fc_invidconf */
487 
488  inv_val |= ((edid->mode.pvsync == '+') ?
491 
492  inv_val |= ((edid->mode.phsync == '+') ?
495 
496  inv_val |= (mdataenablepolarity ?
499 
500  inv_val |= (edid->hdmi_monitor_detected ?
503 
505 
507 
508  write32(&hdmi_regs->fc_invidconf, inv_val);
509 
510  /* set up horizontal active pixel width */
513 
514  /* set up vertical active lines */
517 
518  /* set up horizontal blanking pixel region width */
521 
522  /* set up vertical blanking pixel region width */
524 
525  /* set up hsync active edge delay width (in pixel clks) */
528 
529  /* set up vsync active edge delay (in lines) */
531 
532  /* set up hsync active pulse width (in pixel clks) */
535 
536  /* set up vsync active edge delay (in lines) */
538 }
539 
540 /* hdmi initialization step b.4 */
541 static void hdmi_enable_video_path(void)
542 {
543  u8 clkdis;
544 
545  /* control period minimum duration */
549 
550  /* set to fill tmds data channels */
551  write32(&hdmi_regs->fc_ch0pream, 0x0b);
552  write32(&hdmi_regs->fc_ch1pream, 0x16);
553  write32(&hdmi_regs->fc_ch2pream, 0x21);
554 
555  /* enable pixel clock and tmds data path */
556  clkdis = 0x7f;
558  write32(&hdmi_regs->mc_clkdis, clkdis);
559 
561  write32(&hdmi_regs->mc_clkdis, clkdis);
562 
564  write32(&hdmi_regs->mc_clkdis, clkdis);
565 }
566 
567 /* workaround to clear the overflow condition */
568 static void hdmi_clear_overflow(void)
569 {
570  u8 val, count;
571 
572  /* tmds software reset */
574 
576 
577  for (count = 0; count < 4; count++)
579 }
580 
581 static void hdmi_audio_set_format(void)
582 {
585 
589 
590  write32(&hdmi_regs->aud_conf2, 0x00);
591 }
592 
593 static void hdmi_audio_fifo_reset(void)
594 {
597 
598  write32(&hdmi_regs->aud_int, 0x00);
599  write32(&hdmi_regs->aud_int1, 0x00);
600 }
601 
602 static int hdmi_setup(const struct edid *edid)
603 {
604  int ret;
605 
606  hdmi_debug("hdmi, mode info : clock %d hdis %d vdis %d\n",
608 
610 
612  if (ret)
613  return ret;
614 
616 
620 
622  hdmi_video_csc();
624 
626 
627  return 0;
628 }
629 
630 static void hdmi_init_interrupt(void)
631 {
632  u8 ih_mute;
633 
634  /*
635  * boot up defaults are:
636  * hdmi_ih_mute = 0x03 (disabled)
637  * hdmi_ih_mute_* = 0x00 (enabled)
638  *
639  * disable top level interrupt bits in hdmi block
640  */
641  ih_mute = read32(&hdmi_regs->ih_mute) |
644 
645  write32(&hdmi_regs->ih_mute, ih_mute);
646 
647  /* enable i2c master done irq */
648  write32(&hdmi_regs->i2cm_int, ~0x04);
649 
650  /* enable i2c client nack % arbitration error irq */
651  write32(&hdmi_regs->i2cm_ctlint, ~0x44);
652 
653  /* enable phy i2cm done irq */
655 
656  /* enable phy i2cm nack & arbitration error irq */
660 
661  /* enable cable hot plug irq */
663 
664  /* clear hotplug interrupts */
666 }
667 
669 {
671 
672  return !!(val);
673 }
674 
675 static int hdmi_wait_for_hpd(void)
676 {
677  struct stopwatch hpd;
678 
679  stopwatch_init_msecs_expire(&hpd, 30000);
680  do {
682  return 0;
683  udelay(100);
684  } while (!stopwatch_expired(&hpd));
685 
686  return -1;
687 }
688 
689 static int hdmi_ddc_wait_i2c_done(int msec)
690 {
691  struct stopwatch ddci2c_done;
692  u32 val;
693 
694  stopwatch_init_msecs_expire(&ddci2c_done, msec);
695  do {
697  if (val & 0x2) {
699  return 0;
700  }
701 
702  udelay(100);
703  } while (!stopwatch_expired(&ddci2c_done));
704 
705  return 1;
706 }
707 
708 static void hdmi_ddc_reset(void)
709 {
712 }
713 
714 static int hdmi_read_edid(int block, u8 *buff)
715 {
716  int shift = (block % 2) * 0x80;
717  int edid_read_err = 0;
718  u32 trytime = 5;
719  u32 n, j, val;
720 
721  /* set ddc i2c clk which derived from ddc_clk to 100kHz */
726 
729  write32(&hdmi_regs->i2cm_segptr, block >> 1);
730 
731  while (trytime--) {
732  edid_read_err = 0;
733 
734  for (n = 0; n < HDMI_EDID_BLOCK_SIZE/8; n++) {
735  write32(&hdmi_regs->i2cmess, shift + 8 * n);
736 
737  if (block == 0)
741  else
745 
746  if (hdmi_ddc_wait_i2c_done(10)) {
747  hdmi_ddc_reset();
748  edid_read_err = 1;
749  break;
750  }
751 
752  for (j = 0; j < 8; j++) {
753  val = read32(&hdmi_regs->i2cm_buf0 + j);
754  buff[8 * n + j] = val;
755  }
756  }
757 
758  if (!edid_read_err)
759  break;
760  }
761 
762  return edid_read_err;
763 }
764 
766 {
767  u8 edid_buf[HDMI_EDID_BLOCK_SIZE * 2];
768  u32 edid_size = HDMI_EDID_BLOCK_SIZE;
769  gpio_t hdmi_i2c_sda = GPIO(7, C, 3);
770  gpio_t hdmi_i2c_scl = GPIO(7, C, 4);
771  int ret;
772 
773  /* If SDA is low, try to clock once to fix it */
774  gpio_input_pullup(hdmi_i2c_sda);
775  if (gpio_get(hdmi_i2c_sda) == 0) {
776  gpio_output(hdmi_i2c_scl, 0);
777  udelay(1000);
778  gpio_input_pullup(hdmi_i2c_scl);
779  udelay(1000);
780  }
781 
782  /* HDMI I2C */
785 
786  ret = hdmi_read_edid(0, edid_buf);
787  if (ret) {
788  hdmi_debug("failed to read edid.\n");
789  return -1;
790  }
791 
792  if (edid_buf[0x7e] != 0) {
793  hdmi_read_edid(1, edid_buf + HDMI_EDID_BLOCK_SIZE);
794  edid_size += HDMI_EDID_BLOCK_SIZE;
795  }
796 
797  /* Assume usage of HDMI implies an external display in which case
798  * we should be lenient about errors that the EDID decoder finds. */
799  if (decode_edid(edid_buf, edid_size, edid) != EDID_CONFORMANT)
800  hdmi_debug("failed to decode edid.\n");
801 
802  /* Try 480p for best compatibility. */
804  hdmi_debug("failed to set mode to 640x480@60Hz\n");
805 
806  return 0;
807 }
808 
809 int rk_hdmi_enable(const struct edid *edid)
810 {
811  hdmi_setup(edid);
812 
813  return 0;
814 }
815 
816 int rk_hdmi_init(u32 vop_id)
817 {
818  int ret;
819  u32 val;
820 
821  /* hdmi source select hdmi controller */
822  write32(&rk3288_grf->soc_con6, RK_SETBITS(1 << 15));
823 
824  /* hdmi data from vop id */
825  val = (vop_id == 1) ? RK_SETBITS(1 << 4) : RK_CLRBITS(1 << 4);
827 
828  ret = hdmi_wait_for_hpd();
829  if (ret < 0) {
830  hdmi_debug("hdmi can not get hpd signal\n");
831  return -1;
832  }
833 
835 
836  hdmi_debug("hdmi init success\n");
837 
838  return 0;
839 }
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
static uint32_t read32(const void *addr)
Definition: mmio.h:22
#define ARRAY_SIZE(a)
Definition: helpers.h:12
static u32 addr
Definition: cirrus.c:14
@ GPIO
Definition: chip.h:84
color_depth
Definition: edp.h:577
#define clrsetbits32(addr, clear, set)
Definition: mmio.h:16
@ EDID_CONFORMANT
Definition: edid.h:90
int set_display_mode(struct edid *edid, enum edid_modes mode)
Definition: edid.c:1081
@ EDID_MODE_640x480_60Hz
Definition: edid.h:11
int decode_edid(unsigned char *edid, int size, struct edid *out)
Definition: edid.c:1104
int gpio_get(gpio_t gpio)
Definition: gpio.c:166
void gpio_output(gpio_t gpio, int value)
Definition: gpio.c:194
void gpio_input_pullup(gpio_t gpio)
Definition: gpio.c:184
static int stopwatch_expired(struct stopwatch *sw)
Definition: timer.h:152
static void stopwatch_init_msecs_expire(struct stopwatch *sw, long ms)
Definition: timer.h:133
static struct rk3288_grf_regs *const rk3288_grf
Definition: grf.h:181
#define IOMUX_HDMI_EDP_I2C_SDA
Definition: grf.h:207
#define IOMUX_HDMI_EDP_I2C_SCL
Definition: grf.h:208
#define RK_CLRBITS(clr)
Definition: soc.h:10
#define RK_SETBITS(set)
Definition: soc.h:9
static const struct hdmi_mpll_config rockchip_mpll_cfg[]
Definition: hdmi.c:102
static void hdmi_phy_enable_spare(u8 enable)
Definition: hdmi.c:349
static void hdmi_phy_sel_interface_control(u8 enable)
Definition: hdmi.c:375
static u8 hdmi_get_plug_in_status(void)
Definition: hdmi.c:668
static void hdmi_video_csc(void)
Definition: hdmi.c:241
static const u32 csc_coeff_default[3][4]
Definition: hdmi.c:127
static void hdmi_phy_gen2_pddq(u8 enable)
Definition: hdmi.c:355
static void hdmi_phy_gen2_txpwron(u8 enable)
Definition: hdmi.c:361
struct rk3288_hdmi_regs *const hdmi_regs
Definition: hdmi.c:25
static void hdmi_init_interrupt(void)
Definition: hdmi.c:630
int rk_hdmi_get_edid(struct edid *edid)
Definition: hdmi.c:765
static void hdmi_update_csc_coeffs(void)
Definition: hdmi.c:223
static void hdmi_video_sample(void)
Definition: hdmi.c:199
static int hdmi_ddc_wait_i2c_done(int msec)
Definition: hdmi.c:689
static int hdmi_phy_configure(u32 mpixelclock)
Definition: hdmi.c:381
static int hdmi_setup(const struct edid *edid)
Definition: hdmi.c:602
static int hdmi_phy_init(u32 mpixelclock)
Definition: hdmi.c:458
static void hdmi_ddc_reset(void)
Definition: hdmi.c:708
static void hdmi_audio_set_format(void)
Definition: hdmi.c:581
static void hdmi_phy_enable_power(u8 enable)
Definition: hdmi.c:337
static void hdmi_audio_set_samplerate(u32 pixel_clk)
Definition: hdmi.c:176
static void hdmi_phy_sel_data_en_pol(u8 enable)
Definition: hdmi.c:368
static void hdmi_enable_video_path(void)
Definition: hdmi.c:541
static void hdmi_audio_fifo_reset(void)
Definition: hdmi.c:593
static int hdmi_phy_wait_i2c_done(u32 msec)
Definition: hdmi.c:306
static void hdmi_video_packetize(void)
Definition: hdmi.c:254
int rk_hdmi_enable(const struct edid *edid)
Definition: hdmi.c:809
#define hdmi_debug(x...)
Definition: hdmi.c:23
int rk_hdmi_init(u32 vop_id)
Definition: hdmi.c:816
static int hdmi_wait_for_hpd(void)
Definition: hdmi.c:675
static int hdmi_read_edid(int block, u8 *buff)
Definition: hdmi.c:714
static void hdmi_phy_i2c_write(u16 data, u8 addr)
Definition: hdmi.c:325
static void hdmi_av_composer(const struct edid *edid)
Definition: hdmi.c:480
static void hdmi_phy_test_clear(u8 bit)
Definition: hdmi.c:300
static void hdmi_set_clock_regenerator(u32 n, u32 cts)
Definition: hdmi.c:133
static const struct tmds_n_cts n_cts_table[]
Definition: hdmi.c:33
static int hdmi_lookup_n_cts(u32 pixel_clk)
Definition: hdmi.c:162
static void hdmi_phy_enable_tmds(u8 enable)
Definition: hdmi.c:343
static void hdmi_clear_overflow(void)
Definition: hdmi.c:568
static const struct hdmi_phy_config rockchip_phy_config[]
Definition: hdmi.c:86
#define HDMI_EDID_BLOCK_SIZE
Definition: hdmi.h:8
@ HDMI_VP_CONF_YCC422_EN_MASK
Definition: hdmi.h:233
@ HDMI_PHY_CONF0_ENTMDS_OFFSET
Definition: hdmi.h:335
@ HDMI_TX_INSTUFFING_BDBDATA_STUFFING_ENABLE
Definition: hdmi.h:206
@ HDMI_PHY_CONF0_GEN2_TXPWRON_OFFSET
Definition: hdmi.h:341
@ HDMI_MC_HEACPHY_RST_ASSERT
Definition: hdmi.h:417
@ HDMI_VP_CONF_YCC422_EN_DISABLE
Definition: hdmi.h:234
@ HDMI_FC_INVIDCONF_DE_IN_POLARITY_ACTIVE_HIGH
Definition: hdmi.h:254
@ HDMI_TX_INSTUFFING_GYDATA_STUFFING_ENABLE
Definition: hdmi.h:208
@ HDMI_VP_STUFF_PP_STUFFING_STUFFING_MODE
Definition: hdmi.h:222
@ HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_LOW
Definition: hdmi.h:252
@ PHY_PLLCURRCTRL
Definition: hdmi.h:187
@ HDMI_MC_PHYRSTZ_ASSERT
Definition: hdmi.h:413
@ HDMI_AUD_CTS3_CTS_MANUAL
Definition: hdmi.h:393
@ HDMI_IH_MUTE_MUTE_ALL_INTERRUPT
Definition: hdmi.h:198
@ HDMI_VP_CONF_BYPASS_EN_MASK
Definition: hdmi.h:227
@ HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE
Definition: hdmi.h:224
@ HDMI_VP_STUFF_IDEFAULT_PHASE_MASK
Definition: hdmi.h:217
@ HDMI_MC_SWRSTZ_TMDSSWRST_REQ
Definition: hdmi.h:406
@ HDMI_MC_SWRSTZ_II2SSWRST_REQ
Definition: hdmi.h:405
@ HDMI_IH_PHY_STAT0_HPD
Definition: hdmi.h:194
@ HDMI_VP_CONF_PR_EN_MASK
Definition: hdmi.h:231
@ HDMI_VP_CONF_BYPASS_SELECT_MASK
Definition: hdmi.h:235
@ HDMI_PHY_CONF0_PDZ_MASK
Definition: hdmi.h:332
@ HDMI_TX_INVID0_VIDEO_MAPPING_MASK
Definition: hdmi.h:202
@ HDMI_PHY_I2CM_OPERATION_ADDR_WRITE
Definition: hdmi.h:359
@ PHY_PLLPHBYCTRL
Definition: hdmi.h:188
@ HDMI_FC_INVIDCONF_DE_IN_POLARITY_ACTIVE_LOW
Definition: hdmi.h:255
@ HDMI_CSC_SCALE_CSC_COLORDE_PTH_MASK
Definition: hdmi.h:423
@ HDMI_PHY_CONF0_ENTMDS_MASK
Definition: hdmi.h:334
@ HDMI_VP_PR_CD_COLOR_DEPTH_OFFSET
Definition: hdmi.h:212
@ HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_LOW
Definition: hdmi.h:249
@ HDMI_CSC_CFG_INTMODE_DISABLE
Definition: hdmi.h:420
@ HDMI_PHY_CONF0_PDZ_OFFSET
Definition: hdmi.h:333
@ HDMI_PHY_CONF0_SELDIPIF_MASK
Definition: hdmi.h:344
@ HDMI_MC_CLKDIS_AUDCLK_DISABLE
Definition: hdmi.h:400
@ PHY_TXTERM
Definition: hdmi.h:191
@ HDMI_VP_STUFF_YCC422_STUFFING_MASK
Definition: hdmi.h:219
@ HDMI_AUD_N3_NCTS_ATOMIC_WRITE
Definition: hdmi.h:381
@ HDMI_PHY_CONF0_SPARECTRL_MASK
Definition: hdmi.h:336
@ PHY_PLLGMPCTRL
Definition: hdmi.h:189
@ HDMI_PHY_I2CM_CTLINT_ADDR_NAC_POL
Definition: hdmi.h:365
@ HDMI_AUD_CONF0_SW_AUDIO_FIFO_RST
Definition: hdmi.h:369
@ HDMI_PHY_CONF0_GEN2_PDDQ_MASK
Definition: hdmi.h:338
@ HDMI_VP_STUFF_YCC422_STUFFING_STUFFING_MODE
Definition: hdmi.h:220
@ HDMI_AUD_N3_AUDN19_16_MASK
Definition: hdmi.h:382
@ PHY_VLEVCTRL
Definition: hdmi.h:186
@ HDMI_FC_INVIDCONF_DVI_MODEZ_HDMI_MODE
Definition: hdmi.h:257
@ HDMI_FC_INVIDCONF_IN_I_P_PROGRESSIVE
Definition: hdmi.h:264
@ HDMI_PHY_TST0_TSTCLR_OFFSET
Definition: hdmi.h:349
@ HDMI_VP_CONF_PR_EN_DISABLE
Definition: hdmi.h:232
@ HDMI_AUD_CONF0_I2S_IN_EN_0
Definition: hdmi.h:371
@ HDMI_AUD_CONF1_I2S_WIDTH_16BIT
Definition: hdmi.h:378
@ HDMI_PHY_I2CM_CTLINT_ADDR_ARBITRATION_POL
Definition: hdmi.h:366
@ HDMI_VP_CONF_BYPASS_SELECT_VID_PACKETIZER
Definition: hdmi.h:236
@ HDMI_I2CM_SLAVE_DDC_ADDR
Definition: hdmi.h:431
@ HDMI_PHY_CONF0_SPARECTRL_OFFSET
Definition: hdmi.h:337
@ HDMI_PHY_CONF0_SELDIPIF_OFFSET
Definition: hdmi.h:345
@ HDMI_AUD_CONF0_I2S_SELECT
Definition: hdmi.h:370
@ HDMI_I2CM_DIV_FAST_STD_MODE
Definition: hdmi.h:435
@ HDMI_MC_PHYRSTZ_DEASSERT
Definition: hdmi.h:414
@ PHY_OPMODE_PLLCFG
Definition: hdmi.h:183
@ HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_BYPASS
Definition: hdmi.h:410
@ HDMI_VP_REMAP_YCC422_16BIT
Definition: hdmi.h:241
@ HDMI_PHY_CONF0_SELDATAENPOL_OFFSET
Definition: hdmi.h:343
@ HDMI_I2CM_SEGADDR_DDC
Definition: hdmi.h:432
@ PHY_CKSYMTXCTRL
Definition: hdmi.h:185
@ HDMI_VP_STUFF_PP_STUFFING_MASK
Definition: hdmi.h:221
@ HDMI_VP_CONF_PP_EN_ENMASK
Definition: hdmi.h:229
@ HDMI_AUD_CTS3_AUDCTS19_16_MASK
Definition: hdmi.h:394
@ HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET
Definition: hdmi.h:339
@ HDMI_PHY_TST0_TSTCLR_MASK
Definition: hdmi.h:348
@ HDMI_AUD_CTS3_N_SHIFT_OFFSET
Definition: hdmi.h:385
@ HDMI_I2CM_OPT_RD8_EXT
Definition: hdmi.h:433
@ HDMI_PHY_HPD
Definition: hdmi.h:352
@ HDMI_CSC_SCALE_CSCSCALE_MASK
Definition: hdmi.h:428
@ HDMI_IH_MUTE_MUTE_WAKEUP_INTERRUPT
Definition: hdmi.h:197
@ HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS
Definition: hdmi.h:238
@ HDMI_AUD_CONF1_I2S_MODE_STANDARD_MODE
Definition: hdmi.h:377
@ PHY_PLLCLKBISTPHASE
Definition: hdmi.h:190
@ HDMI_PHY_CONF0_GEN2_TXPWRON_MASK
Definition: hdmi.h:340
@ HDMI_I2CM_OPT_RD8
Definition: hdmi.h:434
@ HDMI_VP_CONF_OUTPUT_SELECTOR_MASK
Definition: hdmi.h:237
@ HDMI_I2CM_DIV_STD_MODE
Definition: hdmi.h:437
@ HDMI_VP_PR_CD_DESIRED_PR_FACTOR_OFFSET
Definition: hdmi.h:214
@ HDMI_VP_CONF_BYPASS_EN_ENABLE
Definition: hdmi.h:228
@ HDMI_MC_CLKDIS_PIXELCLK_DISABLE
Definition: hdmi.h:402
@ HDMI_FC_INVIDCONF_R_V_BLANK_IN_OSC_ACTIVE_LOW
Definition: hdmi.h:261
@ HDMI_FC_INVIDCONF_VSYNC_IN_POLARITY_ACTIVE_HIGH
Definition: hdmi.h:248
@ PHY_CKCALCTRL
Definition: hdmi.h:184
@ HDMI_VP_PR_CD_DESIRED_PR_FACTOR_MASK
Definition: hdmi.h:213
@ HDMI_PHY_I2CM_SLAVE_ADDR_PHY_GEN2
Definition: hdmi.h:356
@ HDMI_FC_INVIDCONF_HDCP_KEEPOUT_INACTIVE
Definition: hdmi.h:246
@ HDMI_PHY_TX_PHY_LOCK
Definition: hdmi.h:353
@ HDMI_VP_STUFF_PR_STUFFING_MASK
Definition: hdmi.h:223
@ HDMI_VP_CONF_PP_EN_DISABLE
Definition: hdmi.h:230
@ HDMI_VP_PR_CD_COLOR_DEPTH_MASK
Definition: hdmi.h:211
@ HDMI_FC_INVIDCONF_DVI_MODEZ_DVI_MODE
Definition: hdmi.h:258
@ HDMI_TX_INVID0_VIDEO_MAPPING_OFFSET
Definition: hdmi.h:203
@ HDMI_PHY_CONF0_SELDATAENPOL_MASK
Definition: hdmi.h:342
@ HDMI_I2CM_SOFTRSTZ
Definition: hdmi.h:438
@ HDMI_VP_STUFF_IDEFAULT_PHASE_OFFSET
Definition: hdmi.h:218
@ HDMI_TX_INSTUFFING_RCRDATA_STUFFING_ENABLE
Definition: hdmi.h:207
@ HDMI_CSC_SCALE_CSC_COLORDE_PTH_24BPP
Definition: hdmi.h:424
@ HDMI_FC_INVIDCONF_HSYNC_IN_POLARITY_ACTIVE_HIGH
Definition: hdmi.h:251
@ HDMI_MC_CLKDIS_TMDSCLK_DISABLE
Definition: hdmi.h:401
@ HDMI_AUD_CTS3_N_SHIFT_1
Definition: hdmi.h:387
@ HDMI_AUD_INPUTCLKFS_128
Definition: hdmi.h:397
@ HDMI_TX_INVID0_INTERNAL_DE_GENERATOR_DISABLE
Definition: hdmi.h:201
@ HDMI_PHY_I2CM_INT_ADDR_DONE_POL
Definition: hdmi.h:362
#define HDMI_TX_BASE
Definition: addressmap.h:72
uint64_t u64
Definition: stdint.h:54
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
unsigned int hbl
Definition: edid.h:26
unsigned int va
Definition: edid.h:30
unsigned int vspw
Definition: edid.h:33
unsigned char phsync
Definition: edid.h:35
unsigned int ha
Definition: edid.h:25
unsigned int vso
Definition: edid.h:32
unsigned int hso
Definition: edid.h:27
unsigned char pvsync
Definition: edid.h:36
unsigned int pixel_clock
Definition: edid.h:22
unsigned int hspw
Definition: edid.h:28
unsigned int vbl
Definition: edid.h:31
Definition: edid.h:49
int hdmi_monitor_detected
Definition: edid.h:84
struct edid_mode mode
Definition: edid.h:72
u64 mpixelclock
Definition: hdmi.c:70
u64 mpixelclock
Definition: hdmi.c:80
u32 vlev_ctr
Definition: hdmi.c:83
u32 term
Definition: hdmi.c:82
u32 sym_ctr
Definition: hdmi.c:81
u32 soc_con6
Definition: grf.h:110
u32 iomux_i2c5scl
Definition: grf.h:87
u32 iomux_i2c5sda
Definition: grf.h:81
u32 fc_exctrlspac
Definition: hdmi.h:73
u32 aud_int1
Definition: hdmi.h:131
u32 aud_inputclkfs
Definition: hdmi.h:139
u32 i2cm_ss_scl_lcnt_0_addr
Definition: hdmi.h:171
u32 fc_invidconf
Definition: hdmi.h:54
u32 fc_hsyncindelay1
Definition: hdmi.h:63
u32 tx_rcrdata1
Definition: hdmi.h:40
u32 mc_flowctrl
Definition: hdmi.h:145
u32 ih_mute
Definition: hdmi.h:34
u32 vp_stuff
Definition: hdmi.h:46
u32 i2cm_slave
Definition: hdmi.h:157
u32 fc_ctrldur
Definition: hdmi.h:71
u32 fc_invactv1
Definition: hdmi.h:60
u32 tx_rcrdata0
Definition: hdmi.h:39
u32 tx_bcbdata0
Definition: hdmi.h:41
u32 fc_invblank
Definition: hdmi.h:61
u32 i2cm_segaddr
Definition: hdmi.h:165
u32 phy_i2cm_operation_addr
Definition: hdmi.h:113
u32 aud_conf0
Definition: hdmi.h:127
u32 phy_mask0
Definition: hdmi.h:104
u32 aud_cts2
Definition: hdmi.h:137
u32 tx_gydata1
Definition: hdmi.h:38
u32 fc_ch1pream
Definition: hdmi.h:75
u32 fc_ch0pream
Definition: hdmi.h:74
u32 aud_cts3
Definition: hdmi.h:138
u32 fc_hsyncinwidth1
Definition: hdmi.h:65
u32 phy_i2cm_datao_1_addr
Definition: hdmi.h:109
u32 fc_hsyncinwidth0
Definition: hdmi.h:64
u32 phy_conf0
Definition: hdmi.h:98
u32 fc_inhactv0
Definition: hdmi.h:55
u32 i2cm_softrstz
Definition: hdmi.h:166
u32 fc_inhblank0
Definition: hdmi.h:57
u32 phy_stat0
Definition: hdmi.h:102
u32 ih_i2cmphy_stat0
Definition: hdmi.h:20
u32 aud_conf2
Definition: hdmi.h:130
u32 mc_phyrstz
Definition: hdmi.h:146
u32 phy_i2cm_datao_0_addr
Definition: hdmi.h:110
u32 phy_i2cm_slave_addr
Definition: hdmi.h:107
u32 aud_cts1
Definition: hdmi.h:136
u32 ih_i2cm_stat0
Definition: hdmi.h:17
u32 phy_i2cm_ctlint_addr
Definition: hdmi.h:115
u32 i2cm_div
Definition: hdmi.h:164
u32 i2cm_ss_scl_hcnt_0_addr
Definition: hdmi.h:169
u32 mc_swrstz
Definition: hdmi.h:143
u32 ih_phy_stat0
Definition: hdmi.h:16
u32 i2cm_buf0
Definition: hdmi.h:177
u32 tx_invid0
Definition: hdmi.h:35
u32 fc_vsyncinwidth
Definition: hdmi.h:67
u32 fc_hsyncindelay0
Definition: hdmi.h:62
u32 vp_pr_cd
Definition: hdmi.h:45
u32 tx_gydata0
Definition: hdmi.h:37
u32 fc_inhblank1
Definition: hdmi.h:58
u32 i2cm_operation
Definition: hdmi.h:161
u32 tx_bcbdata1
Definition: hdmi.h:42
u32 fc_invactv0
Definition: hdmi.h:59
u32 fc_ch2pream
Definition: hdmi.h:76
u32 phy_i2cm_int_addr
Definition: hdmi.h:114
u32 aud_conf1
Definition: hdmi.h:128
u32 vp_remap
Definition: hdmi.h:47
u32 mc_heacphy_rst
Definition: hdmi.h:148
u32 phy_i2cm_address_addr
Definition: hdmi.h:108
u32 tx_instuffing
Definition: hdmi.h:36
u32 i2cm_segptr
Definition: hdmi.h:167
u32 fc_exctrldur
Definition: hdmi.h:72
u32 i2cm_int
Definition: hdmi.h:162
u32 vp_conf
Definition: hdmi.h:48
u32 fc_vsyncindelay
Definition: hdmi.h:66
u32 fc_inhactv1
Definition: hdmi.h:56
struct rk3288_hdmi_regs::@1481 csc_coef[3][4]
u32 mc_clkdis
Definition: hdmi.h:142
u32 csc_scale
Definition: hdmi.h:151
u32 i2cm_ctlint
Definition: hdmi.h:163
u32 phy_tst0
Definition: hdmi.h:99
u32 n
Definition: hdmi.c:30
u32 tmds
Definition: hdmi.c:28
u32 cts
Definition: hdmi.c:29
u8 val
Definition: sys.c:300
void udelay(uint32_t us)
Definition: udelay.c:15
#define count