[U-Boot] [PATCH 04/11] net: sunxi-emac: Add read_rom_hwaddr net_op hook

Olliver Schinagl oliver at schinagl.nl
Tue Nov 8 16:54:30 CET 2016


Add the read_rom_hwaddr net_op hook so that it can be called from boards
to read the mac from a ROM chip.

Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
---
 drivers/net/sunxi_emac.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
index dcf832e..6a6611e 100644
--- a/drivers/net/sunxi_emac.c
+++ b/drivers/net/sunxi_emac.c
@@ -562,6 +562,23 @@ static int sunxi_emac_eth_write_hwaddr(struct udevice *dev)
 	return _sunxi_write_hwaddr(priv, pdata->enetaddr);
 }
 
+__weak int sunxi_board_read_rom_hwaddr(unsigned char *enetaddr)
+{
+	return -ENOSYS;
+}
+
+static int sunxi_emac_eth_read_rom_hwaddr(struct udevice *dev)
+{
+	int retval;
+	struct eth_pdata *pdata = dev_get_platdata(dev);
+
+	retval = sunxi_board_read_rom_hwaddr(pdata->enetaddr);
+	if (retval == -ENOSYS)
+		return 0;
+
+	return retval;
+}
+
 static int sunxi_emac_eth_probe(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
@@ -579,6 +596,7 @@ static const struct eth_ops sunxi_emac_eth_ops = {
 	.recv			= sunxi_emac_eth_recv,
 	.stop			= sunxi_emac_eth_stop,
 	.write_hwaddr		= sunxi_emac_eth_write_hwaddr,
+	.read_rom_hwaddr	= sunxi_emac_eth_read_rom_hwaddr,
 };
 
 static int sunxi_emac_eth_ofdata_to_platdata(struct udevice *dev)
-- 
2.10.2



More information about the U-Boot mailing list