Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sky2: support for new Optima chipsets (EXPERIMENTAL)

This is a backport from the vendor driver of support for the newer Optima
(Prime and 2) chipsets. It also includes some setup changes for the
current Optima chip as well. The code and comments intentionally
mirror the vendor sk98lin driver to allow for easier maintenance.

Although this adds support for new chip id's, these chip id's are not
used by any of the current PCI device id's listed in the driver.
The patch is just to get initial infrastructure in place to handle them
when they come.

I don't have access to any of this hardware to actually test it yet.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

stephen hemminger and committed by
David S. Miller
4fb99cd6 8e11680f

+89 -8
+83 -6
drivers/net/sky2.c
··· 365 365 gm_phy_write(hw, port, PHY_MARV_FE_SPEC_2, spec); 366 366 } 367 367 } else { 368 + if (hw->chip_id >= CHIP_ID_YUKON_OPT) { 369 + u16 ctrl2 = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL_2); 370 + 371 + /* enable PHY Reverse Auto-Negotiation */ 372 + ctrl2 |= 1u << 13; 373 + 374 + /* Write PHY changes (SW-reset must follow) */ 375 + gm_phy_write(hw, port, PHY_MARV_EXT_CTRL_2, ctrl2); 376 + } 377 + 378 + 368 379 /* disable energy detect */ 369 380 ctrl &= ~PHY_M_PC_EN_DET_MSK; 370 381 ··· 637 626 if (ledover) 638 627 gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); 639 628 629 + } else if (hw->chip_id == CHIP_ID_YUKON_PRM && 630 + (sky2_read8(hw, B2_MAC_CFG) & 0xf) == 0x7) { 631 + int i; 632 + /* This a phy register setup workaround copied from vendor driver. */ 633 + static const struct { 634 + u16 reg, val; 635 + } eee_afe[] = { 636 + { 0x156, 0x58ce }, 637 + { 0x153, 0x99eb }, 638 + { 0x141, 0x8064 }, 639 + /* { 0x155, 0x130b },*/ 640 + { 0x000, 0x0000 }, 641 + { 0x151, 0x8433 }, 642 + { 0x14b, 0x8c44 }, 643 + { 0x14c, 0x0f90 }, 644 + { 0x14f, 0x39aa }, 645 + /* { 0x154, 0x2f39 },*/ 646 + { 0x14d, 0xba33 }, 647 + { 0x144, 0x0048 }, 648 + { 0x152, 0x2010 }, 649 + /* { 0x158, 0x1223 },*/ 650 + { 0x140, 0x4444 }, 651 + { 0x154, 0x2f3b }, 652 + { 0x158, 0xb203 }, 653 + { 0x157, 0x2029 }, 654 + }; 655 + 656 + /* Start Workaround for OptimaEEE Rev.Z0 */ 657 + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0x00fb); 658 + 659 + gm_phy_write(hw, port, 1, 0x4099); 660 + gm_phy_write(hw, port, 3, 0x1120); 661 + gm_phy_write(hw, port, 11, 0x113c); 662 + gm_phy_write(hw, port, 14, 0x8100); 663 + gm_phy_write(hw, port, 15, 0x112a); 664 + gm_phy_write(hw, port, 17, 0x1008); 665 + 666 + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0x00fc); 667 + gm_phy_write(hw, port, 1, 0x20b0); 668 + 669 + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0x00ff); 670 + 671 + for (i = 0; i < ARRAY_SIZE(eee_afe); i++) { 672 + /* apply AFE settings */ 673 + gm_phy_write(hw, port, 17, eee_afe[i].val); 674 + gm_phy_write(hw, port, 16, eee_afe[i].reg | 1u<<13); 675 + } 676 + 677 + /* End Workaround for OptimaEEE */ 678 + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0); 679 + 680 + /* Enable 10Base-Te (EEE) */ 681 + if (hw->chip_id >= CHIP_ID_YUKON_PRM) { 682 + reg = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); 683 + gm_phy_write(hw, port, PHY_MARV_EXT_CTRL, 684 + reg | PHY_M_10B_TE_ENABLE); 685 + } 640 686 } 641 687 642 688 /* Enable phy interrupt on auto-negotiation complete (or link up) */ ··· 3027 2959 case CHIP_ID_YUKON_SUPR: 3028 2960 case CHIP_ID_YUKON_UL_2: 3029 2961 case CHIP_ID_YUKON_OPT: 2962 + case CHIP_ID_YUKON_PRM: 2963 + case CHIP_ID_YUKON_OP_2: 3030 2964 return 125; 3031 2965 3032 2966 case CHIP_ID_YUKON_FE: ··· 3134 3064 break; 3135 3065 3136 3066 case CHIP_ID_YUKON_OPT: 3067 + case CHIP_ID_YUKON_PRM: 3068 + case CHIP_ID_YUKON_OP_2: 3137 3069 hw->flags = SKY2_HW_GIGABIT 3138 3070 | SKY2_HW_NEW_LE 3139 3071 | SKY2_HW_ADV_POWER_CTL; ··· 3235 3163 sky2_pci_write32(hw, PCI_DEV_REG3, P_CLK_MACSEC_DIS); 3236 3164 } 3237 3165 3238 - if (hw->chip_id == CHIP_ID_YUKON_OPT) { 3166 + if (hw->chip_id == CHIP_ID_YUKON_OPT || 3167 + hw->chip_id == CHIP_ID_YUKON_PRM || 3168 + hw->chip_id == CHIP_ID_YUKON_OP_2) { 3239 3169 u16 reg; 3240 3170 u32 msk; 3241 3171 3242 - if (hw->chip_rev == 0) { 3172 + if (hw->chip_id == CHIP_ID_YUKON_OPT && hw->chip_rev == 0) { 3243 3173 /* disable PCI-E PHY power down (set PHY reg 0x80, bit 7 */ 3244 3174 sky2_write32(hw, Y2_PEX_PHY_DATA, (0x80UL << 16) | (1 << 7)); 3245 3175 3246 3176 /* set PHY Link Detect Timer to 1.1 second (11x 100ms) */ 3247 3177 reg = 10; 3178 + 3179 + /* re-enable PEX PM in PEX PHY debug reg. 8 (clear bit 12) */ 3180 + sky2_write32(hw, Y2_PEX_PHY_DATA, PEX_DB_ACCESS | (0x08UL << 16)); 3248 3181 } else { 3249 3182 /* set PHY Link Detect Timer to 0.4 second (4x 100ms) */ 3250 3183 reg = 3; 3251 3184 } 3252 3185 3253 3186 reg <<= PSM_CONFIG_REG4_TIMER_PHY_LINK_DETECT_BASE; 3187 + reg |= PSM_CONFIG_REG4_RST_PHY_LINK_DETECT; 3254 3188 3255 3189 /* reset PHY Link Detect */ 3256 3190 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 3257 - sky2_pci_write16(hw, PSM_CONFIG_REG4, 3258 - reg | PSM_CONFIG_REG4_RST_PHY_LINK_DETECT); 3259 3191 sky2_pci_write16(hw, PSM_CONFIG_REG4, reg); 3260 - 3261 3192 3262 3193 /* enable PHY Quick Link */ 3263 3194 msk = sky2_read32(hw, B0_IMSK); ··· 4785 4710 "UL 2", /* 0xba */ 4786 4711 "Unknown", /* 0xbb */ 4787 4712 "Optima", /* 0xbc */ 4713 + "Optima Prime", /* 0xbd */ 4714 + "Optima 2", /* 0xbe */ 4788 4715 }; 4789 4716 4790 - if (chipid >= CHIP_ID_YUKON_XL && chipid <= CHIP_ID_YUKON_OPT) 4717 + if (chipid >= CHIP_ID_YUKON_XL && chipid <= CHIP_ID_YUKON_OP_2) 4791 4718 strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz); 4792 4719 else 4793 4720 snprintf(buf, sz, "(chip %#x)", chipid);
+6 -2
drivers/net/sky2.h
··· 412 412 Y2_IS_HW_ERR = 1<<31, /* Interrupt HW Error */ 413 413 Y2_IS_STAT_BMU = 1<<30, /* Status BMU Interrupt */ 414 414 Y2_IS_ASF = 1<<29, /* ASF subsystem Interrupt */ 415 - 415 + Y2_IS_CPU_TO = 1<<28, /* CPU Timeout */ 416 416 Y2_IS_POLL_CHK = 1<<27, /* Check IRQ from polling unit */ 417 417 Y2_IS_TWSI_RDY = 1<<26, /* IRQ on end of TWSI Tx */ 418 418 Y2_IS_IRQ_SW = 1<<25, /* SW forced IRQ */ ··· 547 547 CHIP_ID_YUKON_SUPR = 0xb9, /* YUKON-2 Supreme */ 548 548 CHIP_ID_YUKON_UL_2 = 0xba, /* YUKON-2 Ultra 2 */ 549 549 CHIP_ID_YUKON_OPT = 0xbc, /* YUKON-2 Optima */ 550 + CHIP_ID_YUKON_PRM = 0xbd, /* YUKON-2 Optima Prime */ 551 + CHIP_ID_YUKON_OP_2 = 0xbe, /* YUKON-2 Optima 2 */ 550 552 }; 551 553 552 554 enum yukon_xl_rev { ··· 1422 1420 PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */ 1423 1421 PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */ 1424 1422 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ 1425 - PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; 1423 + PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */ 1426 1424 1425 + PHY_M_10B_TE_ENABLE = 1<<7, /* 10Base-Te Enable (88E8079 and above) */ 1426 + }; 1427 1427 #define PHY_M_EC_M_DSC(x) ((u16)(x)<<10 & PHY_M_EC_M_DSC_MSK) 1428 1428 /* 00=1x; 01=2x; 10=3x; 11=4x */ 1429 1429 #define PHY_M_EC_S_DSC(x) ((u16)(x)<<8 & PHY_M_EC_S_DSC_MSK)