aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ipq806x/patches-4.1/709-stmac-platform-add-support-for-retreiving-mac-from-m.patch
blob: 84c15c75668539367b57121ed31c4b605ba5966a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 5bf2dabde1fa3af0c9082b42b6847ef3fd198b13 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Sun, 9 Aug 2015 12:53:55 +0200
Subject: [PATCH] stmac: platform: add support for retreiving mac from mtd

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -302,6 +302,7 @@ static int stmmac_pltfr_probe(struct pla
 	struct stmmac_priv *priv = NULL;
 	struct plat_stmmacenet_data *plat_dat = NULL;
 	const char *mac = NULL;
+	u8 mtd_mac[ETH_ALEN] = { };
 	int irq, wol_irq, lpi_irq;
 
 	/* Get IRQ information early to have an ability to ask for deferred
@@ -362,6 +363,15 @@ static int stmmac_pltfr_probe(struct pla
 			pr_err("%s: main dt probe failed", __func__);
 			return ret;
 		}
+
+		if (!mac) {
+			ret = of_get_mac_address_mtd(dev->of_node, &mtd_mac);
+			if (ret == -EPROBE_DEFER)
+				return ret;
+
+			if (is_valid_ether_addr(&mtd_mac))
+				mac = mtd_mac;
+		}
 	}
 
 	/* Custom setup (if needed) */