mt7530.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2017 Sean Wang <sean.wang@mediatek.com>
  4. */
  5. #ifndef __MT7530_H
  6. #define __MT7530_H
  7. #define MT7530_NUM_PORTS 7
  8. #define MT7530_NUM_PHYS 5
  9. #define MT7530_NUM_FDB_RECORDS 2048
  10. #define MT7530_ALL_MEMBERS 0xff
  11. #define MTK_HDR_LEN 4
  12. #define MT7530_MAX_MTU (15 * 1024 - ETH_HLEN - ETH_FCS_LEN - MTK_HDR_LEN)
  13. enum mt753x_id {
  14. ID_MT7530 = 0,
  15. ID_MT7621 = 1,
  16. ID_MT7531 = 2,
  17. ID_MT7988 = 3,
  18. ID_EN7581 = 4,
  19. ID_AN7583 = 5,
  20. };
  21. #define NUM_TRGMII_CTRL 5
  22. #define TRGMII_BASE(x) (0x10000 + (x))
  23. /* Registers to ethsys access */
  24. #define ETHSYS_CLKCFG0 0x2c
  25. #define ETHSYS_TRGMII_CLK_SEL362_5 BIT(11)
  26. #define SYSC_REG_RSTCTRL 0x34
  27. #define RESET_MCM BIT(2)
  28. /* Register for ARL global control */
  29. #define MT753X_AGC 0xc
  30. #define LOCAL_EN BIT(7)
  31. /* Register for MAC forward control */
  32. #define MT753X_MFC 0x10
  33. #define BC_FFP_MASK GENMASK(31, 24)
  34. #define BC_FFP(x) FIELD_PREP(BC_FFP_MASK, x)
  35. #define UNM_FFP_MASK GENMASK(23, 16)
  36. #define UNM_FFP(x) FIELD_PREP(UNM_FFP_MASK, x)
  37. #define UNU_FFP_MASK GENMASK(15, 8)
  38. #define UNU_FFP(x) FIELD_PREP(UNU_FFP_MASK, x)
  39. #define MT7530_CPU_EN BIT(7)
  40. #define MT7530_CPU_PORT_MASK GENMASK(6, 4)
  41. #define MT7530_CPU_PORT(x) FIELD_PREP(MT7530_CPU_PORT_MASK, x)
  42. #define MT7530_MIRROR_EN BIT(3)
  43. #define MT7530_MIRROR_PORT_MASK GENMASK(2, 0)
  44. #define MT7530_MIRROR_PORT_GET(x) FIELD_GET(MT7530_MIRROR_PORT_MASK, x)
  45. #define MT7530_MIRROR_PORT_SET(x) FIELD_PREP(MT7530_MIRROR_PORT_MASK, x)
  46. #define MT7531_QRY_FFP_MASK GENMASK(7, 0)
  47. #define MT7531_QRY_FFP(x) FIELD_PREP(MT7531_QRY_FFP_MASK, x)
  48. /* Register for CPU forward control */
  49. #define MT7531_CFC 0x4
  50. #define MT7531_MIRROR_EN BIT(19)
  51. #define MT7531_MIRROR_PORT_MASK GENMASK(18, 16)
  52. #define MT7531_MIRROR_PORT_GET(x) FIELD_GET(MT7531_MIRROR_PORT_MASK, x)
  53. #define MT7531_MIRROR_PORT_SET(x) FIELD_PREP(MT7531_MIRROR_PORT_MASK, x)
  54. #define MT7531_CPU_PMAP_MASK GENMASK(7, 0)
  55. #define MT7531_CPU_PMAP(x) FIELD_PREP(MT7531_CPU_PMAP_MASK, x)
  56. #define MT753X_MIRROR_REG(id) ((id == ID_MT7531 || \
  57. id == ID_MT7988 || \
  58. id == ID_EN7581 || \
  59. id == ID_AN7583) ? \
  60. MT7531_CFC : MT753X_MFC)
  61. #define MT753X_MIRROR_EN(id) ((id == ID_MT7531 || \
  62. id == ID_MT7988 || \
  63. id == ID_EN7581) ? \
  64. MT7531_MIRROR_EN : MT7530_MIRROR_EN)
  65. #define MT753X_MIRROR_PORT_MASK(id) ((id == ID_MT7531 || \
  66. id == ID_MT7988 || \
  67. id == ID_EN7581 || \
  68. id == ID_AN7583) ? \
  69. MT7531_MIRROR_PORT_MASK : \
  70. MT7530_MIRROR_PORT_MASK)
  71. #define MT753X_MIRROR_PORT_GET(id, val) ((id == ID_MT7531 || \
  72. id == ID_MT7988 || \
  73. id == ID_EN7581 || \
  74. id == ID_AN7583) ? \
  75. MT7531_MIRROR_PORT_GET(val) : \
  76. MT7530_MIRROR_PORT_GET(val))
  77. #define MT753X_MIRROR_PORT_SET(id, val) ((id == ID_MT7531 || \
  78. id == ID_MT7988 || \
  79. id == ID_EN7581 || \
  80. id == ID_AN7583) ? \
  81. MT7531_MIRROR_PORT_SET(val) : \
  82. MT7530_MIRROR_PORT_SET(val))
  83. /* Register for BPDU and PAE frame control */
  84. #define MT753X_BPC 0x24
  85. #define PAE_BPDU_FR BIT(25)
  86. #define PAE_EG_TAG_MASK GENMASK(24, 22)
  87. #define PAE_EG_TAG(x) FIELD_PREP(PAE_EG_TAG_MASK, x)
  88. #define PAE_PORT_FW_MASK GENMASK(18, 16)
  89. #define PAE_PORT_FW(x) FIELD_PREP(PAE_PORT_FW_MASK, x)
  90. #define BPDU_EG_TAG_MASK GENMASK(8, 6)
  91. #define BPDU_EG_TAG(x) FIELD_PREP(BPDU_EG_TAG_MASK, x)
  92. #define BPDU_PORT_FW_MASK GENMASK(2, 0)
  93. /* Register for 01-80-C2-00-00-[01,02] MAC DA frame control */
  94. #define MT753X_RGAC1 0x28
  95. #define R02_BPDU_FR BIT(25)
  96. #define R02_EG_TAG_MASK GENMASK(24, 22)
  97. #define R02_EG_TAG(x) FIELD_PREP(R02_EG_TAG_MASK, x)
  98. #define R02_PORT_FW_MASK GENMASK(18, 16)
  99. #define R02_PORT_FW(x) FIELD_PREP(R02_PORT_FW_MASK, x)
  100. #define R01_BPDU_FR BIT(9)
  101. #define R01_EG_TAG_MASK GENMASK(8, 6)
  102. #define R01_EG_TAG(x) FIELD_PREP(R01_EG_TAG_MASK, x)
  103. #define R01_PORT_FW_MASK GENMASK(2, 0)
  104. /* Register for 01-80-C2-00-00-[03,0E] MAC DA frame control */
  105. #define MT753X_RGAC2 0x2c
  106. #define R0E_BPDU_FR BIT(25)
  107. #define R0E_EG_TAG_MASK GENMASK(24, 22)
  108. #define R0E_EG_TAG(x) FIELD_PREP(R0E_EG_TAG_MASK, x)
  109. #define R0E_PORT_FW_MASK GENMASK(18, 16)
  110. #define R0E_PORT_FW(x) FIELD_PREP(R0E_PORT_FW_MASK, x)
  111. #define R03_BPDU_FR BIT(9)
  112. #define R03_EG_TAG_MASK GENMASK(8, 6)
  113. #define R03_EG_TAG(x) FIELD_PREP(R03_EG_TAG_MASK, x)
  114. #define R03_PORT_FW_MASK GENMASK(2, 0)
  115. enum mt753x_to_cpu_fw {
  116. TO_CPU_FW_SYSTEM_DEFAULT,
  117. TO_CPU_FW_CPU_EXCLUDE = 4,
  118. TO_CPU_FW_CPU_INCLUDE = 5,
  119. TO_CPU_FW_CPU_ONLY = 6,
  120. TO_CPU_FW_DROP = 7,
  121. };
  122. /* Registers for address table access */
  123. #define MT7530_ATA1 0x74
  124. #define STATIC_EMP 0
  125. #define STATIC_ENT 3
  126. #define MT7530_ATA2 0x78
  127. #define ATA2_IVL BIT(15)
  128. #define ATA2_FID(x) (((x) & 0x7) << 12)
  129. /* Register for address table write data */
  130. #define MT7530_ATWD 0x7c
  131. /* Register for address table control */
  132. #define MT7530_ATC 0x80
  133. #define ATC_HASH (((x) & 0xfff) << 16)
  134. #define ATC_BUSY BIT(15)
  135. #define ATC_SRCH_END BIT(14)
  136. #define ATC_SRCH_HIT BIT(13)
  137. #define ATC_INVALID BIT(12)
  138. #define ATC_MAT(x) (((x) & 0xf) << 8)
  139. #define ATC_MAT_MACTAB ATC_MAT(0)
  140. enum mt7530_fdb_cmd {
  141. MT7530_FDB_READ = 0,
  142. MT7530_FDB_WRITE = 1,
  143. MT7530_FDB_FLUSH = 2,
  144. MT7530_FDB_START = 4,
  145. MT7530_FDB_NEXT = 5,
  146. };
  147. /* Registers for table search read address */
  148. #define MT7530_TSRA1 0x84
  149. #define MAC_BYTE_0 24
  150. #define MAC_BYTE_1 16
  151. #define MAC_BYTE_2 8
  152. #define MAC_BYTE_3 0
  153. #define MAC_BYTE_MASK 0xff
  154. #define MT7530_TSRA2 0x88
  155. #define MAC_BYTE_4 24
  156. #define MAC_BYTE_5 16
  157. #define CVID 0
  158. #define CVID_MASK 0xfff
  159. #define MT7530_ATRD 0x8C
  160. #define AGE_TIMER 24
  161. #define AGE_TIMER_MASK 0xff
  162. #define PORT_MAP 4
  163. #define PORT_MAP_MASK 0xff
  164. #define ENT_STATUS 2
  165. #define ENT_STATUS_MASK 0x3
  166. /* Register for vlan table control */
  167. #define MT7530_VTCR 0x90
  168. #define VTCR_BUSY BIT(31)
  169. #define VTCR_INVALID BIT(16)
  170. #define VTCR_FUNC(x) (((x) & 0xf) << 12)
  171. #define VTCR_VID ((x) & 0xfff)
  172. enum mt7530_vlan_cmd {
  173. /* Read/Write the specified VID entry from VAWD register based
  174. * on VID.
  175. */
  176. MT7530_VTCR_RD_VID = 0,
  177. MT7530_VTCR_WR_VID = 1,
  178. };
  179. /* Register for setup vlan and acl write data */
  180. #define MT7530_VAWD1 0x94
  181. #define PORT_STAG BIT(31)
  182. /* Independent VLAN Learning */
  183. #define IVL_MAC BIT(30)
  184. /* Egress Tag Consistent */
  185. #define EG_CON BIT(29)
  186. /* Per VLAN Egress Tag Control */
  187. #define VTAG_EN BIT(28)
  188. /* VLAN Member Control */
  189. #define PORT_MEM(x) (((x) & 0xff) << 16)
  190. /* Filter ID */
  191. #define FID(x) (((x) & 0x7) << 1)
  192. /* VLAN Entry Valid */
  193. #define VLAN_VALID BIT(0)
  194. #define PORT_MEM_SHFT 16
  195. #define PORT_MEM_MASK 0xff
  196. enum mt7530_fid {
  197. FID_STANDALONE = 0,
  198. FID_BRIDGED = 1,
  199. };
  200. #define MT7530_VAWD2 0x98
  201. /* Egress Tag Control */
  202. #define ETAG_CTRL_P(p, x) (((x) & 0x3) << ((p) << 1))
  203. #define ETAG_CTRL_P_MASK(p) ETAG_CTRL_P(p, 3)
  204. enum mt7530_vlan_egress_attr {
  205. MT7530_VLAN_EGRESS_UNTAG = 0,
  206. MT7530_VLAN_EGRESS_TAG = 2,
  207. MT7530_VLAN_EGRESS_STACK = 3,
  208. };
  209. /* Register for address age control */
  210. #define MT7530_AAC 0xa0
  211. /* Disable ageing */
  212. #define AGE_DIS BIT(20)
  213. /* Age count */
  214. #define AGE_CNT_MASK GENMASK(19, 12)
  215. #define AGE_CNT_MAX 0xff
  216. #define AGE_CNT(x) (AGE_CNT_MASK & ((x) << 12))
  217. /* Age unit */
  218. #define AGE_UNIT_MASK GENMASK(11, 0)
  219. #define AGE_UNIT_MAX 0xfff
  220. #define AGE_UNIT(x) (AGE_UNIT_MASK & (x))
  221. #define MT753X_ERLCR_P(x) (0x1040 + ((x) * 0x100))
  222. #define ERLCR_CIR_MASK GENMASK(31, 16)
  223. #define ERLCR_EN_MASK BIT(15)
  224. #define ERLCR_EXP_MASK GENMASK(11, 8)
  225. #define ERLCR_TBF_MODE_MASK BIT(7)
  226. #define ERLCR_MANT_MASK GENMASK(6, 0)
  227. #define MT753X_GERLCR 0x10e0
  228. #define EGR_BC_MASK GENMASK(7, 0)
  229. #define EGR_BC_CRC 0x4 /* crc */
  230. #define EGR_BC_CRC_IPG_PREAMBLE 0x18 /* crc + ipg + preamble */
  231. /* Register for port STP state control */
  232. #define MT7530_SSP_P(x) (0x2000 + ((x) * 0x100))
  233. #define FID_PST(fid, state) (((state) & 0x3) << ((fid) * 2))
  234. #define FID_PST_MASK(fid) FID_PST(fid, 0x3)
  235. enum mt7530_stp_state {
  236. MT7530_STP_DISABLED = 0,
  237. MT7530_STP_BLOCKING = 1,
  238. MT7530_STP_LISTENING = 1,
  239. MT7530_STP_LEARNING = 2,
  240. MT7530_STP_FORWARDING = 3
  241. };
  242. /* Register for port control */
  243. #define MT7530_PCR_P(x) (0x2004 + ((x) * 0x100))
  244. #define PORT_TX_MIR BIT(9)
  245. #define PORT_RX_MIR BIT(8)
  246. #define PORT_VLAN(x) ((x) & 0x3)
  247. enum mt7530_port_mode {
  248. /* Port Matrix Mode: Frames are forwarded by the PCR_MATRIX members. */
  249. MT7530_PORT_MATRIX_MODE = PORT_VLAN(0),
  250. /* Fallback Mode: Forward received frames with ingress ports that do
  251. * not belong to the VLAN member. Frames whose VID is not listed on
  252. * the VLAN table are forwarded by the PCR_MATRIX members.
  253. */
  254. MT7530_PORT_FALLBACK_MODE = PORT_VLAN(1),
  255. /* Security Mode: Discard any frame due to ingress membership
  256. * violation or VID missed on the VLAN table.
  257. */
  258. MT7530_PORT_SECURITY_MODE = PORT_VLAN(3),
  259. };
  260. #define PCR_MATRIX(x) (((x) & 0xff) << 16)
  261. #define PORT_PRI(x) (((x) & 0x7) << 24)
  262. #define EG_TAG(x) (((x) & 0x3) << 28)
  263. #define PCR_MATRIX_MASK PCR_MATRIX(0xff)
  264. #define PCR_MATRIX_CLR PCR_MATRIX(0)
  265. #define PCR_PORT_VLAN_MASK PORT_VLAN(3)
  266. /* Register for port security control */
  267. #define MT7530_PSC_P(x) (0x200c + ((x) * 0x100))
  268. #define SA_DIS BIT(4)
  269. /* Register for port vlan control */
  270. #define MT7530_PVC_P(x) (0x2010 + ((x) * 0x100))
  271. #define PORT_SPEC_TAG BIT(5)
  272. #define PVC_EG_TAG(x) (((x) & 0x7) << 8)
  273. #define PVC_EG_TAG_MASK PVC_EG_TAG(7)
  274. #define VLAN_ATTR(x) (((x) & 0x3) << 6)
  275. #define VLAN_ATTR_MASK VLAN_ATTR(3)
  276. #define ACC_FRM_MASK GENMASK(1, 0)
  277. enum mt7530_vlan_port_eg_tag {
  278. MT7530_VLAN_EG_DISABLED = 0,
  279. MT7530_VLAN_EG_CONSISTENT = 1,
  280. MT7530_VLAN_EG_UNTAGGED = 4,
  281. };
  282. enum mt7530_vlan_port_attr {
  283. MT7530_VLAN_USER = 0,
  284. MT7530_VLAN_TRANSPARENT = 3,
  285. };
  286. enum mt7530_vlan_port_acc_frm {
  287. MT7530_VLAN_ACC_ALL = 0,
  288. MT7530_VLAN_ACC_TAGGED = 1,
  289. MT7530_VLAN_ACC_UNTAGGED = 2,
  290. };
  291. #define STAG_VPID (((x) & 0xffff) << 16)
  292. /* Register for port port-and-protocol based vlan 1 control */
  293. #define MT7530_PPBV1_P(x) (0x2014 + ((x) * 0x100))
  294. #define G0_PORT_VID(x) (((x) & 0xfff) << 0)
  295. #define G0_PORT_VID_MASK G0_PORT_VID(0xfff)
  296. #define G0_PORT_VID_DEF G0_PORT_VID(0)
  297. /* Register for port MAC control register */
  298. #define MT753X_PMCR_P(x) (0x3000 + ((x) * 0x100))
  299. #define PMCR_IFG_XMIT_MASK GENMASK(19, 18)
  300. #define PMCR_IFG_XMIT(x) FIELD_PREP(PMCR_IFG_XMIT_MASK, x)
  301. #define PMCR_EXT_PHY BIT(17)
  302. #define PMCR_MAC_MODE BIT(16)
  303. #define MT7530_FORCE_MODE BIT(15)
  304. #define PMCR_MAC_TX_EN BIT(14)
  305. #define PMCR_MAC_RX_EN BIT(13)
  306. #define PMCR_BACKOFF_EN BIT(9)
  307. #define PMCR_BACKPR_EN BIT(8)
  308. #define PMCR_FORCE_EEE1G BIT(7)
  309. #define PMCR_FORCE_EEE100 BIT(6)
  310. #define PMCR_FORCE_RX_FC_EN BIT(5)
  311. #define PMCR_FORCE_TX_FC_EN BIT(4)
  312. #define PMCR_FORCE_SPEED_1000 BIT(3)
  313. #define PMCR_FORCE_SPEED_100 BIT(2)
  314. #define PMCR_FORCE_FDX BIT(1)
  315. #define PMCR_FORCE_LNK BIT(0)
  316. #define MT7531_FORCE_MODE_LNK BIT(31)
  317. #define MT7531_FORCE_MODE_SPD BIT(30)
  318. #define MT7531_FORCE_MODE_DPX BIT(29)
  319. #define MT7531_FORCE_MODE_RX_FC BIT(28)
  320. #define MT7531_FORCE_MODE_TX_FC BIT(27)
  321. #define MT7531_FORCE_MODE_EEE100 BIT(26)
  322. #define MT7531_FORCE_MODE_EEE1G BIT(25)
  323. #define MT7531_FORCE_MODE_MASK (MT7531_FORCE_MODE_LNK | \
  324. MT7531_FORCE_MODE_SPD | \
  325. MT7531_FORCE_MODE_DPX | \
  326. MT7531_FORCE_MODE_RX_FC | \
  327. MT7531_FORCE_MODE_TX_FC | \
  328. MT7531_FORCE_MODE_EEE100 | \
  329. MT7531_FORCE_MODE_EEE1G)
  330. #define MT753X_FORCE_MODE(id) ((id == ID_MT7531 || \
  331. id == ID_MT7988) ? \
  332. MT7531_FORCE_MODE_MASK : \
  333. MT7530_FORCE_MODE)
  334. #define PMCR_LINK_SETTINGS_MASK (PMCR_MAC_TX_EN | PMCR_MAC_RX_EN | \
  335. PMCR_FORCE_EEE1G | \
  336. PMCR_FORCE_EEE100 | \
  337. PMCR_FORCE_RX_FC_EN | \
  338. PMCR_FORCE_TX_FC_EN | \
  339. PMCR_FORCE_SPEED_1000 | \
  340. PMCR_FORCE_SPEED_100 | \
  341. PMCR_FORCE_FDX | PMCR_FORCE_LNK)
  342. #define MT753X_PMEEECR_P(x) (0x3004 + (x) * 0x100)
  343. #define WAKEUP_TIME_1000_MASK GENMASK(31, 24)
  344. #define WAKEUP_TIME_1000(x) FIELD_PREP(WAKEUP_TIME_1000_MASK, x)
  345. #define WAKEUP_TIME_100_MASK GENMASK(23, 16)
  346. #define WAKEUP_TIME_100(x) FIELD_PREP(WAKEUP_TIME_100_MASK, x)
  347. #define LPI_THRESH_MASK GENMASK(15, 4)
  348. #define LPI_THRESH_GET(x) FIELD_GET(LPI_THRESH_MASK, x)
  349. #define LPI_THRESH_SET(x) FIELD_PREP(LPI_THRESH_MASK, x)
  350. #define LPI_MODE_EN BIT(0)
  351. #define MT7530_PMSR_P(x) (0x3008 + (x) * 0x100)
  352. #define PMSR_EEE1G BIT(7)
  353. #define PMSR_EEE100M BIT(6)
  354. #define PMSR_RX_FC BIT(5)
  355. #define PMSR_TX_FC BIT(4)
  356. #define PMSR_SPEED_1000 BIT(3)
  357. #define PMSR_SPEED_100 BIT(2)
  358. #define PMSR_SPEED_10 0x00
  359. #define PMSR_SPEED_MASK (PMSR_SPEED_100 | PMSR_SPEED_1000)
  360. #define PMSR_DPX BIT(1)
  361. #define PMSR_LINK BIT(0)
  362. /* Register for port debug count */
  363. #define MT7531_DBG_CNT(x) (0x3018 + (x) * 0x100)
  364. #define MT7531_DIS_CLR BIT(31)
  365. #define MT7530_GMACCR 0x30e0
  366. #define MAX_RX_JUMBO(x) ((x) << 2)
  367. #define MAX_RX_JUMBO_MASK GENMASK(5, 2)
  368. #define MAX_RX_PKT_LEN_MASK GENMASK(1, 0)
  369. #define MAX_RX_PKT_LEN_1522 0x0
  370. #define MAX_RX_PKT_LEN_1536 0x1
  371. #define MAX_RX_PKT_LEN_1552 0x2
  372. #define MAX_RX_PKT_LEN_JUMBO 0x3
  373. /* Register for MIB */
  374. #define MT7530_PORT_MIB_COUNTER(x) (0x4000 + (x) * 0x100)
  375. /* Each define is an offset of MT7530_PORT_MIB_COUNTER */
  376. #define MT7530_PORT_MIB_TX_DROP 0x00
  377. #define MT7530_PORT_MIB_TX_CRC_ERR 0x04
  378. #define MT7530_PORT_MIB_TX_UNICAST 0x08
  379. #define MT7530_PORT_MIB_TX_MULTICAST 0x0c
  380. #define MT7530_PORT_MIB_TX_BROADCAST 0x10
  381. #define MT7530_PORT_MIB_TX_COLLISION 0x14
  382. #define MT7530_PORT_MIB_TX_SINGLE_COLLISION 0x18
  383. #define MT7530_PORT_MIB_TX_MULTIPLE_COLLISION 0x1c
  384. #define MT7530_PORT_MIB_TX_DEFERRED 0x20
  385. #define MT7530_PORT_MIB_TX_LATE_COLLISION 0x24
  386. #define MT7530_PORT_MIB_TX_EXCESSIVE_COLLISION 0x28
  387. #define MT7530_PORT_MIB_TX_PAUSE 0x2c
  388. #define MT7530_PORT_MIB_TX_PKT_SZ_64 0x30
  389. #define MT7530_PORT_MIB_TX_PKT_SZ_65_TO_127 0x34
  390. #define MT7530_PORT_MIB_TX_PKT_SZ_128_TO_255 0x38
  391. #define MT7530_PORT_MIB_TX_PKT_SZ_256_TO_511 0x3c
  392. #define MT7530_PORT_MIB_TX_PKT_SZ_512_TO_1023 0x40
  393. #define MT7530_PORT_MIB_TX_PKT_SZ_1024_TO_MAX 0x44
  394. #define MT7530_PORT_MIB_TX_BYTES 0x48 /* 64 bytes */
  395. #define MT7530_PORT_MIB_RX_DROP 0x60
  396. #define MT7530_PORT_MIB_RX_FILTERING 0x64
  397. #define MT7530_PORT_MIB_RX_UNICAST 0x68
  398. #define MT7530_PORT_MIB_RX_MULTICAST 0x6c
  399. #define MT7530_PORT_MIB_RX_BROADCAST 0x70
  400. #define MT7530_PORT_MIB_RX_ALIGN_ERR 0x74
  401. #define MT7530_PORT_MIB_RX_CRC_ERR 0x78
  402. #define MT7530_PORT_MIB_RX_UNDER_SIZE_ERR 0x7c
  403. #define MT7530_PORT_MIB_RX_FRAG_ERR 0x80
  404. #define MT7530_PORT_MIB_RX_OVER_SZ_ERR 0x84
  405. #define MT7530_PORT_MIB_RX_JABBER_ERR 0x88
  406. #define MT7530_PORT_MIB_RX_PAUSE 0x8c
  407. #define MT7530_PORT_MIB_RX_PKT_SZ_64 0x90
  408. #define MT7530_PORT_MIB_RX_PKT_SZ_65_TO_127 0x94
  409. #define MT7530_PORT_MIB_RX_PKT_SZ_128_TO_255 0x98
  410. #define MT7530_PORT_MIB_RX_PKT_SZ_256_TO_511 0x9c
  411. #define MT7530_PORT_MIB_RX_PKT_SZ_512_TO_1023 0xa0
  412. #define MT7530_PORT_MIB_RX_PKT_SZ_1024_TO_MAX 0xa4
  413. #define MT7530_PORT_MIB_RX_BYTES 0xa8 /* 64 bytes */
  414. #define MT7530_PORT_MIB_RX_CTRL_DROP 0xb0
  415. #define MT7530_PORT_MIB_RX_INGRESS_DROP 0xb4
  416. #define MT7530_PORT_MIB_RX_ARL_DROP 0xb8
  417. #define MT7530_MIB_CCR 0x4fe0
  418. #define CCR_MIB_ENABLE BIT(31)
  419. #define CCR_RX_OCT_CNT_GOOD BIT(7)
  420. #define CCR_RX_OCT_CNT_BAD BIT(6)
  421. #define CCR_TX_OCT_CNT_GOOD BIT(5)
  422. #define CCR_TX_OCT_CNT_BAD BIT(4)
  423. #define CCR_MIB_FLUSH (CCR_RX_OCT_CNT_GOOD | \
  424. CCR_RX_OCT_CNT_BAD | \
  425. CCR_TX_OCT_CNT_GOOD | \
  426. CCR_TX_OCT_CNT_BAD)
  427. #define CCR_MIB_ACTIVATE (CCR_MIB_ENABLE | \
  428. CCR_RX_OCT_CNT_GOOD | \
  429. CCR_RX_OCT_CNT_BAD | \
  430. CCR_TX_OCT_CNT_GOOD | \
  431. CCR_TX_OCT_CNT_BAD)
  432. /* MT7531 SGMII register group */
  433. #define MT7531_SGMII_REG_BASE(p) (0x5000 + ((p) - 5) * 0x1000)
  434. #define MT7531_PHYA_CTRL_SIGNAL3 0x128
  435. /* Register for system reset */
  436. #define MT7530_SYS_CTRL 0x7000
  437. #define SYS_CTRL_PHY_RST BIT(2)
  438. #define SYS_CTRL_SW_RST BIT(1)
  439. #define SYS_CTRL_REG_RST BIT(0)
  440. /* Register for system interrupt */
  441. #define MT7530_SYS_INT_EN 0x7008
  442. /* Register for system interrupt status */
  443. #define MT7530_SYS_INT_STS 0x700c
  444. /* Register for PHY Indirect Access Control */
  445. #define MT7531_PHY_IAC 0x701C
  446. #define MT7531_PHY_ACS_ST BIT(31)
  447. #define MT7531_MDIO_REG_ADDR_MASK (0x1f << 25)
  448. #define MT7531_MDIO_PHY_ADDR_MASK (0x1f << 20)
  449. #define MT7531_MDIO_CMD_MASK (0x3 << 18)
  450. #define MT7531_MDIO_ST_MASK (0x3 << 16)
  451. #define MT7531_MDIO_RW_DATA_MASK (0xffff)
  452. #define MT7531_MDIO_REG_ADDR(x) (((x) & 0x1f) << 25)
  453. #define MT7531_MDIO_DEV_ADDR(x) (((x) & 0x1f) << 25)
  454. #define MT7531_MDIO_PHY_ADDR(x) (((x) & 0x1f) << 20)
  455. #define MT7531_MDIO_CMD(x) (((x) & 0x3) << 18)
  456. #define MT7531_MDIO_ST(x) (((x) & 0x3) << 16)
  457. enum mt7531_phy_iac_cmd {
  458. MT7531_MDIO_ADDR = 0,
  459. MT7531_MDIO_WRITE = 1,
  460. MT7531_MDIO_READ = 2,
  461. MT7531_MDIO_READ_CL45 = 3,
  462. };
  463. /* MDIO_ST: MDIO start field */
  464. enum mt7531_mdio_st {
  465. MT7531_MDIO_ST_CL45 = 0,
  466. MT7531_MDIO_ST_CL22 = 1,
  467. };
  468. #define MT7531_MDIO_CL22_READ (MT7531_MDIO_ST(MT7531_MDIO_ST_CL22) | \
  469. MT7531_MDIO_CMD(MT7531_MDIO_READ))
  470. #define MT7531_MDIO_CL22_WRITE (MT7531_MDIO_ST(MT7531_MDIO_ST_CL22) | \
  471. MT7531_MDIO_CMD(MT7531_MDIO_WRITE))
  472. #define MT7531_MDIO_CL45_ADDR (MT7531_MDIO_ST(MT7531_MDIO_ST_CL45) | \
  473. MT7531_MDIO_CMD(MT7531_MDIO_ADDR))
  474. #define MT7531_MDIO_CL45_READ (MT7531_MDIO_ST(MT7531_MDIO_ST_CL45) | \
  475. MT7531_MDIO_CMD(MT7531_MDIO_READ))
  476. #define MT7531_MDIO_CL45_WRITE (MT7531_MDIO_ST(MT7531_MDIO_ST_CL45) | \
  477. MT7531_MDIO_CMD(MT7531_MDIO_WRITE))
  478. /* Register for RGMII clock phase */
  479. #define MT7531_CLKGEN_CTRL 0x7500
  480. #define CLK_SKEW_OUT(x) (((x) & 0x3) << 8)
  481. #define CLK_SKEW_OUT_MASK GENMASK(9, 8)
  482. #define CLK_SKEW_IN(x) (((x) & 0x3) << 6)
  483. #define CLK_SKEW_IN_MASK GENMASK(7, 6)
  484. #define RXCLK_NO_DELAY BIT(5)
  485. #define TXCLK_NO_REVERSE BIT(4)
  486. #define GP_MODE(x) (((x) & 0x3) << 1)
  487. #define GP_MODE_MASK GENMASK(2, 1)
  488. #define GP_CLK_EN BIT(0)
  489. enum mt7531_gp_mode {
  490. MT7531_GP_MODE_RGMII = 0,
  491. MT7531_GP_MODE_MII = 1,
  492. MT7531_GP_MODE_REV_MII = 2
  493. };
  494. enum mt7531_clk_skew {
  495. MT7531_CLK_SKEW_NO_CHG = 0,
  496. MT7531_CLK_SKEW_DLY_100PPS = 1,
  497. MT7531_CLK_SKEW_DLY_200PPS = 2,
  498. MT7531_CLK_SKEW_REVERSE = 3,
  499. };
  500. /* Register for trap status */
  501. #define MT753X_TRAP 0x7800
  502. #define MT7530_XTAL_MASK (BIT(10) | BIT(9))
  503. #define MT7530_XTAL_25MHZ (BIT(10) | BIT(9))
  504. #define MT7530_XTAL_40MHZ BIT(10)
  505. #define MT7530_XTAL_20MHZ BIT(9)
  506. #define MT7531_XTAL25 BIT(7)
  507. /* Register for trap modification */
  508. #define MT753X_MTRAP 0x7804
  509. #define MT7530_P5_PHY0_SEL BIT(20)
  510. #define MT7530_CHG_TRAP BIT(16)
  511. #define MT7530_P5_MAC_SEL BIT(13)
  512. #define MT7530_P6_DIS BIT(8)
  513. #define MT7530_P5_RGMII_MODE BIT(7)
  514. #define MT7530_P5_DIS BIT(6)
  515. #define MT7530_PHY_INDIRECT_ACCESS BIT(5)
  516. #define MT7531_CHG_STRAP BIT(8)
  517. #define MT7531_PHY_EN BIT(6)
  518. enum mt7531_xtal_fsel {
  519. MT7531_XTAL_FSEL_25MHZ,
  520. MT7531_XTAL_FSEL_40MHZ,
  521. };
  522. /* Register for TOP signal control */
  523. #define MT7530_TOP_SIG_CTRL 0x7808
  524. #define TOP_SIG_CTRL_NORMAL (BIT(17) | BIT(16))
  525. #define MT7531_TOP_SIG_SR 0x780c
  526. #define PAD_DUAL_SGMII_EN BIT(1)
  527. #define PAD_MCM_SMI_EN BIT(0)
  528. #define MT7530_IO_DRV_CR 0x7810
  529. #define P5_IO_CLK_DRV(x) ((x) & 0x3)
  530. #define P5_IO_DATA_DRV(x) (((x) & 0x3) << 4)
  531. #define MT7531_CHIP_REV 0x781C
  532. #define MT7531_PLLGP_EN 0x7820
  533. #define EN_COREPLL BIT(2)
  534. #define SW_CLKSW BIT(1)
  535. #define SW_PLLGP BIT(0)
  536. #define MT7530_P6ECR 0x7830
  537. #define P6_INTF_MODE_MASK 0x3
  538. #define P6_INTF_MODE(x) ((x) & 0x3)
  539. #define MT7531_PLLGP_CR0 0x78a8
  540. #define RG_COREPLL_EN BIT(22)
  541. #define RG_COREPLL_POSDIV_S 23
  542. #define RG_COREPLL_POSDIV_M 0x3800000
  543. #define RG_COREPLL_SDM_PCW_S 1
  544. #define RG_COREPLL_SDM_PCW_M 0x3ffffe
  545. #define RG_COREPLL_SDM_PCW_CHG BIT(0)
  546. /* Registers for RGMII and SGMII PLL clock */
  547. #define MT7531_ANA_PLLGP_CR2 0x78b0
  548. #define MT7531_ANA_PLLGP_CR5 0x78bc
  549. /* Registers for TRGMII on the both side */
  550. #define MT7530_TRGMII_RCK_CTRL 0x7a00
  551. #define RX_RST BIT(31)
  552. #define RXC_DQSISEL BIT(30)
  553. #define DQSI1_TAP_MASK (0x7f << 8)
  554. #define DQSI0_TAP_MASK 0x7f
  555. #define DQSI1_TAP(x) (((x) & 0x7f) << 8)
  556. #define DQSI0_TAP(x) ((x) & 0x7f)
  557. #define MT7530_TRGMII_RCK_RTT 0x7a04
  558. #define DQS1_GATE BIT(31)
  559. #define DQS0_GATE BIT(30)
  560. #define MT7530_TRGMII_RD(x) (0x7a10 + (x) * 8)
  561. #define BSLIP_EN BIT(31)
  562. #define EDGE_CHK BIT(30)
  563. #define RD_TAP_MASK 0x7f
  564. #define RD_TAP(x) ((x) & 0x7f)
  565. #define MT7530_TRGMII_TXCTRL 0x7a40
  566. #define TRAIN_TXEN BIT(31)
  567. #define TXC_INV BIT(30)
  568. #define TX_RST BIT(28)
  569. #define MT7530_TRGMII_TD_ODT(i) (0x7a54 + 8 * (i))
  570. #define TD_DM_DRVP(x) ((x) & 0xf)
  571. #define TD_DM_DRVN(x) (((x) & 0xf) << 4)
  572. #define MT7530_TRGMII_TCK_CTRL 0x7a78
  573. #define TCK_TAP(x) (((x) & 0xf) << 8)
  574. #define MT7530_P5RGMIIRXCR 0x7b00
  575. #define CSR_RGMII_EDGE_ALIGN BIT(8)
  576. #define CSR_RGMII_RXC_0DEG_CFG(x) ((x) & 0xf)
  577. #define MT7530_P5RGMIITXCR 0x7b04
  578. #define CSR_RGMII_TXC_CFG(x) ((x) & 0x1f)
  579. /* Registers for GPIO mode */
  580. #define MT7531_GPIO_MODE0 0x7c0c
  581. #define MT7531_GPIO0_MASK GENMASK(3, 0)
  582. #define MT7531_GPIO0_INTERRUPT 1
  583. #define MT7531_GPIO_MODE1 0x7c10
  584. #define MT7531_GPIO11_RG_RXD2_MASK GENMASK(15, 12)
  585. #define MT7531_EXT_P_MDC_11 (2 << 12)
  586. #define MT7531_GPIO12_RG_RXD3_MASK GENMASK(19, 16)
  587. #define MT7531_EXT_P_MDIO_12 (2 << 16)
  588. #define MT753X_CPORT_SPTAG_CFG 0x7c10
  589. #define CPORT_SW2FE_STAG_EN BIT(1)
  590. #define CPORT_FE2SW_STAG_EN BIT(0)
  591. #define AN7583_GEPHY_CONN_CFG 0x7c14
  592. #define AN7583_CSR_DPHY_CKIN_SEL BIT(31)
  593. #define AN7583_CSR_PHY_CORE_REG_CLK_SEL BIT(30)
  594. #define AN7583_CSR_ETHER_AFE_PWD GENMASK(28, 24)
  595. /* Registers for LED GPIO control (MT7530 only)
  596. * All registers follow this pattern:
  597. * [ 2: 0] port 0
  598. * [ 6: 4] port 1
  599. * [10: 8] port 2
  600. * [14:12] port 3
  601. * [18:16] port 4
  602. */
  603. /* LED enable, 0: Disable, 1: Enable (Default) */
  604. #define MT7530_LED_EN 0x7d00
  605. /* LED mode, 0: GPIO mode, 1: PHY mode (Default) */
  606. #define MT7530_LED_IO_MODE 0x7d04
  607. /* GPIO direction, 0: Input, 1: Output */
  608. #define MT7530_LED_GPIO_DIR 0x7d10
  609. /* GPIO output enable, 0: Disable, 1: Enable */
  610. #define MT7530_LED_GPIO_OE 0x7d14
  611. /* GPIO value, 0: Low, 1: High */
  612. #define MT7530_LED_GPIO_DATA 0x7d18
  613. #define MT7530_CREV 0x7ffc
  614. #define CHIP_NAME_SHIFT 16
  615. #define MT7530_ID 0x7530
  616. #define MT7531_CREV 0x781C
  617. #define CHIP_REV_M 0x0f
  618. #define MT7531_ID 0x7531
  619. /* Registers for core PLL access through mmd indirect */
  620. #define CORE_PLL_GROUP2 0x401
  621. #define RG_SYSPLL_EN_NORMAL BIT(15)
  622. #define RG_SYSPLL_VODEN BIT(14)
  623. #define RG_SYSPLL_LF BIT(13)
  624. #define RG_SYSPLL_RST_DLY(x) (((x) & 0x3) << 12)
  625. #define RG_SYSPLL_LVROD_EN BIT(10)
  626. #define RG_SYSPLL_PREDIV(x) (((x) & 0x3) << 8)
  627. #define RG_SYSPLL_POSDIV(x) (((x) & 0x3) << 5)
  628. #define RG_SYSPLL_FBKSEL BIT(4)
  629. #define RT_SYSPLL_EN_AFE_OLT BIT(0)
  630. #define CORE_PLL_GROUP4 0x403
  631. #define RG_SYSPLL_DDSFBK_EN BIT(12)
  632. #define RG_SYSPLL_BIAS_EN BIT(11)
  633. #define RG_SYSPLL_BIAS_LPF_EN BIT(10)
  634. #define MT7531_RG_SYSPLL_DMY2 BIT(6)
  635. #define MT7531_PHY_PLL_OFF BIT(5)
  636. #define MT7531_PHY_PLL_BYPASS_MODE BIT(4)
  637. #define MT753X_CTRL_PHY_ADDR(addr) ((addr + 1) & 0x1f)
  638. #define CORE_PLL_GROUP5 0x404
  639. #define RG_LCDDS_PCW_NCPO1(x) ((x) & 0xffff)
  640. #define CORE_PLL_GROUP6 0x405
  641. #define RG_LCDDS_PCW_NCPO0(x) ((x) & 0xffff)
  642. #define CORE_PLL_GROUP7 0x406
  643. #define RG_LCDDS_PWDB BIT(15)
  644. #define RG_LCDDS_ISO_EN BIT(13)
  645. #define RG_LCCDS_C(x) (((x) & 0x7) << 4)
  646. #define RG_LCDDS_PCW_NCPO_CHG BIT(3)
  647. #define CORE_PLL_GROUP10 0x409
  648. #define RG_LCDDS_SSC_DELTA(x) ((x) & 0xfff)
  649. #define CORE_PLL_GROUP11 0x40a
  650. #define RG_LCDDS_SSC_DELTA1(x) ((x) & 0xfff)
  651. #define CORE_GSWPLL_GRP1 0x40d
  652. #define RG_GSWPLL_PREDIV(x) (((x) & 0x3) << 14)
  653. #define RG_GSWPLL_POSDIV_200M(x) (((x) & 0x3) << 12)
  654. #define RG_GSWPLL_EN_PRE BIT(11)
  655. #define RG_GSWPLL_FBKSEL BIT(10)
  656. #define RG_GSWPLL_BP BIT(9)
  657. #define RG_GSWPLL_BR BIT(8)
  658. #define RG_GSWPLL_FBKDIV_200M(x) ((x) & 0xff)
  659. #define CORE_GSWPLL_GRP2 0x40e
  660. #define RG_GSWPLL_POSDIV_500M(x) (((x) & 0x3) << 8)
  661. #define RG_GSWPLL_FBKDIV_500M(x) ((x) & 0xff)
  662. #define CORE_TRGMII_GSW_CLK_CG 0x410
  663. #define REG_GSWCK_EN BIT(0)
  664. #define REG_TRGMIICK_EN BIT(1)
  665. #define MIB_DESC(_s, _o, _n) \
  666. { \
  667. .size = (_s), \
  668. .offset = (_o), \
  669. .name = (_n), \
  670. }
  671. struct mt7530_mib_desc {
  672. unsigned int size;
  673. unsigned int offset;
  674. const char *name;
  675. };
  676. struct mt7530_fdb {
  677. u16 vid;
  678. u8 port_mask;
  679. u8 aging;
  680. u8 mac[6];
  681. bool noarp;
  682. };
  683. /* struct mt7530_port - This is the main data structure for holding the state
  684. * of the port.
  685. * @enable: The status used for show port is enabled or not.
  686. * @pm: The matrix used to show all connections with the port.
  687. * @pvid: The VLAN specified is to be considered a PVID at ingress. Any
  688. * untagged frames will be assigned to the related VLAN.
  689. * @sgmii_pcs: Pointer to PCS instance for SerDes ports
  690. */
  691. struct mt7530_port {
  692. bool enable;
  693. bool isolated;
  694. u32 pm;
  695. u16 pvid;
  696. struct phylink_pcs *sgmii_pcs;
  697. };
  698. /* Port 5 mode definitions of the MT7530 switch */
  699. enum mt7530_p5_mode {
  700. GMAC5,
  701. MUX_PHY_P0,
  702. MUX_PHY_P4,
  703. };
  704. struct mt7530_priv;
  705. struct mt753x_pcs {
  706. struct phylink_pcs pcs;
  707. struct mt7530_priv *priv;
  708. int port;
  709. };
  710. /* struct mt753x_info - This is the main data structure for holding the specific
  711. * part for each supported device
  712. * @id: Holding the identifier to a switch model
  713. * @pcs_ops: Holding the pointer to the MAC PCS operations structure
  714. * @sw_setup: Holding the handler to a device initialization
  715. * @phy_read_c22: Holding the way reading PHY port using C22
  716. * @phy_write_c22: Holding the way writing PHY port using C22
  717. * @phy_read_c45: Holding the way reading PHY port using C45
  718. * @phy_write_c45: Holding the way writing PHY port using C45
  719. * @mac_port_get_caps: Holding the handler that provides MAC capabilities
  720. * @mac_port_config: Holding the way setting up the PHY attribute to a
  721. * certain MAC port
  722. */
  723. struct mt753x_info {
  724. enum mt753x_id id;
  725. const struct phylink_pcs_ops *pcs_ops;
  726. int (*sw_setup)(struct dsa_switch *ds);
  727. int (*phy_read_c22)(struct mt7530_priv *priv, int port, int regnum);
  728. int (*phy_write_c22)(struct mt7530_priv *priv, int port, int regnum,
  729. u16 val);
  730. int (*phy_read_c45)(struct mt7530_priv *priv, int port, int devad,
  731. int regnum);
  732. int (*phy_write_c45)(struct mt7530_priv *priv, int port, int devad,
  733. int regnum, u16 val);
  734. void (*mac_port_get_caps)(struct dsa_switch *ds, int port,
  735. struct phylink_config *config);
  736. void (*mac_port_config)(struct dsa_switch *ds, int port,
  737. unsigned int mode,
  738. phy_interface_t interface);
  739. };
  740. /* struct mt7530_priv - This is the main data structure for holding the state
  741. * of the driver
  742. * @dev: The device pointer
  743. * @ds: The pointer to the dsa core structure
  744. * @bus: The bus used for the device and built-in PHY
  745. * @regmap: The regmap instance representing all switch registers
  746. * @rstc: The pointer to reset control used by MCM
  747. * @core_pwr: The power supplied into the core
  748. * @io_pwr: The power supplied into the I/O
  749. * @reset: The descriptor for GPIO line tied to its reset pin
  750. * @mcm: Flag for distinguishing if standalone IC or module
  751. * coupling
  752. * @ports: Holding the state among ports
  753. * @reg_mutex: The lock for protecting among process accessing
  754. * registers
  755. * @p5_mode: Holding the current mode of port 5 of the MT7530 switch
  756. * @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch
  757. * has got SGMII
  758. * @irq_domain: IRQ domain of the switch irq_chip
  759. * @create_sgmii: Pointer to function creating SGMII PCS instance(s)
  760. * @active_cpu_ports: Holding the active CPU ports
  761. * @mdiodev: The pointer to the MDIO device structure
  762. */
  763. struct mt7530_priv {
  764. struct device *dev;
  765. struct dsa_switch *ds;
  766. struct mii_bus *bus;
  767. struct regmap *regmap;
  768. struct reset_control *rstc;
  769. struct regulator *core_pwr;
  770. struct regulator *io_pwr;
  771. struct gpio_desc *reset;
  772. const struct mt753x_info *info;
  773. unsigned int id;
  774. bool mcm;
  775. enum mt7530_p5_mode p5_mode;
  776. bool p5_sgmii;
  777. u8 mirror_rx;
  778. u8 mirror_tx;
  779. struct mt7530_port ports[MT7530_NUM_PORTS];
  780. struct mt753x_pcs pcs[MT7530_NUM_PORTS];
  781. /* protect among processes for registers access*/
  782. struct mutex reg_mutex;
  783. struct irq_domain *irq_domain;
  784. int (*create_sgmii)(struct mt7530_priv *priv);
  785. u8 active_cpu_ports;
  786. struct mdio_device *mdiodev;
  787. };
  788. struct mt7530_hw_vlan_entry {
  789. int port;
  790. u8 old_members;
  791. bool untagged;
  792. };
  793. static inline void mt7530_hw_vlan_entry_init(struct mt7530_hw_vlan_entry *e,
  794. int port, bool untagged)
  795. {
  796. e->port = port;
  797. e->untagged = untagged;
  798. }
  799. typedef void (*mt7530_vlan_op)(struct mt7530_priv *,
  800. struct mt7530_hw_vlan_entry *);
  801. struct mt7530_hw_stats {
  802. const char *string;
  803. u16 reg;
  804. u8 sizeof_stat;
  805. };
  806. struct mt7530_dummy_poll {
  807. struct mt7530_priv *priv;
  808. u32 reg;
  809. };
  810. static inline void INIT_MT7530_DUMMY_POLL(struct mt7530_dummy_poll *p,
  811. struct mt7530_priv *priv, u32 reg)
  812. {
  813. p->priv = priv;
  814. p->reg = reg;
  815. }
  816. int mt7530_probe_common(struct mt7530_priv *priv);
  817. void mt7530_remove_common(struct mt7530_priv *priv);
  818. extern const struct mt753x_info mt753x_table[];
  819. #endif /* __MT7530_H */