lpc_eth.c 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608
  1. /*
  2. * drivers/net/ethernet/nxp/lpc_eth.c
  3. *
  4. * Author: Kevin Wells <kevin.wells@nxp.com>
  5. *
  6. * Copyright (C) 2010 NXP Semiconductors
  7. * Copyright (C) 2012 Roland Stigge <stigge@antcom.de>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. */
  19. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  20. #include <linux/module.h>
  21. #include <linux/kernel.h>
  22. #include <linux/sched.h>
  23. #include <linux/slab.h>
  24. #include <linux/delay.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/errno.h>
  27. #include <linux/ioport.h>
  28. #include <linux/crc32.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/spinlock.h>
  31. #include <linux/ethtool.h>
  32. #include <linux/mii.h>
  33. #include <linux/clk.h>
  34. #include <linux/workqueue.h>
  35. #include <linux/netdevice.h>
  36. #include <linux/etherdevice.h>
  37. #include <linux/skbuff.h>
  38. #include <linux/phy.h>
  39. #include <linux/dma-mapping.h>
  40. #include <linux/of.h>
  41. #include <linux/of_net.h>
  42. #include <linux/types.h>
  43. #include <linux/io.h>
  44. #include <mach/board.h>
  45. #include <mach/platform.h>
  46. #include <mach/hardware.h>
  47. #define MODNAME "lpc-eth"
  48. #define DRV_VERSION "1.00"
  49. #define ENET_MAXF_SIZE 1536
  50. #define ENET_RX_DESC 48
  51. #define ENET_TX_DESC 16
  52. #define NAPI_WEIGHT 16
  53. /*
  54. * Ethernet MAC controller Register offsets
  55. */
  56. #define LPC_ENET_MAC1(x) (x + 0x000)
  57. #define LPC_ENET_MAC2(x) (x + 0x004)
  58. #define LPC_ENET_IPGT(x) (x + 0x008)
  59. #define LPC_ENET_IPGR(x) (x + 0x00C)
  60. #define LPC_ENET_CLRT(x) (x + 0x010)
  61. #define LPC_ENET_MAXF(x) (x + 0x014)
  62. #define LPC_ENET_SUPP(x) (x + 0x018)
  63. #define LPC_ENET_TEST(x) (x + 0x01C)
  64. #define LPC_ENET_MCFG(x) (x + 0x020)
  65. #define LPC_ENET_MCMD(x) (x + 0x024)
  66. #define LPC_ENET_MADR(x) (x + 0x028)
  67. #define LPC_ENET_MWTD(x) (x + 0x02C)
  68. #define LPC_ENET_MRDD(x) (x + 0x030)
  69. #define LPC_ENET_MIND(x) (x + 0x034)
  70. #define LPC_ENET_SA0(x) (x + 0x040)
  71. #define LPC_ENET_SA1(x) (x + 0x044)
  72. #define LPC_ENET_SA2(x) (x + 0x048)
  73. #define LPC_ENET_COMMAND(x) (x + 0x100)
  74. #define LPC_ENET_STATUS(x) (x + 0x104)
  75. #define LPC_ENET_RXDESCRIPTOR(x) (x + 0x108)
  76. #define LPC_ENET_RXSTATUS(x) (x + 0x10C)
  77. #define LPC_ENET_RXDESCRIPTORNUMBER(x) (x + 0x110)
  78. #define LPC_ENET_RXPRODUCEINDEX(x) (x + 0x114)
  79. #define LPC_ENET_RXCONSUMEINDEX(x) (x + 0x118)
  80. #define LPC_ENET_TXDESCRIPTOR(x) (x + 0x11C)
  81. #define LPC_ENET_TXSTATUS(x) (x + 0x120)
  82. #define LPC_ENET_TXDESCRIPTORNUMBER(x) (x + 0x124)
  83. #define LPC_ENET_TXPRODUCEINDEX(x) (x + 0x128)
  84. #define LPC_ENET_TXCONSUMEINDEX(x) (x + 0x12C)
  85. #define LPC_ENET_TSV0(x) (x + 0x158)
  86. #define LPC_ENET_TSV1(x) (x + 0x15C)
  87. #define LPC_ENET_RSV(x) (x + 0x160)
  88. #define LPC_ENET_FLOWCONTROLCOUNTER(x) (x + 0x170)
  89. #define LPC_ENET_FLOWCONTROLSTATUS(x) (x + 0x174)
  90. #define LPC_ENET_RXFILTER_CTRL(x) (x + 0x200)
  91. #define LPC_ENET_RXFILTERWOLSTATUS(x) (x + 0x204)
  92. #define LPC_ENET_RXFILTERWOLCLEAR(x) (x + 0x208)
  93. #define LPC_ENET_HASHFILTERL(x) (x + 0x210)
  94. #define LPC_ENET_HASHFILTERH(x) (x + 0x214)
  95. #define LPC_ENET_INTSTATUS(x) (x + 0xFE0)
  96. #define LPC_ENET_INTENABLE(x) (x + 0xFE4)
  97. #define LPC_ENET_INTCLEAR(x) (x + 0xFE8)
  98. #define LPC_ENET_INTSET(x) (x + 0xFEC)
  99. #define LPC_ENET_POWERDOWN(x) (x + 0xFF4)
  100. /*
  101. * mac1 register definitions
  102. */
  103. #define LPC_MAC1_RECV_ENABLE (1 << 0)
  104. #define LPC_MAC1_PASS_ALL_RX_FRAMES (1 << 1)
  105. #define LPC_MAC1_RX_FLOW_CONTROL (1 << 2)
  106. #define LPC_MAC1_TX_FLOW_CONTROL (1 << 3)
  107. #define LPC_MAC1_LOOPBACK (1 << 4)
  108. #define LPC_MAC1_RESET_TX (1 << 8)
  109. #define LPC_MAC1_RESET_MCS_TX (1 << 9)
  110. #define LPC_MAC1_RESET_RX (1 << 10)
  111. #define LPC_MAC1_RESET_MCS_RX (1 << 11)
  112. #define LPC_MAC1_SIMULATION_RESET (1 << 14)
  113. #define LPC_MAC1_SOFT_RESET (1 << 15)
  114. /*
  115. * mac2 register definitions
  116. */
  117. #define LPC_MAC2_FULL_DUPLEX (1 << 0)
  118. #define LPC_MAC2_FRAME_LENGTH_CHECKING (1 << 1)
  119. #define LPC_MAC2_HUGH_LENGTH_CHECKING (1 << 2)
  120. #define LPC_MAC2_DELAYED_CRC (1 << 3)
  121. #define LPC_MAC2_CRC_ENABLE (1 << 4)
  122. #define LPC_MAC2_PAD_CRC_ENABLE (1 << 5)
  123. #define LPC_MAC2_VLAN_PAD_ENABLE (1 << 6)
  124. #define LPC_MAC2_AUTO_DETECT_PAD_ENABLE (1 << 7)
  125. #define LPC_MAC2_PURE_PREAMBLE_ENFORCEMENT (1 << 8)
  126. #define LPC_MAC2_LONG_PREAMBLE_ENFORCEMENT (1 << 9)
  127. #define LPC_MAC2_NO_BACKOFF (1 << 12)
  128. #define LPC_MAC2_BACK_PRESSURE (1 << 13)
  129. #define LPC_MAC2_EXCESS_DEFER (1 << 14)
  130. /*
  131. * ipgt register definitions
  132. */
  133. #define LPC_IPGT_LOAD(n) ((n) & 0x7F)
  134. /*
  135. * ipgr register definitions
  136. */
  137. #define LPC_IPGR_LOAD_PART2(n) ((n) & 0x7F)
  138. #define LPC_IPGR_LOAD_PART1(n) (((n) & 0x7F) << 8)
  139. /*
  140. * clrt register definitions
  141. */
  142. #define LPC_CLRT_LOAD_RETRY_MAX(n) ((n) & 0xF)
  143. #define LPC_CLRT_LOAD_COLLISION_WINDOW(n) (((n) & 0x3F) << 8)
  144. /*
  145. * maxf register definitions
  146. */
  147. #define LPC_MAXF_LOAD_MAX_FRAME_LEN(n) ((n) & 0xFFFF)
  148. /*
  149. * supp register definitions
  150. */
  151. #define LPC_SUPP_SPEED (1 << 8)
  152. #define LPC_SUPP_RESET_RMII (1 << 11)
  153. /*
  154. * test register definitions
  155. */
  156. #define LPC_TEST_SHORTCUT_PAUSE_QUANTA (1 << 0)
  157. #define LPC_TEST_PAUSE (1 << 1)
  158. #define LPC_TEST_BACKPRESSURE (1 << 2)
  159. /*
  160. * mcfg register definitions
  161. */
  162. #define LPC_MCFG_SCAN_INCREMENT (1 << 0)
  163. #define LPC_MCFG_SUPPRESS_PREAMBLE (1 << 1)
  164. #define LPC_MCFG_CLOCK_SELECT(n) (((n) & 0x7) << 2)
  165. #define LPC_MCFG_CLOCK_HOST_DIV_4 0
  166. #define LPC_MCFG_CLOCK_HOST_DIV_6 2
  167. #define LPC_MCFG_CLOCK_HOST_DIV_8 3
  168. #define LPC_MCFG_CLOCK_HOST_DIV_10 4
  169. #define LPC_MCFG_CLOCK_HOST_DIV_14 5
  170. #define LPC_MCFG_CLOCK_HOST_DIV_20 6
  171. #define LPC_MCFG_CLOCK_HOST_DIV_28 7
  172. #define LPC_MCFG_RESET_MII_MGMT (1 << 15)
  173. /*
  174. * mcmd register definitions
  175. */
  176. #define LPC_MCMD_READ (1 << 0)
  177. #define LPC_MCMD_SCAN (1 << 1)
  178. /*
  179. * madr register definitions
  180. */
  181. #define LPC_MADR_REGISTER_ADDRESS(n) ((n) & 0x1F)
  182. #define LPC_MADR_PHY_0ADDRESS(n) (((n) & 0x1F) << 8)
  183. /*
  184. * mwtd register definitions
  185. */
  186. #define LPC_MWDT_WRITE(n) ((n) & 0xFFFF)
  187. /*
  188. * mrdd register definitions
  189. */
  190. #define LPC_MRDD_READ_MASK 0xFFFF
  191. /*
  192. * mind register definitions
  193. */
  194. #define LPC_MIND_BUSY (1 << 0)
  195. #define LPC_MIND_SCANNING (1 << 1)
  196. #define LPC_MIND_NOT_VALID (1 << 2)
  197. #define LPC_MIND_MII_LINK_FAIL (1 << 3)
  198. /*
  199. * command register definitions
  200. */
  201. #define LPC_COMMAND_RXENABLE (1 << 0)
  202. #define LPC_COMMAND_TXENABLE (1 << 1)
  203. #define LPC_COMMAND_REG_RESET (1 << 3)
  204. #define LPC_COMMAND_TXRESET (1 << 4)
  205. #define LPC_COMMAND_RXRESET (1 << 5)
  206. #define LPC_COMMAND_PASSRUNTFRAME (1 << 6)
  207. #define LPC_COMMAND_PASSRXFILTER (1 << 7)
  208. #define LPC_COMMAND_TXFLOWCONTROL (1 << 8)
  209. #define LPC_COMMAND_RMII (1 << 9)
  210. #define LPC_COMMAND_FULLDUPLEX (1 << 10)
  211. /*
  212. * status register definitions
  213. */
  214. #define LPC_STATUS_RXACTIVE (1 << 0)
  215. #define LPC_STATUS_TXACTIVE (1 << 1)
  216. /*
  217. * tsv0 register definitions
  218. */
  219. #define LPC_TSV0_CRC_ERROR (1 << 0)
  220. #define LPC_TSV0_LENGTH_CHECK_ERROR (1 << 1)
  221. #define LPC_TSV0_LENGTH_OUT_OF_RANGE (1 << 2)
  222. #define LPC_TSV0_DONE (1 << 3)
  223. #define LPC_TSV0_MULTICAST (1 << 4)
  224. #define LPC_TSV0_BROADCAST (1 << 5)
  225. #define LPC_TSV0_PACKET_DEFER (1 << 6)
  226. #define LPC_TSV0_ESCESSIVE_DEFER (1 << 7)
  227. #define LPC_TSV0_ESCESSIVE_COLLISION (1 << 8)
  228. #define LPC_TSV0_LATE_COLLISION (1 << 9)
  229. #define LPC_TSV0_GIANT (1 << 10)
  230. #define LPC_TSV0_UNDERRUN (1 << 11)
  231. #define LPC_TSV0_TOTAL_BYTES(n) (((n) >> 12) & 0xFFFF)
  232. #define LPC_TSV0_CONTROL_FRAME (1 << 28)
  233. #define LPC_TSV0_PAUSE (1 << 29)
  234. #define LPC_TSV0_BACKPRESSURE (1 << 30)
  235. #define LPC_TSV0_VLAN (1 << 31)
  236. /*
  237. * tsv1 register definitions
  238. */
  239. #define LPC_TSV1_TRANSMIT_BYTE_COUNT(n) ((n) & 0xFFFF)
  240. #define LPC_TSV1_COLLISION_COUNT(n) (((n) >> 16) & 0xF)
  241. /*
  242. * rsv register definitions
  243. */
  244. #define LPC_RSV_RECEIVED_BYTE_COUNT(n) ((n) & 0xFFFF)
  245. #define LPC_RSV_RXDV_EVENT_IGNORED (1 << 16)
  246. #define LPC_RSV_RXDV_EVENT_PREVIOUSLY_SEEN (1 << 17)
  247. #define LPC_RSV_CARRIER_EVNT_PREVIOUS_SEEN (1 << 18)
  248. #define LPC_RSV_RECEIVE_CODE_VIOLATION (1 << 19)
  249. #define LPC_RSV_CRC_ERROR (1 << 20)
  250. #define LPC_RSV_LENGTH_CHECK_ERROR (1 << 21)
  251. #define LPC_RSV_LENGTH_OUT_OF_RANGE (1 << 22)
  252. #define LPC_RSV_RECEIVE_OK (1 << 23)
  253. #define LPC_RSV_MULTICAST (1 << 24)
  254. #define LPC_RSV_BROADCAST (1 << 25)
  255. #define LPC_RSV_DRIBBLE_NIBBLE (1 << 26)
  256. #define LPC_RSV_CONTROL_FRAME (1 << 27)
  257. #define LPC_RSV_PAUSE (1 << 28)
  258. #define LPC_RSV_UNSUPPORTED_OPCODE (1 << 29)
  259. #define LPC_RSV_VLAN (1 << 30)
  260. /*
  261. * flowcontrolcounter register definitions
  262. */
  263. #define LPC_FCCR_MIRRORCOUNTER(n) ((n) & 0xFFFF)
  264. #define LPC_FCCR_PAUSETIMER(n) (((n) >> 16) & 0xFFFF)
  265. /*
  266. * flowcontrolstatus register definitions
  267. */
  268. #define LPC_FCCR_MIRRORCOUNTERCURRENT(n) ((n) & 0xFFFF)
  269. /*
  270. * rxfliterctrl, rxfilterwolstatus, and rxfilterwolclear shared
  271. * register definitions
  272. */
  273. #define LPC_RXFLTRW_ACCEPTUNICAST (1 << 0)
  274. #define LPC_RXFLTRW_ACCEPTUBROADCAST (1 << 1)
  275. #define LPC_RXFLTRW_ACCEPTUMULTICAST (1 << 2)
  276. #define LPC_RXFLTRW_ACCEPTUNICASTHASH (1 << 3)
  277. #define LPC_RXFLTRW_ACCEPTUMULTICASTHASH (1 << 4)
  278. #define LPC_RXFLTRW_ACCEPTPERFECT (1 << 5)
  279. /*
  280. * rxfliterctrl register definitions
  281. */
  282. #define LPC_RXFLTRWSTS_MAGICPACKETENWOL (1 << 12)
  283. #define LPC_RXFLTRWSTS_RXFILTERENWOL (1 << 13)
  284. /*
  285. * rxfilterwolstatus/rxfilterwolclear register definitions
  286. */
  287. #define LPC_RXFLTRWSTS_RXFILTERWOL (1 << 7)
  288. #define LPC_RXFLTRWSTS_MAGICPACKETWOL (1 << 8)
  289. /*
  290. * intstatus, intenable, intclear, and Intset shared register
  291. * definitions
  292. */
  293. #define LPC_MACINT_RXOVERRUNINTEN (1 << 0)
  294. #define LPC_MACINT_RXERRORONINT (1 << 1)
  295. #define LPC_MACINT_RXFINISHEDINTEN (1 << 2)
  296. #define LPC_MACINT_RXDONEINTEN (1 << 3)
  297. #define LPC_MACINT_TXUNDERRUNINTEN (1 << 4)
  298. #define LPC_MACINT_TXERRORINTEN (1 << 5)
  299. #define LPC_MACINT_TXFINISHEDINTEN (1 << 6)
  300. #define LPC_MACINT_TXDONEINTEN (1 << 7)
  301. #define LPC_MACINT_SOFTINTEN (1 << 12)
  302. #define LPC_MACINT_WAKEUPINTEN (1 << 13)
  303. /*
  304. * powerdown register definitions
  305. */
  306. #define LPC_POWERDOWN_MACAHB (1 << 31)
  307. static phy_interface_t lpc_phy_interface_mode(struct device *dev)
  308. {
  309. if (dev && dev->of_node) {
  310. const char *mode = of_get_property(dev->of_node,
  311. "phy-mode", NULL);
  312. if (mode && !strcmp(mode, "mii"))
  313. return PHY_INTERFACE_MODE_MII;
  314. }
  315. return PHY_INTERFACE_MODE_RMII;
  316. }
  317. static bool use_iram_for_net(struct device *dev)
  318. {
  319. if (dev && dev->of_node)
  320. return of_property_read_bool(dev->of_node, "use-iram");
  321. return false;
  322. }
  323. /* Receive Status information word */
  324. #define RXSTATUS_SIZE 0x000007FF
  325. #define RXSTATUS_CONTROL (1 << 18)
  326. #define RXSTATUS_VLAN (1 << 19)
  327. #define RXSTATUS_FILTER (1 << 20)
  328. #define RXSTATUS_MULTICAST (1 << 21)
  329. #define RXSTATUS_BROADCAST (1 << 22)
  330. #define RXSTATUS_CRC (1 << 23)
  331. #define RXSTATUS_SYMBOL (1 << 24)
  332. #define RXSTATUS_LENGTH (1 << 25)
  333. #define RXSTATUS_RANGE (1 << 26)
  334. #define RXSTATUS_ALIGN (1 << 27)
  335. #define RXSTATUS_OVERRUN (1 << 28)
  336. #define RXSTATUS_NODESC (1 << 29)
  337. #define RXSTATUS_LAST (1 << 30)
  338. #define RXSTATUS_ERROR (1 << 31)
  339. #define RXSTATUS_STATUS_ERROR \
  340. (RXSTATUS_NODESC | RXSTATUS_OVERRUN | RXSTATUS_ALIGN | \
  341. RXSTATUS_RANGE | RXSTATUS_LENGTH | RXSTATUS_SYMBOL | RXSTATUS_CRC)
  342. /* Receive Descriptor control word */
  343. #define RXDESC_CONTROL_SIZE 0x000007FF
  344. #define RXDESC_CONTROL_INT (1 << 31)
  345. /* Transmit Status information word */
  346. #define TXSTATUS_COLLISIONS_GET(x) (((x) >> 21) & 0xF)
  347. #define TXSTATUS_DEFER (1 << 25)
  348. #define TXSTATUS_EXCESSDEFER (1 << 26)
  349. #define TXSTATUS_EXCESSCOLL (1 << 27)
  350. #define TXSTATUS_LATECOLL (1 << 28)
  351. #define TXSTATUS_UNDERRUN (1 << 29)
  352. #define TXSTATUS_NODESC (1 << 30)
  353. #define TXSTATUS_ERROR (1 << 31)
  354. /* Transmit Descriptor control word */
  355. #define TXDESC_CONTROL_SIZE 0x000007FF
  356. #define TXDESC_CONTROL_OVERRIDE (1 << 26)
  357. #define TXDESC_CONTROL_HUGE (1 << 27)
  358. #define TXDESC_CONTROL_PAD (1 << 28)
  359. #define TXDESC_CONTROL_CRC (1 << 29)
  360. #define TXDESC_CONTROL_LAST (1 << 30)
  361. #define TXDESC_CONTROL_INT (1 << 31)
  362. /*
  363. * Structure of a TX/RX descriptors and RX status
  364. */
  365. struct txrx_desc_t {
  366. __le32 packet;
  367. __le32 control;
  368. };
  369. struct rx_status_t {
  370. __le32 statusinfo;
  371. __le32 statushashcrc;
  372. };
  373. /*
  374. * Device driver data structure
  375. */
  376. struct netdata_local {
  377. struct platform_device *pdev;
  378. struct net_device *ndev;
  379. spinlock_t lock;
  380. void __iomem *net_base;
  381. u32 msg_enable;
  382. unsigned int skblen[ENET_TX_DESC];
  383. unsigned int last_tx_idx;
  384. unsigned int num_used_tx_buffs;
  385. struct mii_bus *mii_bus;
  386. struct phy_device *phy_dev;
  387. struct clk *clk;
  388. dma_addr_t dma_buff_base_p;
  389. void *dma_buff_base_v;
  390. size_t dma_buff_size;
  391. struct txrx_desc_t *tx_desc_v;
  392. u32 *tx_stat_v;
  393. void *tx_buff_v;
  394. struct txrx_desc_t *rx_desc_v;
  395. struct rx_status_t *rx_stat_v;
  396. void *rx_buff_v;
  397. int link;
  398. int speed;
  399. int duplex;
  400. struct napi_struct napi;
  401. };
  402. /*
  403. * MAC support functions
  404. */
  405. static void __lpc_set_mac(struct netdata_local *pldat, u8 *mac)
  406. {
  407. u32 tmp;
  408. /* Set station address */
  409. tmp = mac[0] | ((u32)mac[1] << 8);
  410. writel(tmp, LPC_ENET_SA2(pldat->net_base));
  411. tmp = mac[2] | ((u32)mac[3] << 8);
  412. writel(tmp, LPC_ENET_SA1(pldat->net_base));
  413. tmp = mac[4] | ((u32)mac[5] << 8);
  414. writel(tmp, LPC_ENET_SA0(pldat->net_base));
  415. netdev_dbg(pldat->ndev, "Ethernet MAC address %pM\n", mac);
  416. }
  417. static void __lpc_get_mac(struct netdata_local *pldat, u8 *mac)
  418. {
  419. u32 tmp;
  420. /* Get station address */
  421. tmp = readl(LPC_ENET_SA2(pldat->net_base));
  422. mac[0] = tmp & 0xFF;
  423. mac[1] = tmp >> 8;
  424. tmp = readl(LPC_ENET_SA1(pldat->net_base));
  425. mac[2] = tmp & 0xFF;
  426. mac[3] = tmp >> 8;
  427. tmp = readl(LPC_ENET_SA0(pldat->net_base));
  428. mac[4] = tmp & 0xFF;
  429. mac[5] = tmp >> 8;
  430. }
  431. static void __lpc_eth_clock_enable(struct netdata_local *pldat, bool enable)
  432. {
  433. if (enable)
  434. clk_prepare_enable(pldat->clk);
  435. else
  436. clk_disable_unprepare(pldat->clk);
  437. }
  438. static void __lpc_params_setup(struct netdata_local *pldat)
  439. {
  440. u32 tmp;
  441. if (pldat->duplex == DUPLEX_FULL) {
  442. tmp = readl(LPC_ENET_MAC2(pldat->net_base));
  443. tmp |= LPC_MAC2_FULL_DUPLEX;
  444. writel(tmp, LPC_ENET_MAC2(pldat->net_base));
  445. tmp = readl(LPC_ENET_COMMAND(pldat->net_base));
  446. tmp |= LPC_COMMAND_FULLDUPLEX;
  447. writel(tmp, LPC_ENET_COMMAND(pldat->net_base));
  448. writel(LPC_IPGT_LOAD(0x15), LPC_ENET_IPGT(pldat->net_base));
  449. } else {
  450. tmp = readl(LPC_ENET_MAC2(pldat->net_base));
  451. tmp &= ~LPC_MAC2_FULL_DUPLEX;
  452. writel(tmp, LPC_ENET_MAC2(pldat->net_base));
  453. tmp = readl(LPC_ENET_COMMAND(pldat->net_base));
  454. tmp &= ~LPC_COMMAND_FULLDUPLEX;
  455. writel(tmp, LPC_ENET_COMMAND(pldat->net_base));
  456. writel(LPC_IPGT_LOAD(0x12), LPC_ENET_IPGT(pldat->net_base));
  457. }
  458. if (pldat->speed == SPEED_100)
  459. writel(LPC_SUPP_SPEED, LPC_ENET_SUPP(pldat->net_base));
  460. else
  461. writel(0, LPC_ENET_SUPP(pldat->net_base));
  462. }
  463. static void __lpc_eth_reset(struct netdata_local *pldat)
  464. {
  465. /* Reset all MAC logic */
  466. writel((LPC_MAC1_RESET_TX | LPC_MAC1_RESET_MCS_TX | LPC_MAC1_RESET_RX |
  467. LPC_MAC1_RESET_MCS_RX | LPC_MAC1_SIMULATION_RESET |
  468. LPC_MAC1_SOFT_RESET), LPC_ENET_MAC1(pldat->net_base));
  469. writel((LPC_COMMAND_REG_RESET | LPC_COMMAND_TXRESET |
  470. LPC_COMMAND_RXRESET), LPC_ENET_COMMAND(pldat->net_base));
  471. }
  472. static int __lpc_mii_mngt_reset(struct netdata_local *pldat)
  473. {
  474. /* Reset MII management hardware */
  475. writel(LPC_MCFG_RESET_MII_MGMT, LPC_ENET_MCFG(pldat->net_base));
  476. /* Setup MII clock to slowest rate with a /28 divider */
  477. writel(LPC_MCFG_CLOCK_SELECT(LPC_MCFG_CLOCK_HOST_DIV_28),
  478. LPC_ENET_MCFG(pldat->net_base));
  479. return 0;
  480. }
  481. static inline phys_addr_t __va_to_pa(void *addr, struct netdata_local *pldat)
  482. {
  483. phys_addr_t phaddr;
  484. phaddr = addr - pldat->dma_buff_base_v;
  485. phaddr += pldat->dma_buff_base_p;
  486. return phaddr;
  487. }
  488. static void lpc_eth_enable_int(void __iomem *regbase)
  489. {
  490. writel((LPC_MACINT_RXDONEINTEN | LPC_MACINT_TXDONEINTEN),
  491. LPC_ENET_INTENABLE(regbase));
  492. }
  493. static void lpc_eth_disable_int(void __iomem *regbase)
  494. {
  495. writel(0, LPC_ENET_INTENABLE(regbase));
  496. }
  497. /* Setup TX/RX descriptors */
  498. static void __lpc_txrx_desc_setup(struct netdata_local *pldat)
  499. {
  500. u32 *ptxstat;
  501. void *tbuff;
  502. int i;
  503. struct txrx_desc_t *ptxrxdesc;
  504. struct rx_status_t *prxstat;
  505. tbuff = PTR_ALIGN(pldat->dma_buff_base_v, 16);
  506. /* Setup TX descriptors, status, and buffers */
  507. pldat->tx_desc_v = tbuff;
  508. tbuff += sizeof(struct txrx_desc_t) * ENET_TX_DESC;
  509. pldat->tx_stat_v = tbuff;
  510. tbuff += sizeof(u32) * ENET_TX_DESC;
  511. tbuff = PTR_ALIGN(tbuff, 16);
  512. pldat->tx_buff_v = tbuff;
  513. tbuff += ENET_MAXF_SIZE * ENET_TX_DESC;
  514. /* Setup RX descriptors, status, and buffers */
  515. pldat->rx_desc_v = tbuff;
  516. tbuff += sizeof(struct txrx_desc_t) * ENET_RX_DESC;
  517. tbuff = PTR_ALIGN(tbuff, 16);
  518. pldat->rx_stat_v = tbuff;
  519. tbuff += sizeof(struct rx_status_t) * ENET_RX_DESC;
  520. tbuff = PTR_ALIGN(tbuff, 16);
  521. pldat->rx_buff_v = tbuff;
  522. tbuff += ENET_MAXF_SIZE * ENET_RX_DESC;
  523. /* Map the TX descriptors to the TX buffers in hardware */
  524. for (i = 0; i < ENET_TX_DESC; i++) {
  525. ptxstat = &pldat->tx_stat_v[i];
  526. ptxrxdesc = &pldat->tx_desc_v[i];
  527. ptxrxdesc->packet = __va_to_pa(
  528. pldat->tx_buff_v + i * ENET_MAXF_SIZE, pldat);
  529. ptxrxdesc->control = 0;
  530. *ptxstat = 0;
  531. }
  532. /* Map the RX descriptors to the RX buffers in hardware */
  533. for (i = 0; i < ENET_RX_DESC; i++) {
  534. prxstat = &pldat->rx_stat_v[i];
  535. ptxrxdesc = &pldat->rx_desc_v[i];
  536. ptxrxdesc->packet = __va_to_pa(
  537. pldat->rx_buff_v + i * ENET_MAXF_SIZE, pldat);
  538. ptxrxdesc->control = RXDESC_CONTROL_INT | (ENET_MAXF_SIZE - 1);
  539. prxstat->statusinfo = 0;
  540. prxstat->statushashcrc = 0;
  541. }
  542. /* Setup base addresses in hardware to point to buffers and
  543. * descriptors
  544. */
  545. writel((ENET_TX_DESC - 1),
  546. LPC_ENET_TXDESCRIPTORNUMBER(pldat->net_base));
  547. writel(__va_to_pa(pldat->tx_desc_v, pldat),
  548. LPC_ENET_TXDESCRIPTOR(pldat->net_base));
  549. writel(__va_to_pa(pldat->tx_stat_v, pldat),
  550. LPC_ENET_TXSTATUS(pldat->net_base));
  551. writel((ENET_RX_DESC - 1),
  552. LPC_ENET_RXDESCRIPTORNUMBER(pldat->net_base));
  553. writel(__va_to_pa(pldat->rx_desc_v, pldat),
  554. LPC_ENET_RXDESCRIPTOR(pldat->net_base));
  555. writel(__va_to_pa(pldat->rx_stat_v, pldat),
  556. LPC_ENET_RXSTATUS(pldat->net_base));
  557. }
  558. static void __lpc_eth_init(struct netdata_local *pldat)
  559. {
  560. u32 tmp;
  561. /* Disable controller and reset */
  562. tmp = readl(LPC_ENET_COMMAND(pldat->net_base));
  563. tmp &= ~LPC_COMMAND_RXENABLE | LPC_COMMAND_TXENABLE;
  564. writel(tmp, LPC_ENET_COMMAND(pldat->net_base));
  565. tmp = readl(LPC_ENET_MAC1(pldat->net_base));
  566. tmp &= ~LPC_MAC1_RECV_ENABLE;
  567. writel(tmp, LPC_ENET_MAC1(pldat->net_base));
  568. /* Initial MAC setup */
  569. writel(LPC_MAC1_PASS_ALL_RX_FRAMES, LPC_ENET_MAC1(pldat->net_base));
  570. writel((LPC_MAC2_PAD_CRC_ENABLE | LPC_MAC2_CRC_ENABLE),
  571. LPC_ENET_MAC2(pldat->net_base));
  572. writel(ENET_MAXF_SIZE, LPC_ENET_MAXF(pldat->net_base));
  573. /* Collision window, gap */
  574. writel((LPC_CLRT_LOAD_RETRY_MAX(0xF) |
  575. LPC_CLRT_LOAD_COLLISION_WINDOW(0x37)),
  576. LPC_ENET_CLRT(pldat->net_base));
  577. writel(LPC_IPGR_LOAD_PART2(0x12), LPC_ENET_IPGR(pldat->net_base));
  578. if (lpc_phy_interface_mode(&pldat->pdev->dev) == PHY_INTERFACE_MODE_MII)
  579. writel(LPC_COMMAND_PASSRUNTFRAME,
  580. LPC_ENET_COMMAND(pldat->net_base));
  581. else {
  582. writel((LPC_COMMAND_PASSRUNTFRAME | LPC_COMMAND_RMII),
  583. LPC_ENET_COMMAND(pldat->net_base));
  584. writel(LPC_SUPP_RESET_RMII, LPC_ENET_SUPP(pldat->net_base));
  585. }
  586. __lpc_params_setup(pldat);
  587. /* Setup TX and RX descriptors */
  588. __lpc_txrx_desc_setup(pldat);
  589. /* Setup packet filtering */
  590. writel((LPC_RXFLTRW_ACCEPTUBROADCAST | LPC_RXFLTRW_ACCEPTPERFECT),
  591. LPC_ENET_RXFILTER_CTRL(pldat->net_base));
  592. /* Get the next TX buffer output index */
  593. pldat->num_used_tx_buffs = 0;
  594. pldat->last_tx_idx =
  595. readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base));
  596. /* Clear and enable interrupts */
  597. writel(0xFFFF, LPC_ENET_INTCLEAR(pldat->net_base));
  598. smp_wmb();
  599. lpc_eth_enable_int(pldat->net_base);
  600. /* Enable controller */
  601. tmp = readl(LPC_ENET_COMMAND(pldat->net_base));
  602. tmp |= LPC_COMMAND_RXENABLE | LPC_COMMAND_TXENABLE;
  603. writel(tmp, LPC_ENET_COMMAND(pldat->net_base));
  604. tmp = readl(LPC_ENET_MAC1(pldat->net_base));
  605. tmp |= LPC_MAC1_RECV_ENABLE;
  606. writel(tmp, LPC_ENET_MAC1(pldat->net_base));
  607. }
  608. static void __lpc_eth_shutdown(struct netdata_local *pldat)
  609. {
  610. /* Reset ethernet and power down PHY */
  611. __lpc_eth_reset(pldat);
  612. writel(0, LPC_ENET_MAC1(pldat->net_base));
  613. writel(0, LPC_ENET_MAC2(pldat->net_base));
  614. }
  615. /*
  616. * MAC<--->PHY support functions
  617. */
  618. static int lpc_mdio_read(struct mii_bus *bus, int phy_id, int phyreg)
  619. {
  620. struct netdata_local *pldat = bus->priv;
  621. unsigned long timeout = jiffies + msecs_to_jiffies(100);
  622. int lps;
  623. writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base));
  624. writel(LPC_MCMD_READ, LPC_ENET_MCMD(pldat->net_base));
  625. /* Wait for unbusy status */
  626. while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) {
  627. if (time_after(jiffies, timeout))
  628. return -EIO;
  629. cpu_relax();
  630. }
  631. lps = readl(LPC_ENET_MRDD(pldat->net_base));
  632. writel(0, LPC_ENET_MCMD(pldat->net_base));
  633. return lps;
  634. }
  635. static int lpc_mdio_write(struct mii_bus *bus, int phy_id, int phyreg,
  636. u16 phydata)
  637. {
  638. struct netdata_local *pldat = bus->priv;
  639. unsigned long timeout = jiffies + msecs_to_jiffies(100);
  640. writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base));
  641. writel(phydata, LPC_ENET_MWTD(pldat->net_base));
  642. /* Wait for completion */
  643. while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) {
  644. if (time_after(jiffies, timeout))
  645. return -EIO;
  646. cpu_relax();
  647. }
  648. return 0;
  649. }
  650. static int lpc_mdio_reset(struct mii_bus *bus)
  651. {
  652. return __lpc_mii_mngt_reset((struct netdata_local *)bus->priv);
  653. }
  654. static void lpc_handle_link_change(struct net_device *ndev)
  655. {
  656. struct netdata_local *pldat = netdev_priv(ndev);
  657. struct phy_device *phydev = pldat->phy_dev;
  658. unsigned long flags;
  659. bool status_change = false;
  660. spin_lock_irqsave(&pldat->lock, flags);
  661. if (phydev->link) {
  662. if ((pldat->speed != phydev->speed) ||
  663. (pldat->duplex != phydev->duplex)) {
  664. pldat->speed = phydev->speed;
  665. pldat->duplex = phydev->duplex;
  666. status_change = true;
  667. }
  668. }
  669. if (phydev->link != pldat->link) {
  670. if (!phydev->link) {
  671. pldat->speed = 0;
  672. pldat->duplex = -1;
  673. }
  674. pldat->link = phydev->link;
  675. status_change = true;
  676. }
  677. spin_unlock_irqrestore(&pldat->lock, flags);
  678. if (status_change)
  679. __lpc_params_setup(pldat);
  680. }
  681. static int lpc_mii_probe(struct net_device *ndev)
  682. {
  683. struct netdata_local *pldat = netdev_priv(ndev);
  684. struct phy_device *phydev = phy_find_first(pldat->mii_bus);
  685. if (!phydev) {
  686. netdev_err(ndev, "no PHY found\n");
  687. return -ENODEV;
  688. }
  689. /* Attach to the PHY */
  690. if (lpc_phy_interface_mode(&pldat->pdev->dev) == PHY_INTERFACE_MODE_MII)
  691. netdev_info(ndev, "using MII interface\n");
  692. else
  693. netdev_info(ndev, "using RMII interface\n");
  694. phydev = phy_connect(ndev, dev_name(&phydev->dev),
  695. &lpc_handle_link_change,
  696. lpc_phy_interface_mode(&pldat->pdev->dev));
  697. if (IS_ERR(phydev)) {
  698. netdev_err(ndev, "Could not attach to PHY\n");
  699. return PTR_ERR(phydev);
  700. }
  701. /* mask with MAC supported features */
  702. phydev->supported &= PHY_BASIC_FEATURES;
  703. phydev->advertising = phydev->supported;
  704. pldat->link = 0;
  705. pldat->speed = 0;
  706. pldat->duplex = -1;
  707. pldat->phy_dev = phydev;
  708. netdev_info(ndev,
  709. "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
  710. phydev->drv->name, dev_name(&phydev->dev), phydev->irq);
  711. return 0;
  712. }
  713. static int lpc_mii_init(struct netdata_local *pldat)
  714. {
  715. int err = -ENXIO, i;
  716. pldat->mii_bus = mdiobus_alloc();
  717. if (!pldat->mii_bus) {
  718. err = -ENOMEM;
  719. goto err_out;
  720. }
  721. /* Setup MII mode */
  722. if (lpc_phy_interface_mode(&pldat->pdev->dev) == PHY_INTERFACE_MODE_MII)
  723. writel(LPC_COMMAND_PASSRUNTFRAME,
  724. LPC_ENET_COMMAND(pldat->net_base));
  725. else {
  726. writel((LPC_COMMAND_PASSRUNTFRAME | LPC_COMMAND_RMII),
  727. LPC_ENET_COMMAND(pldat->net_base));
  728. writel(LPC_SUPP_RESET_RMII, LPC_ENET_SUPP(pldat->net_base));
  729. }
  730. pldat->mii_bus->name = "lpc_mii_bus";
  731. pldat->mii_bus->read = &lpc_mdio_read;
  732. pldat->mii_bus->write = &lpc_mdio_write;
  733. pldat->mii_bus->reset = &lpc_mdio_reset;
  734. snprintf(pldat->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
  735. pldat->pdev->name, pldat->pdev->id);
  736. pldat->mii_bus->priv = pldat;
  737. pldat->mii_bus->parent = &pldat->pdev->dev;
  738. pldat->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
  739. if (!pldat->mii_bus->irq) {
  740. err = -ENOMEM;
  741. goto err_out_1;
  742. }
  743. for (i = 0; i < PHY_MAX_ADDR; i++)
  744. pldat->mii_bus->irq[i] = PHY_POLL;
  745. platform_set_drvdata(pldat->pdev, pldat->mii_bus);
  746. if (mdiobus_register(pldat->mii_bus))
  747. goto err_out_free_mdio_irq;
  748. if (lpc_mii_probe(pldat->ndev) != 0)
  749. goto err_out_unregister_bus;
  750. return 0;
  751. err_out_unregister_bus:
  752. mdiobus_unregister(pldat->mii_bus);
  753. err_out_free_mdio_irq:
  754. kfree(pldat->mii_bus->irq);
  755. err_out_1:
  756. mdiobus_free(pldat->mii_bus);
  757. err_out:
  758. return err;
  759. }
  760. static void __lpc_handle_xmit(struct net_device *ndev)
  761. {
  762. struct netdata_local *pldat = netdev_priv(ndev);
  763. u32 txcidx, *ptxstat, txstat;
  764. txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base));
  765. while (pldat->last_tx_idx != txcidx) {
  766. unsigned int skblen = pldat->skblen[pldat->last_tx_idx];
  767. /* A buffer is available, get buffer status */
  768. ptxstat = &pldat->tx_stat_v[pldat->last_tx_idx];
  769. txstat = *ptxstat;
  770. /* Next buffer and decrement used buffer counter */
  771. pldat->num_used_tx_buffs--;
  772. pldat->last_tx_idx++;
  773. if (pldat->last_tx_idx >= ENET_TX_DESC)
  774. pldat->last_tx_idx = 0;
  775. /* Update collision counter */
  776. ndev->stats.collisions += TXSTATUS_COLLISIONS_GET(txstat);
  777. /* Any errors occurred? */
  778. if (txstat & TXSTATUS_ERROR) {
  779. if (txstat & TXSTATUS_UNDERRUN) {
  780. /* FIFO underrun */
  781. ndev->stats.tx_fifo_errors++;
  782. }
  783. if (txstat & TXSTATUS_LATECOLL) {
  784. /* Late collision */
  785. ndev->stats.tx_aborted_errors++;
  786. }
  787. if (txstat & TXSTATUS_EXCESSCOLL) {
  788. /* Excessive collision */
  789. ndev->stats.tx_aborted_errors++;
  790. }
  791. if (txstat & TXSTATUS_EXCESSDEFER) {
  792. /* Defer limit */
  793. ndev->stats.tx_aborted_errors++;
  794. }
  795. ndev->stats.tx_errors++;
  796. } else {
  797. /* Update stats */
  798. ndev->stats.tx_packets++;
  799. ndev->stats.tx_bytes += skblen;
  800. }
  801. txcidx = readl(LPC_ENET_TXCONSUMEINDEX(pldat->net_base));
  802. }
  803. if (pldat->num_used_tx_buffs <= ENET_TX_DESC/2) {
  804. if (netif_queue_stopped(ndev))
  805. netif_wake_queue(ndev);
  806. }
  807. }
  808. static int __lpc_handle_recv(struct net_device *ndev, int budget)
  809. {
  810. struct netdata_local *pldat = netdev_priv(ndev);
  811. struct sk_buff *skb;
  812. u32 rxconsidx, len, ethst;
  813. struct rx_status_t *prxstat;
  814. u8 *prdbuf;
  815. int rx_done = 0;
  816. /* Get the current RX buffer indexes */
  817. rxconsidx = readl(LPC_ENET_RXCONSUMEINDEX(pldat->net_base));
  818. while (rx_done < budget && rxconsidx !=
  819. readl(LPC_ENET_RXPRODUCEINDEX(pldat->net_base))) {
  820. /* Get pointer to receive status */
  821. prxstat = &pldat->rx_stat_v[rxconsidx];
  822. len = (prxstat->statusinfo & RXSTATUS_SIZE) + 1;
  823. /* Status error? */
  824. ethst = prxstat->statusinfo;
  825. if ((ethst & (RXSTATUS_ERROR | RXSTATUS_STATUS_ERROR)) ==
  826. (RXSTATUS_ERROR | RXSTATUS_RANGE))
  827. ethst &= ~RXSTATUS_ERROR;
  828. if (ethst & RXSTATUS_ERROR) {
  829. int si = prxstat->statusinfo;
  830. /* Check statuses */
  831. if (si & RXSTATUS_OVERRUN) {
  832. /* Overrun error */
  833. ndev->stats.rx_fifo_errors++;
  834. } else if (si & RXSTATUS_CRC) {
  835. /* CRC error */
  836. ndev->stats.rx_crc_errors++;
  837. } else if (si & RXSTATUS_LENGTH) {
  838. /* Length error */
  839. ndev->stats.rx_length_errors++;
  840. } else if (si & RXSTATUS_ERROR) {
  841. /* Other error */
  842. ndev->stats.rx_length_errors++;
  843. }
  844. ndev->stats.rx_errors++;
  845. } else {
  846. /* Packet is good */
  847. skb = dev_alloc_skb(len);
  848. if (!skb) {
  849. ndev->stats.rx_dropped++;
  850. } else {
  851. prdbuf = skb_put(skb, len);
  852. /* Copy packet from buffer */
  853. memcpy(prdbuf, pldat->rx_buff_v +
  854. rxconsidx * ENET_MAXF_SIZE, len);
  855. /* Pass to upper layer */
  856. skb->protocol = eth_type_trans(skb, ndev);
  857. netif_receive_skb(skb);
  858. ndev->stats.rx_packets++;
  859. ndev->stats.rx_bytes += len;
  860. }
  861. }
  862. /* Increment consume index */
  863. rxconsidx = rxconsidx + 1;
  864. if (rxconsidx >= ENET_RX_DESC)
  865. rxconsidx = 0;
  866. writel(rxconsidx,
  867. LPC_ENET_RXCONSUMEINDEX(pldat->net_base));
  868. rx_done++;
  869. }
  870. return rx_done;
  871. }
  872. static int lpc_eth_poll(struct napi_struct *napi, int budget)
  873. {
  874. struct netdata_local *pldat = container_of(napi,
  875. struct netdata_local, napi);
  876. struct net_device *ndev = pldat->ndev;
  877. int rx_done = 0;
  878. struct netdev_queue *txq = netdev_get_tx_queue(ndev, 0);
  879. __netif_tx_lock(txq, smp_processor_id());
  880. __lpc_handle_xmit(ndev);
  881. __netif_tx_unlock(txq);
  882. rx_done = __lpc_handle_recv(ndev, budget);
  883. if (rx_done < budget) {
  884. napi_complete(napi);
  885. lpc_eth_enable_int(pldat->net_base);
  886. }
  887. return rx_done;
  888. }
  889. static irqreturn_t __lpc_eth_interrupt(int irq, void *dev_id)
  890. {
  891. struct net_device *ndev = dev_id;
  892. struct netdata_local *pldat = netdev_priv(ndev);
  893. u32 tmp;
  894. spin_lock(&pldat->lock);
  895. tmp = readl(LPC_ENET_INTSTATUS(pldat->net_base));
  896. /* Clear interrupts */
  897. writel(tmp, LPC_ENET_INTCLEAR(pldat->net_base));
  898. lpc_eth_disable_int(pldat->net_base);
  899. if (likely(napi_schedule_prep(&pldat->napi)))
  900. __napi_schedule(&pldat->napi);
  901. spin_unlock(&pldat->lock);
  902. return IRQ_HANDLED;
  903. }
  904. static int lpc_eth_close(struct net_device *ndev)
  905. {
  906. unsigned long flags;
  907. struct netdata_local *pldat = netdev_priv(ndev);
  908. if (netif_msg_ifdown(pldat))
  909. dev_dbg(&pldat->pdev->dev, "shutting down %s\n", ndev->name);
  910. napi_disable(&pldat->napi);
  911. netif_stop_queue(ndev);
  912. if (pldat->phy_dev)
  913. phy_stop(pldat->phy_dev);
  914. spin_lock_irqsave(&pldat->lock, flags);
  915. __lpc_eth_reset(pldat);
  916. netif_carrier_off(ndev);
  917. writel(0, LPC_ENET_MAC1(pldat->net_base));
  918. writel(0, LPC_ENET_MAC2(pldat->net_base));
  919. spin_unlock_irqrestore(&pldat->lock, flags);
  920. __lpc_eth_clock_enable(pldat, false);
  921. return 0;
  922. }
  923. static int lpc_eth_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
  924. {
  925. struct netdata_local *pldat = netdev_priv(ndev);
  926. u32 len, txidx;
  927. u32 *ptxstat;
  928. struct txrx_desc_t *ptxrxdesc;
  929. len = skb->len;
  930. spin_lock_irq(&pldat->lock);
  931. if (pldat->num_used_tx_buffs >= (ENET_TX_DESC - 1)) {
  932. /* This function should never be called when there are no
  933. buffers */
  934. netif_stop_queue(ndev);
  935. spin_unlock_irq(&pldat->lock);
  936. WARN(1, "BUG! TX request when no free TX buffers!\n");
  937. return NETDEV_TX_BUSY;
  938. }
  939. /* Get the next TX descriptor index */
  940. txidx = readl(LPC_ENET_TXPRODUCEINDEX(pldat->net_base));
  941. /* Setup control for the transfer */
  942. ptxstat = &pldat->tx_stat_v[txidx];
  943. *ptxstat = 0;
  944. ptxrxdesc = &pldat->tx_desc_v[txidx];
  945. ptxrxdesc->control =
  946. (len - 1) | TXDESC_CONTROL_LAST | TXDESC_CONTROL_INT;
  947. /* Copy data to the DMA buffer */
  948. memcpy(pldat->tx_buff_v + txidx * ENET_MAXF_SIZE, skb->data, len);
  949. /* Save the buffer and increment the buffer counter */
  950. pldat->skblen[txidx] = len;
  951. pldat->num_used_tx_buffs++;
  952. /* Start transmit */
  953. txidx++;
  954. if (txidx >= ENET_TX_DESC)
  955. txidx = 0;
  956. writel(txidx, LPC_ENET_TXPRODUCEINDEX(pldat->net_base));
  957. /* Stop queue if no more TX buffers */
  958. if (pldat->num_used_tx_buffs >= (ENET_TX_DESC - 1))
  959. netif_stop_queue(ndev);
  960. spin_unlock_irq(&pldat->lock);
  961. dev_kfree_skb(skb);
  962. return NETDEV_TX_OK;
  963. }
  964. static int lpc_set_mac_address(struct net_device *ndev, void *p)
  965. {
  966. struct sockaddr *addr = p;
  967. struct netdata_local *pldat = netdev_priv(ndev);
  968. unsigned long flags;
  969. if (!is_valid_ether_addr(addr->sa_data))
  970. return -EADDRNOTAVAIL;
  971. memcpy(ndev->dev_addr, addr->sa_data, ETH_ALEN);
  972. spin_lock_irqsave(&pldat->lock, flags);
  973. /* Set station address */
  974. __lpc_set_mac(pldat, ndev->dev_addr);
  975. spin_unlock_irqrestore(&pldat->lock, flags);
  976. return 0;
  977. }
  978. static void lpc_eth_set_multicast_list(struct net_device *ndev)
  979. {
  980. struct netdata_local *pldat = netdev_priv(ndev);
  981. struct netdev_hw_addr_list *mcptr = &ndev->mc;
  982. struct netdev_hw_addr *ha;
  983. u32 tmp32, hash_val, hashlo, hashhi;
  984. unsigned long flags;
  985. spin_lock_irqsave(&pldat->lock, flags);
  986. /* Set station address */
  987. __lpc_set_mac(pldat, ndev->dev_addr);
  988. tmp32 = LPC_RXFLTRW_ACCEPTUBROADCAST | LPC_RXFLTRW_ACCEPTPERFECT;
  989. if (ndev->flags & IFF_PROMISC)
  990. tmp32 |= LPC_RXFLTRW_ACCEPTUNICAST |
  991. LPC_RXFLTRW_ACCEPTUMULTICAST;
  992. if (ndev->flags & IFF_ALLMULTI)
  993. tmp32 |= LPC_RXFLTRW_ACCEPTUMULTICAST;
  994. if (netdev_hw_addr_list_count(mcptr))
  995. tmp32 |= LPC_RXFLTRW_ACCEPTUMULTICASTHASH;
  996. writel(tmp32, LPC_ENET_RXFILTER_CTRL(pldat->net_base));
  997. /* Set initial hash table */
  998. hashlo = 0x0;
  999. hashhi = 0x0;
  1000. /* 64 bits : multicast address in hash table */
  1001. netdev_hw_addr_list_for_each(ha, mcptr) {
  1002. hash_val = (ether_crc(6, ha->addr) >> 23) & 0x3F;
  1003. if (hash_val >= 32)
  1004. hashhi |= 1 << (hash_val - 32);
  1005. else
  1006. hashlo |= 1 << hash_val;
  1007. }
  1008. writel(hashlo, LPC_ENET_HASHFILTERL(pldat->net_base));
  1009. writel(hashhi, LPC_ENET_HASHFILTERH(pldat->net_base));
  1010. spin_unlock_irqrestore(&pldat->lock, flags);
  1011. }
  1012. static int lpc_eth_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
  1013. {
  1014. struct netdata_local *pldat = netdev_priv(ndev);
  1015. struct phy_device *phydev = pldat->phy_dev;
  1016. if (!netif_running(ndev))
  1017. return -EINVAL;
  1018. if (!phydev)
  1019. return -ENODEV;
  1020. return phy_mii_ioctl(phydev, req, cmd);
  1021. }
  1022. static int lpc_eth_open(struct net_device *ndev)
  1023. {
  1024. struct netdata_local *pldat = netdev_priv(ndev);
  1025. if (netif_msg_ifup(pldat))
  1026. dev_dbg(&pldat->pdev->dev, "enabling %s\n", ndev->name);
  1027. __lpc_eth_clock_enable(pldat, true);
  1028. /* Suspended PHY makes LPC ethernet core block, so resume now */
  1029. phy_resume(pldat->phy_dev);
  1030. /* Reset and initialize */
  1031. __lpc_eth_reset(pldat);
  1032. __lpc_eth_init(pldat);
  1033. /* schedule a link state check */
  1034. phy_start(pldat->phy_dev);
  1035. netif_start_queue(ndev);
  1036. napi_enable(&pldat->napi);
  1037. return 0;
  1038. }
  1039. /*
  1040. * Ethtool ops
  1041. */
  1042. static void lpc_eth_ethtool_getdrvinfo(struct net_device *ndev,
  1043. struct ethtool_drvinfo *info)
  1044. {
  1045. strlcpy(info->driver, MODNAME, sizeof(info->driver));
  1046. strlcpy(info->version, DRV_VERSION, sizeof(info->version));
  1047. strlcpy(info->bus_info, dev_name(ndev->dev.parent),
  1048. sizeof(info->bus_info));
  1049. }
  1050. static u32 lpc_eth_ethtool_getmsglevel(struct net_device *ndev)
  1051. {
  1052. struct netdata_local *pldat = netdev_priv(ndev);
  1053. return pldat->msg_enable;
  1054. }
  1055. static void lpc_eth_ethtool_setmsglevel(struct net_device *ndev, u32 level)
  1056. {
  1057. struct netdata_local *pldat = netdev_priv(ndev);
  1058. pldat->msg_enable = level;
  1059. }
  1060. static int lpc_eth_ethtool_getsettings(struct net_device *ndev,
  1061. struct ethtool_cmd *cmd)
  1062. {
  1063. struct netdata_local *pldat = netdev_priv(ndev);
  1064. struct phy_device *phydev = pldat->phy_dev;
  1065. if (!phydev)
  1066. return -EOPNOTSUPP;
  1067. return phy_ethtool_gset(phydev, cmd);
  1068. }
  1069. static int lpc_eth_ethtool_setsettings(struct net_device *ndev,
  1070. struct ethtool_cmd *cmd)
  1071. {
  1072. struct netdata_local *pldat = netdev_priv(ndev);
  1073. struct phy_device *phydev = pldat->phy_dev;
  1074. if (!phydev)
  1075. return -EOPNOTSUPP;
  1076. return phy_ethtool_sset(phydev, cmd);
  1077. }
  1078. static const struct ethtool_ops lpc_eth_ethtool_ops = {
  1079. .get_drvinfo = lpc_eth_ethtool_getdrvinfo,
  1080. .get_settings = lpc_eth_ethtool_getsettings,
  1081. .set_settings = lpc_eth_ethtool_setsettings,
  1082. .get_msglevel = lpc_eth_ethtool_getmsglevel,
  1083. .set_msglevel = lpc_eth_ethtool_setmsglevel,
  1084. .get_link = ethtool_op_get_link,
  1085. };
  1086. static const struct net_device_ops lpc_netdev_ops = {
  1087. .ndo_open = lpc_eth_open,
  1088. .ndo_stop = lpc_eth_close,
  1089. .ndo_start_xmit = lpc_eth_hard_start_xmit,
  1090. .ndo_set_rx_mode = lpc_eth_set_multicast_list,
  1091. .ndo_do_ioctl = lpc_eth_ioctl,
  1092. .ndo_set_mac_address = lpc_set_mac_address,
  1093. .ndo_validate_addr = eth_validate_addr,
  1094. .ndo_change_mtu = eth_change_mtu,
  1095. };
  1096. static int lpc_eth_drv_probe(struct platform_device *pdev)
  1097. {
  1098. struct resource *res;
  1099. struct net_device *ndev;
  1100. struct netdata_local *pldat;
  1101. struct phy_device *phydev;
  1102. dma_addr_t dma_handle;
  1103. int irq, ret;
  1104. u32 tmp;
  1105. /* Setup network interface for RMII or MII mode */
  1106. tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL);
  1107. tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK;
  1108. if (lpc_phy_interface_mode(&pdev->dev) == PHY_INTERFACE_MODE_MII)
  1109. tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS;
  1110. else
  1111. tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS;
  1112. __raw_writel(tmp, LPC32XX_CLKPWR_MACCLK_CTRL);
  1113. /* Get platform resources */
  1114. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1115. irq = platform_get_irq(pdev, 0);
  1116. if (!res || irq < 0) {
  1117. dev_err(&pdev->dev, "error getting resources.\n");
  1118. ret = -ENXIO;
  1119. goto err_exit;
  1120. }
  1121. /* Allocate net driver data structure */
  1122. ndev = alloc_etherdev(sizeof(struct netdata_local));
  1123. if (!ndev) {
  1124. dev_err(&pdev->dev, "could not allocate device.\n");
  1125. ret = -ENOMEM;
  1126. goto err_exit;
  1127. }
  1128. SET_NETDEV_DEV(ndev, &pdev->dev);
  1129. pldat = netdev_priv(ndev);
  1130. pldat->pdev = pdev;
  1131. pldat->ndev = ndev;
  1132. spin_lock_init(&pldat->lock);
  1133. /* Save resources */
  1134. ndev->irq = irq;
  1135. /* Get clock for the device */
  1136. pldat->clk = clk_get(&pdev->dev, NULL);
  1137. if (IS_ERR(pldat->clk)) {
  1138. dev_err(&pdev->dev, "error getting clock.\n");
  1139. ret = PTR_ERR(pldat->clk);
  1140. goto err_out_free_dev;
  1141. }
  1142. /* Enable network clock */
  1143. __lpc_eth_clock_enable(pldat, true);
  1144. /* Map IO space */
  1145. pldat->net_base = ioremap(res->start, resource_size(res));
  1146. if (!pldat->net_base) {
  1147. dev_err(&pdev->dev, "failed to map registers\n");
  1148. ret = -ENOMEM;
  1149. goto err_out_disable_clocks;
  1150. }
  1151. ret = request_irq(ndev->irq, __lpc_eth_interrupt, 0,
  1152. ndev->name, ndev);
  1153. if (ret) {
  1154. dev_err(&pdev->dev, "error requesting interrupt.\n");
  1155. goto err_out_iounmap;
  1156. }
  1157. /* Setup driver functions */
  1158. ndev->netdev_ops = &lpc_netdev_ops;
  1159. ndev->ethtool_ops = &lpc_eth_ethtool_ops;
  1160. ndev->watchdog_timeo = msecs_to_jiffies(2500);
  1161. /* Get size of DMA buffers/descriptors region */
  1162. pldat->dma_buff_size = (ENET_TX_DESC + ENET_RX_DESC) * (ENET_MAXF_SIZE +
  1163. sizeof(struct txrx_desc_t) + sizeof(struct rx_status_t));
  1164. pldat->dma_buff_base_v = 0;
  1165. if (use_iram_for_net(&pldat->pdev->dev)) {
  1166. dma_handle = LPC32XX_IRAM_BASE;
  1167. if (pldat->dma_buff_size <= lpc32xx_return_iram_size())
  1168. pldat->dma_buff_base_v =
  1169. io_p2v(LPC32XX_IRAM_BASE);
  1170. else
  1171. netdev_err(ndev,
  1172. "IRAM not big enough for net buffers, using SDRAM instead.\n");
  1173. }
  1174. if (pldat->dma_buff_base_v == 0) {
  1175. ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
  1176. if (ret)
  1177. goto err_out_free_irq;
  1178. pldat->dma_buff_size = PAGE_ALIGN(pldat->dma_buff_size);
  1179. /* Allocate a chunk of memory for the DMA ethernet buffers
  1180. and descriptors */
  1181. pldat->dma_buff_base_v =
  1182. dma_alloc_coherent(&pldat->pdev->dev,
  1183. pldat->dma_buff_size, &dma_handle,
  1184. GFP_KERNEL);
  1185. if (pldat->dma_buff_base_v == NULL) {
  1186. ret = -ENOMEM;
  1187. goto err_out_free_irq;
  1188. }
  1189. }
  1190. pldat->dma_buff_base_p = dma_handle;
  1191. netdev_dbg(ndev, "IO address space :%pR\n", res);
  1192. netdev_dbg(ndev, "IO address size :%d\n", resource_size(res));
  1193. netdev_dbg(ndev, "IO address (mapped) :0x%p\n",
  1194. pldat->net_base);
  1195. netdev_dbg(ndev, "IRQ number :%d\n", ndev->irq);
  1196. netdev_dbg(ndev, "DMA buffer size :%d\n", pldat->dma_buff_size);
  1197. netdev_dbg(ndev, "DMA buffer P address :0x%08x\n",
  1198. pldat->dma_buff_base_p);
  1199. netdev_dbg(ndev, "DMA buffer V address :0x%p\n",
  1200. pldat->dma_buff_base_v);
  1201. /* Get MAC address from current HW setting (POR state is all zeros) */
  1202. __lpc_get_mac(pldat, ndev->dev_addr);
  1203. if (!is_valid_ether_addr(ndev->dev_addr)) {
  1204. const char *macaddr = of_get_mac_address(pdev->dev.of_node);
  1205. if (macaddr)
  1206. memcpy(ndev->dev_addr, macaddr, ETH_ALEN);
  1207. }
  1208. if (!is_valid_ether_addr(ndev->dev_addr))
  1209. eth_hw_addr_random(ndev);
  1210. /* Reset the ethernet controller */
  1211. __lpc_eth_reset(pldat);
  1212. /* then shut everything down to save power */
  1213. __lpc_eth_shutdown(pldat);
  1214. /* Set default parameters */
  1215. pldat->msg_enable = NETIF_MSG_LINK;
  1216. /* Force an MII interface reset and clock setup */
  1217. __lpc_mii_mngt_reset(pldat);
  1218. /* Force default PHY interface setup in chip, this will probably be
  1219. changed by the PHY driver */
  1220. pldat->link = 0;
  1221. pldat->speed = 100;
  1222. pldat->duplex = DUPLEX_FULL;
  1223. __lpc_params_setup(pldat);
  1224. netif_napi_add(ndev, &pldat->napi, lpc_eth_poll, NAPI_WEIGHT);
  1225. ret = register_netdev(ndev);
  1226. if (ret) {
  1227. dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
  1228. goto err_out_dma_unmap;
  1229. }
  1230. platform_set_drvdata(pdev, ndev);
  1231. ret = lpc_mii_init(pldat);
  1232. if (ret)
  1233. goto err_out_unregister_netdev;
  1234. netdev_info(ndev, "LPC mac at 0x%08x irq %d\n",
  1235. res->start, ndev->irq);
  1236. phydev = pldat->phy_dev;
  1237. device_init_wakeup(&pdev->dev, 1);
  1238. device_set_wakeup_enable(&pdev->dev, 0);
  1239. return 0;
  1240. err_out_unregister_netdev:
  1241. unregister_netdev(ndev);
  1242. err_out_dma_unmap:
  1243. if (!use_iram_for_net(&pldat->pdev->dev) ||
  1244. pldat->dma_buff_size > lpc32xx_return_iram_size())
  1245. dma_free_coherent(&pldat->pdev->dev, pldat->dma_buff_size,
  1246. pldat->dma_buff_base_v,
  1247. pldat->dma_buff_base_p);
  1248. err_out_free_irq:
  1249. free_irq(ndev->irq, ndev);
  1250. err_out_iounmap:
  1251. iounmap(pldat->net_base);
  1252. err_out_disable_clocks:
  1253. clk_disable_unprepare(pldat->clk);
  1254. clk_put(pldat->clk);
  1255. err_out_free_dev:
  1256. free_netdev(ndev);
  1257. err_exit:
  1258. pr_err("%s: not found (%d).\n", MODNAME, ret);
  1259. return ret;
  1260. }
  1261. static int lpc_eth_drv_remove(struct platform_device *pdev)
  1262. {
  1263. struct net_device *ndev = platform_get_drvdata(pdev);
  1264. struct netdata_local *pldat = netdev_priv(ndev);
  1265. unregister_netdev(ndev);
  1266. if (!use_iram_for_net(&pldat->pdev->dev) ||
  1267. pldat->dma_buff_size > lpc32xx_return_iram_size())
  1268. dma_free_coherent(&pldat->pdev->dev, pldat->dma_buff_size,
  1269. pldat->dma_buff_base_v,
  1270. pldat->dma_buff_base_p);
  1271. free_irq(ndev->irq, ndev);
  1272. iounmap(pldat->net_base);
  1273. mdiobus_unregister(pldat->mii_bus);
  1274. mdiobus_free(pldat->mii_bus);
  1275. clk_disable_unprepare(pldat->clk);
  1276. clk_put(pldat->clk);
  1277. free_netdev(ndev);
  1278. return 0;
  1279. }
  1280. #ifdef CONFIG_PM
  1281. static int lpc_eth_drv_suspend(struct platform_device *pdev,
  1282. pm_message_t state)
  1283. {
  1284. struct net_device *ndev = platform_get_drvdata(pdev);
  1285. struct netdata_local *pldat = netdev_priv(ndev);
  1286. if (device_may_wakeup(&pdev->dev))
  1287. enable_irq_wake(ndev->irq);
  1288. if (ndev) {
  1289. if (netif_running(ndev)) {
  1290. netif_device_detach(ndev);
  1291. __lpc_eth_shutdown(pldat);
  1292. clk_disable_unprepare(pldat->clk);
  1293. /*
  1294. * Reset again now clock is disable to be sure
  1295. * EMC_MDC is down
  1296. */
  1297. __lpc_eth_reset(pldat);
  1298. }
  1299. }
  1300. return 0;
  1301. }
  1302. static int lpc_eth_drv_resume(struct platform_device *pdev)
  1303. {
  1304. struct net_device *ndev = platform_get_drvdata(pdev);
  1305. struct netdata_local *pldat;
  1306. if (device_may_wakeup(&pdev->dev))
  1307. disable_irq_wake(ndev->irq);
  1308. if (ndev) {
  1309. if (netif_running(ndev)) {
  1310. pldat = netdev_priv(ndev);
  1311. /* Enable interface clock */
  1312. clk_enable(pldat->clk);
  1313. /* Reset and initialize */
  1314. __lpc_eth_reset(pldat);
  1315. __lpc_eth_init(pldat);
  1316. netif_device_attach(ndev);
  1317. }
  1318. }
  1319. return 0;
  1320. }
  1321. #endif
  1322. #ifdef CONFIG_OF
  1323. static const struct of_device_id lpc_eth_match[] = {
  1324. { .compatible = "nxp,lpc-eth" },
  1325. { }
  1326. };
  1327. MODULE_DEVICE_TABLE(of, lpc_eth_match);
  1328. #endif
  1329. static struct platform_driver lpc_eth_driver = {
  1330. .probe = lpc_eth_drv_probe,
  1331. .remove = lpc_eth_drv_remove,
  1332. #ifdef CONFIG_PM
  1333. .suspend = lpc_eth_drv_suspend,
  1334. .resume = lpc_eth_drv_resume,
  1335. #endif
  1336. .driver = {
  1337. .name = MODNAME,
  1338. .of_match_table = of_match_ptr(lpc_eth_match),
  1339. },
  1340. };
  1341. module_platform_driver(lpc_eth_driver);
  1342. MODULE_AUTHOR("Kevin Wells <kevin.wells@nxp.com>");
  1343. MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
  1344. MODULE_DESCRIPTION("LPC Ethernet Driver");
  1345. MODULE_LICENSE("GPL");