From: Davide Rizzo <elpa.rizzo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
petkan-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH] Pegasus: Add MAC programmability
Date: Thu, 13 Aug 2009 12:10:26 +0200 [thread overview]
Message-ID: <8447d6730908130310n27f94e9agdfaf688c50fa90b@mail.gmail.com> (raw)
Added capability to set mac address and to program it into EEPROM
Signed-off-by: Davide Rizzo <elpa.rizzo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
diff -urNp linux-2.6.30.4/drivers/net/usb/pegasus.c
linux-2.6.30.4.elpa/drivers/net/usb/pegasus.c
--- linux-2.6.30.4/drivers/net/usb/pegasus.c 2009-08-13 07:14:57.000000000 +0200
+++ linux-2.6.30.4.elpa/drivers/net/usb/pegasus.c 2009-08-13
08:39:01.000000000 +0200
@@ -469,8 +467,49 @@ fail:
dev_warn(&pegasus->intf->dev, "%s failed\n", __func__);
return -ETIMEDOUT;
}
+
+/* Got from adm 8515 starter kit */
+static const __u16 def_eeprom[] = {
+ 0x8515, 0x0170, 0x0082, 0x0409, 0x0000,
+ 0x07a6, 0x8515, 0x100e, 0x202a, 0x380a, 0x0000, 0x0000, 0x0000,
+ 0x030e, 0x0041, 0x0044, 0x004d, 0x0074, 0x0065, 0x006b, 0x0000,
+ 0x001e, 0x0055, 0x0053, 0x0042, 0x0020, 0x0031, 0x0030, 0x002f,
+ 0x032a, 0x0055, 0x0053, 0x0042, 0x0020, 0x0054, 0x006f, 0x0020,
+ 0x004c, 0x0041, 0x004e, 0x0020, 0x0043, 0x006f, 0x006e, 0x0076,
+ 0x0065, 0x0072, 0x0074, 0x0065, 0x0072, 0x0000, 0x0000, 0x0000,
+ 0x030a, 0x0030, 0x0030, 0x0030, 0x0031, 0x0000, 0x0000, 0x0000,
+};
#endif /* PEGASUS_WRITE_EEPROM */
+static int pegasus_set_mac_address(struct net_device *netdev, void *p)
+{
+ struct sockaddr *addr = p;
+ pegasus_t *pegasus = (pegasus_t *) netdev_priv(netdev);
+ int i;
+
+ if (netif_running(netdev))
+ return -EBUSY;
+ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+ dbg("%s: Setting MAC address to ", netdev->name);
+ for (i = 0; i < 5; i++)
+ dbg("%02X:", netdev->dev_addr[i]);
+ dbg("%02X\n", netdev->dev_addr[i]);
+ /* Set the IDR registers. */
+ set_registers(pegasus, EthID, 6, netdev->dev_addr);
+#ifdef PEGASUS_WRITE_EEPROM
+ write_eprom_word(pegasus, 0,
+ (netdev->dev_addr[1] << 8) + netdev->dev_addr[0]);
+ write_eprom_word(pegasus, 1,
+ (netdev->dev_addr[3] << 8) + netdev->dev_addr[2]);
+ write_eprom_word(pegasus, 2,
+ (netdev->dev_addr[5] << 8) + netdev->dev_addr[4]);
+ for (i = 0; i < ARRAY_SIZE(def_eeprom); i++)
+ write_eprom_word(pegasus, i + 3, def_eeprom[i]);
+
+#endif /* PEGASUS_WRITE_EEPROM */
+ return 0;
+}
+
static inline void get_node_id(pegasus_t * pegasus, __u8 * id)
{
int i;
@@ -1492,6 +1531,7 @@ static const struct net_device_ops pegas
.ndo_start_xmit = pegasus_start_xmit,
.ndo_set_multicast_list = pegasus_set_multicast,
.ndo_get_stats = pegasus_netdev_stats,
+ .ndo_set_mac_address = pegasus_set_mac_address,
.ndo_tx_timeout = pegasus_tx_timeout,
.ndo_change_mtu = eth_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2009-08-13 10:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-13 10:10 Davide Rizzo [this message]
2009-08-14 17:21 ` [PATCH] Pegasus: Add MAC programmability petkan
[not found] ` <e75fcab5ff0b69446555a633bdb1907d.squirrel-nPnTwAqkgEqakBO8gow8eQ@public.gmane.org>
2009-08-15 6:18 ` Davide Rizzo
2009-08-16 12:04 ` Petko Manolov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8447d6730908130310n27f94e9agdfaf688c50fa90b@mail.gmail.com \
--to=elpa.rizzo-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=petkan-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox