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