Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 2 | /* |
Robert P. J. Day | 8c60f92 | 2016-05-04 04:47:31 -0400 | [diff] [blame] | 3 | * sh_eth.h - Driver for Renesas SuperH ethernet controller. |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 4 | * |
Nobuhiro Iwamatsu | 4ad2c2a | 2012-08-02 22:08:40 +0000 | [diff] [blame] | 5 | * Copyright (C) 2008 - 2012 Renesas Solutions Corp. |
| 6 | * Copyright (c) 2008 - 2012 Nobuhiro Iwamatsu |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 7 | * Copyright (c) 2007 Carlos Munoz <carlos@kenati.com> |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 8 | */ |
| 9 | |
Nobuhiro Iwamatsu | d8f5d50 | 2008-11-21 12:04:18 +0900 | [diff] [blame] | 10 | #include <netdev.h> |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 11 | #include <asm/types.h> |
| 12 | |
| 13 | #define SHETHER_NAME "sh_eth" |
| 14 | |
Nobuhiro Iwamatsu | 4ad2c2a | 2012-08-02 22:08:40 +0000 | [diff] [blame] | 15 | #if defined(CONFIG_SH) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 16 | /* Malloc returns addresses in the P1 area (cacheable). However we need to |
| 17 | use area P2 (non-cacheable) */ |
| 18 | #define ADDR_TO_P2(addr) ((((int)(addr) & ~0xe0000000) | 0xa0000000)) |
| 19 | |
| 20 | /* The ethernet controller needs to use physical addresses */ |
Yoshihiro Shimoda | 34cca92 | 2011-01-18 17:53:45 +0900 | [diff] [blame] | 21 | #if defined(CONFIG_SH_32BIT) |
| 22 | #define ADDR_TO_PHY(addr) ((((int)(addr) & ~0xe0000000) | 0x40000000)) |
| 23 | #else |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 24 | #define ADDR_TO_PHY(addr) ((int)(addr) & ~0xe0000000) |
Yoshihiro Shimoda | 34cca92 | 2011-01-18 17:53:45 +0900 | [diff] [blame] | 25 | #endif |
Nobuhiro Iwamatsu | 4ad2c2a | 2012-08-02 22:08:40 +0000 | [diff] [blame] | 26 | #elif defined(CONFIG_ARM) |
Chris Brandt | 7123077 | 2017-11-03 08:30:11 -0500 | [diff] [blame] | 27 | #ifndef inl |
| 28 | #define inl readl |
Nobuhiro Iwamatsu | 4ad2c2a | 2012-08-02 22:08:40 +0000 | [diff] [blame] | 29 | #define outl writel |
Chris Brandt | 7123077 | 2017-11-03 08:30:11 -0500 | [diff] [blame] | 30 | #endif |
Nobuhiro Iwamatsu | 4ad2c2a | 2012-08-02 22:08:40 +0000 | [diff] [blame] | 31 | #define ADDR_TO_PHY(addr) ((int)(addr)) |
| 32 | #define ADDR_TO_P2(addr) (addr) |
| 33 | #endif /* defined(CONFIG_SH) */ |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 34 | |
Nobuhiro Iwamatsu | 7a2142c | 2013-08-22 13:22:02 +0900 | [diff] [blame] | 35 | /* base padding size is 16 */ |
| 36 | #ifndef CONFIG_SH_ETHER_ALIGNE_SIZE |
| 37 | #define CONFIG_SH_ETHER_ALIGNE_SIZE 16 |
| 38 | #endif |
| 39 | |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 40 | /* Number of supported ports */ |
| 41 | #define MAX_PORT_NUM 2 |
| 42 | |
| 43 | /* Buffers must be big enough to hold the largest ethernet frame. Also, rx |
| 44 | buffers must be a multiple of 32 bytes */ |
| 45 | #define MAX_BUF_SIZE (48 * 32) |
| 46 | |
| 47 | /* The number of tx descriptors must be large enough to point to 5 or more |
| 48 | frames. If each frame uses 2 descriptors, at least 10 descriptors are needed. |
| 49 | We use one descriptor per frame */ |
| 50 | #define NUM_TX_DESC 8 |
| 51 | |
| 52 | /* The size of the tx descriptor is determined by how much padding is used. |
| 53 | 4, 20, or 52 bytes of padding can be used */ |
Nobuhiro Iwamatsu | 7a2142c | 2013-08-22 13:22:02 +0900 | [diff] [blame] | 54 | #define TX_DESC_PADDING (CONFIG_SH_ETHER_ALIGNE_SIZE - 12) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 55 | |
Nobuhiro Iwamatsu | d8f5d50 | 2008-11-21 12:04:18 +0900 | [diff] [blame] | 56 | /* Tx descriptor. We always use 3 bytes of padding */ |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 57 | struct tx_desc_s { |
| 58 | volatile u32 td0; |
| 59 | u32 td1; |
| 60 | u32 td2; /* Buffer start */ |
Nobuhiro Iwamatsu | 7a2142c | 2013-08-22 13:22:02 +0900 | [diff] [blame] | 61 | u8 padding[TX_DESC_PADDING]; /* aligned cache line size */ |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | /* There is no limitation in the number of rx descriptors */ |
| 65 | #define NUM_RX_DESC 8 |
| 66 | |
| 67 | /* The size of the rx descriptor is determined by how much padding is used. |
| 68 | 4, 20, or 52 bytes of padding can be used */ |
Nobuhiro Iwamatsu | 7a2142c | 2013-08-22 13:22:02 +0900 | [diff] [blame] | 69 | #define RX_DESC_PADDING (CONFIG_SH_ETHER_ALIGNE_SIZE - 12) |
Nobuhiro Iwamatsu | 7a2142c | 2013-08-22 13:22:02 +0900 | [diff] [blame] | 70 | /* aligned cache line size */ |
| 71 | #define RX_BUF_ALIGNE_SIZE (CONFIG_SH_ETHER_ALIGNE_SIZE > 32 ? 64 : 32) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 72 | |
| 73 | /* Rx descriptor. We always use 4 bytes of padding */ |
| 74 | struct rx_desc_s { |
| 75 | volatile u32 rd0; |
| 76 | volatile u32 rd1; |
| 77 | u32 rd2; /* Buffer start */ |
Nobuhiro Iwamatsu | 7a2142c | 2013-08-22 13:22:02 +0900 | [diff] [blame] | 78 | u8 padding[TX_DESC_PADDING]; /* aligned cache line size */ |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 79 | }; |
| 80 | |
Nobuhiro Iwamatsu | d8f5d50 | 2008-11-21 12:04:18 +0900 | [diff] [blame] | 81 | struct sh_eth_info { |
Nobuhiro Iwamatsu | 1c82211 | 2014-11-04 09:15:47 +0900 | [diff] [blame] | 82 | struct tx_desc_s *tx_desc_alloc; |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 83 | struct tx_desc_s *tx_desc_base; |
| 84 | struct tx_desc_s *tx_desc_cur; |
Nobuhiro Iwamatsu | 1c82211 | 2014-11-04 09:15:47 +0900 | [diff] [blame] | 85 | struct rx_desc_s *rx_desc_alloc; |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 86 | struct rx_desc_s *rx_desc_base; |
| 87 | struct rx_desc_s *rx_desc_cur; |
Nobuhiro Iwamatsu | 1c82211 | 2014-11-04 09:15:47 +0900 | [diff] [blame] | 88 | u8 *rx_buf_alloc; |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 89 | u8 *rx_buf_base; |
| 90 | u8 mac_addr[6]; |
| 91 | u8 phy_addr; |
Nobuhiro Iwamatsu | d8f5d50 | 2008-11-21 12:04:18 +0900 | [diff] [blame] | 92 | struct eth_device *dev; |
Yoshihiro Shimoda | 677f6cd | 2011-10-11 18:10:14 +0900 | [diff] [blame] | 93 | struct phy_device *phydev; |
Nobuhiro Iwamatsu | ec921f1 | 2017-12-01 08:10:32 +0900 | [diff] [blame] | 94 | void __iomem *iobase; |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 95 | }; |
| 96 | |
Nobuhiro Iwamatsu | d8f5d50 | 2008-11-21 12:04:18 +0900 | [diff] [blame] | 97 | struct sh_eth_dev { |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 98 | int port; |
Nobuhiro Iwamatsu | d8f5d50 | 2008-11-21 12:04:18 +0900 | [diff] [blame] | 99 | struct sh_eth_info port_info[MAX_PORT_NUM]; |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 100 | }; |
| 101 | |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 102 | /* from linux/drivers/net/ethernet/renesas/sh_eth.h */ |
| 103 | enum { |
| 104 | /* E-DMAC registers */ |
| 105 | EDSR = 0, |
| 106 | EDMR, |
| 107 | EDTRR, |
| 108 | EDRRR, |
| 109 | EESR, |
| 110 | EESIPR, |
| 111 | TDLAR, |
| 112 | TDFAR, |
| 113 | TDFXR, |
| 114 | TDFFR, |
| 115 | RDLAR, |
| 116 | RDFAR, |
| 117 | RDFXR, |
| 118 | RDFFR, |
| 119 | TRSCER, |
| 120 | RMFCR, |
| 121 | TFTR, |
| 122 | FDR, |
| 123 | RMCR, |
| 124 | EDOCR, |
| 125 | TFUCR, |
| 126 | RFOCR, |
| 127 | FCFTR, |
| 128 | RPADIR, |
| 129 | TRIMD, |
| 130 | RBWAR, |
| 131 | TBRAR, |
| 132 | |
| 133 | /* Ether registers */ |
| 134 | ECMR, |
| 135 | ECSR, |
| 136 | ECSIPR, |
| 137 | PIR, |
| 138 | PSR, |
| 139 | RDMLR, |
| 140 | PIPR, |
| 141 | RFLR, |
| 142 | IPGR, |
| 143 | APR, |
| 144 | MPR, |
| 145 | PFTCR, |
| 146 | PFRCR, |
| 147 | RFCR, |
| 148 | RFCF, |
| 149 | TPAUSER, |
| 150 | TPAUSECR, |
| 151 | BCFR, |
| 152 | BCFRR, |
| 153 | GECMR, |
| 154 | BCULR, |
| 155 | MAHR, |
| 156 | MALR, |
| 157 | TROCR, |
| 158 | CDCR, |
| 159 | LCCR, |
| 160 | CNDCR, |
| 161 | CEFCR, |
| 162 | FRECR, |
| 163 | TSFRCR, |
| 164 | TLFRCR, |
| 165 | CERCR, |
| 166 | CEECR, |
Nobuhiro Iwamatsu | 72befd3 | 2013-08-22 13:22:04 +0900 | [diff] [blame] | 167 | RMIIMR, /* R8A7790 */ |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 168 | MAFCR, |
| 169 | RTRATE, |
| 170 | CSMR, |
| 171 | RMII_MII, |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 172 | |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 173 | /* This value must be written at last. */ |
| 174 | SH_ETH_MAX_REGISTER_OFFSET, |
| 175 | }; |
| 176 | |
| 177 | static const u16 sh_eth_offset_gigabit[SH_ETH_MAX_REGISTER_OFFSET] = { |
| 178 | [EDSR] = 0x0000, |
| 179 | [EDMR] = 0x0400, |
| 180 | [EDTRR] = 0x0408, |
| 181 | [EDRRR] = 0x0410, |
| 182 | [EESR] = 0x0428, |
| 183 | [EESIPR] = 0x0430, |
| 184 | [TDLAR] = 0x0010, |
| 185 | [TDFAR] = 0x0014, |
| 186 | [TDFXR] = 0x0018, |
| 187 | [TDFFR] = 0x001c, |
| 188 | [RDLAR] = 0x0030, |
| 189 | [RDFAR] = 0x0034, |
| 190 | [RDFXR] = 0x0038, |
| 191 | [RDFFR] = 0x003c, |
| 192 | [TRSCER] = 0x0438, |
| 193 | [RMFCR] = 0x0440, |
| 194 | [TFTR] = 0x0448, |
| 195 | [FDR] = 0x0450, |
| 196 | [RMCR] = 0x0458, |
| 197 | [RPADIR] = 0x0460, |
| 198 | [FCFTR] = 0x0468, |
| 199 | [CSMR] = 0x04E4, |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 200 | |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 201 | [ECMR] = 0x0500, |
| 202 | [ECSR] = 0x0510, |
| 203 | [ECSIPR] = 0x0518, |
| 204 | [PIR] = 0x0520, |
| 205 | [PSR] = 0x0528, |
| 206 | [PIPR] = 0x052c, |
| 207 | [RFLR] = 0x0508, |
| 208 | [APR] = 0x0554, |
| 209 | [MPR] = 0x0558, |
| 210 | [PFTCR] = 0x055c, |
| 211 | [PFRCR] = 0x0560, |
| 212 | [TPAUSER] = 0x0564, |
| 213 | [GECMR] = 0x05b0, |
| 214 | [BCULR] = 0x05b4, |
| 215 | [MAHR] = 0x05c0, |
| 216 | [MALR] = 0x05c8, |
| 217 | [TROCR] = 0x0700, |
| 218 | [CDCR] = 0x0708, |
| 219 | [LCCR] = 0x0710, |
| 220 | [CEFCR] = 0x0740, |
| 221 | [FRECR] = 0x0748, |
| 222 | [TSFRCR] = 0x0750, |
| 223 | [TLFRCR] = 0x0758, |
| 224 | [RFCR] = 0x0760, |
| 225 | [CERCR] = 0x0768, |
| 226 | [CEECR] = 0x0770, |
| 227 | [MAFCR] = 0x0778, |
| 228 | [RMII_MII] = 0x0790, |
| 229 | }; |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 230 | |
Marek Vasut | 7f6f5ab | 2019-05-01 18:20:48 +0200 | [diff] [blame] | 231 | static const u16 sh_eth_offset_rz[SH_ETH_MAX_REGISTER_OFFSET] = { |
| 232 | [EDSR] = 0x0000, |
| 233 | [EDMR] = 0x0400, |
| 234 | [EDTRR] = 0x0408, |
| 235 | [EDRRR] = 0x0410, |
| 236 | [EESR] = 0x0428, |
| 237 | [EESIPR] = 0x0430, |
| 238 | [TDLAR] = 0x0010, |
| 239 | [TDFAR] = 0x0014, |
| 240 | [TDFXR] = 0x0018, |
| 241 | [TDFFR] = 0x001c, |
| 242 | [RDLAR] = 0x0030, |
| 243 | [RDFAR] = 0x0034, |
| 244 | [RDFXR] = 0x0038, |
| 245 | [RDFFR] = 0x003c, |
| 246 | [TRSCER] = 0x0438, |
| 247 | [RMFCR] = 0x0440, |
| 248 | [TFTR] = 0x0448, |
| 249 | [FDR] = 0x0450, |
| 250 | [RMCR] = 0x0458, |
| 251 | [RPADIR] = 0x0460, |
| 252 | [FCFTR] = 0x0468, |
| 253 | [CSMR] = 0x04E4, |
| 254 | |
| 255 | [ECMR] = 0x0500, |
| 256 | [ECSR] = 0x0510, |
| 257 | [ECSIPR] = 0x0518, |
| 258 | [PIR] = 0x0520, |
| 259 | [PSR] = 0x0528, |
| 260 | [PIPR] = 0x052c, |
| 261 | [RFLR] = 0x0508, |
| 262 | [APR] = 0x0554, |
| 263 | [MPR] = 0x0558, |
| 264 | [PFTCR] = 0x055c, |
| 265 | [PFRCR] = 0x0560, |
| 266 | [TPAUSER] = 0x0564, |
| 267 | [GECMR] = 0x05b0, |
| 268 | [BCULR] = 0x05b4, |
| 269 | [MAHR] = 0x05c0, |
| 270 | [MALR] = 0x05c8, |
| 271 | [TROCR] = 0x0700, |
| 272 | [CDCR] = 0x0708, |
| 273 | [LCCR] = 0x0710, |
| 274 | [CEFCR] = 0x0740, |
| 275 | [FRECR] = 0x0748, |
| 276 | [TSFRCR] = 0x0750, |
| 277 | [TLFRCR] = 0x0758, |
| 278 | [RFCR] = 0x0760, |
| 279 | [CERCR] = 0x0768, |
| 280 | [CEECR] = 0x0770, |
| 281 | [MAFCR] = 0x0778, |
| 282 | [RMII_MII] = 0x0790, |
| 283 | }; |
| 284 | |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 285 | static const u16 sh_eth_offset_fast_sh4[SH_ETH_MAX_REGISTER_OFFSET] = { |
| 286 | [ECMR] = 0x0100, |
| 287 | [RFLR] = 0x0108, |
| 288 | [ECSR] = 0x0110, |
| 289 | [ECSIPR] = 0x0118, |
| 290 | [PIR] = 0x0120, |
| 291 | [PSR] = 0x0128, |
| 292 | [RDMLR] = 0x0140, |
| 293 | [IPGR] = 0x0150, |
| 294 | [APR] = 0x0154, |
| 295 | [MPR] = 0x0158, |
| 296 | [TPAUSER] = 0x0164, |
| 297 | [RFCF] = 0x0160, |
| 298 | [TPAUSECR] = 0x0168, |
| 299 | [BCFRR] = 0x016c, |
| 300 | [MAHR] = 0x01c0, |
| 301 | [MALR] = 0x01c8, |
| 302 | [TROCR] = 0x01d0, |
| 303 | [CDCR] = 0x01d4, |
| 304 | [LCCR] = 0x01d8, |
| 305 | [CNDCR] = 0x01dc, |
| 306 | [CEFCR] = 0x01e4, |
| 307 | [FRECR] = 0x01e8, |
| 308 | [TSFRCR] = 0x01ec, |
| 309 | [TLFRCR] = 0x01f0, |
| 310 | [RFCR] = 0x01f4, |
| 311 | [MAFCR] = 0x01f8, |
| 312 | [RTRATE] = 0x01fc, |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 313 | |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 314 | [EDMR] = 0x0000, |
| 315 | [EDTRR] = 0x0008, |
| 316 | [EDRRR] = 0x0010, |
| 317 | [TDLAR] = 0x0018, |
| 318 | [RDLAR] = 0x0020, |
| 319 | [EESR] = 0x0028, |
| 320 | [EESIPR] = 0x0030, |
| 321 | [TRSCER] = 0x0038, |
| 322 | [RMFCR] = 0x0040, |
| 323 | [TFTR] = 0x0048, |
| 324 | [FDR] = 0x0050, |
| 325 | [RMCR] = 0x0058, |
| 326 | [TFUCR] = 0x0064, |
| 327 | [RFOCR] = 0x0068, |
Nobuhiro Iwamatsu | 72befd3 | 2013-08-22 13:22:04 +0900 | [diff] [blame] | 328 | [RMIIMR] = 0x006C, |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 329 | [FCFTR] = 0x0070, |
| 330 | [RPADIR] = 0x0078, |
| 331 | [TRIMD] = 0x007c, |
| 332 | [RBWAR] = 0x00c8, |
| 333 | [RDFAR] = 0x00cc, |
| 334 | [TBRAR] = 0x00d4, |
| 335 | [TDFAR] = 0x00d8, |
| 336 | }; |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 337 | |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 338 | /* Register Address */ |
| 339 | #if defined(CONFIG_CPU_SH7763) || defined(CONFIG_CPU_SH7734) |
| 340 | #define SH_ETH_TYPE_GETHER |
| 341 | #define BASE_IO_ADDR 0xfee00000 |
Yoshihiro Shimoda | c5901fb | 2013-12-18 16:04:04 +0900 | [diff] [blame] | 342 | #elif defined(CONFIG_CPU_SH7757) || \ |
| 343 | defined(CONFIG_CPU_SH7752) || \ |
| 344 | defined(CONFIG_CPU_SH7753) |
Yoshihiro Shimoda | 3694490 | 2012-06-26 16:38:11 +0000 | [diff] [blame] | 345 | #if defined(CONFIG_SH_ETHER_USE_GETHER) |
| 346 | #define SH_ETH_TYPE_GETHER |
| 347 | #define BASE_IO_ADDR 0xfee00000 |
| 348 | #else |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 349 | #define SH_ETH_TYPE_ETHER |
Yoshihiro Shimoda | 34cca92 | 2011-01-18 17:53:45 +0900 | [diff] [blame] | 350 | #define BASE_IO_ADDR 0xfef00000 |
Yoshihiro Shimoda | 3694490 | 2012-06-26 16:38:11 +0000 | [diff] [blame] | 351 | #endif |
Nobuhiro Iwamatsu | 4ad2c2a | 2012-08-02 22:08:40 +0000 | [diff] [blame] | 352 | #elif defined(CONFIG_R8A7740) |
| 353 | #define SH_ETH_TYPE_GETHER |
| 354 | #define BASE_IO_ADDR 0xE9A00000 |
Marek Vasut | ee2f21b | 2018-01-22 01:42:32 +0100 | [diff] [blame] | 355 | #elif defined(CONFIG_RCAR_GEN2) |
Nobuhiro Iwamatsu | 72befd3 | 2013-08-22 13:22:04 +0900 | [diff] [blame] | 356 | #define SH_ETH_TYPE_ETHER |
| 357 | #define BASE_IO_ADDR 0xEE700200 |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 358 | #elif defined(CONFIG_R7S72100) |
| 359 | #define SH_ETH_TYPE_RZ |
| 360 | #define BASE_IO_ADDR 0xE8203000 |
Yoshihiro Shimoda | 34cca92 | 2011-01-18 17:53:45 +0900 | [diff] [blame] | 361 | #endif |
| 362 | |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 363 | /* |
| 364 | * Register's bits |
| 365 | * Copy from Linux driver source code |
| 366 | */ |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 367 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 368 | /* EDSR */ |
| 369 | enum EDSR_BIT { |
| 370 | EDSR_ENT = 0x01, EDSR_ENR = 0x02, |
| 371 | }; |
| 372 | #define EDSR_ENALL (EDSR_ENT|EDSR_ENR) |
| 373 | #endif |
| 374 | |
| 375 | /* EDMR */ |
| 376 | enum DMAC_M_BIT { |
| 377 | EDMR_DL1 = 0x20, EDMR_DL0 = 0x10, |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 378 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 5880290 | 2012-02-02 21:28:49 +0000 | [diff] [blame] | 379 | EDMR_SRST = 0x03, /* Receive/Send reset */ |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 380 | EMDR_DESC_R = 0x30, /* Descriptor reserve size */ |
| 381 | EDMR_EL = 0x40, /* Litte endian */ |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 382 | #elif defined(SH_ETH_TYPE_ETHER) |
Yoshihiro Shimoda | 34cca92 | 2011-01-18 17:53:45 +0900 | [diff] [blame] | 383 | EDMR_SRST = 0x01, |
| 384 | EMDR_DESC_R = 0x30, /* Descriptor reserve size */ |
| 385 | EDMR_EL = 0x40, /* Litte endian */ |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 386 | #else |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 387 | EDMR_SRST = 0x01, |
| 388 | #endif |
| 389 | }; |
| 390 | |
Nobuhiro Iwamatsu | 7a2142c | 2013-08-22 13:22:02 +0900 | [diff] [blame] | 391 | #if CONFIG_SH_ETHER_ALIGNE_SIZE == 64 |
| 392 | # define EMDR_DESC EDMR_DL1 |
| 393 | #elif CONFIG_SH_ETHER_ALIGNE_SIZE == 32 |
| 394 | # define EMDR_DESC EDMR_DL0 |
| 395 | #elif CONFIG_SH_ETHER_ALIGNE_SIZE == 16 /* Default */ |
| 396 | # define EMDR_DESC 0 |
| 397 | #endif |
| 398 | |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 399 | /* RFLR */ |
| 400 | #define RFLR_RFL_MIN 0x05EE /* Recv Frame length 1518 byte */ |
| 401 | |
| 402 | /* EDTRR */ |
| 403 | enum DMAC_T_BIT { |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 404 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 405 | EDTRR_TRNS = 0x03, |
| 406 | #else |
| 407 | EDTRR_TRNS = 0x01, |
| 408 | #endif |
| 409 | }; |
| 410 | |
| 411 | /* GECMR */ |
| 412 | enum GECMR_BIT { |
Yoshihiro Shimoda | c5901fb | 2013-12-18 16:04:04 +0900 | [diff] [blame] | 413 | #if defined(CONFIG_CPU_SH7757) || \ |
| 414 | defined(CONFIG_CPU_SH7752) || \ |
| 415 | defined(CONFIG_CPU_SH7753) |
Yoshihiro Shimoda | 3694490 | 2012-06-26 16:38:11 +0000 | [diff] [blame] | 416 | GECMR_1000B = 0x20, GECMR_100B = 0x01, GECMR_10B = 0x00, |
| 417 | #else |
Simon Munton | c2d704f | 2009-02-02 09:44:08 +0000 | [diff] [blame] | 418 | GECMR_1000B = 0x01, GECMR_100B = 0x04, GECMR_10B = 0x00, |
Yoshihiro Shimoda | 3694490 | 2012-06-26 16:38:11 +0000 | [diff] [blame] | 419 | #endif |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 420 | }; |
| 421 | |
| 422 | /* EDRRR*/ |
| 423 | enum EDRRR_R_BIT { |
| 424 | EDRRR_R = 0x01, |
| 425 | }; |
| 426 | |
| 427 | /* TPAUSER */ |
| 428 | enum TPAUSER_BIT { |
| 429 | TPAUSER_TPAUSE = 0x0000ffff, |
| 430 | TPAUSER_UNLIMITED = 0, |
| 431 | }; |
| 432 | |
| 433 | /* BCFR */ |
| 434 | enum BCFR_BIT { |
| 435 | BCFR_RPAUSE = 0x0000ffff, |
| 436 | BCFR_UNLIMITED = 0, |
| 437 | }; |
| 438 | |
| 439 | /* PIR */ |
| 440 | enum PIR_BIT { |
| 441 | PIR_MDI = 0x08, PIR_MDO = 0x04, PIR_MMD = 0x02, PIR_MDC = 0x01, |
| 442 | }; |
| 443 | |
| 444 | /* PSR */ |
| 445 | enum PHY_STATUS_BIT { PHY_ST_LINK = 0x01, }; |
| 446 | |
| 447 | /* EESR */ |
| 448 | enum EESR_BIT { |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 449 | #if defined(SH_ETH_TYPE_ETHER) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 450 | EESR_TWB = 0x40000000, |
| 451 | #else |
| 452 | EESR_TWB = 0xC0000000, |
| 453 | EESR_TC1 = 0x20000000, |
| 454 | EESR_TUC = 0x10000000, |
| 455 | EESR_ROC = 0x80000000, |
| 456 | #endif |
| 457 | EESR_TABT = 0x04000000, |
| 458 | EESR_RABT = 0x02000000, EESR_RFRMER = 0x01000000, |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 459 | #if defined(SH_ETH_TYPE_ETHER) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 460 | EESR_ADE = 0x00800000, |
| 461 | #endif |
| 462 | EESR_ECI = 0x00400000, |
| 463 | EESR_FTC = 0x00200000, EESR_TDE = 0x00100000, |
| 464 | EESR_TFE = 0x00080000, EESR_FRC = 0x00040000, |
| 465 | EESR_RDE = 0x00020000, EESR_RFE = 0x00010000, |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 466 | #if defined(SH_ETH_TYPE_ETHER) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 467 | EESR_CND = 0x00000800, |
| 468 | #endif |
| 469 | EESR_DLC = 0x00000400, |
| 470 | EESR_CD = 0x00000200, EESR_RTO = 0x00000100, |
| 471 | EESR_RMAF = 0x00000080, EESR_CEEF = 0x00000040, |
| 472 | EESR_CELF = 0x00000020, EESR_RRF = 0x00000010, |
Nobuhiro Iwamatsu | 8d14b25 | 2014-01-23 07:52:20 +0900 | [diff] [blame] | 473 | EESR_RTLF = 0x00000008, EESR_RTSF = 0x00000004, |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 474 | EESR_PRE = 0x00000002, EESR_CERF = 0x00000001, |
| 475 | }; |
| 476 | |
| 477 | |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 478 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 479 | # define TX_CHECK (EESR_TC1 | EESR_FTC) |
| 480 | # define EESR_ERR_CHECK (EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE \ |
| 481 | | EESR_RFRMER | EESR_TFE | EESR_TDE | EESR_ECI) |
| 482 | # define TX_ERROR_CEHCK (EESR_TWB | EESR_TABT | EESR_TDE | EESR_TFE) |
| 483 | |
| 484 | #else |
| 485 | # define TX_CHECK (EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | EESR_RTO) |
| 486 | # define EESR_ERR_CHECK (EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE \ |
| 487 | | EESR_RFRMER | EESR_ADE | EESR_TFE | EESR_TDE | EESR_ECI) |
| 488 | # define TX_ERROR_CEHCK (EESR_TWB | EESR_TABT | EESR_ADE | EESR_TDE | EESR_TFE) |
| 489 | #endif |
| 490 | |
| 491 | /* EESIPR */ |
| 492 | enum DMAC_IM_BIT { |
| 493 | DMAC_M_TWB = 0x40000000, DMAC_M_TABT = 0x04000000, |
| 494 | DMAC_M_RABT = 0x02000000, |
| 495 | DMAC_M_RFRMER = 0x01000000, DMAC_M_ADF = 0x00800000, |
| 496 | DMAC_M_ECI = 0x00400000, DMAC_M_FTC = 0x00200000, |
| 497 | DMAC_M_TDE = 0x00100000, DMAC_M_TFE = 0x00080000, |
| 498 | DMAC_M_FRC = 0x00040000, DMAC_M_RDE = 0x00020000, |
| 499 | DMAC_M_RFE = 0x00010000, DMAC_M_TINT4 = 0x00000800, |
| 500 | DMAC_M_TINT3 = 0x00000400, DMAC_M_TINT2 = 0x00000200, |
| 501 | DMAC_M_TINT1 = 0x00000100, DMAC_M_RINT8 = 0x00000080, |
| 502 | DMAC_M_RINT5 = 0x00000010, DMAC_M_RINT4 = 0x00000008, |
| 503 | DMAC_M_RINT3 = 0x00000004, DMAC_M_RINT2 = 0x00000002, |
| 504 | DMAC_M_RINT1 = 0x00000001, |
| 505 | }; |
| 506 | |
| 507 | /* Receive descriptor bit */ |
| 508 | enum RD_STS_BIT { |
| 509 | RD_RACT = 0x80000000, RD_RDLE = 0x40000000, |
| 510 | RD_RFP1 = 0x20000000, RD_RFP0 = 0x10000000, |
| 511 | RD_RFE = 0x08000000, RD_RFS10 = 0x00000200, |
| 512 | RD_RFS9 = 0x00000100, RD_RFS8 = 0x00000080, |
| 513 | RD_RFS7 = 0x00000040, RD_RFS6 = 0x00000020, |
| 514 | RD_RFS5 = 0x00000010, RD_RFS4 = 0x00000008, |
| 515 | RD_RFS3 = 0x00000004, RD_RFS2 = 0x00000002, |
| 516 | RD_RFS1 = 0x00000001, |
| 517 | }; |
| 518 | #define RDF1ST RD_RFP1 |
| 519 | #define RDFEND RD_RFP0 |
| 520 | #define RD_RFP (RD_RFP1|RD_RFP0) |
| 521 | |
| 522 | /* RDFFR*/ |
| 523 | enum RDFFR_BIT { |
| 524 | RDFFR_RDLF = 0x01, |
| 525 | }; |
| 526 | |
| 527 | /* FCFTR */ |
| 528 | enum FCFTR_BIT { |
| 529 | FCFTR_RFF2 = 0x00040000, FCFTR_RFF1 = 0x00020000, |
| 530 | FCFTR_RFF0 = 0x00010000, FCFTR_RFD2 = 0x00000004, |
| 531 | FCFTR_RFD1 = 0x00000002, FCFTR_RFD0 = 0x00000001, |
| 532 | }; |
| 533 | #define FIFO_F_D_RFF (FCFTR_RFF2|FCFTR_RFF1|FCFTR_RFF0) |
| 534 | #define FIFO_F_D_RFD (FCFTR_RFD2|FCFTR_RFD1|FCFTR_RFD0) |
| 535 | |
| 536 | /* Transfer descriptor bit */ |
| 537 | enum TD_STS_BIT { |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 538 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_ETHER) || \ |
| 539 | defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 540 | TD_TACT = 0x80000000, |
| 541 | #else |
| 542 | TD_TACT = 0x7fffffff, |
| 543 | #endif |
| 544 | TD_TDLE = 0x40000000, TD_TFP1 = 0x20000000, |
| 545 | TD_TFP0 = 0x10000000, |
| 546 | }; |
| 547 | #define TDF1ST TD_TFP1 |
| 548 | #define TDFEND TD_TFP0 |
| 549 | #define TD_TFP (TD_TFP1|TD_TFP0) |
| 550 | |
| 551 | /* RMCR */ |
| 552 | enum RECV_RST_BIT { RMCR_RST = 0x01, }; |
| 553 | /* ECMR */ |
| 554 | enum FELIC_MODE_BIT { |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 555 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 31e84df | 2014-01-23 07:52:19 +0900 | [diff] [blame] | 556 | ECMR_TRCCM = 0x04000000, ECMR_RCSC = 0x00800000, |
| 557 | ECMR_DPAD = 0x00200000, ECMR_RZPF = 0x00100000, |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 558 | #endif |
| 559 | ECMR_ZPF = 0x00080000, ECMR_PFR = 0x00040000, ECMR_RXF = 0x00020000, |
| 560 | ECMR_TXF = 0x00010000, ECMR_MCT = 0x00002000, ECMR_PRCEF = 0x00001000, |
| 561 | ECMR_PMDE = 0x00000200, ECMR_RE = 0x00000040, ECMR_TE = 0x00000020, |
| 562 | ECMR_ILB = 0x00000008, ECMR_ELB = 0x00000004, ECMR_DM = 0x00000002, |
| 563 | ECMR_PRM = 0x00000001, |
Nobuhiro Iwamatsu | 9dfac0a | 2011-11-14 16:56:59 +0900 | [diff] [blame] | 564 | #ifdef CONFIG_CPU_SH7724 |
| 565 | ECMR_RTM = 0x00000010, |
Marek Vasut | ee2f21b | 2018-01-22 01:42:32 +0100 | [diff] [blame] | 566 | #elif defined(CONFIG_RCAR_GEN2) |
Nobuhiro Iwamatsu | 72befd3 | 2013-08-22 13:22:04 +0900 | [diff] [blame] | 567 | ECMR_RTM = 0x00000004, |
Nobuhiro Iwamatsu | 9dfac0a | 2011-11-14 16:56:59 +0900 | [diff] [blame] | 568 | #endif |
| 569 | |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 570 | }; |
| 571 | |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 572 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 31e84df | 2014-01-23 07:52:19 +0900 | [diff] [blame] | 573 | #define ECMR_CHG_DM (ECMR_TRCCM | ECMR_RZPF | ECMR_ZPF | ECMR_PFR | \ |
| 574 | ECMR_RXF | ECMR_TXF | ECMR_MCT) |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 575 | #elif defined(SH_ETH_TYPE_ETHER) |
Nobuhiro Iwamatsu | 9dfac0a | 2011-11-14 16:56:59 +0900 | [diff] [blame] | 576 | #define ECMR_CHG_DM (ECMR_ZPF | ECMR_PFR | ECMR_RXF | ECMR_TXF) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 577 | #else |
Yoshihiro Shimoda | 34cca92 | 2011-01-18 17:53:45 +0900 | [diff] [blame] | 578 | #define ECMR_CHG_DM (ECMR_ZPF | ECMR_PFR | ECMR_RXF | ECMR_TXF | ECMR_MCT) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 579 | #endif |
| 580 | |
| 581 | /* ECSR */ |
| 582 | enum ECSR_STATUS_BIT { |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 583 | #if defined(SH_ETH_TYPE_ETHER) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 584 | ECSR_BRCRX = 0x20, ECSR_PSRTO = 0x10, |
| 585 | #endif |
| 586 | ECSR_LCHNG = 0x04, |
| 587 | ECSR_MPD = 0x02, ECSR_ICD = 0x01, |
| 588 | }; |
| 589 | |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 590 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 591 | # define ECSR_INIT (ECSR_ICD | ECSIPR_MPDIP) |
| 592 | #else |
| 593 | # define ECSR_INIT (ECSR_BRCRX | ECSR_PSRTO | \ |
| 594 | ECSR_LCHNG | ECSR_ICD | ECSIPR_MPDIP) |
| 595 | #endif |
| 596 | |
| 597 | /* ECSIPR */ |
| 598 | enum ECSIPR_STATUS_MASK_BIT { |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 599 | #if defined(SH_ETH_TYPE_ETHER) |
Nobuhiro Iwamatsu | d8d74e8 | 2012-06-05 16:39:06 +0000 | [diff] [blame] | 600 | ECSIPR_BRCRXIP = 0x20, |
Nobuhiro Iwamatsu | 5880290 | 2012-02-02 21:28:49 +0000 | [diff] [blame] | 601 | ECSIPR_PSRTOIP = 0x10, |
Yoshihiro Shimoda | 9d55303 | 2012-06-26 16:38:06 +0000 | [diff] [blame] | 602 | #elif defined(SH_ETY_TYPE_GETHER) |
Nobuhiro Iwamatsu | 5880290 | 2012-02-02 21:28:49 +0000 | [diff] [blame] | 603 | ECSIPR_PSRTOIP = 0x10, |
| 604 | ECSIPR_PHYIP = 0x08, |
Nobuhiro Iwamatsu | d8d74e8 | 2012-06-05 16:39:06 +0000 | [diff] [blame] | 605 | #endif |
Nobuhiro Iwamatsu | 5880290 | 2012-02-02 21:28:49 +0000 | [diff] [blame] | 606 | ECSIPR_LCHNGIP = 0x04, |
| 607 | ECSIPR_MPDIP = 0x02, |
| 608 | ECSIPR_ICDIP = 0x01, |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 609 | }; |
| 610 | |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 611 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 612 | # define ECSIPR_INIT (ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP) |
| 613 | #else |
| 614 | # define ECSIPR_INIT (ECSIPR_BRCRXIP | ECSIPR_PSRTOIP | ECSIPR_LCHNGIP | \ |
| 615 | ECSIPR_ICDIP | ECSIPR_MPDIP) |
| 616 | #endif |
| 617 | |
| 618 | /* APR */ |
| 619 | enum APR_BIT { |
| 620 | APR_AP = 0x00000004, |
| 621 | }; |
| 622 | |
| 623 | /* MPR */ |
| 624 | enum MPR_BIT { |
| 625 | MPR_MP = 0x00000006, |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 626 | }; |
| 627 | |
| 628 | /* TRSCER */ |
| 629 | enum DESC_I_BIT { |
| 630 | DESC_I_TINT4 = 0x0800, DESC_I_TINT3 = 0x0400, DESC_I_TINT2 = 0x0200, |
| 631 | DESC_I_TINT1 = 0x0100, DESC_I_RINT8 = 0x0080, DESC_I_RINT5 = 0x0010, |
| 632 | DESC_I_RINT4 = 0x0008, DESC_I_RINT3 = 0x0004, DESC_I_RINT2 = 0x0002, |
| 633 | DESC_I_RINT1 = 0x0001, |
| 634 | }; |
| 635 | |
| 636 | /* RPADIR */ |
| 637 | enum RPADIR_BIT { |
| 638 | RPADIR_PADS1 = 0x20000, RPADIR_PADS0 = 0x10000, |
| 639 | RPADIR_PADR = 0x0003f, |
| 640 | }; |
| 641 | |
Nobuhiro Iwamatsu | 46288f4 | 2014-01-23 07:52:18 +0900 | [diff] [blame] | 642 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Nobuhiro Iwamatsu | 240b723 | 2008-06-11 21:05:00 +0900 | [diff] [blame] | 643 | # define RPADIR_INIT (0x00) |
| 644 | #else |
| 645 | # define RPADIR_INIT (RPADIR_PADS1) |
| 646 | #endif |
| 647 | |
| 648 | /* FDR */ |
| 649 | enum FIFO_SIZE_BIT { |
| 650 | FIFO_SIZE_T = 0x00000700, FIFO_SIZE_R = 0x00000007, |
| 651 | }; |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 652 | |
Nobuhiro Iwamatsu | ec921f1 | 2017-12-01 08:10:32 +0900 | [diff] [blame] | 653 | static inline unsigned long sh_eth_reg_addr(struct sh_eth_info *port, |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 654 | int enum_index) |
| 655 | { |
Chris Brandt | a65a929 | 2017-11-03 08:30:12 -0500 | [diff] [blame] | 656 | #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 657 | const u16 *reg_offset = sh_eth_offset_gigabit; |
| 658 | #elif defined(SH_ETH_TYPE_ETHER) |
| 659 | const u16 *reg_offset = sh_eth_offset_fast_sh4; |
Marek Vasut | 7f6f5ab | 2019-05-01 18:20:48 +0200 | [diff] [blame] | 660 | #elif defined(SH_ETH_TYPE_RZ) |
| 661 | const u16 *reg_offset = sh_eth_offset_rz; |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 662 | #else |
| 663 | #error |
| 664 | #endif |
Nobuhiro Iwamatsu | ec921f1 | 2017-12-01 08:10:32 +0900 | [diff] [blame] | 665 | return (unsigned long)port->iobase + reg_offset[enum_index]; |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 666 | } |
| 667 | |
Nobuhiro Iwamatsu | ec921f1 | 2017-12-01 08:10:32 +0900 | [diff] [blame] | 668 | static inline void sh_eth_write(struct sh_eth_info *port, unsigned long data, |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 669 | int enum_index) |
| 670 | { |
Nobuhiro Iwamatsu | ec921f1 | 2017-12-01 08:10:32 +0900 | [diff] [blame] | 671 | outl(data, sh_eth_reg_addr(port, enum_index)); |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 672 | } |
| 673 | |
Nobuhiro Iwamatsu | ec921f1 | 2017-12-01 08:10:32 +0900 | [diff] [blame] | 674 | static inline unsigned long sh_eth_read(struct sh_eth_info *port, |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 675 | int enum_index) |
| 676 | { |
Nobuhiro Iwamatsu | ec921f1 | 2017-12-01 08:10:32 +0900 | [diff] [blame] | 677 | return inl(sh_eth_reg_addr(port, enum_index)); |
Yoshihiro Shimoda | 4c4aa6c | 2012-06-26 16:38:09 +0000 | [diff] [blame] | 678 | } |