On 27-11-16 18:02, Simon Glass wrote:
Hi,

On 25 November 2016 at 08:38, Olliver Schinagl <[email protected]> wrote:
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 <[email protected]>
---
  drivers/net/designware.c | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 9e6d726..3f2f67c 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -230,6 +230,21 @@ static int _dw_write_hwaddr(struct dw_eth_dev *priv, u8 
*mac_id)
         return 0;
  }

+__weak int dw_board_read_rom_hwaddr(unsigned char *enetaddr, int id)
+{
+       return -ENOSYS;
+}
+
+static int designware_eth_read_rom_hwaddr(struct udevice *dev)
+{
+       struct eth_pdata *pdata = dev_get_platdata(dev);
+
+       if (!dev)
+               return -ENOSYS;
+
+       return dw_board_read_rom_hwaddr(pdata->enetaddr, dev->seq);
+}
+
  static void dw_adjust_link(struct eth_mac_regs *mac_p,
                            struct phy_device *phydev)
  {
@@ -685,6 +700,7 @@ static const struct eth_ops designware_eth_ops = {
         .free_pkt               = designware_eth_free_pkt,
         .stop                   = designware_eth_stop,
         .write_hwaddr           = designware_eth_write_hwaddr,
+       .read_rom_hwaddr        = designware_eth_read_rom_hwaddr,
  };

  static int designware_eth_ofdata_to_platdata(struct udevice *dev)
You should not call board code from a driver. But since this is a
sunxi driver, why not move all the code that reads the serial number
into this file?
Hey Simon,

unless I missunderstand, this is how Joe suggested in a while ago, and how it has been implemented in a few other drivers. Can you elaborate a bit more?

Olliver

Regards,
Simon


_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to