diff mbox

[U-Boot,v2,7/7] net/designware: add support of max-speed device tree property

Message ID 1452693577-25786-8-git-send-email-abrodkin@synopsys.com
State Accepted
Commit 6968ec9
Delegated to: Joe Hershberger
Headers show

Commit Message

Alexey Brodkin Jan. 13, 2016, 1:59 p.m. UTC
This property allows to specify fastest connection mode supported by
the MAC (as opposed to features of the phy).

There are situations when phy may handle faster modes than the
MAC (or even it's particular implementation or even due to CPU being too
slow).

This property is a standard one in Linux kernel these days and some
boards do already use it in their device tree descriptions.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Sonic Zhang <sonic.zhang@analog.com>
cc: Simon Glass <sjg@chromium.org>
---

Changes v1 -> v2:
 No changes, this is just a resent in series with other related patches.

 drivers/net/designware.c | 14 +++++++++++++-
 drivers/net/designware.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

Comments

Joe Hershberger Jan. 27, 2016, 4:11 p.m. UTC | #1
On Wed, Jan 13, 2016 at 7:59 AM, Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
> This property allows to specify fastest connection mode supported by
> the MAC (as opposed to features of the phy).
>
> There are situations when phy may handle faster modes than the
> MAC (or even it's particular implementation or even due to CPU being too
> slow).
>
> This property is a standard one in Linux kernel these days and some
> boards do already use it in their device tree descriptions.
>
> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Sonic Zhang <sonic.zhang@analog.com>
> cc: Simon Glass <sjg@chromium.org>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger Jan. 29, 2016, 9:27 p.m. UTC | #2
Hi Alexey,

https://patchwork.ozlabs.org/patch/566953/ was applied to u-boot-net.git.

Thanks!
-Joe
diff mbox

Patch

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 39c7279..66dc701 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -406,7 +406,7 @@  static int _dw_free_pkt(struct dw_eth_dev *priv)
 static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
 {
 	struct phy_device *phydev;
-	int mask = 0xffffffff;
+	int mask = 0xffffffff, ret;
 
 #ifdef CONFIG_PHY_ADDR
 	mask = 1 << CONFIG_PHY_ADDR;
@@ -419,6 +419,11 @@  static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
 	phy_connect_dev(phydev, dev);
 
 	phydev->supported &= PHY_GBIT_FEATURES;
+	if (priv->max_speed) {
+		ret = phy_set_supported(phydev, priv->max_speed);
+		if (ret)
+			return ret;
+	}
 	phydev->advertising = phydev->supported;
 
 	priv->phydev = phydev;
@@ -601,6 +606,7 @@  static int designware_eth_probe(struct udevice *dev)
 	priv->mac_regs_p = (struct eth_mac_regs *)iobase;
 	priv->dma_regs_p = (struct eth_dma_regs *)(iobase + DW_DMA_BASE_OFFSET);
 	priv->interface = pdata->phy_interface;
+	priv->max_speed = pdata->max_speed;
 
 	dw_mdio_init(dev->name, priv->mac_regs_p);
 	priv->bus = miiphy_get_dev_by_name(dev->name);
@@ -635,6 +641,7 @@  static int designware_eth_ofdata_to_platdata(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	const char *phy_mode;
+	const fdt32_t *cell;
 
 	pdata->iobase = dev_get_addr(dev);
 	pdata->phy_interface = -1;
@@ -646,6 +653,11 @@  static int designware_eth_ofdata_to_platdata(struct udevice *dev)
 		return -EINVAL;
 	}
 
+	pdata->max_speed = 0;
+	cell = fdt_getprop(gd->fdt_blob, dev->of_offset, "max-speed", NULL);
+	if (cell)
+		pdata->max_speed = fdt32_to_cpu(*cell);
+
 	return 0;
 }
 
diff --git a/drivers/net/designware.h b/drivers/net/designware.h
index 4b9ec39..ed6344c 100644
--- a/drivers/net/designware.h
+++ b/drivers/net/designware.h
@@ -223,6 +223,7 @@  struct dw_eth_dev {
 	char rxbuffs[RX_TOTAL_BUFSIZE] __aligned(ARCH_DMA_MINALIGN);
 
 	u32 interface;
+	u32 max_speed;
 	u32 tx_currdescnum;
 	u32 rx_currdescnum;