common.h 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806
  1. /*
  2. * TC956X ethernet driver.
  3. *
  4. * common.h - Common Header File
  5. *
  6. * Copyright (C) 2007-2009 STMicroelectronics Ltd
  7. * Copyright (C) 2021 Toshiba Electronic Devices & Storage Corporation
  8. *
  9. * This file has been derived from the STMicro Linux driver,
  10. * and developed or modified for TC956X.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2, or (at your option)
  15. * any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  25. */
  26. /*! History:
  27. * 20 Jan 2021 : Initial Version
  28. * VERSION : 00-01
  29. *
  30. * 15 Mar 2021 : Base lined
  31. * VERSION : 01-00
  32. *
  33. * 05 Jul 2021 : 1. Used Systick handler instead of Driver kernel timer to process transmitted Tx descriptors.
  34. * 2. XFI interface support and module parameters for selection of Port0 and Port1 interface
  35. * VERSION : 01-00-01
  36. * 15 Jul 2021 : 1. USXGMII/XFI/SGMII/RGMII interface supported without module parameter
  37. * VERSION : 01-00-02
  38. * 20 Jul 2021 : CONFIG_DEBUG_FS_TC956X removed and renamed as CONFIG_DEBUG_FS
  39. * VERSION : 01-00-03
  40. * 22 Jul 2021 : 1. USXGMII/XFI/SGMII/RGMII interface supported with module parameters
  41. * VERSION : 01-00-04
  42. * 23 Jul 2021 : 1. Enable DMA IPA OFFLOAD and FRP by default
  43. * VERSION : 01-00-06
  44. * 02 Sep 2021 : 1. Configuration of Link state L0 and L1 transaction delay for PCIe switch ports & Endpoint.
  45. * VERSION : 01-00-11
  46. * 23 Sep 2021 : 1. Enabling MSI MASK for MAC EVENT Interrupt to process RBU status and update to ethtool statistics
  47. * VERSION : 01-00-14
  48. * 14 Oct 2021 : 1. Moving common Macros to common header file
  49. * VERSION : 01-00-16
  50. * 19 Oct 2021 : 1. Adding M3 SRAM Debug counters to ethtool statistics
  51. * 2. Adding MTL RX Overflow/packet miss count, TX underflow counts,Rx Watchdog value to ethtool statistics.
  52. * VERSION : 01-00-17
  53. * 21 Oct 2021 : 1. Added support for GPIO configuration API
  54. * VERSION : 01-00-18
  55. * 26 Oct 2021 : 1. Added macro to enable/disable EEE.
  56. : 2. Added enums for PM Suspend-Resume.
  57. : 3. Added macros for EEE, LPI Timer and MAC RST Status.
  58. * VERSION : 01-00-19
  59. * 04 Nov 2021 : 1. Disabled link state latency configuration for all PCIe ports by default
  60. * VERSION : 01-00-20
  61. * 08 Nov 2021 : 1. Added macro for Maximum Port
  62. * VERSION : 01-00-21
  63. * 24 Nov 2021 : 1. Single Port Suspend/Resume supported
  64. * VERSION : 01-00-22
  65. * 24 Nov 2021 : 1. EEE update for runtime configuration and LPI interrupt disabled.
  66. * VERSION : 01-00-24
  67. * 08 Dec 2021 : 1. Added Macro for Maximum Tx, Rx Queue Size and byte size.
  68. * VERSION : 01-00-30
  69. * 10 Dec 2021 : 1. Added link partner pause frame count debug counters to ethtool statistics.
  70. * VERSION : 01-00-31
  71. * 27 Dec 2021 : 1. Support for eMAC Reset and unused clock disable during Suspend and restoring it back during resume.
  72. * VERSION : 01-00-32
  73. * 24 Jan 2022 : 1. Set Clock control and Reset control register to default value on driver unload.
  74. * VERSION : 01-00-38
  75. * 31 Jan 2022 : 1. Additional macros defined for debug dump API usage.
  76. * VERSION : 01-00-39
  77. * 04 Feb 2021 : 1. Ethtool statistics added to print doorbell SRAM area for all the channels.
  78. * VERSION : 01-00-41
  79. * 14 Feb 2021 : 1. Reset assert and clock disable support during Link Down.
  80. * VERSION : 01-00-42
  81. * 06 Apr 2022 : 1.Max MTU supported is 2000 bytes.
  82. * VERSION : 01-00-48
  83. */
  84. #ifndef __COMMON_H__
  85. #define __COMMON_H__
  86. #include <linux/etherdevice.h>
  87. #include <linux/netdevice.h>
  88. #include "tc956xmac_inc.h"
  89. #include <linux/phy.h>
  90. #include <linux/module.h>
  91. #include <net/pkt_sched.h>
  92. #include <net/pkt_cls.h>
  93. #if IS_ENABLED(CONFIG_VLAN_8021Q)
  94. #define TC956XMAC_VLAN_TAG_USED
  95. #include <linux/if_vlan.h>
  96. #endif
  97. #include "descs.h"
  98. #include "hwif.h"
  99. #include "mmc.h"
  100. #ifdef TC956X
  101. #ifndef TC956X_SRIOV_VF
  102. #include "tc956x_xpcs.h"
  103. #endif
  104. #include "tc956x_pma.h"
  105. #endif
  106. /* Enable DMA IPA offload */
  107. #define TC956X_DMA_OFFLOAD_ENABLE
  108. //#define TC956X_LPI_INTERRUPT
  109. /* Indepenedent Suspend/Resume Debug */
  110. #undef TC956X_PM_DEBUG
  111. #define TC956X_MAX_PORT 2
  112. #define TC956X_ALL_MAC_PORT_SUSPENDED 0 /* All EMAC Port Suspended. To be used just after suspend and before resume. */
  113. #define TC956X_NO_MAC_DEVICE_IN_USE 0 /* No EMAC Port in use. To be used at probe and remove. */
  114. #define TC956X_SINGLE_MAC_DEVICE_IN_USE 1 /* One of the EMAC Port in use. To be used at remove. */
  115. #define TC956X_ALL_MAC_PORT_LINK_DOWN 2 /* All ports are Link Down */
  116. /* Suspend-Resume Arguments */
  117. enum TC956X_PORT_PM_STATE {
  118. SUSPEND = 0,
  119. RESUME,
  120. };
  121. /* Link Down Change Power State Arguments */
  122. enum TC956X_PORT_LINK_CHANGE_STATE {
  123. LINK_DOWN = 0,
  124. LINK_UP,
  125. };
  126. #if defined(TC956X_SRIOV_PF)
  127. //#define TC956X_PCIE_LINK_STATE_LATENCY_CTRL
  128. #define TC956X_PCIE_DSP_CUT_THROUGH
  129. #endif
  130. #define DISABLE 0x0U
  131. #define ENABLE 0x1U
  132. #define SIZE_512B 0x200U
  133. #define SIZE_1KB 0x400U
  134. /* Synopsys Core versions */
  135. #define DWMAC_CORE_3_40 0x34
  136. #define DWMAC_CORE_3_50 0x35
  137. #define DWMAC_CORE_4_00 0x40
  138. #define DWMAC_CORE_4_10 0x41
  139. #define DWMAC_CORE_5_00 0x50
  140. #define DWMAC_CORE_5_10 0x51
  141. #define DWXGMAC_CORE_2_10 0x21
  142. #define DWXGMAC_CORE_3_01 0x30
  143. //#define DISABLE_EMAC_PORT1
  144. #ifndef TC956X_SRIOV_VF
  145. #define EEE /* Enable for EEE support */
  146. #endif
  147. #define TC956X_MAC_ADDR_CNT 6
  148. /* Note: Multiple macro definitions for TC956X_PCIE_LOGSTAT and TC956X_PCIE_LOGSTAT_SUMMARY_ENABLE.
  149. * Please also define/undefine same macro in tc956xmac_ioctl.h, if changing in this file
  150. */
  151. /* #undef TC956X_PCIE_LOGSTAT */
  152. #define TC956X_PCIE_LOGSTAT
  153. #ifdef TC956X_PCIE_LOGSTAT
  154. /* Enable/Disable Logstat Summary Print during probe and resume. */
  155. #undef TC956X_PCIE_LOGSTAT_SUMMARY_ENABLE
  156. #endif
  157. /* This macro to be enabled for loading cbs based on speed change */
  158. // #define TC956X_DYNAMIC_LOAD_CBS
  159. /* This macro to be enabled while running TSN demo Application */
  160. // #define TSN_DEMO_AUTOMOTIVE
  161. #define TC956X_M3_DMEM_OFFSET 0x40000
  162. #define MAC2MAC_ETH0_RXDESC_L 0x7800
  163. #define MAC2MAC_ETH0_RXDESC_H 0x7804
  164. #define MAC2MAC_ETH1_RXDESC_L 0xB800
  165. #define MAC2MAC_ETH1_RXDESC_H 0xB804
  166. //#define TX_LOGGING_TRACE
  167. //#define RX_LOGGING_TRACE
  168. #define TC956XMAC_CHAN0 0 /* Always supported and default for all chips */
  169. //#define TC956X_SRIOV_PF
  170. #define TC956X_SRIOV_LOCK
  171. //#define TC956X_SRIOV_DEBUG
  172. #define TC956XMAC_CHA_NO_0 BIT(0)
  173. #define TC956XMAC_CHA_NO_1 BIT(1)
  174. #define TC956XMAC_CHA_NO_2 BIT(2)
  175. #define TC956XMAC_CHA_NO_3 BIT(3)
  176. #ifdef TC956X_SRIOV_PF
  177. /* VF number for each VF Application */
  178. #define TC956XMAC_VF_IVI 1
  179. #define TC956XMAC_VF_TCU 2
  180. #define TC956XMAC_VF_ADAS 3
  181. #if defined(TC956X_AUTOMOTIVE_CONFIG) || defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  182. /* Legacy channel for each VF Application */
  183. #define TC956XMAC_CHA_IVI TC956XMAC_CHA_NO_0
  184. #define TC956XMAC_CHA_TCU TC956XMAC_CHA_NO_0
  185. #define TC956XMAC_CHA_ADAS TC956XMAC_CHA_NO_0
  186. #define TC956XMAC_CHA_PF TC956XMAC_CHA_NO_0
  187. #if defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  188. #define TC956XMAC_CHA_M2M TC956XMAC_CHA_NO_2
  189. #endif
  190. #else
  191. /* Legacy channel for each VF Application */
  192. #define TC956XMAC_CHA_IVI TC956XMAC_CHA_NO_0
  193. #define TC956XMAC_CHA_TCU TC956XMAC_CHA_NO_1
  194. #define TC956XMAC_CHA_ADAS TC956XMAC_CHA_NO_2
  195. #define TC956XMAC_CHA_PF TC956XMAC_CHA_NO_3
  196. #endif
  197. #endif
  198. #if defined(TC956X_SRIOV_PF) && !defined(TC956X_AUTOMOTIVE_CONFIG) && !defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  199. #define TC956X_TOT_MSI_VEC 2
  200. #else
  201. #define TC956X_TOT_MSI_VEC 1
  202. #endif
  203. #define TC956X_MSI_VECTOR_0 0
  204. #define TC956X_MSI_VECTOR_1 1
  205. #define ETH_DMA_DUMP_OFFSET1 (0x3000 / 4)
  206. #define ETH_DMA_DUMP_OFFSET1_END (0x30A0 / 4)
  207. #define ETH_DMA_DUMP_OFFSET2 (0x3100 / 4)
  208. #define ETH_CORE_DUMP_OFFSET1 (0x0)
  209. #define ETH_CORE_DUMP_OFFSET1_END (0xe0 / 4)
  210. #define ETH_CORE_DUMP_OFFSET2 (0x110 / 4)
  211. #define ETH_CORE_DUMP_OFFSET2_END (0xdd0 / 4)
  212. #define ETH_CORE_DUMP_OFFSET3 (0x1000 / 4)
  213. #define ETH_CORE_DUMP_OFFSET3_END (0x10f4 / 4)
  214. #define ETH_CORE_DUMP_OFFSET4 (0x1100 / 4)
  215. #define ETH_CORE_DUMP_OFFSET4_END (0x1108 / 4)
  216. #define ETH_CORE_DUMP_OFFSET5 (0x1110 / 4)
  217. #define ETH_CORE_DUMP_OFFSET5_END (0x1124 / 4)
  218. #define ETH_CORE_DUMP_OFFSET6 (0x1140 / 4)
  219. #define ETH_CORE_DUMP_OFFSET6_END (0x1174 / 4)
  220. /* 0x20004000 to 0x2000401C is for Port0, 0x20004020 to 0x2000403C is for Port1 */
  221. #define SRAM_TX_PCIE_ADDR_LOC 0x44000
  222. /* 0x20004040 to 0x2000405C is for Port0, 0x20004060 to 0x2000407C is for Port1 */
  223. #define SRAM_RX_PCIE_ADDR_LOC 0x44040
  224. #ifdef CONFIG_DEBUG_FS
  225. #ifdef TC956X
  226. int tc956xmac_init(void);
  227. #endif
  228. #ifdef TC956X
  229. void tc956xmac_exit(void);
  230. #endif
  231. #endif
  232. #ifdef TC956X_SRIOV_PF
  233. /* TC956X Semaphore lock/unlock register */
  234. #define NSEM(reg) (0x1100 + (reg * 4))
  235. /* TC956X Semaphore read register */
  236. #define NSEM_RD(reg) (0x1140 + (reg * 4))
  237. #define MBX_MSG_OFST 4 /* First 4 bytes for ACK management */
  238. #define MBX_MSG_SIZE 60 /* Excluding ACK */
  239. #define MBX_ACK_SIZE 4 /* ACK management */
  240. #define MBX_TOT_SIZE (MBX_MSG_SIZE + MBX_ACK_SIZE)
  241. #define ACK 0x01
  242. #define NACK 0x02
  243. #define MAX_NO_OF_VFS 3
  244. /* Mailbox opcode definitions */
  245. #define OPCODE_MBX_ADD_MAC_ADDR 0x01
  246. #define OPCODE_MBX_SET_TX_Q_WEIGHT 0x02
  247. #define OPCODE_MBX_CFG_CBS 0x03
  248. #define OPCODE_MBX_SET_TX_Q_PRIOR 0x04
  249. #define OPCODE_MBX_RESET_EEE_MODE 0x05
  250. #define OPCODE_MBX_VF_IOCTL 0x06
  251. #define OPCODE_MBX_VF_ETHTOOL 0x07
  252. #define OPCODE_MBX_VF_ADD_MAC 0x08
  253. #define OPCODE_MBX_VF_DELETE_MAC 0x09
  254. #define OPCODE_MBX_VF_ADD_VLAN 0x10
  255. #define OPCODE_MBX_VF_DELETE_VLAN 0x11
  256. #define OPCODE_MBX_SET_DMA_TX_MODE 0x12
  257. #define OPCODE_MBX_VF_GET_LINK_STATUS 0x13
  258. #define OPCODE_MBX_PHY_LINK 0x14
  259. #define OPCODE_MBX_SETUP_CBS 0x15
  260. #define OPCODE_MBX_RX_CRC 0x16
  261. #define OPCODE_MBX_RX_CSUM 0x17
  262. #define OPCODE_MBX_DRV_CAP 0x18
  263. #define OPCODE_MBX_VF_GET_MII_PHY 0x23
  264. #define TC956XMAC_GET_PAUSE_PARAM_2 0x24
  265. #define OPCODE_MBX_GET_UMAC_ADDR 0x25
  266. #define OPCODE_VF_RESET 0x26
  267. #define OPCODE_MBX_DMA_CH_TLPTR 0x29
  268. #define OPCODE_MBX_SETUP_ETF 0x30
  269. #define OPCODE_MBX_FLR 0x33
  270. #define OPCODE_MBX_DMA_ERR 0x34
  271. #define OPCODE_MBX_ACK_MSG 0xFF
  272. #define SIZE_MBX_SET_TX_Q_WEIGHT 8
  273. #define SIZE_MBX_CFG_CBS 20
  274. #define SIZE_MBX_SETUP_ETF 5
  275. #define SIZE_MBX_CFG_EST 540 /* 28 + (4*128) */
  276. #define SIZE_MBX_CFG_FPE 20
  277. #define SIZE_MBX_SETUP_CBS 21
  278. #define SIZE_MBX_SET_TX_Q_PRIOR 8
  279. #define SIZE_MBX_SET_DMA_TX_MODE 13
  280. #define SIZE_MBX_VF_GET_LINK_STATUS 0
  281. #define SIZE_MBX_PHY_LINK 12
  282. #define SIZE_MBX_RX_CRC 4
  283. #define SIZE_MBX_RX_CSUM 4
  284. #define SIZE_MBX_DRV_CAP 4
  285. #define SIZE_GET_UMAC_ADDR 4
  286. #define SIZE_SET_UMAC_ADDR 10
  287. #define SIZE_MBX_VF_MAC 6
  288. #define SIZE_MBX_VF_VLAN 2
  289. #define SIZE_MBX_VF_REG_WR 13
  290. #define SIZE_MBX_VF_SPEED 1
  291. #define SIZE_MBX_SET_GET_CBS_1 56
  292. #define SIZE_MBX_SET_GET_RXP_1 56
  293. #define SIZE_MBX_SET_GET_CBS_2 44
  294. #define SIZE_MBX_VF_PAUSE_PARAM 1
  295. #define SIZE_MBX_VF_EEE 1
  296. #define SIZE_MBX_VF_TS_INFO 1
  297. #define SIZE_VF_RESET 1
  298. #define SIZE_MBX_VF_TIMESTAMP 2
  299. #define SIZE_MBX_SET_GET_EST_1 56
  300. #define SIZE_MBX_RX_DMA_TL_PTR 4
  301. #define SIZE_MBX_SET_GET_FPE_1 20
  302. #define SIZE_MBX_GET_HW_STMP 12
  303. #define MAX_SIZE_GCL_MSG 14
  304. #define EST_FIX_MSG_LEN 28
  305. #define RXP_FIX_MSG_LEN 16
  306. #define VF_UP 1
  307. #define VF_DOWN 0
  308. #define VF_SUSPEND 2
  309. #define VF_RELEASE 3
  310. #define SCH_WQ_PHY_REG_RD 1
  311. #define SCH_WQ_RX_DMA_ERR 2
  312. #define SCH_WQ_GET_PAUSE_PARAM 3
  313. #endif /* #ifdef TC956X_SRIOV_PF */
  314. #ifdef TC956X_SRIOV_VF
  315. #define TC956X_MIN_MSI_VEC 1
  316. #define TC956X_MAX_MSI_VEC 1
  317. #define TC956X_MSI_VECTOR_0 0
  318. #define TC956X_MSI_VECTOR_1 1
  319. #endif
  320. enum mbx_msg_fns {
  321. mcu = 0,
  322. pf0 = 1,
  323. pf1 = 2,
  324. vf0 = 3,
  325. vf1 = 4,
  326. vf2 = 5
  327. };
  328. struct fn_id {
  329. bool fn_type; /*0 - PF; 1-VF*/
  330. u8 pf_no; /* PF number [0-1], In case of VF, this gives information
  331. * about associated PF
  332. */
  333. u8 vf_no; /*VF number [1-3]*/
  334. };
  335. /* Packets types */
  336. enum packets_types {
  337. PACKET_AVCPQ = 0x1, /* AV Untagged Control packets */
  338. PACKET_PTPQ = 0x2, /* PTP Packets */
  339. PACKET_DCBCPQ = 0x3, /* DCB Control Packets */
  340. PACKET_UPQ = 0x4, /* Untagged Packets */
  341. PACKET_MCBCQ = 0x5, /* Multicast & Broadcast Packets */
  342. #ifdef TC956X
  343. PACKET_FPE_RESIDUE = 0x6, /* Frame Pre-emption residue packets */
  344. #endif
  345. #if defined(TC956X_SRIOV_PF) && !defined(TC956X_AUTOMOTIVE_CONFIG) && !defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  346. PACKET_FILTER_FAIL = 0x7, /* Filter Fail packets */
  347. #endif
  348. };
  349. //#define TX_LOGGING_TRACE
  350. /* Dual Port related Macros */
  351. #define RM_PF0_ID (0)
  352. #define RM_PF1_ID (1)
  353. #define RM_IS_PF (0)
  354. #define RM_IS_VF (1)
  355. #define MAC_PORT_NUM_CHECK (priv->port_num == RM_PF0_ID)
  356. /* Select the MDC range based on PHY specification.
  357. * IEEE recommends max of 2.5MHz. But if PHY supports more than that, then it can be used
  358. */
  359. #define PORT0_MDC TC956XMAC_XGMAC_MDC_CSR_12
  360. #define PORT1_MDC TC956XMAC_XGMAC_MDC_CSR_62
  361. #ifdef TC956X
  362. #define PORT0_C45_STATE true
  363. #define PORT1_C45_STATE false
  364. #endif
  365. #if defined(TX_LOGGING_TRACE)
  366. #define PACKET_IPG 125000
  367. #define PACKET_CDT_IPG 500000
  368. #endif
  369. #define TC956X_M3_FW_EXIT_VALUE 2
  370. #ifdef TC956X
  371. #define TC956X_AVB_PRIORITY_CLASS_A (3)
  372. #define TC956X_AVB_PRIORITY_CLASS_B (2)
  373. #define TC956X_PRIORITY_CLASS_CDT (7)
  374. /* skip the addresses added during hw setup*/
  375. /*
  376. * Note: If source address (SA) replacement or SA insertion feature is
  377. * supported, MAC_ADDR_ADD_SKIP_OFST should be increased accordingly
  378. */
  379. #define TC956X_MAX_PERFECT_ADDRESSES 32
  380. #define TC956X_MAX_PERFECT_VLAN 16
  381. #if defined(TC956X_SRIOV_PF) && !defined(TC956X_AUTOMOTIVE_CONFIG) && !defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  382. #define XGMAC_ADDR_ADD_SKIP_OFST 6
  383. #else
  384. #define XGMAC_ADDR_ADD_SKIP_OFST 3
  385. #endif
  386. #define TC956X_MAC_STATE_VACANT 0x0
  387. #define TC956X_MAC_STATE_OCCUPIED 0x1
  388. #define TC956X_MAC_STATE_NEW 0x2
  389. #define TC956X_MAC_STATE_MODIFIED 0x4
  390. /* C45 registers for Port0 PHY */
  391. /* CL45_CTRL_REG is the equivalent of CL22 BMCR */
  392. #define PHY0_CL45_CTRL_REG_MMD_BANK (7)
  393. #define PHY0_CL45_CTRL_REG_ADDR (0x0)
  394. /* CL45_STATUS_REG is the equivalent of CL22 BMSR */
  395. #define PHY0_CL45_STATUS_REG_MMD_BANK (7)
  396. #define PHY0_CL45_STATUS_REG_ADDR (0x1)
  397. /* CL45_PHYID1 is the equivalent of CL22 PHYIDR1 */
  398. #define PHY0_CL45_PHYID1_MMD_BANK (1)
  399. #define PHY0_CL45_PHYID1_ADDR (2)
  400. /* CL45_PHYID1 is the equivalent of CL22 PHYIDR2 */
  401. #define PHY0_CL45_PHYID2_MMD_BANK (1)
  402. #define PHY0_CL45_PHYID2_ADDR (3)
  403. #define PHY0_CL45_PHYID1_REG \
  404. ((PHY0_CL45_PHYID1_MMD_BANK << 16) | (PHY0_CL45_PHYID1_ADDR))
  405. #define PHY0_CL45_PHYID2_REG \
  406. ((PHY0_CL45_PHYID2_MMD_BANK << 16) | (PHY0_CL45_PHYID2_ADDR))
  407. /* C45 registers for Port1 PHY */
  408. /* CL45_CTRL_REG is the equivalent of CL22 BMCR */
  409. #define PHY1_CL45_CTRL_REG_MMD_BANK (7)
  410. #define PHY1_CL45_CTRL_REG_ADDR (0x0)
  411. /* CL45_STATUS_REG is the equivalent of CL22 BMSR */
  412. #define PHY1_CL45_STATUS_REG_MMD_BANK (7)
  413. #define PHY1_CL45_STATUS_REG_ADDR (0x1)
  414. /* CL45_PHYID1 is the equivalent of CL22 PHYIDR1 */
  415. #define PHY1_CL45_PHYID1_MMD_BANK (1)
  416. #define PHY1_CL45_PHYID1_ADDR (2)
  417. /* CL45_PHYID1 is the equivalent of CL22 PHYIDR2 */
  418. #define PHY1_CL45_PHYID2_MMD_BANK (1)
  419. #define PHY1_CL45_PHYID2_ADDR (3)
  420. #define PHY1_CL45_PHYID1_REG \
  421. ((PHY1_CL45_PHYID1_MMD_BANK << 16) | (PHY1_CL45_PHYID1_ADDR))
  422. #define PHY1_CL45_PHYID2_REG \
  423. ((PHY1_CL45_PHYID2_MMD_BANK << 16) | (PHY1_CL45_PHYID2_ADDR))
  424. /* CL45_CTRL_REG is the equivalent of CL22 BMCR */
  425. #define PHY_CL45_CTRL_REG_MMD_BANK ((MAC_PORT_NUM_CHECK) ? \
  426. (PHY0_CL45_CTRL_REG_MMD_BANK) : (PHY1_CL45_CTRL_REG_MMD_BANK))
  427. #define PHY_CL45_CTRL_REG_ADDR ((MAC_PORT_NUM_CHECK) ? \
  428. (PHY0_CL45_CTRL_REG_ADDR) : (PHY1_CL45_CTRL_REG_ADDR))
  429. /* CL45_STATUS_REG is the equivalent of CL22 BMSR */
  430. #define PHY_CL45_STATUS_REG_MMD_BANK ((MAC_PORT_NUM_CHECK) ? \
  431. (PHY0_CL45_STATUS_REG_MMD_BANK) : (PHY1_CL45_STATUS_REG_MMD_BANK))
  432. #define PHY_CL45_STATUS_REG_ADDR ((MAC_PORT_NUM_CHECK) ? \
  433. (PHY0_CL45_STATUS_REG_ADDR) : (PHY1_CL45_STATUS_REG_ADDR))
  434. /* CL45_PHYID1 is the equivalent of CL22 PHYIDR1 */
  435. #define PHY_CL45_PHYID1_MMD_BANK ((MAC_PORT_NUM_CHECK) ? \
  436. (PHY0_CL45_PHYID1_MMD_BANK) : (PHY1_CL45_PHYID1_MMD_BANK))
  437. #define PHY_CL45_PHYID1_ADDR ((MAC_PORT_NUM_CHECK) ? \
  438. (PHY0_CL45_PHYID1_ADDR) : (PHY1_CL45_PHYID1_ADDR))
  439. /* CL45_PHYID1 is the equivalent of CL22 PHYIDR2 */
  440. #define PHY_CL45_PHYID2_MMD_BANK ((MAC_PORT_NUM_CHECK) ? \
  441. (PHY0_CL45_PHYID2_MMD_BANK) : (PHY1_CL45_PHYID2_MMD_BANK))
  442. #define PHY_CL45_PHYID2_ADDR ((MAC_PORT_NUM_CHECK) ? \
  443. (PHY0_CL45_PHYID2_ADDR) : (PHY1_CL45_PHYID2_ADDR))
  444. #define PHY_CL45_PHYID1_REG ((MAC_PORT_NUM_CHECK) ? \
  445. (PHY0_CL45_PHYID1_REG) : (PHY1_CL45_PHYID1_REG))
  446. #define PHY_CL45_PHYID2_REG ((MAC_PORT_NUM_CHECK) ? \
  447. (PHY0_CL45_PHYID2_REG) : (PHY1_CL45_PHYID2_REG))
  448. #define NFUNCEN4_OFFSET (0x1528)
  449. #define MAX_RX_QUEUE_SIZE 47104 /* 46KB Maximun RX Queue size */
  450. #define MAX_TX_QUEUE_SIZE 47104 /* 46KB Maximun TX Queue size */
  451. #if defined(TC956X_SRIOV_PF) && !defined(TC956X_AUTOMOTIVE_CONFIG) && !defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  452. /************************ TC956X_SRIOV_PF Starts ************************/
  453. #define TC956X_DMA_RX_AIS BIT(14)
  454. #define TC956X_DMA_RX_FBE BIT(12)
  455. #define TC956X_DMA_RX_RPS BIT(8)
  456. #define MAX_TX_QUEUES_TO_USE 8
  457. #define MAX_RX_QUEUES_TO_USE 8
  458. /* Tx Queue Size*/
  459. #define TX_QUEUE0_SIZE 4096
  460. #define TX_QUEUE1_SIZE 4096
  461. #define TX_QUEUE2_SIZE 18432
  462. #define TX_QUEUE3_SIZE 4096
  463. #define TX_QUEUE4_SIZE 1024
  464. #define TX_QUEUE5_SIZE 4096
  465. #define TX_QUEUE6_SIZE 4096
  466. #define TX_QUEUE7_SIZE 4096
  467. /* TX Queue 0: Legacy and Jumbo packets */
  468. #define TX_QUEUE0_MODE MTL_QUEUE_DCB
  469. /* TX Queue 1:Legacy*/
  470. #define TX_QUEUE1_MODE MTL_QUEUE_DCB
  471. /* TX Queue 2: Legacy */
  472. #define TX_QUEUE2_MODE MTL_QUEUE_DCB
  473. /* TX Queue 3: Legacy */
  474. #define TX_QUEUE3_MODE MTL_QUEUE_DCB
  475. /* TX Queue 4: Untagged PTP */
  476. #define TX_QUEUE4_MODE MTL_QUEUE_DCB
  477. /* TX Queue 5: AVB Class B AVTP packet */
  478. #define TX_QUEUE5_MODE MTL_QUEUE_AVB
  479. /* TX Queue 6: AVB Class A AVTP packet */
  480. #define TX_QUEUE6_MODE MTL_QUEUE_AVB
  481. /* TX Queue 7: TSN Class CDT packet */
  482. #if defined(TSN_DEMO_AUTOMOTIVE)
  483. #define TX_QUEUE7_MODE MTL_QUEUE_DCB
  484. #else
  485. #define TX_QUEUE7_MODE MTL_QUEUE_AVB
  486. #endif
  487. /* Tx Queue TBS Enable/Disable */
  488. #define TX_QUEUE0_TBS 0
  489. #define TX_QUEUE1_TBS 0
  490. #define TX_QUEUE2_TBS 0
  491. #define TX_QUEUE3_TBS 0
  492. #define TX_QUEUE4_TBS 0
  493. #define TX_QUEUE5_TBS 1
  494. #define TX_QUEUE6_TBS 1
  495. #define TX_QUEUE7_TBS 1
  496. /* Tx Queue TSO Enable/Disable */
  497. #define TX_QUEUE0_TSO 1
  498. #define TX_QUEUE1_TSO 1
  499. #define TX_QUEUE2_TSO 1
  500. #define TX_QUEUE3_TSO 1
  501. #define TX_QUEUE4_TSO 0
  502. #define TX_QUEUE5_TSO 0
  503. #define TX_QUEUE6_TSO 0
  504. #define TX_QUEUE7_TSO 0
  505. /* Configure TxQueue - Traffic Class mapping */
  506. #define TX_QUEUE0_TC 0x0
  507. #define TX_QUEUE1_TC 0x0
  508. #define TX_QUEUE2_TC 0x0
  509. #define TX_QUEUE3_TC 0x0
  510. #define TX_QUEUE4_TC 0x1
  511. #define TX_QUEUE5_TC 0x2
  512. #define TX_QUEUE6_TC 0x3
  513. #define TX_QUEUE7_TC 0x4
  514. /*
  515. * RX Queue 0: Unicast/Untagged Packets - Packets with
  516. * unique MAC Address of Host/Guest OS DMA channel selection will be based on
  517. * MAC_Address(#i)_High.DCS
  518. */
  519. #define RX_QUEUE0_MODE MTL_QUEUE_DCB
  520. /* RX Queue 1: VLAN Tagged Legacy packets- Pkt routing will be based on VLAN */
  521. #define RX_QUEUE1_MODE MTL_QUEUE_DCB
  522. /* RX Queue 2: Untagged gPTP packets */
  523. #define RX_QUEUE2_MODE MTL_QUEUE_DCB
  524. /* RX Queue 3: Filter Fail packet queue */
  525. #define RX_QUEUE3_MODE MTL_QUEUE_DCB
  526. /* RX Queue 4: AVB Class B AVTP packets */
  527. #define RX_QUEUE4_MODE MTL_QUEUE_AVB
  528. /* RX Queue 5: AVB Class A AVTP packets */
  529. #define RX_QUEUE5_MODE MTL_QUEUE_AVB
  530. /* RX Queue 6:TSN Class CDT packets */
  531. #define RX_QUEUE6_MODE MTL_QUEUE_AVB
  532. /* RX Queue 7: Broadcast/Multicast packets */
  533. #define RX_QUEUE7_MODE MTL_QUEUE_DCB
  534. /* Rx Queue Size */
  535. #define RX_QUEUE0_SIZE 18432
  536. #define RX_QUEUE1_SIZE 4096
  537. #define RX_QUEUE2_SIZE 1024
  538. #define RX_QUEUE3_SIZE 4096
  539. #define RX_QUEUE4_SIZE 4096
  540. #define RX_QUEUE5_SIZE 4096
  541. #define RX_QUEUE6_SIZE 4096
  542. #define RX_QUEUE7_SIZE 4096
  543. /* Rx Queue Packet Routing */
  544. #define RX_QUEUE0_PKT_ROUTE PACKET_UPQ
  545. #define RX_QUEUE1_PKT_ROUTE 0
  546. #define RX_QUEUE2_PKT_ROUTE PACKET_PTPQ
  547. #define RX_QUEUE3_PKT_ROUTE PACKET_FILTER_FAIL
  548. /* Queue 4,5,6 Routed based on Packet Priority Configured in
  549. * MAC_RxQ_Ctrl2/MAC_RxQ_Ctrl3
  550. */
  551. #define RX_QUEUE4_PKT_ROUTE 0
  552. #define RX_QUEUE5_PKT_ROUTE 0
  553. #define RX_QUEUE6_PKT_ROUTE 0
  554. #define RX_QUEUE7_PKT_ROUTE PACKET_MCBCQ
  555. #define TC956X_DA_MAP 0xF
  556. /* Unicast/Untagged packet */
  557. #define LEG_UNTAGGED_PACKET TC956X_DA_MAP
  558. /* VLAN tagged packets */
  559. #define LEG_TAGGED_PACKET TC956X_DA_MAP
  560. /* Untagged gPTP packet */
  561. #define UNTAGGED_GPTP_PACKET 4
  562. /* Filter Failed Unicast, Multicast, Tagged packets.
  563. * Route to PF Best Effort Channel. Used only in SRIOV promiscuous mode
  564. */
  565. #define FILTER_FAIL_PACKET 3
  566. /* Class B AVB Packet */
  567. #define AVB_CLASS_B_PACKET 5
  568. /* Class A AVB Packet */
  569. #define AVB_CLASS_A_PACKET 6
  570. /* TSN Class CDT Packet */
  571. #define TSN_CLASS_CDT_PACKET 7
  572. /* Broadcast/Multicast packet */
  573. #define BC_MC_PACKET TC956X_DA_MAP
  574. #define TX_QUEUE0_USE_PRIO true
  575. #define TX_QUEUE1_USE_PRIO true
  576. #define TX_QUEUE2_USE_PRIO true
  577. #define TX_QUEUE3_USE_PRIO true
  578. #define TX_QUEUE4_USE_PRIO false
  579. #define TX_QUEUE5_USE_PRIO false
  580. #define TX_QUEUE6_USE_PRIO false
  581. #define TX_QUEUE7_USE_PRIO false
  582. #define TX_QUEUE0_PRIO 0xFF /* TC0 Priority */
  583. #define TX_QUEUE1_PRIO 0xFF
  584. #define TX_QUEUE2_PRIO 0xFF
  585. #define TX_QUEUE3_PRIO 0xFF
  586. #define TX_QUEUE4_PRIO 0x00
  587. #define TX_QUEUE5_PRIO 0x00
  588. #define TX_QUEUE6_PRIO 0x00
  589. #define TX_QUEUE7_PRIO 0x00
  590. /* Rx Queue Use Priority */
  591. #define RX_QUEUE0_USE_PRIO false
  592. #define RX_QUEUE1_USE_PRIO true
  593. #define RX_QUEUE2_USE_PRIO false
  594. #define RX_QUEUE3_USE_PRIO false
  595. #define RX_QUEUE4_USE_PRIO true
  596. #define RX_QUEUE5_USE_PRIO true
  597. #define RX_QUEUE6_USE_PRIO true
  598. #define RX_QUEUE7_USE_PRIO false
  599. /* Rx Queue VLAN tagged Priority mapping */
  600. #define RX_QUEUE0_PRIO 0
  601. #define RX_QUEUE1_PRIO 0xFF
  602. #define RX_QUEUE2_PRIO 0
  603. #define RX_QUEUE3_PRIO 0
  604. #define RX_QUEUE4_PRIO (1 << TC956X_AVB_PRIORITY_CLASS_B)
  605. #define RX_QUEUE5_PRIO (1 << TC956X_AVB_PRIORITY_CLASS_A)
  606. #define RX_QUEUE6_PRIO (1 << TC956X_PRIORITY_CLASS_CDT)
  607. #define RX_QUEUE7_PRIO 0
  608. #define EEPROM_OFFSET 0
  609. #define EEPROM_MAC_COUNT 8
  610. /* DMA Ch allocation in tx-rx pairs for PF & VF */
  611. #define TC956X_PF_CH_ALLOC 0x18 /* PF - Ch 3, 4 */
  612. #define TC956X_VF0_CH_ALLOC 0x21 /* VF0 - Ch 0, 5 */
  613. #define TC956X_VF1_CH_ALLOC 0x02 /* VF1 - Ch 1 */
  614. #define TC956X_VF2_CH_ALLOC 0xC4 /* VF2 - Ch 2, 6, 7 */
  615. /************************* TC956X_SRIOV_PF Ends *************************/
  616. #elif defined(TC956X_SRIOV_PF)
  617. /***************** Automotive and Port Bridge Config Starts *************/
  618. #if defined(TC956X_DMA_OFFLOAD_ENABLE)
  619. #define TX_DMA_CH0_OWNER USE_IN_TC956X_SW
  620. #define TX_DMA_CH1_OWNER NOT_USED
  621. #define TX_DMA_CH2_OWNER USE_IN_TC956X_SW
  622. #define TX_DMA_CH3_OWNER USE_IN_TC956X_SW
  623. #define TX_DMA_CH4_OWNER USE_IN_TC956X_SW
  624. #define TX_DMA_CH5_OWNER USE_IN_TC956X_SW
  625. #define TX_DMA_CH6_OWNER USE_IN_TC956X_SW
  626. #define TX_DMA_CH7_OWNER USE_IN_TC956X_SW
  627. #define RX_DMA_CH0_OWNER USE_IN_TC956X_SW
  628. #define RX_DMA_CH1_OWNER NOT_USED
  629. #define RX_DMA_CH2_OWNER USE_IN_TC956X_SW
  630. #define RX_DMA_CH3_OWNER USE_IN_TC956X_SW
  631. #define RX_DMA_CH4_OWNER USE_IN_TC956X_SW
  632. #define RX_DMA_CH5_OWNER USE_IN_TC956X_SW
  633. #define RX_DMA_CH6_OWNER USE_IN_TC956X_SW
  634. #define RX_DMA_CH7_OWNER USE_IN_TC956X_SW
  635. #endif
  636. #define TC956X_DMA_RX_AIS BIT(14)
  637. #define TC956X_DMA_RX_FBE BIT(12)
  638. #define TC956X_DMA_RX_RPS BIT(8)
  639. #define MAX_TX_QUEUES_TO_USE 8
  640. #define MAX_RX_QUEUES_TO_USE 8
  641. /* Tx Queue Size*/
  642. #ifdef TC956X_ENABLE_MAC2MAC_BRIDGE
  643. #define TX_QUEUE0_SIZE 18432
  644. #define TX_QUEUE1_SIZE 0
  645. #define TX_QUEUE2_SIZE 18432
  646. #define TX_QUEUE3_SIZE 0
  647. #define TX_QUEUE4_SIZE 1024
  648. #define TX_QUEUE5_SIZE 2048
  649. #define TX_QUEUE6_SIZE 2048
  650. #define TX_QUEUE7_SIZE 4096
  651. #else
  652. #define TX_QUEUE0_SIZE 18432
  653. #define TX_QUEUE1_SIZE 14336
  654. #define TX_QUEUE2_SIZE 0
  655. #define TX_QUEUE3_SIZE 0
  656. #define TX_QUEUE4_SIZE 1024
  657. #define TX_QUEUE5_SIZE 4096
  658. #define TX_QUEUE6_SIZE 4096
  659. #define TX_QUEUE7_SIZE 4096
  660. #endif
  661. /* TX Queue 0: Legacy and Jumbo packets */
  662. #define TX_QUEUE0_MODE MTL_QUEUE_DCB
  663. /* TX Queue 1: Legacy */
  664. #define TX_QUEUE1_MODE MTL_QUEUE_DCB
  665. /* TX Queue 2: Legacy */
  666. #define TX_QUEUE2_MODE MTL_QUEUE_DISABLE
  667. /* TX Queue 3: Legacy */
  668. #define TX_QUEUE3_MODE MTL_QUEUE_DISABLE
  669. /* TX Queue 4: Untagged PTP */
  670. #define TX_QUEUE4_MODE MTL_QUEUE_DCB
  671. /* TX Queue 5: AVB Class B AVTP packet */
  672. #define TX_QUEUE5_MODE MTL_QUEUE_AVB
  673. /* TX Queue 6: AVB Class A AVTP packet */
  674. #define TX_QUEUE6_MODE MTL_QUEUE_AVB
  675. /* TX Queue 7: TSN Class CDT packet */
  676. #if defined(TSN_DEMO_AUTOMOTIVE)
  677. #define TX_QUEUE7_MODE MTL_QUEUE_DCB
  678. #else
  679. #define TX_QUEUE7_MODE MTL_QUEUE_AVB
  680. #endif
  681. /* Tx Queue TBS Enable/Disable */
  682. #define TX_QUEUE0_TBS 0
  683. #define TX_QUEUE1_TBS 0
  684. #define TX_QUEUE2_TBS 0
  685. #define TX_QUEUE3_TBS 0
  686. #define TX_QUEUE4_TBS 0
  687. #define TX_QUEUE5_TBS 1
  688. #define TX_QUEUE6_TBS 1
  689. #define TX_QUEUE7_TBS 1
  690. /* Tx Queue TSO Enable/Disable */
  691. #define TX_QUEUE0_TSO 1
  692. #define TX_QUEUE1_TSO 1
  693. #define TX_QUEUE2_TSO 0
  694. #define TX_QUEUE3_TSO 0
  695. #define TX_QUEUE4_TSO 0
  696. #define TX_QUEUE5_TSO 0
  697. #define TX_QUEUE6_TSO 0
  698. #define TX_QUEUE7_TSO 0
  699. /* Configure TxQueue - Traffic Class mapping */
  700. #define TX_QUEUE0_TC 0x0
  701. #define TX_QUEUE1_TC 0x0
  702. #define TX_QUEUE2_TC 0x0
  703. #define TX_QUEUE3_TC 0x0
  704. #define TX_QUEUE4_TC 0x1
  705. #define TX_QUEUE5_TC 0x2
  706. #define TX_QUEUE6_TC 0x3
  707. #define TX_QUEUE7_TC 0x4
  708. /*
  709. * RX Queue 0: Unicast/Untagged Packets - Packets with
  710. * unique MAC Address of Host/Guest OS DMA channel selection will be based on
  711. * MAC_Address(#i)_High.DCS
  712. */
  713. #define RX_QUEUE0_MODE MTL_QUEUE_DCB
  714. /* RX Queue 1: VLAN Tagged Legacy packets- Pkt routing will be based on VLAN */
  715. /* Queue is used for MAC2MAC Usecase */
  716. #define RX_QUEUE1_MODE MTL_QUEUE_DCB
  717. /* RX Queue 2: Untagged gPTP packets */
  718. #define RX_QUEUE2_MODE MTL_QUEUE_DCB
  719. /* RX Queue 3: Untagged AV Control packets */
  720. #define RX_QUEUE3_MODE MTL_QUEUE_AVB
  721. /* RX Queue 4: AVB Class B AVTP packets */
  722. #define RX_QUEUE4_MODE MTL_QUEUE_AVB
  723. /* RX Queue 5: AVB Class A AVTP packets */
  724. #define RX_QUEUE5_MODE MTL_QUEUE_AVB
  725. /* RX Queue 6:TSN Class CDT packets */
  726. #define RX_QUEUE6_MODE MTL_QUEUE_AVB
  727. /* RX Queue 7: Broadcast/Multicast packets */
  728. #define RX_QUEUE7_MODE MTL_QUEUE_DCB
  729. /* Rx Queue Size */
  730. #ifdef TC956X_ENABLE_MAC2MAC_BRIDGE
  731. #define RX_QUEUE0_SIZE 18432
  732. #define RX_QUEUE1_SIZE 18432
  733. #define RX_QUEUE2_SIZE 1024
  734. #define RX_QUEUE3_SIZE 1024
  735. #define RX_QUEUE4_SIZE 2048
  736. #define RX_QUEUE5_SIZE 1024
  737. #define RX_QUEUE6_SIZE 1024
  738. #define RX_QUEUE7_SIZE 4096
  739. #else
  740. #define RX_QUEUE0_SIZE 18432
  741. #define RX_QUEUE1_SIZE 4096
  742. #define RX_QUEUE2_SIZE 1024
  743. #define RX_QUEUE3_SIZE 1024
  744. #define RX_QUEUE4_SIZE 4096
  745. #define RX_QUEUE5_SIZE 4096
  746. #define RX_QUEUE6_SIZE 4096
  747. #define RX_QUEUE7_SIZE 4096
  748. #endif
  749. /* Rx Queue Packet Routing */
  750. #define RX_QUEUE0_PKT_ROUTE PACKET_UPQ
  751. #define RX_QUEUE1_PKT_ROUTE 0
  752. #define RX_QUEUE2_PKT_ROUTE PACKET_PTPQ
  753. #define RX_QUEUE3_PKT_ROUTE PACKET_AVCPQ
  754. /* Queue 4,5,6 Routed based on Packet Priority Configured in
  755. * MAC_RxQ_Ctrl2/MAC_RxQ_Ctrl3
  756. */
  757. #define RX_QUEUE4_PKT_ROUTE 0
  758. #define RX_QUEUE5_PKT_ROUTE 0
  759. #define RX_QUEUE6_PKT_ROUTE 0
  760. #define RX_QUEUE7_PKT_ROUTE PACKET_MCBCQ
  761. #define TC956X_DA_MAP 0xF
  762. /* Unicast/Untagged packet */
  763. #define LEG_UNTAGGED_PACKET 0
  764. /* VLAN tagged packets */
  765. #define LEG_TAGGED_PACKET 0
  766. /* Untagged gPTP packet */
  767. #define UNTAGGED_GPTP_PACKET 4
  768. /* Untagged AV Control Packet */
  769. #define UNTAGGED_AVCTRL_PACKET 3
  770. /* Class B AVB Packet */
  771. #define AVB_CLASS_B_PACKET 5
  772. /* Class A AVB Packet */
  773. #define AVB_CLASS_A_PACKET 6
  774. /* TSN Class CDT Packet */
  775. #define TSN_CLASS_CDT_PACKET 7
  776. /* Broadcast/Multicast packet */
  777. #define BC_MC_PACKET 0
  778. #define TX_QUEUE0_USE_PRIO true
  779. #define TX_QUEUE1_USE_PRIO true
  780. #define TX_QUEUE2_USE_PRIO true
  781. #define TX_QUEUE3_USE_PRIO true
  782. #define TX_QUEUE4_USE_PRIO false
  783. #define TX_QUEUE5_USE_PRIO false
  784. #define TX_QUEUE6_USE_PRIO false
  785. #define TX_QUEUE7_USE_PRIO false
  786. #define TX_QUEUE0_PRIO 0xFF /* TC0 Priority */
  787. #define TX_QUEUE1_PRIO 0xFF
  788. #define TX_QUEUE2_PRIO 0xFF
  789. #define TX_QUEUE3_PRIO 0xFF
  790. #define TX_QUEUE4_PRIO 0x00
  791. #define TX_QUEUE5_PRIO 0x00
  792. #define TX_QUEUE6_PRIO 0x00
  793. #define TX_QUEUE7_PRIO 0x00
  794. /* Rx Queue Use Priority */
  795. #ifdef TC956X_ENABLE_MAC2MAC_BRIDGE
  796. /* RXQ0 used for Host unicast/untagged and vlan tagged packets
  797. RXQ1 used for MAC2MAC */
  798. #define RX_QUEUE0_USE_PRIO true
  799. #define RX_QUEUE1_USE_PRIO false
  800. #else
  801. #define RX_QUEUE0_USE_PRIO false
  802. #define RX_QUEUE1_USE_PRIO true
  803. #endif
  804. #define RX_QUEUE2_USE_PRIO false
  805. #define RX_QUEUE3_USE_PRIO false
  806. #define RX_QUEUE4_USE_PRIO true
  807. #define RX_QUEUE5_USE_PRIO true
  808. #define RX_QUEUE6_USE_PRIO true
  809. #define RX_QUEUE7_USE_PRIO false
  810. /* Rx Queue VLAN tagged Priority mapping */
  811. #ifdef TC956X_ENABLE_MAC2MAC_BRIDGE
  812. #define RX_QUEUE0_PRIO 0xFF
  813. #define RX_QUEUE1_PRIO 0
  814. #else
  815. #define RX_QUEUE0_PRIO 0
  816. #define RX_QUEUE1_PRIO 0xFF
  817. #endif
  818. #define RX_QUEUE2_PRIO 0
  819. #define RX_QUEUE3_PRIO 0
  820. #define RX_QUEUE4_PRIO (1 << TC956X_AVB_PRIORITY_CLASS_B)
  821. #define RX_QUEUE5_PRIO (1 << TC956X_AVB_PRIORITY_CLASS_A)
  822. #define RX_QUEUE6_PRIO (1 << TC956X_PRIORITY_CLASS_CDT)
  823. #define RX_QUEUE7_PRIO 0
  824. #define EEPROM_OFFSET 0
  825. #define EEPROM_MAC_COUNT 2
  826. /* DMA Ch allocation in tx-rx pairs for PF & VF */
  827. #define TC956X_PF_CH_ALLOC 0xFF /* PF - All Channels */
  828. #define TC956X_VF0_CH_ALLOC 0x00 /* VF0 - NA */
  829. #define TC956X_VF1_CH_ALLOC 0x00 /* VF1 - NA */
  830. #define TC956X_VF2_CH_ALLOC 0x00 /* VF2 - NA */
  831. /***************** Automotive and Port Bridge Config Ends ***************/
  832. #elif defined TC956X_SRIOV_VF
  833. /************************ TC956X_SRIOV_VF Starts ************************/
  834. #define MAX_TX_QUEUES_TO_USE 8
  835. #define MAX_RX_QUEUES_TO_USE 8
  836. #define MAX_FUNCS_PER_PF 4
  837. #define TX_TC_ZERO 0x0
  838. #define TC956X_DMA_CH0_MASK 0x01
  839. #define EEPROM_PORT_OFFSET ((MAC_PORT_NUM_CHECK) ? \
  840. (EEPROM_VF_SLOT_OFST1) : (EEPROM_VF_SLOT_OFST2))
  841. #define EEPROM_VF_SLOT_OFST1 2
  842. #define EEPROM_VF_SLOT_OFST2 3
  843. /************************** TC956X_SRIOV_VF Ends ************************/
  844. #else /* TC956X_SRIOV_PF */
  845. #ifdef TC956X
  846. /* CPE usecase Configruations */
  847. #define MAX_TX_QUEUES_TO_USE 2
  848. #define MAX_RX_QUEUES_TO_USE 2
  849. /* Tx Queue Size*/
  850. #define TX_QUEUE0_SIZE 18432
  851. #define TX_QUEUE1_SIZE 18432
  852. #define TX_QUEUE2_SIZE 0
  853. #define TX_QUEUE3_SIZE 0
  854. #define TX_QUEUE4_SIZE 0
  855. #define TX_QUEUE5_SIZE 0
  856. #define TX_QUEUE6_SIZE 0
  857. #define TX_QUEUE7_SIZE 0
  858. /* TX Queue 0: Legacy and Jumbo packets */
  859. #define TX_QUEUE0_MODE MTL_QUEUE_DCB
  860. /* TX Queue 1: Legacy */
  861. #define TX_QUEUE1_MODE MTL_QUEUE_DCB
  862. /* TX Queue 2: Legacy */
  863. #define TX_QUEUE2_MODE MTL_QUEUE_DISABLE
  864. /* TX Queue 3: Legacy */
  865. #define TX_QUEUE3_MODE MTL_QUEUE_DISABLE
  866. /* TX Queue 4: Untagged PTP */
  867. #define TX_QUEUE4_MODE MTL_QUEUE_DISABLE
  868. /* TX Queue 5: AVB Class B AVTP packet */
  869. #define TX_QUEUE5_MODE MTL_QUEUE_DISABLE
  870. /* TX Queue 6: AVB Class A AVTP packet */
  871. #define TX_QUEUE6_MODE MTL_QUEUE_DISABLE
  872. /* TX Queue 7: TSN Class CDT packet */
  873. #define TX_QUEUE7_MODE MTL_QUEUE_DISABLE
  874. /* Tx Queue TBS Enable/Disable */
  875. #define TX_QUEUE0_TBS 0
  876. #define TX_QUEUE1_TBS 0
  877. #define TX_QUEUE2_TBS 0
  878. #define TX_QUEUE3_TBS 0
  879. #define TX_QUEUE4_TBS 0
  880. #define TX_QUEUE5_TBS 0
  881. #define TX_QUEUE6_TBS 0
  882. #define TX_QUEUE7_TBS 0
  883. /* Tx Queue TSO Enable/Disable */
  884. #define TX_QUEUE0_TSO 1
  885. #define TX_QUEUE1_TSO 0
  886. #define TX_QUEUE2_TSO 0
  887. #define TX_QUEUE3_TSO 0
  888. #define TX_QUEUE4_TSO 0
  889. #define TX_QUEUE5_TSO 0
  890. #define TX_QUEUE6_TSO 0
  891. #define TX_QUEUE7_TSO 0
  892. /* Configure TxQueue - Traffic Class mapping */
  893. #define TX_QUEUE0_TC 0x0
  894. #define TX_QUEUE1_TC 0x1
  895. #define TX_QUEUE2_TC 0x0
  896. #define TX_QUEUE3_TC 0x0
  897. #define TX_QUEUE4_TC 0x0
  898. #define TX_QUEUE5_TC 0x0
  899. #define TX_QUEUE6_TC 0x0
  900. #define TX_QUEUE7_TC 0x0
  901. /* Rx Queue Size */
  902. #define RX_QUEUE0_SIZE 18432
  903. #define RX_QUEUE1_SIZE 18432
  904. #define RX_QUEUE2_SIZE 0
  905. #define RX_QUEUE3_SIZE 0
  906. #define RX_QUEUE4_SIZE 0
  907. #define RX_QUEUE5_SIZE 0
  908. #define RX_QUEUE6_SIZE 0
  909. #define RX_QUEUE7_SIZE 0
  910. /*
  911. * RX Queue 0: Unicast/Untagged Packets - Packets with
  912. * unique MAC Address of Host/Guest OS DMA channel selection will be based on
  913. * MAC_Address(#i)_High.DCS
  914. */
  915. #define RX_QUEUE0_MODE MTL_QUEUE_DCB
  916. /* RX Queue 1: VLAN Tagged Legacy packets - Pkt routing will be based on VLAN */
  917. #define RX_QUEUE1_MODE MTL_QUEUE_DCB
  918. /* RX Queue 2: Untagged gPTP packets */
  919. #define RX_QUEUE2_MODE MTL_QUEUE_DISABLE
  920. /* RX Queue 3: Untagged AV Control packets */
  921. #define RX_QUEUE3_MODE MTL_QUEUE_DISABLE
  922. /* RX Queue 4: AVB Class B AVTP packets */
  923. #define RX_QUEUE4_MODE MTL_QUEUE_DISABLE
  924. /* RX Queue 5: AVB Class A AVTP packets */
  925. #define RX_QUEUE5_MODE MTL_QUEUE_DISABLE
  926. /* RX Queue 6:TSN Class CDT packets */
  927. #define RX_QUEUE6_MODE MTL_QUEUE_DISABLE
  928. /* RX Queue 7: Broadcast/Multicast packets */
  929. #define RX_QUEUE7_MODE MTL_QUEUE_DISABLE
  930. /* Rx Queue Packet Routing */
  931. #define RX_QUEUE0_PKT_ROUTE PACKET_MCBCQ
  932. #define RX_QUEUE1_PKT_ROUTE PACKET_UPQ
  933. #define RX_QUEUE2_PKT_ROUTE 0
  934. #define RX_QUEUE3_PKT_ROUTE 0
  935. #define RX_QUEUE4_PKT_ROUTE 0
  936. #define RX_QUEUE5_PKT_ROUTE 0
  937. #define RX_QUEUE6_PKT_ROUTE 0
  938. #define RX_QUEUE7_PKT_ROUTE 0
  939. /* Packet Type - Rx DMA channel static mapping */
  940. /* Unicast/Untagged packet */
  941. #define LEG_UNTAGGED_PACKET 0
  942. /* VLAN tagged packets
  943. * For static mapping, route to RxCh0
  944. */
  945. #define LEG_TAGGED_PACKET 0
  946. /* Untagged gPTP packet */
  947. #define UNTAGGED_GPTP_PACKET 4 /*Not used in CPE case */
  948. /* Untagged AV Control Packet */
  949. #define UNTAGGED_AVCTRL_PACKET 3 /*Not used in CPE case */
  950. /* Class B AVB Packet */
  951. #define AVB_CLASS_B_PACKET 5 /*Not used in CPE case */
  952. /* Class A AVB Packet */
  953. #define AVB_CLASS_A_PACKET 6 /*Not used in CPE case */
  954. /* TSN Class CDT Packet */
  955. #define TSN_CLASS_CDT_PACKET 7 /*Not used in CPE case */
  956. /* Broadcast/Multicast packet */
  957. #define BC_MC_PACKET 0
  958. /* Rx Queue Use Priority */
  959. #define RX_QUEUE0_USE_PRIO false
  960. #define RX_QUEUE1_USE_PRIO true
  961. #define RX_QUEUE2_USE_PRIO false
  962. #define RX_QUEUE3_USE_PRIO false
  963. #define RX_QUEUE4_USE_PRIO false
  964. #define RX_QUEUE5_USE_PRIO false
  965. #define RX_QUEUE6_USE_PRIO false
  966. #define RX_QUEUE7_USE_PRIO false
  967. /* Rx Queue VLAN tagged Priority mapping */
  968. #define RX_QUEUE0_PRIO 0
  969. #define RX_QUEUE1_PRIO 0xFF
  970. #define RX_QUEUE2_PRIO 0
  971. #define RX_QUEUE3_PRIO 0
  972. #define RX_QUEUE4_PRIO 0
  973. #define RX_QUEUE5_PRIO 0
  974. #define RX_QUEUE6_PRIO 0
  975. #define RX_QUEUE7_PRIO 0
  976. #define EEPROM_OFFSET 0
  977. #define EEPROM_MAC_COUNT 2
  978. #define TX_DMA_CH0_OWNER USE_IN_TC956X_SW
  979. #define TX_DMA_CH1_OWNER NOT_USED
  980. #define TX_DMA_CH2_OWNER USE_IN_TC956X_SW
  981. #define TX_DMA_CH3_OWNER USE_IN_TC956X_SW
  982. #define TX_DMA_CH4_OWNER USE_IN_TC956X_SW
  983. #define TX_DMA_CH5_OWNER USE_IN_TC956X_SW
  984. #define TX_DMA_CH6_OWNER USE_IN_TC956X_SW
  985. #define TX_DMA_CH7_OWNER USE_IN_TC956X_SW
  986. #define RX_DMA_CH0_OWNER USE_IN_TC956X_SW
  987. #define RX_DMA_CH1_OWNER NOT_USED
  988. #define RX_DMA_CH2_OWNER USE_IN_TC956X_SW
  989. #define RX_DMA_CH3_OWNER USE_IN_TC956X_SW
  990. #define RX_DMA_CH4_OWNER USE_IN_TC956X_SW
  991. #define RX_DMA_CH5_OWNER USE_IN_TC956X_SW
  992. #define RX_DMA_CH6_OWNER USE_IN_TC956X_SW
  993. #define RX_DMA_CH7_OWNER USE_IN_TC956X_SW
  994. #endif /* TC956X */
  995. #endif /* TC956X_SRIOV_PF */
  996. /* PCI new class code */
  997. #define PCI_ETHC_CLASS_CODE 0x020000
  998. #ifdef TC956X
  999. #define MAC0_BASE_OFFSET 0x40000/* eMAC0 Base Offset */
  1000. #define MAC1_BASE_OFFSET 0x48000 /* eMAC1 Base Offset */
  1001. #else
  1002. #define MAC0_BASE_OFFSET 0xA000/* eMAC0 Base Offset */
  1003. #define MAC1_BASE_OFFSET 0xA000 /* eMAC1 Base Offset */
  1004. #endif
  1005. #define TC956X_PTP_SYSCLOCK 250000000 /* System clock is 250MHz */
  1006. #define TC956X_TARGET_PTP_CLK 50000000
  1007. /* Debug prints */
  1008. #define NMSGPR_INFO(dev, x...) dev_info(dev, x)
  1009. #define NMSGPR_ALERT(dev, x...) dev_alert(dev, x)
  1010. #define NMSGPR_ERR(dev, x...) dev_err(dev, x)
  1011. //#define TC956X_DBG_FUNC
  1012. //#define TC956X_DBG_PTP
  1013. //#define TC956X_DBG_TSN
  1014. //#define TC956X_DBG_MDIO
  1015. //#define TC956X_DBG_ETHTOOL
  1016. //#define TC956X_DBG_L1
  1017. //#define TC956X_DBG_L2
  1018. //#define TC956X_TEST
  1019. //#define TC956X_MSI_GEN_SW_AGENT /*Macro to enable and handle SW MSI interrupt*/
  1020. //#define TC956X_TEST_RXCH1_FRP_DISABLED
  1021. //#define TC956X_PKT_DUP
  1022. #define TC956X_FRP_ENABLE
  1023. #ifdef TC956X_DBG_PTP
  1024. #define DBGPR_FUNC_PTP(x...) pr_alert(x)
  1025. #else
  1026. #define DBGPR_FUNC_PTP(x...) do { } while (0)
  1027. #endif
  1028. #ifdef TC956X_DBG_TSN
  1029. #define DBGPR_FUNC_TSN(x...) pr_alert(x)
  1030. #else
  1031. #define DBGPR_FUNC_TSN(x...) do { } while (0)
  1032. #endif
  1033. #ifdef TC956X_DBG_MDIO
  1034. #define DBGPR_FUNC_MDIO(x...) pr_alert(x)
  1035. #else
  1036. #define DBGPR_FUNC_MDIO(x...) do { } while (0)
  1037. #endif
  1038. #ifdef TC956X_DBG_ETHTOOL
  1039. #define DBGPR_FUNC_ETHTOOL(x...) pr_alert(x)
  1040. #else
  1041. #define DBGPR_FUNC_ETHTOOL(x...) do { } while (0)
  1042. #endif
  1043. #ifdef TC956X_SRIOV_VF
  1044. /* TC956X Semaphore lock/unlock register */
  1045. #define NSEM(reg) (0x1100 + (reg * 4))
  1046. /* TC956X Semaphore read register */
  1047. #define NSEM_RD(reg) (0x1140 + (reg * 4))
  1048. #endif
  1049. #define TC956X_DBG_FUNC
  1050. #define TC956X_TEST
  1051. #define TC956X_DBG_L1
  1052. #define TC956X_DBG_L2
  1053. //#define TC956X_KPRINT_DEBUG_L1
  1054. #define TC956X_KPRINT_INFO
  1055. #define TC956X_KPRINT_NOTICE
  1056. #define TC956X_KPRINT_WARNING
  1057. #define TC956X_KPRINT_ERR
  1058. #define TC956X_KPRINT_CRIT
  1059. #define TC956X_KPRINT_ALERT
  1060. /* Debug prints */
  1061. #define NMSGPR_INFO(dev, x...) dev_info(dev, x)
  1062. #define NMSGPR_ALERT(dev, x...) dev_alert(dev, x)
  1063. #define NMSGPR_ERR(dev, x...) dev_err(dev, x)
  1064. #ifdef TC956X_DBG_FUNC
  1065. #define DBGPR_FUNC(dev, x...) dev_alert(dev, x)
  1066. #else
  1067. #define DBGPR_FUNC(dev, x...) do { } while (0)
  1068. #endif
  1069. #ifdef TC956X_TEST
  1070. #define DBGPR_TEST(dev, x...) dev_alert(dev, x)
  1071. #else
  1072. #define DBGPR_TEST(dev, x...) do { } while (0)
  1073. #endif
  1074. #ifdef TC956X_DBG_L1
  1075. #define NDBGPR_L1(dev, x...) dev_dbg(dev, x)
  1076. #else
  1077. #define NDBGPR_L1(dev, x...) do { } while (0)
  1078. #endif
  1079. #ifdef TC956X_DBG_L2
  1080. #define NDBGPR_L2(dev, x...) dev_dbg(dev, x)
  1081. #else
  1082. #define NDBGPR_L2(dev, x...) do { } while (0)
  1083. #endif
  1084. /* Kernel Print without dev */
  1085. #ifdef TC956X_KPRINT_DEBUG_L2
  1086. #define KPRINT_DEBUG2(x...) printk(KERN_DEBUG x)
  1087. #else
  1088. #define KPRINT_DEBUG2(x...) do { } while (0)
  1089. #endif
  1090. #ifdef TC956X_KPRINT_DEBUG_L1
  1091. #define KPRINT_DEBUG1(x...) printk(KERN_DEBUG x)
  1092. #else
  1093. #define KPRINT_DEBUG1(x...) do { } while (0)
  1094. #endif
  1095. #ifdef TC956X_KPRINT_INFO
  1096. #define KPRINT_INFO(x...) printk(KERN_INFO x)
  1097. #else
  1098. #define KPRINT_INFO(x...) do { } while (0)
  1099. #endif
  1100. #ifdef TC956X_KPRINT_NOTICE
  1101. #define KPRINT_NOTICE(x...) printk(KERN_NOTICE x)
  1102. #else
  1103. #define KPRINT_NOTICE(x...) do { } while (0)
  1104. #endif
  1105. #ifdef TC956X_KPRINT_WARNING
  1106. #define KPRINT_WARNING(x...) printk(KERN_WARNING x)
  1107. #else
  1108. #define KPRINT_WARNING(x...) do { } while (0)
  1109. #endif
  1110. #ifdef TC956X_KPRINT_ERR
  1111. #define KPRINT_ERR(x...) printk(KERN_ERR x)
  1112. #else
  1113. #define KPRINT_ERR(x...) do { } while (0)
  1114. #endif
  1115. #ifdef TC956X_KPRINT_CRIT
  1116. #define KPRINT_CRIT(x...) printk(KERN_CRIT x)
  1117. #else
  1118. #define KPRINT_CRIT(x...) do { } while (0)
  1119. #endif
  1120. #ifdef TC956X_KPRINT_ALERT
  1121. #define KPRINT_ALERT(x...) printk(KERN_ALERT x)
  1122. #else
  1123. #define KPRINT_ALERT(x...) do { } while (0)
  1124. #endif
  1125. #define SPEED_1GBPS (1000) /* 1Gbps Interms of MBPS */
  1126. #define SPEED_10GBPS (10000) /* 10Gbps Interms of MBPS */
  1127. //#define RSC_MNG_OFFSET 0x2000
  1128. //#define RSCMNG_ID_REG ((RSC_MNG_OFFSET) + 0x00000000)
  1129. #define RSCMNG_PFN GENMASK(3, 0)
  1130. #define RSCMNG_PFN_SHIFT 0
  1131. /* Configuration Register Address */
  1132. #define NCID_OFFSET (0x0000) /* TC956X Chip and revision ID */
  1133. #define NMODESTS_OFFSET (0x0004) /* TC956X current operation mode */
  1134. #define NFUNCEN0_OFFSET (0x0008) /* TC956X pin mux control */
  1135. #define NPCIEBOOT_OFFSET (0x0018) /* TC956X PCIE Boot HW Sequence Status and Control */
  1136. /* Pinmux for PPS Out PPO01 and PPO11*/
  1137. #define NFUNCEN0_JTAGEN_MASK 0x40000000U
  1138. #define NFUNCEN0_JTAG_MASK 0x000F0000U
  1139. #define NFUNCEN0_JTAG_SHIFT 16U
  1140. #define FUNCTION1 0x1U
  1141. #define FUNCTION2 0x2U
  1142. #define NFUNCEN4_GPIO2_MASK 0x00000F00U
  1143. #define NFUNCEN4_GPIO2_SHIFT 8U
  1144. #define NFUNCEN4_GPIO4_MASK 0x000F0000
  1145. #define NFUNCEN4_GPIO4_SHIFT 16U
  1146. #define NSYSDATA0_OFFSET (0x0100)
  1147. #define NSYSDATA1_OFFSET (0x0104)
  1148. #ifdef TC956X
  1149. #define NCTLSTS_OFFSET (0x1000) /* TC956X control and status */
  1150. #define NCLKCTRL0_OFFSET (0x1004) /* TC956X clock control Register-0 */
  1151. #define NCLKCTRL0_MCUCEN BIT(0)
  1152. #define NCLKCTRL0_INTCEN BIT(4)
  1153. #define NCLKCTRL0_MAC0TXCEN BIT(7)
  1154. #define NCLKCTRL0_PCIECEN BIT(9)
  1155. #define NCLKCTRL0_I2SSPIEN BIT(12)
  1156. #define NCLKCTRL0_SRMCEM BIT(13)
  1157. #define NCLKCTRL0_MAC0RXCEN BIT(14)
  1158. #define NCLKCTRL0_UARTOCEN BIT(16)
  1159. #define NCLKCTRL0_MSIGENCEN BIT(18)
  1160. #define NCLKCTRL0_POEPLLCEN BIT(24)
  1161. #define NCLKCTRL0_SGMPCIEN BIT(25)
  1162. #define NCLKCTRL0_REFCLKOCEN BIT(26)
  1163. #define NCLKCTRL0_MAC0125CLKEN BIT(29)
  1164. #define NCLKCTRL0_MAC0312CLKEN BIT(30)
  1165. #define NCLKCTRL0_MAC0ALLCLKEN BIT(31)
  1166. #define NRSTCTRL0_OFFSET (0x1008) /* TC956X reset control Register-0 */
  1167. #define NRSTCTRL0_MCURST BIT(0)
  1168. #define NRSTCTRL0_INTRST BIT(4)
  1169. #define NRSTCTRL0_MAC0RST BIT(7)
  1170. #define NRSTCTRL0_PCIERST BIT(9)
  1171. #define NRSTCTRL0_UART0RST BIT(16)
  1172. #define NRSTCTRL0_MSIGENRST BIT(18)
  1173. #define NRSTCTRL0_MAC0PMARST BIT(30)
  1174. #define NRSTCTRL0_MAC0PONRST BIT(31)
  1175. #define NCLKCTRL1_OFFSET (0x100C) /* TC956X clock control Register-1 for eMAC Port-1*/
  1176. #define NCLKCTRL1_MAC1TXCEN BIT(7)
  1177. #define NCLKCTRL1_MAC1RXCEN BIT(14)
  1178. #define NCLKCTRL1_MAC1RMCEN BIT(15)
  1179. #define NCLKCTRL1_MAC1125CLKEN1 BIT(29)
  1180. #define NCLKCTRL1_MAC1312CLKEN1 BIT(30)
  1181. #define NCLKCTRL1_MAC1ALLCLKEN1 BIT(31)
  1182. #define NRSTCTRL1_OFFSET (0x1010) /* TC956X reset control Register-1 for eMAC Port-1*/
  1183. #define NRSTCTRL1_MAC1RST1 BIT(7)
  1184. #define NRSTCTRL1_MAC1PMARST1 BIT(30)
  1185. #define NRSTCTRL1_MAC1PONRST1 BIT(31)
  1186. #define NRSTCTRL_EMAC_MASK (NRSTCTRL0_MAC0RST | NRSTCTRL0_MAC0PMARST | \
  1187. NRSTCTRL0_MAC0PONRST)
  1188. #define NCLKCTRL_EMAC_MASK (NCLKCTRL0_MAC0TXCEN | NCLKCTRL0_MAC0RXCEN | \
  1189. NCLKCTRL0_MAC0125CLKEN | NCLKCTRL0_MAC0312CLKEN | \
  1190. NCLKCTRL1_MAC1RMCEN | NCLKCTRL0_MAC0ALLCLKEN)
  1191. #define NCLKCTRL0_COMMON_EMAC_MASK (NCLKCTRL0_POEPLLCEN | NCLKCTRL0_SGMPCIEN | \
  1192. NCLKCTRL0_REFCLKOCEN)
  1193. #define NRSTCTRL0_DEFAULT (NRSTCTRL0_MAC0PONRST | NRSTCTRL0_MAC0PMARST | \
  1194. NRSTCTRL0_MAC0RST)
  1195. #define NRSTCTRL_COMMON (NRSTCTRL0_MSIGENRST | NRSTCTRL0_UART0RST | \
  1196. NRSTCTRL0_INTRST | NRSTCTRL0_MCURST)
  1197. #define NCLKCTRL0_DEFAULT (NCLKCTRL0_SRMCEM | NCLKCTRL0_I2SSPIEN | \
  1198. NCLKCTRL0_PCIECEN | NCLKCTRL0_MCUCEN)
  1199. #define NCLKCTRL_ENABLE_COMMON_EMAC_MASK (NCLKCTRL0_SRMCEM | NCLKCTRL0_I2SSPIEN | \
  1200. NCLKCTRL0_PCIECEN | NCLKCTRL0_MCUCEN)
  1201. #define NCLKCTRL_DISABLE_COMMON_EMAC_MASK (NCLKCTRL0_MAC0ALLCLKEN | NCLKCTRL0_MAC0312CLKEN | \
  1202. NCLKCTRL0_MAC0125CLKEN | NCLKCTRL0_REFCLKOCEN | \
  1203. NCLKCTRL0_SGMPCIEN | NCLKCTRL0_POEPLLCEN | \
  1204. NCLKCTRL0_MSIGENCEN | NCLKCTRL0_UARTOCEN | \
  1205. NCLKCTRL0_MAC0RXCEN | NCLKCTRL0_MAC0TXCEN | \
  1206. NCLKCTRL0_INTCEN)
  1207. #define NCLKCTRL_PORT0_EMAC_MASK (NCLKCTRL0_MAC0TXCEN | NCLKCTRL0_MAC0RXCEN | \
  1208. NCLKCTRL0_MAC0125CLKEN | NCLKCTRL0_MAC0312CLKEN | \
  1209. NCLKCTRL0_MAC0ALLCLKEN)
  1210. #define NBUSCTRL_OFFSET (0x1014)
  1211. #define NRSTCTRL_LINK_DOWN (NRSTCTRL0_MAC0PMARST | NRSTCTRL0_MAC0PONRST)
  1212. #define NCLKCTRL_LINK_DOWN (NCLKCTRL0_MAC0TXCEN | NCLKCTRL0_MAC0RXCEN | \
  1213. NCLKCTRL0_MAC0125CLKEN | NCLKCTRL0_MAC0312CLKEN | \
  1214. NCLKCTRL1_MAC1RMCEN)
  1215. #define NRSTCTRL_LINK_DOWN_SAVE (0xC0000080U) /* Save Non-Common Reset Register Bits Between Port 0 and Port 1 */
  1216. #define NCLKCTRL_LINK_DOWN_SAVE (0xE000C080U) /* Save Non-Common Clock Register Bits Between Port 0 and Port 1 */
  1217. #define NRSTCTRL_LINK_DOWN_CMN_SAVE (0x00051213U) /* Save Common Reset Register Bits Between Port 0 and Port 1 */
  1218. #define NCLKCTRL_LINK_DOWN_CMN_SAVE (0x07053211U) /* Save Common Clock Register Bits Between Port 0 and Port 1 */
  1219. #define TC956X_MSIGENCEN 18
  1220. /* Interrupts to CM3 to be enabled in FW */
  1221. #define TC956X_INT_MASK0 0xFFFF1FFF/*0x00000000*/
  1222. #define TC956X_INT_MASK1 0xFFFF1F80/*0x00000000*/
  1223. #define TC956X_INT_MASK2 0x00007740/*0x00000000*/
  1224. #endif
  1225. #define NSPLLPARAM_OFFSET (0x1020) /* TC956X System PLL parameters */
  1226. #define NSPLLUPDT_OFFSET (0x1024) /* TC956X System PLL update */
  1227. #define NOSCCTRL_OFFSET (0x1028) /* TC956X OSC drive strength control */
  1228. #define NEMACTXCDLY_OFFSET (0x1050) /* Integrated Delay on RGMII TXC */
  1229. #define NEMACINTO00EN_OFFSET (0x1054)
  1230. #define NEMACINTO01EN_OFFSET (0x1058)
  1231. #define NEMACINTO10EN_OFFSET (0x105C)
  1232. #define NEMACINTO11EN_OFFSET (0x1060)
  1233. #ifdef TC956X
  1234. #define NEMAC0CTL_OFFSET (0x1070) /* eMAC Port-0 Control */
  1235. #endif
  1236. #ifdef TC956X_SRIOV_PF
  1237. /* MSIGEN Registers */
  1238. #define MSI_INT_TX_CH0 3
  1239. #define MSI_INT_RX_CH0 11
  1240. #define MSI_INT_EXT_PHY 20
  1241. #define TC956X_MSI_BASE (0xF000)
  1242. #define TC956X_MSI_F_OFFSET (0x0100)
  1243. #define TC956X_MSI_OUT_EN_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1244. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0000))
  1245. #define TC956X_MSI_MASK_SET_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1246. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0008))
  1247. #define TC956X_MSI_INT_RAW_STS_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE + \
  1248. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0014))
  1249. #define TC956X_MSI_STS_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE + \
  1250. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0018))
  1251. #define TC956X_MSI_MASK_CLR_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1252. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x000c))
  1253. #define TC956X_MSI_INT_STS_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1254. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0010))
  1255. #define TC956X_MSI_VECT_SET0_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1256. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0020))
  1257. #define TC956X_MSI_VECT_SET1_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1258. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0024))
  1259. #define TC956X_MSI_VECT_SET2_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1260. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0028))
  1261. #define TC956X_MSI_VECT_SET3_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1262. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x002C))
  1263. #define TC956X_MSI_VECT_SET4_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1264. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0030))
  1265. #define TC956X_MSI_VECT_SET5_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1266. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0034))
  1267. #define TC956X_MSI_VECT_SET6_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1268. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0038))
  1269. #define TC956X_MSI_VECT_SET7_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1270. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x003C))
  1271. #define TC956X_MSI_SW_MSI_CLR(pf_id, vf_id) (TC956X_MSI_BASE +\
  1272. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0054))
  1273. #define TC956X_MSI_EVENT_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1274. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0068))
  1275. #define TC956X_MSI_CNT0(pf_id, vf_id) (TC956X_MSI_BASE +\
  1276. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0080))
  1277. #define TC956X_MSI_CNT1(pf_id, vf_id) (TC956X_MSI_BASE +\
  1278. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0084))
  1279. #define TC956X_MSI_CNT2(pf_id, vf_id) (TC956X_MSI_BASE +\
  1280. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0088))
  1281. #define TC956X_MSI_CNT3(pf_id, vf_id) (TC956X_MSI_BASE +\
  1282. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x008C))
  1283. #define TC956X_MSI_CNT4(pf_id, vf_id) (TC956X_MSI_BASE +\
  1284. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x0090))
  1285. #define TC956X_MSI_CNT11(pf_id, vf_id) (TC956X_MSI_BASE +\
  1286. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x00AC))
  1287. #define TC956X_MSI_CNT12(pf_id, vf_id) (TC956X_MSI_BASE +\
  1288. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x00B0))
  1289. #define TC956X_MSI_CNT20(pf_id, vf_id) (TC956X_MSI_BASE +\
  1290. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x00D0))
  1291. #define TC956X_MSI_CNT24(pf_id, vf_id) (TC956X_MSI_BASE +\
  1292. (vf_id * TC956X_MSI_F_OFFSET) + (pf_id * TC956X_MSI_F_OFFSET) + (0x00E0))
  1293. #define TC956X_MSI_OUT_EN_CLR (0x00000000)
  1294. /* Enabled LPI_INT, EVENT_INT, TX_INT[3], TX_INT[4], RX_INT[3], RX_INT[4]
  1295. * XPCS_INT, PFMAILBOX_INT
  1296. * INT 6, 7, 14, 15 is allocated to MSI Vector 1.
  1297. * All other enabled INT to Vector 0.
  1298. */
  1299. #if defined(TC956X_AUTOMOTIVE_CONFIG)
  1300. #ifdef TC956X_LPI_INTERRUPT
  1301. #define TC956X_MSI_OUT_EN (0x0017FFFD)
  1302. #else /* #ifdef TC956X_LPI_INTERRUPT */
  1303. #define TC956X_MSI_OUT_EN (0x0017FFFC)
  1304. #endif /* #ifdef TC956X_LPI_INTERRUPT */
  1305. #else /* #if defined(TC956X_AUTOMOTIVE_CONFIG) */
  1306. #define TC956X_MSI_OUT_EN (0x0037FFFD)
  1307. #endif /* #if defined(TC956X_AUTOMOTIVE_CONFIG) */
  1308. #if defined(TC956X_AUTOMOTIVE_CONFIG) || defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  1309. #define TC956X_MSI_MASK_SET (0xFFFFFFFE)
  1310. #define TC956X_MSI_MASK_CLR (0x00000001)
  1311. #define TC956X_MSI_SET0 (0x00000000)
  1312. #define TC956X_MSI_SET1 (0x00000000)
  1313. #define TC956X_MSI_SET2 (0x00000000)
  1314. #define TC956X_MSI_SET3 (0x00000000)
  1315. #define TC956X_MSI_SET4 (0x00000000)
  1316. #define TC956X_MSI_SET5 (0x00000000)
  1317. #define TC956X_MSI_SET6 (0x00000000)
  1318. #define TC956X_MSI_SET7 (0x00000000)
  1319. #else
  1320. #define TC956X_MSI_MASK_SET (0xFFFFFFFC)
  1321. #define TC956X_MSI_MASK_CLR (0x00000003)
  1322. #define TC956X_MSI_SET0 (0x00010101)
  1323. #define TC956X_MSI_SET1 (0x00000000)
  1324. #define TC956X_MSI_SET2 (0x00000000)
  1325. #define TC956X_MSI_SET3 (0x00000000)
  1326. #define TC956X_MSI_SET4 (0x01000000)
  1327. #define TC956X_MSI_SET5 (0x01010101)
  1328. #define TC956X_MSI_SET6 (0x01010101)
  1329. #define TC956X_MSI_SET7 (0x01010101)
  1330. #endif
  1331. #endif /* TC956X_SRIOV_PF */
  1332. #define NEMAC1CTL_OFFSET (0x1074) /* eMAC Port-1 Control */
  1333. #define NEMACSTS_OFFSET (0x1078) /* eMAC status */
  1334. #define NEMACIOCTL_OFFSET (0x107C) /* eMAC IO Control */
  1335. #define NEMACCTL_SP_SEL_MASK GENMASK(3, 0)
  1336. #define NEMACCTL_INIT_DONE 0x200000
  1337. #define NEMACCTL_LPIHWCLKEN (0x100)
  1338. #define NEMACCTL_PHY_INF_SEL_MASK GENMASK(5, 4)
  1339. #define NEMACCTL_PHY_INF_SEL (0x10)/* Phy_intf_sel : clock from PHY */
  1340. #define NEMACCTL_SP_SEL_SGMII_10M (0x7) /* SGMII 10M */
  1341. #define NEMACCTL_SP_SEL_SGMII_100M (0x6) /* SGMII 100M */
  1342. #define NEMACCTL_SP_SEL_SGMII_1000M (0x5) /* SGMII 1000M */
  1343. #define NEMACCTL_SP_SEL_SGMII_2500M (0x4) /* SGMII 2500M */
  1344. #define NEMACCTL_SP_SEL_USXGMII_2_5G_2_5G (0xD) /* USXGMII 2.5G/2.5G */
  1345. #define NEMACCTL_SP_SEL_USXGMII_2_5G_5G (0xC) /* USXGMII 2.5G/5G */
  1346. #define NEMACCTL_SP_SEL_USXGMII_2_5G_10G (0xB) /* USXGMII 2.5G/10G */
  1347. #define NEMACCTL_SP_SEL_USXGMII_5G_5G (0xA) /* USXGMII 5G/5G */
  1348. #define NEMACCTL_SP_SEL_USXGMII_5G_10G (0x9) /* USXGMII 5G/10G */
  1349. #define NEMACCTL_SP_SEL_USXGMII_10G_10G (0x8) /* USXGMII 10G/10G */
  1350. #define NEMACCTL_SP_SEL_RGMII_10M (0x2) /* RGMII 10M */
  1351. #define NEMACCTL_SP_SEL_RGMII_100M (0x1) /* RGMII 100M */
  1352. #define NEMACCTL_SP_SEL_RGMII_1000M (0x0) /* RGMII 1000M */
  1353. #define GPIOI0_OFFSET (0x1200) /* GPIO Input-0 register */
  1354. #define GPIOI1_OFFSET (0x1204) /* GPIO Input-1 register */
  1355. #define GPIOE0_OFFSET (0x1208) /* GPIO Enable-0 register */
  1356. #define GPIOE1_OFFSET (0x120C) /* GPIO Enable-1 register */
  1357. #define GPIOO0_OFFSET (0x1210) /* GPIO Output-0 register */
  1358. #define GPIOO1_OFFSET (0x1214) /* GPIO Output-1 register */
  1359. #define NPCIEPWR_OFFSET (0x1300) /* PCIe power gating control */
  1360. #define I2CERRADD_OFFSET (0x1400)
  1361. #define SPIERRADD_OFFSET (0x1404)
  1362. #define NFUNCEN1_OFFSET (0x1514)
  1363. #define NFUNCEN2_OFFSET (0x151C)
  1364. #define NFUNCEN3_OFFSET (0x1524)
  1365. #define NFUNCEN4_OFFSET (0x1528)
  1366. #define NFUNCEN5_OFFSET (0x152C)
  1367. #define NFUNCEN6_OFFSET (0x1530)
  1368. #define NFUNCEN7_OFFSET (0x153C)
  1369. #define NFUNCEN_FUNC0 (0)
  1370. #define NFUNCEN4_GPIO_00 GENMASK(3, 0)
  1371. #define NFUNCEN4_GPIO_00_SHIFT (0)
  1372. #define NFUNCEN4_GPIO_01 GENMASK(7, 4)
  1373. #define NFUNCEN4_GPIO_01_SHIFT (4)
  1374. #define NFUNCEN4_GPIO_02 GENMASK(11, 8)
  1375. #define NFUNCEN4_GPIO_02_SHIFT (8)
  1376. #define NFUNCEN4_GPIO_03 GENMASK(15, 12)
  1377. #define NFUNCEN4_GPIO_03_SHIFT (12)
  1378. #define NFUNCEN4_GPIO_04 GENMASK(19, 16)
  1379. #define NFUNCEN4_GPIO_04_SHIFT (16)
  1380. #define NFUNCEN4_GPIO_05 GENMASK(23, 20)
  1381. #define NFUNCEN4_GPIO_05_SHIFT (20)
  1382. #define NFUNCEN4_GPIO_06 GENMASK(27, 24)
  1383. #define NFUNCEN4_GPIO_06_SHIFT (24)
  1384. #define NFUNCEN5_GPIO_10 GENMASK(3, 0)
  1385. #define NFUNCEN5_GPIO_10_SHIFT (0)
  1386. #define NFUNCEN5_GPIO_11 GENMASK(7, 4)
  1387. #define NFUNCEN5_GPIO_11_SHIFT (4)
  1388. #define NFUNCEN6_GPIO_12 GENMASK(19, 16)
  1389. #define NFUNCEN6_GPIO_12_SHIFT (16)
  1390. #define NIOCFG1_OFFSET (0x1614)
  1391. #define NIOCFG7_OFFSET (0x163C)
  1392. #define NIOEN7_OFFSET (0x173C)
  1393. #define GPIO_00 (0)
  1394. #define GPIO_01 (1)
  1395. #define GPIO_02 (2)
  1396. #define GPIO_03 (3)
  1397. #define GPIO_04 (4)
  1398. #define GPIO_05 (5)
  1399. #define GPIO_06 (6)
  1400. #define GPIO_10 (10)
  1401. #define GPIO_11 (11)
  1402. #define GPIO_12 (12)
  1403. #define GPIO_32 (32)
  1404. #define TRIG00_SHIFT 4
  1405. #define TRIG10_SHIFT 12
  1406. #define TRIG00_MASK 0xF0
  1407. #define TRIG10_MASK 0xF000
  1408. #define TSIE_SHIFT 12
  1409. /* PCIe registers */
  1410. #define PCIE_OFFSET (0x20000)
  1411. #define PCIE_RANGE_UP_OFFSET_RgOffAddr(no) (PCIE_OFFSET + 0x6200 + (no*0x10))
  1412. #define PCIE_RANGE_EN_RgOffAddr(no) (PCIE_OFFSET + 0x6204 + (no*0x10))
  1413. #define PCIE_RANGE_UP_RPLC_RgOffAddr(no) (PCIE_OFFSET + 0x6208 + (no*0x10))
  1414. #define PCIE_RANGE_WIDTH_RgOffAddr(no) (PCIE_OFFSET + 0x620C + (no*0x10))
  1415. /* INTC Registers */
  1416. #define INTC_OFFSET (0x8000)
  1417. #define INTC_INTSTATUS (INTC_OFFSET)
  1418. #define INTC_MAC0STATUS (INTC_OFFSET + 0x0C)
  1419. #define INTC_MAC1STATUS (INTC_OFFSET + 0x10)
  1420. #define INTC_EXTINTFLG (INTC_OFFSET + 0x14)
  1421. #define INTC_PCIEL12FLG (INTC_OFFSET + 0x18)
  1422. #define INTC_I2CSPIINTFLG (INTC_OFFSET + 0x1C)
  1423. #define INTMCUMASK0 (INTC_OFFSET + 0x20)
  1424. #define INTMCUMASK1 (INTC_OFFSET + 0x24)
  1425. #define INTMCUMASK2 (INTC_OFFSET + 0x28)
  1426. #define INTMCUMASK3 (INTC_OFFSET + 0x2C)
  1427. #define INTMCUMASK_TX_CH0 16
  1428. #define INTMCUMASK_RX_CH0 24
  1429. #define INTC_EXTINTCFG (INTC_OFFSET + 0x4C)
  1430. #define INTC_MCUFLG (INTC_OFFSET + 0x54)
  1431. #define INTC_EXTFLG (INTC_OFFSET + 0x58)
  1432. #define INTC_MACPPOFLG (INTC_OFFSET + 0x5C)
  1433. #define INTC_INTINTWDCTL (INTC_OFFSET + 0x60)
  1434. #define INTC_INTINTWDEXP (INTC_OFFSET + 0x64)
  1435. #define INTC_INTINTWDMON (INTC_OFFSET + 0x68)
  1436. #define MACRXSTS_MASK (0xFF)
  1437. #define MACTXSTS_MASK (0xFF0000)
  1438. #define INTC_INTSTS_MAC_EVENT BIT(11)
  1439. #define MAC_OFFSET ((MAC_PORT_NUM_CHECK) ? \
  1440. (MAC0_BASE_OFFSET) : (MAC1_BASE_OFFSET))
  1441. #define NEMACCTL_OFFSET \
  1442. ((MAC_PORT_NUM_CHECK) ? (NEMAC0CTL_OFFSET) : (NEMAC1CTL_OFFSET))
  1443. #define INTC_MAC_STATUS \
  1444. ((MAC_PORT_NUM_CHECK) ? (INTC_MAC0STATUS) : (INTC_MAC1STATUS))
  1445. #ifdef TC956X
  1446. #define TC956X_ETH_XPCS_INT BIT(19)
  1447. #define TC956X_EXT_PHY_ETH_INT BIT(20)
  1448. #ifdef TC956X_SW_MSI
  1449. #define TC956X_SW_MSI_INT BIT(24)
  1450. #endif
  1451. #define TC956X_SSREG_BRREG_REG_BASE (0x00024000U)
  1452. #define TC956X_GLUE_LOGIC_BASE_OFST (0x0002C000U)
  1453. /*All phy core use the same base address, glue register we need to select correct phy core*/
  1454. #define TC956X_PHY_CORE0_REG_BASE (0x00028000U)
  1455. #define TC956X_PHY_CORE1_REG_BASE (0x00028000U)
  1456. #define TC956X_PHY_CORE2_REG_BASE (0x00028000U)
  1457. #define TC956X_PHY_CORE3_REG_BASE (0x00028000U)
  1458. #define TC956X_SSREG_K_PCICONF_015_000 (TC956X_SSREG_BRREG_REG_BASE \
  1459. + 0x00000850U)
  1460. #define TC956X_SSREG_K_PCICONF_031_016 (TC956X_SSREG_BRREG_REG_BASE \
  1461. + 0x00000854U)
  1462. #define TC956X_SSREG_K_PCICONF_021_021 (TC956X_SSREG_BRREG_REG_BASE \
  1463. + 0x000009E4U)
  1464. #define TC956X_SSREG_K_PCICONF_022_022 (TC956X_SSREG_BRREG_REG_BASE \
  1465. + 0x000009E8U)
  1466. #define TC956X_GLUE_EFUSE_CTRL (TC956X_GLUE_LOGIC_BASE_OFST \
  1467. + 0x0000001CU)
  1468. #define TC956X_GLUE_SW_REG_ACCESS_CTRL (TC956X_GLUE_LOGIC_BASE_OFST \
  1469. + 0x0000002CU)
  1470. #define TC956X_GLUE_PHY_REG_ACCESS_CTRL (TC956X_GLUE_LOGIC_BASE_OFST \
  1471. + 0x00000030U)
  1472. #define TC956X_GLUE_SW_RESET_CTRL (TC956X_GLUE_LOGIC_BASE_OFST \
  1473. + 0x00000044U)
  1474. #define TC956X_GLUE_SW_DSP1_TEST_IN_31_00 (TC956X_GLUE_LOGIC_BASE_OFST \
  1475. + 0x0000006CU)
  1476. #define TC956X_GLUE_SW_DSP2_TEST_IN_31_00 (TC956X_GLUE_LOGIC_BASE_OFST \
  1477. + 0x00000074U)
  1478. #define TC956X_GLUE_SW_USP_TEST_OUT_127_096 (TC956X_GLUE_LOGIC_BASE_OFST \
  1479. + 0x00000098U)
  1480. #define TC956X_GLUE_TL_LINK_SPEED_MON (TC956X_GLUE_LOGIC_BASE_OFST \
  1481. + 0x00000244U)
  1482. #define TC956X_GLUE_TL_NUM_LANES_MON (TC956X_GLUE_LOGIC_BASE_OFST \
  1483. + 0x00000248U)
  1484. #define TC956X_GLUE_RSVD_RW0 (TC956X_GLUE_LOGIC_BASE_OFST \
  1485. + 0x0000024CU)
  1486. #ifdef TC956X_PCIE_LINK_STATE_LATENCY_CTRL
  1487. #define TC956X_PCIE_S_REG_OFFSET (0x00024000U)
  1488. #define TC956X_PCIE_S_L0s_ENTRY_LATENCY (TC956X_PCIE_S_REG_OFFSET \
  1489. + 0x0000096CU)
  1490. #define TC956X_PCIE_S_L1_ENTRY_LATENCY (TC956X_PCIE_S_REG_OFFSET \
  1491. + 0x00000970U)
  1492. #define TC956X_PCIE_EP_REG_OFFSET (0x00020000U)
  1493. #define TC956X_PCIE_EP_CAPB_SET (TC956X_PCIE_EP_REG_OFFSET \
  1494. + 0x000000D8U)
  1495. #define TC956X_PCIE_EP_L0s_ENTRY_SHIFT (13)
  1496. #define TC956X_PCIE_EP_L1_ENTRY_SHIFT (18)
  1497. #define TC956X_PCIE_EP_L0s_ENTRY_MASK GENMASK(17, 13)
  1498. #define TC956X_PCIE_EP_L1_ENTRY_MASK GENMASK(27, 18)
  1499. #define TC956X_PCIE_S_EN_ALL_PORTS_ACCESS (0xF)
  1500. /*
  1501. L0s value range: 1-31
  1502. L1 value range : 1-1023
  1503. Ex: entry value is n then
  1504. entry delay = n * 256 ns */
  1505. /* Link state change delay configuration for Upstream Port */
  1506. #define USP_L0s_ENTRY_DELAY (0x1FU)
  1507. #define USP_L1_ENTRY_DELAY (0x3FFU)
  1508. /* Link state change delay configuration for Downstream Port-1 */
  1509. #define DSP1_L0s_ENTRY_DELAY (0x1FU)
  1510. #define DSP1_L1_ENTRY_DELAY (0x3FFU)
  1511. /* Link state change delay configuration for Downstream Port-2 */
  1512. #define DSP2_L0s_ENTRY_DELAY (0x1FU)
  1513. #define DSP2_L1_ENTRY_DELAY (0x3FFU)
  1514. /* Link state change delay configuration for Virtual Downstream Port */
  1515. #define VDSP_L0s_ENTRY_DELAY (0x1FU)
  1516. #define VDSP_L1_ENTRY_DELAY (0x3FFU)
  1517. /* Link state change delay configuration for Internal Endpoint */
  1518. #define EP_L0s_ENTRY_DELAY (0x1FU)
  1519. #define EP_L1_ENTRY_DELAY (0x3FFU)
  1520. #endif /* end of TC956X_PCIE_LINK_STATE_LATENCY_CTRL */
  1521. #define TC956X_PHY_COREX_PMACNT_GL_PM_PWRST2_CFG0 (TC956X_PHY_CORE0_REG_BASE \
  1522. + 0x0000009CU)
  1523. #define TC956X_PHY_COREX_PMACNT_GL_PM_PWRST2_CFG1 (TC956X_PHY_CORE0_REG_BASE \
  1524. + 0x000000A0U)
  1525. #define TC956X_PHY_COREX_PCS_GL_MD_CFG_TXMARGIN0 (TC956X_PHY_CORE0_REG_BASE \
  1526. + 0x00000234U)
  1527. #define TC956X_PHY_COREX_PMA_LN_PCS_TAP_ADV_R0 (TC956X_PHY_CORE0_REG_BASE \
  1528. + 0x00003148U)
  1529. #define TC956X_PHY_COREX_PMA_LN_PCS_TAP_DLY_R0 (TC956X_PHY_CORE0_REG_BASE \
  1530. + 0x0000314CU)
  1531. #define TC956X_PHY_COREX_PMA_LN_PCS_TAP_ADV_R1 (TC956X_PHY_CORE0_REG_BASE \
  1532. + 0x000031B4U)
  1533. #define TC956X_PHY_COREX_PMA_LN_PCS_TAP_DLY_R1 (TC956X_PHY_CORE0_REG_BASE \
  1534. + 0x000031B8U)
  1535. #define TC956X_PHY_COREX_PMA_LN_PCS_TAP_ADV_R2 (TC956X_PHY_CORE0_REG_BASE \
  1536. + 0x00003220U)
  1537. #define TC956X_PHY_COREX_PMA_LN_PCS_TAP_DLY_R2 (TC956X_PHY_CORE0_REG_BASE \
  1538. + 0x00003224U)
  1539. #define TC956X_PHY_COREX_PMA_LN_RT_OVREN_PCS_TAP_ADV (TC956X_PHY_CORE0_REG_BASE \
  1540. + 0x000032F0U)
  1541. #define TC956X_PHY_COREX_PMA_LN_RT_OVREN_PCS_TAP_DLY (TC956X_PHY_CORE0_REG_BASE \
  1542. + 0x000032F4U)
  1543. #define TC956X_PHY_COREX_PMACNT_LN_PM_LOSCNT_CNT0 (TC956X_PHY_CORE0_REG_BASE \
  1544. + 0x00000844U)
  1545. #define TC956X_PHY_COREX_PMACNT_LN_PM_EMCNT_RESULT_BEST_MON0 (TC956X_PHY_CORE0_REG_BASE \
  1546. + 0x00000890U)
  1547. #define TC956X_PHY_COREX_PMACNT_LN_PM_EMCNT_INIT_CFG0_R2 (TC956X_PHY_CORE0_REG_BASE \
  1548. + 0x00000A18U)
  1549. #define TC956X_PHY_COREX_PMACNT_LN_PM_EQ_CFG0_R2 (TC956X_PHY_CORE0_REG_BASE \
  1550. + 0x00000A04U)
  1551. #define TC956X_PHY_COREX_PMACNT_LN_PM_EQ_CFG1_R2 (TC956X_PHY_CORE0_REG_BASE \
  1552. + 0x00000A08U)
  1553. #define TC956X_PHY_COREX_PMACNT_LN_PM_EQ1_CFG0_R2 (TC956X_PHY_CORE0_REG_BASE \
  1554. + 0x00000A0CU)
  1555. #define TC956X_PHY_COREX_PMACNT_LN_PM_EQ2_CFG0_R2 (TC956X_PHY_CORE0_REG_BASE \
  1556. + 0x00000A14U)
  1557. #define TC956X_PHY_COREX_PMACNT_GL_PM_DFE_PD_CTRL (TC956X_PHY_CORE0_REG_BASE \
  1558. + 0x00000254U)
  1559. #define TC956X_PHY_CORE1_PMACNT_GL_PM_DFE_PD_CTRL (TC956X_PHY_CORE0_REG_BASE \
  1560. + 0x00000244U)
  1561. #define TC956X_PHY_COREX_PMACNT_GL_PM_IF_CNT0 (TC956X_PHY_CORE0_REG_BASE \
  1562. + 0x00000040U)
  1563. #define TC956X_PHY_COREX_PMACNT_GL_PM_IF_CNT4 (TC956X_PHY_CORE0_REG_BASE \
  1564. + 0x00000050U)
  1565. /* PHY core 0 registers */
  1566. #define TC956X_PHY_CORE0_GL_LANE_ACCESS (TC956X_PHY_CORE0_REG_BASE \
  1567. + 0x00000000U)
  1568. #define TC956X_PHY_CORE0_POWER_CTL (TC956X_PHY_CORE0_REG_BASE \
  1569. + 0x0000309CU)
  1570. #define TC956X_PHY_CORE0_OVEREN_POWER_CTL (TC956X_PHY_CORE0_REG_BASE \
  1571. + 0x000032C8U)
  1572. #define TC956X_PMA_LN_PCS2PMA_PHYMODE_R2 (TC956X_PHY_CORE0_REG_BASE \
  1573. + 0x00003268U)
  1574. #define TC956X_PHY_CORE0_MISC_RW0_R0 (TC956X_PHY_CORE0_REG_BASE \
  1575. + 0x00000288U)
  1576. #define TC956X_PHY_CORE0_MISC_RW0_R1 (TC956X_PHY_CORE0_REG_BASE \
  1577. + 0x000002BCU)
  1578. #define TC956X_PHY_CORE0_MISC_RW0_R2 (TC956X_PHY_CORE0_REG_BASE \
  1579. + 0x000002F0U)
  1580. /* PHY core 1 registers */
  1581. #define TC956X_PHY_CORE1_GL_LANE_ACCESS (TC956X_PHY_CORE1_REG_BASE \
  1582. + 0x00000000U)
  1583. #define TC956X_PHY_CORE1_POWER_CTL (TC956X_PHY_CORE1_REG_BASE \
  1584. + 0x0000309CU)
  1585. #define TC956X_PHY_CORE1_OVEREN_POWER_CTL (TC956X_PHY_CORE1_REG_BASE \
  1586. + 0x000032C8U)
  1587. #define TC956X_PHY_CORE1_MISC_RW0_R0 (TC956X_PHY_CORE1_REG_BASE \
  1588. + 0x00000278U)
  1589. #define TC956X_PHY_CORE1_MISC_RW0_R1 (TC956X_PHY_CORE1_REG_BASE \
  1590. + 0x000002A0U)
  1591. #define TC956X_PHY_CORE1_MISC_RW0_R2 (TC956X_PHY_CORE1_REG_BASE \
  1592. + 0x000002C8U)
  1593. #define TC956X_GLUE_LTSSM_STATE_MASK (0x0000001FU)
  1594. #define TC956X_GLUE_LTSSM_STATE_SHIFT (0)
  1595. #define TC956X_GLUE_DLL_MASK (0x00000020U)
  1596. #define TC956X_GLUE_DLL_SHIFT (5)
  1597. #define TC956X_GLUE_SPEED_MASK(x) (0x0000000FU << (8*x))
  1598. #define TC956X_GLUE_SPEED_SHIFT(x) (8*x)
  1599. #define USP_LANE_WIDTH_MASK (0x0000003F)
  1600. #define DSP1_LANE_WIDTH_MASK (0x00003F00)
  1601. #define DSP1_LANE_WIDTH_SHIFT (8)
  1602. #define TC956X_GLUE_LANE_WIDTH_MASK(x) (0x0000003FU << (8*x))
  1603. #define TC956X_GLUE_LANE_WIDTH_SHIFT(x) (8*x)
  1604. #define USP_LINK_WIDTH_CHANGE_4_TO_1 (0x00000010)
  1605. #define USP_LINK_WIDTH_CHANGE_4_TO_2 (0x00000011)
  1606. #define USP_LINK_WIDTH_CHANGE_1_2_TO_4 (0x00000013)
  1607. #define USP_LINK_WIDTH_CHANGE_2_TO_1 (0x00000010)
  1608. #define USP_LINK_WIDTH_CHANGE_1_TO_2 (0x00000011)
  1609. #define DSP1_LINK_WIDTH_CHANGE_2_TO_1 (0x00100000)
  1610. #define DSP1_LINK_WIDTH_CHANGE_1_TO_2 (0x00110000)
  1611. #define SW_PORT_ENABLE_MASK GENMASK(3, 0)
  1612. #define SW_PORT_ENABLE_SHIFT 0U
  1613. #define SW_USP_ENABLE (0x00000001)
  1614. #define SW_DSP1_ENABLE (0x00000002)
  1615. #define SW_DSP2_ENABLE (0x00000004)
  1616. #define SW_VDSP_ENABLE (0x00000008)
  1617. #define PHY_CORE_ENABLE_MASK GENMASK(3, 0)
  1618. #define PHY_CORE_0_ENABLE (0x00000001)
  1619. #define PHY_CORE_1_ENABLE (0x00000002)
  1620. #define PHY_CORE_2_ENABLE (0x00000004)
  1621. #define PHY_CORE_3_ENABLE (0x00000008)
  1622. #define LANE_ENABLE_MASK GENMASK(1, 0)
  1623. #define LANE_0_ENABLE (0x00000001)
  1624. #define LANE_1_ENABLE (0x00000002)
  1625. #define POWER_CTL_MASK GENMASK(24, 0)
  1626. #define POWER_CTL_LOW_POWER_ENABLE 0x00474804
  1627. #define POWER_CTL_OVER_ENABLE 0x00000001
  1628. #define PC_DEBUG_P1_TOGGLE 0x00000001
  1629. #define ENABLE_CUT_THROUGH_ON_RX_PATH_MASK 0x1U
  1630. #define ENABLE_CUT_THROUGH_ON_TX_PATH_MASK 0x1U
  1631. #endif
  1632. /* MSIGEN Registers */
  1633. #define MSI_INT_TX_CH0 3
  1634. #define MSI_INT_RX_CH0 11
  1635. #define MSI_INT_EXT_PHY 20
  1636. #ifdef TC956X_SW_MSI
  1637. #define MSI_INT_SW_MSI 24
  1638. #endif
  1639. #ifdef TC956X_SRIOV_VF //VF_DRV related
  1640. #define TC956X_MSIGENCEN 18
  1641. /* MSIGEN Registers */
  1642. #define TC956X_MSI_BASE (0xF000)
  1643. #define TC956X_MSI_PF0 (0x0000)
  1644. #define TC956X_MSI_PF1 (0x0100)
  1645. #define TC956X_MSI_OUT_EN_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1646. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x0000))
  1647. #define TC956X_MSI_MASK_SET_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1648. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x0008))
  1649. #define TC956X_MSI_MASK_CLR_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1650. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x000c))
  1651. #define TC956X_MSI_VECT_SET0_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1652. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x0020))
  1653. #define TC956X_MSI_VECT_SET1_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1654. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x0024))
  1655. #define TC956X_MSI_VECT_SET2_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1656. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x0028))
  1657. #define TC956X_MSI_VECT_SET3_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1658. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x002C))
  1659. #define TC956X_MSI_VECT_SET4_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1660. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x0030))
  1661. #define TC956X_MSI_VECT_SET5_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1662. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x0034))
  1663. #define TC956X_MSI_VECT_SET6_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1664. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x0038))
  1665. #define TC956X_MSI_VECT_SET7_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1666. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x003C))
  1667. #define TC956X_MSI_EVENT_OFFSET(pf_id, vf_id) (TC956X_MSI_BASE +\
  1668. TC956X_MSI_PF1 + (vf_id * 0x100) + (pf_id * 0x300) + (0x0068))
  1669. #define TC956X_MSI_OUT_EN_CLR (0x00000000)
  1670. /* Enabled LPI_INT, EVENT_INT, TX_INT[3], TX_INT[4], RX_INT[3], RX_INT[4]
  1671. * XPCS_INT, PFMAILBOX_INT
  1672. */
  1673. //#define TC956X_MSI_OUT_EN (0x0028C0C5)
  1674. #define TC956X_MSI_OUT_EN (0x0027FFF8)
  1675. #define TC956X_MSI_MASK_SET (0xFFFFFFFE)
  1676. #define TC956X_MSI_MASK_CLR (0x00000001)
  1677. #define TC956X_MSI_SET0 (0x00000000)
  1678. #define TC956X_MSI_SET1 (0x00000000)
  1679. #define TC956X_MSI_SET2 (0x00000000)
  1680. #define TC956X_MSI_SET3 (0x00000000)
  1681. #define TC956X_MSI_SET4 (0x00000000)
  1682. #define TC956X_MSI_SET5 (0x00000000)
  1683. #define TC956X_MSI_SET6 (0x00000000)
  1684. #define TC956X_MSI_SET7 (0x00000000)
  1685. #define TC956X_MSI_INT_TXDMA_CH0 (3)
  1686. #define TC956X_MSI_INT_RXDMA_CH0 (11)
  1687. #define TC956X_MSI_INT_MBX (21)
  1688. #endif // #ifdef TC956X_SRIOV_VF
  1689. #if defined(TC956X_AUTOMOTIVE_CONFIG)
  1690. #define CLASS_B_CH 5 /* Class B Queue */
  1691. #define CLASS_CDT_CH 7 /* CDT Queue */
  1692. #endif
  1693. #if defined(TC956X_SRIOV_PF) && !defined(TC956X_AUTOMOTIVE_CONFIG) && !defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  1694. #define HOST_BEST_EFF_CH 3 /* Best effort traffic Queue*/
  1695. #define UNTAGGED_PTP_CH 4 /* Untagged PTP Queue */
  1696. #define CLASS_B_CH 5 /* Class B Queue */
  1697. #define CLASS_A_CH 6 /* Class A Queue */
  1698. #define CLASS_CDT_CH 7 /* CDT Queue */
  1699. #define TC956X_GPTP_TX_CH UNTAGGED_PTP_CH
  1700. /* All data is redirected to Legacy Channel for SRIOV Usecase */
  1701. #define LEGACY_VLAN_TAGGED_CH HOST_BEST_EFF_CH
  1702. #define AVB_CLASS_B_TX_CH HOST_BEST_EFF_CH
  1703. #define AVB_CLASS_A_TX_CH HOST_BEST_EFF_CH
  1704. #define TSN_CLASS_CDT_TX_CH HOST_BEST_EFF_CH
  1705. #elif defined(TC956X_SRIOV_PF) && (defined(TC956X_AUTOMOTIVE_CONFIG) || defined(TC956X_ENABLE_MAC2MAC_BRIDGE))
  1706. #define HOST_BEST_EFF_CH 0 /* Legacy channel is best effort traffic */
  1707. #define LEGACY_VLAN_TAGGED_CH 0 /* Legacy VLAN tagged queue */
  1708. #define TC956X_GPTP_TX_CH 4 /* gPTP Tx Channel */
  1709. #define AVB_CLASS_B_TX_CH 5 /* AVB Class B Qeuue */
  1710. #define AVB_CLASS_A_TX_CH 6 /* AVB Class A Qeuue */
  1711. #define TSN_CLASS_CDT_TX_CH 7 /* Express Control Traffic */
  1712. #else
  1713. #ifdef TC956X
  1714. #ifndef TC956X_SRIOV_VF
  1715. /* CPE usecase only TxCH 0 is applicable */
  1716. #define HOST_BEST_EFF_CH 0 /* Legacy channel is best effort traffic */
  1717. #define LEGACY_VLAN_TAGGED_CH 0 /* Legacy VLAN tagged queue */
  1718. #define TC956X_GPTP_TX_CH 0 /* gPTP Tx Channel */
  1719. #define AVB_CLASS_B_TX_CH 0 /* AVB Class B Qeuue */
  1720. #define AVB_CLASS_A_TX_CH 0 /* AVB Class A Qeuue */
  1721. #define TSN_CLASS_CDT_TX_CH 0 /* Express Control Traffic */
  1722. #endif
  1723. #endif
  1724. #endif
  1725. /* Scale factor for the CBS calculus */
  1726. #define AVB_CBS_SCALE 1024
  1727. #define TC956X_HOST_PHYSICAL_ADRS_MASK (0x10) /* bit no 37: (1<<36) */
  1728. #define ETHNORMAL_LEN 1500
  1729. #define MAX_SUPPORTED_MTU (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
  1730. #define MIN_SUPPORTED_MTU (ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN)
  1731. #define HOST_MAC_ADDR_OFFSET 2
  1732. #define HOST_BC_ADDR_OFFSET 0
  1733. #endif /* End of TC956X Define */
  1734. /* These need to be power of two, and >= 4 */
  1735. #define DMA_TX_SIZE 512
  1736. #define DMA_RX_SIZE 512
  1737. #define TC956XMAC_GET_ENTRY(x, size) ((x + 1) & (size - 1))
  1738. /* default DMA channel for TC */
  1739. #if defined(TC956X_SRIOV_PF) && !defined(TC956X_AUTOMOTIVE_CONFIG) && !defined(TC956X_ENABLE_MAC2MAC_BRIDGE)
  1740. #define TC956X_TC_DEFAULT_DMA_CH (0x1 << 3)
  1741. #else
  1742. #define TC956X_TC_DEFAULT_DMA_CH (0x1 << 0)
  1743. #endif
  1744. #undef FRAME_FILTER_DEBUG
  1745. /* #define FRAME_FILTER_DEBUG */
  1746. #define TOTAL_VF 3
  1747. /* Extra statistic and debug information exposed by ethtool */
  1748. struct tc956xmac_extra_stats {
  1749. /* Transmit errors */
  1750. u64 tx_underflow ____cacheline_aligned;
  1751. u64 tx_carrier;
  1752. u64 tx_losscarrier;
  1753. u64 vlan_tag;
  1754. u64 tx_deferred;
  1755. u64 tx_vlan;
  1756. u64 tx_jabber;
  1757. u64 tx_frame_flushed;
  1758. u64 tx_payload_error;
  1759. u64 tx_ip_header_error;
  1760. /* Receive errors */
  1761. u64 rx_desc;
  1762. u64 sa_filter_fail;
  1763. u64 overflow_error;
  1764. u64 ipc_csum_error;
  1765. u64 rx_collision;
  1766. u64 rx_crc_errors;
  1767. u64 dribbling_bit;
  1768. u64 rx_length;
  1769. u64 rx_mii;
  1770. u64 rx_multicast;
  1771. u64 rx_gmac_overflow;
  1772. u64 rx_watchdog;
  1773. u64 da_rx_filter_fail;
  1774. u64 sa_rx_filter_fail;
  1775. u64 rx_missed_cntr;
  1776. u64 rx_overflow_cntr;
  1777. u64 rx_vlan;
  1778. u64 rx_split_hdr_pkt_n;
  1779. /* Tx/Rx IRQ error info */
  1780. u64 tx_undeflow_irq;
  1781. u64 tx_process_stopped_irq[TC956XMAC_CH_MAX];
  1782. u64 tx_jabber_irq;
  1783. u64 rx_overflow_irq;
  1784. u64 rx_buf_unav_irq[TC956XMAC_CH_MAX];
  1785. u64 rx_process_stopped_irq;
  1786. u64 rx_watchdog_irq;
  1787. u64 tx_early_irq;
  1788. u64 fatal_bus_error_irq[TC956XMAC_CH_MAX];
  1789. /* Tx/Rx IRQ Events */
  1790. u64 rx_early_irq;
  1791. u64 threshold;
  1792. u64 tx_pkt_n[TC956XMAC_CH_MAX];
  1793. u64 tx_pkt_errors_n[TC956XMAC_CH_MAX];
  1794. u64 rx_pkt_n[TC956XMAC_CH_MAX];
  1795. u64 normal_irq_n[TC956XMAC_CH_MAX];
  1796. u64 rx_normal_irq_n[TC956XMAC_CH_MAX];
  1797. u64 napi_poll_tx[TC956XMAC_CH_MAX];
  1798. u64 napi_poll_rx[TC956XMAC_CH_MAX];
  1799. u64 tx_normal_irq_n[TC956XMAC_CH_MAX];
  1800. u64 tx_clean[TC956XMAC_CH_MAX];
  1801. u64 tx_set_ic_bit;
  1802. u64 irq_receive_pmt_irq_n;
  1803. /* MMC info */
  1804. u64 mmc_tx_irq_n;
  1805. u64 mmc_rx_irq_n;
  1806. u64 mmc_rx_csum_offload_irq_n;
  1807. /* EEE */
  1808. u64 irq_tx_path_in_lpi_mode_n;
  1809. u64 irq_tx_path_exit_lpi_mode_n;
  1810. u64 irq_rx_path_in_lpi_mode_n;
  1811. u64 irq_rx_path_exit_lpi_mode_n;
  1812. u64 phy_eee_wakeup_error_n;
  1813. /* Extended RDES status */
  1814. u64 ip_hdr_err;
  1815. u64 ip_payload_err;
  1816. u64 ip_csum_bypassed;
  1817. u64 ipv4_pkt_rcvd;
  1818. u64 ipv6_pkt_rcvd;
  1819. u64 no_ptp_rx_msg_type_ext;
  1820. u64 ptp_rx_msg_type_sync;
  1821. u64 ptp_rx_msg_type_follow_up;
  1822. u64 ptp_rx_msg_type_delay_req;
  1823. u64 ptp_rx_msg_type_delay_resp;
  1824. u64 ptp_rx_msg_type_pdelay_req;
  1825. u64 ptp_rx_msg_type_pdelay_resp;
  1826. u64 ptp_rx_msg_type_pdelay_follow_up;
  1827. u64 ptp_rx_msg_type_announce;
  1828. u64 ptp_rx_msg_type_management;
  1829. u64 ptp_rx_msg_pkt_reserved_type;
  1830. u64 ptp_frame_type;
  1831. u64 ptp_ver;
  1832. u64 timestamp_dropped;
  1833. u64 av_pkt_rcvd;
  1834. u64 av_tagged_pkt_rcvd;
  1835. u64 vlan_tag_priority_val;
  1836. u64 l3_filter_match;
  1837. u64 l4_filter_match;
  1838. u64 l3_l4_filter_no_match;
  1839. /* PCS */
  1840. u64 irq_pcs_ane_n;
  1841. u64 irq_pcs_link_n;
  1842. u64 irq_rgmii_n;
  1843. u64 pcs_link;
  1844. u64 pcs_duplex;
  1845. u64 pcs_speed;
  1846. /* debug register */
  1847. u64 mtl_tx_status_fifo_full;
  1848. u64 mtl_tx_fifo_not_empty[MTL_MAX_TX_QUEUES];
  1849. u64 mmtl_fifo_ctrl[MTL_MAX_TX_QUEUES];
  1850. u64 mtl_tx_fifo_read_ctrl_write[MTL_MAX_TX_QUEUES];
  1851. u64 mtl_tx_fifo_read_ctrl_wait[MTL_MAX_TX_QUEUES];
  1852. u64 mtl_tx_fifo_read_ctrl_read[MTL_MAX_TX_QUEUES];
  1853. u64 mtl_tx_fifo_read_ctrl_idle[MTL_MAX_TX_QUEUES];
  1854. u64 mac_tx_in_pause[MTL_MAX_TX_QUEUES];
  1855. u64 mac_tx_frame_ctrl_xfer;
  1856. u64 mac_tx_frame_ctrl_idle;
  1857. u64 mac_tx_frame_ctrl_wait;
  1858. u64 mac_tx_frame_ctrl_pause;
  1859. u64 mac_gmii_tx_proto_engine;
  1860. u64 mtl_rx_fifo_fill_level_full[MTL_MAX_RX_QUEUES];
  1861. u64 mtl_rx_fifo_fill_above_thresh[MTL_MAX_RX_QUEUES];
  1862. u64 mtl_rx_fifo_fill_below_thresh[MTL_MAX_RX_QUEUES];
  1863. u64 mtl_rx_fifo_fill_level_empty[MTL_MAX_RX_QUEUES];
  1864. u64 mtl_rx_fifo_read_ctrl_flush[MTL_MAX_RX_QUEUES];
  1865. u64 mtl_rx_fifo_read_ctrl_read[MTL_MAX_RX_QUEUES];
  1866. u64 mtl_rx_fifo_read_ctrl_status[MTL_MAX_RX_QUEUES];
  1867. u64 mtl_rx_fifo_read_ctrl_idle[MTL_MAX_RX_QUEUES];
  1868. u64 mtl_rx_fifo_ctrl_active[MTL_MAX_RX_QUEUES];
  1869. u64 mac_rx_frame_ctrl_fifo;
  1870. u64 mac_gmii_rx_proto_engine;
  1871. /* TSO */
  1872. u64 tx_tso_frames[TC956XMAC_CH_MAX];
  1873. u64 tx_tso_nfrags[TC956XMAC_CH_MAX];
  1874. /* Tx desc statistics */
  1875. u64 txch_status[TC956XMAC_CH_MAX];
  1876. u64 txch_control[TC956XMAC_CH_MAX];
  1877. u64 txch_desc_list_haddr[TC956XMAC_CH_MAX];
  1878. u64 txch_desc_list_laddr[TC956XMAC_CH_MAX];
  1879. u64 txch_desc_ring_len[TC956XMAC_CH_MAX];
  1880. u64 txch_desc_curr_haddr[TC956XMAC_CH_MAX];
  1881. u64 txch_desc_curr_laddr[TC956XMAC_CH_MAX];
  1882. u64 txch_desc_tail[TC956XMAC_CH_MAX];
  1883. u64 txch_desc_buf_haddr[TC956XMAC_CH_MAX];
  1884. u64 txch_desc_buf_laddr[TC956XMAC_CH_MAX];
  1885. u64 txch_sw_cur_tx[TC956XMAC_CH_MAX];
  1886. u64 txch_sw_dirty_tx[TC956XMAC_CH_MAX];
  1887. /* Rx desc statistics */
  1888. u64 rxch_status[TC956XMAC_CH_MAX];
  1889. u64 rxch_control[TC956XMAC_CH_MAX];
  1890. u64 rxch_desc_list_haddr[TC956XMAC_CH_MAX];
  1891. u64 rxch_desc_list_laddr[TC956XMAC_CH_MAX];
  1892. u64 rxch_desc_ring_len[TC956XMAC_CH_MAX];
  1893. u64 rxch_desc_curr_haddr[TC956XMAC_CH_MAX];
  1894. u64 rxch_desc_curr_laddr[TC956XMAC_CH_MAX];
  1895. u64 rxch_desc_tail[TC956XMAC_CH_MAX];
  1896. u64 rxch_desc_buf_haddr[TC956XMAC_CH_MAX];
  1897. u64 rxch_desc_buf_laddr[TC956XMAC_CH_MAX];
  1898. u64 rxch_sw_cur_rx[TC956XMAC_CH_MAX];
  1899. u64 rxch_sw_dirty_rx[TC956XMAC_CH_MAX];
  1900. #ifdef TC956X_SRIOV_PF
  1901. u64 mbx_pf_sent_vf[TOTAL_VF];
  1902. u64 mbx_pf_rcvd_vf[TOTAL_VF];
  1903. #else
  1904. u64 mbx_vf_sent_pf;
  1905. u64 mbx_vf_rcvd_pf;
  1906. #endif
  1907. /*debug interrupt counters */
  1908. u64 total_interrupts;
  1909. u64 lpi_intr_n;
  1910. u64 pmt_intr_n;
  1911. u64 event_intr_n;
  1912. u64 tx_intr_n;
  1913. u64 rx_intr_n;
  1914. u64 xpcs_intr_n;
  1915. u64 phy_intr_n;
  1916. u64 sw_msi_n;
  1917. /*MTL Debug counters */
  1918. u64 mtl_tx_underflow[MTL_MAX_TX_QUEUES];
  1919. u64 mtl_rx_miss_pkt_cnt[MTL_MAX_RX_QUEUES];
  1920. u64 mtl_rx_overflow_pkt_cnt[MTL_MAX_RX_QUEUES];
  1921. u64 rxch_watchdog_timer[TC956XMAC_CH_MAX];
  1922. u64 link_partner_pause_frame_cnt;
  1923. /*m3 SRAM debug counters */
  1924. u64 m3_debug_cnt0;
  1925. u64 m3_debug_cnt1;
  1926. u64 m3_debug_cnt2;
  1927. u64 m3_debug_cnt3;
  1928. u64 m3_debug_cnt4;
  1929. u64 m3_debug_cnt5;
  1930. u64 m3_debug_cnt6;
  1931. u64 m3_debug_cnt7;
  1932. u64 m3_debug_cnt8;
  1933. u64 m3_debug_cnt9;
  1934. u64 m3_debug_cnt10;
  1935. u64 m3_watchdog_exp_cnt;
  1936. u64 m3_watchdog_monitor_cnt;
  1937. u64 m3_debug_cnt13;
  1938. u64 m3_debug_cnt14;
  1939. u64 m3_systick_cnt_upper_value;
  1940. u64 m3_systick_cnt_lower_value;
  1941. u64 m3_tx_timeout_port0;
  1942. u64 m3_tx_timeout_port1;
  1943. u64 m3_debug_cnt19;
  1944. u64 m3_tx_pcie_addr_loc_port0[TC956XMAC_CH_MAX];
  1945. u64 m3_tx_pcie_addr_loc_port1[TC956XMAC_CH_MAX];
  1946. u64 m3_rx_pcie_addr_loc_port0[TC956XMAC_CH_MAX];
  1947. u64 m3_rx_pcie_addr_loc_port1[TC956XMAC_CH_MAX];
  1948. };
  1949. /* Safety Feature statistics exposed by ethtool */
  1950. struct tc956xmac_safety_stats {
  1951. unsigned long mac_errors[32];
  1952. unsigned long mtl_errors[32];
  1953. unsigned long dma_errors[32];
  1954. };
  1955. #ifdef TC956X_SRIOV_VF
  1956. struct tc956x_sw_counters {
  1957. u64 tx_frame_count_good_bad;
  1958. u64 rx_frame_count_good_bad;
  1959. u64 rx_frame_count_good;
  1960. u64 rx_fame_count_bad;
  1961. u64 rx_packet_good_octets;
  1962. u64 rx_header_good_octets;
  1963. u64 rx_av_tagged_datapacket_count;
  1964. u64 rx_av_tagged_controlpacket_count;
  1965. u64 rx_nonav_packet_count;
  1966. u64 rx_tunnel_packet_count;
  1967. u64 rx_non_ip_pkt_count;
  1968. u64 rx_ipv4_tcp_pkt_count;
  1969. u64 rx_ipv4_udp_pkt_count;
  1970. u64 rx_ipv4_icmp_pkt_count;
  1971. u64 rx_ipv4_igmp_pkt_count;
  1972. u64 rx_ipv4_unkown_pkt_count;
  1973. u64 rx_ipv6_tcp_pkt_count;
  1974. u64 rx_ipv6_udp_pkt_count;
  1975. u64 rx_ipv6_icmp_pkt_count;
  1976. u64 rx_ipv6_unkown_pkt_count;
  1977. u64 rx_err_wd_timeout_count;
  1978. u64 rx_err_gmii_inv_count;
  1979. u64 rx_err_crc_count;
  1980. u64 rx_err_giant_count;
  1981. u64 rx_err_checksum_count;
  1982. u64 rx_err_overflow_count;
  1983. u64 rx_err_bus_count;
  1984. u64 rx_err_pkt_len_count;
  1985. u64 rx_err_runt_pkt_count;
  1986. u64 rx_err_dribble_count;
  1987. u64 rx_err_t_out_ip_header_count;
  1988. u64 rx_err_t_out_ip_pl_l4_csum_count;
  1989. u64 rx_err_t_in_ip_header_count;
  1990. u64 rx_err_t_in_ip_pl_l4_csum_count;
  1991. u64 rx_err_t_invalid_vlan_header;
  1992. u64 rx_l2_len_pkt_count;
  1993. u64 rx_l2_mac_control_pkt_count;
  1994. u64 rx_l2_dcb_control_pkt_count;
  1995. u64 rx_l2_arp_pkt_count;
  1996. u64 rx_l2_oam_type_pkt_count;
  1997. u64 rx_l2_untg_typ_match_pkt_count;
  1998. u64 rx_l2_other_type_pkt_count;
  1999. u64 rx_l2_single_svlan_pkt_count;
  2000. u64 rx_l2_single_cvlan_pkt_count;
  2001. u64 rx_l2_d_cvlan_cvlan_pkt_count;
  2002. u64 rx_l2_d_svlan_svlan_pkt_count;
  2003. u64 rx_l2_d_svlan_cvlan_pkt_count;
  2004. u64 rx_l2_d_cvlan_svlan_pkt_count;
  2005. u64 rx_l2_untg_av_control_pkt_count;
  2006. u64 rx_ptp_no_msg;
  2007. u64 rx_ptp_msg_type_sync;
  2008. u64 rx_ptp_msg_type_follow_up;
  2009. u64 rx_ptp_msg_type_delay_req;
  2010. u64 rx_ptp_msg_type_delay_resp;
  2011. u64 rx_ptp_msg_type_pdelay_req;
  2012. u64 rx_ptp_msg_type_pdelay_resp;
  2013. u64 rx_ptp_msg_type_pdelay_follow_up;
  2014. u64 rx_ptp_msg_type_announce;
  2015. u64 rx_ptp_msg_type_management;
  2016. u64 rx_ptp_msg_pkt_signaling;
  2017. u64 rx_ptp_msg_pkt_reserved_type;
  2018. };
  2019. #endif //#ifdef TC956X_SRIOV_VF
  2020. struct tc956x_mac_addr {
  2021. u8 mac_address[6];
  2022. u8 status;
  2023. u8 counter;
  2024. u8 vf[4];
  2025. };
  2026. struct vf_status {
  2027. u8 vf_number;
  2028. u8 loc_counter;
  2029. };
  2030. struct tc956x_vlan_id {
  2031. u16 vid;
  2032. u8 status;
  2033. u8 glo_counter;
  2034. struct vf_status vf[4];
  2035. };
  2036. /* Number of fields in Safety Stats */
  2037. #define TC956XMAC_SAFETY_FEAT_SIZE \
  2038. (sizeof(struct tc956xmac_safety_stats) / sizeof(unsigned long))
  2039. /* CSR Frequency Access Defines*/
  2040. #define CSR_F_35M 35000000
  2041. #define CSR_F_60M 60000000
  2042. #define CSR_F_100M 100000000
  2043. #define CSR_F_150M 150000000
  2044. #define CSR_F_250M 250000000
  2045. #define CSR_F_300M 300000000
  2046. #define MAC_CSR_H_FRQ_MASK 0x20
  2047. #define HASH_TABLE_SIZE 64
  2048. #define MAX_MAC_ADDR_FILTERS 32
  2049. #define PAUSE_TIME 0xffff
  2050. /* Flow Control defines */
  2051. #define FLOW_OFF 0
  2052. #define FLOW_RX 1
  2053. #define FLOW_TX 2
  2054. #define FLOW_AUTO (FLOW_TX | FLOW_RX)
  2055. /* PCS defines */
  2056. #define TC956XMAC_PCS_RGMII (1 << 0)
  2057. #define TC956XMAC_PCS_SGMII (1 << 1)
  2058. #define TC956XMAC_PCS_TBI (1 << 2)
  2059. #define TC956XMAC_PCS_RTBI (1 << 3)
  2060. #define TC956XMAC_PCS_USXGMII (1 << 4)
  2061. #define SF_DMA_MODE 1 /* DMA STORE-AND-FORWARD Operation Mode */
  2062. /* DAM HW feature register fields */
  2063. #define DMA_HW_FEAT_MIISEL 0x00000001 /* 10/100 Mbps Support */
  2064. #define DMA_HW_FEAT_GMIISEL 0x00000002 /* 1000 Mbps Support */
  2065. #define DMA_HW_FEAT_HDSEL 0x00000004 /* Half-Duplex Support */
  2066. #define DMA_HW_FEAT_EXTHASHEN 0x00000008 /* Expanded DA Hash Filter */
  2067. #define DMA_HW_FEAT_HASHSEL 0x00000010 /* HASH Filter */
  2068. #define DMA_HW_FEAT_ADDMAC 0x00000020 /* Multiple MAC Addr Reg */
  2069. #define DMA_HW_FEAT_PCSSEL 0x00000040 /* PCS registers */
  2070. #define DMA_HW_FEAT_L3L4FLTREN 0x00000080 /* Layer 3 & Layer 4 Feature */
  2071. #define DMA_HW_FEAT_SMASEL 0x00000100 /* SMA(MDIO) Interface */
  2072. #define DMA_HW_FEAT_RWKSEL 0x00000200 /* PMT Remote Wakeup */
  2073. #define DMA_HW_FEAT_MGKSEL 0x00000400 /* PMT Magic Packet */
  2074. #define DMA_HW_FEAT_MMCSEL 0x00000800 /* RMON Module */
  2075. #define DMA_HW_FEAT_TSVER1SEL 0x00001000 /* Only IEEE 1588-2002 */
  2076. #define DMA_HW_FEAT_TSVER2SEL 0x00002000 /* IEEE 1588-2008 PTPv2 */
  2077. #define DMA_HW_FEAT_EEESEL 0x00004000 /* Energy Efficient Ethernet */
  2078. #define DMA_HW_FEAT_AVSEL 0x00008000 /* AV Feature */
  2079. #define DMA_HW_FEAT_TXCOESEL 0x00010000 /* Checksum Offload in Tx */
  2080. #define DMA_HW_FEAT_RXTYP1COE 0x00020000 /* IP COE (Type 1) in Rx */
  2081. #define DMA_HW_FEAT_RXTYP2COE 0x00040000 /* IP COE (Type 2) in Rx */
  2082. #define DMA_HW_FEAT_RXFIFOSIZE 0x00080000 /* Rx FIFO > 2048 Bytes */
  2083. #define DMA_HW_FEAT_RXCHCNT 0x00300000 /* No. additional Rx Channels */
  2084. #define DMA_HW_FEAT_TXCHCNT 0x00c00000 /* No. additional Tx Channels */
  2085. #define DMA_HW_FEAT_ENHDESSEL 0x01000000 /* Alternate Descriptor */
  2086. /* Timestamping with Internal System Time */
  2087. #define DMA_HW_FEAT_INTTSEN 0x02000000
  2088. #define DMA_HW_FEAT_FLEXIPPSEN 0x04000000 /* Flexible PPS Output */
  2089. #define DMA_HW_FEAT_SAVLANINS 0x08000000 /* Source Addr or VLAN */
  2090. #define DMA_HW_FEAT_ACTPHYIF 0x70000000 /* Active/selected PHY iface */
  2091. #define DEFAULT_DMA_PBL 8
  2092. /* PCS status and mask defines */
  2093. #define PCS_ANE_IRQ BIT(2) /* PCS Auto-Negotiation */
  2094. #define PCS_LINK_IRQ BIT(1) /* PCS Link */
  2095. #define PCS_RGSMIIIS_IRQ BIT(0) /* RGMII or SMII Interrupt */
  2096. /* Max/Min RI Watchdog Timer count value */
  2097. #define MAX_DMA_RIWT 0xFF
  2098. #define MIN_DMA_RIWT 0x1
  2099. #define DEF_DMA_RIWT 0xa0
  2100. /* Tx coalesce parameters */
  2101. #define TC956XMAC_COAL_TX_TIMER 1000
  2102. #define TC956XMAC_MAX_COAL_TX_TICK 100000
  2103. #define TC956XMAC_TX_MAX_FRAMES 256
  2104. #define TC956XMAC_RX_MAX_FRAMES 32
  2105. #define TC956XMAC_TX_FRAMES 64
  2106. #define TC956XMAC_RX_FRAMES 0
  2107. /* Rx IPC status */
  2108. enum rx_frame_status {
  2109. good_frame = 0x0,
  2110. discard_frame = 0x1,
  2111. csum_none = 0x2,
  2112. llc_snap = 0x4,
  2113. dma_own = 0x8,
  2114. rx_not_ls = 0x10,
  2115. };
  2116. /* Tx status */
  2117. enum tx_frame_status {
  2118. tx_done = 0x0,
  2119. tx_not_ls = 0x1,
  2120. tx_err = 0x2,
  2121. tx_dma_own = 0x4,
  2122. };
  2123. enum dma_irq_status {
  2124. tx_hard_error = 0x1,
  2125. tx_hard_error_bump_tc = 0x2,
  2126. handle_rx = 0x4,
  2127. handle_tx = 0x8,
  2128. };
  2129. #ifdef TC956X_SRIOV_VF
  2130. #define MBX_MSG_OFST 4 /* First 4 bytes for ACK management */
  2131. #define MBX_MSG_SIZE 60 /* Excluding ACK */
  2132. #define MBX_ACK_SIZE 4 /* ACK management */
  2133. #define MBX_TOT_SIZE (MBX_MSG_SIZE + MBX_ACK_SIZE)
  2134. #define ACK 0x01
  2135. #define NACK 0x02
  2136. /* Mailbox opcode definitions */
  2137. #define OPCODE_MBX_ADD_MAC_ADDR 0x01
  2138. #define OPCODE_MBX_SET_TX_Q_WEIGHT 0x02
  2139. #define OPCODE_MBX_CFG_CBS 0x03
  2140. #define OPCODE_MBX_SET_TX_Q_PRIOR 0x04
  2141. #define OPCODE_MBX_RESET_EEE_MODE 0x05
  2142. #define OPCODE_MBX_VF_IOCTL 0x06
  2143. #define OPCODE_MBX_VF_ETHTOOL 0x07
  2144. #define OPCODE_MBX_VF_ADD_MAC 0x08
  2145. #define OPCODE_MBX_VF_DELETE_MAC 0x09
  2146. #define OPCODE_MBX_VF_ADD_VLAN 0x10
  2147. #define OPCODE_MBX_VF_DELETE_VLAN 0x11
  2148. #define OPCODE_MBX_SET_DMA_TX_MODE 0x12
  2149. #define OPCODE_MBX_VF_GET_LINK_STATUS 0x13
  2150. #define OPCODE_MBX_PHY_LINK 0x14
  2151. #define OPCODE_MBX_SETUP_CBS 0x15
  2152. #define OPCODE_MBX_RX_CRC 0x16
  2153. #define OPCODE_MBX_RX_CSUM 0x17
  2154. #define OPCODE_MBX_DRV_CAP 0x18
  2155. #define OPCODE_MBX_VF_GET_PAUSE_PARAM 0x19
  2156. #define OPCODE_MBX_VF_GET_EEE 0x20
  2157. #define OPCODE_MBX_VF_GET_TS_INFO 0x22
  2158. #define OPCODE_MBX_VF_GET_MII_PHY 0x23
  2159. #define OPCODE_MBX_VF_GET_PAUSE_PARAM_2 0x24
  2160. #define OPCODE_MBX_GET_UMAC_ADDR 0x25
  2161. #define OPCODE_VF_RESET 0x26
  2162. #define OPCODE_MBX_DMA_CH_TLPTR 0x29
  2163. #define OPCODE_MBX_SETUP_ETF 0x30
  2164. #define OPCODE_MBX_FLR 0x33
  2165. #define OPCODE_MBX_DMA_ERR 0x34
  2166. #define OPCODE_MBX_ACK_MSG 0xFF
  2167. #define SIZE_MBX_SET_TX_Q_WEIGHT 8
  2168. #define SIZE_MBX_CFG_CBS 20
  2169. #define SIZE_MBX_SETUP_ETF 5
  2170. #define SIZE_MBX_SETUP_CBS 21
  2171. #define SIZE_MBX_CFG_EST 56
  2172. #define SIZE_MBX_CFG_FPE 20
  2173. #define SIZE_MBX_SET_TX_Q_PRIOR 8
  2174. #define SIZE_MBX_SET_DMA_TX_MODE 13
  2175. #define SIZE_MBX_VF_GET_LINK_STATUS 0
  2176. #define SIZE_MBX_PHY_LINK 12
  2177. #define SIZE_MBX_RX_CRC 4
  2178. #define SIZE_MBX_RX_CSUM 4
  2179. #define SIZE_MBX_DRV_CAP 4
  2180. #define SIZE_SET_UMAC_ADDR 10
  2181. #define SIZE_GET_UMAC_ADDR 4
  2182. #define SIZE_MBX_VF_MAC 6
  2183. #define SIZE_MBX_VF_VLAN 2
  2184. #define SIZE_MBX_VF_REG_WR 13
  2185. #define SIZE_MBX_VF_SPEED 1
  2186. #define SIZE_MBX_SET_GET_CBS_1 56
  2187. #define SIZE_MBX_SET_GET_CBS_2 44
  2188. #define SIZE_MBX_SET_GET_EST_1 56
  2189. #define SIZE_MBX_SET_GET_RXP_1 56
  2190. #define SIZE_MBX_SET_GET_FPE_1 20
  2191. #define SIZE_MBX_VF_GET_CBS 2
  2192. #define SIZE_MBX_VF_PAUSE_PARAM 1
  2193. #define SIZE_MBX_VF_EEE 1
  2194. #define SIZE_MBX_VF_TS_INFO 1
  2195. #define SIZE_VF_RESET 1
  2196. #define SIZE_MBX_VF_TIMESTAMP 2
  2197. #define SIZE_MBX_VF_GET_EST 1
  2198. #define SIZE_MBX_VF_GET_RXP 1
  2199. #define SIZE_MBX_VF_GET_FPE 1
  2200. #define SIZE_MBX_VF_GET_MII_REG 23
  2201. #define SIZE_MBX_RX_DMA_TL_PTR 4
  2202. #define SIZE_MBX_GET_HW_STMP 12
  2203. #define MAX_SIZE_GCL_MSG 14
  2204. #define EST_FIX_MSG_LEN 28
  2205. #define RXP_FIX_MSG_LEN 16
  2206. #define VF_UP 1
  2207. #define VF_DOWN 0
  2208. #define VF_SUSPEND 2
  2209. #define VF_RELEASE 3
  2210. #define SCH_WQ_PF_FLR 1
  2211. #define SCH_WQ_RX_DMA_ERR 2
  2212. #define SCH_WQ_LINK_STATE_UP 3
  2213. #endif /* #ifdef TC956X_SRIOV_VF */
  2214. /* EEE and LPI defines */
  2215. #define CORE_IRQ_TX_PATH_IN_LPI_MODE (1 << 0)
  2216. #define CORE_IRQ_TX_PATH_EXIT_LPI_MODE (1 << 1)
  2217. #define CORE_IRQ_RX_PATH_IN_LPI_MODE (1 << 2)
  2218. #define CORE_IRQ_RX_PATH_EXIT_LPI_MODE (1 << 3)
  2219. #define CORE_IRQ_MTL_RX_OVERFLOW BIT(8)
  2220. /* Physical Coding Sublayer */
  2221. struct rgmii_adv {
  2222. unsigned int pause;
  2223. unsigned int duplex;
  2224. unsigned int lp_pause;
  2225. unsigned int lp_duplex;
  2226. };
  2227. #define TC956XMAC_PCS_PAUSE 1
  2228. #define TC956XMAC_PCS_ASYM_PAUSE 2
  2229. /* DMA HW capabilities */
  2230. struct dma_features {
  2231. unsigned int mbps_10_100;
  2232. unsigned int mbps_1000;
  2233. unsigned int half_duplex;
  2234. unsigned int hash_filter;
  2235. unsigned int multi_addr;
  2236. unsigned int pcs;
  2237. unsigned int sma_mdio;
  2238. unsigned int pmt_remote_wake_up;
  2239. unsigned int pmt_magic_frame;
  2240. unsigned int rmon;
  2241. /* IEEE 1588-2002 */
  2242. unsigned int time_stamp;
  2243. /* IEEE 1588-2008 */
  2244. unsigned int atime_stamp;
  2245. /* 802.3az - Energy-Efficient Ethernet (EEE) */
  2246. unsigned int eee;
  2247. unsigned int av;
  2248. unsigned int hash_tb_sz;
  2249. unsigned int tsoen;
  2250. /* TX and RX csum */
  2251. unsigned int tx_coe;
  2252. unsigned int rx_coe;
  2253. unsigned int rx_coe_type1;
  2254. unsigned int rx_coe_type2;
  2255. unsigned int rxfifo_over_2048;
  2256. /* TX and RX number of channels */
  2257. unsigned int number_rx_channel;
  2258. unsigned int number_tx_channel;
  2259. /* TX and RX number of queues */
  2260. unsigned int number_rx_queues;
  2261. unsigned int number_tx_queues;
  2262. /* PPS output */
  2263. unsigned int pps_out_num;
  2264. /* Alternate (enhanced) DESC mode */
  2265. unsigned int enh_desc;
  2266. /* TX and RX FIFO sizes */
  2267. unsigned int tx_fifo_size;
  2268. unsigned int rx_fifo_size;
  2269. /* Automotive Safety Package */
  2270. unsigned int asp;
  2271. /* RX Parser */
  2272. unsigned int spram;
  2273. unsigned int frpsel;
  2274. unsigned int frpbs;
  2275. unsigned int frpes;
  2276. unsigned int addr64;
  2277. unsigned int rssen;
  2278. unsigned int vlhash;
  2279. unsigned int sphen;
  2280. unsigned int vlins;
  2281. unsigned int dvlan;
  2282. unsigned int l3l4fnum;
  2283. unsigned int arpoffsel;
  2284. /* TSN Features */
  2285. unsigned int estwid;
  2286. unsigned int estdep;
  2287. unsigned int estsel;
  2288. unsigned int fpesel;
  2289. unsigned int tbssel;
  2290. unsigned int ptoen;
  2291. unsigned int osten;
  2292. };
  2293. /* RX Buffer size must be multiple of 4/8/16 bytes */
  2294. #define BUF_SIZE_16KiB 16368
  2295. #define BUF_SIZE_8KiB 8188
  2296. #define BUF_SIZE_4KiB 4096
  2297. #define BUF_SIZE_2KiB 2048
  2298. /* Power Down and WOL */
  2299. #define PMT_NOT_SUPPORTED 0
  2300. #define PMT_SUPPORTED 1
  2301. /* Common MAC defines */
  2302. #define MAC_CTRL_REG (MAC_OFFSET + 0x00000000) /* MAC Control */
  2303. #define MAC_ENABLE_TX 0x00000008 /* Transmitter Enable */
  2304. #define MAC_ENABLE_RX 0x00000004 /* Receiver Enable */
  2305. /* Default LPI timers */
  2306. #define TC956XMAC_DEFAULT_LIT_LS 0x3E8
  2307. #define TC956XMAC_DEFAULT_TWT_LS 0x1E
  2308. #define TC956XMAC_LIT_LS 0x0011
  2309. #define TC956XMAC_TWT_LS 0x0028
  2310. #define TC956XMAC_TIC_1US_CNTR 0x7c
  2311. #define TC956XMAC_LPIET_600US 0x258
  2312. #define TC956X_PHY_SPEED_5G 5000
  2313. #define TC956X_PHY_SPEED_2_5G 2500
  2314. #define TC956XMAC_CHAIN_MODE 0x1
  2315. #define TC956XMAC_RING_MODE 0x2
  2316. #define JUMBO_LEN (TC956XMAC_ALIGN(9000))
  2317. /* Receive Side Scaling */
  2318. #define TC956XMAC_RSS_HASH_KEY_SIZE 40
  2319. #define TC956XMAC_RSS_MAX_TABLE_SIZE 256
  2320. /* VLAN */
  2321. #define TC956XMAC_VLAN_NONE 0x0
  2322. #define TC956XMAC_VLAN_REMOVE 0x1
  2323. #define TC956XMAC_VLAN_INSERT 0x2
  2324. #define TC956XMAC_VLAN_REPLACE 0x3
  2325. #define TC956X_ENABLE 1
  2326. #define TC956X_DISABLE 0
  2327. /* Numbers in Words */
  2328. #define TC956X_ZERO 0
  2329. #define TC956X_ONE 1
  2330. #define TC956X_TWO 2
  2331. #define TC956X_THREE 3
  2332. #define TC956X_FOUR 4
  2333. #define TC956X_FIVE 5
  2334. #define TC956X_SIX 6
  2335. #define TC956X_SEVEN 7
  2336. #define TC956X_EIGHT 8
  2337. #define TC956X_NINE 9
  2338. #define TC956X_TEN 10
  2339. #define TC956X_SIXTEEN 16
  2340. #define TC956X_TWENTY_FOUR 24
  2341. #define TC956X_FORTY_EIGHT 48
  2342. #define TC956X_FORTY_NINE 49
  2343. /* EEPROM Mac address mask values */
  2344. #define EEPROM_MAC_ADDR_MASK1 0x000000FF
  2345. #define EEPROM_MAC_ADDR_MASK2 0x0000FF00
  2346. #define EEPROM_MAC_ADDR_MASK3 0x00FF0000
  2347. #define EEPROM_MAC_ADDR_MASK4 0xFF000000
  2348. #define TC956X_MIN_LPI_AUTO_ENTRY_TIMER 0
  2349. #define TC956X_MAX_LPI_AUTO_ENTRY_TIMER 0xFFFF8 /* LPI Entry timer is in the units of 8 micro second granularity. So mask the last 3 bits. */
  2350. extern const struct tc956xmac_desc_ops enh_desc_ops;
  2351. extern const struct tc956xmac_desc_ops ndesc_ops;
  2352. struct mac_device_info;
  2353. extern const struct tc956xmac_hwtimestamp tc956xmac_ptp;
  2354. extern const struct tc956xmac_mode_ops dwmac4_ring_mode_ops;
  2355. struct mac_link {
  2356. u32 speed_mask;
  2357. u32 speed10;
  2358. u32 speed100;
  2359. u32 speed1000;
  2360. u32 speed2500;
  2361. u32 duplex;
  2362. struct {
  2363. u32 speed2500;
  2364. u32 speed5000;
  2365. u32 speed10000;
  2366. } xgmii;
  2367. };
  2368. struct mii_regs {
  2369. unsigned int addr; /* MII Address */
  2370. unsigned int data; /* MII Data */
  2371. unsigned int addr_shift; /* MII address shift */
  2372. unsigned int reg_shift; /* MII reg shift */
  2373. unsigned int addr_mask; /* MII address mask */
  2374. unsigned int reg_mask; /* MII reg mask */
  2375. unsigned int clk_csr_shift;
  2376. unsigned int clk_csr_mask;
  2377. };
  2378. struct mac_device_info {
  2379. const struct tc956xmac_ops *mac;
  2380. const struct tc956xmac_desc_ops *desc;
  2381. const struct tc956xmac_dma_ops *dma;
  2382. const struct tc956xmac_mode_ops *mode;
  2383. const struct tc956xmac_hwtimestamp *ptp;
  2384. const struct tc956xmac_tc_ops *tc;
  2385. const struct tc956x_msi_ops *msi;
  2386. #ifdef TC956X_SRIOV_PF
  2387. const struct mac_rsc_mng_ops *rsc;
  2388. const struct mac_mbx_ops *mbx;
  2389. const struct tc956x_mbx_wrapper_ops *mbx_wrapper;
  2390. #endif
  2391. #ifdef TC956X_SRIOV_VF
  2392. const struct mac_rsc_mng_ops *rsc;
  2393. const struct mac_mbx_ops *mbx;
  2394. const struct tc956xmac_mbx_wrapper_ops *mbx_wrapper;
  2395. #endif
  2396. const struct tc956xmac_mmc_ops *mmc;
  2397. const struct tc956xmac_pma_ops *pma;
  2398. struct mii_regs mii; /* MII register Addresses */
  2399. struct mac_link link;
  2400. void __iomem *pcsr; /* vpointer to device CSRs */
  2401. unsigned int multicast_filter_bins;
  2402. unsigned int unicast_filter_entries;
  2403. unsigned int mcast_bits_log2;
  2404. unsigned int rx_csum;
  2405. unsigned int pcs;
  2406. #ifdef TC956X
  2407. unsigned int xpcs;
  2408. #endif
  2409. unsigned int pmt;
  2410. unsigned int ps;
  2411. };
  2412. struct tc956xmac_rx_routing {
  2413. u32 reg_mask;
  2414. u32 reg_shift;
  2415. };
  2416. int dwmac100_setup(struct tc956xmac_priv *priv);
  2417. int dwmac1000_setup(struct tc956xmac_priv *priv);
  2418. int dwmac4_setup(struct tc956xmac_priv *priv);
  2419. int dwxgmac2_setup(struct tc956xmac_priv *priv);
  2420. #ifdef TC956X_SRIOV_PF
  2421. void tc956xmac_set_mac_addr(void __iomem *ioaddr, u8 addr[6],
  2422. unsigned int high, unsigned int low);
  2423. void tc956xmac_get_mac_addr(void __iomem *ioaddr, unsigned char *addr,
  2424. unsigned int high, unsigned int low);
  2425. void tc956xmac_set_mac(struct tc956xmac_priv *priv, void __iomem *ioaddr, bool enable);
  2426. int tc956x_add_mac_addr(struct net_device *dev, const unsigned char *mac);
  2427. #elif defined TC956X_SRIOV_VF
  2428. void tc956xmac_vf_set_mac_addr(void __iomem *ioaddr, u8 addr[6],
  2429. unsigned int high, unsigned int low);
  2430. void tc956xmac_vf_get_mac_addr(void __iomem *ioaddr, unsigned char *addr,
  2431. unsigned int high, unsigned int low);
  2432. void tc956xmac_set_mac(struct tc956xmac_priv *priv, void __iomem *ioaddr, bool enable);
  2433. #endif
  2434. void tc956xmac_dwmac4_set_mac_addr(void __iomem *ioaddr, u8 addr[6],
  2435. unsigned int high, unsigned int low);
  2436. void tc956xmac_dwmac4_get_mac_addr(void __iomem *ioaddr, unsigned char *addr,
  2437. unsigned int high, unsigned int low);
  2438. void tc956xmac_dwmac4_set_mac(struct tc956xmac_priv *priv, void __iomem *ioaddr, bool enable);
  2439. void dwmac_dma_flush_tx_fifo(void __iomem *ioaddr);
  2440. extern const struct tc956xmac_mode_ops ring_mode_ops;
  2441. extern const struct tc956xmac_mode_ops chain_mode_ops;
  2442. extern const struct tc956xmac_desc_ops dwmac4_desc_ops;
  2443. #ifdef TC956X_SRIOV_VF
  2444. void tc956xmac_mailbox_service_event_schedule(struct tc956xmac_priv *priv);
  2445. #endif
  2446. #endif /* __COMMON_H__ */