summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrygorii Strashko <grygorii.strashko@ti.com>2019-09-19 11:16:39 +0300
committerTom Rini <trini@konsulko.com>2019-11-03 09:36:06 -0500
commit3c57b620db1764335caaba0367e46b058ff9d724 (patch)
treebf452a9e255885998cc8c769f8cfe8cc8449a0fb
parent4040148b9e932124f843f309d0b344376337311b (diff)
downloadu-boot-3c57b620db1764335caaba0367e46b058ff9d724.tar.gz
u-boot-3c57b620db1764335caaba0367e46b058ff9d724.tar.bz2
u-boot-3c57b620db1764335caaba0367e46b058ff9d724.zip
net: ti: cpsw: add support for standard eth "max-speed" dt property
This patch adds support for standard Ethernet "max-speed" DT property to allow PHY link speed limitation. Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
-rw-r--r--drivers/net/ti/cpsw.c15
-rw-r--r--include/cpsw.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c
index 533c167995..24265360e6 100644
--- a/drivers/net/ti/cpsw.c
+++ b/drivers/net/ti/cpsw.c
@@ -839,6 +839,7 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)
{
struct phy_device *phydev;
u32 supported = PHY_GBIT_FEATURES;
+ int ret;
phydev = phy_connect(priv->bus,
slave->data->phy_addr,
@@ -849,6 +850,13 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)
return -1;
phydev->supported &= supported;
+ if (slave->data->max_speed) {
+ ret = phy_set_supported(phydev, slave->data->max_speed);
+ if (ret)
+ return ret;
+ dev_dbg(priv->dev, "Port %u speed forced to %uMbit\n",
+ slave->slave_num + 1, slave->data->max_speed);
+ }
phydev->advertising = phydev->supported;
#ifdef CONFIG_DM_ETH
@@ -1185,6 +1193,7 @@ static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data,
struct cpsw_slave_data *slave_data;
const void *fdt = gd->fdt_blob;
const char *phy_mode;
+ int max_speed = -1;
u32 phy_id[2];
slave_data = &data->slave_data[slave_index];
@@ -1206,6 +1215,12 @@ static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data,
phy_id, 2);
slave_data->phy_addr = phy_id[1];
}
+
+ slave_data->max_speed = 0;
+ max_speed = fdtdec_get_int(fdt, subnode,
+ "max-speed", max_speed);
+ if (max_speed > 0)
+ slave_data->max_speed = max_speed;
}
static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
diff --git a/include/cpsw.h b/include/cpsw.h
index 96ff254f98..c7532fc866 100644
--- a/include/cpsw.h
+++ b/include/cpsw.h
@@ -39,6 +39,7 @@ struct cpsw_slave_data {
int phy_addr;
int phy_if;
int phy_of_handle;
+ int max_speed;
};
enum {