make mt7623 clock of hdmi stable
Subsystems (4)
v7 cover make mt7623 clock of hdmi stable
From: Wangyan Wang <[email protected]>
V7 adopt maintainer's suggestion.
Here is the change list between V6 & V7
1. use readl directly & delete hdmi_phy->pll_rate in mtk_hdmi_pll_recalc_rate().
in "drm/mediatek: recalculate hdmi ..."
2. detele mtk_hdmi_phy_read() in mtk_hdmi_phy.c. in "fix the rate of parent for hdmi phy in MT2701"
3. optimize mtk_hdmi_pll_round_rate().
in "fix the rate of parent for hdmi phy in MT2701"
chunhui dai (6):
drm/mediatek: recalculate hdmi phy clock of MT2701 by querying
hardware
drm/mediatek: move the setting of fixed divider drm/mediatek: using different flags of clk for HDMI phy drm/mediatek: fix the rate and divder of hdmi phy for MT2701 drm/mediatek: using new factor for tvdpll in MT2701 drm/mediatek: fix the rate of parent for hdmi phy in MT2701
drivers/gpu/drm/mediatek/mtk_dpi.c | 8 ++--- drivers/gpu/drm/mediatek/mtk_hdmi_phy.c | 35 +++--------------- drivers/gpu/drm/mediatek/mtk_hdmi_phy.h | 6 +--- drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 50 ++++++++++++++++++++++---- drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 23 ++++++++++++ 5 files changed, 76 insertions(+), 46 deletions(-)
Signature · 1 line
2.14.1
PATCH v7 1/6 drm/mediatek: recalculate hdmi phy clock of MT2701 by querying hardware
From: chunhui dai <[email protected]>
Recalculate the rate of this clock, by querying hardware.
--- drivers/gpu/drm/mediatek/mtk_hdmi_phy.c | 7 ++---- drivers/gpu/drm/mediatek/mtk_hdmi_phy.h | 3 +-- drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 33 ++++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 8 +++++++ 4 files changed, 44 insertions(+), 7 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +2 -5
@@ -29,12 +29,9 @@ long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,return rate; } -unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate) +u32 mtk_hdmi_phy_read (struct mtk_hdmi_phy *hdmi_phy,u32 offset) { -struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); - -return hdmi_phy->pll_rate; +return readl (hdmi_phy->regs + offset); } void mtk_hdmi_phy_clear_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,
drivers/gpu/drm/mediatek/mtk_hdmi_phy.h +1 -2
@@ -41,6 +41,7 @@ struct mtk_hdmi_phy {unsigned int ibias_up; }; +u32 mtk_hdmi_phy_read (struct mtk_hdmi_phy *hdmi_phy,u32 offset);void mtk_hdmi_phy_clear_bits (struct mtk_hdmi_phy *hdmi_phy,u32 offset,u32 bits); void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,
@@ -50,8 +51,6 @@ void mtk_hdmi_phy_mask(struct mtk_hdmi_phy *hdmi_phy, u32 offset,struct mtk_hdmi_phy *to_mtk_hdmi_phy (struct clk_hw *hw);long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate,unsigned long *parent_rate); -unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate);extern struct platform_driver mtk_hdmi_phy_driver;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf;
drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +33 -0
@@ -153,6 +153,39 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, RG_HDMITX_DRV_IBIAS_MASK);return 0 ; } +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +unsigned long out_rate, val; + + val = (readl (hdmi_phy->regs +HDMI_CON6 ) + &RG_HTPLL_PREDIV_MASK ) >>RG_HTPLL_PREDIV ; +switch (val) { +case 0x00 : + out_rate = parent_rate; +break ; +case 0x01 : + out_rate = parent_rate /2 ; +break ; +default : + out_rate = parent_rate /4 ; +break ; + } + + val = (readl (hdmi_phy->regs +HDMI_CON6 ) + &RG_HTPLL_FBKDIV_MASK ) >>RG_HTPLL_FBKDIV ; + out_rate *= (val +1 ) *2 ; + val = (readl (hdmi_phy->regs +HDMI_CON2 ) + &RG_HDMITX_TX_POSDIV_MASK ); + + out_rate >>= (val >>RG_HDMITX_TX_POSDIV ); + +if (readl (hdmi_phy->regs +HDMI_CON2 ) &RG_HDMITX_EN_TX_POSDIV ) + out_rate = out_rate /5 ; + +return out_rate; +}static const struct clk_ops mtk_hdmi_phy_pll_ops = { .prepare = mtk_hdmi_pll_prepare,
drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c +8 -0
@@ -285,6 +285,14 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,return 0 ; } +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + +return hdmi_phy->pll_rate; +} +static const struct clk_ops mtk_hdmi_phy_pll_ops = { .prepare = mtk_hdmi_pll_prepare, .unprepare = mtk_hdmi_pll_unprepare,
Signature · 1 line
2.14.1
PATCH v7 2/6 drm/mediatek: move the setting of fixed divider
In reply to wangyan wangFrom: chunhui dai <[email protected]>
move the setting of fixed divider from enable/disable to the function of setting rate.
the patch is for hdmi pll divider, the divder should be configured before clock calculation to ensure the clock is right.
--- drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +1 -4
@@ -79,7 +79,6 @@ static int mtk_hdmi_pll_prepare(struct clk_hw *hw)mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SLDO_MASK );usleep_range (80 ,100 );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_MBIAS_LPF_EN ); -mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SER_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_PRED_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_DRV_MASK );
@@ -94,7 +93,6 @@ static void mtk_hdmi_pll_unprepare(struct clk_hw *hw)mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_DRV_MASK );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_PRED_MASK );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SER_MASK ); -mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_MBIAS_LPF_EN );usleep_range (80 ,100 );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SLDO_MASK );
@@ -123,6 +121,7 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON6 ,RG_HTPLL_PREDIV_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON6 ,RG_HTPLL_POSDIV_MASK ); +mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_mask (hdmi_phy,HDMI_CON6 , (0x1 <<RG_HTPLL_IC ),RG_HTPLL_IC_MASK ); mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IR),
@@ -207,7 +206,6 @@ static void mtk_hdmi_phy_enable_tmds(struct mtk_hdmi_phy *hdmi_phy)mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SLDO_MASK );usleep_range (80 ,100 );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_MBIAS_LPF_EN ); -mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SER_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_PRED_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_DRV_MASK );
@@ -219,7 +217,6 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy)mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_DRV_MASK );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_PRED_MASK );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SER_MASK ); -mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_MBIAS_LPF_EN );usleep_range (80 ,100 );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SLDO_MASK );
Signature · 1 line
2.14.1
PATCH v7 3/6 drm/mediatek: using different flags of clk for HDMI phy
In reply to wangyan wangFrom: chunhui dai <[email protected]>
The parent rate of hdmi phy had set by DPI driver.
We should not set or change the parent rate of MT2701 hdmi phy, as a result we should remove the flags of "CLK_SET_RATE_PARENT" from the clock of MT2701 hdmi phy.
--- drivers/gpu/drm/mediatek/mtk_hdmi_phy.c | 13 +++++-------- drivers/gpu/drm/mediatek/mtk_hdmi_phy.h | 1 + drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 1 + drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 1 + 4 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +5 -8
@@ -107,13 +107,11 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)return NULL ; } -static void mtk_hdmi_phy_clk_get_ops (struct mtk_hdmi_phy *hdmi_phy, -const struct clk_ops **ops) +static void mtk_hdmi_phy_clk_get_data (struct mtk_hdmi_phy *hdmi_phy, +struct clk_init_data *clk_init) { -if (hdmi_phy && hdmi_phy->conf && hdmi_phy->conf->hdmi_phy_clk_ops) - *ops = hdmi_phy->conf->hdmi_phy_clk_ops; -else -dev_err (hdmi_phy->dev,"Failed to get clk ops of phy\n" ); + clk_init->flags = hdmi_phy->conf->flags; + clk_init->ops = hdmi_phy->conf->hdmi_phy_clk_ops; }static int mtk_hdmi_phy_probe (struct platform_device *pdev)
@@ -126,7 +124,6 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev)struct clk_init_data clk_init = { .num_parents =1 , .parent_names = (const char *const *)&ref_clk_name, - .flags =CLK_SET_RATE_PARENT |CLK_SET_RATE_GATE , };struct phy *phy;
@@ -164,7 +161,7 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev) hdmi_phy->dev = dev; hdmi_phy->conf = (struct mtk_hdmi_phy_conf *)of_device_get_match_data (dev); -mtk_hdmi_phy_clk_get_ops (hdmi_phy, &clk_init.ops); +mtk_hdmi_phy_clk_get_data (hdmi_phy, &clk_init); hdmi_phy->pll_hw.init = &clk_init; hdmi_phy->pll =devm_clk_register (dev, &hdmi_phy->pll_hw);if (IS_ERR (hdmi_phy->pll)) {
drivers/gpu/drm/mediatek/mtk_hdmi_phy.h +1 -0
@@ -21,6 +21,7 @@ struct mtk_hdmi_phy;struct mtk_hdmi_phy_conf {bool tz_disabled; +unsigned long flags;const struct clk_ops *hdmi_phy_clk_ops;void (*hdmi_phy_enable_tmds)(struct mtk_hdmi_phy *hdmi_phy);void (*hdmi_phy_disable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +1 -0
@@ -232,6 +232,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy)struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf = { .tz_disabled = true, + .flags =CLK_SET_RATE_NO_REPARENT |CLK_SET_RATE_GATE , .hdmi_phy_clk_ops = &mtk_hdmi_phy_pll_ops, .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds, .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c +1 -0
@@ -317,6 +317,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy) }struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf = { + .flags =CLK_SET_RATE_PARENT |CLK_SET_RATE_GATE , .hdmi_phy_clk_ops = &mtk_hdmi_phy_pll_ops, .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds, .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
Signature · 1 line
2.14.1
PATCH v7 4/6 drm/mediatek: fix the rate and divder of hdmi phy for MT2701
In reply to wangyan wangFrom: chunhui dai <[email protected]>
--- drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +2 -2
@@ -114,8 +114,8 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,if (rate <=64000000 ) pos_div =3 ; -else if (rate <=12800000 ) - pos_div =1 ; +else if (rate <=128000000 ) + pos_div =2 ;else pos_div =1 ;
Signature · 1 line
2.14.1
PATCH v7 5/6 drm/mediatek: using new factor for tvdpll in MT2701
In reply to wangyan wangFrom: chunhui dai <[email protected]>
The factor depends on the divider of DPI in MT2701, therefore, we should fix this factor to the right and new one.
--- drivers/gpu/drm/mediatek/mtk_dpi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -5
@@ -662,13 +662,11 @@ static unsigned int mt8173_calculate_factor(int clock)static unsigned int mt2701_calculate_factor (int clock) {if (clock <=64000 ) -return 16 ; -else if (clock <=128000 ) -return 8 ; -else if (clock <=256000 )return 4 ; -else +else if (clock <=128000 )return 2 ; +else +return 1 ; }static const struct mtk_dpi_conf mt8173_conf = {
Signature · 1 line
2.14.1
PATCH v7 6/6 drm/mediatek: fix the rate of parent for hdmi phy in MT2701
In reply to wangyan wangFrom: chunhui dai <[email protected]>
We should not change the rate of parent for hdmi phy when doing round_rate for this clock. The parent clock of hdmi phy must be the same as it. We change it when doing set_rate only.
--- drivers/gpu/drm/mediatek/mtk_hdmi_phy.c | 19 ------------------- drivers/gpu/drm/mediatek/mtk_hdmi_phy.h | 4 ---- drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 7 +++++++ drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 23 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +0 -19
@@ -15,25 +15,6 @@ static const struct phy_ops mtk_hdmi_phy_dev_ops = { .owner = THIS_MODULE, }; -long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate, -unsigned long *parent_rate) -{ -struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); - - hdmi_phy->pll_rate = rate; -if (rate <=74250000 ) - *parent_rate = rate; -else - *parent_rate = rate /2 ; - -return rate; -} - -u32 mtk_hdmi_phy_read (struct mtk_hdmi_phy *hdmi_phy,u32 offset) -{ -return readl (hdmi_phy->regs + offset); -} -void mtk_hdmi_phy_clear_bits (struct mtk_hdmi_phy *hdmi_phy,u32 offset,u32 bits) {
drivers/gpu/drm/mediatek/mtk_hdmi_phy.h +0 -4
@@ -42,7 +42,6 @@ struct mtk_hdmi_phy {unsigned int ibias_up; }; -u32 mtk_hdmi_phy_read (struct mtk_hdmi_phy *hdmi_phy,u32 offset);void mtk_hdmi_phy_clear_bits (struct mtk_hdmi_phy *hdmi_phy,u32 offset,u32 bits); void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,
@@ -50,9 +49,6 @@ void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,void mtk_hdmi_phy_mask (struct mtk_hdmi_phy *hdmi_phy,u32 offset,u32 val,u32 mask);struct mtk_hdmi_phy *to_mtk_hdmi_phy (struct clk_hw *hw); -long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate, -unsigned long *parent_rate); -extern struct platform_driver mtk_hdmi_phy_driver;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf;
drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +7 -0
@@ -152,6 +152,13 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, RG_HDMITX_DRV_IBIAS_MASK);return 0 ; } + +static long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *parent_rate) +{ +return rate; +} +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw,unsigned long parent_rate) {
drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c +14 -0
@@ -285,6 +285,20 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,return 0 ; } +static long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + + hdmi_phy->pll_rate = rate; +if (rate <=74250000 ) + *parent_rate = rate; +else + *parent_rate = rate /2 ; + +return rate; +} +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw,unsigned long parent_rate) {
Signature · 1 line
2.14.1
Quoted 24 lines · wangyan wang
From: Wangyan Wang <[email protected]>
V7 adopt maintainer's suggestion.
Here is the change list between V6 & V71. use readl directly & delete
hdmi_phy->pll_rateinmtk_hdmi_pll_recalc_rate().
in "drm/mediatek: recalculate hdmi ..."2. detele
mtk_hdmi_phy_read()inmtk_hdmi_phy.c. in "fix the rate of parent for hdmi phy in MT2701"3. optimize
mtk_hdmi_pll_round_rate().
in "fix the rate of parent for hdmi phy in MT2701"chunhui dai (6):
drm/mediatek: recalculate hdmi phy clock of MT2701 by querying
hardware
drm/mediatek: move the setting of fixed divider drm/mediatek: using different flags of clk for HDMI phy drm/mediatek: fix the rate and divder of hdmi phy for MT2701 drm/mediatek: using new factor for tvdpll in MT2701 drm/mediatek: fix the rate of parent for hdmi phy in MT2701
Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dpi.c | 8 ++--- drivers/gpu/drm/mediatek/mtk_hdmi_phy.c | 35 +++--------------- drivers/gpu/drm/mediatek/mtk_hdmi_phy.h | 6 +--- drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 50 ++++++++++++++++++++++---- drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 23 ++++++++++++ 5 files changed, 76 insertions(+), 46 deletions(-)
The series could not work on v5.1. Please check it out.
Re: [PATCH V7 1/6] drm/mediatek: recalculate hdmi phy clock of MT2701 by querying hardware
In reply to wangyan wangQuoted 3 lines · wangyan wang
From: chunhui dai <[email protected]>
Recalculate the rate of this clock, by querying hardware.
You just describe _WHAT_ do you do here, I would like you to describe _WHT_ do you do here. I think this patch is to make implementation of recalc_rate() to match the definition.
Quoted 17 lines
Signed-off-by chunhui dai <[email protected]>Signed-off-by wangyan wang <[email protected]>--- drivers/gpu/drm/mediatek/mtk_hdmi_phy.c | 7 ++---- drivers/gpu/drm/mediatek/mtk_hdmi_phy.h | 3 +-- drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 33 ++++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 8 +++++++ 4 files changed, 44 insertions(+), 7 deletions(-)drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +0
-0@@ -29,12 +29,9 @@ long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,return rate; }
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate, · line 35
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +2
-5-unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate) +u32 mtk_hdmi_phy_read (struct mtk_hdmi_phy *hdmi_phy,u32 offset) { -struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); - -return hdmi_phy->pll_rate; +return readl (hdmi_phy->regs + offset); }
This function is useless, so remove it.
Regards,
CK
Quoted 86 lines
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +0
-0void mtk_hdmi_phy_clear_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,drivers/gpu/drm/mediatek/mtk_hdmi_phy.h +1
-2@@ -41,6 +41,7 @@ struct mtk_hdmi_phy {unsigned int ibias_up; }; +u32 mtk_hdmi_phy_read (struct mtk_hdmi_phy *hdmi_phy,u32 offset);void mtk_hdmi_phy_clear_bits (struct mtk_hdmi_phy *hdmi_phy,u32 offset,u32 bits); void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,@@ -50,8 +51,6 @@ void mtk_hdmi_phy_mask(struct mtk_hdmi_phy *hdmi_phy, u32 offset,struct mtk_hdmi_phy *to_mtk_hdmi_phy (struct clk_hw *hw);long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate,unsigned long *parent_rate); -unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate);extern struct platform_driver mtk_hdmi_phy_driver;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf;drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +33
-0@@ -153,6 +153,39 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, RG_HDMITX_DRV_IBIAS_MASK);return 0 ; } +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +unsigned long out_rate, val; + + val = (readl (hdmi_phy->regs +HDMI_CON6 ) + &RG_HTPLL_PREDIV_MASK ) >>RG_HTPLL_PREDIV ; +switch (val) { +case 0x00 : + out_rate = parent_rate; +break ; +case 0x01 : + out_rate = parent_rate /2 ; +break ; +default : + out_rate = parent_rate /4 ; +break ; + } + + val = (readl (hdmi_phy->regs +HDMI_CON6 ) + &RG_HTPLL_FBKDIV_MASK ) >>RG_HTPLL_FBKDIV ; + out_rate *= (val +1 ) *2 ; + val = (readl (hdmi_phy->regs +HDMI_CON2 ) + &RG_HDMITX_TX_POSDIV_MASK ); + + out_rate >>= (val >>RG_HDMITX_TX_POSDIV ); + +if (readl (hdmi_phy->regs +HDMI_CON2 ) &RG_HDMITX_EN_TX_POSDIV ) + out_rate = out_rate /5 ; + +return out_rate; +}static const struct clk_ops mtk_hdmi_phy_pll_ops = { .prepare = mtk_hdmi_pll_prepare,drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c +8
-0@@ -285,6 +285,14 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,return 0 ; } +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + +return hdmi_phy->pll_rate; +} +static const struct clk_ops mtk_hdmi_phy_pll_ops = { .prepare = mtk_hdmi_pll_prepare, .unprepare = mtk_hdmi_pll_unprepare,
Re: [PATCH V7 2/6] drm/mediatek: move the setting of fixed divider
In reply to wangyan wangHi, Wangyan:
Quoted 8 lines · wangyan wang
From: chunhui dai <[email protected]>
move the setting of fixed divider from enable/disable to the function of setting rate.
the patch is for hdmi pll divider, the divder should be configured before clock calculation to ensure the clock is right.
I think this patch is introduced by the patch "drm/mediatek: recalculate hdmi phy clock of MT2701 by querying hardware", so I would like to squash this patch into that patch.
Regards,
CK
Quoted 51 lines
Signed-off-by chunhui dai <[email protected]>Signed-off-by wangyan wang <[email protected]>--- drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +1
-4@@ -79,7 +79,6 @@ static int mtk_hdmi_pll_prepare(struct clk_hw *hw)mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SLDO_MASK );usleep_range (80 ,100 );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_MBIAS_LPF_EN ); -mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SER_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_PRED_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_DRV_MASK );@@ -94,7 +93,6 @@ static void mtk_hdmi_pll_unprepare(struct clk_hw *hw)mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_DRV_MASK );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_PRED_MASK );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SER_MASK ); -mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_MBIAS_LPF_EN );usleep_range (80 ,100 );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SLDO_MASK );@@ -123,6 +121,7 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON6 ,RG_HTPLL_PREDIV_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON6 ,RG_HTPLL_POSDIV_MASK ); +mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_mask (hdmi_phy,HDMI_CON6 , (0x1 <<RG_HTPLL_IC ),RG_HTPLL_IC_MASK ); mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IR),@@ -207,7 +206,6 @@ static void mtk_hdmi_phy_enable_tmds(struct mtk_hdmi_phy *hdmi_phy)mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SLDO_MASK );usleep_range (80 ,100 );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_MBIAS_LPF_EN ); -mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SER_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_PRED_MASK );mtk_hdmi_phy_set_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_DRV_MASK );@@ -219,7 +217,6 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy)mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_DRV_MASK );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_PRED_MASK );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SER_MASK ); -mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_EN_TX_POSDIV );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON2 ,RG_HDMITX_MBIAS_LPF_EN );usleep_range (80 ,100 );mtk_hdmi_phy_clear_bits (hdmi_phy,HDMI_CON0 ,RG_HDMITX_EN_SLDO_MASK );
Re: [PATCH V7 3/6] drm/mediatek: using different flags of clk for HDMI phy
In reply to wangyan wangHi, Wangyan:
As offline discuss, I think you could just remove the flag CLK_SET_RATE_PARENT and do not add CLK_SET_RATE_NO_REPARENT.
I would like the title to be more clear about what you do so we could quickly understand what this patch do. For example:
drm/mediatek: remove flag CLK_SET_RATE_PARENT for MT2701 HDMI phy
And I think there are three patches is related to HDMI stable and each one is not independent (Apply only one patch would make something wrong, so these three patches should be applied together). So I would like you to describe the three steps you do in each patch and what's the step of this patch, for example:
"To make MT2701 HDMI stable, TVDPLL should not be adjusted and it's the parent clock of HDMI phy, so HDMI phy could not adjust parent rate. This patch is the first step to make MT2701 HDMI stable. These steps include:
1. Remove flag CLK_SET_RATE_PARENT for MT2701 HDMI phy to not propagate rate change to parent.
2. Using new factor for tvdpll in MT2701 to ......
3. No change parent rate in round_rate() for MT2701 HDMI phy"
Regards,
CK
Quoted 91 lines · wangyan wang
From: chunhui dai <[email protected]>
The parent rate of hdmi phy had set by DPI driver.
We should not set or change the parent rate of MT2701 hdmi phy, as a result we should remove the flags of "CLK_SET_RATE_PARENT" from the clock of MT2701 hdmi phy.Signed-off-by chunhui dai <[email protected]>Signed-off-by wangyan wang <[email protected]>--- drivers/gpu/drm/mediatek/mtk_hdmi_phy.c | 13 +++++-------- drivers/gpu/drm/mediatek/mtk_hdmi_phy.h | 1 + drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 1 + drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 1 + 4 files changed, 8 insertions(+), 8 deletions(-)drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +5
-8@@ -107,13 +107,11 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy *hdmi_phy)return NULL ; } -static void mtk_hdmi_phy_clk_get_ops (struct mtk_hdmi_phy *hdmi_phy, -const struct clk_ops **ops) +static void mtk_hdmi_phy_clk_get_data (struct mtk_hdmi_phy *hdmi_phy, +struct clk_init_data *clk_init) { -if (hdmi_phy && hdmi_phy->conf && hdmi_phy->conf->hdmi_phy_clk_ops) - *ops = hdmi_phy->conf->hdmi_phy_clk_ops; -else -dev_err (hdmi_phy->dev,"Failed to get clk ops of phy\n" ); + clk_init->flags = hdmi_phy->conf->flags; + clk_init->ops = hdmi_phy->conf->hdmi_phy_clk_ops; }static int mtk_hdmi_phy_probe (struct platform_device *pdev)@@ -126,7 +124,6 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev)struct clk_init_data clk_init = { .num_parents =1 , .parent_names = (const char *const *)&ref_clk_name, - .flags =CLK_SET_RATE_PARENT |CLK_SET_RATE_GATE , };struct phy *phy;@@ -164,7 +161,7 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev) hdmi_phy->dev = dev; hdmi_phy->conf = (struct mtk_hdmi_phy_conf *)of_device_get_match_data (dev); -mtk_hdmi_phy_clk_get_ops (hdmi_phy, &clk_init.ops); +mtk_hdmi_phy_clk_get_data (hdmi_phy, &clk_init); hdmi_phy->pll_hw.init = &clk_init; hdmi_phy->pll =devm_clk_register (dev, &hdmi_phy->pll_hw);if (IS_ERR (hdmi_phy->pll)) {drivers/gpu/drm/mediatek/mtk_hdmi_phy.h +1
-0@@ -21,6 +21,7 @@ struct mtk_hdmi_phy;struct mtk_hdmi_phy_conf {bool tz_disabled; +unsigned long flags;const struct clk_ops *hdmi_phy_clk_ops;void (*hdmi_phy_enable_tmds)(struct mtk_hdmi_phy *hdmi_phy);void (*hdmi_phy_disable_tmds)(struct mtk_hdmi_phy *hdmi_phy);drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +1
-0@@ -232,6 +232,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy)struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf = { .tz_disabled = true, + .flags =CLK_SET_RATE_NO_REPARENT |CLK_SET_RATE_GATE , .hdmi_phy_clk_ops = &mtk_hdmi_phy_pll_ops, .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds, .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c +1
-0@@ -317,6 +317,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy) }struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf = { + .flags =CLK_SET_RATE_PARENT |CLK_SET_RATE_GATE , .hdmi_phy_clk_ops = &mtk_hdmi_phy_pll_ops, .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds, .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
Re: [PATCH V7 6/6] drm/mediatek: fix the rate of parent for hdmi phy in MT2701
In reply to wangyan wangHi, Wangyan:
I would like the title to more clear about what this patch do. For example:
drm/mediatek: no change parent rate in round_rate() for MT2701 HDMI phy
Quoted 32 lines · wangyan wang
From: chunhui dai <[email protected]>
We should not change the rate of parent for hdmi phy when doing
round_ratefor this clock. The parent clock of hdmi phy must be the same as it. We change it when doingset_rateonly.Signed-off-by chunhui dai <[email protected]>Signed-off-by wangyan wang <[email protected]>--- drivers/gpu/drm/mediatek/mtk_hdmi_phy.c | 19 ------------------- drivers/gpu/drm/mediatek/mtk_hdmi_phy.h | 4 ---- drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c | 7 +++++++ drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 23 deletions(-)drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +0
-8@@ -15,25 +15,6 @@ static const struct phy_ops mtk_hdmi_phy_dev_ops = { .owner = THIS_MODULE, }; -long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate, -unsigned long *parent_rate) -{ -struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); - - hdmi_phy->pll_rate = rate; -if (rate <=74250000 ) - *parent_rate = rate;
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c static const struct phy_ops mtk_hdmi_phy_dev_ops = { · line 35
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +0
-10-else - *parent_rate = rate /2 ; - -return rate; -} - -u32 mtk_hdmi_phy_read (struct mtk_hdmi_phy *hdmi_phy,u32 offset) -{ -return readl (hdmi_phy->regs + offset); -}
I think this function should already be removed by the patch "drm/mediatek: recalculate hdmi phy clock of MT2701 by querying hardware"
Regards,
CK
Quoted 59 lines
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c +0
-1-void mtk_hdmi_phy_clear_bits (struct mtk_hdmi_phy *hdmi_phy,u32 offset,u32 bits) {drivers/gpu/drm/mediatek/mtk_hdmi_phy.h +0
-4@@ -42,7 +42,6 @@ struct mtk_hdmi_phy {unsigned int ibias_up; }; -u32 mtk_hdmi_phy_read (struct mtk_hdmi_phy *hdmi_phy,u32 offset);void mtk_hdmi_phy_clear_bits (struct mtk_hdmi_phy *hdmi_phy,u32 offset,u32 bits); void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,@@ -50,9 +49,6 @@ void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset,void mtk_hdmi_phy_mask (struct mtk_hdmi_phy *hdmi_phy,u32 offset,u32 val,u32 mask);struct mtk_hdmi_phy *to_mtk_hdmi_phy (struct clk_hw *hw); -long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate, -unsigned long *parent_rate); -extern struct platform_driver mtk_hdmi_phy_driver;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf;drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c +7
-0@@ -152,6 +152,13 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, RG_HDMITX_DRV_IBIAS_MASK);return 0 ; } + +static long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *parent_rate) +{ +return rate; +} +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw,unsigned long parent_rate) {drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c +7
-0@@ -285,6 +285,20 @@ static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,return 0 ; } +static long mtk_hdmi_pll_round_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + + hdmi_phy->pll_rate = rate; +if (rate <=74250000 )
drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, · line 304
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c +7
-0+ *parent_rate = rate; + else + *parent_rate = rate /2 ; + +return rate; +} +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw,unsigned long parent_rate) {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel