mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 14:43:16 +00:00
net: phy: smsc: Fix disabling energy detect mode
When the lan87xx_read_status function is getting called the energy detect mode is enabled again even if it has been disabled by device tree. Added private struct to check the energy detect status. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8e0c2ab262
commit
0a9c453eef
@ -24,6 +24,10 @@
|
|||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/smscphy.h>
|
#include <linux/smscphy.h>
|
||||||
|
|
||||||
|
struct smsc_phy_priv {
|
||||||
|
bool energy_enable;
|
||||||
|
};
|
||||||
|
|
||||||
static int smsc_phy_config_intr(struct phy_device *phydev)
|
static int smsc_phy_config_intr(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
int rc = phy_write (phydev, MII_LAN83C185_IM,
|
int rc = phy_write (phydev, MII_LAN83C185_IM,
|
||||||
@ -43,19 +47,14 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
|
|||||||
|
|
||||||
static int smsc_phy_config_init(struct phy_device *phydev)
|
static int smsc_phy_config_init(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
int __maybe_unused len;
|
struct smsc_phy_priv *priv = phydev->priv;
|
||||||
struct device *dev __maybe_unused = &phydev->mdio.dev;
|
|
||||||
struct device_node *of_node __maybe_unused = dev->of_node;
|
|
||||||
int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
|
int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
|
||||||
int enable_energy = 1;
|
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
if (of_find_property(of_node, "smsc,disable-energy-detect", &len))
|
if (priv->energy_enable) {
|
||||||
enable_energy = 0;
|
|
||||||
|
|
||||||
if (enable_energy) {
|
|
||||||
/* Enable energy detect mode for this SMSC Transceivers */
|
/* Enable energy detect mode for this SMSC Transceivers */
|
||||||
rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
|
rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
|
||||||
rc | MII_LAN83C185_EDPWRDOWN);
|
rc | MII_LAN83C185_EDPWRDOWN);
|
||||||
@ -110,10 +109,13 @@ static int lan911x_config_init(struct phy_device *phydev)
|
|||||||
*/
|
*/
|
||||||
static int lan87xx_read_status(struct phy_device *phydev)
|
static int lan87xx_read_status(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
int err = genphy_read_status(phydev);
|
struct smsc_phy_priv *priv = phydev->priv;
|
||||||
int i;
|
|
||||||
|
int err = genphy_read_status(phydev);
|
||||||
|
|
||||||
|
if (!phydev->link && priv->energy_enable) {
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!phydev->link) {
|
|
||||||
/* Disable EDPD to wake up PHY */
|
/* Disable EDPD to wake up PHY */
|
||||||
int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
|
int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
@ -149,6 +151,26 @@ static int lan87xx_read_status(struct phy_device *phydev)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int smsc_phy_probe(struct phy_device *phydev)
|
||||||
|
{
|
||||||
|
struct device *dev = &phydev->mdio.dev;
|
||||||
|
struct device_node *of_node = dev->of_node;
|
||||||
|
struct smsc_phy_priv *priv;
|
||||||
|
|
||||||
|
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||||
|
if (!priv)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
priv->energy_enable = true;
|
||||||
|
|
||||||
|
if (of_property_read_bool(of_node, "smsc,disable-energy-detect"))
|
||||||
|
priv->energy_enable = false;
|
||||||
|
|
||||||
|
phydev->priv = priv;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static struct phy_driver smsc_phy_driver[] = {
|
static struct phy_driver smsc_phy_driver[] = {
|
||||||
{
|
{
|
||||||
.phy_id = 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
|
.phy_id = 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
|
||||||
@ -159,6 +181,8 @@ static struct phy_driver smsc_phy_driver[] = {
|
|||||||
| SUPPORTED_Asym_Pause),
|
| SUPPORTED_Asym_Pause),
|
||||||
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
||||||
|
|
||||||
|
.probe = smsc_phy_probe,
|
||||||
|
|
||||||
/* basic functions */
|
/* basic functions */
|
||||||
.config_aneg = genphy_config_aneg,
|
.config_aneg = genphy_config_aneg,
|
||||||
.read_status = genphy_read_status,
|
.read_status = genphy_read_status,
|
||||||
@ -180,6 +204,8 @@ static struct phy_driver smsc_phy_driver[] = {
|
|||||||
| SUPPORTED_Asym_Pause),
|
| SUPPORTED_Asym_Pause),
|
||||||
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
||||||
|
|
||||||
|
.probe = smsc_phy_probe,
|
||||||
|
|
||||||
/* basic functions */
|
/* basic functions */
|
||||||
.config_aneg = genphy_config_aneg,
|
.config_aneg = genphy_config_aneg,
|
||||||
.read_status = genphy_read_status,
|
.read_status = genphy_read_status,
|
||||||
@ -201,6 +227,8 @@ static struct phy_driver smsc_phy_driver[] = {
|
|||||||
| SUPPORTED_Asym_Pause),
|
| SUPPORTED_Asym_Pause),
|
||||||
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
||||||
|
|
||||||
|
.probe = smsc_phy_probe,
|
||||||
|
|
||||||
/* basic functions */
|
/* basic functions */
|
||||||
.config_aneg = genphy_config_aneg,
|
.config_aneg = genphy_config_aneg,
|
||||||
.read_status = lan87xx_read_status,
|
.read_status = lan87xx_read_status,
|
||||||
@ -222,6 +250,8 @@ static struct phy_driver smsc_phy_driver[] = {
|
|||||||
| SUPPORTED_Asym_Pause),
|
| SUPPORTED_Asym_Pause),
|
||||||
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
||||||
|
|
||||||
|
.probe = smsc_phy_probe,
|
||||||
|
|
||||||
/* basic functions */
|
/* basic functions */
|
||||||
.config_aneg = genphy_config_aneg,
|
.config_aneg = genphy_config_aneg,
|
||||||
.read_status = genphy_read_status,
|
.read_status = genphy_read_status,
|
||||||
@ -242,6 +272,8 @@ static struct phy_driver smsc_phy_driver[] = {
|
|||||||
| SUPPORTED_Asym_Pause),
|
| SUPPORTED_Asym_Pause),
|
||||||
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
||||||
|
|
||||||
|
.probe = smsc_phy_probe,
|
||||||
|
|
||||||
/* basic functions */
|
/* basic functions */
|
||||||
.config_aneg = genphy_config_aneg,
|
.config_aneg = genphy_config_aneg,
|
||||||
.read_status = lan87xx_read_status,
|
.read_status = lan87xx_read_status,
|
||||||
@ -263,6 +295,8 @@ static struct phy_driver smsc_phy_driver[] = {
|
|||||||
| SUPPORTED_Asym_Pause),
|
| SUPPORTED_Asym_Pause),
|
||||||
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
.flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
|
||||||
|
|
||||||
|
.probe = smsc_phy_probe,
|
||||||
|
|
||||||
/* basic functions */
|
/* basic functions */
|
||||||
.config_aneg = genphy_config_aneg,
|
.config_aneg = genphy_config_aneg,
|
||||||
.read_status = lan87xx_read_status,
|
.read_status = lan87xx_read_status,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user