drm/mediatek/dp: The register is written with the parsed DTS SSC value.
Subsystems (4)
PATCH 1/1 drm/mediatek/dp: The register is written with the parsed DTS SSC value.
[Description]
Severe screen flickering has been observed on the external display when the DP projection function is used with the market expansion dock.
[Root cause]
It has been discovered through analysis that severe screen flickering will occur when using the current default settings of
SC (Spread Spectrum Clocking) after it is opened.
[Solution]
Reducing SSC capability on the test platform can
resolve the screen flickering issue.
By configuring SSC parameters in DTS, locating the DP SSC node in phy-mtk-dp, parsing the current value of SSC, and writing this value into PHY to configure SSC can solve the screen flickering problem.
[Test]
The SSC configuration values are read from DTS, parsed in the driver, and then written to the hardware. The test results indicate that there is no screen flickering.
--- drivers/phy/mediatek/phy-mtk-dp.c | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
drivers/phy/mediatek/phy-mtk-dp.c +61 -0
@@ -25,6 +25,10 @@#define BIT_RATE_HBR2 2#define BIT_RATE_HBR3 3 +#define MTK_DP_PHY_DIG_GLB_DA_REG_14 (PHY_OFFSET + 0xD8) +#define XTP_GLB_TXPLL_SSC_DELTA_RBR_DEFAULT GENMASK(15, 0) +#define XTP_GLB_TXPLL_SSC_DELTA_HBR_DEFAULT GENMASK(31, 16) +#define MTK_DP_PHY_DIG_SW_RST (PHY_OFFSET + 0x38)#define DP_GLB_SW_RST_PHYD BIT(0)
@@ -78,10 +82,57 @@#define DRIVING_PARAM_8_DEFAULT (XTP_LN_TX_LCTXCP1_SW2_PRE1_DEFAULT | \ XTP_LN_TX_LCTXCP1_SW3_PRE0_DEFAULT) +#define SSC_SETTING "dp-ssc-setting" +#define RG_XTP_GLB_TXPLL_SSC_DELTA_RBR "ssc-delta-rbr" +#define RG_XTP_GLB_TXPLL_SSC_DELTA_HBR "ssc-delta-hbr" +struct mtk_dp_phy {struct regmap *regs; +struct device *dev; }; +static int mtk_dp_set_ssc_config (struct phy *phy,struct mtk_dp_phy *dp_phy, +struct device_node *ssc_node,const char *mode_name,u32 ssc_reg_offset) +{ +int ret; +u32 read_value =0 ; + + ret =of_property_read_u32 (ssc_node, mode_name, &read_value); +if (ret) { +dev_err (&phy->dev,"Read fail,DPTX is not %s\n" , mode_name); +return -EINVAL ; + } + +if (!read_value) { +dev_err (&phy->dev,"Read value is NULL\n" ); +return -ENOMEM ; + } + +if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_RBR )) { +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_RBR_DEFAULT , read_value); + }else if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_HBR )) { + read_value = read_value <<16 |0x0000 ; +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_HBR_DEFAULT , read_value); + } + +return 0 ; +} + +static struct device_node *mtk_dp_get_ssc_node (struct phy *phy,struct mtk_dp_phy *dp_phy) +{ +struct device_node *mode_node =NULL ; + + mode_node =of_find_node_by_name (dp_phy->dev->of_node,SSC_SETTING ); +if (!mode_node) { +dev_err (&phy->dev,"SSC node is NULL\n" ); +return NULL ; + } + +return mode_node; +} +static int mtk_dp_phy_init (struct phy *phy) {struct mtk_dp_phy *dp_phy =phy_get_drvdata (phy);
@@ -109,6 +160,7 @@ static int mtk_dp_phy_init(struct phy *phy)static int mtk_dp_phy_configure (struct phy *phy,union phy_configure_opts *opts) {struct mtk_dp_phy *dp_phy =phy_get_drvdata (phy); +struct device_node *ssc_node =NULL ;u32 val;if (opts->dp.set_rate) {
@@ -137,6 +189,14 @@ static int mtk_dp_phy_configure(struct phy *phy, union phy_configure_opts *opts)regmap_update_bits (dp_phy->regs,MTK_DP_PHY_DIG_PLL_CTL_1 ,TPLL_SSC_EN , opts->dp.ssc ?TPLL_SSC_EN :0 ); + ssc_node =mtk_dp_get_ssc_node (phy, dp_phy); +if (ssc_node) { +mtk_dp_set_ssc_config (phy, dp_phy, ssc_node,RG_XTP_GLB_TXPLL_SSC_DELTA_RBR , +MTK_DP_PHY_DIG_GLB_DA_REG_14 ); +mtk_dp_set_ssc_config (phy, dp_phy, ssc_node,RG_XTP_GLB_TXPLL_SSC_DELTA_HBR , +MTK_DP_PHY_DIG_GLB_DA_REG_14 ); + } +return 0 ; }
@@ -186,6 +246,7 @@ static int mtk_dp_phy_probe(struct platform_device *pdev)if (!dev->of_node)phy_create_lookup (phy,"dp" ,dev_name (dev)); + dp_phy->dev = dev;return 0 ; }
Signature · 1 line
2.43.0
Quoted 12 lines · Liankun Yang
[Description]
Severe screen flickering has been observed on the external display when the DP projection function is used with the market expansion dock.drivers/phy/mediatek/phy-mtk-dp.c +7
-0+if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_RBR )) { +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_RBR_DEFAULT , read_value); + }else if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_HBR )) { + read_value = read_value <<16 |0x0000 ; +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_HBR_DEFAULT , read_value);
drivers/phy/mediatek/phy-mtk-dp.c line 127
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-dp.c +10
-0+ } + +return 0 ; +} + +static struct device_node *mtk_dp_get_ssc_node (struct phy *phy,struct mtk_dp_phy *dp_phy) +{ +struct device_node *mode_node =NULL ; + + mode_node =of_find_node_by_name (dp_phy->dev->of_node,SSC_SETTING );
?!?!
You have the node, why do you try to find it?
Best regards,
Krzysztof
Quoted 18 lines · Krzysztof Kozlowski
Quoted 17 lines · Liankun Yang
[Description]
Severe screen flickering has been observed on the external display when the DP projection function is used with the market expansion dock.drivers/phy/mediatek/phy-mtk-dp.c +12
-0+if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_RBR )) { +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_RBR_DEFAULT , read_value); + }else if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_HBR )) { + read_value = read_value <<16 |0x0000 ; +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_HBR_DEFAULT , read_value); + } + +return 0 ; +} +
Quoted 9 lines
drivers/phy/mediatek/phy-mtk-dp.c line 127
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-dp.c +5
-0+static struct device_node *mtk_dp_get_ssc_node (struct phy *phy,struct mtk_dp_phy *dp_phy) +{ +struct device_node *mode_node =NULL ; + + mode_node =of_find_node_by_name (dp_phy->dev->of_node,SSC_SETTING );?!?!
You have the node, why do you try to find it?
Wait, that was brainfuck from my side or -ENOCOFFEE. Ignore.
I still have a question though, where did you document new ABI:
dependency on the node name here?
Also, why you are not going through direct children - of_get_child_by_name()?
Best regards,
Krzysztof
Quoted 37 lines · Krzysztof Kozlowski
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 4 lines · Krzysztof Kozlowski
Quoted 3 lines · Liankun Yang
[Description]
Severe screen flickering has been observed on the external display when the DP projection function is used with the market expansiondock.
Quoted 15 lines
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-dp.c +3
-0+if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_RBR )) { +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_RBR_DEFAULT , read_value);drivers/phy/mediatek/phy-mtk-dp.c
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-dp.c +10
-0+}else if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_HBR )) { +read_value = read_value <<16 |0x0000 ; +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_HBR_DEFAULT , read_value); +} + +return 0 ; +} + +static struct device_node *mtk_dp_get_ssc_node(struct phy *phy,struct
mtk_dp_phy*dp_phy)Quoted 4 lines
drivers/phy/mediatek/phy-mtk-dp.c
Quoted 4 lines
drivers/phy/mediatek/phy-mtk-dp.c +4
-0+{ +struct device_node *mode_node =NULL ; + +mode_node = of_find_node_by_name(dp_phy->dev->of_node,
SSC_SETTING);Quoted 4 lines
?!?!
You have the node, why do you try to find it?Wait, that was brainfuck from my side or
-ENOCOFFEE. Ignore.
Quoted 10 lines
I still have a question though, where did you document new ABI:
dependency on the node name here?Also, why you are not going through direct children -
of_get_child_by_name()?Best regards,
Krzysztof
Sorry, there is formatting issue in the previous email.
The dp_phy device has already been registered through the mtk_dp_register_phy function in the mtk_dp.c file,
so it cannot be redefined in the dts. Avoid using of_get_child_by_name for this purpose.
To find the node name, utilize of_find_node_by_name since it has already been registered.
Best regards,
Liankun Yang
Quoted 1 line
Quoted 51 lines · LIANKUN YANG (杨连坤)
Quoted 37 lines · Krzysztof Kozlowski
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 4 lines · Krzysztof Kozlowski
Quoted 3 lines · Liankun Yang
[Description]
Severe screen flickering has been observed on the external display when the DP projection function is used with the market expansiondock.
Quoted 15 lines
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-dp.c +3
-0+if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_RBR )) { +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_RBR_DEFAULT , read_value);drivers/phy/mediatek/phy-mtk-dp.c
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-dp.c +10
-0+}else if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_HBR )) { +read_value = read_value <<16 |0x0000 ; +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_HBR_DEFAULT , read_value); +} + +return 0 ; +} + +static struct device_node *mtk_dp_get_ssc_node(struct phy *phy,struct
mtk_dp_phy*dp_phy)Quoted 4 lines
drivers/phy/mediatek/phy-mtk-dp.c
Quoted 4 lines
drivers/phy/mediatek/phy-mtk-dp.c +4
-0+{ +struct device_node *mode_node =NULL ; + +mode_node = of_find_node_by_name(dp_phy->dev->of_node,
SSC_SETTING);Quoted 4 lines
?!?!
You have the node, why do you try to find it?Wait, that was brainfuck from my side or
-ENOCOFFEE. Ignore.Quoted 10 lines
I still have a question though, where did you document new ABI:
dependency on the node name here?Also, why you are not going through direct children -
of_get_child_by_name()?Best regards,
KrzysztofSorry, there is formatting issue in the previous email.
Quoted 7 lines
The
dp_phydevice has already been registered through themtk_dp_register_phyfunction in themtk_dp.cfile,
so it cannot be redefined in the dts. Avoid usingof_get_child_by_namefor this purpose.To find the node name, utilize
of_find_node_by_namesince it has already been registered.
This does not answer my question at all. You speak about driver, I speak about ABI and bindings.
Best regards,
Krzysztof
On Wed, 2024-04-03 at 16:56 +0200, Krzysztof Kozlowski wrote:
Dear Krzysztof:
The dp_phy device has already been registered through the mtk_dp_register_phy function in the mtk_dp.c file, so it cannot be redefined in the dts. Avoid using of_get_child_by_name for this purpose.
To find the node name, utilize of_find_node_by_name since it has already been registered.
Best regards,
Liankun Yang
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 44 lines · Krzysztof Kozlowski
Quoted 41 lines · Liankun Yang
[Description]
Severe screen flickering has been observed on the external display
when the DP projection function is used with the market expansion dock.
drivers/phy/mediatek/phy-mtk-dp.c +16
-0+if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_RBR )) { +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_RBR_DEFAULT , read_value); +}else if (!strcmp (mode_name,RG_XTP_GLB_TXPLL_SSC_DELTA_HBR )) { +read_value = read_value <<16 |0x0000 ; +regmap_update_bits (dp_phy->regs, ssc_reg_offset, +XTP_GLB_TXPLL_SSC_DELTA_HBR_DEFAULT , read_value); +} + +return 0 ; +} + +static struct device_node *mtk_dp_get_ssc_node (struct phy *phy,struct mtk_dp_phy *dp_phy) +{ +struct device_node *mode_node =NULL ; +
Quoted 9 lines
Quoted 1 line
+mode_node =
of_find_node_by_name(dp_phy->dev->of_node, SSC_SETTING);?!?!
You have the node, why do you try to find it?
Wait, that was brainfuck from my side or -ENOCOFFEE. Ignore.
I still have a question though, where did you document new ABI:
dependency on the node name here?
Also, why you are not going through direct children -
of_get_child_by_name()?
Best regards,
Krzysztof