netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sky2: Add module parameter for passing the MAC address
@ 2015-08-05 15:50 Liviu Dudau
  2015-08-05 16:40 ` Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Liviu Dudau @ 2015-08-05 15:50 UTC (permalink / raw)
  To: Mirko Lindner, Stephen Hemminger; +Cc: Ryan Harkin, netdev, lkml

For designs where EEPROMs are not connected to PCI Yukon2
chips we need to get the MAC address from the firmware.
Add a module parameter called 'mac_address' for this. It
will be used if no DT node can be found and the B2_MAC
register holds an invalid value.

Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
---
 drivers/net/ethernet/marvell/sky2.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index d9f4498..a977d95 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -101,6 +101,10 @@ static int legacy_pme = 0;
 module_param(legacy_pme, int, 0);
 MODULE_PARM_DESC(legacy_pme, "Legacy power management");
 
+/* Ugh!  Let the firmware tell us the hardware address */
+static int mac_address[ETH_ALEN] = { 0, };
+module_param_array(mac_address, int, NULL, 0);
+
 static const struct pci_device_id sky2_id_table[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
 	{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
@@ -4811,13 +4815,21 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port,
 	/* try to get mac address in the following order:
 	 * 1) from device tree data
 	 * 2) from internal registers set by bootloader
+	 * 3) from the command line parameter
 	 */
 	iap = of_get_mac_address(hw->pdev->dev.of_node);
 	if (iap)
 		memcpy(dev->dev_addr, iap, ETH_ALEN);
-	else
+	else {
 		memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8,
 			      ETH_ALEN);
+		if (!is_valid_ether_addr(&dev->dev_addr[0])) {
+			int i;
+
+			for (i = 0; i < ETH_ALEN; i++)
+				dev->dev_addr[i] = mac_address[i];
+		}
+	}
 
 	return dev;
 }
-- 
2.4.6

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-08-12 16:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05 15:50 [PATCH] sky2: Add module parameter for passing the MAC address Liviu Dudau
2015-08-05 16:40 ` Stephen Hemminger
2015-08-05 17:16   ` Liviu Dudau
2015-08-05 20:33     ` Francois Romieu
2015-08-05 23:16       ` Stephen Hemminger
2015-08-06  0:33         ` Florian Fainelli
2015-08-11 14:35           ` [PATCH v2 net-next] sky2: use random address if EEPROM is bad Liviu Dudau
2015-08-11 17:01             ` Stephen Hemminger
2015-08-12  9:30               ` Liviu Dudau
2015-08-12 15:28                 ` Stephen Hemminger
2015-08-12 16:00                   ` Liviu Dudau
2015-08-11 18:56             ` Sergei Shtylyov
2015-08-12  9:15               ` Liviu Dudau
     [not found] ` <CAD0U-h+Lbz+bygVCaF1Ji0VPLfh9sn504rCeGigXLER+H=KnZg@mail.gmail.com>
2015-08-05 17:18   ` [PATCH] sky2: Add module parameter for passing the MAC address Liviu Dudau
2015-08-06  0:32 ` David Miller
2015-08-06 10:31   ` Liviu Dudau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).