ipq807x: Set the NSS ports clock and MAC speed dynamically
Change-Id: If4cbff1a939fb165b2aef04d81e93b531789c8ed
Signed-off-by: Sham Muthayyan <smuthayy@codeaurora.org>
diff --git a/drivers/net/ipq807x/ipq807x_edma.c b/drivers/net/ipq807x/ipq807x_edma.c
index 5b24d73..c261ab8 100644
--- a/drivers/net/ipq807x/ipq807x_edma.c
+++ b/drivers/net/ipq807x/ipq807x_edma.c
@@ -868,7 +868,7 @@
char *lstatus[] = {"up", "Down"};
char *dp[] = {"Half", "Full"};
int linkup=0;
-
+ int mac_speed, speed_clock1, speed_clock2;
if (!priv->ops) {
printf ("Phy ops not mapped\n");
return -1;
@@ -896,8 +896,25 @@
phy_get_ops->phy_get_duplex(priv->mac_unit, i, &duplex);
switch (speed) {
case FAL_SPEED_10:
+ mac_speed = 0x0;
+ speed_clock1 = 0x109;
+ speed_clock2 = 0x9;
+ printf ("eth%d PHY%d %s Speed :%d %s duplex\n",
+ priv->mac_unit, i, lstatus[status], speed,
+ dp[duplex]);
+ break;
case FAL_SPEED_100:
+ mac_speed = 0x1;
+ speed_clock1 = 0x101;
+ speed_clock2 = 0x4;
+ printf ("eth%d PHY%d %s Speed :%d %s duplex\n",
+ priv->mac_unit, i, lstatus[status], speed,
+ dp[duplex]);
+ break;
case FAL_SPEED_1000:
+ mac_speed = 0x2;
+ speed_clock1 = 0x101;
+ speed_clock2 = 0x0;
printf ("eth%d PHY%d %s Speed :%d %s duplex\n",
priv->mac_unit, i, lstatus[status], speed,
dp[duplex]);
@@ -906,6 +923,7 @@
printf("Unknown speed\n");
break;
}
+ ipq807x_pqsgmii_speed_clock_set(i, mac_speed, speed_clock1, speed_clock2);
}
if (linkup <= 0) {
diff --git a/drivers/net/ipq807x/ipq807x_edma.h b/drivers/net/ipq807x/ipq807x_edma.h
index 396baf2..454e8d0 100644
--- a/drivers/net/ipq807x/ipq807x_edma.h
+++ b/drivers/net/ipq807x/ipq807x_edma.h
@@ -306,5 +306,6 @@
} ipq807x_edma_board_cfg_t;
extern void ipq807x_ppe_provision_init(void);
+extern void ipq807x_pqsgmii_speed_clock_set(int port, int speed, int speed_clock1, int speed_clock2);
#endif /* ___IPQ807X_EDMA__ */
diff --git a/drivers/net/ipq807x/ipq807x_ppe.c b/drivers/net/ipq807x/ipq807x_ppe.c
index 4fad3f3..671b2eb 100644
--- a/drivers/net/ipq807x/ipq807x_ppe.c
+++ b/drivers/net/ipq807x/ipq807x_ppe.c
@@ -106,6 +106,18 @@
ipq807x_ppe_reg_write(IPQ807X_PPE_MAC_SPEED + (0x200 * port), 0x2);
ipq807x_ppe_reg_write(IPQ807X_PPE_MAC_MIB_CTL + (0x200 * port), 0x1);
}
+void ipq807x_pqsgmii_speed_clock_set(int port, int speed, int speed_clock1, int speed_clock2)
+{
+ int i;
+
+ for (i = 0; i < 2; i++)
+ {
+ writel(speed_clock2, GCC_NSS_PORT1_RX_MISC + i*4 + port*0x10);
+ writel(speed_clock1, GCC_NSS_PORT1_RX_CFG_RCGR + i*8 + port*0x10);
+ writel(0x1, GCC_NSS_PORT1_RX_CMD_RCGR + i*8 + port*0x10);
+ }
+ ipq807x_ppe_reg_write(IPQ807X_PPE_MAC_SPEED + (0x200 * port), speed);
+}
/*
* ipq807x_ppe_flow_port_map_tbl_port_num_set()
diff --git a/drivers/net/ipq807x/ipq807x_ppe.h b/drivers/net/ipq807x/ipq807x_ppe.h
index b79529e..dea7637 100644
--- a/drivers/net/ipq807x/ipq807x_ppe.h
+++ b/drivers/net/ipq807x/ipq807x_ppe.h
@@ -25,6 +25,10 @@
#include <net.h>
#include <miiphy.h>
+#define GCC_NSS_PORT1_RX_CMD_RCGR 0x01868020
+#define GCC_NSS_PORT1_RX_CFG_RCGR 0x01868024
+#define GCC_NSS_PORT1_RX_MISC 0x01868400
+
#define IPQ807X_PPE_BASE_ADDR 0x3a000000
#define IPQ807X_PPE_REG_SIZE 0x1000000