mediatek: 6.6: refresh patches
[openwrt/staging/nbd.git] / target / linux / mediatek / patches-6.6 / 200-phy-phy-mtk-tphy-Add-hifsys-support.patch
1 From 28f9a5e2a3f5441ab5594669ed82da11e32277a9 Mon Sep 17 00:00:00 2001
2 From: Kristian Evensen <kristian.evensen@gmail.com>
3 Date: Mon, 30 Apr 2018 14:38:01 +0200
4 Subject: [PATCH] phy: phy-mtk-tphy: Add hifsys-support
5
6 ---
7 drivers/phy/mediatek/phy-mtk-tphy.c | 20 ++++++++++++++++++++
8 1 file changed, 20 insertions(+)
9
10 --- a/drivers/phy/mediatek/phy-mtk-tphy.c
11 +++ b/drivers/phy/mediatek/phy-mtk-tphy.c
12 @@ -18,6 +18,8 @@
13 #include <linux/phy/phy.h>
14 #include <linux/platform_device.h>
15 #include <linux/regmap.h>
16 +#include <linux/mfd/syscon.h>
17 +#include <linux/regmap.h>
18
19 #include "phy-mtk-io.h"
20
21 @@ -267,6 +269,9 @@
22
23 #define USER_BUF_LEN(count) min_t(size_t, 8, (count))
24
25 +#define HIF_SYSCFG1 0x14
26 +#define HIF_SYSCFG1_PHY2_MASK (0x3 << 20)
27 +
28 enum mtk_phy_version {
29 MTK_PHY_V1 = 1,
30 MTK_PHY_V2,
31 @@ -334,6 +339,7 @@ struct mtk_tphy {
32 void __iomem *sif_base; /* only shared sif */
33 const struct mtk_phy_pdata *pdata;
34 struct mtk_phy_instance **phys;
35 + struct regmap *hif;
36 int nphys;
37 int src_ref_clk; /* MHZ, reference clock for slew rate calibrate */
38 int src_coef; /* coefficient for slew rate calibrate */
39 @@ -951,6 +957,10 @@ static void pcie_phy_instance_init(struc
40 if (tphy->pdata->version != MTK_PHY_V1)
41 return;
42
43 + if (tphy->hif)
44 + regmap_update_bits(tphy->hif, HIF_SYSCFG1,
45 + HIF_SYSCFG1_PHY2_MASK, 0);
46 +
47 mtk_phy_update_bits(phya + U3P_U3_PHYA_DA_REG0,
48 P3A_RG_XTAL_EXT_PE1H | P3A_RG_XTAL_EXT_PE2H,
49 FIELD_PREP(P3A_RG_XTAL_EXT_PE1H, 0x2) |
50 @@ -1597,6 +1607,16 @@ static int mtk_tphy_probe(struct platfor
51 &tphy->src_coef);
52 }
53
54 + if (of_find_property(np, "mediatek,phy-switch", NULL)) {
55 + tphy->hif = syscon_regmap_lookup_by_phandle(np,
56 + "mediatek,phy-switch");
57 + if (IS_ERR(tphy->hif)) {
58 + dev_err(&pdev->dev,
59 + "missing \"mediatek,phy-switch\" phandle\n");
60 + return PTR_ERR(tphy->hif);
61 + }
62 + }
63 +
64 port = 0;
65 for_each_child_of_node(np, child_np) {
66 struct mtk_phy_instance *instance;