@@ -18,7 +18,8 @@ Optional properties:
to reprogram drive strength and in effect slow
down the edge rate if desired. Table 1 shows the
impact to the edge rate per VDDMAC supply for each
- drive strength setting.
+ drive strength setting. VDDMAC supply voltage
+ should be one of the value in Table-1 first row.
Ref: Table:1 - Edge rate change below.
Note: see dt-bindings/net/mscc-phy-vsc8531.h for applicable values
@@ -12,7 +12,6 @@
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/of.h>
-#include <dt-bindings/net/mscc-phy-vsc8531.h>
enum rgmii_rx_clock_delay {
RGMII_RX_CLK_DELAY_0_2_NS = 0,
@@ -56,16 +55,18 @@ enum rgmii_rx_clock_delay {
#define PHY_ID_VSC8531 0x00070570
#define PHY_ID_VSC8541 0x00070770
+#define MSCC_SLOWDOWN_MAX 8
+
struct edge_rate_table {
u16 vddmac;
- int slowdown[MSCC_SLOWDOWN_MAX];
+ u8 slowdown[MSCC_SLOWDOWN_MAX];
};
-struct edge_rate_table edge_table[MSCC_VDDMAC_MAX] = {
- {3300, { 0, -2, -4, -7, -10, -17, -29, -53} },
- {2500, { 0, -3, -6, -10, -14, -23, -37, -63} },
- {1800, { 0, -5, -9, -16, -23, -35, -52, -76} },
- {1500, { 0, -6, -14, -21, -29, -42, -58, -77} },
+static const struct edge_rate_table edge_table[] = {
+ {3300, { 0, 2, 4, 7, 10, 17, 29, 53} },
+ {2500, { 0, 3, 6, 10, 14, 23, 37, 63} },
+ {1800, { 0, 5, 9, 16, 23, 35, 52, 76} },
+ {1500, { 0, 6, 14, 21, 29, 42, 58, 77} },
};
struct vsc8531_private {
@@ -81,21 +82,26 @@ static int vsc85xx_phy_page_set(struct phy_device *phydev, u8 page)
return rc;
}
-static u8 edge_rate_magic_get(u16 vddmac,
- int slowdown)
+static u8 vsc85xx_edge_rate_magic_get(u16 vddmac,
+ u8 slowdown)
{
- int rc = (MSCC_SLOWDOWN_MAX - 1);
+ int rc = (ARRAY_SIZE(edge_table[0].slowdown) - 1);
u8 vdd;
u8 sd;
- for (vdd = 0; vdd < MSCC_VDDMAC_MAX; vdd++) {
+ for (vdd = 0; vdd < ARRAY_SIZE(edge_table); vdd++) {
if (edge_table[vdd].vddmac == vddmac) {
- for (sd = 0; sd < MSCC_SLOWDOWN_MAX; sd++) {
- if (edge_table[vdd].slowdown[sd] <= slowdown) {
- rc = (MSCC_SLOWDOWN_MAX - sd - 1);
+ for (sd = 0;
+ sd < ARRAY_SIZE(edge_table[0].slowdown);
+ sd++) {
+ if (edge_table[vdd].slowdown[sd] >= slowdown) {
+ rc = (ARRAY_SIZE(edge_table[0].slowdown)
+ - sd - 1);
break;
}
}
+ /* Max Slowdown Magic number should be zero */
+ rc = 0;
}
}
@@ -198,14 +204,13 @@ static int vsc8531_of_init(struct phy_device *phydev)
rc = of_property_read_u16(of_node, "vsc8531,vddmac",
&vsc8531->vddmac);
if (rc == -EINVAL)
- vsc8531->vddmac = MSCC_VDDMAC_3300;
+ vsc8531->vddmac = 3300;
rc = of_property_read_u8(of_node, "vsc8531,edge-slowdown",
&vsc8531->edge_slowdown);
if (rc == -EINVAL)
vsc8531->edge_slowdown = 0;
- rc = 0;
- return rc;
+ return 0;
}
#else
static int vsc8531_of_init(struct phy_device *phydev)
@@ -232,8 +237,8 @@ static int vsc85xx_config_init(struct phy_device *phydev)
if (rc)
return rc;
- edge_rate = edge_rate_magic_get(vsc8531->vddmac,
- -(int)vsc8531->edge_slowdown);
+ edge_rate = vsc85xx_edge_rate_magic_get(vsc8531->vddmac,
+ vsc8531->edge_slowdown);
rc = vsc85xx_edge_rate_cntl_set(phydev, edge_rate);
if (rc)
return rc;
deleted file mode 100644
@@ -1,21 +0,0 @@
-/*
- * Device Tree constants for Microsemi VSC8531 PHY
- *
- * Author: Nagaraju Lakkaraju
- *
- * License: Dual MIT/GPL
- * Copyright (c) 2016 Microsemi Corporation
- */
-
-#ifndef _DT_BINDINGS_MSCC_VSC8531_H
-#define _DT_BINDINGS_MSCC_VSC8531_H
-
-/* MAC interface Edge rate control VDDMAC in milli Volts */
-#define MSCC_VDDMAC_3300 3300
-#define MSCC_VDDMAC_2500 2500
-#define MSCC_VDDMAC_1800 1800
-#define MSCC_VDDMAC_1500 1500
-#define MSCC_VDDMAC_MAX 4
-#define MSCC_SLOWDOWN_MAX 8
-
-#endif