2016-08-05 19:24:21 +07:00
|
|
|
/*
|
|
|
|
* Driver for Microsemi VSC85xx PHYs
|
|
|
|
*
|
|
|
|
* Author: Nagaraju Lakkaraju
|
|
|
|
* License: Dual MIT/GPL
|
|
|
|
* Copyright (c) 2016 Microsemi Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mdio.h>
|
|
|
|
#include <linux/mii.h>
|
|
|
|
#include <linux/phy.h>
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
#include <linux/of.h>
|
|
|
|
#include <dt-bindings/net/mscc-phy-vsc8531.h>
|
2016-10-05 15:49:27 +07:00
|
|
|
#include <linux/netdevice.h>
|
2016-08-05 19:24:21 +07:00
|
|
|
|
|
|
|
enum rgmii_rx_clock_delay {
|
2016-09-08 15:39:31 +07:00
|
|
|
RGMII_RX_CLK_DELAY_0_2_NS = 0,
|
|
|
|
RGMII_RX_CLK_DELAY_0_8_NS = 1,
|
|
|
|
RGMII_RX_CLK_DELAY_1_1_NS = 2,
|
|
|
|
RGMII_RX_CLK_DELAY_1_7_NS = 3,
|
|
|
|
RGMII_RX_CLK_DELAY_2_0_NS = 4,
|
|
|
|
RGMII_RX_CLK_DELAY_2_3_NS = 5,
|
|
|
|
RGMII_RX_CLK_DELAY_2_6_NS = 6,
|
|
|
|
RGMII_RX_CLK_DELAY_3_4_NS = 7
|
2016-08-05 19:24:21 +07:00
|
|
|
};
|
|
|
|
|
2016-09-19 17:03:54 +07:00
|
|
|
/* Microsemi VSC85xx PHY registers */
|
|
|
|
/* IEEE 802. Std Registers */
|
|
|
|
#define MSCC_PHY_EXT_PHY_CNTL_1 23
|
|
|
|
#define MAC_IF_SELECTION_MASK 0x1800
|
|
|
|
#define MAC_IF_SELECTION_GMII 0
|
|
|
|
#define MAC_IF_SELECTION_RMII 1
|
|
|
|
#define MAC_IF_SELECTION_RGMII 2
|
|
|
|
#define MAC_IF_SELECTION_POS 11
|
|
|
|
#define FAR_END_LOOPBACK_MODE_MASK 0x0008
|
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
#define MII_VSC85XX_INT_MASK 25
|
|
|
|
#define MII_VSC85XX_INT_MASK_MASK 0xa000
|
2016-10-05 15:49:27 +07:00
|
|
|
#define MII_VSC85XX_INT_MASK_WOL 0x0040
|
2016-09-08 15:39:31 +07:00
|
|
|
#define MII_VSC85XX_INT_STATUS 26
|
2016-08-05 19:24:21 +07:00
|
|
|
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
#define MSCC_PHY_WOL_MAC_CONTROL 27
|
|
|
|
#define EDGE_RATE_CNTL_POS 5
|
|
|
|
#define EDGE_RATE_CNTL_MASK 0x00E0
|
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
#define MSCC_EXT_PAGE_ACCESS 31
|
|
|
|
#define MSCC_PHY_PAGE_STANDARD 0x0000 /* Standard registers */
|
|
|
|
#define MSCC_PHY_PAGE_EXTENDED_2 0x0002 /* Extended reg - page 2 */
|
2016-08-05 19:24:21 +07:00
|
|
|
|
|
|
|
/* Extended Page 2 Registers */
|
2016-09-08 15:39:31 +07:00
|
|
|
#define MSCC_PHY_RGMII_CNTL 20
|
|
|
|
#define RGMII_RX_CLK_DELAY_MASK 0x0070
|
|
|
|
#define RGMII_RX_CLK_DELAY_POS 4
|
2016-08-05 19:24:21 +07:00
|
|
|
|
2016-10-05 15:49:27 +07:00
|
|
|
#define MSCC_PHY_WOL_LOWER_MAC_ADDR 21
|
|
|
|
#define MSCC_PHY_WOL_MID_MAC_ADDR 22
|
|
|
|
#define MSCC_PHY_WOL_UPPER_MAC_ADDR 23
|
|
|
|
#define MSCC_PHY_WOL_LOWER_PASSWD 24
|
|
|
|
#define MSCC_PHY_WOL_MID_PASSWD 25
|
|
|
|
#define MSCC_PHY_WOL_UPPER_PASSWD 26
|
|
|
|
|
|
|
|
#define MSCC_PHY_WOL_MAC_CONTROL 27
|
|
|
|
#define SECURE_ON_ENABLE 0x8000
|
|
|
|
#define SECURE_ON_PASSWD_LEN_4 0x4000
|
|
|
|
|
2016-08-05 19:24:21 +07:00
|
|
|
/* Microsemi PHY ID's */
|
2016-09-08 15:39:31 +07:00
|
|
|
#define PHY_ID_VSC8531 0x00070570
|
|
|
|
#define PHY_ID_VSC8541 0x00070770
|
2016-08-05 19:24:21 +07:00
|
|
|
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
struct edge_rate_table {
|
|
|
|
u16 vddmac;
|
|
|
|
int 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} },
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vsc8531_private {
|
|
|
|
u8 edge_slowdown;
|
|
|
|
u16 vddmac;
|
|
|
|
};
|
|
|
|
|
2016-08-05 19:24:21 +07:00
|
|
|
static int vsc85xx_phy_page_set(struct phy_device *phydev, u8 page)
|
|
|
|
{
|
2016-09-08 15:39:31 +07:00
|
|
|
int rc;
|
2016-08-05 19:24:21 +07:00
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
rc = phy_write(phydev, MSCC_EXT_PAGE_ACCESS, page);
|
|
|
|
return rc;
|
2016-08-05 19:24:21 +07:00
|
|
|
}
|
|
|
|
|
2016-10-05 15:49:27 +07:00
|
|
|
static int vsc85xx_wol_set(struct phy_device *phydev,
|
|
|
|
struct ethtool_wolinfo *wol)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
u16 reg_val;
|
|
|
|
u8 i;
|
|
|
|
u16 pwd[3] = {0, 0, 0};
|
|
|
|
struct ethtool_wolinfo *wol_conf = wol;
|
|
|
|
u8 *mac_addr = phydev->attached_dev->dev_addr;
|
|
|
|
|
|
|
|
mutex_lock(&phydev->lock);
|
|
|
|
rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED_2);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
if (wol->wolopts & WAKE_MAGIC) {
|
|
|
|
/* Store the device address for the magic packet */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(pwd); i++)
|
|
|
|
pwd[i] = mac_addr[5 - (i * 2 + 1)] << 8 |
|
|
|
|
mac_addr[5 - i * 2];
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_LOWER_MAC_ADDR, pwd[0]);
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_MID_MAC_ADDR, pwd[1]);
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_UPPER_MAC_ADDR, pwd[2]);
|
|
|
|
} else {
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_LOWER_MAC_ADDR, 0);
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_MID_MAC_ADDR, 0);
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_UPPER_MAC_ADDR, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wol_conf->wolopts & WAKE_MAGICSECURE) {
|
|
|
|
for (i = 0; i < ARRAY_SIZE(pwd); i++)
|
|
|
|
pwd[i] = wol_conf->sopass[5 - (i * 2 + 1)] << 8 |
|
|
|
|
wol_conf->sopass[5 - i * 2];
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_LOWER_PASSWD, pwd[0]);
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_MID_PASSWD, pwd[1]);
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_UPPER_PASSWD, pwd[2]);
|
|
|
|
} else {
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_LOWER_PASSWD, 0);
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_MID_PASSWD, 0);
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_UPPER_PASSWD, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
reg_val = phy_read(phydev, MSCC_PHY_WOL_MAC_CONTROL);
|
|
|
|
if (wol_conf->wolopts & WAKE_MAGICSECURE)
|
|
|
|
reg_val |= SECURE_ON_ENABLE;
|
|
|
|
else
|
|
|
|
reg_val &= ~SECURE_ON_ENABLE;
|
|
|
|
phy_write(phydev, MSCC_PHY_WOL_MAC_CONTROL, reg_val);
|
|
|
|
|
|
|
|
rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_STANDARD);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
if (wol->wolopts & WAKE_MAGIC) {
|
|
|
|
/* Enable the WOL interrupt */
|
|
|
|
reg_val = phy_read(phydev, MII_VSC85XX_INT_MASK);
|
|
|
|
reg_val |= MII_VSC85XX_INT_MASK_WOL;
|
|
|
|
rc = phy_write(phydev, MII_VSC85XX_INT_MASK, reg_val);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_unlock;
|
|
|
|
} else {
|
|
|
|
/* Disable the WOL interrupt */
|
|
|
|
reg_val = phy_read(phydev, MII_VSC85XX_INT_MASK);
|
|
|
|
reg_val &= (~MII_VSC85XX_INT_MASK_WOL);
|
|
|
|
rc = phy_write(phydev, MII_VSC85XX_INT_MASK, reg_val);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
/* Clear WOL iterrupt status */
|
|
|
|
reg_val = phy_read(phydev, MII_VSC85XX_INT_STATUS);
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
mutex_unlock(&phydev->lock);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vsc85xx_wol_get(struct phy_device *phydev,
|
|
|
|
struct ethtool_wolinfo *wol)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
u16 reg_val;
|
|
|
|
u8 i;
|
|
|
|
u16 pwd[3] = {0, 0, 0};
|
|
|
|
struct ethtool_wolinfo *wol_conf = wol;
|
|
|
|
|
|
|
|
mutex_lock(&phydev->lock);
|
|
|
|
rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED_2);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
reg_val = phy_read(phydev, MSCC_PHY_WOL_MAC_CONTROL);
|
|
|
|
if (reg_val & SECURE_ON_ENABLE)
|
|
|
|
wol_conf->wolopts |= WAKE_MAGICSECURE;
|
|
|
|
if (wol_conf->wolopts & WAKE_MAGICSECURE) {
|
|
|
|
pwd[0] = phy_read(phydev, MSCC_PHY_WOL_LOWER_PASSWD);
|
|
|
|
pwd[1] = phy_read(phydev, MSCC_PHY_WOL_MID_PASSWD);
|
|
|
|
pwd[2] = phy_read(phydev, MSCC_PHY_WOL_UPPER_PASSWD);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(pwd); i++) {
|
|
|
|
wol_conf->sopass[5 - i * 2] = pwd[i] & 0x00ff;
|
|
|
|
wol_conf->sopass[5 - (i * 2 + 1)] = (pwd[i] & 0xff00)
|
|
|
|
>> 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_STANDARD);
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
mutex_unlock(&phydev->lock);
|
|
|
|
}
|
|
|
|
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
static u8 edge_rate_magic_get(u16 vddmac,
|
|
|
|
int slowdown)
|
|
|
|
{
|
|
|
|
int rc = (MSCC_SLOWDOWN_MAX - 1);
|
|
|
|
u8 vdd;
|
|
|
|
u8 sd;
|
|
|
|
|
|
|
|
for (vdd = 0; vdd < MSCC_VDDMAC_MAX; 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);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vsc85xx_edge_rate_cntl_set(struct phy_device *phydev,
|
|
|
|
u8 edge_rate)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
u16 reg_val;
|
|
|
|
|
|
|
|
mutex_lock(&phydev->lock);
|
|
|
|
rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED_2);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_unlock;
|
|
|
|
reg_val = phy_read(phydev, MSCC_PHY_WOL_MAC_CONTROL);
|
|
|
|
reg_val &= ~(EDGE_RATE_CNTL_MASK);
|
|
|
|
reg_val |= (edge_rate << EDGE_RATE_CNTL_POS);
|
|
|
|
rc = phy_write(phydev, MSCC_PHY_WOL_MAC_CONTROL, reg_val);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_unlock;
|
|
|
|
rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_STANDARD);
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
mutex_unlock(&phydev->lock);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-09-19 17:03:54 +07:00
|
|
|
static int vsc85xx_mac_if_set(struct phy_device *phydev,
|
|
|
|
phy_interface_t interface)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
u16 reg_val;
|
|
|
|
|
|
|
|
mutex_lock(&phydev->lock);
|
|
|
|
reg_val = phy_read(phydev, MSCC_PHY_EXT_PHY_CNTL_1);
|
|
|
|
reg_val &= ~(MAC_IF_SELECTION_MASK);
|
|
|
|
switch (interface) {
|
|
|
|
case PHY_INTERFACE_MODE_RGMII:
|
|
|
|
reg_val |= (MAC_IF_SELECTION_RGMII << MAC_IF_SELECTION_POS);
|
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_RMII:
|
|
|
|
reg_val |= (MAC_IF_SELECTION_RMII << MAC_IF_SELECTION_POS);
|
|
|
|
break;
|
|
|
|
case PHY_INTERFACE_MODE_MII:
|
|
|
|
case PHY_INTERFACE_MODE_GMII:
|
|
|
|
reg_val |= (MAC_IF_SELECTION_GMII << MAC_IF_SELECTION_POS);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = -EINVAL;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
rc = phy_write(phydev, MSCC_PHY_EXT_PHY_CNTL_1, reg_val);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
rc = genphy_soft_reset(phydev);
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
mutex_unlock(&phydev->lock);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-08-05 19:24:21 +07:00
|
|
|
static int vsc85xx_default_config(struct phy_device *phydev)
|
|
|
|
{
|
2016-09-08 15:39:31 +07:00
|
|
|
int rc;
|
|
|
|
u16 reg_val;
|
2016-08-05 19:24:21 +07:00
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
mutex_lock(&phydev->lock);
|
|
|
|
rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED_2);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out_unlock;
|
2016-08-05 19:24:21 +07:00
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
reg_val = phy_read(phydev, MSCC_PHY_RGMII_CNTL);
|
|
|
|
reg_val &= ~(RGMII_RX_CLK_DELAY_MASK);
|
|
|
|
reg_val |= (RGMII_RX_CLK_DELAY_1_1_NS << RGMII_RX_CLK_DELAY_POS);
|
|
|
|
phy_write(phydev, MSCC_PHY_RGMII_CNTL, reg_val);
|
|
|
|
rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_STANDARD);
|
2016-08-05 19:24:21 +07:00
|
|
|
|
|
|
|
out_unlock:
|
2016-09-08 15:39:31 +07:00
|
|
|
mutex_unlock(&phydev->lock);
|
2016-08-05 19:24:21 +07:00
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
return rc;
|
2016-08-05 19:24:21 +07:00
|
|
|
}
|
|
|
|
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
#ifdef CONFIG_OF_MDIO
|
|
|
|
static int vsc8531_of_init(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct vsc8531_private *vsc8531 = phydev->priv;
|
|
|
|
struct device *dev = &phydev->mdio.dev;
|
|
|
|
struct device_node *of_node = dev->of_node;
|
|
|
|
|
|
|
|
if (!of_node)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
rc = of_property_read_u16(of_node, "vsc8531,vddmac",
|
|
|
|
&vsc8531->vddmac);
|
|
|
|
if (rc == -EINVAL)
|
|
|
|
vsc8531->vddmac = MSCC_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;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static int vsc8531_of_init(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_OF_MDIO */
|
|
|
|
|
2016-08-05 19:24:21 +07:00
|
|
|
static int vsc85xx_config_init(struct phy_device *phydev)
|
|
|
|
{
|
2016-09-08 15:39:31 +07:00
|
|
|
int rc;
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
struct vsc8531_private *vsc8531 = phydev->priv;
|
|
|
|
u8 edge_rate;
|
|
|
|
|
|
|
|
rc = vsc8531_of_init(phydev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2016-08-05 19:24:21 +07:00
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
rc = vsc85xx_default_config(phydev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2016-09-19 17:03:54 +07:00
|
|
|
|
|
|
|
rc = vsc85xx_mac_if_set(phydev, phydev->interface);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
edge_rate = edge_rate_magic_get(vsc8531->vddmac,
|
|
|
|
-(int)vsc8531->edge_slowdown);
|
|
|
|
rc = vsc85xx_edge_rate_cntl_set(phydev, edge_rate);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
rc = genphy_config_init(phydev);
|
2016-08-05 19:24:21 +07:00
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
return rc;
|
2016-08-05 19:24:21 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vsc85xx_ack_interrupt(struct phy_device *phydev)
|
|
|
|
{
|
2016-09-08 15:39:31 +07:00
|
|
|
int rc = 0;
|
2016-08-05 19:24:21 +07:00
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
|
|
|
|
rc = phy_read(phydev, MII_VSC85XX_INT_STATUS);
|
2016-08-05 19:24:21 +07:00
|
|
|
|
2016-09-08 15:39:31 +07:00
|
|
|
return (rc < 0) ? rc : 0;
|
2016-08-05 19:24:21 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vsc85xx_config_intr(struct phy_device *phydev)
|
|
|
|
{
|
2016-09-08 15:39:31 +07:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
|
|
|
|
rc = phy_write(phydev, MII_VSC85XX_INT_MASK,
|
|
|
|
MII_VSC85XX_INT_MASK_MASK);
|
|
|
|
} else {
|
|
|
|
rc = phy_write(phydev, MII_VSC85XX_INT_MASK, 0);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
rc = phy_read(phydev, MII_VSC85XX_INT_STATUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
2016-08-05 19:24:21 +07:00
|
|
|
}
|
|
|
|
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
static int vsc85xx_probe(struct phy_device *phydev)
|
|
|
|
{
|
|
|
|
struct vsc8531_private *vsc8531;
|
|
|
|
|
|
|
|
vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL);
|
|
|
|
if (!vsc8531)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
phydev->priv = vsc8531;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-05 19:24:21 +07:00
|
|
|
/* Microsemi VSC85xx PHYs */
|
|
|
|
static struct phy_driver vsc85xx_driver[] = {
|
|
|
|
{
|
2016-09-08 15:39:31 +07:00
|
|
|
.phy_id = PHY_ID_VSC8531,
|
|
|
|
.name = "Microsemi VSC8531",
|
|
|
|
.phy_id_mask = 0xfffffff0,
|
|
|
|
.features = PHY_GBIT_FEATURES,
|
|
|
|
.flags = PHY_HAS_INTERRUPT,
|
|
|
|
.soft_reset = &genphy_soft_reset,
|
|
|
|
.config_init = &vsc85xx_config_init,
|
|
|
|
.config_aneg = &genphy_config_aneg,
|
|
|
|
.aneg_done = &genphy_aneg_done,
|
|
|
|
.read_status = &genphy_read_status,
|
|
|
|
.ack_interrupt = &vsc85xx_ack_interrupt,
|
|
|
|
.config_intr = &vsc85xx_config_intr,
|
|
|
|
.suspend = &genphy_suspend,
|
|
|
|
.resume = &genphy_resume,
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
.probe = &vsc85xx_probe,
|
2016-10-05 15:49:27 +07:00
|
|
|
.set_wol = &vsc85xx_wol_set,
|
|
|
|
.get_wol = &vsc85xx_wol_get,
|
2016-08-05 19:24:21 +07:00
|
|
|
},
|
|
|
|
{
|
2016-09-08 15:39:31 +07:00
|
|
|
.phy_id = PHY_ID_VSC8541,
|
|
|
|
.name = "Microsemi VSC8541 SyncE",
|
|
|
|
.phy_id_mask = 0xfffffff0,
|
|
|
|
.features = PHY_GBIT_FEATURES,
|
|
|
|
.flags = PHY_HAS_INTERRUPT,
|
|
|
|
.soft_reset = &genphy_soft_reset,
|
|
|
|
.config_init = &vsc85xx_config_init,
|
|
|
|
.config_aneg = &genphy_config_aneg,
|
|
|
|
.aneg_done = &genphy_aneg_done,
|
|
|
|
.read_status = &genphy_read_status,
|
|
|
|
.ack_interrupt = &vsc85xx_ack_interrupt,
|
|
|
|
.config_intr = &vsc85xx_config_intr,
|
|
|
|
.suspend = &genphy_suspend,
|
|
|
|
.resume = &genphy_resume,
|
net: phy: Add Edge-rate driver for Microsemi PHYs.
Edge-rate:
As system and networking speeds increase, a signal's output transition,
also know as the edge rate or slew rate (V/ns), takes on greater importance
because high-speed signals come with a price. That price is an assortment of
interference problems like ringing on the line, signal overshoot and
undershoot, extended signal settling times, crosstalk noise, transmission
line reflections, false signal detection by the receiving device and
electromagnetic interference (EMI) -- all of which can negate the potential
gains designers are seeking when they try to increase system speeds through
the use of higher performance logic devices. The fact is, faster signaling
edge rates can cause a higher level of electrical noise or other type of
interference that can actually lead to slower line speeds and lower maximum
system frequencies. This parameter allow the board designers to change the
driving strange, and thereby change the EMI behavioral.
Edge-rate parameters (vddmac, edge-slowdown) get from Device Tree.
Tested on Beaglebone Black with VSC 8531 PHY.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-03 14:23:13 +07:00
|
|
|
.probe = &vsc85xx_probe,
|
2016-10-05 15:49:27 +07:00
|
|
|
.set_wol = &vsc85xx_wol_set,
|
|
|
|
.get_wol = &vsc85xx_wol_get,
|
2016-08-05 19:24:21 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module_phy_driver(vsc85xx_driver);
|
|
|
|
|
|
|
|
static struct mdio_device_id __maybe_unused vsc85xx_tbl[] = {
|
2016-09-08 15:39:31 +07:00
|
|
|
{ PHY_ID_VSC8531, 0xfffffff0, },
|
|
|
|
{ PHY_ID_VSC8541, 0xfffffff0, },
|
|
|
|
{ }
|
2016-08-05 19:24:21 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(mdio, vsc85xx_tbl);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Microsemi VSC85xx PHY driver");
|
|
|
|
MODULE_AUTHOR("Nagaraju Lakkaraju");
|
|
|
|
MODULE_LICENSE("Dual MIT/GPL");
|