63 int attempts,
int delay)
68 if (!!val == polarity)
77 #define TPI_ATTEMPTS 50
93 pr_alert(
"%s: TPI write to 0x%x failed\n",
102 spin_lock(&adapter->tpi_lock);
104 spin_unlock(&adapter->tpi_lock);
121 pr_alert(
"%s: TPI read from 0x%x failed\n",
122 adapter->name, addr);
132 spin_lock(&adapter->tpi_lock);
134 spin_unlock(&adapter->tpi_lock);
157 phy->
ops->get_link_status(phy, &link_ok, &speed, &duplex, &fc);
168 mac->
ops->set_speed_duplex_fc(mac, speed, duplex, fc);
169 lc->
fc = (
unsigned char)fc;
174 static int t1_pci_intr_handler(
adapter_t *adapter)
188 #ifdef CONFIG_CHELSIO_T1_1G
194 static int fpga_phy_intr_handler(
adapter_t *adapter)
200 if (cause & (1 << p)) {
201 struct cphy *
phy = adapter->port[
p].phy;
202 int phy_cause = phy->
ops->interrupt_handler(phy);
214 static int fpga_slow_intr(
adapter_t *adapter)
223 fpga_phy_intr_handler(adapter);
236 t1_pci_intr_handler(adapter);
249 static int mi1_wait_until_ready(
adapter_t *adapter,
int mi1_reg)
251 int attempts = 100,
busy;
260 }
while (
busy && --attempts);
262 pr_alert(
"%s: MDIO operation timed out\n", adapter->name);
280 #if defined(CONFIG_CHELSIO_T1_1G)
284 static int mi1_mdio_read(
struct net_device *
dev,
int phy_addr,
int mmd_addr,
287 struct adapter *adapter = dev->
ml_priv;
301 static int mi1_mdio_write(
struct net_device *
dev,
int phy_addr,
int mmd_addr,
304 struct adapter *adapter = dev->
ml_priv;
317 static const struct mdio_ops mi1_mdio_ops = {
318 .
init = mi1_mdio_init,
319 .read = mi1_mdio_read,
320 .write = mi1_mdio_write,
326 static int mi1_mdio_ext_read(
struct net_device *
dev,
int phy_addr,
int mmd_addr,
329 struct adapter *adapter = dev->
ml_priv;
353 static int mi1_mdio_ext_write(
struct net_device *
dev,
int phy_addr,
356 struct adapter *adapter = dev->
ml_priv;
376 static const struct mdio_ops mi1_mdio_ext_ops = {
377 .init = mi1_mdio_init,
378 .read = mi1_mdio_ext_read,
379 .write = mi1_mdio_ext_write,
400 .clock_core = 125000000,
401 .clock_mc3 = 150000000,
402 .clock_mc4 = 125000000,
408 .mdio_phybaseaddr = 1,
411 .mdio_ops = &mi1_mdio_ext_ops,
412 .desc =
"Chelsio T110 1x10GBase-CX4 TOE",
422 .clock_core = 125000000,
428 .mdio_phybaseaddr = 0,
431 .mdio_ops = &mi1_mdio_ext_ops,
432 .desc =
"Chelsio N110 1x10GBaseX NIC",
442 .clock_core = 125000000,
448 .mdio_phybaseaddr = 0,
451 .mdio_ops = &mi1_mdio_ext_ops,
452 .desc =
"Chelsio N210 1x10GBaseX NIC",
462 .clock_core = 125000000,
463 .clock_mc3 = 133000000,
464 .clock_mc4 = 125000000,
470 .mdio_phybaseaddr = 0,
473 .mdio_ops = &mi1_mdio_ext_ops,
474 .desc =
"Chelsio T210 1x10GBaseX TOE",
484 .clock_core = 125000000,
485 .clock_mc3 = 133000000,
486 .clock_mc4 = 125000000,
492 .mdio_phybaseaddr = 1,
495 .mdio_ops = &mi1_mdio_ext_ops,
496 .desc =
"Chelsio T210 1x10GBase-CX4 TOE",
499 #ifdef CONFIG_CHELSIO_T1_1G
510 .clock_core = 100000000,
516 .mdio_phybaseaddr = 4,
519 .mdio_ops = &mi1_mdio_ops,
520 .desc =
"Chelsio N204 4x100/1000BaseT NIC",
555 #define EEPROMSIZE (8 * 1024)
556 #define EEPROM_MAX_POLL 4
578 if (!(val & F_VPD_OP_FLAG)) {
579 pr_err(
"%s: reading EEPROM address 0x%x failed\n",
580 adapter->name, addr);
592 for (addr = 0; !ret && addr <
sizeof(*vpd); addr +=
sizeof(
u32))
606 if (t1_eeprom_vpd_get(adapter, &vpd))
608 memcpy(mac_addr, vpd.mac_base_address, 5);
609 mac_addr[5] = vpd.mac_base_address[5] +
index;
632 (mac->
adapter->params.nports < 2)))
645 lc->
fc = (
unsigned char)fc;
646 mac->
ops->set_speed_duplex_fc(mac, lc->
speed,
651 phy->
ops->reset(phy, 0);
654 phy->
ops->autoneg_enable(phy);
658 mac->ops->set_speed_duplex_fc(
mac, -1, -1,
fc);
660 phy->
ops->reset(phy, 0);
677 #ifdef CONFIG_CHELSIO_T1_1G
685 if (!(cause & (1 << port_bit)))
688 phy = adapter->port[
i].phy;
689 phy_cause = phy->
ops->interrupt_handler(phy);
697 phy = adapter->port[0].phy;
698 phy_cause = phy->
ops->interrupt_handler(phy);
712 phy = adapter->port[
p].phy;
713 phy_cause = phy->
ops->interrupt_handler(phy);
724 phy = adapter->port[0].phy;
725 phy_cause = phy->
ops->interrupt_handler(phy);
734 "External interrupt cause 0x%x\n", cause);
735 if (cause & ELMER0_GP_BIT1) {
736 struct cmac *
mac = adapter->port[0].mac;
738 mac->
ops->interrupt_handler(mac);
747 mod_detect ?
"removed" :
"inserted");
760 adapter->slow_intr_mask = F_PL_INTR_SGE_ERR |
F_PL_INTR_TP;
771 adapter->port[
i].mac->ops->interrupt_enable(adapter->port[i].mac);
772 adapter->port[
i].phy->ops->interrupt_enable(adapter->port[i].phy);
776 if (t1_is_asic(adapter)) {
801 adapter->port[
i].mac->ops->interrupt_disable(adapter->port[i].mac);
802 adapter->port[
i].phy->ops->interrupt_disable(adapter->port[i].phy);
806 if (t1_is_asic(adapter))
812 adapter->slow_intr_mask = 0;
827 adapter->port[
i].mac->ops->interrupt_clear(adapter->port[i].mac);
828 adapter->port[
i].phy->ops->interrupt_clear(adapter->port[i].phy);
832 if (t1_is_asic(adapter)) {
846 static int asic_slow_intr(
adapter_t *adapter)
850 cause &= adapter->slow_intr_mask;
853 if (cause & F_PL_INTR_SGE_ERR)
860 t1_pci_intr_handler(adapter);
872 #ifdef CONFIG_CHELSIO_T1_1G
873 if (!t1_is_asic(adapter))
874 return fpga_slow_intr(adapter);
876 return asic_slow_intr(adapter);
880 static void power_sequence_xpak(
adapter_t* adapter)
928 t1_tpi_par(adapter, 0xf);
932 t1_tpi_par(adapter, 0xf);
938 power_sequence_xpak(adapter);
940 #ifdef CONFIG_CHELSIO_T1_1G
946 t1_tpi_par(adapter, 0xf);
951 t1_tpi_par(adapter, 0xf);
997 static const unsigned short speed_map[] = { 33, 66, 100, 133 };
1014 struct cmac *
mac = adapter->port[
i].mac;
1015 struct cphy *phy = adapter->port[
i].phy;
1018 mac->
ops->destroy(mac);
1020 phy->
ops->destroy(phy);
1057 adapter->params.brd_info =
bi;
1059 adapter->params.stats_update_period = bi->
gmac->stats_update_period;
1061 adapter->sge =
t1_sge_create(adapter, &adapter->params.sge);
1062 if (!adapter->sge) {
1063 pr_err(
"%s: SGE initialization failed\n",
1069 pr_err(
"%s: ESPI initialization failed\n",
1074 adapter->tp =
t1_tp_create(adapter, &adapter->params.tp);
1076 pr_err(
"%s: TP initialization failed\n",
1081 board_init(adapter, bi);
1083 if (bi->
gphy->reset)
1084 bi->
gphy->reset(adapter);
1085 if (bi->
gmac->reset)
1086 bi->
gmac->reset(adapter);
1093 adapter->port[
i].phy = bi->
gphy->create(adapter->port[i].
dev,
1095 if (!adapter->port[i].phy) {
1096 pr_err(
"%s: PHY %d initialization failed\n",
1101 adapter->port[
i].mac = mac = bi->
gmac->create(adapter, i);
1103 pr_err(
"%s: MAC %d initialization failed\n",
1113 mac->
ops->macaddress_get(mac, hw_addr);
1114 else if (vpd_macaddress_get(adapter, i, hw_addr)) {
1115 pr_err(
"%s: could not read MAC address from VPD ROM\n",
1116 adapter->port[i].
dev->name);
1120 init_link_config(&adapter->port[i].link_config, bi);
1123 get_pci_mode(adapter, &adapter->params.pci);