200-phy-phy-mtk-tphy-Add-hifsys-support.patch 1.9 KB

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