730-v6.5-net-phy-add-driver-for-MediaTek-SoC-built-in-GE-PHYs.patch 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. From 98c485eaf509bc0e2a85f9b58d17cd501f274c4e Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Sun, 11 Jun 2023 00:48:10 +0100
  4. Subject: [PATCH] net: phy: add driver for MediaTek SoC built-in GE PHYs
  5. Some of MediaTek's Filogic SoCs come with built-in gigabit Ethernet
  6. PHYs which require calibration data from the SoC's efuse.
  7. Despite the similar design the driver doesn't share any code with the
  8. existing mediatek-ge.c.
  9. Add support for such PHYs by introducing a new driver with basic
  10. support for MediaTek SoCs MT7981 and MT7988 built-in 1GE PHYs.
  11. Signed-off-by: Daniel Golle <[email protected]>
  12. Reviewed-by: Andrew Lunn <[email protected]>
  13. Signed-off-by: David S. Miller <[email protected]>
  14. ---
  15. MAINTAINERS | 9 +
  16. drivers/net/phy/Kconfig | 12 +
  17. drivers/net/phy/Makefile | 1 +
  18. drivers/net/phy/mediatek-ge-soc.c | 1116 +++++++++++++++++++++++++++++
  19. drivers/net/phy/mediatek-ge.c | 3 +-
  20. 5 files changed, 1140 insertions(+), 1 deletion(-)
  21. create mode 100644 drivers/net/phy/mediatek-ge-soc.c
  22. --- a/MAINTAINERS
  23. +++ b/MAINTAINERS
  24. @@ -12936,6 +12936,15 @@ S: Maintained
  25. F: drivers/net/pcs/pcs-mtk-lynxi.c
  26. F: include/linux/pcs/pcs-mtk-lynxi.h
  27. +MEDIATEK ETHERNET PHY DRIVERS
  28. +M: Daniel Golle <[email protected]>
  29. +M: Qingfang Deng <[email protected]>
  30. +M: SkyLake Huang <[email protected]>
  31. +L: [email protected]
  32. +S: Maintained
  33. +F: drivers/net/phy/mediatek-ge-soc.c
  34. +F: drivers/net/phy/mediatek-ge.c
  35. +
  36. MEDIATEK I2C CONTROLLER DRIVER
  37. M: Qii Wang <[email protected]>
  38. L: [email protected]
  39. --- a/drivers/net/phy/Kconfig
  40. +++ b/drivers/net/phy/Kconfig
  41. @@ -311,6 +311,18 @@ config MEDIATEK_GE_PHY
  42. help
  43. Supports the MediaTek Gigabit Ethernet PHYs.
  44. +config MEDIATEK_GE_SOC_PHY
  45. + tristate "MediaTek SoC Ethernet PHYs"
  46. + depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST
  47. + select NVMEM_MTK_EFUSE
  48. + help
  49. + Supports MediaTek SoC built-in Gigabit Ethernet PHYs.
  50. +
  51. + Include support for built-in Ethernet PHYs which are present in
  52. + the MT7981 and MT7988 SoCs. These PHYs need calibration data
  53. + present in the SoCs efuse and will dynamically calibrate VCM
  54. + (common-mode voltage) during startup.
  55. +
  56. config MICREL_PHY
  57. tristate "Micrel PHYs"
  58. depends on PTP_1588_CLOCK_OPTIONAL
  59. --- a/drivers/net/phy/Makefile
  60. +++ b/drivers/net/phy/Makefile
  61. @@ -80,6 +80,7 @@ obj-$(CONFIG_MARVELL_PHY) += marvell.o
  62. obj-$(CONFIG_MARVELL_88X2222_PHY) += marvell-88x2222.o
  63. obj-$(CONFIG_MAXLINEAR_GPHY) += mxl-gpy.o
  64. obj-$(CONFIG_MEDIATEK_GE_PHY) += mediatek-ge.o
  65. +obj-$(CONFIG_MEDIATEK_GE_SOC_PHY) += mediatek-ge-soc.o
  66. obj-$(CONFIG_MESON_GXL_PHY) += meson-gxl.o
  67. obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o
  68. obj-$(CONFIG_MICREL_PHY) += micrel.o
  69. --- /dev/null
  70. +++ b/drivers/net/phy/mediatek-ge-soc.c
  71. @@ -0,0 +1,1116 @@
  72. +// SPDX-License-Identifier: GPL-2.0+
  73. +#include <linux/bitfield.h>
  74. +#include <linux/module.h>
  75. +#include <linux/nvmem-consumer.h>
  76. +#include <linux/of_address.h>
  77. +#include <linux/of_platform.h>
  78. +#include <linux/pinctrl/consumer.h>
  79. +#include <linux/phy.h>
  80. +
  81. +#define MTK_GPHY_ID_MT7981 0x03a29461
  82. +#define MTK_GPHY_ID_MT7988 0x03a29481
  83. +
  84. +#define MTK_EXT_PAGE_ACCESS 0x1f
  85. +#define MTK_PHY_PAGE_STANDARD 0x0000
  86. +#define MTK_PHY_PAGE_EXTENDED_3 0x0003
  87. +
  88. +#define MTK_PHY_LPI_REG_14 0x14
  89. +#define MTK_PHY_LPI_WAKE_TIMER_1000_MASK GENMASK(8, 0)
  90. +
  91. +#define MTK_PHY_LPI_REG_1c 0x1c
  92. +#define MTK_PHY_SMI_DET_ON_THRESH_MASK GENMASK(13, 8)
  93. +
  94. +#define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30
  95. +#define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5
  96. +
  97. +#define ANALOG_INTERNAL_OPERATION_MAX_US 20
  98. +#define TXRESERVE_MIN 0
  99. +#define TXRESERVE_MAX 7
  100. +
  101. +#define MTK_PHY_ANARG_RG 0x10
  102. +#define MTK_PHY_TCLKOFFSET_MASK GENMASK(12, 8)
  103. +
  104. +/* Registers on MDIO_MMD_VEND1 */
  105. +#define MTK_PHY_TXVLD_DA_RG 0x12
  106. +#define MTK_PHY_DA_TX_I2MPB_A_GBE_MASK GENMASK(15, 10)
  107. +#define MTK_PHY_DA_TX_I2MPB_A_TBT_MASK GENMASK(5, 0)
  108. +
  109. +#define MTK_PHY_TX_I2MPB_TEST_MODE_A2 0x16
  110. +#define MTK_PHY_DA_TX_I2MPB_A_HBT_MASK GENMASK(15, 10)
  111. +#define MTK_PHY_DA_TX_I2MPB_A_TST_MASK GENMASK(5, 0)
  112. +
  113. +#define MTK_PHY_TX_I2MPB_TEST_MODE_B1 0x17
  114. +#define MTK_PHY_DA_TX_I2MPB_B_GBE_MASK GENMASK(13, 8)
  115. +#define MTK_PHY_DA_TX_I2MPB_B_TBT_MASK GENMASK(5, 0)
  116. +
  117. +#define MTK_PHY_TX_I2MPB_TEST_MODE_B2 0x18
  118. +#define MTK_PHY_DA_TX_I2MPB_B_HBT_MASK GENMASK(13, 8)
  119. +#define MTK_PHY_DA_TX_I2MPB_B_TST_MASK GENMASK(5, 0)
  120. +
  121. +#define MTK_PHY_TX_I2MPB_TEST_MODE_C1 0x19
  122. +#define MTK_PHY_DA_TX_I2MPB_C_GBE_MASK GENMASK(13, 8)
  123. +#define MTK_PHY_DA_TX_I2MPB_C_TBT_MASK GENMASK(5, 0)
  124. +
  125. +#define MTK_PHY_TX_I2MPB_TEST_MODE_C2 0x20
  126. +#define MTK_PHY_DA_TX_I2MPB_C_HBT_MASK GENMASK(13, 8)
  127. +#define MTK_PHY_DA_TX_I2MPB_C_TST_MASK GENMASK(5, 0)
  128. +
  129. +#define MTK_PHY_TX_I2MPB_TEST_MODE_D1 0x21
  130. +#define MTK_PHY_DA_TX_I2MPB_D_GBE_MASK GENMASK(13, 8)
  131. +#define MTK_PHY_DA_TX_I2MPB_D_TBT_MASK GENMASK(5, 0)
  132. +
  133. +#define MTK_PHY_TX_I2MPB_TEST_MODE_D2 0x22
  134. +#define MTK_PHY_DA_TX_I2MPB_D_HBT_MASK GENMASK(13, 8)
  135. +#define MTK_PHY_DA_TX_I2MPB_D_TST_MASK GENMASK(5, 0)
  136. +
  137. +#define MTK_PHY_RXADC_CTRL_RG7 0xc6
  138. +#define MTK_PHY_DA_AD_BUF_BIAS_LP_MASK GENMASK(9, 8)
  139. +
  140. +#define MTK_PHY_RXADC_CTRL_RG9 0xc8
  141. +#define MTK_PHY_DA_RX_PSBN_TBT_MASK GENMASK(14, 12)
  142. +#define MTK_PHY_DA_RX_PSBN_HBT_MASK GENMASK(10, 8)
  143. +#define MTK_PHY_DA_RX_PSBN_GBE_MASK GENMASK(6, 4)
  144. +#define MTK_PHY_DA_RX_PSBN_LP_MASK GENMASK(2, 0)
  145. +
  146. +#define MTK_PHY_LDO_OUTPUT_V 0xd7
  147. +
  148. +#define MTK_PHY_RG_ANA_CAL_RG0 0xdb
  149. +#define MTK_PHY_RG_CAL_CKINV BIT(12)
  150. +#define MTK_PHY_RG_ANA_CALEN BIT(8)
  151. +#define MTK_PHY_RG_ZCALEN_A BIT(0)
  152. +
  153. +#define MTK_PHY_RG_ANA_CAL_RG1 0xdc
  154. +#define MTK_PHY_RG_ZCALEN_B BIT(12)
  155. +#define MTK_PHY_RG_ZCALEN_C BIT(8)
  156. +#define MTK_PHY_RG_ZCALEN_D BIT(4)
  157. +#define MTK_PHY_RG_TXVOS_CALEN BIT(0)
  158. +
  159. +#define MTK_PHY_RG_ANA_CAL_RG5 0xe0
  160. +#define MTK_PHY_RG_REXT_TRIM_MASK GENMASK(13, 8)
  161. +
  162. +#define MTK_PHY_RG_TX_FILTER 0xfe
  163. +
  164. +#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120 0x120
  165. +#define MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK GENMASK(12, 8)
  166. +#define MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK GENMASK(4, 0)
  167. +
  168. +#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122 0x122
  169. +#define MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK GENMASK(7, 0)
  170. +
  171. +#define MTK_PHY_RG_TESTMUX_ADC_CTRL 0x144
  172. +#define MTK_PHY_RG_TXEN_DIG_MASK GENMASK(5, 5)
  173. +
  174. +#define MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B 0x172
  175. +#define MTK_PHY_CR_TX_AMP_OFFSET_A_MASK GENMASK(13, 8)
  176. +#define MTK_PHY_CR_TX_AMP_OFFSET_B_MASK GENMASK(6, 0)
  177. +
  178. +#define MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D 0x173
  179. +#define MTK_PHY_CR_TX_AMP_OFFSET_C_MASK GENMASK(13, 8)
  180. +#define MTK_PHY_CR_TX_AMP_OFFSET_D_MASK GENMASK(6, 0)
  181. +
  182. +#define MTK_PHY_RG_AD_CAL_COMP 0x17a
  183. +#define MTK_PHY_AD_CAL_COMP_OUT_SHIFT (8)
  184. +
  185. +#define MTK_PHY_RG_AD_CAL_CLK 0x17b
  186. +#define MTK_PHY_DA_CAL_CLK BIT(0)
  187. +
  188. +#define MTK_PHY_RG_AD_CALIN 0x17c
  189. +#define MTK_PHY_DA_CALIN_FLAG BIT(0)
  190. +
  191. +#define MTK_PHY_RG_DASN_DAC_IN0_A 0x17d
  192. +#define MTK_PHY_DASN_DAC_IN0_A_MASK GENMASK(9, 0)
  193. +
  194. +#define MTK_PHY_RG_DASN_DAC_IN0_B 0x17e
  195. +#define MTK_PHY_DASN_DAC_IN0_B_MASK GENMASK(9, 0)
  196. +
  197. +#define MTK_PHY_RG_DASN_DAC_IN0_C 0x17f
  198. +#define MTK_PHY_DASN_DAC_IN0_C_MASK GENMASK(9, 0)
  199. +
  200. +#define MTK_PHY_RG_DASN_DAC_IN0_D 0x180
  201. +#define MTK_PHY_DASN_DAC_IN0_D_MASK GENMASK(9, 0)
  202. +
  203. +#define MTK_PHY_RG_DASN_DAC_IN1_A 0x181
  204. +#define MTK_PHY_DASN_DAC_IN1_A_MASK GENMASK(9, 0)
  205. +
  206. +#define MTK_PHY_RG_DASN_DAC_IN1_B 0x182
  207. +#define MTK_PHY_DASN_DAC_IN1_B_MASK GENMASK(9, 0)
  208. +
  209. +#define MTK_PHY_RG_DASN_DAC_IN1_C 0x183
  210. +#define MTK_PHY_DASN_DAC_IN1_C_MASK GENMASK(9, 0)
  211. +
  212. +#define MTK_PHY_RG_DASN_DAC_IN1_D 0x184
  213. +#define MTK_PHY_DASN_DAC_IN1_D_MASK GENMASK(9, 0)
  214. +
  215. +#define MTK_PHY_RG_DEV1E_REG19b 0x19b
  216. +#define MTK_PHY_BYPASS_DSP_LPI_READY BIT(8)
  217. +
  218. +#define MTK_PHY_RG_LP_IIR2_K1_L 0x22a
  219. +#define MTK_PHY_RG_LP_IIR2_K1_U 0x22b
  220. +#define MTK_PHY_RG_LP_IIR2_K2_L 0x22c
  221. +#define MTK_PHY_RG_LP_IIR2_K2_U 0x22d
  222. +#define MTK_PHY_RG_LP_IIR2_K3_L 0x22e
  223. +#define MTK_PHY_RG_LP_IIR2_K3_U 0x22f
  224. +#define MTK_PHY_RG_LP_IIR2_K4_L 0x230
  225. +#define MTK_PHY_RG_LP_IIR2_K4_U 0x231
  226. +#define MTK_PHY_RG_LP_IIR2_K5_L 0x232
  227. +#define MTK_PHY_RG_LP_IIR2_K5_U 0x233
  228. +
  229. +#define MTK_PHY_RG_DEV1E_REG234 0x234
  230. +#define MTK_PHY_TR_OPEN_LOOP_EN_MASK GENMASK(0, 0)
  231. +#define MTK_PHY_LPF_X_AVERAGE_MASK GENMASK(7, 4)
  232. +#define MTK_PHY_TR_LP_IIR_EEE_EN BIT(12)
  233. +
  234. +#define MTK_PHY_RG_LPF_CNT_VAL 0x235
  235. +
  236. +#define MTK_PHY_RG_DEV1E_REG238 0x238
  237. +#define MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK GENMASK(8, 0)
  238. +#define MTK_PHY_LPI_SLV_SEND_TX_EN BIT(12)
  239. +
  240. +#define MTK_PHY_RG_DEV1E_REG239 0x239
  241. +#define MTK_PHY_LPI_SEND_LOC_TIMER_MASK GENMASK(8, 0)
  242. +#define MTK_PHY_LPI_TXPCS_LOC_RCV BIT(12)
  243. +
  244. +#define MTK_PHY_RG_DEV1E_REG27C 0x27c
  245. +#define MTK_PHY_VGASTATE_FFE_THR_ST1_MASK GENMASK(12, 8)
  246. +#define MTK_PHY_RG_DEV1E_REG27D 0x27d
  247. +#define MTK_PHY_VGASTATE_FFE_THR_ST2_MASK GENMASK(4, 0)
  248. +
  249. +#define MTK_PHY_RG_DEV1E_REG2C7 0x2c7
  250. +#define MTK_PHY_MAX_GAIN_MASK GENMASK(4, 0)
  251. +#define MTK_PHY_MIN_GAIN_MASK GENMASK(12, 8)
  252. +
  253. +#define MTK_PHY_RG_DEV1E_REG2D1 0x2d1
  254. +#define MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK GENMASK(7, 0)
  255. +#define MTK_PHY_LPI_SKIP_SD_SLV_TR BIT(8)
  256. +#define MTK_PHY_LPI_TR_READY BIT(9)
  257. +#define MTK_PHY_LPI_VCO_EEE_STG0_EN BIT(10)
  258. +
  259. +#define MTK_PHY_RG_DEV1E_REG323 0x323
  260. +#define MTK_PHY_EEE_WAKE_MAS_INT_DC BIT(0)
  261. +#define MTK_PHY_EEE_WAKE_SLV_INT_DC BIT(4)
  262. +
  263. +#define MTK_PHY_RG_DEV1E_REG324 0x324
  264. +#define MTK_PHY_SMI_DETCNT_MAX_MASK GENMASK(5, 0)
  265. +#define MTK_PHY_SMI_DET_MAX_EN BIT(8)
  266. +
  267. +#define MTK_PHY_RG_DEV1E_REG326 0x326
  268. +#define MTK_PHY_LPI_MODE_SD_ON BIT(0)
  269. +#define MTK_PHY_RESET_RANDUPD_CNT BIT(1)
  270. +#define MTK_PHY_TREC_UPDATE_ENAB_CLR BIT(2)
  271. +#define MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF BIT(4)
  272. +#define MTK_PHY_TR_READY_SKIP_AFE_WAKEUP BIT(5)
  273. +
  274. +#define MTK_PHY_LDO_PUMP_EN_PAIRAB 0x502
  275. +#define MTK_PHY_LDO_PUMP_EN_PAIRCD 0x503
  276. +
  277. +#define MTK_PHY_DA_TX_R50_PAIR_A 0x53d
  278. +#define MTK_PHY_DA_TX_R50_PAIR_B 0x53e
  279. +#define MTK_PHY_DA_TX_R50_PAIR_C 0x53f
  280. +#define MTK_PHY_DA_TX_R50_PAIR_D 0x540
  281. +
  282. +#define MTK_PHY_RG_BG_RASEL 0x115
  283. +#define MTK_PHY_RG_BG_RASEL_MASK GENMASK(2, 0)
  284. +
  285. +/* These macro privides efuse parsing for internal phy. */
  286. +#define EFS_DA_TX_I2MPB_A(x) (((x) >> 0) & GENMASK(5, 0))
  287. +#define EFS_DA_TX_I2MPB_B(x) (((x) >> 6) & GENMASK(5, 0))
  288. +#define EFS_DA_TX_I2MPB_C(x) (((x) >> 12) & GENMASK(5, 0))
  289. +#define EFS_DA_TX_I2MPB_D(x) (((x) >> 18) & GENMASK(5, 0))
  290. +#define EFS_DA_TX_AMP_OFFSET_A(x) (((x) >> 24) & GENMASK(5, 0))
  291. +
  292. +#define EFS_DA_TX_AMP_OFFSET_B(x) (((x) >> 0) & GENMASK(5, 0))
  293. +#define EFS_DA_TX_AMP_OFFSET_C(x) (((x) >> 6) & GENMASK(5, 0))
  294. +#define EFS_DA_TX_AMP_OFFSET_D(x) (((x) >> 12) & GENMASK(5, 0))
  295. +#define EFS_DA_TX_R50_A(x) (((x) >> 18) & GENMASK(5, 0))
  296. +#define EFS_DA_TX_R50_B(x) (((x) >> 24) & GENMASK(5, 0))
  297. +
  298. +#define EFS_DA_TX_R50_C(x) (((x) >> 0) & GENMASK(5, 0))
  299. +#define EFS_DA_TX_R50_D(x) (((x) >> 6) & GENMASK(5, 0))
  300. +
  301. +#define EFS_RG_BG_RASEL(x) (((x) >> 4) & GENMASK(2, 0))
  302. +#define EFS_RG_REXT_TRIM(x) (((x) >> 7) & GENMASK(5, 0))
  303. +
  304. +enum {
  305. + NO_PAIR,
  306. + PAIR_A,
  307. + PAIR_B,
  308. + PAIR_C,
  309. + PAIR_D,
  310. +};
  311. +
  312. +enum {
  313. + GPHY_PORT0,
  314. + GPHY_PORT1,
  315. + GPHY_PORT2,
  316. + GPHY_PORT3,
  317. +};
  318. +
  319. +enum calibration_mode {
  320. + EFUSE_K,
  321. + SW_K
  322. +};
  323. +
  324. +enum CAL_ITEM {
  325. + REXT,
  326. + TX_OFFSET,
  327. + TX_AMP,
  328. + TX_R50,
  329. + TX_VCM
  330. +};
  331. +
  332. +enum CAL_MODE {
  333. + EFUSE_M,
  334. + SW_M
  335. +};
  336. +
  337. +static int mtk_socphy_read_page(struct phy_device *phydev)
  338. +{
  339. + return __phy_read(phydev, MTK_EXT_PAGE_ACCESS);
  340. +}
  341. +
  342. +static int mtk_socphy_write_page(struct phy_device *phydev, int page)
  343. +{
  344. + return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page);
  345. +}
  346. +
  347. +/* One calibration cycle consists of:
  348. + * 1.Set DA_CALIN_FLAG high to start calibration. Keep it high
  349. + * until AD_CAL_COMP is ready to output calibration result.
  350. + * 2.Wait until DA_CAL_CLK is available.
  351. + * 3.Fetch AD_CAL_COMP_OUT.
  352. + */
  353. +static int cal_cycle(struct phy_device *phydev, int devad,
  354. + u32 regnum, u16 mask, u16 cal_val)
  355. +{
  356. + int reg_val;
  357. + int ret;
  358. +
  359. + phy_modify_mmd(phydev, devad, regnum,
  360. + mask, cal_val);
  361. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN,
  362. + MTK_PHY_DA_CALIN_FLAG);
  363. +
  364. + ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1,
  365. + MTK_PHY_RG_AD_CAL_CLK, reg_val,
  366. + reg_val & MTK_PHY_DA_CAL_CLK, 500,
  367. + ANALOG_INTERNAL_OPERATION_MAX_US, false);
  368. + if (ret) {
  369. + phydev_err(phydev, "Calibration cycle timeout\n");
  370. + return ret;
  371. + }
  372. +
  373. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN,
  374. + MTK_PHY_DA_CALIN_FLAG);
  375. + ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CAL_COMP) >>
  376. + MTK_PHY_AD_CAL_COMP_OUT_SHIFT;
  377. + phydev_dbg(phydev, "cal_val: 0x%x, ret: %d\n", cal_val, ret);
  378. +
  379. + return ret;
  380. +}
  381. +
  382. +static int rext_fill_result(struct phy_device *phydev, u16 *buf)
  383. +{
  384. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5,
  385. + MTK_PHY_RG_REXT_TRIM_MASK, buf[0] << 8);
  386. + phy_modify_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_RG_BG_RASEL,
  387. + MTK_PHY_RG_BG_RASEL_MASK, buf[1]);
  388. +
  389. + return 0;
  390. +}
  391. +
  392. +static int rext_cal_efuse(struct phy_device *phydev, u32 *buf)
  393. +{
  394. + u16 rext_cal_val[2];
  395. +
  396. + rext_cal_val[0] = EFS_RG_REXT_TRIM(buf[3]);
  397. + rext_cal_val[1] = EFS_RG_BG_RASEL(buf[3]);
  398. + rext_fill_result(phydev, rext_cal_val);
  399. +
  400. + return 0;
  401. +}
  402. +
  403. +static int tx_offset_fill_result(struct phy_device *phydev, u16 *buf)
  404. +{
  405. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B,
  406. + MTK_PHY_CR_TX_AMP_OFFSET_A_MASK, buf[0] << 8);
  407. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B,
  408. + MTK_PHY_CR_TX_AMP_OFFSET_B_MASK, buf[1]);
  409. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D,
  410. + MTK_PHY_CR_TX_AMP_OFFSET_C_MASK, buf[2] << 8);
  411. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D,
  412. + MTK_PHY_CR_TX_AMP_OFFSET_D_MASK, buf[3]);
  413. +
  414. + return 0;
  415. +}
  416. +
  417. +static int tx_offset_cal_efuse(struct phy_device *phydev, u32 *buf)
  418. +{
  419. + u16 tx_offset_cal_val[4];
  420. +
  421. + tx_offset_cal_val[0] = EFS_DA_TX_AMP_OFFSET_A(buf[0]);
  422. + tx_offset_cal_val[1] = EFS_DA_TX_AMP_OFFSET_B(buf[1]);
  423. + tx_offset_cal_val[2] = EFS_DA_TX_AMP_OFFSET_C(buf[1]);
  424. + tx_offset_cal_val[3] = EFS_DA_TX_AMP_OFFSET_D(buf[1]);
  425. +
  426. + tx_offset_fill_result(phydev, tx_offset_cal_val);
  427. +
  428. + return 0;
  429. +}
  430. +
  431. +static int tx_amp_fill_result(struct phy_device *phydev, u16 *buf)
  432. +{
  433. + int i;
  434. + int bias[16] = {};
  435. + const int vals_9461[16] = { 7, 1, 4, 7,
  436. + 7, 1, 4, 7,
  437. + 7, 1, 4, 7,
  438. + 7, 1, 4, 7 };
  439. + const int vals_9481[16] = { 10, 6, 6, 10,
  440. + 10, 6, 6, 10,
  441. + 10, 6, 6, 10,
  442. + 10, 6, 6, 10 };
  443. + switch (phydev->drv->phy_id) {
  444. + case MTK_GPHY_ID_MT7981:
  445. + /* We add some calibration to efuse values
  446. + * due to board level influence.
  447. + * GBE: +7, TBT: +1, HBT: +4, TST: +7
  448. + */
  449. + memcpy(bias, (const void *)vals_9461, sizeof(bias));
  450. + break;
  451. + case MTK_GPHY_ID_MT7988:
  452. + memcpy(bias, (const void *)vals_9481, sizeof(bias));
  453. + break;
  454. + }
  455. +
  456. + /* Prevent overflow */
  457. + for (i = 0; i < 12; i++) {
  458. + if (buf[i >> 2] + bias[i] > 63) {
  459. + buf[i >> 2] = 63;
  460. + bias[i] = 0;
  461. + }
  462. + }
  463. +
  464. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG,
  465. + MTK_PHY_DA_TX_I2MPB_A_GBE_MASK, (buf[0] + bias[0]) << 10);
  466. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG,
  467. + MTK_PHY_DA_TX_I2MPB_A_TBT_MASK, buf[0] + bias[1]);
  468. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2,
  469. + MTK_PHY_DA_TX_I2MPB_A_HBT_MASK, (buf[0] + bias[2]) << 10);
  470. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2,
  471. + MTK_PHY_DA_TX_I2MPB_A_TST_MASK, buf[0] + bias[3]);
  472. +
  473. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1,
  474. + MTK_PHY_DA_TX_I2MPB_B_GBE_MASK, (buf[1] + bias[4]) << 8);
  475. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1,
  476. + MTK_PHY_DA_TX_I2MPB_B_TBT_MASK, buf[1] + bias[5]);
  477. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2,
  478. + MTK_PHY_DA_TX_I2MPB_B_HBT_MASK, (buf[1] + bias[6]) << 8);
  479. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2,
  480. + MTK_PHY_DA_TX_I2MPB_B_TST_MASK, buf[1] + bias[7]);
  481. +
  482. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1,
  483. + MTK_PHY_DA_TX_I2MPB_C_GBE_MASK, (buf[2] + bias[8]) << 8);
  484. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1,
  485. + MTK_PHY_DA_TX_I2MPB_C_TBT_MASK, buf[2] + bias[9]);
  486. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2,
  487. + MTK_PHY_DA_TX_I2MPB_C_HBT_MASK, (buf[2] + bias[10]) << 8);
  488. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2,
  489. + MTK_PHY_DA_TX_I2MPB_C_TST_MASK, buf[2] + bias[11]);
  490. +
  491. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1,
  492. + MTK_PHY_DA_TX_I2MPB_D_GBE_MASK, (buf[3] + bias[12]) << 8);
  493. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1,
  494. + MTK_PHY_DA_TX_I2MPB_D_TBT_MASK, buf[3] + bias[13]);
  495. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2,
  496. + MTK_PHY_DA_TX_I2MPB_D_HBT_MASK, (buf[3] + bias[14]) << 8);
  497. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2,
  498. + MTK_PHY_DA_TX_I2MPB_D_TST_MASK, buf[3] + bias[15]);
  499. +
  500. + return 0;
  501. +}
  502. +
  503. +static int tx_amp_cal_efuse(struct phy_device *phydev, u32 *buf)
  504. +{
  505. + u16 tx_amp_cal_val[4];
  506. +
  507. + tx_amp_cal_val[0] = EFS_DA_TX_I2MPB_A(buf[0]);
  508. + tx_amp_cal_val[1] = EFS_DA_TX_I2MPB_B(buf[0]);
  509. + tx_amp_cal_val[2] = EFS_DA_TX_I2MPB_C(buf[0]);
  510. + tx_amp_cal_val[3] = EFS_DA_TX_I2MPB_D(buf[0]);
  511. + tx_amp_fill_result(phydev, tx_amp_cal_val);
  512. +
  513. + return 0;
  514. +}
  515. +
  516. +static int tx_r50_fill_result(struct phy_device *phydev, u16 tx_r50_cal_val,
  517. + u8 txg_calen_x)
  518. +{
  519. + int bias = 0;
  520. + u16 reg, val;
  521. +
  522. + if (phydev->drv->phy_id == MTK_GPHY_ID_MT7988)
  523. + bias = -2;
  524. +
  525. + val = clamp_val(bias + tx_r50_cal_val, 0, 63);
  526. +
  527. + switch (txg_calen_x) {
  528. + case PAIR_A:
  529. + reg = MTK_PHY_DA_TX_R50_PAIR_A;
  530. + break;
  531. + case PAIR_B:
  532. + reg = MTK_PHY_DA_TX_R50_PAIR_B;
  533. + break;
  534. + case PAIR_C:
  535. + reg = MTK_PHY_DA_TX_R50_PAIR_C;
  536. + break;
  537. + case PAIR_D:
  538. + reg = MTK_PHY_DA_TX_R50_PAIR_D;
  539. + break;
  540. + default:
  541. + return -EINVAL;
  542. + }
  543. +
  544. + phy_write_mmd(phydev, MDIO_MMD_VEND1, reg, val | val << 8);
  545. +
  546. + return 0;
  547. +}
  548. +
  549. +static int tx_r50_cal_efuse(struct phy_device *phydev, u32 *buf,
  550. + u8 txg_calen_x)
  551. +{
  552. + u16 tx_r50_cal_val;
  553. +
  554. + switch (txg_calen_x) {
  555. + case PAIR_A:
  556. + tx_r50_cal_val = EFS_DA_TX_R50_A(buf[1]);
  557. + break;
  558. + case PAIR_B:
  559. + tx_r50_cal_val = EFS_DA_TX_R50_B(buf[1]);
  560. + break;
  561. + case PAIR_C:
  562. + tx_r50_cal_val = EFS_DA_TX_R50_C(buf[2]);
  563. + break;
  564. + case PAIR_D:
  565. + tx_r50_cal_val = EFS_DA_TX_R50_D(buf[2]);
  566. + break;
  567. + default:
  568. + return -EINVAL;
  569. + }
  570. + tx_r50_fill_result(phydev, tx_r50_cal_val, txg_calen_x);
  571. +
  572. + return 0;
  573. +}
  574. +
  575. +static int tx_vcm_cal_sw(struct phy_device *phydev, u8 rg_txreserve_x)
  576. +{
  577. + u8 lower_idx, upper_idx, txreserve_val;
  578. + u8 lower_ret, upper_ret;
  579. + int ret;
  580. +
  581. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
  582. + MTK_PHY_RG_ANA_CALEN);
  583. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
  584. + MTK_PHY_RG_CAL_CKINV);
  585. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1,
  586. + MTK_PHY_RG_TXVOS_CALEN);
  587. +
  588. + switch (rg_txreserve_x) {
  589. + case PAIR_A:
  590. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  591. + MTK_PHY_RG_DASN_DAC_IN0_A,
  592. + MTK_PHY_DASN_DAC_IN0_A_MASK);
  593. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  594. + MTK_PHY_RG_DASN_DAC_IN1_A,
  595. + MTK_PHY_DASN_DAC_IN1_A_MASK);
  596. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
  597. + MTK_PHY_RG_ANA_CAL_RG0,
  598. + MTK_PHY_RG_ZCALEN_A);
  599. + break;
  600. + case PAIR_B:
  601. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  602. + MTK_PHY_RG_DASN_DAC_IN0_B,
  603. + MTK_PHY_DASN_DAC_IN0_B_MASK);
  604. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  605. + MTK_PHY_RG_DASN_DAC_IN1_B,
  606. + MTK_PHY_DASN_DAC_IN1_B_MASK);
  607. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
  608. + MTK_PHY_RG_ANA_CAL_RG1,
  609. + MTK_PHY_RG_ZCALEN_B);
  610. + break;
  611. + case PAIR_C:
  612. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  613. + MTK_PHY_RG_DASN_DAC_IN0_C,
  614. + MTK_PHY_DASN_DAC_IN0_C_MASK);
  615. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  616. + MTK_PHY_RG_DASN_DAC_IN1_C,
  617. + MTK_PHY_DASN_DAC_IN1_C_MASK);
  618. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
  619. + MTK_PHY_RG_ANA_CAL_RG1,
  620. + MTK_PHY_RG_ZCALEN_C);
  621. + break;
  622. + case PAIR_D:
  623. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  624. + MTK_PHY_RG_DASN_DAC_IN0_D,
  625. + MTK_PHY_DASN_DAC_IN0_D_MASK);
  626. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  627. + MTK_PHY_RG_DASN_DAC_IN1_D,
  628. + MTK_PHY_DASN_DAC_IN1_D_MASK);
  629. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
  630. + MTK_PHY_RG_ANA_CAL_RG1,
  631. + MTK_PHY_RG_ZCALEN_D);
  632. + break;
  633. + default:
  634. + ret = -EINVAL;
  635. + goto restore;
  636. + }
  637. +
  638. + lower_idx = TXRESERVE_MIN;
  639. + upper_idx = TXRESERVE_MAX;
  640. +
  641. + phydev_dbg(phydev, "Start TX-VCM SW cal.\n");
  642. + while ((upper_idx - lower_idx) > 1) {
  643. + txreserve_val = DIV_ROUND_CLOSEST(lower_idx + upper_idx, 2);
  644. + ret = cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9,
  645. + MTK_PHY_DA_RX_PSBN_TBT_MASK |
  646. + MTK_PHY_DA_RX_PSBN_HBT_MASK |
  647. + MTK_PHY_DA_RX_PSBN_GBE_MASK |
  648. + MTK_PHY_DA_RX_PSBN_LP_MASK,
  649. + txreserve_val << 12 | txreserve_val << 8 |
  650. + txreserve_val << 4 | txreserve_val);
  651. + if (ret == 1) {
  652. + upper_idx = txreserve_val;
  653. + upper_ret = ret;
  654. + } else if (ret == 0) {
  655. + lower_idx = txreserve_val;
  656. + lower_ret = ret;
  657. + } else {
  658. + goto restore;
  659. + }
  660. + }
  661. +
  662. + if (lower_idx == TXRESERVE_MIN) {
  663. + lower_ret = cal_cycle(phydev, MDIO_MMD_VEND1,
  664. + MTK_PHY_RXADC_CTRL_RG9,
  665. + MTK_PHY_DA_RX_PSBN_TBT_MASK |
  666. + MTK_PHY_DA_RX_PSBN_HBT_MASK |
  667. + MTK_PHY_DA_RX_PSBN_GBE_MASK |
  668. + MTK_PHY_DA_RX_PSBN_LP_MASK,
  669. + lower_idx << 12 | lower_idx << 8 |
  670. + lower_idx << 4 | lower_idx);
  671. + ret = lower_ret;
  672. + } else if (upper_idx == TXRESERVE_MAX) {
  673. + upper_ret = cal_cycle(phydev, MDIO_MMD_VEND1,
  674. + MTK_PHY_RXADC_CTRL_RG9,
  675. + MTK_PHY_DA_RX_PSBN_TBT_MASK |
  676. + MTK_PHY_DA_RX_PSBN_HBT_MASK |
  677. + MTK_PHY_DA_RX_PSBN_GBE_MASK |
  678. + MTK_PHY_DA_RX_PSBN_LP_MASK,
  679. + upper_idx << 12 | upper_idx << 8 |
  680. + upper_idx << 4 | upper_idx);
  681. + ret = upper_ret;
  682. + }
  683. + if (ret < 0)
  684. + goto restore;
  685. +
  686. + /* We calibrate TX-VCM in different logic. Check upper index and then
  687. + * lower index. If this calibration is valid, apply lower index's result.
  688. + */
  689. + ret = upper_ret - lower_ret;
  690. + if (ret == 1) {
  691. + ret = 0;
  692. + /* Make sure we use upper_idx in our calibration system */
  693. + cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9,
  694. + MTK_PHY_DA_RX_PSBN_TBT_MASK |
  695. + MTK_PHY_DA_RX_PSBN_HBT_MASK |
  696. + MTK_PHY_DA_RX_PSBN_GBE_MASK |
  697. + MTK_PHY_DA_RX_PSBN_LP_MASK,
  698. + upper_idx << 12 | upper_idx << 8 |
  699. + upper_idx << 4 | upper_idx);
  700. + phydev_dbg(phydev, "TX-VCM SW cal result: 0x%x\n", upper_idx);
  701. + } else if (lower_idx == TXRESERVE_MIN && upper_ret == 1 &&
  702. + lower_ret == 1) {
  703. + ret = 0;
  704. + cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9,
  705. + MTK_PHY_DA_RX_PSBN_TBT_MASK |
  706. + MTK_PHY_DA_RX_PSBN_HBT_MASK |
  707. + MTK_PHY_DA_RX_PSBN_GBE_MASK |
  708. + MTK_PHY_DA_RX_PSBN_LP_MASK,
  709. + lower_idx << 12 | lower_idx << 8 |
  710. + lower_idx << 4 | lower_idx);
  711. + phydev_warn(phydev, "TX-VCM SW cal result at low margin 0x%x\n",
  712. + lower_idx);
  713. + } else if (upper_idx == TXRESERVE_MAX && upper_ret == 0 &&
  714. + lower_ret == 0) {
  715. + ret = 0;
  716. + phydev_warn(phydev, "TX-VCM SW cal result at high margin 0x%x\n",
  717. + upper_idx);
  718. + } else {
  719. + ret = -EINVAL;
  720. + }
  721. +
  722. +restore:
  723. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
  724. + MTK_PHY_RG_ANA_CALEN);
  725. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1,
  726. + MTK_PHY_RG_TXVOS_CALEN);
  727. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0,
  728. + MTK_PHY_RG_ZCALEN_A);
  729. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1,
  730. + MTK_PHY_RG_ZCALEN_B | MTK_PHY_RG_ZCALEN_C |
  731. + MTK_PHY_RG_ZCALEN_D);
  732. +
  733. + return ret;
  734. +}
  735. +
  736. +static void mt798x_phy_common_finetune(struct phy_device *phydev)
  737. +{
  738. + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);
  739. + /* EnabRandUpdTrig = 1 */
  740. + __phy_write(phydev, 0x11, 0x2f00);
  741. + __phy_write(phydev, 0x12, 0xe);
  742. + __phy_write(phydev, 0x10, 0x8fb0);
  743. +
  744. + /* NormMseLoThresh = 85 */
  745. + __phy_write(phydev, 0x11, 0x55a0);
  746. + __phy_write(phydev, 0x12, 0x0);
  747. + __phy_write(phydev, 0x10, 0x83aa);
  748. +
  749. + /* TrFreeze = 0 */
  750. + __phy_write(phydev, 0x11, 0x0);
  751. + __phy_write(phydev, 0x12, 0x0);
  752. + __phy_write(phydev, 0x10, 0x9686);
  753. +
  754. + /* SSTrKp1000Slv = 5 */
  755. + __phy_write(phydev, 0x11, 0xbaef);
  756. + __phy_write(phydev, 0x12, 0x2e);
  757. + __phy_write(phydev, 0x10, 0x968c);
  758. +
  759. + /* MrvlTrFix100Kp = 3, MrvlTrFix100Kf = 2,
  760. + * MrvlTrFix1000Kp = 3, MrvlTrFix1000Kf = 2
  761. + */
  762. + __phy_write(phydev, 0x11, 0xd10a);
  763. + __phy_write(phydev, 0x12, 0x34);
  764. + __phy_write(phydev, 0x10, 0x8f82);
  765. +
  766. + /* VcoSlicerThreshBitsHigh */
  767. + __phy_write(phydev, 0x11, 0x5555);
  768. + __phy_write(phydev, 0x12, 0x55);
  769. + __phy_write(phydev, 0x10, 0x8ec0);
  770. + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
  771. +
  772. + /* TR_OPEN_LOOP_EN = 1, lpf_x_average = 9*/
  773. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG234,
  774. + MTK_PHY_TR_OPEN_LOOP_EN_MASK | MTK_PHY_LPF_X_AVERAGE_MASK,
  775. + BIT(0) | FIELD_PREP(MTK_PHY_LPF_X_AVERAGE_MASK, 0x9));
  776. +
  777. + /* rg_tr_lpf_cnt_val = 512 */
  778. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LPF_CNT_VAL, 0x200);
  779. +
  780. + /* IIR2 related */
  781. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K1_L, 0x82);
  782. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K1_U, 0x0);
  783. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K2_L, 0x103);
  784. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K2_U, 0x0);
  785. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K3_L, 0x82);
  786. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K3_U, 0x0);
  787. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K4_L, 0xd177);
  788. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K4_U, 0x3);
  789. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K5_L, 0x2c82);
  790. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K5_U, 0xe);
  791. +
  792. + /* FFE peaking */
  793. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG27C,
  794. + MTK_PHY_VGASTATE_FFE_THR_ST1_MASK, 0x1b << 8);
  795. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG27D,
  796. + MTK_PHY_VGASTATE_FFE_THR_ST2_MASK, 0x1e);
  797. +
  798. + /* Disable LDO pump */
  799. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_PUMP_EN_PAIRAB, 0x0);
  800. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_PUMP_EN_PAIRCD, 0x0);
  801. + /* Adjust LDO output voltage */
  802. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_OUTPUT_V, 0x2222);
  803. +}
  804. +
  805. +static void mt7981_phy_finetune(struct phy_device *phydev)
  806. +{
  807. + u16 val[8] = { 0x01ce, 0x01c1,
  808. + 0x020f, 0x0202,
  809. + 0x03d0, 0x03c0,
  810. + 0x0013, 0x0005 };
  811. + int i, k;
  812. +
  813. + /* 100M eye finetune:
  814. + * Keep middle level of TX MLT3 shapper as default.
  815. + * Only change TX MLT3 overshoot level here.
  816. + */
  817. + for (k = 0, i = 1; i < 12; i++) {
  818. + if (i % 3 == 0)
  819. + continue;
  820. + phy_write_mmd(phydev, MDIO_MMD_VEND1, i, val[k++]);
  821. + }
  822. +
  823. + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);
  824. + /* SlvDSPreadyTime = 24, MasDSPreadyTime = 24 */
  825. + __phy_write(phydev, 0x11, 0xc71);
  826. + __phy_write(phydev, 0x12, 0xc);
  827. + __phy_write(phydev, 0x10, 0x8fae);
  828. +
  829. + /* ResetSyncOffset = 6 */
  830. + __phy_write(phydev, 0x11, 0x600);
  831. + __phy_write(phydev, 0x12, 0x0);
  832. + __phy_write(phydev, 0x10, 0x8fc0);
  833. +
  834. + /* VgaDecRate = 1 */
  835. + __phy_write(phydev, 0x11, 0x4c2a);
  836. + __phy_write(phydev, 0x12, 0x3e);
  837. + __phy_write(phydev, 0x10, 0x8fa4);
  838. +
  839. + /* FfeUpdGainForce = 4 */
  840. + __phy_write(phydev, 0x11, 0x240);
  841. + __phy_write(phydev, 0x12, 0x0);
  842. + __phy_write(phydev, 0x10, 0x9680);
  843. +
  844. + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
  845. +}
  846. +
  847. +static void mt7988_phy_finetune(struct phy_device *phydev)
  848. +{
  849. + u16 val[12] = { 0x0187, 0x01cd, 0x01c8, 0x0182,
  850. + 0x020d, 0x0206, 0x0384, 0x03d0,
  851. + 0x03c6, 0x030a, 0x0011, 0x0005 };
  852. + int i;
  853. +
  854. + /* Set default MLT3 shaper first */
  855. + for (i = 0; i < 12; i++)
  856. + phy_write_mmd(phydev, MDIO_MMD_VEND1, i, val[i]);
  857. +
  858. + /* TCT finetune */
  859. + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_TX_FILTER, 0x5);
  860. +
  861. + /* Disable TX power saving */
  862. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG7,
  863. + MTK_PHY_DA_AD_BUF_BIAS_LP_MASK, 0x3 << 8);
  864. +
  865. + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);
  866. +
  867. + /* SlvDSPreadyTime = 24, MasDSPreadyTime = 12 */
  868. + __phy_write(phydev, 0x11, 0x671);
  869. + __phy_write(phydev, 0x12, 0xc);
  870. + __phy_write(phydev, 0x10, 0x8fae);
  871. +
  872. + /* ResetSyncOffset = 5 */
  873. + __phy_write(phydev, 0x11, 0x500);
  874. + __phy_write(phydev, 0x12, 0x0);
  875. + __phy_write(phydev, 0x10, 0x8fc0);
  876. +
  877. + /* VgaDecRate is 1 at default on mt7988 */
  878. +
  879. + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
  880. +
  881. + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_2A30);
  882. + /* TxClkOffset = 2 */
  883. + __phy_modify(phydev, MTK_PHY_ANARG_RG, MTK_PHY_TCLKOFFSET_MASK,
  884. + FIELD_PREP(MTK_PHY_TCLKOFFSET_MASK, 0x2));
  885. + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
  886. +}
  887. +
  888. +static void mt798x_phy_eee(struct phy_device *phydev)
  889. +{
  890. + phy_modify_mmd(phydev, MDIO_MMD_VEND1,
  891. + MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120,
  892. + MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK |
  893. + MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK,
  894. + FIELD_PREP(MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK, 0x0) |
  895. + FIELD_PREP(MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK, 0x14));
  896. +
  897. + phy_modify_mmd(phydev, MDIO_MMD_VEND1,
  898. + MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122,
  899. + MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK,
  900. + FIELD_PREP(MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK,
  901. + 0xff));
  902. +
  903. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  904. + MTK_PHY_RG_TESTMUX_ADC_CTRL,
  905. + MTK_PHY_RG_TXEN_DIG_MASK);
  906. +
  907. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
  908. + MTK_PHY_RG_DEV1E_REG19b, MTK_PHY_BYPASS_DSP_LPI_READY);
  909. +
  910. + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
  911. + MTK_PHY_RG_DEV1E_REG234, MTK_PHY_TR_LP_IIR_EEE_EN);
  912. +
  913. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG238,
  914. + MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK |
  915. + MTK_PHY_LPI_SLV_SEND_TX_EN,
  916. + FIELD_PREP(MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK, 0x120));
  917. +
  918. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG239,
  919. + MTK_PHY_LPI_SEND_LOC_TIMER_MASK |
  920. + MTK_PHY_LPI_TXPCS_LOC_RCV,
  921. + FIELD_PREP(MTK_PHY_LPI_SEND_LOC_TIMER_MASK, 0x117));
  922. +
  923. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG2C7,
  924. + MTK_PHY_MAX_GAIN_MASK | MTK_PHY_MIN_GAIN_MASK,
  925. + FIELD_PREP(MTK_PHY_MAX_GAIN_MASK, 0x8) |
  926. + FIELD_PREP(MTK_PHY_MIN_GAIN_MASK, 0x13));
  927. +
  928. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG2D1,
  929. + MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK,
  930. + FIELD_PREP(MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK,
  931. + 0x33) |
  932. + MTK_PHY_LPI_SKIP_SD_SLV_TR | MTK_PHY_LPI_TR_READY |
  933. + MTK_PHY_LPI_VCO_EEE_STG0_EN);
  934. +
  935. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG323,
  936. + MTK_PHY_EEE_WAKE_MAS_INT_DC |
  937. + MTK_PHY_EEE_WAKE_SLV_INT_DC);
  938. +
  939. + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG324,
  940. + MTK_PHY_SMI_DETCNT_MAX_MASK,
  941. + FIELD_PREP(MTK_PHY_SMI_DETCNT_MAX_MASK, 0x3f) |
  942. + MTK_PHY_SMI_DET_MAX_EN);
  943. +
  944. + phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG326,
  945. + MTK_PHY_LPI_MODE_SD_ON | MTK_PHY_RESET_RANDUPD_CNT |
  946. + MTK_PHY_TREC_UPDATE_ENAB_CLR |
  947. + MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF |
  948. + MTK_PHY_TR_READY_SKIP_AFE_WAKEUP);
  949. +
  950. + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5);
  951. + /* Regsigdet_sel_1000 = 0 */
  952. + __phy_write(phydev, 0x11, 0xb);
  953. + __phy_write(phydev, 0x12, 0x0);
  954. + __phy_write(phydev, 0x10, 0x9690);
  955. +
  956. + /* REG_EEE_st2TrKf1000 = 3 */
  957. + __phy_write(phydev, 0x11, 0x114f);
  958. + __phy_write(phydev, 0x12, 0x2);
  959. + __phy_write(phydev, 0x10, 0x969a);
  960. +
  961. + /* RegEEE_slv_wake_tr_timer_tar = 6, RegEEE_slv_remtx_timer_tar = 20 */
  962. + __phy_write(phydev, 0x11, 0x3028);
  963. + __phy_write(phydev, 0x12, 0x0);
  964. + __phy_write(phydev, 0x10, 0x969e);
  965. +
  966. + /* RegEEE_slv_wake_int_timer_tar = 8 */
  967. + __phy_write(phydev, 0x11, 0x5010);
  968. + __phy_write(phydev, 0x12, 0x0);
  969. + __phy_write(phydev, 0x10, 0x96a0);
  970. +
  971. + /* RegEEE_trfreeze_timer2 = 586 */
  972. + __phy_write(phydev, 0x11, 0x24a);
  973. + __phy_write(phydev, 0x12, 0x0);
  974. + __phy_write(phydev, 0x10, 0x96a8);
  975. +
  976. + /* RegEEE100Stg1_tar = 16 */
  977. + __phy_write(phydev, 0x11, 0x3210);
  978. + __phy_write(phydev, 0x12, 0x0);
  979. + __phy_write(phydev, 0x10, 0x96b8);
  980. +
  981. + /* REGEEE_wake_slv_tr_wait_dfesigdet_en = 1 */
  982. + __phy_write(phydev, 0x11, 0x1463);
  983. + __phy_write(phydev, 0x12, 0x0);
  984. + __phy_write(phydev, 0x10, 0x96ca);
  985. +
  986. + /* DfeTailEnableVgaThresh1000 = 27 */
  987. + __phy_write(phydev, 0x11, 0x36);
  988. + __phy_write(phydev, 0x12, 0x0);
  989. + __phy_write(phydev, 0x10, 0x8f80);
  990. + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
  991. +
  992. + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_3);
  993. + __phy_modify(phydev, MTK_PHY_LPI_REG_14, MTK_PHY_LPI_WAKE_TIMER_1000_MASK,
  994. + FIELD_PREP(MTK_PHY_LPI_WAKE_TIMER_1000_MASK, 0x19c));
  995. +
  996. + __phy_modify(phydev, MTK_PHY_LPI_REG_1c, MTK_PHY_SMI_DET_ON_THRESH_MASK,
  997. + FIELD_PREP(MTK_PHY_SMI_DET_ON_THRESH_MASK, 0xc));
  998. + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0);
  999. +
  1000. + phy_modify_mmd(phydev, MDIO_MMD_VEND1,
  1001. + MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122,
  1002. + MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK,
  1003. + FIELD_PREP(MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, 0xff));
  1004. +}
  1005. +
  1006. +static int cal_sw(struct phy_device *phydev, enum CAL_ITEM cal_item,
  1007. + u8 start_pair, u8 end_pair)
  1008. +{
  1009. + u8 pair_n;
  1010. + int ret;
  1011. +
  1012. + for (pair_n = start_pair; pair_n <= end_pair; pair_n++) {
  1013. + /* TX_OFFSET & TX_AMP have no SW calibration. */
  1014. + switch (cal_item) {
  1015. + case TX_VCM:
  1016. + ret = tx_vcm_cal_sw(phydev, pair_n);
  1017. + break;
  1018. + default:
  1019. + return -EINVAL;
  1020. + }
  1021. + if (ret)
  1022. + return ret;
  1023. + }
  1024. + return 0;
  1025. +}
  1026. +
  1027. +static int cal_efuse(struct phy_device *phydev, enum CAL_ITEM cal_item,
  1028. + u8 start_pair, u8 end_pair, u32 *buf)
  1029. +{
  1030. + u8 pair_n;
  1031. + int ret;
  1032. +
  1033. + for (pair_n = start_pair; pair_n <= end_pair; pair_n++) {
  1034. + /* TX_VCM has no efuse calibration. */
  1035. + switch (cal_item) {
  1036. + case REXT:
  1037. + ret = rext_cal_efuse(phydev, buf);
  1038. + break;
  1039. + case TX_OFFSET:
  1040. + ret = tx_offset_cal_efuse(phydev, buf);
  1041. + break;
  1042. + case TX_AMP:
  1043. + ret = tx_amp_cal_efuse(phydev, buf);
  1044. + break;
  1045. + case TX_R50:
  1046. + ret = tx_r50_cal_efuse(phydev, buf, pair_n);
  1047. + break;
  1048. + default:
  1049. + return -EINVAL;
  1050. + }
  1051. + if (ret)
  1052. + return ret;
  1053. + }
  1054. +
  1055. + return 0;
  1056. +}
  1057. +
  1058. +static int start_cal(struct phy_device *phydev, enum CAL_ITEM cal_item,
  1059. + enum CAL_MODE cal_mode, u8 start_pair,
  1060. + u8 end_pair, u32 *buf)
  1061. +{
  1062. + int ret;
  1063. +
  1064. + switch (cal_mode) {
  1065. + case EFUSE_M:
  1066. + ret = cal_efuse(phydev, cal_item, start_pair,
  1067. + end_pair, buf);
  1068. + break;
  1069. + case SW_M:
  1070. + ret = cal_sw(phydev, cal_item, start_pair, end_pair);
  1071. + break;
  1072. + default:
  1073. + return -EINVAL;
  1074. + }
  1075. +
  1076. + if (ret) {
  1077. + phydev_err(phydev, "cal %d failed\n", cal_item);
  1078. + return -EIO;
  1079. + }
  1080. +
  1081. + return 0;
  1082. +}
  1083. +
  1084. +static int mt798x_phy_calibration(struct phy_device *phydev)
  1085. +{
  1086. + int ret = 0;
  1087. + u32 *buf;
  1088. + size_t len;
  1089. + struct nvmem_cell *cell;
  1090. +
  1091. + cell = nvmem_cell_get(&phydev->mdio.dev, "phy-cal-data");
  1092. + if (IS_ERR(cell)) {
  1093. + if (PTR_ERR(cell) == -EPROBE_DEFER)
  1094. + return PTR_ERR(cell);
  1095. + return 0;
  1096. + }
  1097. +
  1098. + buf = (u32 *)nvmem_cell_read(cell, &len);
  1099. + if (IS_ERR(buf))
  1100. + return PTR_ERR(buf);
  1101. + nvmem_cell_put(cell);
  1102. +
  1103. + if (!buf[0] || !buf[1] || !buf[2] || !buf[3] || len < 4 * sizeof(u32)) {
  1104. + phydev_err(phydev, "invalid efuse data\n");
  1105. + ret = -EINVAL;
  1106. + goto out;
  1107. + }
  1108. +
  1109. + ret = start_cal(phydev, REXT, EFUSE_M, NO_PAIR, NO_PAIR, buf);
  1110. + if (ret)
  1111. + goto out;
  1112. + ret = start_cal(phydev, TX_OFFSET, EFUSE_M, NO_PAIR, NO_PAIR, buf);
  1113. + if (ret)
  1114. + goto out;
  1115. + ret = start_cal(phydev, TX_AMP, EFUSE_M, NO_PAIR, NO_PAIR, buf);
  1116. + if (ret)
  1117. + goto out;
  1118. + ret = start_cal(phydev, TX_R50, EFUSE_M, PAIR_A, PAIR_D, buf);
  1119. + if (ret)
  1120. + goto out;
  1121. + ret = start_cal(phydev, TX_VCM, SW_M, PAIR_A, PAIR_A, buf);
  1122. + if (ret)
  1123. + goto out;
  1124. +
  1125. +out:
  1126. + kfree(buf);
  1127. + return ret;
  1128. +}
  1129. +
  1130. +static int mt798x_phy_config_init(struct phy_device *phydev)
  1131. +{
  1132. + switch (phydev->drv->phy_id) {
  1133. + case MTK_GPHY_ID_MT7981:
  1134. + mt7981_phy_finetune(phydev);
  1135. + break;
  1136. + case MTK_GPHY_ID_MT7988:
  1137. + mt7988_phy_finetune(phydev);
  1138. + break;
  1139. + }
  1140. +
  1141. + mt798x_phy_common_finetune(phydev);
  1142. + mt798x_phy_eee(phydev);
  1143. +
  1144. + return mt798x_phy_calibration(phydev);
  1145. +}
  1146. +
  1147. +static struct phy_driver mtk_socphy_driver[] = {
  1148. + {
  1149. + PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981),
  1150. + .name = "MediaTek MT7981 PHY",
  1151. + .config_init = mt798x_phy_config_init,
  1152. + .config_intr = genphy_no_config_intr,
  1153. + .handle_interrupt = genphy_handle_interrupt_no_ack,
  1154. + .probe = mt798x_phy_calibration,
  1155. + .suspend = genphy_suspend,
  1156. + .resume = genphy_resume,
  1157. + .read_page = mtk_socphy_read_page,
  1158. + .write_page = mtk_socphy_write_page,
  1159. + },
  1160. + {
  1161. + PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988),
  1162. + .name = "MediaTek MT7988 PHY",
  1163. + .config_init = mt798x_phy_config_init,
  1164. + .config_intr = genphy_no_config_intr,
  1165. + .handle_interrupt = genphy_handle_interrupt_no_ack,
  1166. + .probe = mt798x_phy_calibration,
  1167. + .suspend = genphy_suspend,
  1168. + .resume = genphy_resume,
  1169. + .read_page = mtk_socphy_read_page,
  1170. + .write_page = mtk_socphy_write_page,
  1171. + },
  1172. +};
  1173. +
  1174. +module_phy_driver(mtk_socphy_driver);
  1175. +
  1176. +static struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = {
  1177. + { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981) },
  1178. + { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988) },
  1179. + { }
  1180. +};
  1181. +
  1182. +MODULE_DESCRIPTION("MediaTek SoC Gigabit Ethernet PHY driver");
  1183. +MODULE_AUTHOR("Daniel Golle <[email protected]>");
  1184. +MODULE_AUTHOR("SkyLake Huang <[email protected]>");
  1185. +MODULE_LICENSE("GPL");
  1186. +
  1187. +MODULE_DEVICE_TABLE(mdio, mtk_socphy_tbl);
  1188. --- a/drivers/net/phy/mediatek-ge.c
  1189. +++ b/drivers/net/phy/mediatek-ge.c
  1190. @@ -136,7 +136,8 @@ static struct phy_driver mtk_gephy_drive
  1191. module_phy_driver(mtk_gephy_driver);
  1192. static struct mdio_device_id __maybe_unused mtk_gephy_tbl[] = {
  1193. - { PHY_ID_MATCH_VENDOR(0x03a29400) },
  1194. + { PHY_ID_MATCH_EXACT(0x03a29441) },
  1195. + { PHY_ID_MATCH_EXACT(0x03a29412) },
  1196. { }
  1197. };