printf(DRIVERNAME ": MAC %pM\n", m);
}
+static bool smc911x_read_mac_address(struct smc911x_priv *priv)
+{
+ u32 addrh, addrl;
+
+ /* address is obtained from optional eeprom */
+ addrh = smc911x_get_mac_csr(priv, ADDRH);
+ addrl = smc911x_get_mac_csr(priv, ADDRL);
+ if (addrl == 0xffffffff && addrh == 0x0000ffff)
+ return false;
+
+ priv->enetaddr[0] = addrl;
+ priv->enetaddr[1] = addrl >> 8;
+ priv->enetaddr[2] = addrl >> 16;
+ priv->enetaddr[3] = addrl >> 24;
+ priv->enetaddr[4] = addrh;
+ priv->enetaddr[5] = addrh >> 8;
+
+ return true;
+}
+
static int smc911x_eth_phy_read(struct smc911x_priv *priv,
u8 phy, u8 reg, u16 *val)
{
int smc911x_initialize(u8 dev_num, int base_addr)
{
- unsigned long addrl, addrh;
struct smc911x_priv *priv;
int ret;
goto err_detect;
}
- addrh = smc911x_get_mac_csr(priv, ADDRH);
- addrl = smc911x_get_mac_csr(priv, ADDRL);
- if (!(addrl == 0xffffffff && addrh == 0x0000ffff)) {
- /* address is obtained from optional eeprom */
- priv->enetaddr[0] = addrl;
- priv->enetaddr[1] = addrl >> 8;
- priv->enetaddr[2] = addrl >> 16;
- priv->enetaddr[3] = addrl >> 24;
- priv->enetaddr[4] = addrh;
- priv->enetaddr[5] = addrh >> 8;
+ if (smc911x_read_mac_address(priv))
memcpy(priv->dev.enetaddr, priv->enetaddr, 6);
- }
priv->dev.init = smc911x_init;
priv->dev.halt = smc911x_halt;
return ret ? ret : -EAGAIN;
}
+static int smc911x_read_rom_hwaddr(struct udevice *dev)
+{
+ struct smc911x_priv *priv = dev_get_priv(dev);
+ struct eth_pdata *pdata = dev_get_platdata(dev);
+
+ if (!smc911x_read_mac_address(priv))
+ return -ENODEV;
+
+ memcpy(pdata->enetaddr, priv->enetaddr, sizeof(pdata->enetaddr));
+
+ return 0;
+}
+
static int smc911x_bind(struct udevice *dev)
{
return device_set_name(dev, dev->name);
static int smc911x_probe(struct udevice *dev)
{
struct smc911x_priv *priv = dev_get_priv(dev);
- unsigned long addrh, addrl;
int ret;
/* Try to detect chip. Will fail if not present. */
if (ret)
return ret;
- addrh = smc911x_get_mac_csr(priv, ADDRH);
- addrl = smc911x_get_mac_csr(priv, ADDRL);
- if (!(addrl == 0xffffffff && addrh == 0x0000ffff)) {
- /* address is obtained from optional eeprom */
- priv->enetaddr[0] = addrl;
- priv->enetaddr[1] = addrl >> 8;
- priv->enetaddr[2] = addrl >> 16;
- priv->enetaddr[3] = addrl >> 24;
- priv->enetaddr[4] = addrh;
- priv->enetaddr[5] = addrh >> 8;
- }
+ smc911x_read_rom_hwaddr(dev);
return 0;
}
.send = smc911x_send,
.recv = smc911x_recv,
.stop = smc911x_stop,
+ .read_rom_hwaddr = smc911x_read_rom_hwaddr,
};
static const struct udevice_id smc911x_ids[] = {