Commit 29a6b6c0 authored by Raffaele Recalcati's avatar Raffaele Recalcati Committed by David S. Miller

net/ethernet: ks8851_mll mac address configuration support added

Signed-off-by: default avatarRaffaele Recalcati <raffaele.recalcati@bticino.it>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d594e987
......@@ -35,7 +35,7 @@
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <asm/io.h>
#include <linux/ks8851_mll.h>
#define DRV_NAME "ks8851_mll"
......@@ -1515,6 +1515,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
struct net_device *netdev;
struct ks_net *ks;
u16 id, data;
struct ks8851_mll_platform_data *pdata;
io_d = platform_get_resource(pdev, IORESOURCE_MEM, 0);
io_c = platform_get_resource(pdev, IORESOURCE_MEM, 1);
......@@ -1596,17 +1597,27 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
ks_disable_qmu(ks);
ks_setup(ks);
ks_setup_int(ks);
memcpy(netdev->dev_addr, ks->mac_addr, 6);
data = ks_rdreg16(ks, KS_OBCR);
ks_wrreg16(ks, KS_OBCR, data | OBCR_ODS_16MA);
/**
* If you want to use the default MAC addr,
* comment out the 2 functions below.
*/
/* overwriting the default MAC address */
pdata = pdev->dev.platform_data;
if (!pdata) {
netdev_err(netdev, "No platform data\n");
err = -ENODEV;
goto err_register;
}
memcpy(ks->mac_addr, pdata->mac_addr, 6);
if (!is_valid_ether_addr(ks->mac_addr)) {
/* Use random MAC address if none passed */
random_ether_addr(ks->mac_addr);
netdev_info(netdev, "Using random mac address\n");
}
netdev_info(netdev, "Mac address is: %pM\n", ks->mac_addr);
memcpy(netdev->dev_addr, ks->mac_addr, 6);
random_ether_addr(netdev->dev_addr);
ks_set_mac(ks, netdev->dev_addr);
id = ks_rdreg16(ks, KS_CIDER);
......
/*
* ks8861_mll platform data struct definition
* Copyright (c) 2012 BTicino S.p.A.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _LINUX_KS8851_MLL_H
#define _LINUX_KS8851_MLL_H
#include <linux/if_ether.h>
/**
* struct ks8851_mll_platform_data - Platform data of the KS8851_MLL network driver
* @macaddr: The MAC address of the device, set to all 0:s to use the on in
* the chip.
*/
struct ks8851_mll_platform_data {
u8 mac_addr[ETH_ALEN];
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment