Jesse Keating 2f82dd
From: Stephen Hemminger <shemminger@vyatta.com>
Jesse Keating 2f82dd
Date: Thu, 29 Oct 2009 06:37:09 +0000 (+0000)
Jesse Keating 2f82dd
Subject: sky2: 88E8059 support
Jesse Keating 2f82dd
X-Git-Tag: v2.6.33-rc1~388^2~588
Jesse Keating 2f82dd
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=0f5aac7070a01ec757ed243febe4fff7c944c4d2
Jesse Keating 2f82dd
Jesse Keating 2f82dd
sky2: 88E8059 support
Jesse Keating 2f82dd
Jesse Keating 2f82dd
Tentative support for newer Marvell hardware including
Jesse Keating 2f82dd
the Yukon-2 Optima chip. Do not have hatdware to test this yet,
Jesse Keating 2f82dd
code is based on vendor driver.
Jesse Keating 2f82dd
Jesse Keating 2f82dd
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Jesse Keating 2f82dd
Signed-off-by: David S. Miller <davem@davemloft.net>
Jesse Keating 2f82dd
---
Jesse Keating 2f82dd
Jesse Keating 2f82dd
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
Jesse Keating 2f82dd
index 3387a2f..53cce74 100644
Jesse Keating 2f82dd
--- a/drivers/net/sky2.c
Jesse Keating 2f82dd
+++ b/drivers/net/sky2.c
Jesse Keating 2f82dd
@@ -140,6 +140,7 @@ static DEFINE_PCI_DEVICE_TABLE(sky2_id_table) = {
Jesse Keating 2f82dd
 	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436D) }, /* 88E8055 */
Jesse Keating 2f82dd
 	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4370) }, /* 88E8075 */
Jesse Keating 2f82dd
 	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4380) }, /* 88E8057 */
Jesse Keating 2f82dd
+	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4381) }, /* 88E8059 */
Jesse Keating 2f82dd
 	{ 0 }
Jesse Keating 2f82dd
 };
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
@@ -603,6 +604,16 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
Jesse Keating 2f82dd
 		/* apply workaround for integrated resistors calibration */
Jesse Keating 2f82dd
 		gm_phy_write(hw, port, PHY_MARV_PAGE_ADDR, 17);
Jesse Keating 2f82dd
 		gm_phy_write(hw, port, PHY_MARV_PAGE_DATA, 0x3f60);
Jesse Keating 2f82dd
+	} else if (hw->chip_id == CHIP_ID_YUKON_OPT && hw->chip_rev == 0) {
Jesse Keating 2f82dd
+		/* apply fixes in PHY AFE */
Jesse Keating 2f82dd
+		gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0x00ff);
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+		/* apply RDAC termination workaround */
Jesse Keating 2f82dd
+		gm_phy_write(hw, port, 24, 0x2800);
Jesse Keating 2f82dd
+		gm_phy_write(hw, port, 23, 0x2001);
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+		/* set page register back to 0 */
Jesse Keating 2f82dd
+		gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0);
Jesse Keating 2f82dd
 	} else if (hw->chip_id != CHIP_ID_YUKON_EX &&
Jesse Keating 2f82dd
 		   hw->chip_id < CHIP_ID_YUKON_SUPR) {
Jesse Keating 2f82dd
 		/* no effect on Yukon-XL */
Jesse Keating 2f82dd
@@ -2127,6 +2138,25 @@ out:
Jesse Keating 2f82dd
 	spin_unlock(&sky2->phy_lock);
Jesse Keating 2f82dd
 }
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
+/* Special quick link interrupt (Yukon-2 Optima only) */
Jesse Keating 2f82dd
+static void sky2_qlink_intr(struct sky2_hw *hw)
Jesse Keating 2f82dd
+{
Jesse Keating 2f82dd
+	struct sky2_port *sky2 = netdev_priv(hw->dev[0]);
Jesse Keating 2f82dd
+	u32 imask;
Jesse Keating 2f82dd
+	u16 phy;
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+	/* disable irq */
Jesse Keating 2f82dd
+	imask = sky2_read32(hw, B0_IMSK);
Jesse Keating 2f82dd
+	imask &= ~Y2_IS_PHY_QLNK;
Jesse Keating 2f82dd
+	sky2_write32(hw, B0_IMSK, imask);
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+	/* reset PHY Link Detect */
Jesse Keating 2f82dd
+	phy = sky2_pci_read16(hw, PSM_CONFIG_REG4);
Jesse Keating 2f82dd
+	sky2_pci_write16(hw, PSM_CONFIG_REG4, phy | 1);
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+	sky2_link_up(sky2);
Jesse Keating 2f82dd
+}
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
 /* Transmit timeout is only called if we are running, carrier is up
Jesse Keating 2f82dd
  * and tx queue is full (stopped).
Jesse Keating 2f82dd
  */
Jesse Keating 2f82dd
@@ -2796,6 +2826,9 @@ static int sky2_poll(struct napi_struct *napi, int work_limit)
Jesse Keating 2f82dd
 	if (status & Y2_IS_IRQ_PHY2)
Jesse Keating 2f82dd
 		sky2_phy_intr(hw, 1);
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
+	if (status & Y2_IS_PHY_QLNK)
Jesse Keating 2f82dd
+		sky2_qlink_intr(hw);
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
 	while ((idx = sky2_read16(hw, STAT_PUT_IDX)) != hw->st_idx) {
Jesse Keating 2f82dd
 		work_done += sky2_status_intr(hw, work_limit - work_done, idx);
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
@@ -2845,6 +2878,7 @@ static u32 sky2_mhz(const struct sky2_hw *hw)
Jesse Keating 2f82dd
 	case CHIP_ID_YUKON_EX:
Jesse Keating 2f82dd
 	case CHIP_ID_YUKON_SUPR:
Jesse Keating 2f82dd
 	case CHIP_ID_YUKON_UL_2:
Jesse Keating 2f82dd
+	case CHIP_ID_YUKON_OPT:
Jesse Keating 2f82dd
 		return 125;
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 	case CHIP_ID_YUKON_FE:
Jesse Keating 2f82dd
@@ -2934,6 +2968,7 @@ static int __devinit sky2_init(struct sky2_hw *hw)
Jesse Keating 2f82dd
 		break;
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
 	case CHIP_ID_YUKON_UL_2:
Jesse Keating 2f82dd
+	case CHIP_ID_YUKON_OPT:
Jesse Keating 2f82dd
 		hw->flags = SKY2_HW_GIGABIT
Jesse Keating 2f82dd
 			| SKY2_HW_ADV_POWER_CTL;
Jesse Keating 2f82dd
 		break;
Jesse Keating 2f82dd
@@ -3024,6 +3059,46 @@ static void sky2_reset(struct sky2_hw *hw)
Jesse Keating 2f82dd
 		sky2_pci_write32(hw, PCI_DEV_REG3, P_CLK_MACSEC_DIS);
Jesse Keating 2f82dd
 	}
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
+	if (hw->chip_id == CHIP_ID_YUKON_OPT) {
Jesse Keating 2f82dd
+		u16 reg;
Jesse Keating 2f82dd
+		u32 msk;
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+		if (hw->chip_rev == 0) {
Jesse Keating 2f82dd
+			/* disable PCI-E PHY power down (set PHY reg 0x80, bit 7 */
Jesse Keating 2f82dd
+			sky2_write32(hw, Y2_PEX_PHY_DATA, (0x80UL << 16) | (1 << 7));
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+			/* set PHY Link Detect Timer to 1.1 second (11x 100ms) */
Jesse Keating 2f82dd
+			reg = 10;
Jesse Keating 2f82dd
+		} else {
Jesse Keating 2f82dd
+			/* set PHY Link Detect Timer to 0.4 second (4x 100ms) */
Jesse Keating 2f82dd
+			reg = 3;
Jesse Keating 2f82dd
+		}
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+		reg <<= PSM_CONFIG_REG4_TIMER_PHY_LINK_DETECT_BASE;
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+		/* reset PHY Link Detect */
Jesse Keating 2f82dd
+		sky2_pci_write16(hw, PSM_CONFIG_REG4,
Jesse Keating 2f82dd
+				 reg | PSM_CONFIG_REG4_RST_PHY_LINK_DETECT);
Jesse Keating 2f82dd
+		sky2_pci_write16(hw, PSM_CONFIG_REG4, reg);
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+		/* enable PHY Quick Link */
Jesse Keating 2f82dd
+		msk = sky2_read32(hw, B0_IMSK);
Jesse Keating 2f82dd
+		msk |= Y2_IS_PHY_QLNK;
Jesse Keating 2f82dd
+		sky2_write32(hw, B0_IMSK, msk);
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+		/* check if PSMv2 was running before */
Jesse Keating 2f82dd
+		reg = sky2_pci_read16(hw, PSM_CONFIG_REG3);
Jesse Keating 2f82dd
+		if (reg & PCI_EXP_LNKCTL_ASPMC) {
Jesse Keating 2f82dd
+			int cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
Jesse Keating 2f82dd
+			/* restore the PCIe Link Control register */
Jesse Keating 2f82dd
+			sky2_pci_write16(hw, cap + PCI_EXP_LNKCTL, reg);
Jesse Keating 2f82dd
+		}
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
+		/* re-enable PEX PM in PEX PHY debug reg. 8 (clear bit 12) */
Jesse Keating 2f82dd
+		sky2_write32(hw, Y2_PEX_PHY_DATA, PEX_DB_ACCESS | (0x08UL << 16));
Jesse Keating 2f82dd
+	}
Jesse Keating 2f82dd
+
Jesse Keating 2f82dd
 	/* Clear I2C IRQ noise */
Jesse Keating 2f82dd
 	sky2_write32(hw, B2_I2C_IRQ, 1);
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
@@ -4442,9 +4517,11 @@ static const char *sky2_name(u8 chipid, char *buf, int sz)
Jesse Keating 2f82dd
 		"FE+",		/* 0xb8 */
Jesse Keating 2f82dd
 		"Supreme",	/* 0xb9 */
Jesse Keating 2f82dd
 		"UL 2",		/* 0xba */
Jesse Keating 2f82dd
+		"Unknown",	/* 0xbb */
Jesse Keating 2f82dd
+		"Optima",	/* 0xbc */
Jesse Keating 2f82dd
 	};
Jesse Keating 2f82dd
 
Jesse Keating 2f82dd
-	if (chipid >= CHIP_ID_YUKON_XL && chipid < CHIP_ID_YUKON_UL_2)
Jesse Keating 2f82dd
+	if (chipid >= CHIP_ID_YUKON_XL && chipid < CHIP_ID_YUKON_OPT)
Jesse Keating 2f82dd
 		strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz);
Jesse Keating 2f82dd
 	else
Jesse Keating 2f82dd
 		snprintf(buf, sz, "(chip %#x)", chipid);