mutex_unlock(&bus->mdio_lock);
}
+u16
+ar8xxx_phy_mmd_read(struct ar8xxx_priv *priv, int phy_addr, u16 addr)
+{
+ struct mii_bus *bus = priv->mii_bus;
+ u16 data;
+
+ mutex_lock(&bus->mdio_lock);
+ bus->write(bus, phy_addr, MII_ATH_MMD_ADDR, addr);
+ data = bus->read(bus, phy_addr, MII_ATH_MMD_DATA);
+ mutex_unlock(&bus->mdio_lock);
+
+ return data;
+}
+
static int
ar8xxx_reg_wait(struct ar8xxx_priv *priv, u32 reg, u32 mask, u32 val,
unsigned timeout)
link->tx_flow = !!(status & AR8216_PORT_STATUS_TXFLOW);
link->rx_flow = !!(status & AR8216_PORT_STATUS_RXFLOW);
+ if (link->aneg && link->duplex && priv->chip->read_port_eee_status)
+ link->eee = priv->chip->read_port_eee_status(priv, port);
+
speed = (status & AR8216_PORT_STATUS_SPEED) >>
AR8216_PORT_STATUS_SPEED_S;
void (*init_port)(struct ar8xxx_priv *priv, int port);
void (*setup_port)(struct ar8xxx_priv *priv, int port, u32 members);
u32 (*read_port_status)(struct ar8xxx_priv *priv, int port);
+ u32 (*read_port_eee_status)(struct ar8xxx_priv *priv, int port);
int (*atu_flush)(struct ar8xxx_priv *priv);
void (*vtu_flush)(struct ar8xxx_priv *priv);
void (*vtu_load_vlan)(struct ar8xxx_priv *priv, u32 vid, u32 port_mask);
u16 dbg_addr, u16 dbg_data);
void
ar8xxx_phy_mmd_write(struct ar8xxx_priv *priv, int phy_addr, u16 addr, u16 data);
+u16
+ar8xxx_phy_mmd_read(struct ar8xxx_priv *priv, int phy_addr, u16 addr);
void
ar8xxx_phy_init(struct ar8xxx_priv *priv);
int
#include <linux/workqueue.h>
#include <linux/of_device.h>
#include <linux/leds.h>
+#include <linux/mdio.h>
#include "ar8216.h"
#include "ar8327.h"
return ar8xxx_read(priv, AR8327_REG_PORT_STATUS(port));
}
+static u32
+ar8327_read_port_eee_status(struct ar8xxx_priv *priv, int port)
+{
+ int phy;
+ u16 t;
+
+ if (port >= priv->dev.ports)
+ return 0;
+
+ if (port == 0 || port == 6)
+ return 0;
+
+ phy = port - 1;
+
+ /* EEE Ability Auto-negotiation Result */
+ ar8xxx_phy_mmd_write(priv, phy, 0x7, 0x8000);
+ t = ar8xxx_phy_mmd_read(priv, phy, 0x4007);
+
+ return mmd_eee_adv_to_ethtool_adv_t(t);
+}
+
static int
ar8327_atu_flush(struct ar8xxx_priv *priv)
{
.init_port = ar8327_init_port,
.setup_port = ar8327_setup_port,
.read_port_status = ar8327_read_port_status,
+ .read_port_eee_status = ar8327_read_port_eee_status,
.atu_flush = ar8327_atu_flush,
.vtu_flush = ar8327_vtu_flush,
.vtu_load_vlan = ar8327_vtu_load_vlan,
.init_port = ar8327_init_port,
.setup_port = ar8327_setup_port,
.read_port_status = ar8327_read_port_status,
+ .read_port_eee_status = ar8327_read_port_eee_status,
.atu_flush = ar8327_atu_flush,
.vtu_flush = ar8327_vtu_flush,
.vtu_load_vlan = ar8327_vtu_load_vlan,
if (link.link)
len = snprintf(dev->buf, sizeof(dev->buf),
- "port:%d link:up speed:%s %s-duplex %s%s%s",
+ "port:%d link:up speed:%s %s-duplex %s%s%s%s%s",
val->port_vlan,
swconfig_speed_str(link.speed),
link.duplex ? "full" : "half",
link.tx_flow ? "txflow " : "",
link.rx_flow ? "rxflow " : "",
+ link.eee & ADVERTISED_100baseT_Full ? "eee100 " : "",
+ link.eee & ADVERTISED_1000baseT_Full ? "eee1000 " : "",
link.aneg ? "auto" : "");
else
len = snprintf(dev->buf, sizeof(dev->buf), "port:%d link:down",
bool tx_flow;
bool rx_flow;
enum switch_port_speed speed;
+ /* in ethtool adv_t format */
+ u32 eee;
};
struct switch_port_stats {