1ac15bdb72dcee3a9f93634b238c6fe9b8dfe703
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.14 / 0226-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 diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
11 index 721a2a1c9..0cb1cea53 100644
12 --- a/drivers/phy/mediatek/phy-mtk-tphy.c
13 +++ b/drivers/phy/mediatek/phy-mtk-tphy.c
14 @@ -22,6 +22,8 @@
15 #include <linux/of_address.h>
16 #include <linux/phy/phy.h>
17 #include <linux/platform_device.h>
18 +#include <linux/mfd/syscon.h>
19 +#include <linux/regmap.h>
20
21 /* version V1 sub-banks offset base address */
22 /* banks shared by multiple phys */
23 @@ -259,6 +261,9 @@
24 #define RG_CDR_BIRLTD0_GEN3_MSK GENMASK(4, 0)
25 #define RG_CDR_BIRLTD0_GEN3_VAL(x) (0x1f & (x))
26
27 +#define HIF_SYSCFG1 0x14
28 +#define HIF_SYSCFG1_PHY2_MASK (0x3 << 20)
29 +
30 enum mtk_phy_version {
31 MTK_PHY_V1 = 1,
32 MTK_PHY_V2,
33 @@ -302,6 +307,7 @@ struct mtk_tphy {
34 struct clk *u3phya_ref; /* reference clock of usb3 anolog phy */
35 const struct mtk_phy_pdata *pdata;
36 struct mtk_phy_instance **phys;
37 + struct regmap *hif;
38 int nphys;
39 };
40
41 @@ -594,6 +600,10 @@ static void pcie_phy_instance_init(struct mtk_tphy *tphy,
42 if (tphy->pdata->version != MTK_PHY_V1)
43 return;
44
45 + if (tphy->hif)
46 + regmap_update_bits(tphy->hif, HIF_SYSCFG1,
47 + HIF_SYSCFG1_PHY2_MASK, 0);
48 +
49 tmp = readl(u3_banks->phya + U3P_U3_PHYA_DA_REG0);
50 tmp &= ~(P3A_RG_XTAL_EXT_PE1H | P3A_RG_XTAL_EXT_PE2H);
51 tmp |= P3A_RG_XTAL_EXT_PE1H_VAL(0x2) | P3A_RG_XTAL_EXT_PE2H_VAL(0x2);
52 @@ -1008,6 +1018,16 @@ static int mtk_tphy_probe(struct platform_device *pdev)
53 tphy->u3phya_ref = NULL;
54 }
55
56 + if (of_find_property(np, "mediatek,phy-switch", NULL)) {
57 + tphy->hif = syscon_regmap_lookup_by_phandle(np,
58 + "mediatek,phy-switch");
59 + if (IS_ERR(tphy->hif)) {
60 + dev_err(&pdev->dev,
61 + "missing \"mediatek,phy-switch\" phandle\n");
62 + return PTR_ERR(tphy->hif);
63 + }
64 + }
65 +
66 port = 0;
67 for_each_child_of_node(np, child_np) {
68 struct mtk_phy_instance *instance;
69 --
70 2.14.1
71