sh_eth.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. /*
  2. * SuperH Ethernet device driver
  3. *
  4. * Copyright (C) 2006-2012 Nobuhiro Iwamatsu
  5. * Copyright (C) 2008-2012 Renesas Solutions Corp.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms and conditions of the GNU General Public License,
  9. * version 2, as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * The full GNU General Public License is included in this distribution in
  20. * the file called "COPYING".
  21. */
  22. #ifndef __SH_ETH_H__
  23. #define __SH_ETH_H__
  24. #define CARDNAME "sh-eth"
  25. #define TX_TIMEOUT (5*HZ)
  26. #define TX_RING_SIZE 64 /* Tx ring size */
  27. #define RX_RING_SIZE 64 /* Rx ring size */
  28. #define TX_RING_MIN 64
  29. #define RX_RING_MIN 64
  30. #define TX_RING_MAX 1024
  31. #define RX_RING_MAX 1024
  32. #define ETHERSMALL 60
  33. #define PKT_BUF_SZ 1538
  34. #define SH_ETH_TSU_TIMEOUT_MS 500
  35. #define SH_ETH_TSU_CAM_ENTRIES 32
  36. enum {
  37. /* E-DMAC registers */
  38. EDSR = 0,
  39. EDMR,
  40. EDTRR,
  41. EDRRR,
  42. EESR,
  43. EESIPR,
  44. TDLAR,
  45. TDFAR,
  46. TDFXR,
  47. TDFFR,
  48. RDLAR,
  49. RDFAR,
  50. RDFXR,
  51. RDFFR,
  52. TRSCER,
  53. RMFCR,
  54. TFTR,
  55. FDR,
  56. RMCR,
  57. EDOCR,
  58. TFUCR,
  59. RFOCR,
  60. RMIIMODE,
  61. FCFTR,
  62. RPADIR,
  63. TRIMD,
  64. RBWAR,
  65. TBRAR,
  66. /* Ether registers */
  67. ECMR,
  68. ECSR,
  69. ECSIPR,
  70. PIR,
  71. PSR,
  72. RDMLR,
  73. PIPR,
  74. RFLR,
  75. IPGR,
  76. APR,
  77. MPR,
  78. PFTCR,
  79. PFRCR,
  80. RFCR,
  81. RFCF,
  82. TPAUSER,
  83. TPAUSECR,
  84. BCFR,
  85. BCFRR,
  86. GECMR,
  87. BCULR,
  88. MAHR,
  89. MALR,
  90. TROCR,
  91. CDCR,
  92. LCCR,
  93. CNDCR,
  94. CEFCR,
  95. FRECR,
  96. TSFRCR,
  97. TLFRCR,
  98. CERCR,
  99. CEECR,
  100. MAFCR,
  101. RTRATE,
  102. CSMR,
  103. RMII_MII,
  104. /* TSU Absolute address */
  105. ARSTR,
  106. TSU_CTRST,
  107. TSU_FWEN0,
  108. TSU_FWEN1,
  109. TSU_FCM,
  110. TSU_BSYSL0,
  111. TSU_BSYSL1,
  112. TSU_PRISL0,
  113. TSU_PRISL1,
  114. TSU_FWSL0,
  115. TSU_FWSL1,
  116. TSU_FWSLC,
  117. TSU_QTAG0,
  118. TSU_QTAG1,
  119. TSU_QTAGM0,
  120. TSU_QTAGM1,
  121. TSU_FWSR,
  122. TSU_FWINMK,
  123. TSU_ADQT0,
  124. TSU_ADQT1,
  125. TSU_VTAG0,
  126. TSU_VTAG1,
  127. TSU_ADSBSY,
  128. TSU_TEN,
  129. TSU_POST1,
  130. TSU_POST2,
  131. TSU_POST3,
  132. TSU_POST4,
  133. TSU_ADRH0,
  134. TSU_ADRL0,
  135. TSU_ADRH31,
  136. TSU_ADRL31,
  137. TXNLCR0,
  138. TXALCR0,
  139. RXNLCR0,
  140. RXALCR0,
  141. FWNLCR0,
  142. FWALCR0,
  143. TXNLCR1,
  144. TXALCR1,
  145. RXNLCR1,
  146. RXALCR1,
  147. FWNLCR1,
  148. FWALCR1,
  149. /* This value must be written at last. */
  150. SH_ETH_MAX_REGISTER_OFFSET,
  151. };
  152. enum {
  153. SH_ETH_REG_GIGABIT,
  154. SH_ETH_REG_FAST_RCAR,
  155. SH_ETH_REG_FAST_SH4,
  156. SH_ETH_REG_FAST_SH3_SH2
  157. };
  158. /* Driver's parameters */
  159. #if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
  160. #define SH4_SKB_RX_ALIGN 32
  161. #else
  162. #define SH2_SH3_SKB_RX_ALIGN 2
  163. #endif
  164. /*
  165. * Register's bits
  166. */
  167. /* EDSR : sh7734, sh7757, sh7763, and r8a7740 only */
  168. enum EDSR_BIT {
  169. EDSR_ENT = 0x01, EDSR_ENR = 0x02,
  170. };
  171. #define EDSR_ENALL (EDSR_ENT|EDSR_ENR)
  172. /* GECMR : sh7734, sh7763 and r8a7740 only */
  173. enum GECMR_BIT {
  174. GECMR_10 = 0x0, GECMR_100 = 0x04, GECMR_1000 = 0x01,
  175. };
  176. /* EDMR */
  177. enum DMAC_M_BIT {
  178. EDMR_EL = 0x40, /* Litte endian */
  179. EDMR_DL1 = 0x20, EDMR_DL0 = 0x10,
  180. EDMR_SRST_GETHER = 0x03,
  181. EDMR_SRST_ETHER = 0x01,
  182. };
  183. /* EDTRR */
  184. enum DMAC_T_BIT {
  185. EDTRR_TRNS_GETHER = 0x03,
  186. EDTRR_TRNS_ETHER = 0x01,
  187. };
  188. /* EDRRR*/
  189. enum EDRRR_R_BIT {
  190. EDRRR_R = 0x01,
  191. };
  192. /* TPAUSER */
  193. enum TPAUSER_BIT {
  194. TPAUSER_TPAUSE = 0x0000ffff,
  195. TPAUSER_UNLIMITED = 0,
  196. };
  197. /* BCFR */
  198. enum BCFR_BIT {
  199. BCFR_RPAUSE = 0x0000ffff,
  200. BCFR_UNLIMITED = 0,
  201. };
  202. /* PIR */
  203. enum PIR_BIT {
  204. PIR_MDI = 0x08, PIR_MDO = 0x04, PIR_MMD = 0x02, PIR_MDC = 0x01,
  205. };
  206. /* PSR */
  207. enum PHY_STATUS_BIT { PHY_ST_LINK = 0x01, };
  208. /* EESR */
  209. enum EESR_BIT {
  210. EESR_TWB1 = 0x80000000,
  211. EESR_TWB = 0x40000000, /* same as TWB0 */
  212. EESR_TC1 = 0x20000000,
  213. EESR_TUC = 0x10000000,
  214. EESR_ROC = 0x08000000,
  215. EESR_TABT = 0x04000000,
  216. EESR_RABT = 0x02000000,
  217. EESR_RFRMER = 0x01000000, /* same as RFCOF */
  218. EESR_ADE = 0x00800000,
  219. EESR_ECI = 0x00400000,
  220. EESR_FTC = 0x00200000, /* same as TC or TC0 */
  221. EESR_TDE = 0x00100000,
  222. EESR_TFE = 0x00080000, /* same as TFUF */
  223. EESR_FRC = 0x00040000, /* same as FR */
  224. EESR_RDE = 0x00020000,
  225. EESR_RFE = 0x00010000,
  226. EESR_CND = 0x00000800,
  227. EESR_DLC = 0x00000400,
  228. EESR_CD = 0x00000200,
  229. EESR_RTO = 0x00000100,
  230. EESR_RMAF = 0x00000080,
  231. EESR_CEEF = 0x00000040,
  232. EESR_CELF = 0x00000020,
  233. EESR_RRF = 0x00000010,
  234. EESR_RTLF = 0x00000008,
  235. EESR_RTSF = 0x00000004,
  236. EESR_PRE = 0x00000002,
  237. EESR_CERF = 0x00000001,
  238. };
  239. #define EESR_RX_CHECK (EESR_FRC | /* Frame recv */ \
  240. EESR_RMAF | /* Multicast address recv */ \
  241. EESR_RRF | /* Bit frame recv */ \
  242. EESR_RTLF | /* Long frame recv */ \
  243. EESR_RTSF | /* Short frame recv */ \
  244. EESR_PRE | /* PHY-LSI recv error */ \
  245. EESR_CERF) /* Recv frame CRC error */
  246. #define DEFAULT_TX_CHECK (EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | \
  247. EESR_RTO)
  248. #define DEFAULT_EESR_ERR_CHECK (EESR_TWB | EESR_TABT | EESR_RABT | EESR_RFE | \
  249. EESR_RDE | EESR_RFRMER | EESR_ADE | \
  250. EESR_TFE | EESR_TDE | EESR_ECI)
  251. /* EESIPR */
  252. enum DMAC_IM_BIT {
  253. DMAC_M_TWB = 0x40000000, DMAC_M_TABT = 0x04000000,
  254. DMAC_M_RABT = 0x02000000,
  255. DMAC_M_RFRMER = 0x01000000, DMAC_M_ADF = 0x00800000,
  256. DMAC_M_ECI = 0x00400000, DMAC_M_FTC = 0x00200000,
  257. DMAC_M_TDE = 0x00100000, DMAC_M_TFE = 0x00080000,
  258. DMAC_M_FRC = 0x00040000, DMAC_M_RDE = 0x00020000,
  259. DMAC_M_RFE = 0x00010000, DMAC_M_TINT4 = 0x00000800,
  260. DMAC_M_TINT3 = 0x00000400, DMAC_M_TINT2 = 0x00000200,
  261. DMAC_M_TINT1 = 0x00000100, DMAC_M_RINT8 = 0x00000080,
  262. DMAC_M_RINT5 = 0x00000010, DMAC_M_RINT4 = 0x00000008,
  263. DMAC_M_RINT3 = 0x00000004, DMAC_M_RINT2 = 0x00000002,
  264. DMAC_M_RINT1 = 0x00000001,
  265. };
  266. /* Receive descriptor bit */
  267. enum RD_STS_BIT {
  268. RD_RACT = 0x80000000, RD_RDEL = 0x40000000,
  269. RD_RFP1 = 0x20000000, RD_RFP0 = 0x10000000,
  270. RD_RFE = 0x08000000, RD_RFS10 = 0x00000200,
  271. RD_RFS9 = 0x00000100, RD_RFS8 = 0x00000080,
  272. RD_RFS7 = 0x00000040, RD_RFS6 = 0x00000020,
  273. RD_RFS5 = 0x00000010, RD_RFS4 = 0x00000008,
  274. RD_RFS3 = 0x00000004, RD_RFS2 = 0x00000002,
  275. RD_RFS1 = 0x00000001,
  276. };
  277. #define RDF1ST RD_RFP1
  278. #define RDFEND RD_RFP0
  279. #define RD_RFP (RD_RFP1|RD_RFP0)
  280. /* FCFTR */
  281. enum FCFTR_BIT {
  282. FCFTR_RFF2 = 0x00040000, FCFTR_RFF1 = 0x00020000,
  283. FCFTR_RFF0 = 0x00010000, FCFTR_RFD2 = 0x00000004,
  284. FCFTR_RFD1 = 0x00000002, FCFTR_RFD0 = 0x00000001,
  285. };
  286. #define DEFAULT_FIFO_F_D_RFF (FCFTR_RFF2 | FCFTR_RFF1 | FCFTR_RFF0)
  287. #define DEFAULT_FIFO_F_D_RFD (FCFTR_RFD2 | FCFTR_RFD1 | FCFTR_RFD0)
  288. /* Transmit descriptor bit */
  289. enum TD_STS_BIT {
  290. TD_TACT = 0x80000000, TD_TDLE = 0x40000000,
  291. TD_TFP1 = 0x20000000, TD_TFP0 = 0x10000000,
  292. TD_TFE = 0x08000000, TD_TWBI = 0x04000000,
  293. };
  294. #define TDF1ST TD_TFP1
  295. #define TDFEND TD_TFP0
  296. #define TD_TFP (TD_TFP1|TD_TFP0)
  297. /* RMCR */
  298. enum RMCR_BIT {
  299. RMCR_RNC = 0x00000001,
  300. };
  301. #define DEFAULT_RMCR_VALUE 0x00000000
  302. /* ECMR */
  303. enum FELIC_MODE_BIT {
  304. ECMR_TRCCM = 0x04000000, ECMR_RCSC = 0x00800000,
  305. ECMR_DPAD = 0x00200000, ECMR_RZPF = 0x00100000,
  306. ECMR_ZPF = 0x00080000, ECMR_PFR = 0x00040000, ECMR_RXF = 0x00020000,
  307. ECMR_TXF = 0x00010000, ECMR_MCT = 0x00002000, ECMR_PRCEF = 0x00001000,
  308. ECMR_PMDE = 0x00000200, ECMR_RE = 0x00000040, ECMR_TE = 0x00000020,
  309. ECMR_RTM = 0x00000010, ECMR_ILB = 0x00000008, ECMR_ELB = 0x00000004,
  310. ECMR_DM = 0x00000002, ECMR_PRM = 0x00000001,
  311. };
  312. /* ECSR */
  313. enum ECSR_STATUS_BIT {
  314. ECSR_BRCRX = 0x20, ECSR_PSRTO = 0x10,
  315. ECSR_LCHNG = 0x04,
  316. ECSR_MPD = 0x02, ECSR_ICD = 0x01,
  317. };
  318. #define DEFAULT_ECSR_INIT (ECSR_BRCRX | ECSR_PSRTO | ECSR_LCHNG | \
  319. ECSR_ICD | ECSIPR_MPDIP)
  320. /* ECSIPR */
  321. enum ECSIPR_STATUS_MASK_BIT {
  322. ECSIPR_BRCRXIP = 0x20, ECSIPR_PSRTOIP = 0x10,
  323. ECSIPR_LCHNGIP = 0x04,
  324. ECSIPR_MPDIP = 0x02, ECSIPR_ICDIP = 0x01,
  325. };
  326. #define DEFAULT_ECSIPR_INIT (ECSIPR_BRCRXIP | ECSIPR_PSRTOIP | \
  327. ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP)
  328. /* APR */
  329. enum APR_BIT {
  330. APR_AP = 0x00000001,
  331. };
  332. /* MPR */
  333. enum MPR_BIT {
  334. MPR_MP = 0x00000001,
  335. };
  336. /* TRSCER */
  337. enum DESC_I_BIT {
  338. DESC_I_TINT4 = 0x0800, DESC_I_TINT3 = 0x0400, DESC_I_TINT2 = 0x0200,
  339. DESC_I_TINT1 = 0x0100, DESC_I_RINT8 = 0x0080, DESC_I_RINT5 = 0x0010,
  340. DESC_I_RINT4 = 0x0008, DESC_I_RINT3 = 0x0004, DESC_I_RINT2 = 0x0002,
  341. DESC_I_RINT1 = 0x0001,
  342. };
  343. /* RPADIR */
  344. enum RPADIR_BIT {
  345. RPADIR_PADS1 = 0x20000, RPADIR_PADS0 = 0x10000,
  346. RPADIR_PADR = 0x0003f,
  347. };
  348. /* FDR */
  349. #define DEFAULT_FDR_INIT 0x00000707
  350. /* ARSTR */
  351. enum ARSTR_BIT { ARSTR_ARSTR = 0x00000001, };
  352. /* TSU_FWEN0 */
  353. enum TSU_FWEN0_BIT {
  354. TSU_FWEN0_0 = 0x00000001,
  355. };
  356. /* TSU_ADSBSY */
  357. enum TSU_ADSBSY_BIT {
  358. TSU_ADSBSY_0 = 0x00000001,
  359. };
  360. /* TSU_TEN */
  361. enum TSU_TEN_BIT {
  362. TSU_TEN_0 = 0x80000000,
  363. };
  364. /* TSU_FWSL0 */
  365. enum TSU_FWSL0_BIT {
  366. TSU_FWSL0_FW50 = 0x1000, TSU_FWSL0_FW40 = 0x0800,
  367. TSU_FWSL0_FW30 = 0x0400, TSU_FWSL0_FW20 = 0x0200,
  368. TSU_FWSL0_FW10 = 0x0100, TSU_FWSL0_RMSA0 = 0x0010,
  369. };
  370. /* TSU_FWSLC */
  371. enum TSU_FWSLC_BIT {
  372. TSU_FWSLC_POSTENU = 0x2000, TSU_FWSLC_POSTENL = 0x1000,
  373. TSU_FWSLC_CAMSEL03 = 0x0080, TSU_FWSLC_CAMSEL02 = 0x0040,
  374. TSU_FWSLC_CAMSEL01 = 0x0020, TSU_FWSLC_CAMSEL00 = 0x0010,
  375. TSU_FWSLC_CAMSEL13 = 0x0008, TSU_FWSLC_CAMSEL12 = 0x0004,
  376. TSU_FWSLC_CAMSEL11 = 0x0002, TSU_FWSLC_CAMSEL10 = 0x0001,
  377. };
  378. /* TSU_VTAGn */
  379. #define TSU_VTAG_ENABLE 0x80000000
  380. #define TSU_VTAG_VID_MASK 0x00000fff
  381. /*
  382. * The sh ether Tx buffer descriptors.
  383. * This structure should be 20 bytes.
  384. */
  385. struct sh_eth_txdesc {
  386. u32 status; /* TD0 */
  387. #if defined(__LITTLE_ENDIAN)
  388. u16 pad0; /* TD1 */
  389. u16 buffer_length; /* TD1 */
  390. #else
  391. u16 buffer_length; /* TD1 */
  392. u16 pad0; /* TD1 */
  393. #endif
  394. u32 addr; /* TD2 */
  395. u32 pad1; /* padding data */
  396. } __attribute__((aligned(2), packed));
  397. /*
  398. * The sh ether Rx buffer descriptors.
  399. * This structure should be 20 bytes.
  400. */
  401. struct sh_eth_rxdesc {
  402. u32 status; /* RD0 */
  403. #if defined(__LITTLE_ENDIAN)
  404. u16 frame_length; /* RD1 */
  405. u16 buffer_length; /* RD1 */
  406. #else
  407. u16 buffer_length; /* RD1 */
  408. u16 frame_length; /* RD1 */
  409. #endif
  410. u32 addr; /* RD2 */
  411. u32 pad0; /* padding data */
  412. } __attribute__((aligned(2), packed));
  413. /* This structure is used by each CPU dependency handling. */
  414. struct sh_eth_cpu_data {
  415. /* optional functions */
  416. void (*chip_reset)(struct net_device *ndev);
  417. void (*set_duplex)(struct net_device *ndev);
  418. void (*set_rate)(struct net_device *ndev);
  419. /* mandatory initialize value */
  420. int register_type;
  421. unsigned long eesipr_value;
  422. /* optional initialize value */
  423. unsigned long ecsr_value;
  424. unsigned long ecsipr_value;
  425. unsigned long fdr_value;
  426. unsigned long fcftr_value;
  427. unsigned long rpadir_value;
  428. unsigned long rmcr_value;
  429. /* interrupt checking mask */
  430. unsigned long tx_check;
  431. unsigned long eesr_err_check;
  432. /* hardware features */
  433. unsigned long irq_flags; /* IRQ configuration flags */
  434. unsigned no_psr:1; /* EtherC DO NOT have PSR */
  435. unsigned apr:1; /* EtherC have APR */
  436. unsigned mpr:1; /* EtherC have MPR */
  437. unsigned tpauser:1; /* EtherC have TPAUSER */
  438. unsigned bculr:1; /* EtherC have BCULR */
  439. unsigned tsu:1; /* EtherC have TSU */
  440. unsigned hw_swap:1; /* E-DMAC have DE bit in EDMR */
  441. unsigned rpadir:1; /* E-DMAC have RPADIR */
  442. unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */
  443. unsigned no_ade:1; /* E-DMAC DO NOT have ADE bit in EESR */
  444. unsigned hw_crc:1; /* E-DMAC have CSMR */
  445. unsigned select_mii:1; /* EtherC have RMII_MII (MII select register) */
  446. unsigned shift_rd0:1; /* shift Rx descriptor word 0 right by 16 */
  447. unsigned rmiimode:1; /* EtherC has RMIIMODE register */
  448. };
  449. struct sh_eth_private {
  450. struct platform_device *pdev;
  451. struct sh_eth_cpu_data *cd;
  452. const u16 *reg_offset;
  453. void __iomem *addr;
  454. void __iomem *tsu_addr;
  455. u32 num_rx_ring;
  456. u32 num_tx_ring;
  457. dma_addr_t rx_desc_dma;
  458. dma_addr_t tx_desc_dma;
  459. struct sh_eth_rxdesc *rx_ring;
  460. struct sh_eth_txdesc *tx_ring;
  461. struct sk_buff **rx_skbuff;
  462. struct sk_buff **tx_skbuff;
  463. spinlock_t lock;
  464. u32 cur_rx, dirty_rx; /* Producer/consumer ring indices */
  465. u32 cur_tx, dirty_tx;
  466. u32 rx_buf_sz; /* Based on MTU+slack. */
  467. int edmac_endian;
  468. struct napi_struct napi;
  469. /* MII transceiver section. */
  470. u32 phy_id; /* PHY ID */
  471. struct mii_bus *mii_bus; /* MDIO bus control */
  472. struct phy_device *phydev; /* PHY device control */
  473. int link;
  474. phy_interface_t phy_interface;
  475. int msg_enable;
  476. int speed;
  477. int duplex;
  478. int port; /* for TSU */
  479. int vlan_num_ids; /* for VLAN tag filter */
  480. unsigned no_ether_link:1;
  481. unsigned ether_link_active_low:1;
  482. };
  483. static inline void sh_eth_soft_swap(char *src, int len)
  484. {
  485. #ifdef __LITTLE_ENDIAN__
  486. u32 *p = (u32 *)src;
  487. u32 *maxp;
  488. maxp = p + ((len + sizeof(u32) - 1) / sizeof(u32));
  489. for (; p < maxp; p++)
  490. *p = swab32(*p);
  491. #endif
  492. }
  493. static inline void sh_eth_write(struct net_device *ndev, unsigned long data,
  494. int enum_index)
  495. {
  496. struct sh_eth_private *mdp = netdev_priv(ndev);
  497. iowrite32(data, mdp->addr + mdp->reg_offset[enum_index]);
  498. }
  499. static inline unsigned long sh_eth_read(struct net_device *ndev,
  500. int enum_index)
  501. {
  502. struct sh_eth_private *mdp = netdev_priv(ndev);
  503. return ioread32(mdp->addr + mdp->reg_offset[enum_index]);
  504. }
  505. static inline void *sh_eth_tsu_get_offset(struct sh_eth_private *mdp,
  506. int enum_index)
  507. {
  508. return mdp->tsu_addr + mdp->reg_offset[enum_index];
  509. }
  510. static inline void sh_eth_tsu_write(struct sh_eth_private *mdp,
  511. unsigned long data, int enum_index)
  512. {
  513. iowrite32(data, mdp->tsu_addr + mdp->reg_offset[enum_index]);
  514. }
  515. static inline unsigned long sh_eth_tsu_read(struct sh_eth_private *mdp,
  516. int enum_index)
  517. {
  518. return ioread32(mdp->tsu_addr + mdp->reg_offset[enum_index]);
  519. }
  520. #endif /* #ifndef __SH_ETH_H__ */