00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 FILE_LICENCE ( GPL_ANY );
00020
00021 #include <stdint.h>
00022 #include <stdlib.h>
00023 #include <unistd.h>
00024 #include <errno.h>
00025 #include <assert.h>
00026 #include <byteswap.h>
00027 #include <console.h>
00028 #include <gpxe/io.h>
00029 #include <gpxe/pci.h>
00030 #include <gpxe/malloc.h>
00031 #include <gpxe/ethernet.h>
00032 #include <gpxe/iobuf.h>
00033 #include <gpxe/netdevice.h>
00034 #include <gpxe/timer.h>
00035 #include <mii.h>
00036 #include "etherfabric.h"
00037 #include "etherfabric_nic.h"
00038
00039
00040
00041
00042
00043
00044
00045
00046 #define EFAB_REGDUMP(...)
00047 #define EFAB_TRACE(...) DBGP(__VA_ARGS__)
00048
00049
00050 #define EFAB_LOG(...) DBG(__VA_ARGS__)
00051 #define EFAB_ERR(...) DBG(__VA_ARGS__)
00052
00053 #define FALCON_USE_IO_BAR 0
00054
00055 #define HZ 100
00056 #define EFAB_BYTE 1
00057
00058
00059
00060
00061
00062
00063
00064 extern int __invalid_queue_size;
00065 #define FQS(_prefix, _x) \
00066 ( ( (_x) == 512 ) ? _prefix ## _SIZE_512 : \
00067 ( ( (_x) == 1024 ) ? _prefix ## _SIZE_1K : \
00068 ( ( (_x) == 2048 ) ? _prefix ## _SIZE_2K : \
00069 ( ( (_x) == 4096) ? _prefix ## _SIZE_4K : \
00070 __invalid_queue_size ) ) ) )
00071
00072
00073 #define EFAB_MAX_FRAME_LEN(mtu) \
00074 ( ( ( ( mtu ) + 4 ) + 7 ) & ~7 )
00075
00076
00077
00078
00079
00080
00081
00082
00083 static void falcon_mdio_write (struct efab_nic *efab, int device,
00084 int location, int value );
00085 static int falcon_mdio_read ( struct efab_nic *efab, int device, int location );
00086
00087
00088 #define GMII_PSSR 0x11
00089
00090
00091 #define LPA_EF_1000FULL 0x00020000
00092 #define LPA_EF_1000HALF 0x00010000
00093 #define LPA_EF_10000FULL 0x00040000
00094 #define LPA_EF_10000HALF 0x00080000
00095
00096 #define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
00097 #define LPA_EF_1000 ( LPA_EF_1000FULL | LPA_EF_1000HALF )
00098 #define LPA_EF_10000 ( LPA_EF_10000FULL | LPA_EF_10000HALF )
00099 #define LPA_EF_DUPLEX ( LPA_10FULL | LPA_100FULL | LPA_EF_1000FULL | \
00100 LPA_EF_10000FULL )
00101
00102
00103 #define LPA_OTHER ~( LPA_10FULL | LPA_10HALF | LPA_100FULL | \
00104 LPA_100HALF | LPA_EF_1000FULL | LPA_EF_1000HALF )
00105
00106
00107 #define PSSR_LSTATUS 0x0400
00108
00109
00110
00111
00112
00113 static unsigned int
00114 gmii_autoneg_advertised ( struct efab_nic *efab )
00115 {
00116 unsigned int mii_advertise;
00117 unsigned int gmii_advertise;
00118
00119
00120 mii_advertise = falcon_mdio_read ( efab, 0, MII_ADVERTISE );
00121 gmii_advertise = ( ( falcon_mdio_read ( efab, 0, MII_CTRL1000 ) >> 8 )
00122 & 0x03 );
00123 return ( ( gmii_advertise << 16 ) | mii_advertise );
00124 }
00125
00126
00127
00128
00129
00130 static unsigned int
00131 gmii_autoneg_lpa ( struct efab_nic *efab )
00132 {
00133 unsigned int mii_lpa;
00134 unsigned int gmii_lpa;
00135
00136
00137 mii_lpa = falcon_mdio_read ( efab, 0, MII_LPA );
00138 gmii_lpa = ( falcon_mdio_read ( efab, 0, MII_STAT1000 ) >> 10 ) & 0x03;
00139 return ( ( gmii_lpa << 16 ) | mii_lpa );
00140 }
00141
00142
00143
00144
00145
00146 static unsigned int
00147 gmii_nway_result ( unsigned int negotiated )
00148 {
00149 unsigned int other_bits;
00150
00151
00152 other_bits = negotiated & LPA_OTHER;
00153
00154 if ( negotiated & LPA_EF_1000FULL )
00155 return ( other_bits | LPA_EF_1000FULL );
00156 else if ( negotiated & LPA_EF_1000HALF )
00157 return ( other_bits | LPA_EF_1000HALF );
00158 else if ( negotiated & LPA_100FULL )
00159 return ( other_bits | LPA_100FULL );
00160 else if ( negotiated & LPA_100BASE4 )
00161 return ( other_bits | LPA_100BASE4 );
00162 else if ( negotiated & LPA_100HALF )
00163 return ( other_bits | LPA_100HALF );
00164 else if ( negotiated & LPA_10FULL )
00165 return ( other_bits | LPA_10FULL );
00166 else return ( other_bits | LPA_10HALF );
00167 }
00168
00169
00170
00171
00172
00173 static int
00174 gmii_link_ok ( struct efab_nic *efab )
00175 {
00176 int status;
00177 int phy_status;
00178
00179
00180
00181
00182
00183
00184 (void) falcon_mdio_read ( efab, 0, MII_BMSR );
00185 status = falcon_mdio_read ( efab, 0, MII_BMSR );
00186
00187
00188
00189
00190 phy_status = falcon_mdio_read ( efab, 0, GMII_PSSR );
00191
00192 return ( ( status & BMSR_LSTATUS ) && ( phy_status & PSSR_LSTATUS ) );
00193 }
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 #define MDIO_MMD_PMAPMD (1)
00205
00206 #define MDIO_MMD_WIS (2)
00207
00208 #define MDIO_MMD_PCS (3)
00209
00210 #define MDIO_MMD_PHYXS (4)
00211
00212 #define MDIO_MMD_DTEXS (5)
00213
00214 #define MDIO_MMD_TC (6)
00215
00216 #define MDIO_MMD_AN (7)
00217
00218
00219 #define MDIO_MMDREG_CTRL1 (0)
00220 #define MDIO_MMDREG_STAT1 (1)
00221 #define MDIO_MMDREG_DEVS0 (5)
00222 #define MDIO_MMDREG_STAT2 (8)
00223
00224
00225
00226 #define MDIO_MMDREG_CTRL1_RESET_LBN (15)
00227 #define MDIO_MMDREG_CTRL1_RESET_WIDTH (1)
00228
00229
00230 #define MDIO_MMDREG_STAT1_FAULT_LBN (7)
00231 #define MDIO_MMDREG_STAT1_FAULT_WIDTH (1)
00232
00233
00234 #define MDIO_MMDREG_STAT1_LINK_LBN (2)
00235 #define MDIO_MMDREG_STAT1_LINK_WIDTH (1)
00236
00237
00238 #define DEV_PRESENT_BIT(_b) (1 << _b)
00239
00240 #define MDIO_MMDREG_DEVS0_DTEXS DEV_PRESENT_BIT(MDIO_MMD_DTEXS)
00241 #define MDIO_MMDREG_DEVS0_PHYXS DEV_PRESENT_BIT(MDIO_MMD_PHYXS)
00242 #define MDIO_MMDREG_DEVS0_PCS DEV_PRESENT_BIT(MDIO_MMD_PCS)
00243 #define MDIO_MMDREG_DEVS0_WIS DEV_PRESENT_BIT(MDIO_MMD_WIS)
00244 #define MDIO_MMDREG_DEVS0_PMAPMD DEV_PRESENT_BIT(MDIO_MMD_PMAPMD)
00245
00246 #define MDIO_MMDREG_DEVS0_AN DEV_PRESENT_BIT(MDIO_MMD_AN)
00247
00248
00249 #define MDIO_MMDREG_STAT2_PRESENT_VAL (2)
00250 #define MDIO_MMDREG_STAT2_PRESENT_LBN (14)
00251 #define MDIO_MMDREG_STAT2_PRESENT_WIDTH (2)
00252
00253
00254 #define MDIO_PHYXS_LANE_STATE (0x18)
00255 #define MDIO_PHYXS_LANE_ALIGNED_LBN (12)
00256 #define MDIO_PHYXS_LANE_SYNC0_LBN (0)
00257 #define MDIO_PHYXS_LANE_SYNC1_LBN (1)
00258 #define MDIO_PHYXS_LANE_SYNC2_LBN (2)
00259 #define MDIO_PHYXS_LANE_SYNC3_LBN (3)
00260
00261
00262 #define MDIO45_RESET_TRIES 100
00263 #define MDIO45_RESET_SPINTIME 10
00264
00265 static int
00266 mdio_clause45_wait_reset_mmds ( struct efab_nic* efab )
00267 {
00268 int tries = MDIO45_RESET_TRIES;
00269 int in_reset;
00270
00271 while(tries) {
00272 int mask = efab->phy_op->mmds;
00273 int mmd = 0;
00274 in_reset = 0;
00275 while(mask) {
00276 if (mask & 1) {
00277 int stat = falcon_mdio_read ( efab, mmd,
00278 MDIO_MMDREG_CTRL1 );
00279 if (stat < 0) {
00280 EFAB_ERR("Failed to read status of MMD %d\n",
00281 mmd );
00282 in_reset = 1;
00283 break;
00284 }
00285 if (stat & (1 << MDIO_MMDREG_CTRL1_RESET_LBN))
00286 in_reset |= (1 << mmd);
00287 }
00288 mask = mask >> 1;
00289 mmd++;
00290 }
00291 if (!in_reset)
00292 break;
00293 tries--;
00294 mdelay ( MDIO45_RESET_SPINTIME );
00295 }
00296 if (in_reset != 0) {
00297 EFAB_ERR("Not all MMDs came out of reset in time. MMDs "
00298 "still in reset: %x\n", in_reset);
00299 return -ETIMEDOUT;
00300 }
00301 return 0;
00302 }
00303
00304 static int
00305 mdio_clause45_reset_mmd ( struct efab_nic *efab, int mmd )
00306 {
00307 int tries = MDIO45_RESET_TRIES;
00308 int ctrl;
00309
00310 falcon_mdio_write ( efab, mmd, MDIO_MMDREG_CTRL1,
00311 ( 1 << MDIO_MMDREG_CTRL1_RESET_LBN ) );
00312
00313
00314 do {
00315 mdelay ( MDIO45_RESET_SPINTIME );
00316
00317 ctrl = falcon_mdio_read ( efab, mmd, MDIO_MMDREG_CTRL1 );
00318 if ( ~ctrl & ( 1 << MDIO_MMDREG_CTRL1_RESET_LBN ) )
00319 return 0;
00320 } while ( --tries );
00321
00322 EFAB_ERR ( "Failed to reset mmd %d\n", mmd );
00323
00324 return -ETIMEDOUT;
00325 }
00326
00327 static int
00328 mdio_clause45_links_ok(struct efab_nic *efab )
00329 {
00330 int status, good;
00331 int ok = 1;
00332 int mmd = 0;
00333 int mmd_mask = efab->phy_op->mmds;
00334
00335 while (mmd_mask) {
00336 if (mmd_mask & 1) {
00337
00338
00339 status = falcon_mdio_read ( efab, mmd,
00340 MDIO_MMDREG_STAT1 );
00341 status = falcon_mdio_read ( efab, mmd,
00342 MDIO_MMDREG_STAT1 );
00343
00344 good = status & (1 << MDIO_MMDREG_STAT1_LINK_LBN);
00345 ok = ok && good;
00346 }
00347 mmd_mask = (mmd_mask >> 1);
00348 mmd++;
00349 }
00350 return ok;
00351 }
00352
00353 static int
00354 mdio_clause45_check_mmds ( struct efab_nic *efab )
00355 {
00356 int mmd = 0;
00357 int devices = falcon_mdio_read ( efab, MDIO_MMD_PHYXS,
00358 MDIO_MMDREG_DEVS0 );
00359 int mmd_mask = efab->phy_op->mmds;
00360
00361
00362 if ( devices < 0 ) {
00363 EFAB_ERR ( "Failed to read devices present\n" );
00364 return -EIO;
00365 }
00366 if ( ( devices & mmd_mask ) != mmd_mask ) {
00367 EFAB_ERR ( "required MMDs not present: got %x, wanted %x\n",
00368 devices, mmd_mask );
00369 return -EIO;
00370 }
00371
00372
00373 while ( mmd_mask ) {
00374 if ( mmd_mask & 1 ) {
00375 efab_dword_t reg;
00376 int status;
00377 reg.opaque = falcon_mdio_read ( efab, mmd,
00378 MDIO_MMDREG_STAT2 );
00379 status = EFAB_DWORD_FIELD ( reg,
00380 MDIO_MMDREG_STAT2_PRESENT );
00381 if ( status != MDIO_MMDREG_STAT2_PRESENT_VAL ) {
00382
00383
00384 return -EIO;
00385 }
00386 }
00387 mmd_mask >>= 1;
00388 mmd++;
00389 }
00390
00391 return 0;
00392 }
00393
00394
00395 #define FCN_IOM_IND_ADR_REG 0x0
00396
00397
00398 #define FCN_IOM_IND_DAT_REG 0x4
00399
00400
00401 #define FCN_ADR_REGION_REG_KER 0x00
00402 #define FCN_ADR_REGION0_LBN 0
00403 #define FCN_ADR_REGION0_WIDTH 18
00404 #define FCN_ADR_REGION1_LBN 32
00405 #define FCN_ADR_REGION1_WIDTH 18
00406 #define FCN_ADR_REGION2_LBN 64
00407 #define FCN_ADR_REGION2_WIDTH 18
00408 #define FCN_ADR_REGION3_LBN 96
00409 #define FCN_ADR_REGION3_WIDTH 18
00410
00411
00412 #define FCN_INT_EN_REG_KER 0x0010
00413 #define FCN_MEM_PERR_INT_EN_KER_LBN 5
00414 #define FCN_MEM_PERR_INT_EN_KER_WIDTH 1
00415 #define FCN_KER_INT_CHAR_LBN 4
00416 #define FCN_KER_INT_CHAR_WIDTH 1
00417 #define FCN_KER_INT_KER_LBN 3
00418 #define FCN_KER_INT_KER_WIDTH 1
00419 #define FCN_ILL_ADR_ERR_INT_EN_KER_LBN 2
00420 #define FCN_ILL_ADR_ERR_INT_EN_KER_WIDTH 1
00421 #define FCN_SRM_PERR_INT_EN_KER_LBN 1
00422 #define FCN_SRM_PERR_INT_EN_KER_WIDTH 1
00423 #define FCN_DRV_INT_EN_KER_LBN 0
00424 #define FCN_DRV_INT_EN_KER_WIDTH 1
00425
00426
00427 #define FCN_INT_ADR_REG_KER 0x0030
00428 #define FCN_INT_ADR_KER_LBN 0
00429 #define FCN_INT_ADR_KER_WIDTH EFAB_DMA_TYPE_WIDTH ( 64 )
00430
00431
00432 #define INT_ISR0_B0 0x90
00433 #define INT_ISR1_B0 0xA0
00434
00435
00436 #define FCN_INT_ACK_KER_REG_A1 0x0050
00437 #define INT_ACK_DUMMY_DATA_LBN 0
00438 #define INT_ACK_DUMMY_DATA_WIDTH 32
00439
00440
00441 #define WORK_AROUND_BROKEN_PCI_READS_REG_KER_A1 0x0070
00442
00443
00444 #define FCN_HW_INIT_REG_KER 0x00c0
00445 #define FCN_BCSR_TARGET_MASK_LBN 101
00446 #define FCN_BCSR_TARGET_MASK_WIDTH 4
00447
00448
00449 #define FCN_EE_SPI_HCMD_REG 0x0100
00450 #define FCN_EE_SPI_HCMD_CMD_EN_LBN 31
00451 #define FCN_EE_SPI_HCMD_CMD_EN_WIDTH 1
00452 #define FCN_EE_WR_TIMER_ACTIVE_LBN 28
00453 #define FCN_EE_WR_TIMER_ACTIVE_WIDTH 1
00454 #define FCN_EE_SPI_HCMD_SF_SEL_LBN 24
00455 #define FCN_EE_SPI_HCMD_SF_SEL_WIDTH 1
00456 #define FCN_EE_SPI_EEPROM 0
00457 #define FCN_EE_SPI_FLASH 1
00458 #define FCN_EE_SPI_HCMD_DABCNT_LBN 16
00459 #define FCN_EE_SPI_HCMD_DABCNT_WIDTH 5
00460 #define FCN_EE_SPI_HCMD_READ_LBN 15
00461 #define FCN_EE_SPI_HCMD_READ_WIDTH 1
00462 #define FCN_EE_SPI_READ 1
00463 #define FCN_EE_SPI_WRITE 0
00464 #define FCN_EE_SPI_HCMD_DUBCNT_LBN 12
00465 #define FCN_EE_SPI_HCMD_DUBCNT_WIDTH 2
00466 #define FCN_EE_SPI_HCMD_ADBCNT_LBN 8
00467 #define FCN_EE_SPI_HCMD_ADBCNT_WIDTH 2
00468 #define FCN_EE_SPI_HCMD_ENC_LBN 0
00469 #define FCN_EE_SPI_HCMD_ENC_WIDTH 8
00470
00471
00472 #define FCN_EE_SPI_HADR_REG 0x0110
00473 #define FCN_EE_SPI_HADR_DUBYTE_LBN 24
00474 #define FCN_EE_SPI_HADR_DUBYTE_WIDTH 8
00475 #define FCN_EE_SPI_HADR_ADR_LBN 0
00476 #define FCN_EE_SPI_HADR_ADR_WIDTH 24
00477
00478
00479 #define FCN_EE_SPI_HDATA_REG 0x0120
00480 #define FCN_EE_SPI_HDATA3_LBN 96
00481 #define FCN_EE_SPI_HDATA3_WIDTH 32
00482 #define FCN_EE_SPI_HDATA2_LBN 64
00483 #define FCN_EE_SPI_HDATA2_WIDTH 32
00484 #define FCN_EE_SPI_HDATA1_LBN 32
00485 #define FCN_EE_SPI_HDATA1_WIDTH 32
00486 #define FCN_EE_SPI_HDATA0_LBN 0
00487 #define FCN_EE_SPI_HDATA0_WIDTH 32
00488
00489
00490 #define FCN_EE_VPD_CFG_REG 0x0140
00491 #define FCN_EE_VPD_EN_LBN 0
00492 #define FCN_EE_VPD_EN_WIDTH 1
00493 #define FCN_EE_VPD_EN_AD9_MODE_LBN 1
00494 #define FCN_EE_VPD_EN_AD9_MODE_WIDTH 1
00495 #define FCN_EE_EE_CLOCK_DIV_LBN 112
00496 #define FCN_EE_EE_CLOCK_DIV_WIDTH 7
00497 #define FCN_EE_SF_CLOCK_DIV_LBN 120
00498 #define FCN_EE_SF_CLOCK_DIV_WIDTH 7
00499
00500
00501
00502 #define FCN_NIC_STAT_REG 0x0200
00503 #define FCN_ONCHIP_SRAM_LBN 16
00504 #define FCN_ONCHIP_SRAM_WIDTH 1
00505 #define FCN_SF_PRST_LBN 9
00506 #define FCN_SF_PRST_WIDTH 1
00507 #define FCN_EE_PRST_LBN 8
00508 #define FCN_EE_PRST_WIDTH 1
00509 #define FCN_EE_STRAP_LBN 7
00510 #define FCN_EE_STRAP_WIDTH 1
00511 #define FCN_PCI_PCIX_MODE_LBN 4
00512 #define FCN_PCI_PCIX_MODE_WIDTH 3
00513 #define FCN_PCI_PCIX_MODE_PCI33_DECODE 0
00514 #define FCN_PCI_PCIX_MODE_PCI66_DECODE 1
00515 #define FCN_PCI_PCIX_MODE_PCIX66_DECODE 5
00516 #define FCN_PCI_PCIX_MODE_PCIX100_DECODE 6
00517 #define FCN_PCI_PCIX_MODE_PCIX133_DECODE 7
00518 #define FCN_STRAP_ISCSI_EN_LBN 3
00519 #define FCN_STRAP_ISCSI_EN_WIDTH 1
00520 #define FCN_STRAP_PINS_LBN 0
00521 #define FCN_STRAP_PINS_WIDTH 3
00522 #define FCN_STRAP_10G_LBN 2
00523 #define FCN_STRAP_10G_WIDTH 1
00524 #define FCN_STRAP_DUAL_PORT_LBN 1
00525 #define FCN_STRAP_DUAL_PORT_WIDTH 1
00526 #define FCN_STRAP_PCIE_LBN 0
00527 #define FCN_STRAP_PCIE_WIDTH 1
00528
00529
00530 #define FALCON_REV_A0 0
00531 #define FALCON_REV_A1 1
00532 #define FALCON_REV_B0 2
00533
00534
00535 #define FCN_GPIO_CTL_REG_KER 0x0210
00536 #define FCN_GPIO_CTL_REG_KER 0x0210
00537
00538 #define FCN_GPIO3_OEN_LBN 27
00539 #define FCN_GPIO3_OEN_WIDTH 1
00540 #define FCN_GPIO2_OEN_LBN 26
00541 #define FCN_GPIO2_OEN_WIDTH 1
00542 #define FCN_GPIO1_OEN_LBN 25
00543 #define FCN_GPIO1_OEN_WIDTH 1
00544 #define FCN_GPIO0_OEN_LBN 24
00545 #define FCN_GPIO0_OEN_WIDTH 1
00546
00547 #define FCN_GPIO3_OUT_LBN 19
00548 #define FCN_GPIO3_OUT_WIDTH 1
00549 #define FCN_GPIO2_OUT_LBN 18
00550 #define FCN_GPIO2_OUT_WIDTH 1
00551 #define FCN_GPIO1_OUT_LBN 17
00552 #define FCN_GPIO1_OUT_WIDTH 1
00553 #define FCN_GPIO0_OUT_LBN 16
00554 #define FCN_GPIO0_OUT_WIDTH 1
00555
00556 #define FCN_GPIO3_IN_LBN 11
00557 #define FCN_GPIO3_IN_WIDTH 1
00558 #define FCN_GPIO2_IN_LBN 10
00559 #define FCN_GPIO2_IN_WIDTH 1
00560 #define FCN_GPIO1_IN_LBN 9
00561 #define FCN_GPIO1_IN_WIDTH 1
00562 #define FCN_GPIO0_IN_LBN 8
00563 #define FCN_GPIO0_IN_WIDTH 1
00564
00565 #define FCN_FLASH_PRESENT_LBN 7
00566 #define FCN_FLASH_PRESENT_WIDTH 1
00567 #define FCN_EEPROM_PRESENT_LBN 6
00568 #define FCN_EEPROM_PRESENT_WIDTH 1
00569 #define FCN_BOOTED_USING_NVDEVICE_LBN 3
00570 #define FCN_BOOTED_USING_NVDEVICE_WIDTH 1
00571
00572
00573 #define FCN_NV_MAGIC_NUMBER 0xFA1C
00574
00575
00576 #define FCN_GLB_CTL_REG_KER 0x0220
00577 #define FCN_EXT_PHY_RST_CTL_LBN 63
00578 #define FCN_EXT_PHY_RST_CTL_WIDTH 1
00579 #define FCN_PCIE_SD_RST_CTL_LBN 61
00580 #define FCN_PCIE_SD_RST_CTL_WIDTH 1
00581 #define FCN_PCIE_STCK_RST_CTL_LBN 59
00582 #define FCN_PCIE_STCK_RST_CTL_WIDTH 1
00583 #define FCN_PCIE_NSTCK_RST_CTL_LBN 58
00584 #define FCN_PCIE_NSTCK_RST_CTL_WIDTH 1
00585 #define FCN_PCIE_CORE_RST_CTL_LBN 57
00586 #define FCN_PCIE_CORE_RST_CTL_WIDTH 1
00587 #define FCN_EE_RST_CTL_LBN 49
00588 #define FCN_EE_RST_CTL_WIDTH 1
00589 #define FCN_RST_EXT_PHY_LBN 31
00590 #define FCN_RST_EXT_PHY_WIDTH 1
00591 #define FCN_EXT_PHY_RST_DUR_LBN 1
00592 #define FCN_EXT_PHY_RST_DUR_WIDTH 3
00593 #define FCN_SWRST_LBN 0
00594 #define FCN_SWRST_WIDTH 1
00595 #define INCLUDE_IN_RESET 0
00596 #define EXCLUDE_FROM_RESET 1
00597
00598
00599 #define FCN_ALTERA_BUILD_REG_KER 0x0300
00600 #define FCN_VER_MAJOR_LBN 24
00601 #define FCN_VER_MAJOR_WIDTH 8
00602 #define FCN_VER_MINOR_LBN 16
00603 #define FCN_VER_MINOR_WIDTH 8
00604 #define FCN_VER_BUILD_LBN 0
00605 #define FCN_VER_BUILD_WIDTH 16
00606 #define FCN_VER_ALL_LBN 0
00607 #define FCN_VER_ALL_WIDTH 32
00608
00609
00610 #define FCN_SPARE_REG_KER 0x310
00611 #define FCN_MEM_PERR_EN_TX_DATA_LBN 72
00612 #define FCN_MEM_PERR_EN_TX_DATA_WIDTH 2
00613
00614
00615 #define FCN_TIMER_CMD_REG_KER 0x420
00616 #define FCN_TIMER_MODE_LBN 12
00617 #define FCN_TIMER_MODE_WIDTH 2
00618 #define FCN_TIMER_MODE_DIS 0
00619 #define FCN_TIMER_MODE_INT_HLDOFF 1
00620 #define FCN_TIMER_VAL_LBN 0
00621 #define FCN_TIMER_VAL_WIDTH 12
00622
00623
00624 #define FCN_RX_CFG_REG_KER 0x800
00625 #define FCN_RX_XOFF_EN_LBN 0
00626 #define FCN_RX_XOFF_EN_WIDTH 1
00627
00628
00629 #define FCN_SRM_RX_DC_CFG_REG_KER 0x610
00630 #define FCN_SRM_RX_DC_BASE_ADR_LBN 0
00631 #define FCN_SRM_RX_DC_BASE_ADR_WIDTH 21
00632
00633
00634 #define FCN_SRM_TX_DC_CFG_REG_KER 0x620
00635 #define FCN_SRM_TX_DC_BASE_ADR_LBN 0
00636 #define FCN_SRM_TX_DC_BASE_ADR_WIDTH 21
00637
00638
00639 #define FCN_SRM_CFG_REG_KER 0x630
00640 #define FCN_SRAM_OOB_ADR_INTEN_LBN 5
00641 #define FCN_SRAM_OOB_ADR_INTEN_WIDTH 1
00642 #define FCN_SRAM_OOB_BUF_INTEN_LBN 4
00643 #define FCN_SRAM_OOB_BUF_INTEN_WIDTH 1
00644 #define FCN_SRAM_OOB_BT_INIT_EN_LBN 3
00645 #define FCN_SRAM_OOB_BT_INIT_EN_WIDTH 1
00646 #define FCN_SRM_NUM_BANK_LBN 2
00647 #define FCN_SRM_NUM_BANK_WIDTH 1
00648 #define FCN_SRM_BANK_SIZE_LBN 0
00649 #define FCN_SRM_BANK_SIZE_WIDTH 2
00650 #define FCN_SRM_NUM_BANKS_AND_BANK_SIZE_LBN 0
00651 #define FCN_SRM_NUM_BANKS_AND_BANK_SIZE_WIDTH 3
00652
00653 #define FCN_RX_CFG_REG_KER 0x800
00654 #define FCN_RX_INGR_EN_B0_LBN 47
00655 #define FCN_RX_INGR_EN_B0_WIDTH 1
00656 #define FCN_RX_USR_BUF_SIZE_B0_LBN 19
00657 #define FCN_RX_USR_BUF_SIZE_B0_WIDTH 9
00658 #define FCN_RX_XON_MAC_TH_B0_LBN 10
00659 #define FCN_RX_XON_MAC_TH_B0_WIDTH 9
00660 #define FCN_RX_XOFF_MAC_TH_B0_LBN 1
00661 #define FCN_RX_XOFF_MAC_TH_B0_WIDTH 9
00662 #define FCN_RX_XOFF_MAC_EN_B0_LBN 0
00663 #define FCN_RX_XOFF_MAC_EN_B0_WIDTH 1
00664 #define FCN_RX_USR_BUF_SIZE_A1_LBN 11
00665 #define FCN_RX_USR_BUF_SIZE_A1_WIDTH 9
00666 #define FCN_RX_XON_MAC_TH_A1_LBN 6
00667 #define FCN_RX_XON_MAC_TH_A1_WIDTH 5
00668 #define FCN_RX_XOFF_MAC_TH_A1_LBN 1
00669 #define FCN_RX_XOFF_MAC_TH_A1_WIDTH 5
00670 #define FCN_RX_XOFF_MAC_EN_A1_LBN 0
00671 #define FCN_RX_XOFF_MAC_EN_A1_WIDTH 1
00672
00673 #define FCN_RX_USR_BUF_SIZE_A1_LBN 11
00674 #define FCN_RX_USR_BUF_SIZE_A1_WIDTH 9
00675 #define FCN_RX_XOFF_MAC_EN_A1_LBN 0
00676 #define FCN_RX_XOFF_MAC_EN_A1_WIDTH 1
00677
00678
00679 #define FCN_RX_FILTER_CTL_REG_KER 0x810
00680 #define FCN_UDP_FULL_SRCH_LIMIT_LBN 32
00681 #define FCN_UDP_FULL_SRCH_LIMIT_WIDTH 8
00682 #define FCN_NUM_KER_LBN 24
00683 #define FCN_NUM_KER_WIDTH 2
00684 #define FCN_UDP_WILD_SRCH_LIMIT_LBN 16
00685 #define FCN_UDP_WILD_SRCH_LIMIT_WIDTH 8
00686 #define FCN_TCP_WILD_SRCH_LIMIT_LBN 8
00687 #define FCN_TCP_WILD_SRCH_LIMIT_WIDTH 8
00688 #define FCN_TCP_FULL_SRCH_LIMIT_LBN 0
00689 #define FCN_TCP_FULL_SRCH_LIMIT_WIDTH 8
00690
00691
00692 #define FCN_RX_FLUSH_DESCQ_REG_KER 0x0820
00693 #define FCN_RX_FLUSH_DESCQ_CMD_LBN 24
00694 #define FCN_RX_FLUSH_DESCQ_CMD_WIDTH 1
00695 #define FCN_RX_FLUSH_DESCQ_LBN 0
00696 #define FCN_RX_FLUSH_DESCQ_WIDTH 12
00697
00698
00699 #define FCN_RX_DESC_UPD_REG_KER 0x0830
00700 #define FCN_RX_DESC_WPTR_LBN 96
00701 #define FCN_RX_DESC_WPTR_WIDTH 12
00702 #define FCN_RX_DESC_UPD_REG_KER_DWORD ( FCN_RX_DESC_UPD_REG_KER + 12 )
00703 #define FCN_RX_DESC_WPTR_DWORD_LBN 0
00704 #define FCN_RX_DESC_WPTR_DWORD_WIDTH 12
00705
00706
00707 #define FCN_RX_DC_CFG_REG_KER 0x840
00708 #define FCN_RX_DC_SIZE_LBN 0
00709 #define FCN_RX_DC_SIZE_WIDTH 2
00710
00711 #define FCN_RX_SELF_RST_REG_KER 0x890
00712 #define FCN_RX_ISCSI_DIS_LBN 17
00713 #define FCN_RX_ISCSI_DIS_WIDTH 1
00714 #define FCN_RX_NODESC_WAIT_DIS_LBN 9
00715 #define FCN_RX_NODESC_WAIT_DIS_WIDTH 1
00716 #define FCN_RX_RECOVERY_EN_LBN 8
00717 #define FCN_RX_RECOVERY_EN_WIDTH 1
00718
00719
00720 #define FCN_TX_FLUSH_DESCQ_REG_KER 0x0a00
00721 #define FCN_TX_FLUSH_DESCQ_CMD_LBN 12
00722 #define FCN_TX_FLUSH_DESCQ_CMD_WIDTH 1
00723 #define FCN_TX_FLUSH_DESCQ_LBN 0
00724 #define FCN_TX_FLUSH_DESCQ_WIDTH 12
00725
00726
00727 #define FCN_TX_CFG2_REG_KER 0xa80
00728 #define FCN_TX_DIS_NON_IP_EV_LBN 17
00729 #define FCN_TX_DIS_NON_IP_EV_WIDTH 1
00730
00731
00732 #define FCN_TX_DESC_UPD_REG_KER 0x0a10
00733 #define FCN_TX_DESC_WPTR_LBN 96
00734 #define FCN_TX_DESC_WPTR_WIDTH 12
00735 #define FCN_TX_DESC_UPD_REG_KER_DWORD ( FCN_TX_DESC_UPD_REG_KER + 12 )
00736 #define FCN_TX_DESC_WPTR_DWORD_LBN 0
00737 #define FCN_TX_DESC_WPTR_DWORD_WIDTH 12
00738
00739
00740 #define FCN_TX_DC_CFG_REG_KER 0xa20
00741 #define FCN_TX_DC_SIZE_LBN 0
00742 #define FCN_TX_DC_SIZE_WIDTH 2
00743
00744
00745 #define FCN_MD_TXD_REG_KER 0xc00
00746 #define FCN_MD_TXD_LBN 0
00747 #define FCN_MD_TXD_WIDTH 16
00748
00749
00750 #define FCN_MD_RXD_REG_KER 0xc10
00751 #define FCN_MD_RXD_LBN 0
00752 #define FCN_MD_RXD_WIDTH 16
00753
00754
00755 #define FCN_MD_CS_REG_KER 0xc20
00756 #define FCN_MD_GC_LBN 4
00757 #define FCN_MD_GC_WIDTH 1
00758 #define FCN_MD_RIC_LBN 2
00759 #define FCN_MD_RIC_WIDTH 1
00760 #define FCN_MD_RDC_LBN 1
00761 #define FCN_MD_RDC_WIDTH 1
00762 #define FCN_MD_WRC_LBN 0
00763 #define FCN_MD_WRC_WIDTH 1
00764
00765
00766 #define FCN_MD_PHY_ADR_REG_KER 0xc30
00767 #define FCN_MD_PHY_ADR_LBN 0
00768 #define FCN_MD_PHY_ADR_WIDTH 16
00769
00770
00771 #define FCN_MD_ID_REG_KER 0xc40
00772 #define FCN_MD_PRT_ADR_LBN 11
00773 #define FCN_MD_PRT_ADR_WIDTH 5
00774 #define FCN_MD_DEV_ADR_LBN 6
00775 #define FCN_MD_DEV_ADR_WIDTH 5
00776
00777
00778 #define FCN_MD_STAT_REG_KER 0xc50
00779 #define FCN_MD_PINT_LBN 4
00780 #define FCN_MD_PINT_WIDTH 1
00781 #define FCN_MD_DONE_LBN 3
00782 #define FCN_MD_DONE_WIDTH 1
00783 #define FCN_MD_BSERR_LBN 2
00784 #define FCN_MD_BSERR_WIDTH 1
00785 #define FCN_MD_LNFL_LBN 1
00786 #define FCN_MD_LNFL_WIDTH 1
00787 #define FCN_MD_BSY_LBN 0
00788 #define FCN_MD_BSY_WIDTH 1
00789
00790
00791 #define FCN_MAC0_CTRL_REG_KER 0xc80
00792 #define FCN_MAC1_CTRL_REG_KER 0xc90
00793 #define FCN_MAC_XOFF_VAL_LBN 16
00794 #define FCN_MAC_XOFF_VAL_WIDTH 16
00795 #define FCN_MAC_BCAD_ACPT_LBN 4
00796 #define FCN_MAC_BCAD_ACPT_WIDTH 1
00797 #define FCN_MAC_UC_PROM_LBN 3
00798 #define FCN_MAC_UC_PROM_WIDTH 1
00799 #define FCN_MAC_LINK_STATUS_LBN 2
00800 #define FCN_MAC_LINK_STATUS_WIDTH 1
00801 #define FCN_MAC_SPEED_LBN 0
00802 #define FCN_MAC_SPEED_WIDTH 2
00803
00804
00805 #define XX_TXDRV_DEQ_DEFAULT 0xe
00806 #define XX_TXDRV_DTX_DEFAULT 0x5
00807 #define XX_SD_CTL_DRV_DEFAULT 0
00808
00809
00810 #define FALCON_GMAC_REGBANK 0xe00
00811 #define FALCON_GMAC_REGBANK_SIZE 0x200
00812 #define FALCON_GMAC_REG_SIZE 0x10
00813
00814
00815 #define FALCON_XMAC_REGBANK 0x1200
00816 #define FALCON_XMAC_REGBANK_SIZE 0x200
00817 #define FALCON_XMAC_REG_SIZE 0x10
00818
00819
00820 #define FCN_XM_ADR_LO_REG_MAC 0x00
00821 #define FCN_XM_ADR_3_LBN 24
00822 #define FCN_XM_ADR_3_WIDTH 8
00823 #define FCN_XM_ADR_2_LBN 16
00824 #define FCN_XM_ADR_2_WIDTH 8
00825 #define FCN_XM_ADR_1_LBN 8
00826 #define FCN_XM_ADR_1_WIDTH 8
00827 #define FCN_XM_ADR_0_LBN 0
00828 #define FCN_XM_ADR_0_WIDTH 8
00829
00830
00831 #define FCN_XM_ADR_HI_REG_MAC 0x01
00832 #define FCN_XM_ADR_5_LBN 8
00833 #define FCN_XM_ADR_5_WIDTH 8
00834 #define FCN_XM_ADR_4_LBN 0
00835 #define FCN_XM_ADR_4_WIDTH 8
00836
00837
00838 #define FCN_XM_GLB_CFG_REG_MAC 0x02
00839 #define FCN_XM_RX_STAT_EN_LBN 11
00840 #define FCN_XM_RX_STAT_EN_WIDTH 1
00841 #define FCN_XM_TX_STAT_EN_LBN 10
00842 #define FCN_XM_TX_STAT_EN_WIDTH 1
00843 #define FCN_XM_RX_JUMBO_MODE_LBN 6
00844 #define FCN_XM_RX_JUMBO_MODE_WIDTH 1
00845 #define FCN_XM_CORE_RST_LBN 0
00846 #define FCN_XM_CORE_RST_WIDTH 1
00847
00848
00849 #define FCN_XM_TX_CFG_REG_MAC 0x03
00850 #define FCN_XM_IPG_LBN 16
00851 #define FCN_XM_IPG_WIDTH 4
00852 #define FCN_XM_FCNTL_LBN 10
00853 #define FCN_XM_FCNTL_WIDTH 1
00854 #define FCN_XM_TXCRC_LBN 8
00855 #define FCN_XM_TXCRC_WIDTH 1
00856 #define FCN_XM_AUTO_PAD_LBN 5
00857 #define FCN_XM_AUTO_PAD_WIDTH 1
00858 #define FCN_XM_TX_PRMBL_LBN 2
00859 #define FCN_XM_TX_PRMBL_WIDTH 1
00860 #define FCN_XM_TXEN_LBN 1
00861 #define FCN_XM_TXEN_WIDTH 1
00862
00863
00864 #define FCN_XM_RX_CFG_REG_MAC 0x04
00865 #define FCN_XM_PASS_CRC_ERR_LBN 25
00866 #define FCN_XM_PASS_CRC_ERR_WIDTH 1
00867 #define FCN_XM_AUTO_DEPAD_LBN 8
00868 #define FCN_XM_AUTO_DEPAD_WIDTH 1
00869 #define FCN_XM_RXEN_LBN 1
00870 #define FCN_XM_RXEN_WIDTH 1
00871
00872
00873 #define FCN_XM_MGT_INT_MSK_REG_MAC_B0 0x5
00874 #define FCN_XM_MSK_PRMBLE_ERR_LBN 2
00875 #define FCN_XM_MSK_PRMBLE_ERR_WIDTH 1
00876 #define FCN_XM_MSK_RMTFLT_LBN 1
00877 #define FCN_XM_MSK_RMTFLT_WIDTH 1
00878 #define FCN_XM_MSK_LCLFLT_LBN 0
00879 #define FCN_XM_MSK_LCLFLT_WIDTH 1
00880
00881
00882 #define FCN_XM_FC_REG_MAC 0x7
00883 #define FCN_XM_PAUSE_TIME_LBN 16
00884 #define FCN_XM_PAUSE_TIME_WIDTH 16
00885 #define FCN_XM_DIS_FCNTL_LBN 0
00886 #define FCN_XM_DIS_FCNTL_WIDTH 1
00887
00888
00889 #define FCN_XM_TX_PARAM_REG_MAC 0x0d
00890 #define FCN_XM_TX_JUMBO_MODE_LBN 31
00891 #define FCN_XM_TX_JUMBO_MODE_WIDTH 1
00892 #define FCN_XM_MAX_TX_FRM_SIZE_LBN 16
00893 #define FCN_XM_MAX_TX_FRM_SIZE_WIDTH 14
00894 #define FCN_XM_ACPT_ALL_MCAST_LBN 11
00895 #define FCN_XM_ACPT_ALL_MCAST_WIDTH 1
00896
00897
00898 #define FCN_XM_RX_PARAM_REG_MAC 0x0e
00899 #define FCN_XM_MAX_RX_FRM_SIZE_LBN 0
00900 #define FCN_XM_MAX_RX_FRM_SIZE_WIDTH 14
00901
00902
00903 #define FCN_XM_MGT_INT_REG_MAC_B0 0x0f
00904 #define FCN_XM_PRMBLE_ERR 2
00905 #define FCN_XM_PRMBLE_WIDTH 1
00906 #define FCN_XM_RMTFLT_LBN 1
00907 #define FCN_XM_RMTFLT_WIDTH 1
00908 #define FCN_XM_LCLFLT_LBN 0
00909 #define FCN_XM_LCLFLT_WIDTH 1
00910
00911
00912 #define FCN_XX_ALIGN_DONE_LBN 20
00913 #define FCN_XX_ALIGN_DONE_WIDTH 1
00914 #define FCN_XX_CORE_STAT_REG_MAC 0x16
00915 #define FCN_XX_SYNC_STAT_LBN 16
00916 #define FCN_XX_SYNC_STAT_WIDTH 4
00917 #define FCN_XX_SYNC_STAT_DECODE_SYNCED 0xf
00918 #define FCN_XX_COMMA_DET_LBN 12
00919 #define FCN_XX_COMMA_DET_WIDTH 4
00920 #define FCN_XX_COMMA_DET_RESET 0xf
00921 #define FCN_XX_CHARERR_LBN 4
00922 #define FCN_XX_CHARERR_WIDTH 4
00923 #define FCN_XX_CHARERR_RESET 0xf
00924 #define FCN_XX_DISPERR_LBN 0
00925 #define FCN_XX_DISPERR_WIDTH 4
00926 #define FCN_XX_DISPERR_RESET 0xf
00927
00928
00929 #define FCN_XX_PWR_RST_REG_MAC 0x10
00930 #define FCN_XX_PWRDND_EN_LBN 15
00931 #define FCN_XX_PWRDND_EN_WIDTH 1
00932 #define FCN_XX_PWRDNC_EN_LBN 14
00933 #define FCN_XX_PWRDNC_EN_WIDTH 1
00934 #define FCN_XX_PWRDNB_EN_LBN 13
00935 #define FCN_XX_PWRDNB_EN_WIDTH 1
00936 #define FCN_XX_PWRDNA_EN_LBN 12
00937 #define FCN_XX_PWRDNA_EN_WIDTH 1
00938 #define FCN_XX_RSTPLLCD_EN_LBN 9
00939 #define FCN_XX_RSTPLLCD_EN_WIDTH 1
00940 #define FCN_XX_RSTPLLAB_EN_LBN 8
00941 #define FCN_XX_RSTPLLAB_EN_WIDTH 1
00942 #define FCN_XX_RESETD_EN_LBN 7
00943 #define FCN_XX_RESETD_EN_WIDTH 1
00944 #define FCN_XX_RESETC_EN_LBN 6
00945 #define FCN_XX_RESETC_EN_WIDTH 1
00946 #define FCN_XX_RESETB_EN_LBN 5
00947 #define FCN_XX_RESETB_EN_WIDTH 1
00948 #define FCN_XX_RESETA_EN_LBN 4
00949 #define FCN_XX_RESETA_EN_WIDTH 1
00950 #define FCN_XX_RSTXGXSRX_EN_LBN 2
00951 #define FCN_XX_RSTXGXSRX_EN_WIDTH 1
00952 #define FCN_XX_RSTXGXSTX_EN_LBN 1
00953 #define FCN_XX_RSTXGXSTX_EN_WIDTH 1
00954 #define FCN_XX_RST_XX_EN_LBN 0
00955 #define FCN_XX_RST_XX_EN_WIDTH 1
00956
00957
00958
00959 #define FCN_XX_SD_CTL_REG_MAC 0x11
00960 #define FCN_XX_TERMADJ1_LBN 17
00961 #define FCN_XX_TERMADJ1_WIDTH 1
00962 #define FCN_XX_TERMADJ0_LBN 16
00963 #define FCN_XX_TERMADJ0_WIDTH 1
00964 #define FCN_XX_HIDRVD_LBN 15
00965 #define FCN_XX_HIDRVD_WIDTH 1
00966 #define FCN_XX_LODRVD_LBN 14
00967 #define FCN_XX_LODRVD_WIDTH 1
00968 #define FCN_XX_HIDRVC_LBN 13
00969 #define FCN_XX_HIDRVC_WIDTH 1
00970 #define FCN_XX_LODRVC_LBN 12
00971 #define FCN_XX_LODRVC_WIDTH 1
00972 #define FCN_XX_HIDRVB_LBN 11
00973 #define FCN_XX_HIDRVB_WIDTH 1
00974 #define FCN_XX_LODRVB_LBN 10
00975 #define FCN_XX_LODRVB_WIDTH 1
00976 #define FCN_XX_HIDRVA_LBN 9
00977 #define FCN_XX_HIDRVA_WIDTH 1
00978 #define FCN_XX_LODRVA_LBN 8
00979 #define FCN_XX_LODRVA_WIDTH 1
00980 #define FCN_XX_LPBKD_LBN 3
00981 #define FCN_XX_LPBKD_WIDTH 1
00982 #define FCN_XX_LPBKC_LBN 2
00983 #define FCN_XX_LPBKC_WIDTH 1
00984 #define FCN_XX_LPBKB_LBN 1
00985 #define FCN_XX_LPBKB_WIDTH 1
00986 #define FCN_XX_LPBKA_LBN 0
00987 #define FCN_XX_LPBKA_WIDTH 1
00988
00989 #define FCN_XX_TXDRV_CTL_REG_MAC 0x12
00990 #define FCN_XX_DEQD_LBN 28
00991 #define FCN_XX_DEQD_WIDTH 4
00992 #define FCN_XX_DEQC_LBN 24
00993 #define FCN_XX_DEQC_WIDTH 4
00994 #define FCN_XX_DEQB_LBN 20
00995 #define FCN_XX_DEQB_WIDTH 4
00996 #define FCN_XX_DEQA_LBN 16
00997 #define FCN_XX_DEQA_WIDTH 4
00998 #define FCN_XX_DTXD_LBN 12
00999 #define FCN_XX_DTXD_WIDTH 4
01000 #define FCN_XX_DTXC_LBN 8
01001 #define FCN_XX_DTXC_WIDTH 4
01002 #define FCN_XX_DTXB_LBN 4
01003 #define FCN_XX_DTXB_WIDTH 4
01004 #define FCN_XX_DTXA_LBN 0
01005 #define FCN_XX_DTXA_WIDTH 4
01006
01007
01008 #define FCN_RX_FILTER_TBL0 0xF00000
01009
01010
01011 #define FCN_RX_DESC_PTR_TBL_KER_A1 0x11800
01012 #define FCN_RX_DESC_PTR_TBL_KER_B0 0xF40000
01013 #define FCN_RX_ISCSI_DDIG_EN_LBN 88
01014 #define FCN_RX_ISCSI_DDIG_EN_WIDTH 1
01015 #define FCN_RX_ISCSI_HDIG_EN_LBN 87
01016 #define FCN_RX_ISCSI_HDIG_EN_WIDTH 1
01017 #define FCN_RX_DESCQ_BUF_BASE_ID_LBN 36
01018 #define FCN_RX_DESCQ_BUF_BASE_ID_WIDTH 20
01019 #define FCN_RX_DESCQ_EVQ_ID_LBN 24
01020 #define FCN_RX_DESCQ_EVQ_ID_WIDTH 12
01021 #define FCN_RX_DESCQ_OWNER_ID_LBN 10
01022 #define FCN_RX_DESCQ_OWNER_ID_WIDTH 14
01023 #define FCN_RX_DESCQ_SIZE_LBN 3
01024 #define FCN_RX_DESCQ_SIZE_WIDTH 2
01025 #define FCN_RX_DESCQ_SIZE_4K 3
01026 #define FCN_RX_DESCQ_SIZE_2K 2
01027 #define FCN_RX_DESCQ_SIZE_1K 1
01028 #define FCN_RX_DESCQ_SIZE_512 0
01029 #define FCN_RX_DESCQ_TYPE_LBN 2
01030 #define FCN_RX_DESCQ_TYPE_WIDTH 1
01031 #define FCN_RX_DESCQ_JUMBO_LBN 1
01032 #define FCN_RX_DESCQ_JUMBO_WIDTH 1
01033 #define FCN_RX_DESCQ_EN_LBN 0
01034 #define FCN_RX_DESCQ_EN_WIDTH 1
01035
01036
01037 #define FCN_TX_DESC_PTR_TBL_KER_A1 0x11900
01038 #define FCN_TX_DESC_PTR_TBL_KER_B0 0xF50000
01039 #define FCN_TX_NON_IP_DROP_DIS_B0_LBN 91
01040 #define FCN_TX_NON_IP_DROP_DIS_B0_WIDTH 1
01041 #define FCN_TX_DESCQ_EN_LBN 88
01042 #define FCN_TX_DESCQ_EN_WIDTH 1
01043 #define FCN_TX_ISCSI_DDIG_EN_LBN 87
01044 #define FCN_TX_ISCSI_DDIG_EN_WIDTH 1
01045 #define FCN_TX_ISCSI_HDIG_EN_LBN 86
01046 #define FCN_TX_ISCSI_HDIG_EN_WIDTH 1
01047 #define FCN_TX_DESCQ_BUF_BASE_ID_LBN 36
01048 #define FCN_TX_DESCQ_BUF_BASE_ID_WIDTH 20
01049 #define FCN_TX_DESCQ_EVQ_ID_LBN 24
01050 #define FCN_TX_DESCQ_EVQ_ID_WIDTH 12
01051 #define FCN_TX_DESCQ_OWNER_ID_LBN 10
01052 #define FCN_TX_DESCQ_OWNER_ID_WIDTH 14
01053 #define FCN_TX_DESCQ_SIZE_LBN 3
01054 #define FCN_TX_DESCQ_SIZE_WIDTH 2
01055 #define FCN_TX_DESCQ_SIZE_4K 3
01056 #define FCN_TX_DESCQ_SIZE_2K 2
01057 #define FCN_TX_DESCQ_SIZE_1K 1
01058 #define FCN_TX_DESCQ_SIZE_512 0
01059 #define FCN_TX_DESCQ_TYPE_LBN 1
01060 #define FCN_TX_DESCQ_TYPE_WIDTH 2
01061 #define FCN_TX_DESCQ_FLUSH_LBN 0
01062 #define FCN_TX_DESCQ_FLUSH_WIDTH 1
01063
01064
01065 #define FCN_EVQ_PTR_TBL_KER_A1 0x11a00
01066 #define FCN_EVQ_PTR_TBL_KER_B0 0xf60000
01067 #define FCN_EVQ_EN_LBN 23
01068 #define FCN_EVQ_EN_WIDTH 1
01069 #define FCN_EVQ_SIZE_LBN 20
01070 #define FCN_EVQ_SIZE_WIDTH 3
01071 #define FCN_EVQ_SIZE_32K 6
01072 #define FCN_EVQ_SIZE_16K 5
01073 #define FCN_EVQ_SIZE_8K 4
01074 #define FCN_EVQ_SIZE_4K 3
01075 #define FCN_EVQ_SIZE_2K 2
01076 #define FCN_EVQ_SIZE_1K 1
01077 #define FCN_EVQ_SIZE_512 0
01078 #define FCN_EVQ_BUF_BASE_ID_LBN 0
01079 #define FCN_EVQ_BUF_BASE_ID_WIDTH 20
01080
01081
01082 #define FCN_RX_RSS_INDIR_TBL_B0 0xFB0000
01083
01084
01085 #define FCN_EVQ_RPTR_REG_KER_A1 0x11b00
01086 #define FCN_EVQ_RPTR_REG_KER_B0 0xfa0000
01087 #define FCN_EVQ_RPTR_LBN 0
01088 #define FCN_EVQ_RPTR_WIDTH 14
01089 #define FCN_EVQ_RPTR_REG_KER_DWORD_A1 ( FCN_EVQ_RPTR_REG_KER_A1 + 0 )
01090 #define FCN_EVQ_RPTR_REG_KER_DWORD_B0 ( FCN_EVQ_RPTR_REG_KER_B0 + 0 )
01091 #define FCN_EVQ_RPTR_DWORD_LBN 0
01092 #define FCN_EVQ_RPTR_DWORD_WIDTH 14
01093
01094
01095 #define FCN_BUF_FULL_TBL_KER_A1 0x18000
01096 #define FCN_BUF_FULL_TBL_KER_B0 0x800000
01097 #define FCN_IP_DAT_BUF_SIZE_LBN 50
01098 #define FCN_IP_DAT_BUF_SIZE_WIDTH 1
01099 #define FCN_IP_DAT_BUF_SIZE_8K 1
01100 #define FCN_IP_DAT_BUF_SIZE_4K 0
01101 #define FCN_BUF_ADR_FBUF_LBN 14
01102 #define FCN_BUF_ADR_FBUF_WIDTH 34
01103 #define FCN_BUF_OWNER_ID_FBUF_LBN 0
01104 #define FCN_BUF_OWNER_ID_FBUF_WIDTH 14
01105
01106
01107 #define FALCON_GMAC_REG( efab, mac_reg ) \
01108 ( FALCON_GMAC_REGBANK + \
01109 ( (mac_reg) * FALCON_GMAC_REG_SIZE ) )
01110
01111
01112 #define FALCON_XMAC_REG( efab_port, mac_reg ) \
01113 ( FALCON_XMAC_REGBANK + \
01114 ( (mac_reg) * FALCON_XMAC_REG_SIZE ) )
01115
01116 #define FCN_MAC_DATA_LBN 0
01117 #define FCN_MAC_DATA_WIDTH 32
01118
01119
01120 #define FCN_TX_KER_PORT_LBN 63
01121 #define FCN_TX_KER_PORT_WIDTH 1
01122 #define FCN_TX_KER_BYTE_CNT_LBN 48
01123 #define FCN_TX_KER_BYTE_CNT_WIDTH 14
01124 #define FCN_TX_KER_BUF_ADR_LBN 0
01125 #define FCN_TX_KER_BUF_ADR_WIDTH EFAB_DMA_TYPE_WIDTH ( 46 )
01126
01127
01128
01129 #define FCN_RX_KER_BUF_SIZE_LBN 48
01130 #define FCN_RX_KER_BUF_SIZE_WIDTH 14
01131 #define FCN_RX_KER_BUF_ADR_LBN 0
01132 #define FCN_RX_KER_BUF_ADR_WIDTH EFAB_DMA_TYPE_WIDTH ( 46 )
01133
01134
01135 #define FCN_EV_CODE_LBN 60
01136 #define FCN_EV_CODE_WIDTH 4
01137 #define FCN_RX_IP_EV_DECODE 0
01138 #define FCN_TX_IP_EV_DECODE 2
01139 #define FCN_DRIVER_EV_DECODE 5
01140
01141
01142 #define FCN_RX_EV_PKT_OK_LBN 56
01143 #define FCN_RX_EV_PKT_OK_WIDTH 1
01144 #define FCN_RX_PORT_LBN 30
01145 #define FCN_RX_PORT_WIDTH 1
01146 #define FCN_RX_EV_BYTE_CNT_LBN 16
01147 #define FCN_RX_EV_BYTE_CNT_WIDTH 14
01148 #define FCN_RX_EV_DESC_PTR_LBN 0
01149 #define FCN_RX_EV_DESC_PTR_WIDTH 12
01150
01151
01152 #define FCN_TX_EV_DESC_PTR_LBN 0
01153 #define FCN_TX_EV_DESC_PTR_WIDTH 12
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163 #define FCN_REVISION_REG(efab, reg) \
01164 ( ( efab->pci_revision == FALCON_REV_B0 ) ? reg ## _B0 : reg ## _A1 )
01165
01166 #define EFAB_SET_OWORD_FIELD_VER(efab, reg, field, val) \
01167 if ( efab->pci_revision == FALCON_REV_B0 ) \
01168 EFAB_SET_OWORD_FIELD ( reg, field ## _B0, val ); \
01169 else \
01170 EFAB_SET_OWORD_FIELD ( reg, field ## _A1, val );
01171
01172 #if FALCON_USE_IO_BAR
01173
01174
01175 static inline void _falcon_writel ( struct efab_nic *efab, uint32_t value,
01176 unsigned int reg ) {
01177 outl ( reg, efab->iobase + FCN_IOM_IND_ADR_REG );
01178 outl ( value, efab->iobase + FCN_IOM_IND_DAT_REG );
01179 }
01180
01181
01182 static inline uint32_t _falcon_readl ( struct efab_nic *efab,
01183 unsigned int reg ) {
01184 outl ( reg, efab->iobase + FCN_IOM_IND_ADR_REG );
01185 return inl ( efab->iobase + FCN_IOM_IND_DAT_REG );
01186 }
01187
01188 #else
01189
01190 #define _falcon_writel( efab, value, reg ) \
01191 writel ( (value), (efab)->membase + (reg) )
01192 #define _falcon_readl( efab, reg ) readl ( (efab)->membase + (reg) )
01193
01194 #endif
01195
01196
01197
01198
01199
01200 static inline void
01201 falcon_write ( struct efab_nic *efab, efab_oword_t *value, unsigned int reg )
01202 {
01203
01204 EFAB_REGDUMP ( "Writing register %x with " EFAB_OWORD_FMT "\n",
01205 reg, EFAB_OWORD_VAL ( *value ) );
01206
01207 _falcon_writel ( efab, value->u32[0], reg + 0 );
01208 _falcon_writel ( efab, value->u32[1], reg + 4 );
01209 _falcon_writel ( efab, value->u32[2], reg + 8 );
01210 wmb();
01211 _falcon_writel ( efab, value->u32[3], reg + 12 );
01212 wmb();
01213 }
01214
01215
01216
01217
01218
01219 static inline void
01220 falcon_write_sram ( struct efab_nic *efab, efab_qword_t *value,
01221 unsigned int index )
01222 {
01223 unsigned int reg = ( FCN_REVISION_REG ( efab, FCN_BUF_FULL_TBL_KER ) +
01224 ( index * sizeof ( *value ) ) );
01225
01226 EFAB_REGDUMP ( "Writing SRAM register %x with " EFAB_QWORD_FMT "\n",
01227 reg, EFAB_QWORD_VAL ( *value ) );
01228
01229 _falcon_writel ( efab, value->u32[0], reg + 0 );
01230 _falcon_writel ( efab, value->u32[1], reg + 4 );
01231 wmb();
01232 }
01233
01234
01235
01236
01237
01238 static inline void
01239 falcon_writel ( struct efab_nic *efab, efab_dword_t *value, unsigned int reg )
01240 {
01241 EFAB_REGDUMP ( "Writing partial register %x with " EFAB_DWORD_FMT "\n",
01242 reg, EFAB_DWORD_VAL ( *value ) );
01243 _falcon_writel ( efab, value->u32[0], reg );
01244 }
01245
01246
01247
01248
01249
01250 static inline void
01251 falcon_read ( struct efab_nic *efab, efab_oword_t *value, unsigned int reg )
01252 {
01253 value->u32[0] = _falcon_readl ( efab, reg + 0 );
01254 wmb();
01255 value->u32[1] = _falcon_readl ( efab, reg + 4 );
01256 value->u32[2] = _falcon_readl ( efab, reg + 8 );
01257 value->u32[3] = _falcon_readl ( efab, reg + 12 );
01258
01259 EFAB_REGDUMP ( "Read from register %x, got " EFAB_OWORD_FMT "\n",
01260 reg, EFAB_OWORD_VAL ( *value ) );
01261 }
01262
01263
01264
01265
01266
01267 static inline void
01268 falcon_read_sram ( struct efab_nic *efab, efab_qword_t *value,
01269 unsigned int index )
01270 {
01271 unsigned int reg = ( FCN_REVISION_REG ( efab, FCN_BUF_FULL_TBL_KER ) +
01272 ( index * sizeof ( *value ) ) );
01273
01274 value->u32[0] = _falcon_readl ( efab, reg + 0 );
01275 value->u32[1] = _falcon_readl ( efab, reg + 4 );
01276 EFAB_REGDUMP ( "Read from SRAM register %x, got " EFAB_QWORD_FMT "\n",
01277 reg, EFAB_QWORD_VAL ( *value ) );
01278 }
01279
01280
01281
01282
01283
01284 static inline void
01285 falcon_readl ( struct efab_nic *efab, efab_dword_t *value, unsigned int reg )
01286 {
01287 value->u32[0] = _falcon_readl ( efab, reg );
01288 EFAB_REGDUMP ( "Read from register %x, got " EFAB_DWORD_FMT "\n",
01289 reg, EFAB_DWORD_VAL ( *value ) );
01290 }
01291
01292 #define FCN_DUMP_REG( efab, _reg ) do { \
01293 efab_oword_t reg; \
01294 falcon_read ( efab, ®, _reg ); \
01295 EFAB_LOG ( #_reg " = " EFAB_OWORD_FMT "\n", \
01296 EFAB_OWORD_VAL ( reg ) ); \
01297 } while ( 0 );
01298
01299 #define FCN_DUMP_MAC_REG( efab, _mac_reg ) do { \
01300 efab_dword_t reg; \
01301 efab->mac_op->mac_readl ( efab, ®, _mac_reg ); \
01302 EFAB_LOG ( #_mac_reg " = " EFAB_DWORD_FMT "\n", \
01303 EFAB_DWORD_VAL ( reg ) ); \
01304 } while ( 0 );
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321 static inline int
01322 falcon_event_present ( falcon_event_t* event )
01323 {
01324 return ( ! ( EFAB_DWORD_IS_ALL_ONES ( event->dword[0] ) |
01325 EFAB_DWORD_IS_ALL_ONES ( event->dword[1] ) ) );
01326 }
01327
01328 static void
01329 falcon_eventq_read_ack ( struct efab_nic *efab, struct efab_ev_queue *ev_queue )
01330 {
01331 efab_dword_t reg;
01332
01333 EFAB_POPULATE_DWORD_1 ( reg, FCN_EVQ_RPTR_DWORD, ev_queue->read_ptr );
01334 falcon_writel ( efab, ®,
01335 FCN_REVISION_REG ( efab, FCN_EVQ_RPTR_REG_KER_DWORD ) );
01336 }
01337
01338 #if 0
01339
01340
01341
01342
01343
01344
01345 static inline void
01346 falcon_dump_regs ( struct efab_nic *efab )
01347 {
01348 FCN_DUMP_REG ( efab, FCN_INT_EN_REG_KER );
01349 FCN_DUMP_REG ( efab, FCN_INT_ADR_REG_KER );
01350 FCN_DUMP_REG ( efab, FCN_GLB_CTL_REG_KER );
01351 FCN_DUMP_REG ( efab, FCN_TIMER_CMD_REG_KER );
01352 FCN_DUMP_REG ( efab, FCN_SRM_RX_DC_CFG_REG_KER );
01353 FCN_DUMP_REG ( efab, FCN_SRM_TX_DC_CFG_REG_KER );
01354 FCN_DUMP_REG ( efab, FCN_RX_FILTER_CTL_REG_KER );
01355 FCN_DUMP_REG ( efab, FCN_RX_DC_CFG_REG_KER );
01356 FCN_DUMP_REG ( efab, FCN_TX_DC_CFG_REG_KER );
01357 FCN_DUMP_REG ( efab, FCN_MAC0_CTRL_REG_KER );
01358 FCN_DUMP_REG ( efab, FCN_MAC1_CTRL_REG_KER );
01359 FCN_DUMP_REG ( efab, FCN_REVISION_REG ( efab, FCN_RX_DESC_PTR_TBL_KER ) );
01360 FCN_DUMP_REG ( efab, FCN_REVISION_REG ( efab, FCN_TX_DESC_PTR_TBL_KER ) );
01361 FCN_DUMP_REG ( efab, FCN_REVISION_REG ( efab, FCN_EVQ_PTR_TBL_KER ) );
01362 FCN_DUMP_MAC_REG ( efab, GM_CFG1_REG_MAC );
01363 FCN_DUMP_MAC_REG ( efab, GM_CFG2_REG_MAC );
01364 FCN_DUMP_MAC_REG ( efab, GM_MAX_FLEN_REG_MAC );
01365 FCN_DUMP_MAC_REG ( efab, GM_MII_MGMT_CFG_REG_MAC );
01366 FCN_DUMP_MAC_REG ( efab, GM_ADR1_REG_MAC );
01367 FCN_DUMP_MAC_REG ( efab, GM_ADR2_REG_MAC );
01368 FCN_DUMP_MAC_REG ( efab, GMF_CFG0_REG_MAC );
01369 FCN_DUMP_MAC_REG ( efab, GMF_CFG1_REG_MAC );
01370 FCN_DUMP_MAC_REG ( efab, GMF_CFG2_REG_MAC );
01371 FCN_DUMP_MAC_REG ( efab, GMF_CFG3_REG_MAC );
01372 FCN_DUMP_MAC_REG ( efab, GMF_CFG4_REG_MAC );
01373 FCN_DUMP_MAC_REG ( efab, GMF_CFG5_REG_MAC );
01374 }
01375 #endif
01376
01377 static void
01378 falcon_interrupts ( struct efab_nic *efab, int enabled, int force )
01379 {
01380 efab_oword_t int_en_reg_ker;
01381
01382 EFAB_POPULATE_OWORD_2 ( int_en_reg_ker,
01383 FCN_KER_INT_KER, force,
01384 FCN_DRV_INT_EN_KER, enabled );
01385 falcon_write ( efab, &int_en_reg_ker, FCN_INT_EN_REG_KER );
01386 }
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398 #define FALCON_SPI_MAX_LEN 16
01399
01400 static int
01401 falcon_spi_wait ( struct efab_nic *efab )
01402 {
01403 efab_oword_t reg;
01404 int count;
01405
01406 count = 0;
01407 do {
01408 udelay ( 100 );
01409 falcon_read ( efab, ®, FCN_EE_SPI_HCMD_REG );
01410 if ( EFAB_OWORD_FIELD ( reg, FCN_EE_SPI_HCMD_CMD_EN ) == 0 )
01411 return 0;
01412 } while ( ++count < 1000 );
01413
01414 EFAB_ERR ( "Timed out waiting for SPI\n" );
01415 return -ETIMEDOUT;
01416 }
01417
01418 static int
01419 falcon_spi_rw ( struct spi_bus* bus, struct spi_device *device,
01420 unsigned int command, int address,
01421 const void* data_out, void *data_in, size_t len )
01422 {
01423 struct efab_nic *efab = container_of ( bus, struct efab_nic, spi_bus );
01424 int address_len, rc, device_id, read_cmd;
01425 efab_oword_t reg;
01426
01427
01428
01429 assert ( len <= FALCON_SPI_MAX_LEN );
01430
01431
01432 if ( device == &efab->spi_flash )
01433 device_id = FCN_EE_SPI_FLASH;
01434 else if ( device == &efab->spi_eeprom )
01435 device_id = FCN_EE_SPI_EEPROM;
01436 else {
01437 EFAB_ERR ( "Unknown device %p\n", device );
01438 return -EINVAL;
01439 }
01440
01441 EFAB_TRACE ( "Executing spi command %d on device %d at %d for %zd bytes\n",
01442 command, device_id, address, len );
01443
01444
01445 rc = falcon_spi_wait ( efab );
01446 if ( rc )
01447 goto fail1;
01448
01449
01450 if ( data_out ) {
01451 memcpy ( ®, data_out, len );
01452 falcon_write ( efab, ®, FCN_EE_SPI_HDATA_REG );
01453 }
01454
01455
01456 if ( address >= 0 ) {
01457 EFAB_POPULATE_OWORD_1 ( reg, FCN_EE_SPI_HADR_ADR, address );
01458 falcon_write ( efab, ®, FCN_EE_SPI_HADR_REG );
01459 }
01460
01461
01462 address_len = ( address >= 0 ) ? device->address_len / 8 : 0;
01463 read_cmd = ( data_in ? FCN_EE_SPI_READ : FCN_EE_SPI_WRITE );
01464 EFAB_POPULATE_OWORD_7 ( reg,
01465 FCN_EE_SPI_HCMD_CMD_EN, 1,
01466 FCN_EE_SPI_HCMD_SF_SEL, device_id,
01467 FCN_EE_SPI_HCMD_DABCNT, len,
01468 FCN_EE_SPI_HCMD_READ, read_cmd,
01469 FCN_EE_SPI_HCMD_DUBCNT, 0,
01470 FCN_EE_SPI_HCMD_ADBCNT, address_len,
01471 FCN_EE_SPI_HCMD_ENC, command );
01472 falcon_write ( efab, ®, FCN_EE_SPI_HCMD_REG );
01473
01474
01475 rc = falcon_spi_wait ( efab );
01476 if ( rc )
01477 goto fail2;
01478
01479
01480 if ( data_in ) {
01481 falcon_read ( efab, ®, FCN_EE_SPI_HDATA_REG );
01482 memcpy ( data_in, ®, len );
01483 }
01484
01485 return 0;
01486
01487 fail2:
01488 fail1:
01489 EFAB_ERR ( "Failed SPI command %d to device %d address 0x%x len 0x%zx\n",
01490 command, device_id, address, len );
01491
01492 return rc;
01493 }
01494
01495
01496 static struct nvo_fragment falcon_nvo_fragments[] = {
01497 { 0x100, 0xf0 },
01498 { 0, 0 }
01499 };
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509 static void
01510 falcon_i2c_bit_write ( struct bit_basher *basher, unsigned int bit_id,
01511 unsigned long data )
01512 {
01513 struct efab_nic *efab = container_of ( basher, struct efab_nic,
01514 i2c_bb.basher );
01515 efab_oword_t reg;
01516
01517 falcon_read ( efab, ®, FCN_GPIO_CTL_REG_KER );
01518 switch ( bit_id ) {
01519 case I2C_BIT_SCL:
01520 EFAB_SET_OWORD_FIELD ( reg, FCN_GPIO0_OEN, ( data ? 0 : 1 ) );
01521 break;
01522 case I2C_BIT_SDA:
01523 EFAB_SET_OWORD_FIELD ( reg, FCN_GPIO3_OEN, ( data ? 0 : 1 ) );
01524 break;
01525 default:
01526 EFAB_ERR ( "%s bit=%d\n", __func__, bit_id );
01527 break;
01528 }
01529
01530 falcon_write ( efab, ®, FCN_GPIO_CTL_REG_KER );
01531 }
01532
01533 static int
01534 falcon_i2c_bit_read ( struct bit_basher *basher, unsigned int bit_id )
01535 {
01536 struct efab_nic *efab = container_of ( basher, struct efab_nic,
01537 i2c_bb.basher );
01538 efab_oword_t reg;
01539
01540 falcon_read ( efab, ®, FCN_GPIO_CTL_REG_KER );
01541 switch ( bit_id ) {
01542 case I2C_BIT_SCL:
01543 return EFAB_OWORD_FIELD ( reg, FCN_GPIO0_IN );
01544 break;
01545 case I2C_BIT_SDA:
01546 return EFAB_OWORD_FIELD ( reg, FCN_GPIO3_IN );
01547 break;
01548 default:
01549 EFAB_ERR ( "%s bit=%d\n", __func__, bit_id );
01550 break;
01551 }
01552
01553 return -1;
01554 }
01555
01556 static struct bit_basher_operations falcon_i2c_bit_ops = {
01557 .read = falcon_i2c_bit_read,
01558 .write = falcon_i2c_bit_write,
01559 };
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570 static int
01571 falcon_gmii_wait ( struct efab_nic *efab )
01572 {
01573 efab_dword_t md_stat;
01574 int count;
01575
01576
01577 for (count = 0; count < 1000; count++) {
01578 falcon_readl ( efab, &md_stat, FCN_MD_STAT_REG_KER );
01579 if ( EFAB_DWORD_FIELD ( md_stat, FCN_MD_BSY ) == 0 ) {
01580 if ( EFAB_DWORD_FIELD ( md_stat, FCN_MD_LNFL ) != 0 ||
01581 EFAB_DWORD_FIELD ( md_stat, FCN_MD_BSERR ) != 0 ) {
01582 EFAB_ERR ( "Error from GMII access "
01583 EFAB_DWORD_FMT"\n",
01584 EFAB_DWORD_VAL ( md_stat ));
01585 return -EIO;
01586 }
01587 return 0;
01588 }
01589 udelay(10);
01590 }
01591
01592 EFAB_ERR ( "Timed out waiting for GMII\n" );
01593 return -ETIMEDOUT;
01594 }
01595
01596 static void
01597 falcon_mdio_write ( struct efab_nic *efab, int device,
01598 int location, int value )
01599 {
01600 efab_oword_t reg;
01601
01602 EFAB_TRACE ( "Writing GMII %d register %02x with %04x\n",
01603 device, location, value );
01604
01605
01606 if ( falcon_gmii_wait ( efab ) )
01607 return;
01608
01609
01610 EFAB_POPULATE_OWORD_1 ( reg, FCN_MD_PHY_ADR, location );
01611 falcon_write ( efab, ®, FCN_MD_PHY_ADR_REG_KER );
01612
01613 if ( efab->phy_10g ) {
01614
01615 EFAB_POPULATE_OWORD_2 ( reg,
01616 FCN_MD_PRT_ADR, efab->phy_addr,
01617 FCN_MD_DEV_ADR, device );
01618 }
01619 else {
01620
01621 assert ( device == 0 );
01622
01623 EFAB_POPULATE_OWORD_2 ( reg,
01624 FCN_MD_PRT_ADR, efab->phy_addr,
01625 FCN_MD_DEV_ADR, location );
01626 }
01627 falcon_write ( efab, ®, FCN_MD_ID_REG_KER );
01628
01629
01630
01631 EFAB_POPULATE_OWORD_1 ( reg, FCN_MD_TXD, value );
01632 falcon_write ( efab, ®, FCN_MD_TXD_REG_KER );
01633
01634 EFAB_POPULATE_OWORD_2 ( reg,
01635 FCN_MD_WRC, 1,
01636 FCN_MD_GC, ( efab->phy_10g ? 0 : 1 ) );
01637 falcon_write ( efab, ®, FCN_MD_CS_REG_KER );
01638
01639
01640 if ( falcon_gmii_wait ( efab ) ) {
01641
01642 EFAB_POPULATE_OWORD_2 ( reg,
01643 FCN_MD_WRC, 0,
01644 FCN_MD_GC, 1);
01645 falcon_write ( efab, ®, FCN_MD_CS_REG_KER );
01646 udelay(10);
01647 }
01648 }
01649
01650 static int
01651 falcon_mdio_read ( struct efab_nic *efab, int device, int location )
01652 {
01653 efab_oword_t reg;
01654 int value;
01655
01656
01657 if ( falcon_gmii_wait ( efab ) )
01658 return -1;
01659
01660 if ( efab->phy_10g ) {
01661
01662 EFAB_POPULATE_OWORD_1 ( reg, FCN_MD_PHY_ADR, location );
01663 falcon_write ( efab, ®, FCN_MD_PHY_ADR_REG_KER );
01664
01665 EFAB_POPULATE_OWORD_2 ( reg,
01666 FCN_MD_PRT_ADR, efab->phy_addr,
01667 FCN_MD_DEV_ADR, device );
01668 falcon_write ( efab, ®, FCN_MD_ID_REG_KER);
01669
01670
01671 EFAB_POPULATE_OWORD_2 ( reg,
01672 FCN_MD_RDC, 1,
01673 FCN_MD_GC, 0 );
01674 }
01675 else {
01676
01677 assert ( device == 0 );
01678
01679 EFAB_POPULATE_OWORD_2 ( reg,
01680 FCN_MD_PRT_ADR, efab->phy_addr,
01681 FCN_MD_DEV_ADR, location );
01682 falcon_write ( efab, ®, FCN_MD_ID_REG_KER );
01683
01684
01685 EFAB_POPULATE_OWORD_2 ( reg,
01686 FCN_MD_RIC, 1,
01687 FCN_MD_GC, 1 );
01688 }
01689
01690 falcon_write ( efab, ®, FCN_MD_CS_REG_KER );
01691
01692
01693 if ( falcon_gmii_wait ( efab ) ) {
01694
01695 EFAB_POPULATE_OWORD_2 ( reg,
01696 FCN_MD_RIC, 0,
01697 FCN_MD_GC, 1 );
01698 falcon_write ( efab, ®, FCN_MD_CS_REG_KER );
01699 udelay ( 10 );
01700 value = -1;
01701 }
01702 else {
01703
01704 falcon_read ( efab, ®, FCN_MD_RXD_REG_KER );
01705 value = EFAB_OWORD_FIELD ( reg, FCN_MD_RXD );
01706 }
01707
01708 EFAB_TRACE ( "Read from GMII %d register %02x, got %04x\n",
01709 device, location, value );
01710
01711 return value;
01712 }
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722 static void
01723 falcon_reconfigure_mac_wrapper ( struct efab_nic *efab )
01724 {
01725 efab_oword_t reg;
01726 int link_speed;
01727
01728 if ( efab->link_options & LPA_EF_10000 ) {
01729 link_speed = 0x3;
01730 } else if ( efab->link_options & LPA_EF_1000 ) {
01731 link_speed = 0x2;
01732 } else if ( efab->link_options & LPA_100 ) {
01733 link_speed = 0x1;
01734 } else {
01735 link_speed = 0x0;
01736 }
01737 EFAB_POPULATE_OWORD_5 ( reg,
01738 FCN_MAC_XOFF_VAL, 0xffff ,
01739 FCN_MAC_BCAD_ACPT, 1,
01740 FCN_MAC_UC_PROM, 0,
01741 FCN_MAC_LINK_STATUS, 1,
01742 FCN_MAC_SPEED, link_speed );
01743
01744 falcon_write ( efab, ®, FCN_MAC0_CTRL_REG_KER );
01745 }
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756 #define GM_CFG1_REG_MAC 0x00
01757 #define GM_SW_RST_LBN 31
01758 #define GM_SW_RST_WIDTH 1
01759 #define GM_RX_FC_EN_LBN 5
01760 #define GM_RX_FC_EN_WIDTH 1
01761 #define GM_TX_FC_EN_LBN 4
01762 #define GM_TX_FC_EN_WIDTH 1
01763 #define GM_RX_EN_LBN 2
01764 #define GM_RX_EN_WIDTH 1
01765 #define GM_TX_EN_LBN 0
01766 #define GM_TX_EN_WIDTH 1
01767
01768
01769 #define GM_CFG2_REG_MAC 0x01
01770 #define GM_PAMBL_LEN_LBN 12
01771 #define GM_PAMBL_LEN_WIDTH 4
01772 #define GM_IF_MODE_LBN 8
01773 #define GM_IF_MODE_WIDTH 2
01774 #define GM_PAD_CRC_EN_LBN 2
01775 #define GM_PAD_CRC_EN_WIDTH 1
01776 #define GM_FD_LBN 0
01777 #define GM_FD_WIDTH 1
01778
01779
01780 #define GM_MAX_FLEN_REG_MAC 0x04
01781 #define GM_MAX_FLEN_LBN 0
01782 #define GM_MAX_FLEN_WIDTH 16
01783
01784
01785 #define GM_MII_MGMT_CFG_REG_MAC 0x08
01786 #define GM_MGMT_CLK_SEL_LBN 0
01787 #define GM_MGMT_CLK_SEL_WIDTH 3
01788
01789
01790 #define GM_MII_MGMT_CMD_REG_MAC 0x09
01791 #define GM_MGMT_SCAN_CYC_LBN 1
01792 #define GM_MGMT_SCAN_CYC_WIDTH 1
01793 #define GM_MGMT_RD_CYC_LBN 0
01794 #define GM_MGMT_RD_CYC_WIDTH 1
01795
01796
01797 #define GM_MII_MGMT_ADR_REG_MAC 0x0a
01798 #define GM_MGMT_PHY_ADDR_LBN 8
01799 #define GM_MGMT_PHY_ADDR_WIDTH 5
01800 #define GM_MGMT_REG_ADDR_LBN 0
01801 #define GM_MGMT_REG_ADDR_WIDTH 5
01802
01803
01804 #define GM_MII_MGMT_CTL_REG_MAC 0x0b
01805 #define GM_MGMT_CTL_LBN 0
01806 #define GM_MGMT_CTL_WIDTH 16
01807
01808
01809 #define GM_MII_MGMT_STAT_REG_MAC 0x0c
01810 #define GM_MGMT_STAT_LBN 0
01811 #define GM_MGMT_STAT_WIDTH 16
01812
01813
01814 #define GM_MII_MGMT_IND_REG_MAC 0x0d
01815 #define GM_MGMT_BUSY_LBN 0
01816 #define GM_MGMT_BUSY_WIDTH 1
01817
01818
01819 #define GM_ADR1_REG_MAC 0x10
01820 #define GM_HWADDR_5_LBN 24
01821 #define GM_HWADDR_5_WIDTH 8
01822 #define GM_HWADDR_4_LBN 16
01823 #define GM_HWADDR_4_WIDTH 8
01824 #define GM_HWADDR_3_LBN 8
01825 #define GM_HWADDR_3_WIDTH 8
01826 #define GM_HWADDR_2_LBN 0
01827 #define GM_HWADDR_2_WIDTH 8
01828
01829
01830 #define GM_ADR2_REG_MAC 0x11
01831 #define GM_HWADDR_1_LBN 24
01832 #define GM_HWADDR_1_WIDTH 8
01833 #define GM_HWADDR_0_LBN 16
01834 #define GM_HWADDR_0_WIDTH 8
01835
01836
01837 #define GMF_CFG0_REG_MAC 0x12
01838 #define GMF_FTFENREQ_LBN 12
01839 #define GMF_FTFENREQ_WIDTH 1
01840 #define GMF_STFENREQ_LBN 11
01841 #define GMF_STFENREQ_WIDTH 1
01842 #define GMF_FRFENREQ_LBN 10
01843 #define GMF_FRFENREQ_WIDTH 1
01844 #define GMF_SRFENREQ_LBN 9
01845 #define GMF_SRFENREQ_WIDTH 1
01846 #define GMF_WTMENREQ_LBN 8
01847 #define GMF_WTMENREQ_WIDTH 1
01848
01849
01850 #define GMF_CFG1_REG_MAC 0x13
01851 #define GMF_CFGFRTH_LBN 16
01852 #define GMF_CFGFRTH_WIDTH 5
01853 #define GMF_CFGXOFFRTX_LBN 0
01854 #define GMF_CFGXOFFRTX_WIDTH 16
01855
01856
01857 #define GMF_CFG2_REG_MAC 0x14
01858 #define GMF_CFGHWM_LBN 16
01859 #define GMF_CFGHWM_WIDTH 6
01860 #define GMF_CFGLWM_LBN 0
01861 #define GMF_CFGLWM_WIDTH 6
01862
01863
01864 #define GMF_CFG3_REG_MAC 0x15
01865 #define GMF_CFGHWMFT_LBN 16
01866 #define GMF_CFGHWMFT_WIDTH 6
01867 #define GMF_CFGFTTH_LBN 0
01868 #define GMF_CFGFTTH_WIDTH 6
01869
01870
01871 #define GMF_CFG4_REG_MAC 0x16
01872 #define GMF_HSTFLTRFRM_PAUSE_LBN 12
01873 #define GMF_HSTFLTRFRM_PAUSE_WIDTH 12
01874
01875
01876 #define GMF_CFG5_REG_MAC 0x17
01877 #define GMF_CFGHDPLX_LBN 22
01878 #define GMF_CFGHDPLX_WIDTH 1
01879 #define GMF_CFGBYTMODE_LBN 19
01880 #define GMF_CFGBYTMODE_WIDTH 1
01881 #define GMF_HSTDRPLT64_LBN 18
01882 #define GMF_HSTDRPLT64_WIDTH 1
01883 #define GMF_HSTFLTRFRMDC_PAUSE_LBN 12
01884 #define GMF_HSTFLTRFRMDC_PAUSE_WIDTH 1
01885
01886 static void
01887 falcon_gmac_writel ( struct efab_nic *efab, efab_dword_t *value,
01888 unsigned int mac_reg )
01889 {
01890 efab_oword_t temp;
01891
01892 EFAB_POPULATE_OWORD_1 ( temp, FCN_MAC_DATA,
01893 EFAB_DWORD_FIELD ( *value, FCN_MAC_DATA ) );
01894 falcon_write ( efab, &temp, FALCON_GMAC_REG ( efab, mac_reg ) );
01895 }
01896
01897 static void
01898 falcon_gmac_readl ( struct efab_nic *efab, efab_dword_t *value,
01899 unsigned int mac_reg )
01900 {
01901 efab_oword_t temp;
01902
01903 falcon_read ( efab, &temp, FALCON_GMAC_REG ( efab, mac_reg ) );
01904 EFAB_POPULATE_DWORD_1 ( *value, FCN_MAC_DATA,
01905 EFAB_OWORD_FIELD ( temp, FCN_MAC_DATA ) );
01906 }
01907
01908 static void
01909 mentormac_reset ( struct efab_nic *efab )
01910 {
01911 efab_dword_t reg;
01912
01913
01914 EFAB_POPULATE_DWORD_1 ( reg, GM_SW_RST, 1 );
01915 falcon_gmac_writel ( efab, ®, GM_CFG1_REG_MAC );
01916 udelay ( 1000 );
01917
01918
01919 EFAB_POPULATE_DWORD_1 ( reg, GM_SW_RST, 0 );
01920 falcon_gmac_writel ( efab, ®, GM_CFG1_REG_MAC );
01921 udelay ( 1000 );
01922
01923
01924
01925
01926
01927 EFAB_POPULATE_DWORD_1 ( reg, GM_MGMT_CLK_SEL, 0x4 );
01928 falcon_gmac_writel ( efab, ®, GM_MII_MGMT_CFG_REG_MAC );
01929 udelay ( 10 );
01930 }
01931
01932 static void
01933 mentormac_init ( struct efab_nic *efab )
01934 {
01935 int pause, if_mode, full_duplex, bytemode, half_duplex;
01936 efab_dword_t reg;
01937
01938
01939 pause = ( efab->link_options & LPA_PAUSE_CAP ) ? 1 : 0;
01940 if ( ! ( efab->link_options & LPA_EF_DUPLEX ) ) {
01941
01942 pause = 1;
01943 }
01944 EFAB_POPULATE_DWORD_4 ( reg,
01945 GM_TX_EN, 1,
01946 GM_TX_FC_EN, pause,
01947 GM_RX_EN, 1,
01948 GM_RX_FC_EN, 1 );
01949 falcon_gmac_writel ( efab, ®, GM_CFG1_REG_MAC );
01950 udelay ( 10 );
01951
01952
01953 if_mode = ( efab->link_options & LPA_EF_1000 ) ? 2 : 1;
01954 full_duplex = ( efab->link_options & LPA_EF_DUPLEX ) ? 1 : 0;
01955 EFAB_POPULATE_DWORD_4 ( reg,
01956 GM_IF_MODE, if_mode,
01957 GM_PAD_CRC_EN, 1,
01958 GM_FD, full_duplex,
01959 GM_PAMBL_LEN, 0x7 );
01960 falcon_gmac_writel ( efab, ®, GM_CFG2_REG_MAC );
01961 udelay ( 10 );
01962
01963
01964 EFAB_POPULATE_DWORD_1 ( reg, GM_MAX_FLEN,
01965 EFAB_MAX_FRAME_LEN ( ETH_FRAME_LEN ) );
01966 falcon_gmac_writel ( efab, ®, GM_MAX_FLEN_REG_MAC );
01967 udelay ( 10 );
01968
01969
01970 EFAB_POPULATE_DWORD_5 ( reg,
01971 GMF_FTFENREQ, 1,
01972 GMF_STFENREQ, 1,
01973 GMF_FRFENREQ, 1,
01974 GMF_SRFENREQ, 1,
01975 GMF_WTMENREQ, 1 );
01976 falcon_gmac_writel ( efab, ®, GMF_CFG0_REG_MAC );
01977 udelay ( 10 );
01978
01979
01980 EFAB_POPULATE_DWORD_2 ( reg,
01981 GMF_CFGFRTH, 0x12,
01982 GMF_CFGXOFFRTX, 0xffff );
01983 falcon_gmac_writel ( efab, ®, GMF_CFG1_REG_MAC );
01984 udelay ( 10 );
01985
01986
01987 EFAB_POPULATE_DWORD_2 ( reg,
01988 GMF_CFGHWM, 0x3f,
01989 GMF_CFGLWM, 0xa );
01990 falcon_gmac_writel ( efab, ®, GMF_CFG2_REG_MAC );
01991 udelay ( 10 );
01992
01993
01994 EFAB_POPULATE_DWORD_2 ( reg,
01995 GMF_CFGHWMFT, 0x1c,
01996 GMF_CFGFTTH, 0x08 );
01997 falcon_gmac_writel ( efab, ®, GMF_CFG3_REG_MAC );
01998 udelay ( 10 );
01999
02000
02001 EFAB_POPULATE_DWORD_1 ( reg, GMF_HSTFLTRFRM_PAUSE, 1 );
02002 falcon_gmac_writel ( efab, ®, GMF_CFG4_REG_MAC );
02003 udelay ( 10 );
02004
02005
02006 bytemode = ( efab->link_options & LPA_EF_1000 ) ? 1 : 0;
02007 half_duplex = ( efab->link_options & LPA_EF_DUPLEX ) ? 0 : 1;
02008 falcon_gmac_readl ( efab, ®, GMF_CFG5_REG_MAC );
02009 EFAB_SET_DWORD_FIELD ( reg, GMF_CFGBYTMODE, bytemode );
02010 EFAB_SET_DWORD_FIELD ( reg, GMF_CFGHDPLX, half_duplex );
02011 EFAB_SET_DWORD_FIELD ( reg, GMF_HSTDRPLT64, half_duplex );
02012 EFAB_SET_DWORD_FIELD ( reg, GMF_HSTFLTRFRMDC_PAUSE, 0 );
02013 falcon_gmac_writel ( efab, ®, GMF_CFG5_REG_MAC );
02014 udelay ( 10 );
02015
02016
02017 EFAB_POPULATE_DWORD_4 ( reg,
02018 GM_HWADDR_5, efab->mac_addr[5],
02019 GM_HWADDR_4, efab->mac_addr[4],
02020 GM_HWADDR_3, efab->mac_addr[3],
02021 GM_HWADDR_2, efab->mac_addr[2] );
02022 falcon_gmac_writel ( efab, ®, GM_ADR1_REG_MAC );
02023 udelay ( 10 );
02024 EFAB_POPULATE_DWORD_2 ( reg,
02025 GM_HWADDR_1, efab->mac_addr[1],
02026 GM_HWADDR_0, efab->mac_addr[0] );
02027 falcon_gmac_writel ( efab, ®, GM_ADR2_REG_MAC );
02028 udelay ( 10 );
02029 }
02030
02031 static int
02032 falcon_init_gmac ( struct efab_nic *efab )
02033 {
02034
02035 mentormac_reset ( efab );
02036
02037
02038 efab->phy_op->init ( efab );
02039
02040
02041 if ( !efab->link_up )
02042 return -EAGAIN;
02043
02044
02045 mentormac_init ( efab );
02046
02047
02048 falcon_reconfigure_mac_wrapper ( efab );
02049
02050 return 0;
02051 }
02052
02053 static struct efab_mac_operations falcon_gmac_operations = {
02054 .init = falcon_init_gmac,
02055 };
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070 static void
02071 falcon_xmac_writel ( struct efab_nic *efab, efab_dword_t *value,
02072 unsigned int mac_reg )
02073 {
02074 efab_oword_t temp;
02075
02076 EFAB_POPULATE_OWORD_1 ( temp, FCN_MAC_DATA,
02077 EFAB_DWORD_FIELD ( *value, FCN_MAC_DATA ) );
02078 falcon_write ( efab, &temp,
02079 FALCON_XMAC_REG ( efab, mac_reg ) );
02080 }
02081
02082
02083
02084
02085
02086 static void
02087 falcon_xmac_readl ( struct efab_nic *efab, efab_dword_t *value,
02088 unsigned int mac_reg )
02089 {
02090 efab_oword_t temp;
02091
02092 falcon_read ( efab, &temp,
02093 FALCON_XMAC_REG ( efab, mac_reg ) );
02094 EFAB_POPULATE_DWORD_1 ( *value, FCN_MAC_DATA,
02095 EFAB_OWORD_FIELD ( temp, FCN_MAC_DATA ) );
02096 }
02097
02098
02099
02100
02101 static void
02102 falcon_setup_xaui ( struct efab_nic *efab )
02103 {
02104 efab_dword_t sdctl, txdrv;
02105
02106 falcon_xmac_readl ( efab, &sdctl, FCN_XX_SD_CTL_REG_MAC );
02107 EFAB_SET_DWORD_FIELD ( sdctl, FCN_XX_HIDRVD, XX_SD_CTL_DRV_DEFAULT );
02108 EFAB_SET_DWORD_FIELD ( sdctl, FCN_XX_LODRVD, XX_SD_CTL_DRV_DEFAULT );
02109 EFAB_SET_DWORD_FIELD ( sdctl, FCN_XX_HIDRVC, XX_SD_CTL_DRV_DEFAULT );
02110 EFAB_SET_DWORD_FIELD ( sdctl, FCN_XX_LODRVC, XX_SD_CTL_DRV_DEFAULT );
02111 EFAB_SET_DWORD_FIELD ( sdctl, FCN_XX_HIDRVB, XX_SD_CTL_DRV_DEFAULT );
02112 EFAB_SET_DWORD_FIELD ( sdctl, FCN_XX_LODRVB, XX_SD_CTL_DRV_DEFAULT );
02113 EFAB_SET_DWORD_FIELD ( sdctl, FCN_XX_HIDRVA, XX_SD_CTL_DRV_DEFAULT );
02114 EFAB_SET_DWORD_FIELD ( sdctl, FCN_XX_LODRVA, XX_SD_CTL_DRV_DEFAULT );
02115 falcon_xmac_writel ( efab, &sdctl, FCN_XX_SD_CTL_REG_MAC );
02116
02117 EFAB_POPULATE_DWORD_8 ( txdrv,
02118 FCN_XX_DEQD, XX_TXDRV_DEQ_DEFAULT,
02119 FCN_XX_DEQC, XX_TXDRV_DEQ_DEFAULT,
02120 FCN_XX_DEQB, XX_TXDRV_DEQ_DEFAULT,
02121 FCN_XX_DEQA, XX_TXDRV_DEQ_DEFAULT,
02122 FCN_XX_DTXD, XX_TXDRV_DTX_DEFAULT,
02123 FCN_XX_DTXC, XX_TXDRV_DTX_DEFAULT,
02124 FCN_XX_DTXB, XX_TXDRV_DTX_DEFAULT,
02125 FCN_XX_DTXA, XX_TXDRV_DTX_DEFAULT);
02126 falcon_xmac_writel ( efab, &txdrv, FCN_XX_TXDRV_CTL_REG_MAC);
02127 }
02128
02129 static int
02130 falcon_xgmii_status ( struct efab_nic *efab )
02131 {
02132 efab_dword_t reg;
02133
02134 if ( efab->pci_revision < FALCON_REV_B0 )
02135 return 1;
02136
02137 falcon_xmac_readl ( efab, ®, FCN_XM_MGT_INT_REG_MAC_B0 );
02138 falcon_xmac_readl ( efab, ®, FCN_XM_MGT_INT_REG_MAC_B0 );
02139
02140 if ( EFAB_DWORD_FIELD ( reg, FCN_XM_LCLFLT ) ||
02141 EFAB_DWORD_FIELD ( reg, FCN_XM_RMTFLT ) ) {
02142 EFAB_TRACE ( "MGT_INT: "EFAB_DWORD_FMT"\n",
02143 EFAB_DWORD_VAL ( reg ) );
02144 return 0;
02145 }
02146
02147 return 1;
02148 }
02149
02150 static void
02151 falcon_mask_status_intr ( struct efab_nic *efab, int enable )
02152 {
02153 efab_dword_t reg;
02154
02155 if ( efab->pci_revision < FALCON_REV_B0 )
02156 return;
02157
02158
02159 if ( enable )
02160 falcon_xmac_readl ( efab, ®, FCN_XM_MGT_INT_REG_MAC_B0 );
02161
02162 EFAB_POPULATE_DWORD_2 ( reg,
02163 FCN_XM_MSK_RMTFLT, !enable,
02164 FCN_XM_MSK_LCLFLT, !enable);
02165 falcon_xmac_readl ( efab, ®, FCN_XM_MGT_INT_MSK_REG_MAC_B0 );
02166 }
02167
02168
02169
02170
02171
02172 static int
02173 falcon_reset_xmac ( struct efab_nic *efab )
02174 {
02175 efab_dword_t reg;
02176 int count;
02177
02178 EFAB_POPULATE_DWORD_1 ( reg, FCN_XM_CORE_RST, 1 );
02179 falcon_xmac_writel ( efab, ®, FCN_XM_GLB_CFG_REG_MAC );
02180
02181 for ( count = 0 ; count < 1000 ; count++ ) {
02182 udelay ( 10 );
02183 falcon_xmac_readl ( efab, ®,
02184 FCN_XM_GLB_CFG_REG_MAC );
02185 if ( EFAB_DWORD_FIELD ( reg, FCN_XM_CORE_RST ) == 0 )
02186 return 0;
02187 }
02188 return -ETIMEDOUT;
02189 }
02190
02191
02192 static int
02193 falcon_reset_xaui ( struct efab_nic *efab )
02194 {
02195 efab_dword_t reg;
02196 int count;
02197
02198 if (!efab->is_asic)
02199 return 0;
02200
02201 EFAB_POPULATE_DWORD_1 ( reg, FCN_XX_RST_XX_EN, 1 );
02202 falcon_xmac_writel ( efab, ®, FCN_XX_PWR_RST_REG_MAC );
02203
02204
02205 for (count = 0; count < 1000; count++) {
02206 falcon_xmac_readl ( efab, ®, FCN_XX_PWR_RST_REG_MAC );
02207 if ( EFAB_DWORD_FIELD ( reg, FCN_XX_RST_XX_EN ) == 0 ) {
02208 falcon_setup_xaui ( efab );
02209 return 0;
02210 }
02211 udelay(10);
02212 }
02213 EFAB_ERR ( "timed out waiting for XAUI/XGXS reset\n" );
02214 return -ETIMEDOUT;
02215 }
02216
02217 static int
02218 falcon_xaui_link_ok ( struct efab_nic *efab )
02219 {
02220 efab_dword_t reg;
02221 int align_done, lane_status, sync;
02222 int has_phyxs;
02223 int link_ok = 1;
02224
02225
02226 if ( efab->is_asic ) {
02227
02228 falcon_xmac_readl ( efab, ®, FCN_XX_CORE_STAT_REG_MAC );
02229 align_done = EFAB_DWORD_FIELD ( reg, FCN_XX_ALIGN_DONE );
02230
02231 sync = EFAB_DWORD_FIELD ( reg, FCN_XX_SYNC_STAT );
02232 sync = ( sync == FCN_XX_SYNC_STAT_DECODE_SYNCED );
02233
02234 link_ok = align_done && sync;
02235 }
02236
02237
02238 EFAB_SET_DWORD_FIELD ( reg, FCN_XX_COMMA_DET, FCN_XX_COMMA_DET_RESET );
02239 EFAB_SET_DWORD_FIELD ( reg, FCN_XX_CHARERR, FCN_XX_CHARERR_RESET);
02240 EFAB_SET_DWORD_FIELD ( reg, FCN_XX_DISPERR, FCN_XX_DISPERR_RESET);
02241 falcon_xmac_writel ( efab, ®, FCN_XX_CORE_STAT_REG_MAC );
02242
02243 has_phyxs = ( efab->phy_op->mmds & ( 1 << MDIO_MMD_PHYXS ) );
02244 if ( link_ok && has_phyxs ) {
02245 lane_status = falcon_mdio_read ( efab, MDIO_MMD_PHYXS,
02246 MDIO_PHYXS_LANE_STATE );
02247 link_ok = ( lane_status & ( 1 << MDIO_PHYXS_LANE_ALIGNED_LBN ) );
02248
02249 if (!link_ok )
02250 EFAB_LOG ( "XGXS lane status: %x\n", lane_status );
02251 }
02252
02253 return link_ok;
02254 }
02255
02256
02257
02258
02259
02260 static void
02261 falcon_reconfigure_xmac ( struct efab_nic *efab )
02262 {
02263 efab_dword_t reg;
02264 int max_frame_len;
02265
02266
02267 EFAB_POPULATE_DWORD_3 ( reg,
02268 FCN_XM_RX_JUMBO_MODE, 1,
02269 FCN_XM_TX_STAT_EN, 1,
02270 FCN_XM_RX_STAT_EN, 1);
02271 falcon_xmac_writel ( efab, ®, FCN_XM_GLB_CFG_REG_MAC );
02272
02273
02274 EFAB_POPULATE_DWORD_6 ( reg,
02275 FCN_XM_TXEN, 1,
02276 FCN_XM_TX_PRMBL, 1,
02277 FCN_XM_AUTO_PAD, 1,
02278 FCN_XM_TXCRC, 1,
02279 FCN_XM_FCNTL, 1,
02280 FCN_XM_IPG, 0x3 );
02281 falcon_xmac_writel ( efab, ®, FCN_XM_TX_CFG_REG_MAC );
02282
02283
02284 EFAB_POPULATE_DWORD_4 ( reg,
02285 FCN_XM_RXEN, 1,
02286 FCN_XM_AUTO_DEPAD, 0,
02287 FCN_XM_ACPT_ALL_MCAST, 1,
02288 FCN_XM_PASS_CRC_ERR, 1 );
02289 falcon_xmac_writel ( efab, ®, FCN_XM_RX_CFG_REG_MAC );
02290
02291
02292 max_frame_len = EFAB_MAX_FRAME_LEN ( ETH_FRAME_LEN );
02293 EFAB_POPULATE_DWORD_1 ( reg,
02294 FCN_XM_MAX_RX_FRM_SIZE, max_frame_len );
02295 falcon_xmac_writel ( efab, ®, FCN_XM_RX_PARAM_REG_MAC );
02296 EFAB_POPULATE_DWORD_2 ( reg,
02297 FCN_XM_MAX_TX_FRM_SIZE, max_frame_len,
02298 FCN_XM_TX_JUMBO_MODE, 1 );
02299 falcon_xmac_writel ( efab, ®, FCN_XM_TX_PARAM_REG_MAC );
02300
02301
02302 EFAB_POPULATE_DWORD_2 ( reg,
02303 FCN_XM_PAUSE_TIME, 0xfffe,
02304 FCN_XM_DIS_FCNTL, 0 );
02305 falcon_xmac_writel ( efab, ®, FCN_XM_FC_REG_MAC );
02306
02307
02308 EFAB_POPULATE_DWORD_4 ( reg,
02309 FCN_XM_ADR_0, efab->mac_addr[0],
02310 FCN_XM_ADR_1, efab->mac_addr[1],
02311 FCN_XM_ADR_2, efab->mac_addr[2],
02312 FCN_XM_ADR_3, efab->mac_addr[3] );
02313 falcon_xmac_writel ( efab, ®, FCN_XM_ADR_LO_REG_MAC );
02314 EFAB_POPULATE_DWORD_2 ( reg,
02315 FCN_XM_ADR_4, efab->mac_addr[4],
02316 FCN_XM_ADR_5, efab->mac_addr[5] );
02317 falcon_xmac_writel ( efab, ®, FCN_XM_ADR_HI_REG_MAC );
02318 }
02319
02320 static int
02321 falcon_init_xmac ( struct efab_nic *efab )
02322 {
02323 int count, rc;
02324
02325
02326 falcon_mask_status_intr ( efab, 0 );
02327
02328
02329 rc = efab->phy_op->init ( efab );
02330 if ( rc ) {
02331 EFAB_ERR ( "unable to initialise PHY\n" );
02332 goto fail1;
02333 }
02334
02335 falcon_reset_xaui ( efab );
02336
02337
02338 mdelay ( 100 );
02339
02340
02341 rc = falcon_reset_xmac ( efab );
02342 if ( rc )
02343 goto fail2;
02344 falcon_reconfigure_xmac ( efab );
02345 falcon_reconfigure_mac_wrapper ( efab );
02346
02347
02348
02349
02350 for (count=0; count<50; count++) {
02351 int link_ok = 1;
02352
02353
02354 mdelay ( 100 );
02355 if ((count % 5) == 0)
02356 putchar ( '.' );
02357
02358
02359 link_ok = mdio_clause45_links_ok ( efab );
02360
02361 if ( link_ok ) {
02362 link_ok = falcon_xaui_link_ok ( efab );
02363 if ( !link_ok )
02364 falcon_reset_xaui ( efab );
02365 }
02366
02367
02368 if ( link_ok )
02369 link_ok = falcon_xgmii_status ( efab );
02370
02371 efab->link_up = link_ok;
02372 if ( link_ok ) {
02373
02374 falcon_mask_status_intr ( efab, 1 );
02375 return 0;
02376 }
02377 }
02378
02379
02380 rc = -ETIMEDOUT;
02381
02382 fail2:
02383 fail1:
02384 return rc;
02385 }
02386
02387 static struct efab_mac_operations falcon_xmac_operations = {
02388 .init = falcon_init_xmac,
02389 };
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399 static int
02400 falcon_xaui_phy_init ( struct efab_nic *efab )
02401 {
02402
02403 efab->link_options = LPA_EF_10000FULL;
02404
02405
02406 return 0;
02407 }
02408
02409 static struct efab_phy_operations falcon_xaui_phy_ops = {
02410 .init = falcon_xaui_phy_init,
02411 .mmds = 0,
02412 };
02413
02414
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427 static int
02428 alaska_init ( struct efab_nic *efab )
02429 {
02430 unsigned int advertised, lpa;
02431
02432
02433 efab->link_up = gmii_link_ok ( efab );
02434
02435 if ( ! efab->link_up )
02436 return -EIO;
02437
02438
02439 advertised = gmii_autoneg_advertised ( efab );
02440 lpa = gmii_autoneg_lpa ( efab );
02441 efab->link_options = gmii_nway_result ( advertised & lpa );
02442
02443 return 0;
02444 }
02445
02446 static struct efab_phy_operations falcon_alaska_phy_ops = {
02447 .init = alaska_init,
02448 };
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458 #define XFP_REQUIRED_DEVS ( MDIO_MMDREG_DEVS0_PCS | \
02459 MDIO_MMDREG_DEVS0_PMAPMD | \
02460 MDIO_MMDREG_DEVS0_PHYXS )
02461
02462 static int
02463 falcon_xfp_phy_init ( struct efab_nic *efab )
02464 {
02465 int rc;
02466
02467
02468 efab->link_options = LPA_EF_10000FULL;
02469
02470
02471 rc = mdio_clause45_reset_mmd ( efab, MDIO_MMD_PHYXS );
02472 if ( rc )
02473 return rc;
02474
02475 return 0;
02476 }
02477
02478 static struct efab_phy_operations falcon_xfp_phy_ops = {
02479 .init = falcon_xfp_phy_init,
02480 .mmds = XFP_REQUIRED_DEVS,
02481 };
02482
02483
02484
02485
02486
02487
02488
02489
02490
02491
02492 #define TXC_GLRGS_GLCMD (0xc004)
02493 #define TXC_GLCMD_LMTSWRST_LBN (14)
02494
02495
02496 #define TXC_ALRGS_ATXAMP0 (0xc041)
02497 #define TXC_ALRGS_ATXAMP1 (0xc042)
02498
02499 #define TXC_ATXAMP_LANE02_LBN (3)
02500 #define TXC_ATXAMP_LANE13_LBN (11)
02501
02502 #define TXC_ATXAMP_1280_mV (0)
02503 #define TXC_ATXAMP_1200_mV (8)
02504 #define TXC_ATXAMP_1120_mV (12)
02505 #define TXC_ATXAMP_1060_mV (14)
02506 #define TXC_ATXAMP_0820_mV (25)
02507 #define TXC_ATXAMP_0720_mV (26)
02508 #define TXC_ATXAMP_0580_mV (27)
02509 #define TXC_ATXAMP_0440_mV (28)
02510
02511 #define TXC_ATXAMP_0820_BOTH ( (TXC_ATXAMP_0820_mV << TXC_ATXAMP_LANE02_LBN) | \
02512 (TXC_ATXAMP_0820_mV << TXC_ATXAMP_LANE13_LBN) )
02513
02514 #define TXC_ATXAMP_DEFAULT (0x6060)
02515
02516
02517 #define TXC_ALRGS_ATXPRE0 (0xc043)
02518 #define TXC_ALRGS_ATXPRE1 (0xc044)
02519
02520 #define TXC_ATXPRE_NONE (0)
02521 #define TXC_ATXPRE_DEFAULT (0x1010)
02522
02523 #define TXC_REQUIRED_DEVS ( MDIO_MMDREG_DEVS0_PCS | \
02524 MDIO_MMDREG_DEVS0_PMAPMD | \
02525 MDIO_MMDREG_DEVS0_PHYXS )
02526
02527 static int
02528 falcon_txc_logic_reset ( struct efab_nic *efab )
02529 {
02530 int val;
02531 int tries = 50;
02532
02533 val = falcon_mdio_read ( efab, MDIO_MMD_PCS, TXC_GLRGS_GLCMD );
02534 val |= (1 << TXC_GLCMD_LMTSWRST_LBN);
02535 falcon_mdio_write ( efab, MDIO_MMD_PCS, TXC_GLRGS_GLCMD, val );
02536
02537 while ( tries--) {
02538 val = falcon_mdio_read ( efab, MDIO_MMD_PCS, TXC_GLRGS_GLCMD );
02539 if ( ~val & ( 1 << TXC_GLCMD_LMTSWRST_LBN ) )
02540 return 0;
02541 udelay(1);
02542 }
02543
02544 EFAB_ERR ( "logic reset failed\n" );
02545
02546 return -ETIMEDOUT;
02547 }
02548
02549 static int
02550 falcon_txc_phy_init ( struct efab_nic *efab )
02551 {
02552 int rc;
02553
02554
02555 efab->link_options = LPA_EF_10000FULL;
02556
02557
02558 rc = mdio_clause45_reset_mmd ( efab, MDIO_MMD_PMAPMD );
02559 if ( rc )
02560 goto fail1;
02561
02562 rc = mdio_clause45_check_mmds ( efab );
02563 if ( rc )
02564 goto fail2;
02565
02566
02567
02568
02569
02570
02571
02572 falcon_mdio_write ( efab, MDIO_MMD_PHYXS, TXC_ALRGS_ATXPRE0,
02573 TXC_ATXPRE_NONE );
02574 falcon_mdio_write ( efab, MDIO_MMD_PHYXS, TXC_ALRGS_ATXPRE1,
02575 TXC_ATXPRE_NONE );
02576
02577
02578 falcon_mdio_write ( efab, MDIO_MMD_PHYXS, TXC_ALRGS_ATXAMP0,
02579 TXC_ATXAMP_0820_BOTH );
02580 falcon_mdio_write ( efab, MDIO_MMD_PHYXS, TXC_ALRGS_ATXAMP1,
02581 TXC_ATXAMP_0820_BOTH );
02582
02583
02584
02585
02586 falcon_mdio_write ( efab, MDIO_MMD_PMAPMD, TXC_ALRGS_ATXPRE0,
02587 TXC_ATXPRE_DEFAULT );
02588 falcon_mdio_write ( efab, MDIO_MMD_PMAPMD, TXC_ALRGS_ATXPRE1,
02589 TXC_ATXPRE_DEFAULT );
02590 falcon_mdio_write ( efab, MDIO_MMD_PMAPMD, TXC_ALRGS_ATXAMP0,
02591 TXC_ATXAMP_DEFAULT );
02592 falcon_mdio_write ( efab, MDIO_MMD_PMAPMD, TXC_ALRGS_ATXAMP1,
02593 TXC_ATXAMP_DEFAULT );
02594
02595 rc = falcon_txc_logic_reset ( efab );
02596 if ( rc )
02597 goto fail3;
02598
02599 return 0;
02600
02601 fail3:
02602 fail2:
02603 fail1:
02604 return rc;
02605 }
02606
02607 static struct efab_phy_operations falcon_txc_phy_ops = {
02608 .init = falcon_txc_phy_init,
02609 .mmds = TXC_REQUIRED_DEVS,
02610 };
02611
02612
02613
02614
02615
02616
02617
02618
02619
02620
02621 #define TENXPRESS_REQUIRED_DEVS ( MDIO_MMDREG_DEVS0_PMAPMD | \
02622 MDIO_MMDREG_DEVS0_PCS | \
02623 MDIO_MMDREG_DEVS0_PHYXS )
02624
02625 #define PCS_TEST_SELECT_REG 0xd807
02626 #define CLK312_EN_LBN 3
02627 #define CLK312_EN_WIDTH 1
02628
02629 #define PCS_CLOCK_CTRL_REG 0xd801
02630 #define PLL312_RST_N_LBN 2
02631
02632
02633 #define PMA_PMD_EXT_CTRL_REG 49152
02634 #define PMA_PMD_EXT_SSR_LBN 15
02635
02636
02637 #define PCS_BOOT_STATUS_REG 0xd000
02638 #define PCS_BOOT_FATAL_ERR_LBN 0
02639 #define PCS_BOOT_PROGRESS_LBN 1
02640 #define PCS_BOOT_PROGRESS_WIDTH 2
02641 #define PCS_BOOT_COMPLETE_LBN 3
02642
02643 #define PCS_SOFT_RST2_REG 0xd806
02644 #define SERDES_RST_N_LBN 13
02645 #define XGXS_RST_N_LBN 12
02646
02647 static int
02648 falcon_tenxpress_check_c11 ( struct efab_nic *efab )
02649 {
02650 int count;
02651 uint32_t boot_stat;
02652
02653
02654 for (count=0; count<10; count++) {
02655 boot_stat = falcon_mdio_read ( efab, MDIO_MMD_PCS,
02656 PCS_BOOT_STATUS_REG );
02657 if ( boot_stat & ( 1 << PCS_BOOT_COMPLETE_LBN ) )
02658 return 0;
02659
02660 udelay(10);
02661 }
02662
02663 EFAB_ERR ( "C11 failed to boot\n" );
02664 return -ETIMEDOUT;
02665 }
02666
02667 static int
02668 falcon_tenxpress_phy_init ( struct efab_nic *efab )
02669 {
02670 int rc, reg;
02671
02672
02673 efab->link_options = LPA_EF_10000FULL;
02674
02675
02676 rc = mdio_clause45_wait_reset_mmds ( efab );
02677 if ( rc )
02678 goto fail1;
02679
02680 rc = mdio_clause45_check_mmds ( efab );
02681 if ( rc )
02682 goto fail2;
02683
02684
02685 reg = (1 << CLK312_EN_LBN);
02686 falcon_mdio_write ( efab, MDIO_MMD_PCS, PCS_TEST_SELECT_REG, reg);
02687
02688
02689 mdelay(200);
02690
02691 rc = falcon_tenxpress_check_c11 ( efab );
02692 if ( rc )
02693 goto fail3;
02694
02695 return 0;
02696
02697 fail3:
02698 fail2:
02699 fail1:
02700 return rc;
02701 }
02702
02703 static struct efab_phy_operations falcon_tenxpress_phy_ops = {
02704 .init = falcon_tenxpress_phy_init,
02705 .mmds = TENXPRESS_REQUIRED_DEVS,
02706 };
02707
02708
02709
02710
02711
02712
02713
02714
02715
02716
02717 #define PM8358_REQUIRED_DEVS (MDIO_MMDREG_DEVS0_DTEXS)
02718
02719
02720
02721 #define PMC_MASTER_REG (0xd000)
02722
02723 #define PMC_MASTER_ANLG_CTRL (1<< 11)
02724
02725
02726 #define PMC_MCONF2_REG (0xd002)
02727
02728 #define PMC_MCONF2_TEDGE (1 << 2)
02729
02730 #define PMC_MCONF2_REDGE (1 << 3)
02731
02732
02733 #define PMC_ANALOG_RX_CFG0 (0xd025)
02734 #define PMC_ANALOG_RX_CFG1 (0xd02d)
02735 #define PMC_ANALOG_RX_CFG2 (0xd035)
02736 #define PMC_ANALOG_RX_CFG3 (0xd03d)
02737
02738
02739 #define PMC_ANALOG_RX_TERM (1 << 15)
02740
02741 #define PMC_ANALOG_RX_EQ_MASK (3 << 8)
02742 #define PMC_ANALOG_RX_EQ_NONE (0 << 8)
02743 #define PMC_ANALOG_RX_EQ_HALF (1 << 8)
02744 #define PMC_ANALOG_RX_EQ_FULL (2 << 8)
02745 #define PMC_ANALOG_RX_EQ_RSVD (3 << 8)
02746
02747 static int
02748 falcon_pm8358_phy_init ( struct efab_nic *efab )
02749 {
02750 int rc, reg, i;
02751
02752
02753 efab->link_options = LPA_EF_10000FULL;
02754
02755 rc = mdio_clause45_reset_mmd ( efab, MDIO_MMDREG_DEVS0_DTEXS );
02756 if ( rc )
02757 return rc;
02758
02759
02760 reg = falcon_mdio_read ( efab, MDIO_MMD_DTEXS, PMC_MASTER_REG );
02761 reg |= PMC_MASTER_ANLG_CTRL;
02762 falcon_mdio_write ( efab, MDIO_MMD_DTEXS, PMC_MASTER_REG, reg );
02763
02764
02765 for (i=0; i< 3; i++) {
02766
02767 uint16_t addr = PMC_ANALOG_RX_CFG0 + 8*i;
02768 reg = falcon_mdio_read ( efab, MDIO_MMD_DTEXS, addr );
02769 reg = ( reg & ~PMC_ANALOG_RX_EQ_MASK ) | PMC_ANALOG_RX_EQ_FULL;
02770 falcon_mdio_write ( efab, MDIO_MMD_DTEXS, addr, reg );
02771 }
02772
02773
02774 reg = falcon_mdio_read ( efab, MDIO_MMD_DTEXS, PMC_MCONF2_REG );
02775 reg = ( reg & ~PMC_MCONF2_REDGE) | PMC_MCONF2_TEDGE;
02776 falcon_mdio_write ( efab, MDIO_MMD_DTEXS, PMC_MCONF2_REG, reg );
02777
02778 return 0;
02779 }
02780
02781 static struct efab_phy_operations falcon_pm8358_phy_ops = {
02782 .init = falcon_pm8358_phy_init,
02783 .mmds = PM8358_REQUIRED_DEVS,
02784 };
02785
02786
02787
02788
02789
02790
02791
02792
02793
02794 #define MAX_TEMP_THRESH 90
02795
02796
02797 #define PCA9539 0x74
02798
02799 #define P0_IN 0x00
02800 #define P0_OUT 0x02
02801 #define P0_CONFIG 0x06
02802
02803 #define P0_EN_1V0X_LBN 0
02804 #define P0_EN_1V0X_WIDTH 1
02805 #define P0_EN_1V2_LBN 1
02806 #define P0_EN_1V2_WIDTH 1
02807 #define P0_EN_2V5_LBN 2
02808 #define P0_EN_2V5_WIDTH 1
02809 #define P0_EN_3V3X_LBN 3
02810 #define P0_EN_3V3X_WIDTH 1
02811 #define P0_EN_5V_LBN 4
02812 #define P0_EN_5V_WIDTH 1
02813 #define P0_X_TRST_LBN 6
02814 #define P0_X_TRST_WIDTH 1
02815
02816 #define P1_IN 0x01
02817 #define P1_CONFIG 0x07
02818
02819 #define P1_AFE_PWD_LBN 0
02820 #define P1_AFE_PWD_WIDTH 1
02821 #define P1_DSP_PWD25_LBN 1
02822 #define P1_DSP_PWD25_WIDTH 1
02823 #define P1_SPARE_LBN 4
02824 #define P1_SPARE_WIDTH 4
02825
02826
02827 #define MAX6647 0x4e
02828
02829 #define RSL 0x02
02830 #define RLHN 0x05
02831 #define WLHO 0x0b
02832
02833 static struct i2c_device i2c_pca9539 = {
02834 .dev_addr = PCA9539,
02835 .dev_addr_len = 1,
02836 .word_addr_len = 1,
02837 };
02838
02839
02840 static struct i2c_device i2c_max6647 = {
02841 .dev_addr = MAX6647,
02842 .dev_addr_len = 1,
02843 .word_addr_len = 1,
02844 };
02845
02846 static int
02847 sfe4001_init ( struct efab_nic *efab )
02848 {
02849 struct i2c_interface *i2c = &efab->i2c_bb.i2c;
02850 efab_dword_t reg;
02851 uint8_t in, cfg, out;
02852 int count, rc;
02853
02854 EFAB_LOG ( "Initialise SFE4001 board\n" );
02855
02856
02857 EFAB_POPULATE_DWORD_7 ( reg,
02858 FCN_XX_PWRDNA_EN, 1,
02859 FCN_XX_PWRDNB_EN, 1,
02860 FCN_XX_RSTPLLAB_EN, 1,
02861 FCN_XX_RESETA_EN, 1,
02862 FCN_XX_RESETB_EN, 1,
02863 FCN_XX_RSTXGXSRX_EN, 1,
02864 FCN_XX_RSTXGXSTX_EN, 1 );
02865 falcon_xmac_writel ( efab, ®, FCN_XX_PWR_RST_REG_MAC);
02866 udelay(10);
02867
02868
02869 cfg = MAX_TEMP_THRESH;
02870 rc = i2c->write ( i2c, &i2c_max6647, WLHO, &cfg, EFAB_BYTE );
02871 if ( rc )
02872 goto fail1;
02873
02874
02875 rc = i2c->read ( i2c, &i2c_max6647, RLHN, &in, EFAB_BYTE );
02876 if ( rc )
02877 goto fail2;
02878
02879 if ( in != MAX_TEMP_THRESH ) {
02880 EFAB_ERR ( "Unable to verify MAX6647 limit (requested=%d "
02881 "confirmed=%d)\n", cfg, in );
02882 rc = -EIO;
02883 goto fail3;
02884 }
02885
02886
02887 rc = i2c->read ( i2c, &i2c_max6647, RSL, &in, EFAB_BYTE );
02888 if ( rc )
02889 goto fail4;
02890
02891
02892 cfg = 0x00;
02893 rc = i2c->write ( i2c, &i2c_pca9539, P0_CONFIG, &cfg, EFAB_BYTE );
02894 if ( rc )
02895 goto fail5;
02896 cfg = 0xff & ~(1 << P1_SPARE_LBN);
02897 rc = i2c->write ( i2c, &i2c_pca9539, P1_CONFIG, &cfg, EFAB_BYTE );
02898 if ( rc )
02899 goto fail6;
02900
02901
02902 out = 0xff & ~((0 << P0_EN_1V2_LBN) | (0 << P0_EN_2V5_LBN) |
02903 (0 << P0_EN_3V3X_LBN) | (0 << P0_EN_5V_LBN) |
02904 (0 << P0_EN_1V0X_LBN));
02905
02906 rc = i2c->write ( i2c, &i2c_pca9539, P0_OUT, &out, EFAB_BYTE );
02907 if ( rc )
02908 goto fail7;
02909
02910 mdelay(1000);
02911
02912 for (count=0; count<20; count++) {
02913
02914 out = 0xff & ~( (1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) |
02915 (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) |
02916 (1 << P0_X_TRST_LBN) );
02917
02918 rc = i2c->write ( i2c, &i2c_pca9539, P0_OUT, &out, EFAB_BYTE );
02919 if ( rc )
02920 goto fail8;
02921
02922 mdelay ( 10 );
02923
02924
02925 out &= ~( 1 << P0_EN_1V0X_LBN );
02926 rc = i2c->write ( i2c, &i2c_pca9539, P0_OUT, &out, EFAB_BYTE );
02927 if ( rc )
02928 goto fail9;
02929
02930 EFAB_LOG ( "Waiting for power...(attempt %d)\n", count);
02931 mdelay ( 1000 );
02932
02933
02934 rc = i2c->read ( i2c, &i2c_pca9539, P1_IN, &in, EFAB_BYTE );
02935 if ( rc )
02936 goto fail10;
02937
02938 if ( in & ( 1 << P1_AFE_PWD_LBN ) )
02939 return 0;
02940 }
02941
02942 rc = -ETIMEDOUT;
02943
02944 fail10:
02945 fail9:
02946 fail8:
02947 fail7:
02948
02949 out = 0xff;
02950 (void) i2c->write ( i2c, &i2c_pca9539, P0_OUT, &out, EFAB_BYTE );
02951
02952 out = 0xff;
02953 (void) i2c->write ( i2c, &i2c_pca9539, P1_CONFIG, &out, EFAB_BYTE );
02954 fail6:
02955
02956 out = 0xff;
02957 (void) i2c->write ( i2c, &i2c_pca9539, P1_CONFIG, &out, EFAB_BYTE );
02958 fail5:
02959 fail4:
02960 fail3:
02961 fail2:
02962 fail1:
02963 EFAB_ERR ( "Failed initialising SFE4001 board\n" );
02964 return rc;
02965 }
02966
02967 static void
02968 sfe4001_fini ( struct efab_nic *efab )
02969 {
02970 struct i2c_interface *i2c = &efab->i2c_bb.i2c;
02971 uint8_t in, cfg, out;
02972
02973 EFAB_ERR ( "Turning off SFE4001\n" );
02974
02975
02976 out = 0xff;
02977 (void) i2c->write ( i2c, &i2c_pca9539, P0_OUT, &out, EFAB_BYTE );
02978
02979
02980 cfg = 0xff;
02981 (void) i2c->write ( i2c, &i2c_pca9539, P1_CONFIG, &cfg, EFAB_BYTE );
02982
02983
02984 cfg = 0xff;
02985 (void) i2c->write ( i2c, &i2c_pca9539, P0_CONFIG, &cfg, EFAB_BYTE );
02986
02987
02988 (void) i2c->read ( i2c, &i2c_max6647, RSL, &in, EFAB_BYTE );
02989 }
02990
02991 struct efab_board_operations sfe4001_ops = {
02992 .init = sfe4001_init,
02993 .fini = sfe4001_fini,
02994 };
02995
02996 static int sfe4002_init ( struct efab_nic *efab __attribute__((unused)) )
02997 {
02998 return 0;
02999 }
03000 static void sfe4002_fini ( struct efab_nic *efab __attribute__((unused)) )
03001 {
03002 }
03003
03004 struct efab_board_operations sfe4002_ops = {
03005 .init = sfe4002_init,
03006 .fini = sfe4002_fini,
03007 };
03008
03009 static int sfe4003_init ( struct efab_nic *efab __attribute__((unused)) )
03010 {
03011 return 0;
03012 }
03013 static void sfe4003_fini ( struct efab_nic *efab __attribute__((unused)) )
03014 {
03015 }
03016
03017 struct efab_board_operations sfe4003_ops = {
03018 .init = sfe4003_init,
03019 .fini = sfe4003_fini,
03020 };
03021
03022
03023
03024
03025
03026
03027
03028
03029
03030 static void
03031 falcon_free_special_buffer ( void *p )
03032 {
03033
03034
03035 free_dma ( p, EFAB_BUF_ALIGN );
03036 }
03037
03038 static void*
03039 falcon_alloc_special_buffer ( struct efab_nic *efab, int bytes,
03040 struct efab_special_buffer *entry )
03041 {
03042 void* buffer;
03043 int remaining;
03044 efab_qword_t buf_desc;
03045 unsigned long dma_addr;
03046
03047
03048 buffer = malloc_dma ( bytes, EFAB_BUF_ALIGN );
03049 if ( ! buffer )
03050 return NULL;
03051
03052
03053 entry->id = efab->buffer_head;
03054 entry->dma_addr = dma_addr = virt_to_bus ( buffer );
03055 assert ( ( dma_addr & ( EFAB_BUF_ALIGN - 1 ) ) == 0 );
03056
03057 remaining = bytes;
03058 while ( remaining > 0 ) {
03059 EFAB_POPULATE_QWORD_3 ( buf_desc,
03060 FCN_IP_DAT_BUF_SIZE, FCN_IP_DAT_BUF_SIZE_4K,
03061 FCN_BUF_ADR_FBUF, ( dma_addr >> 12 ),
03062 FCN_BUF_OWNER_ID_FBUF, 0 );
03063
03064 falcon_write_sram ( efab, &buf_desc, efab->buffer_head );
03065
03066 ++efab->buffer_head;
03067 dma_addr += EFAB_BUF_ALIGN;
03068 remaining -= EFAB_BUF_ALIGN;
03069 }
03070
03071 EFAB_TRACE ( "Allocated 0x%x bytes at %p backed by buffer table "
03072 "entries 0x%x..0x%x\n", bytes, buffer, entry->id,
03073 efab->buffer_head - 1 );
03074
03075 return buffer;
03076 }
03077
03078 static void
03079 clear_b0_fpga_memories ( struct efab_nic *efab)
03080 {
03081 efab_oword_t blanko, temp;
03082 efab_dword_t blankd;
03083 int offset;
03084
03085 EFAB_ZERO_OWORD ( blanko );
03086 EFAB_ZERO_DWORD ( blankd );
03087
03088
03089 EFAB_POPULATE_OWORD_4 ( temp,
03090 FCN_ADR_REGION0, 0,
03091 FCN_ADR_REGION1, ( 1 << 16 ),
03092 FCN_ADR_REGION2, ( 2 << 16 ),
03093 FCN_ADR_REGION3, ( 3 << 16 ) );
03094 falcon_write ( efab, &temp, FCN_ADR_REGION_REG_KER );
03095
03096 EFAB_TRACE ( "Clearing filter and RSS tables\n" );
03097
03098 for ( offset = FCN_RX_FILTER_TBL0 ;
03099 offset < FCN_RX_RSS_INDIR_TBL_B0+0x800 ;
03100 offset += 0x10 ) {
03101 falcon_write ( efab, &blanko, offset );
03102 }
03103
03104 EFAB_TRACE ( "Wiping buffer tables\n" );
03105
03106
03107 for ( offset = 0x2800000 ;
03108 offset < 0x3000000 ;
03109 offset += 0x8) {
03110 _falcon_writel ( efab, 0, offset );
03111 _falcon_writel ( efab, 0, offset + 4 );
03112 wmb();
03113 }
03114 }
03115
03116 static int
03117 falcon_reset ( struct efab_nic *efab )
03118 {
03119 efab_oword_t glb_ctl_reg_ker;
03120
03121
03122 EFAB_POPULATE_OWORD_6 ( glb_ctl_reg_ker,
03123 FCN_PCIE_CORE_RST_CTL, EXCLUDE_FROM_RESET,
03124 FCN_PCIE_NSTCK_RST_CTL, EXCLUDE_FROM_RESET,
03125 FCN_PCIE_SD_RST_CTL, EXCLUDE_FROM_RESET,
03126 FCN_EE_RST_CTL, EXCLUDE_FROM_RESET,
03127 FCN_EXT_PHY_RST_DUR, 0x7,
03128 FCN_SWRST, 1 );
03129
03130 falcon_write ( efab, &glb_ctl_reg_ker, FCN_GLB_CTL_REG_KER );
03131
03132
03133 mdelay ( 50 );
03134
03135
03136 falcon_read ( efab, &glb_ctl_reg_ker, FCN_GLB_CTL_REG_KER );
03137 if ( EFAB_OWORD_FIELD ( glb_ctl_reg_ker, FCN_SWRST ) != 0 ) {
03138 EFAB_ERR ( "Reset failed\n" );
03139 return -ETIMEDOUT;
03140 }
03141
03142 if ( ( efab->pci_revision == FALCON_REV_B0 ) && !efab->is_asic ) {
03143 clear_b0_fpga_memories ( efab );
03144 }
03145
03146 return 0;
03147 }
03148
03149
03150 #define FALCON_MAC_ADDRESS_OFFSET 0x310
03151
03152
03153
03154
03155 #define SF_NV_CONFIG_BASE 0x300
03156 #define SF_NV_CONFIG_EXTRA 0xA0
03157
03158 struct falcon_nv_config_ver2 {
03159 uint16_t nports;
03160 uint8_t port0_phy_addr;
03161 uint8_t port0_phy_type;
03162 uint8_t port1_phy_addr;
03163 uint8_t port1_phy_type;
03164 uint16_t asic_sub_revision;
03165 uint16_t board_revision;
03166 uint8_t mac_location;
03167 };
03168
03169 struct falcon_nv_extra {
03170 uint16_t magicnumber;
03171 uint16_t structure_version;
03172 uint16_t checksum;
03173 union {
03174 struct falcon_nv_config_ver2 ver2;
03175 } ver_specific;
03176 };
03177
03178 #define BOARD_TYPE(_rev) (_rev >> 8)
03179
03180 static void
03181 falcon_probe_nic_variant ( struct efab_nic *efab, struct pci_device *pci )
03182 {
03183 efab_oword_t altera_build, nic_stat;
03184 int is_pcie, fpga_version;
03185 uint8_t revision;
03186
03187
03188 pci_read_config_byte ( pci, PCI_CLASS_REVISION, &revision );
03189 efab->pci_revision = revision;
03190
03191
03192 falcon_read ( efab, &altera_build, FCN_ALTERA_BUILD_REG_KER );
03193 fpga_version = EFAB_OWORD_FIELD ( altera_build, FCN_VER_ALL );
03194 efab->is_asic = (fpga_version == 0);
03195
03196
03197 falcon_read ( efab, &nic_stat, FCN_NIC_STAT_REG );
03198 if ( efab->pci_revision == FALCON_REV_B0 ) {
03199 is_pcie = 1;
03200 efab->phy_10g = EFAB_OWORD_FIELD ( nic_stat, FCN_STRAP_10G );
03201 }
03202 else if ( efab->is_asic ) {
03203 is_pcie = EFAB_OWORD_FIELD ( nic_stat, FCN_STRAP_PCIE );
03204 efab->phy_10g = EFAB_OWORD_FIELD ( nic_stat, FCN_STRAP_10G );
03205 }
03206 else {
03207 int minor = EFAB_OWORD_FIELD ( altera_build, FCN_VER_MINOR );
03208 is_pcie = 0;
03209 efab->phy_10g = ( minor == 0x14 );
03210 }
03211 }
03212
03213 static void
03214 falcon_init_spi_device ( struct efab_nic *efab, struct spi_device *spi )
03215 {
03216
03217
03218
03219 if ( spi->nvs.block_size > FALCON_SPI_MAX_LEN )
03220 spi->nvs.block_size = FALCON_SPI_MAX_LEN;
03221
03222 spi->bus = &efab->spi_bus;
03223 efab->spi = spi;
03224 }
03225
03226 static int
03227 falcon_probe_spi ( struct efab_nic *efab )
03228 {
03229 efab_oword_t nic_stat, gpio_ctl, ee_vpd_cfg;
03230 int has_flash, has_eeprom, ad9bit;
03231
03232 falcon_read ( efab, &nic_stat, FCN_NIC_STAT_REG );
03233 falcon_read ( efab, &gpio_ctl, FCN_GPIO_CTL_REG_KER );
03234 falcon_read ( efab, &ee_vpd_cfg, FCN_EE_VPD_CFG_REG );
03235
03236
03237 if ( ( efab->pci_revision >= FALCON_REV_B0 ) || efab->is_asic ) {
03238 has_flash = EFAB_OWORD_FIELD ( nic_stat, FCN_SF_PRST );
03239 has_eeprom = EFAB_OWORD_FIELD ( nic_stat, FCN_EE_PRST );
03240 } else {
03241 has_flash = EFAB_OWORD_FIELD ( gpio_ctl, FCN_FLASH_PRESENT );
03242 has_eeprom = EFAB_OWORD_FIELD ( gpio_ctl, FCN_EEPROM_PRESENT );
03243 }
03244 ad9bit = EFAB_OWORD_FIELD ( ee_vpd_cfg, FCN_EE_VPD_EN_AD9_MODE );
03245
03246
03247 efab->spi_bus.rw = falcon_spi_rw;
03248 init_i2c_bit_basher ( &efab->i2c_bb, &falcon_i2c_bit_ops );
03249
03250
03251
03252
03253
03254 if ( has_eeprom ) {
03255 if ( has_flash && ad9bit )
03256 init_at25040 ( &efab->spi_eeprom );
03257 else
03258 init_mc25xx640 ( &efab->spi_eeprom );
03259 falcon_init_spi_device ( efab, &efab->spi_eeprom );
03260 }
03261
03262
03263 if ( has_flash ) {
03264 init_at25f1024 ( &efab->spi_flash );
03265 falcon_init_spi_device ( efab, &efab->spi_flash );
03266 }
03267
03268 EFAB_LOG ( "flash is %s, EEPROM is %s%s\n",
03269 ( has_flash ? "present" : "absent" ),
03270 ( has_eeprom ? "present " : "absent" ),
03271 ( has_eeprom ? (ad9bit ? "(9bit)" : "(16bit)") : "") );
03272
03273
03274 if ( ! efab->spi ) {
03275 EFAB_ERR ( "Device appears to have no flash or eeprom\n" );
03276 return -EIO;
03277 }
03278
03279
03280 if ( has_eeprom )
03281 nvo_init ( &efab->nvo, &efab->spi_eeprom.nvs, falcon_nvo_fragments,
03282 &efab->netdev->refcnt );
03283
03284 return 0;
03285 }
03286
03287 static int
03288 falcon_probe_nvram ( struct efab_nic *efab )
03289 {
03290 struct nvs_device *nvs = &efab->spi->nvs;
03291 struct falcon_nv_extra nv;
03292 int rc, board_revision;
03293
03294
03295 rc = nvs_read ( nvs, FALCON_MAC_ADDRESS_OFFSET,
03296 efab->mac_addr, ETH_ALEN );
03297 if ( rc )
03298 return rc;
03299
03300
03301 rc = nvs_read ( nvs, SF_NV_CONFIG_BASE + SF_NV_CONFIG_EXTRA,
03302 &nv, sizeof ( nv ) );
03303 if ( rc )
03304 return rc;
03305
03306
03307 if ( ( le16_to_cpu ( nv.magicnumber ) == FCN_NV_MAGIC_NUMBER ) &&
03308 ( le16_to_cpu ( nv.structure_version ) >= 2 ) ) {
03309 struct falcon_nv_config_ver2* ver2 = &nv.ver_specific.ver2;
03310
03311
03312 efab->phy_addr = le16_to_cpu ( ver2->port0_phy_addr );
03313 efab->phy_type = le16_to_cpu ( ver2->port0_phy_type );
03314 board_revision = le16_to_cpu ( ver2->board_revision );
03315 }
03316 else {
03317 EFAB_ERR ( "NVram is not recognised\n" );
03318 return -EINVAL;
03319 }
03320
03321 efab->board_type = BOARD_TYPE ( board_revision );
03322
03323 EFAB_TRACE ( "Falcon board %d phy %d @ addr %d\n",
03324 efab->board_type, efab->phy_type, efab->phy_addr );
03325
03326
03327 switch ( efab->board_type ) {
03328 case EFAB_BOARD_SFE4001:
03329 efab->board_op = &sfe4001_ops;
03330 break;
03331 case EFAB_BOARD_SFE4002:
03332 efab->board_op = &sfe4002_ops;
03333 break;
03334 case EFAB_BOARD_SFE4003:
03335 efab->board_op = &sfe4003_ops;
03336 break;
03337 default:
03338 EFAB_ERR ( "Unrecognised board type\n" );
03339 return -EINVAL;
03340 }
03341
03342
03343 if ( efab->phy_10g )
03344 efab->mac_op = &falcon_xmac_operations;
03345 else
03346 efab->mac_op = &falcon_gmac_operations;
03347
03348
03349 switch ( efab->phy_type ) {
03350 case PHY_TYPE_10XPRESS:
03351 efab->phy_op = &falcon_tenxpress_phy_ops;
03352 break;
03353 case PHY_TYPE_CX4:
03354 efab->phy_op = &falcon_xaui_phy_ops;
03355 break;
03356 case PHY_TYPE_XFP:
03357 efab->phy_op = &falcon_xfp_phy_ops;
03358 break;
03359 case PHY_TYPE_CX4_RTMR:
03360 efab->phy_op = &falcon_txc_phy_ops;
03361 break;
03362 case PHY_TYPE_PM8358:
03363 efab->phy_op = &falcon_pm8358_phy_ops;
03364 break;
03365 case PHY_TYPE_1GIG_ALASKA:
03366 efab->phy_op = &falcon_alaska_phy_ops;
03367 break;
03368 default:
03369 EFAB_ERR ( "Unknown PHY type: %d\n", efab->phy_type );
03370 return -EINVAL;
03371 }
03372
03373 return 0;
03374 }
03375
03376 static int
03377 falcon_init_sram ( struct efab_nic *efab )
03378 {
03379 efab_oword_t reg;
03380 int count;
03381
03382
03383 falcon_read ( efab, ®, FCN_NIC_STAT_REG );
03384 EFAB_SET_OWORD_FIELD ( reg, FCN_ONCHIP_SRAM, 1 );
03385 falcon_write ( efab, ®, FCN_NIC_STAT_REG );
03386
03387
03388 EFAB_POPULATE_OWORD_2 ( reg,
03389 FCN_GPIO1_OEN, 1,
03390 FCN_GPIO1_OUT, 1 );
03391 falcon_write ( efab, ®, FCN_GPIO_CTL_REG_KER );
03392
03393
03394 EFAB_POPULATE_OWORD_2 ( reg,
03395 FCN_SRAM_OOB_BT_INIT_EN, 1,
03396 FCN_SRM_NUM_BANKS_AND_BANK_SIZE, 0 );
03397 falcon_write ( efab, ®, FCN_SRM_CFG_REG_KER );
03398
03399
03400 count = 0;
03401 do {
03402
03403 mdelay ( 20 );
03404
03405
03406 falcon_read ( efab, ®, FCN_SRM_CFG_REG_KER );
03407 if ( !EFAB_OWORD_FIELD ( reg, FCN_SRAM_OOB_BT_INIT_EN ) )
03408 return 0;
03409 } while (++count < 20);
03410
03411 EFAB_ERR ( "timed out waiting for SRAM reset\n");
03412 return -ETIMEDOUT;
03413 }
03414
03415 static void
03416 falcon_setup_nic ( struct efab_nic *efab )
03417 {
03418 efab_dword_t timer_cmd;
03419 efab_oword_t reg;
03420 int tx_fc, xoff_thresh, xon_thresh;
03421
03422
03423
03424
03425 falcon_read ( efab, ®, FCN_SPARE_REG_KER );
03426 EFAB_SET_OWORD_FIELD ( reg, FCN_MEM_PERR_EN_TX_DATA, 0 );
03427 falcon_write ( efab, ®, FCN_SPARE_REG_KER );
03428
03429
03430 EFAB_POPULATE_OWORD_1 ( reg, FCN_SRM_TX_DC_BASE_ADR, 0x130000 );
03431 falcon_write ( efab, ®, FCN_SRM_TX_DC_CFG_REG_KER );
03432 EFAB_POPULATE_OWORD_1 ( reg, FCN_TX_DC_SIZE, 1 );
03433 falcon_write ( efab, ®, FCN_TX_DC_CFG_REG_KER );
03434 EFAB_POPULATE_OWORD_1 ( reg, FCN_SRM_RX_DC_BASE_ADR, 0x100000 );
03435 falcon_write ( efab, ®, FCN_SRM_RX_DC_CFG_REG_KER );
03436 EFAB_POPULATE_OWORD_1 ( reg, FCN_RX_DC_SIZE, 2 );
03437 falcon_write ( efab, ®, FCN_RX_DC_CFG_REG_KER );
03438
03439
03440
03441
03442 EFAB_POPULATE_OWORD_5 ( reg,
03443 FCN_NUM_KER, 0,
03444 FCN_UDP_FULL_SRCH_LIMIT, 8,
03445 FCN_UDP_WILD_SRCH_LIMIT, 8,
03446 FCN_TCP_WILD_SRCH_LIMIT, 8,
03447 FCN_TCP_FULL_SRCH_LIMIT, 8);
03448 falcon_write ( efab, ®, FCN_RX_FILTER_CTL_REG_KER );
03449 udelay ( 1000 );
03450
03451
03452
03453
03454
03455 falcon_read ( efab, ®, FCN_RX_SELF_RST_REG_KER );
03456 EFAB_SET_OWORD_FIELD ( reg, FCN_RX_NODESC_WAIT_DIS, 1 );
03457 EFAB_SET_OWORD_FIELD ( reg, FCN_RX_RECOVERY_EN, 1 );
03458 EFAB_SET_OWORD_FIELD ( reg, FCN_RX_ISCSI_DIS, 1 );
03459 falcon_write ( efab, ®, FCN_RX_SELF_RST_REG_KER );
03460
03461
03462
03463 if ( efab->pci_revision == FALCON_REV_B0 ) {
03464 tx_fc = 1;
03465 xoff_thresh = 54272;
03466 xon_thresh = 27648;
03467 }
03468 else if ( !efab->phy_10g ) {
03469 tx_fc = 1;
03470 xoff_thresh = 2048;
03471 xon_thresh = 512;
03472 }
03473 else {
03474 tx_fc = xoff_thresh = xon_thresh = 0;
03475 }
03476
03477
03478 falcon_read ( efab, ®, FCN_TX_CFG2_REG_KER );
03479 EFAB_SET_OWORD_FIELD ( reg, FCN_TX_DIS_NON_IP_EV, 1 );
03480 falcon_write ( efab, ®, FCN_TX_CFG2_REG_KER );
03481
03482 falcon_read ( efab, ®, FCN_RX_CFG_REG_KER );
03483 EFAB_SET_OWORD_FIELD_VER ( efab, reg, FCN_RX_USR_BUF_SIZE,
03484 (3*4096) / 32 );
03485 if ( efab->pci_revision == FALCON_REV_B0)
03486 EFAB_SET_OWORD_FIELD ( reg, FCN_RX_INGR_EN_B0, 1 );
03487 EFAB_SET_OWORD_FIELD_VER ( efab, reg, FCN_RX_XON_MAC_TH,
03488 xon_thresh / 256);
03489 EFAB_SET_OWORD_FIELD_VER ( efab, reg, FCN_RX_XOFF_MAC_TH,
03490 xoff_thresh / 256);
03491 EFAB_SET_OWORD_FIELD_VER ( efab, reg, FCN_RX_XOFF_MAC_EN, tx_fc);
03492 falcon_write ( efab, ®, FCN_RX_CFG_REG_KER );
03493
03494
03495 EFAB_POPULATE_DWORD_2 ( timer_cmd,
03496 FCN_TIMER_MODE, FCN_TIMER_MODE_DIS,
03497 FCN_TIMER_VAL, 0 );
03498 falcon_writel ( efab, &timer_cmd, FCN_TIMER_CMD_REG_KER );
03499 }
03500
03501 static void
03502 falcon_init_resources ( struct efab_nic *efab )
03503 {
03504 struct efab_ev_queue *ev_queue = &efab->ev_queue;
03505 struct efab_rx_queue *rx_queue = &efab->rx_queue;
03506 struct efab_tx_queue *tx_queue = &efab->tx_queue;
03507
03508 efab_oword_t reg;
03509 int jumbo;
03510
03511
03512 tx_queue->read_ptr = tx_queue->write_ptr = 0;
03513 rx_queue->read_ptr = rx_queue->write_ptr = 0;
03514 ev_queue->read_ptr = 0;
03515
03516
03517 EFAB_POPULATE_OWORD_3 ( reg,
03518 FCN_EVQ_EN, 1,
03519 FCN_EVQ_SIZE, FQS(FCN_EVQ, EFAB_EVQ_SIZE),
03520 FCN_EVQ_BUF_BASE_ID, ev_queue->entry.id );
03521 falcon_write ( efab, ®,
03522 FCN_REVISION_REG ( efab, FCN_EVQ_PTR_TBL_KER ) );
03523
03524
03525 EFAB_POPULATE_OWORD_8 ( reg,
03526 FCN_TX_DESCQ_EN, 1,
03527 FCN_TX_ISCSI_DDIG_EN, 0,
03528 FCN_TX_ISCSI_DDIG_EN, 0,
03529 FCN_TX_DESCQ_BUF_BASE_ID, tx_queue->entry.id,
03530 FCN_TX_DESCQ_EVQ_ID, 0,
03531 FCN_TX_DESCQ_SIZE, FQS(FCN_TX_DESCQ, EFAB_TXD_SIZE),
03532 FCN_TX_DESCQ_TYPE, 0 ,
03533 FCN_TX_NON_IP_DROP_DIS_B0, 1 );
03534 falcon_write ( efab, ®,
03535 FCN_REVISION_REG ( efab, FCN_TX_DESC_PTR_TBL_KER ) );
03536
03537
03538 jumbo = ( efab->pci_revision == FALCON_REV_B0 ) ? 0 : 1;
03539 EFAB_POPULATE_OWORD_8 ( reg,
03540 FCN_RX_ISCSI_DDIG_EN, 0,
03541 FCN_RX_ISCSI_HDIG_EN, 0,
03542 FCN_RX_DESCQ_BUF_BASE_ID, rx_queue->entry.id,
03543 FCN_RX_DESCQ_EVQ_ID, 0,
03544 FCN_RX_DESCQ_SIZE, FQS(FCN_RX_DESCQ, EFAB_RXD_SIZE),
03545 FCN_RX_DESCQ_TYPE, 0 ,
03546 FCN_RX_DESCQ_JUMBO, jumbo,
03547 FCN_RX_DESCQ_EN, 1 );
03548 falcon_write ( efab, ®,
03549 FCN_REVISION_REG ( efab, FCN_RX_DESC_PTR_TBL_KER ) );
03550
03551
03552 EFAB_POPULATE_OWORD_1 ( reg,
03553 FCN_INT_ADR_KER, virt_to_bus ( &efab->int_ker ) );
03554 falcon_write ( efab, ®, FCN_INT_ADR_REG_KER );
03555
03556
03557 falcon_eventq_read_ack ( efab, ev_queue );
03558 }
03559
03560 static void
03561 falcon_fini_resources ( struct efab_nic *efab )
03562 {
03563 efab_oword_t cmd;
03564
03565
03566 falcon_interrupts ( efab, 0, 0 );
03567
03568
03569 EFAB_POPULATE_OWORD_2 ( cmd,
03570 FCN_TX_FLUSH_DESCQ_CMD, 1,
03571 FCN_TX_FLUSH_DESCQ, 0 );
03572 falcon_write ( efab, &cmd,
03573 FCN_REVISION_REG ( efab, FCN_TX_DESC_PTR_TBL_KER ) );
03574
03575 EFAB_POPULATE_OWORD_2 ( cmd,
03576 FCN_RX_FLUSH_DESCQ_CMD, 1,
03577 FCN_RX_FLUSH_DESCQ, 0 );
03578 falcon_write ( efab, &cmd,
03579 FCN_REVISION_REG ( efab, FCN_RX_DESC_PTR_TBL_KER ) );
03580
03581 mdelay ( 100 );
03582
03583
03584 EFAB_ZERO_OWORD ( cmd );
03585 falcon_write ( efab, &cmd,
03586 FCN_REVISION_REG ( efab, FCN_TX_DESC_PTR_TBL_KER ) );
03587 falcon_write ( efab, &cmd,
03588 FCN_REVISION_REG ( efab, FCN_RX_DESC_PTR_TBL_KER ) );
03589 falcon_write ( efab, &cmd,
03590 FCN_REVISION_REG ( efab, FCN_EVQ_PTR_TBL_KER ) );
03591 }
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601 static void
03602 falcon_build_rx_desc ( falcon_rx_desc_t *rxd, struct io_buffer *iob )
03603 {
03604 EFAB_POPULATE_QWORD_2 ( *rxd,
03605 FCN_RX_KER_BUF_SIZE, EFAB_RX_BUF_SIZE,
03606 FCN_RX_KER_BUF_ADR, virt_to_bus ( iob->data ) );
03607 }
03608
03609 static void
03610 falcon_notify_rx_desc ( struct efab_nic *efab, struct efab_rx_queue *rx_queue )
03611 {
03612 efab_dword_t reg;
03613 int ptr = rx_queue->write_ptr % EFAB_RXD_SIZE;
03614
03615 EFAB_POPULATE_DWORD_1 ( reg, FCN_RX_DESC_WPTR_DWORD, ptr );
03616 falcon_writel ( efab, ®, FCN_RX_DESC_UPD_REG_KER_DWORD );
03617 }
03618
03619
03620
03621
03622
03623
03624
03625
03626
03627
03628 static void
03629 falcon_build_tx_desc ( falcon_tx_desc_t *txd, struct io_buffer *iob )
03630 {
03631 EFAB_POPULATE_QWORD_2 ( *txd,
03632 FCN_TX_KER_BYTE_CNT, iob_len ( iob ),
03633 FCN_TX_KER_BUF_ADR, virt_to_bus ( iob->data ) );
03634 }
03635
03636 static void
03637 falcon_notify_tx_desc ( struct efab_nic *efab,
03638 struct efab_tx_queue *tx_queue )
03639 {
03640 efab_dword_t reg;
03641 int ptr = tx_queue->write_ptr % EFAB_TXD_SIZE;
03642
03643 EFAB_POPULATE_DWORD_1 ( reg, FCN_TX_DESC_WPTR_DWORD, ptr );
03644 falcon_writel ( efab, ®, FCN_TX_DESC_UPD_REG_KER_DWORD );
03645 }
03646
03647
03648
03649
03650
03651
03652
03653
03654
03655
03656 static int
03657 efab_fill_rx_queue ( struct efab_nic *efab,
03658 struct efab_rx_queue *rx_queue )
03659 {
03660 int fill_level = rx_queue->write_ptr - rx_queue->read_ptr;
03661 int space = EFAB_NUM_RX_DESC - fill_level - 1;
03662 int pushed = 0;
03663
03664 while ( space ) {
03665 int buf_id = rx_queue->write_ptr % EFAB_NUM_RX_DESC;
03666 int desc_id = rx_queue->write_ptr % EFAB_RXD_SIZE;
03667 struct io_buffer *iob;
03668 falcon_rx_desc_t *rxd;
03669
03670 assert ( rx_queue->buf[buf_id] == NULL );
03671 iob = alloc_iob ( EFAB_RX_BUF_SIZE );
03672 if ( !iob )
03673 break;
03674
03675 EFAB_TRACE ( "pushing rx_buf[%d] iob %p data %p\n",
03676 buf_id, iob, iob->data );
03677
03678 rx_queue->buf[buf_id] = iob;
03679 rxd = rx_queue->ring + desc_id;
03680 falcon_build_rx_desc ( rxd, iob );
03681 ++rx_queue->write_ptr;
03682 ++pushed;
03683 --space;
03684 }
03685
03686 if ( pushed ) {
03687
03688 falcon_notify_rx_desc ( efab, rx_queue );
03689
03690 fill_level = rx_queue->write_ptr - rx_queue->read_ptr;
03691 EFAB_TRACE ( "pushed %d rx buffers to fill level %d\n",
03692 pushed, fill_level );
03693 }
03694
03695 if ( fill_level == 0 )
03696 return -ENOMEM;
03697 return 0;
03698 }
03699
03700 static void
03701 efab_receive ( struct efab_nic *efab, unsigned int id, int len, int drop )
03702 {
03703 struct efab_rx_queue *rx_queue = &efab->rx_queue;
03704 struct io_buffer *iob;
03705 unsigned int read_ptr = rx_queue->read_ptr % EFAB_RXD_SIZE;
03706 unsigned int buf_ptr = rx_queue->read_ptr % EFAB_NUM_RX_DESC;
03707
03708 assert ( id == read_ptr );
03709
03710
03711 iob = rx_queue->buf[buf_ptr];
03712 rx_queue->buf[buf_ptr] = NULL;
03713
03714 EFAB_TRACE ( "popping rx_buf[%d] iob %p data %p with %d bytes %s\n",
03715 id, iob, iob->data, len, drop ? "bad" : "ok" );
03716
03717
03718 if ( drop )
03719 free_iob ( iob );
03720 else {
03721 iob_put ( iob, len );
03722 netdev_rx ( efab->netdev, iob );
03723 }
03724
03725 ++rx_queue->read_ptr;
03726 }
03727
03728
03729
03730
03731
03732
03733
03734
03735
03736 static int
03737 efab_transmit ( struct net_device *netdev, struct io_buffer *iob )
03738 {
03739 struct efab_nic *efab = netdev_priv ( netdev );
03740 struct efab_tx_queue *tx_queue = &efab->tx_queue;
03741 int fill_level, space;
03742 falcon_tx_desc_t *txd;
03743 int buf_id;
03744
03745 fill_level = tx_queue->write_ptr - tx_queue->read_ptr;
03746 space = EFAB_TXD_SIZE - fill_level - 1;
03747 if ( space < 1 )
03748 return -ENOBUFS;
03749
03750
03751 buf_id = tx_queue->write_ptr % EFAB_TXD_SIZE;
03752 assert ( tx_queue->buf[buf_id] == NULL );
03753 tx_queue->buf[buf_id] = iob;
03754
03755 EFAB_TRACE ( "tx_buf[%d] for iob %p data %p len %zd\n",
03756 buf_id, iob, iob->data, iob_len ( iob ) );
03757
03758
03759 txd = tx_queue->ring + buf_id;
03760 falcon_build_tx_desc ( txd, iob );
03761 ++tx_queue->write_ptr;
03762 falcon_notify_tx_desc ( efab, tx_queue );
03763
03764 return 0;
03765 }
03766
03767 static int
03768 efab_transmit_done ( struct efab_nic *efab, int id )
03769 {
03770 struct efab_tx_queue *tx_queue = &efab->tx_queue;
03771 unsigned int read_ptr, stop;
03772
03773
03774 read_ptr = tx_queue->read_ptr % EFAB_TXD_SIZE;
03775 stop = ( id + 1 ) % EFAB_TXD_SIZE;
03776
03777 while ( read_ptr != stop ) {
03778 struct io_buffer *iob = tx_queue->buf[read_ptr];
03779 assert ( iob );
03780
03781
03782 if ( iob )
03783 netdev_tx_complete ( efab->netdev, iob );
03784 tx_queue->buf[read_ptr] = NULL;
03785
03786 ++tx_queue->read_ptr;
03787 read_ptr = tx_queue->read_ptr % EFAB_TXD_SIZE;
03788 }
03789
03790 return 0;
03791 }
03792
03793
03794
03795
03796
03797
03798
03799
03800
03801 static void
03802 falcon_clear_interrupts ( struct efab_nic *efab )
03803 {
03804 efab_dword_t reg;
03805
03806 if ( efab->pci_revision == FALCON_REV_B0 ) {
03807
03808 falcon_readl( efab, ®, INT_ISR0_B0 );
03809 }
03810 else {
03811
03812 falcon_writel ( efab, 0, FCN_INT_ACK_KER_REG_A1 );
03813 mb();
03814 falcon_readl ( efab, ®,
03815 WORK_AROUND_BROKEN_PCI_READS_REG_KER_A1 );
03816 }
03817 }
03818
03819 static void
03820 falcon_handle_event ( struct efab_nic *efab, falcon_event_t *evt )
03821 {
03822 int ev_code, desc_ptr, len, drop;
03823
03824
03825 ev_code = EFAB_QWORD_FIELD ( *evt, FCN_EV_CODE );
03826 switch ( ev_code ) {
03827 case FCN_TX_IP_EV_DECODE:
03828 desc_ptr = EFAB_QWORD_FIELD ( *evt, FCN_TX_EV_DESC_PTR );
03829 efab_transmit_done ( efab, desc_ptr );
03830 break;
03831
03832 case FCN_RX_IP_EV_DECODE:
03833 desc_ptr = EFAB_QWORD_FIELD ( *evt, FCN_RX_EV_DESC_PTR );
03834 len = EFAB_QWORD_FIELD ( *evt, FCN_RX_EV_BYTE_CNT );
03835 drop = !EFAB_QWORD_FIELD ( *evt, FCN_RX_EV_PKT_OK );
03836
03837 efab_receive ( efab, desc_ptr, len, drop );
03838 break;
03839
03840 default:
03841 EFAB_TRACE ( "Unknown event type %d\n", ev_code );
03842 break;
03843 }
03844 }
03845
03846
03847
03848
03849
03850
03851
03852
03853
03854 static void
03855 efab_poll ( struct net_device *netdev )
03856 {
03857 struct efab_nic *efab = netdev_priv ( netdev );
03858 struct efab_ev_queue *ev_queue = &efab->ev_queue;
03859 struct efab_rx_queue *rx_queue = &efab->rx_queue;
03860 falcon_event_t *evt;
03861
03862
03863
03864 evt = ev_queue->ring + ev_queue->read_ptr;
03865 while ( falcon_event_present ( evt ) ) {
03866
03867 EFAB_TRACE ( "Event at index 0x%x address %p is "
03868 EFAB_QWORD_FMT "\n", ev_queue->read_ptr,
03869 evt, EFAB_QWORD_VAL ( *evt ) );
03870
03871 falcon_handle_event ( efab, evt );
03872
03873
03874 EFAB_SET_QWORD ( *evt );
03875
03876
03877
03878 ev_queue->read_ptr = ( ( ev_queue->read_ptr + 1 ) %
03879 EFAB_EVQ_SIZE );
03880 evt = ev_queue->ring + ev_queue->read_ptr;
03881 }
03882
03883
03884 (void) efab_fill_rx_queue ( efab, rx_queue );
03885
03886
03887 falcon_clear_interrupts ( efab );
03888
03889
03890 falcon_eventq_read_ack ( efab, ev_queue );
03891 }
03892
03893 static void
03894 efab_irq ( struct net_device *netdev, int enable )
03895 {
03896 struct efab_nic *efab = netdev_priv ( netdev );
03897 struct efab_ev_queue *ev_queue = &efab->ev_queue;
03898
03899 switch ( enable ) {
03900 case 0:
03901 falcon_interrupts ( efab, 0, 0 );
03902 break;
03903 case 1:
03904 falcon_interrupts ( efab, 1, 0 );
03905 falcon_eventq_read_ack ( efab, ev_queue );
03906 break;
03907 case 2:
03908 falcon_interrupts ( efab, 1, 1 );
03909 break;
03910 }
03911 }
03912
03913
03914
03915
03916
03917
03918
03919
03920
03921 static void
03922 efab_free_resources ( struct efab_nic *efab )
03923 {
03924 struct efab_ev_queue *ev_queue = &efab->ev_queue;
03925 struct efab_rx_queue *rx_queue = &efab->rx_queue;
03926 struct efab_tx_queue *tx_queue = &efab->tx_queue;
03927 int i;
03928
03929 for ( i = 0; i < EFAB_NUM_RX_DESC; i++ ) {
03930 if ( rx_queue->buf[i] )
03931 free_iob ( rx_queue->buf[i] );
03932 }
03933
03934 for ( i = 0; i < EFAB_TXD_SIZE; i++ ) {
03935 if ( tx_queue->buf[i] )
03936 netdev_tx_complete ( efab->netdev, tx_queue->buf[i] );
03937 }
03938
03939 if ( rx_queue->ring )
03940 falcon_free_special_buffer ( rx_queue->ring );
03941
03942 if ( tx_queue->ring )
03943 falcon_free_special_buffer ( tx_queue->ring );
03944
03945 if ( ev_queue->ring )
03946 falcon_free_special_buffer ( ev_queue->ring );
03947
03948 memset ( rx_queue, 0, sizeof ( *rx_queue ) );
03949 memset ( tx_queue, 0, sizeof ( *tx_queue ) );
03950 memset ( ev_queue, 0, sizeof ( *ev_queue ) );
03951
03952
03953 efab->buffer_head = 0;
03954 }
03955
03956 static int
03957 efab_alloc_resources ( struct efab_nic *efab )
03958 {
03959 struct efab_ev_queue *ev_queue = &efab->ev_queue;
03960 struct efab_rx_queue *rx_queue = &efab->rx_queue;
03961 struct efab_tx_queue *tx_queue = &efab->tx_queue;
03962 size_t bytes;
03963
03964
03965 bytes = sizeof ( falcon_event_t ) * EFAB_TXD_SIZE;
03966 ev_queue->ring = falcon_alloc_special_buffer ( efab, bytes,
03967 &ev_queue->entry );
03968 if ( !ev_queue->ring )
03969 goto fail1;
03970
03971
03972 memset ( ev_queue->ring, 0xff, bytes );
03973
03974
03975 bytes = sizeof ( falcon_tx_desc_t ) * EFAB_TXD_SIZE;
03976 tx_queue->ring = falcon_alloc_special_buffer ( efab, bytes,
03977 &tx_queue->entry );
03978 if ( ! tx_queue->ring )
03979 goto fail2;
03980
03981
03982 bytes = sizeof ( falcon_rx_desc_t ) * EFAB_RXD_SIZE;
03983 rx_queue->ring = falcon_alloc_special_buffer ( efab, bytes,
03984 &rx_queue->entry );
03985 if ( ! rx_queue->ring )
03986 goto fail3;
03987
03988 return 0;
03989
03990 fail3:
03991 falcon_free_special_buffer ( tx_queue->ring );
03992 tx_queue->ring = NULL;
03993 fail2:
03994 falcon_free_special_buffer ( ev_queue->ring );
03995 ev_queue->ring = NULL;
03996 fail1:
03997 return -ENOMEM;
03998 }
03999
04000 static int
04001 efab_init_mac ( struct efab_nic *efab )
04002 {
04003 int count, rc;
04004
04005
04006 EFAB_LOG ( "Waiting for link..\n" );
04007 for ( count=0; count<5; count++ ) {
04008 rc = efab->mac_op->init ( efab );
04009 if ( rc ) {
04010 EFAB_ERR ( "Failed reinitialising MAC, error %s\n",
04011 strerror ( rc ));
04012 return rc;
04013 }
04014
04015
04016
04017
04018
04019 sleep ( 2 );
04020
04021 if ( ! efab->link_up ) {
04022 EFAB_ERR ( "!\n" );
04023 continue;
04024 }
04025
04026 EFAB_LOG ( "\n%dMbps %s-duplex\n",
04027 ( efab->link_options & LPA_EF_10000 ? 10000 :
04028 ( efab->link_options & LPA_EF_1000 ? 1000 :
04029 ( efab->link_options & LPA_100 ? 100 : 10 ) ) ),
04030 ( efab->link_options & LPA_EF_DUPLEX ?
04031 "full" : "half" ) );
04032
04033
04034 netdev_link_up ( efab->netdev );
04035 return 0;
04036 }
04037
04038 EFAB_ERR ( "timed initialising MAC\n" );
04039 return -ETIMEDOUT;
04040 }
04041
04042 static void
04043 efab_close ( struct net_device *netdev )
04044 {
04045 struct efab_nic *efab = netdev_priv ( netdev );
04046
04047 falcon_fini_resources ( efab );
04048 efab_free_resources ( efab );
04049 efab->board_op->fini ( efab );
04050 falcon_reset ( efab );
04051 }
04052
04053 static int
04054 efab_open ( struct net_device *netdev )
04055 {
04056 struct efab_nic *efab = netdev_priv ( netdev );
04057 struct efab_rx_queue *rx_queue = &efab->rx_queue;
04058 int rc;
04059
04060 rc = falcon_reset ( efab );
04061 if ( rc )
04062 goto fail1;
04063
04064 rc = efab->board_op->init ( efab );
04065 if ( rc )
04066 goto fail2;
04067
04068 rc = falcon_init_sram ( efab );
04069 if ( rc )
04070 goto fail3;
04071
04072
04073 falcon_setup_nic ( efab );
04074
04075 rc = efab_alloc_resources ( efab );
04076 if ( rc )
04077 goto fail4;
04078
04079 falcon_init_resources ( efab );
04080
04081
04082 rc = efab_fill_rx_queue ( efab, rx_queue );
04083 if ( rc )
04084 goto fail5;
04085
04086
04087 rc = efab_init_mac ( efab );
04088 if ( rc )
04089 goto fail6;
04090
04091 return 0;
04092
04093 fail6:
04094 fail5:
04095 efab_free_resources ( efab );
04096 fail4:
04097 fail3:
04098 efab->board_op->fini ( efab );
04099 fail2:
04100 falcon_reset ( efab );
04101 fail1:
04102 return rc;
04103 }
04104
04105 static struct net_device_operations efab_operations = {
04106 .open = efab_open,
04107 .close = efab_close,
04108 .transmit = efab_transmit,
04109 .poll = efab_poll,
04110 .irq = efab_irq,
04111 };
04112
04113 static void
04114 efab_remove ( struct pci_device *pci )
04115 {
04116 struct net_device *netdev = pci_get_drvdata ( pci );
04117 struct efab_nic *efab = netdev_priv ( netdev );
04118
04119 if ( efab->membase ) {
04120 falcon_reset ( efab );
04121
04122 iounmap ( efab->membase );
04123 efab->membase = NULL;
04124 }
04125
04126 if ( efab->nvo.nvs ) {
04127 unregister_nvo ( &efab->nvo );
04128 efab->nvo.nvs = NULL;
04129 }
04130
04131 unregister_netdev ( netdev );
04132 netdev_nullify ( netdev );
04133 netdev_put ( netdev );
04134 }
04135
04136 static int
04137 efab_probe ( struct pci_device *pci,
04138 const struct pci_device_id *id )
04139 {
04140 struct net_device *netdev;
04141 struct efab_nic *efab;
04142 unsigned long mmio_start, mmio_len;
04143 int rc;
04144
04145
04146 netdev = alloc_etherdev ( sizeof ( struct efab_nic ) );
04147 if ( ! netdev ) {
04148 rc = -ENOMEM;
04149 goto fail1;
04150 }
04151
04152
04153 netdev_init ( netdev, &efab_operations );
04154 pci_set_drvdata ( pci, netdev );
04155 netdev->dev = &pci->dev;
04156
04157 efab = netdev_priv ( netdev );
04158 memset ( efab, 0, sizeof ( *efab ) );
04159 efab->netdev = netdev;
04160
04161
04162 mmio_start = pci_bar_start ( pci, PCI_BASE_ADDRESS_2 );
04163 mmio_len = pci_bar_size ( pci, PCI_BASE_ADDRESS_2 );
04164 efab->membase = ioremap ( mmio_start, mmio_len );
04165 EFAB_TRACE ( "BAR of %lx bytes at phys %lx mapped at %p\n",
04166 mmio_len, mmio_start, efab->membase );
04167
04168
04169 adjust_pci_device ( pci );
04170 efab->iobase = pci->ioaddr & ~3;
04171
04172
04173 falcon_probe_nic_variant ( efab, pci );
04174
04175
04176
04177 rc = falcon_probe_spi ( efab );
04178 if ( rc )
04179 goto fail2;
04180 rc = falcon_probe_nvram ( efab );
04181 if ( rc )
04182 goto fail3;
04183
04184 memcpy ( netdev->hw_addr, efab->mac_addr, ETH_ALEN );
04185
04186 netdev_link_up ( netdev );
04187 rc = register_netdev ( netdev );
04188 if ( rc )
04189 goto fail4;
04190
04191
04192 if ( efab->nvo.nvs ) {
04193 rc = register_nvo ( &efab->nvo, netdev_settings ( netdev ) );
04194 if ( rc )
04195 goto fail5;
04196 }
04197
04198 EFAB_LOG ( "Found %s EtherFabric %s %s revision %d\n", id->name,
04199 efab->is_asic ? "ASIC" : "FPGA",
04200 efab->phy_10g ? "10G" : "1G",
04201 efab->pci_revision );
04202
04203 return 0;
04204
04205 fail5:
04206 unregister_netdev ( netdev );
04207 fail4:
04208 fail3:
04209 fail2:
04210 iounmap ( efab->membase );
04211 efab->membase = NULL;
04212 netdev_put ( netdev );
04213 fail1:
04214 return rc;
04215 }
04216
04217
04218 static struct pci_device_id efab_nics[] = {
04219 PCI_ROM(0x1924, 0x0703, "falcon", "EtherFabric Falcon", 0),
04220 PCI_ROM(0x1924, 0x0710, "falconb0", "EtherFabric FalconB0", 0),
04221 };
04222
04223 struct pci_driver etherfabric_driver __pci_driver = {
04224 .ids = efab_nics,
04225 .id_count = sizeof ( efab_nics ) / sizeof ( efab_nics[0] ),
04226 .probe = efab_probe,
04227 .remove = efab_remove,
04228 };
04229
04230
04231
04232
04233
04234
04235
04236