int ignore_sscp_tmds = 1;
int find_best_eq;
int eq_try_cnt = 20;
+int pll_rst_max = 10;
/*------------------------variable define end------------------------------*/
static int check_regmap_flag(unsigned int addr)
}
EXPORT_SYMBOL(rx_set_audio_param);
+bool is_tl1_former(void)
+{
+ if (is_meson_tl1_cpu() &&
+ is_meson_rev_a())
+ return 1;
+ return 0;
+}
/*
* rx_get_hdmi5v_sts - get current pwr5v status on all ports
*/
static const uint32_t phy_misci[][4] = {
/* 0xd7 0xd8 0xe0 0xe1 */
{ /* 24~45M */
- 0x3003707f, 0x00400080, 0x02218000, 0x00000010,
+ 0x3003707f, 0x00000080, 0x02218000, 0x00000010,
},
{ /* 45~74.5M */
- 0x3003707f, 0x00400080, 0x02218000, 0x00000010,
+ 0x3003707f, 0x00000080, 0x02218000, 0x00000010,
},
{ /* 77~155M */
0x3003707f, 0x00000080, 0x02218000, 0x00000010,
static const uint32_t phy_dcha[][3] = {
/* 0xe2 0xe3 0xe4 */
{ /* 24~45M */
- 0x00000180, 0x2400c202, 0x030088a2,
+ 0x00000280, 0x4400c202, 0x030088a2,
},
{ /* 45~74.5M */
- 0x00000180, 0x2400c202, 0x030088a2,
+ 0x00000280, 0x4400c202, 0x030088a2,
},
{ /* 77~155M */
- 0x000002a2, 0x4800c202, 0x01009126,
+ 0x000002a2, 0x6800c202, 0x01009126,
},
{ /* 155~340M */
0x000002a2, 0x0800c202, 0x0100cc31,
},
};
-/* short cable */
-static const uint32_t phy_dchd_1[][3] = {
- /* 0xe5 0xe6 0xe7 */
+static const uint32_t phy_dcha_reva[][3] = {
+ /* 0xe2 0xe3 0xe4 */
{ /* 24~45M */
- 0x002e712a, 0x1e022220, 0x00018000,
+ 0x00000280, 0x2400c202, 0x030088a2,
},
{ /* 45~74.5M */
- 0x002e714a, 0x1e022220, 0x00018000,
+ 0x00000280, 0x2400c202, 0x030088a2,
},
{ /* 77~155M */
- 0x002c715a, 0x1e022220, 0x00018000,
+ 0x000002a2, 0x4800c202, 0x01009126,
},
{ /* 155~340M */
- 0x002c715a, 0x1e022220, 0x00018000,
+ 0x000002a2, 0x0800c202, 0x0100cc31,
},
{ /* 340~525M */
- 0x002c715a, 0x1e012330, 0x0001a000,
+ 0x000002a2, 0x0700003c, 0x1d00cc31,
},
{ /* 525~600M */
- 0x002c715a, 0x1e022220, 0x00018000,
+ 0x000002a2, 0x0700003c, 0x1d00cc31,
},
};
+
/* long cable */
-static const uint32_t phy_dchd_2[][3] = {
+static const uint32_t phy_dchd_1[][3] = {
/* 0xe5 0xe6 0xe7 */
{ /* 24~45M */
- 0x002e712a, 0x1e062620, 0x00018000,
+ 0x002e714a, 0x1e051630, 0x00018000,
},
{ /* 45~74.5M */
- 0x002e714a, 0x1e062620, 0x00018000,
+ 0x002e714a, 0x1e051630, 0x00018000,
},
{ /* 77~155M */
0x002c714a, 0x1e062620, 0x00018000,
};
/* short cable */
-static const uint32_t phy_dchd_3[][3] = {
+static const uint32_t phy_dchd_2[][3] = {
/* 0xe5 0xe6 0xe7 */
{ /* 24~45M */
- 0x002e712a, 0x1e022220, 0x00018000,
+ 0x002e714a, 0x1e022220, 0x00018000,
},
{ /* 45~74.5M */
0x002e714a, 0x1e022220, 0x00018000,
0x002c714a, 0x1e022220, 0x00018000,
},
{ /* 340~525M */
- 0x002c714a, 0x1e012330, 0x0001a000,
+ 0x002c714a, 0x1e022220, 0x0001a000,
},
{ /* 525~600M */
0x002c714a, 0x1e022220, 0x00018000,
},
};
+
/* long cable */
-static const uint32_t phy_dchd_4[][3] = {
+static const uint32_t phy_dchd_3[][3] = {
/* 0xe5 0xe6 0xe7 */
{ /* 24~45M */
0x002e712a, 0x1e062620, 0x00018000,
},
};
+/* short cable */
+static const uint32_t phy_dchd_4[][3] = {
+ /* 0xe5 0xe6 0xe7 */
+ { /* 24~45M */
+ 0x002e712a, 0x1e022220, 0x00018000,
+ },
+ { /* 45~74.5M */
+ 0x002e714a, 0x1e022220, 0x00018000,
+ },
+ { /* 77~155M */
+ 0x002c715a, 0x1e022220, 0x00018000,
+ },
+ { /* 155~340M */
+ 0x002c715a, 0x1e022220, 0x00018000,
+ },
+ { /* 340~525M */
+ 0x002c715a, 0x1e012330, 0x0001a000,
+ },
+ { /* 525~600M */
+ 0x002c715a, 0x1e022220, 0x00018000,
+ },
+};
+
+void aml_phy_init_1(void)
+{
+ uint32_t idx = rx.phy.phy_bw;
+ uint32_t data32;
+
+ data32 = phy_misci[idx][1];
+ wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL1, data32);
+
+ wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL2,
+ phy_misci[idx][2]);
+
+ /* reset and select data port */
+ data32 = phy_misci[idx][3];
+ data32 |= ((1 << rx.port) << 6);
+ wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL3, data32);
+
+ /* release reset */
+ data32 |= (1 << 11);
+ wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL3, data32);
+
+ udelay(5);
+ if (is_tl1_former()) {
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL0,
+ phy_dcha_reva[idx][0]);
+
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL1,
+ phy_dcha_reva[idx][1]);
+
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL2,
+ phy_dcha_reva[idx][2]);
+ } else {
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL0,
+ phy_dcha[idx][0]);
+
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL1,
+ phy_dcha[idx][1]);
+
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL2,
+ phy_dcha[idx][2]);
+ }
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHD_CNTL0,
+ phy_dchd_1[idx][0]);
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHD_CNTL2,
+ phy_dchd_1[idx][2]);
+ if ((rx.phy.cablesel % 2) == 0)
+ data32 = phy_dchd_1[idx][1];
+ else if ((rx.phy.cablesel % 2) == 1)
+ data32 = phy_dchd_2[idx][1];
+
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHD_CNTL1, data32);/*398*/
+ udelay(5);
+ data32 |= 0x00400000;
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHD_CNTL1, data32);/*398*/
+ data32 = rd_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0);
+ data32 &= ~(0xf << 7);
+ wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0, data32);
+ udelay(5);
+ /* data channel release reset */
+ data32 |= (0xf << 7);
+ wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0, data32);
+}
+
void aml_phy_init(void)
{
uint32_t idx = rx.phy.phy_bw;
udelay(2);
/* data channel and common block reset */
data32 |= 0xf << 7;
+ udelay(5);
wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0, data32);
udelay(2);
wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL3, data32);
udelay(5);
- wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL0, phy_dcha[idx][0]);
+ if (is_tl1_former()) {
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL0,
+ phy_dcha_reva[idx][0]);
+
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL1,
+ phy_dcha_reva[idx][1]);
+
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL2,
+ phy_dcha_reva[idx][2]);
+ } else {
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL0,
+ phy_dcha[idx][0]);
- wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL1, phy_dcha[idx][1]);
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL1,
+ phy_dcha[idx][1]);
- wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL2, phy_dcha[idx][2]);
+ wr_reg_hhi(HHI_HDMIRX_PHY_DCHA_CNTL2,
+ phy_dcha[idx][2]);
+ }
wr_reg_hhi(HHI_HDMIRX_PHY_DCHD_CNTL0, phy_dchd_1[idx][0]);
wr_reg_hhi(HHI_HDMIRX_PHY_DCHD_CNTL2, phy_dchd_1[idx][2]);
- data32 = phy_dchd_1[idx][1];
+ if ((rx.phy.cablesel % 2) == 0)
+ data32 = phy_dchd_1[idx][1];
+ else if ((rx.phy.cablesel % 2) == 1)
+ data32 = phy_dchd_2[idx][1];
wr_reg_hhi(HHI_HDMIRX_PHY_DCHD_CNTL1, data32);/*398*/
udelay(5);
wr_reg_hhi(HHI_HDMIRX_PHY_DCHD_CNTL1, data32);
- udelay(2);
+ udelay(5);
data32 |= 0x00400000;
wr_reg_hhi(HHI_HDMIRX_PHY_DCHD_CNTL1, data32);
}
}
}
+bool is_tmds_clk_stable(void)
+{
+ bool ret = true;
+ uint32_t cableclk;
+ uint32_t pixel_clk;
+
+ if (rx.phy.clk_rate)
+ cableclk = rx.phy.cable_clk * 4;
+ else
+ cableclk = rx.phy.cable_clk;
+
+ pixel_clk = meson_clk_measure(29);
+ if (abs(cableclk - pixel_clk) > 5 * MHz) {
+ if (log_level & VIDEO_LOG)
+ rx_pr("cableclk=%d,tmdsclk=%d,pixelclk=%d\n",
+ cableclk/MHz, rx.phy.tmds_clk/MHz,
+ meson_clk_measure(29)/MHz);
+ ret = false;
+ } else
+ ret = true;
+
+ return ret;
+}
+
/*
* for tl1 phy function
*/
/*od for tmds: 2/4/8/16/32*/
/*od2 for audio: 1/2/4/8/16*/
/* bw M, N, od, od_div, od2, od2_div */
- {pll_frq_band_0, 160, 1, 0x5, 32, 0x3, 8},/*tmdsx4*/
- {pll_frq_band_1, 80, 1, 0x4, 16, 0x3, 8},/*tmdsx2*/
- {pll_frq_band_2, 40, 1, 0x3, 8, 0x3, 8},/*tmds*/
- {pll_frq_band_3, 40, 2, 0x2, 4, 0x2, 4},/*tmds*/
- {pll_frq_band_4, 40, 1, 0x1, 2, 0x1, 2},/*tmds*/
- {pll_frq_null, 40, 1, 0x3, 8, 0x3, 8},
+ {pll_frq_band_0, 160, 1, 0x5, 32, 0x2, 8},/*tmdsx4*/
+ {pll_frq_band_1, 80, 1, 0x4, 16, 0x2, 8},/*tmdsx2*/
+ {pll_frq_band_2, 40, 1, 0x3, 8, 0x2, 8},/*tmds*/
+ {pll_frq_band_3, 40, 2, 0x2, 4, 0x1, 4},/*tmds*/
+ {pll_frq_band_4, 40, 1, 0x1, 2, 0x0, 2},/*tmds*/
+ {pll_frq_null, 40, 1, 0x3, 8, 0x2, 8},
};
void aml_phy_pll_setting(void)
uint32_t data, data2;
uint32_t aud_div;
uint32_t cableclk = rx.phy.cable_clk / KHz;
+ int pll_rst_cnt = 0;
od_div = apll_tab[bw].od_div;
od = apll_tab[bw].od;
/*tmds clk out*/
apll_out = (vco_clk/od_div)/5;
aud_pll_out = ((vco_clk/od2_div)/5);
+ if (is_tl1_former())
+ od2 += 1;
+ do {
+ /*cntl0 M <7:0> N<14:10>*/
+ data = 0x00090400 & 0xffff8300;
+ data |= M;
+ data |= (N << 10);
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL0, data|0x20000000);
+ udelay(5);
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL0, data|0x30000000);
+ udelay(5);
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL1, 0x00000000);
+ udelay(5);
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL2, 0x00001118);
+ udelay(5);
+ data2 = 0x10058f30|od2;
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL3, data2);
+
+ /* verB: bit'27=1 */
+ if (is_tl1_former())
+ data2 = 0x000100c0;
+ else
+ data2 = 0x080100c0;
+ data2 |= (od << 24);
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL4, data2);
+ udelay(5);
+ /*apll_vctrl_mon_en*/
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL4, data2|0x00800000);
+ udelay(5);
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL0, data|0x34000000);
+ udelay(5);
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL0, data|0x14000000);
+ udelay(5);
+ /* bit'5: force lock bit'2: improve ldo voltage:pll 0.8v->0.9 */
+ wr_reg_hhi(HHI_HDMIRX_APLL_CNTL2, 0x0000303c);
+ udelay(5);
+ /* common block release reset */
+ data = rd_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0);
+ data &= ~(0xf << 7);
+ wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0, data);
+ udelay(5);
+ /* data channel release reset */
+ data |= (0xf << 7);
+ wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0, data);
- /*cntl0 M <7:0> N<14:10>*/
- data = 0x00090400 & 0xffff8300;
- data |= M;
- data |= (N << 10);
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL0, data|0x20000000);
- udelay(2);
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL0, data|0x30000000);
- udelay(50);
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL1, 0x00000000);
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL2, 0x00001118);
- data2 = 0x10058f30|od2;
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL3, data2);
-
- data2 = 0x000100c0 /*& 0xf8ffffff*/;
- data2 |= (od << 24);
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL4, data2);
- udelay(2);
- /*apll_vctrl_mon_en*/
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL4, data2|0x00800000);
- udelay(80);
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL0, data|0x34000000);
- udelay(2);
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL0, data|0x14000000);
- udelay(60);
- /* bit'5: force lock bit'2: improve ldo voltage */
- wr_reg_hhi(HHI_HDMIRX_APLL_CNTL2, 0x0000303c);
- /* common block release reset */
- data = rd_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0);
- data &= ~(0x7 << 7);
- wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0, data);
- udelay(2);
- /* data channel release reset */
- data |= (0x7 << 7);
- wr_reg_hhi(HHI_HDMIRX_PHY_MISC_CNTL0, data);
-
+ mdelay(1);
+ if (pll_rst_cnt++ > pll_rst_max) {
+ rx_pr("pll rst error\n");
+ return;
+ }
+ if (log_level & VIDEO_LOG)
+ rx_pr("pll init-cableclk=%d,pixelclk=%d,sq=%d\n",
+ rx.phy.cable_clk/MHz,
+ meson_clk_measure(29)/MHz,
+ hdmirx_rd_top(TOP_MISC_STAT0) & 0x1);
+ } while ((!is_tmds_clk_stable()) && is_clk_stable());
/*set audio pll divider*/
aud_div = aud_pll_out/apll_out;
if (aud_div == 1)
void aml_phy_bw_switch(void)
{
aml_phy_init();
- udelay(1);
+ udelay(10);
aml_phy_pll_setting();
- udelay(1);
- aml_eq_setting();
+ udelay(10);
+ aml_phy_init_1();
}
unsigned int aml_phy_pll_lock(void)
return false;
}
-bool is_tmds_clk_stable(void)
-{
- bool ret = true;
- uint32_t cableclk;
-
- if (rx.phy.clk_rate)
- cableclk = rx.phy.cable_clk * 4;
- else
- cableclk = rx.phy.cable_clk;
-
- if (abs(cableclk - rx.phy.tmds_clk) > 5 * MHz) {
- if (log_level & VIDEO_LOG)
- rx_pr("cableclk=%d,tmdsclk=%d\n",
- cableclk/MHz, rx.phy.tmds_clk/MHz);
- ret = false;
- } else
- ret = true;
-
- return ret;
-}
-
bool is_tmds_valid(void)
{
if (force_vic)
unsigned int aml_phy_tmds_valid(void)
{
unsigned int tmds_valid;
- unsigned int tmdsclk_valid;
+ /* unsigned int tmdsclk_valid; */
unsigned int sqofclk;
/* unsigned int pll_lock; */
unsigned int tmds_align;
tmds_valid = hdmirx_rd_dwc(DWC_HDMI_PLL_LCK_STS) & 0x01;
sqofclk = hdmirx_rd_top(TOP_MISC_STAT0) & 0x1;
/*pll_lock = rd_reg_hhi(HHI_HDMIRX_APLL_CNTL0) & 0x80000000;*/
- tmdsclk_valid = is_tmds_clk_stable();
+ /* tmdsclk_valid = is_tmds_clk_stable(); */
tmds_align = hdmirx_rd_top(TOP_TMDS_ALIGN_STAT) & 0x3f000000;
- if (tmds_valid && sqofclk && tmdsclk_valid &&
+ if (tmds_valid && sqofclk &&
(tmds_align == 0x3f000000))
return true;
else {
if (log_level & VIDEO_LOG) {
- rx_pr("tmds:%x,sqo:%x,tmdsclk_valid:%x,align:%x\n",
- tmds_valid, sqofclk, tmdsclk_valid, tmds_align);
+ rx_pr("tmds:%x,sqo:%x,align:%x\n",
+ tmds_valid, sqofclk, tmds_align);
rx_pr("cable clk0:%d\n",
rx_measure_clock(MEASURE_CLK_CABLE));
rx_pr("cable clk1:%d\n",