@@ -1409,6 +1409,43 @@ static struct dm9000_plat_data *dm9000_parse_dt(struct device *dev)
return pdata;
}
+static char *mac_addr = ":";
+module_param(mac_addr, charp, 0);
+MODULE_PARM_DESC(mac_addr, "MAC address");
+
+static void get_mac_addr(struct net_device *ndev, char *macaddr)
+{
+ int i = 0;
+ int j = 0;
+ int got_num = 0;
+ int num = 0;
+
+ while (j < ETH_ALEN) {
+ if (macaddr[i]) {
+ int digit;
+
+ got_num = 1;
+ digit = hex_to_bin(macaddr[i]);
+ if (digit >= 0)
+ num = num * 16 + digit;
+ else if (':' == macaddr[i])
+ got_num = 2;
+ else
+ break;
+ } else if (got_num) {
+ got_num = 2;
+ } else {
+ break;
+ }
+ if (got_num == 2) {
+ ndev->dev_addr[j++] = (u8)num;
+ num = 0;
+ got_num = 0;
+ }
+ i++;
+ }
+}
+
/*
* Search DM9000 board, allocate space and register it
*/
@@ -1679,6 +1716,11 @@ dm9000_probe(struct platform_device *pdev)
ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
}
+ if (!is_valid_ether_addr(ndev->dev_addr)) {
+ mac_src = "param";
+ get_mac_addr(ndev, mac_addr);
+ }
+
if (!is_valid_ether_addr(ndev->dev_addr)) {
inv_mac_addr = true;
eth_hw_addr_random(ndev);
This is needed to give the MIPS Ingenic CI20 board a stable MAC address which can be optionally provided by vendor U-Boot. For get_mac_addr() we use an adapted copy of from ksz884x.c which has very similar functionality. Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com> --- drivers/net/ethernet/davicom/dm9000.c | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)