aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ax88796.c
diff options
context:
space:
mode:
authorMagnus Damm <magnus.damm@gmail.com>2007-09-29 01:42:16 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:53:56 -0400
commit89e536a190f90d038bae7905a0c582cb7089b739 (patch)
tree3d9f7dc5c750c8adcadf568e98f12395bd7c5b68 /drivers/net/ax88796.c
parent6daf65310374d24d888201b7a6eba90b44008b7b (diff)
ax88796: add 93cx6 eeprom support
Hook up the 93cx6 eeprom code to the ax88796 driver and modify the ax88796 driver to read out the mac address from the eeprom. We need this for the ax88796 on certain SuperH boards. The pin configuration used to connect the eeprom to the ax88796 on these boards is the same as pointed out by the ax88796 datasheet, so we can probably reuse this code for multiple platforms in the future. Signed-off-by: Magnus Damm <damm@igel.co.jp> Cc: Ben Dooks <ben-linux@fluff.org> Cc: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/ax88796.c')
-rw-r--r--drivers/net/ax88796.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index 90e0734e6037..9fe0517cf893 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -24,6 +24,7 @@
24#include <linux/etherdevice.h> 24#include <linux/etherdevice.h>
25#include <linux/ethtool.h> 25#include <linux/ethtool.h>
26#include <linux/mii.h> 26#include <linux/mii.h>
27#include <linux/eeprom_93cx6.h>
27 28
28#include <net/ax88796.h> 29#include <net/ax88796.h>
29 30
@@ -582,6 +583,37 @@ static const struct ethtool_ops ax_ethtool_ops = {
582 .get_link = ax_get_link, 583 .get_link = ax_get_link,
583}; 584};
584 585
586#ifdef CONFIG_AX88796_93CX6
587static void ax_eeprom_register_read(struct eeprom_93cx6 *eeprom)
588{
589 struct ei_device *ei_local = eeprom->data;
590 u8 reg = ei_inb(ei_local->mem + AX_MEMR);
591
592 eeprom->reg_data_in = reg & AX_MEMR_EEI;
593 eeprom->reg_data_out = reg & AX_MEMR_EEO; /* Input pin */
594 eeprom->reg_data_clock = reg & AX_MEMR_EECLK;
595 eeprom->reg_chip_select = reg & AX_MEMR_EECS;
596}
597
598static void ax_eeprom_register_write(struct eeprom_93cx6 *eeprom)
599{
600 struct ei_device *ei_local = eeprom->data;
601 u8 reg = ei_inb(ei_local->mem + AX_MEMR);
602
603 reg &= ~(AX_MEMR_EEI | AX_MEMR_EECLK | AX_MEMR_EECS);
604
605 if (eeprom->reg_data_in)
606 reg |= AX_MEMR_EEI;
607 if (eeprom->reg_data_clock)
608 reg |= AX_MEMR_EECLK;
609 if (eeprom->reg_chip_select)
610 reg |= AX_MEMR_EECS;
611
612 ei_outb(reg, ei_local->mem + AX_MEMR);
613 udelay(10);
614}
615#endif
616
585/* setup code */ 617/* setup code */
586 618
587static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local) 619static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local)
@@ -640,6 +672,23 @@ static int ax_init_dev(struct net_device *dev, int first_init)
640 memcpy(dev->dev_addr, SA_prom, 6); 672 memcpy(dev->dev_addr, SA_prom, 6);
641 } 673 }
642 674
675#ifdef CONFIG_AX88796_93CX6
676 if (first_init && ax->plat->flags & AXFLG_HAS_93CX6) {
677 unsigned char mac_addr[6];
678 struct eeprom_93cx6 eeprom;
679
680 eeprom.data = ei_local;
681 eeprom.register_read = ax_eeprom_register_read;
682 eeprom.register_write = ax_eeprom_register_write;
683 eeprom.width = PCI_EEPROM_WIDTH_93C56;
684
685 eeprom_93cx6_multiread(&eeprom, 0,
686 (__le16 __force *)mac_addr,
687 sizeof(mac_addr) >> 1);
688
689 memcpy(dev->dev_addr, mac_addr, 6);
690 }
691#endif
643 if (ax->plat->wordlength == 2) { 692 if (ax->plat->wordlength == 2) {
644 /* We must set the 8390 for word mode. */ 693 /* We must set the 8390 for word mode. */
645 ei_outb(ax->plat->dcr_val, ei_local->mem + EN0_DCFG); 694 ei_outb(ax->plat->dcr_val, ei_local->mem + EN0_DCFG);