phy: phy-mtk-tphy: add property to set pre-emphasis
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Wed, 14 Sep 2022 06:07:42 +0000 (14:07 +0800)
committerVinod Koul <vkoul@kernel.org>
Tue, 20 Sep 2022 06:29:05 +0000 (11:59 +0530)
Add a property to set usb2 phy's pre-emphasis, it's disabled by default
on some SoCs.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220914060746.10004-3-chunfeng.yun@mediatek.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/mediatek/phy-mtk-tphy.c

index 8ee7682b8e93eb86346d1e55e1f6963a5f8f77d0..986fde0f63a099f7efeec8dd08e016ed39eb715a 100644 (file)
@@ -72,6 +72,8 @@
 #define PA5_RG_U2_HS_100U_U3_EN        BIT(11)
 
 #define U3P_USBPHYACR6         0x018
+#define PA6_RG_U2_PRE_EMP              GENMASK(31, 30)
+#define PA6_RG_U2_PRE_EMP_VAL(x)       ((0x3 & (x)) << 30)
 #define PA6_RG_U2_BC11_SW_EN           BIT(23)
 #define PA6_RG_U2_OTG_VBUSCMP_EN       BIT(20)
 #define PA6_RG_U2_DISCTH               GENMASK(7, 4)
@@ -370,6 +372,7 @@ struct mtk_phy_instance {
        int eye_term;
        int intr;
        int discth;
+       int pre_emphasis;
        bool bc12_en;
 };
 
@@ -841,10 +844,13 @@ static void phy_parse_property(struct mtk_tphy *tphy,
                                 &instance->intr);
        device_property_read_u32(dev, "mediatek,discth",
                                 &instance->discth);
+       device_property_read_u32(dev, "mediatek,pre-emphasis",
+                                &instance->pre_emphasis);
        dev_dbg(dev, "bc12:%d, src:%d, vrt:%d, term:%d, intr:%d, disc:%d\n",
                instance->bc12_en, instance->eye_src,
                instance->eye_vrt, instance->eye_term,
                instance->intr, instance->discth);
+       dev_dbg(dev, "pre-emp:%d\n", instance->pre_emphasis);
 }
 
 static void u2_phy_props_set(struct mtk_tphy *tphy,
@@ -875,6 +881,10 @@ static void u2_phy_props_set(struct mtk_tphy *tphy,
        if (instance->discth)
                mtk_phy_update_bits(com + U3P_USBPHYACR6, PA6_RG_U2_DISCTH,
                                    PA6_RG_U2_DISCTH_VAL(instance->discth));
+
+       if (instance->pre_emphasis)
+               mtk_phy_update_bits(com + U3P_USBPHYACR6, PA6_RG_U2_PRE_EMP,
+                                   PA6_RG_U2_PRE_EMP_VAL(instance->pre_emphasis));
 }
 
 /* type switch for usb3/pcie/sgmii/sata */