#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#include <linux/pm_runtime.h>
-
+#include <linux/soc/rockchip/rk_vendor_storage.h>
#include "stmmac_platform.h"
struct rk_priv_data;
dev_err(dev, "unsupported interface %d", bsp_priv->phy_iface);
}
+void rk_get_eth_addr_vendor(void *priv, unsigned char *addr)
+{
+ int ret;
+ struct rk_priv_data *bsp_priv = priv;
+ struct device *dev = &bsp_priv->pdev->dev;
+
+ ret = rk_vendor_read(LAN_MAC_ID, addr, 6);
+ if (ret != 6 || is_zero_ether_addr(addr)) {
+ dev_err(dev, "%s: rk_vendor_read eth mac address failed (%d)",
+ __func__, ret);
+ random_ether_addr(addr);
+ dev_err(dev, "%s: generate random eth mac address: %02x:%02x:%02x:%02x:%02x:%02x",
+ __func__, addr[0], addr[1], addr[2],
+ addr[3], addr[4], addr[5]);
+ ret = rk_vendor_write(LAN_MAC_ID, addr, 6);
+ if (ret != 0)
+ dev_err(dev, "%s: rk_vendor_write eth mac address failed (%d)",
+ __func__, ret);
+ } else {
+ dev_err(dev, "%s: rk_vendor_read eth mac address: %02x:%02x:%02x:%02x:%02x:%02x",
+ __func__, addr[0], addr[1], addr[2],
+ addr[3], addr[4], addr[5]);
+ }
+}
+
static int rk_gmac_probe(struct platform_device *pdev)
{
struct plat_stmmacenet_data *plat_dat;
plat_dat->init = rk_gmac_init;
plat_dat->exit = rk_gmac_exit;
plat_dat->fix_mac_speed = rk_fix_speed;
+ plat_dat->get_eth_addr = rk_get_eth_addr_vendor;
plat_dat->bsp_priv = rk_gmac_setup(pdev, data);
if (IS_ERR(plat_dat->bsp_priv))
if (!is_valid_ether_addr(priv->dev->dev_addr)) {
priv->hw->mac->get_umac_addr(priv->hw,
priv->dev->dev_addr, 0);
+ if (likely(priv->plat->get_eth_addr))
+ priv->plat->get_eth_addr(priv->plat->bsp_priv,
+ priv->dev->dev_addr);
if (!is_valid_ether_addr(priv->dev->dev_addr))
eth_hw_addr_random(priv->dev);
pr_info("%s: device MAC address %pM\n", priv->dev->name,