From 770bc346fd5d4380c3572b8e313c3d2714227069 Mon Sep 17 00:00:00 2001
From: Siva Reddy Kallam <siva.kallam@broadcom.com>
Date: Mon, 25 Sep 2017 12:37:05 +0530
Subject: [PATCH] tg3: Add clock override support for 5762

This patch add the override support for 5762

Signed-off-by: Siva Reddy Kallam <siva.kallam@broadcom.com>
---
 drivers/net/ethernet/broadcom/tg3.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index d8d5f20..cde6244 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -9009,6 +9009,11 @@ static void tg3_override_clk(struct tg3 *tp)
 	case ASIC_REV_5720:
 		tw32(TG3_CPMU_CLCK_ORIDE, CPMU_CLCK_ORIDE_MAC_ORIDE_EN);
 		break;
+	case ASIC_REV_5762:
+		val = tr32(TG3_CPMU_CLCK_ORIDE_ENABLE);
+		tw32(TG3_CPMU_CLCK_ORIDE_ENABLE, val |
+		     TG3_CPMU_MAC_ORIDE_ENABLE);
+		break;
 
 	default:
 		return;
@@ -9131,13 +9136,6 @@ static int tg3_chip_reset(struct tg3 *tp)
 		     tr32(GRC_VCPU_EXT_CTRL) & ~GRC_VCPU_EXT_CTRL_HALT_CPU);
 	}
 
-	/* Set the clock to the highest frequency to avoid timeouts. With link
-	 * aware mode, the clock speed could be slow and bootcode does not
-	 * complete within the expected time. Override the clock to allow the
-	 * bootcode to finish sooner and then restore it.
-	 */
-	tg3_override_clk(tp);
-
 	/* Manage gphy power for all CPMU absent PCIe devices. */
 	if (tg3_flag(tp, 5705_PLUS) && !tg3_flag(tp, CPMU_PRESENT))
 		val |= GRC_MISC_CFG_KEEP_GPHY_POWER;
@@ -9235,6 +9233,13 @@ static int tg3_chip_reset(struct tg3 *tp)
 	if (err)
 		return err;
 
+	/* Set the clock to the highest frequency to avoid timeouts. With link
+	 * aware mode, the clock speed could be slow and bootcode does not
+	 * complete within the expected time. Override the clock to allow the
+	 * bootcode to finish sooner and then restore it.
+	 */
+	tg3_override_clk(tp);
+
 	tw32(GRC_MODE, tp->grc_mode);
 
 	if (tg3_chip_rev_id(tp) == CHIPREV_ID_5705_A0) {
-- 
1.8.3.1

