netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ax88796: add 93cx6 eeprom support
@ 2007-09-27 10:51 Magnus Damm
  2007-09-27 22:04 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Magnus Damm @ 2007-09-27 10:51 UTC (permalink / raw)
  To: netdev; +Cc: Magnus Damm, lethal, jgarzik, akpm, ben-linux

ax88796: add 93cx6 eeprom support

This patch hooks up the 93cx6 eeprom code to the ax88796 driver and modifies
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>
---

 This is a broken out version of the larger patch recently posted to netdev:
 http://www.mail-archive.com/netdev@vger.kernel.org/msg47278.html

 drivers/net/Kconfig          |    7 ++++++
 drivers/net/ax88796.c        |   49 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/eeprom_93cx6.h |    3 +-
 include/net/ax88796.h        |    1 
 4 files changed, 59 insertions(+), 1 deletion(-)

--- 0001/drivers/net/Kconfig
+++ work/drivers/net/Kconfig	2007-09-27 19:32:10.000000000 +0900
@@ -225,6 +225,13 @@ config AX88796
 	  AX88796 driver, using platform bus to provide
 	  chip detection and resources
 
+config AX88796_93CX6
+	bool "ASIX AX88796 external 93CX6 eeprom support"
+	depends on AX88796
+	select EEPROM_93CX6
+	help
+	  Select this if your platform comes with an external 93CX6 eeprom.
+
 config MACE
 	tristate "MACE (Power Mac ethernet) support"
 	depends on PPC_PMAC && PPC32
--- 0001/drivers/net/ax88796.c
+++ work/drivers/net/ax88796.c	2007-09-27 19:17:44.000000000 +0900
@@ -24,6 +24,7 @@
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
 #include <linux/mii.h>
+#include <linux/eeprom_93cx6.h>
 
 #include <net/ax88796.h>
 
@@ -582,6 +583,37 @@ static const struct ethtool_ops ax_ethto
 	.get_link		= ax_get_link,
 };
 
+#ifdef CONFIG_AX88796_93CX6
+static void ax_eeprom_register_read(struct eeprom_93cx6 *eeprom)
+{
+	struct ei_device *ei_local = eeprom->data;
+	u8 reg = ei_inb(ei_local->mem + AX_MEMR);
+
+	eeprom->reg_data_in = reg & AX_MEMR_EEI;
+	eeprom->reg_data_out = reg & AX_MEMR_EEO; /* Input pin */
+	eeprom->reg_data_clock = reg & AX_MEMR_EECLK;
+	eeprom->reg_chip_select = reg & AX_MEMR_EECS;
+}
+
+static void ax_eeprom_register_write(struct eeprom_93cx6 *eeprom)
+{
+	struct ei_device *ei_local = eeprom->data;
+	u8 reg = ei_inb(ei_local->mem + AX_MEMR);
+
+	reg &= ~(AX_MEMR_EEI | AX_MEMR_EECLK | AX_MEMR_EECS);
+
+	if (eeprom->reg_data_in)
+		reg |= AX_MEMR_EEI;
+	if (eeprom->reg_data_clock)
+		reg |= AX_MEMR_EECLK;
+	if (eeprom->reg_chip_select)
+		reg |= AX_MEMR_EECS;
+
+	ei_outb(reg, ei_local->mem + AX_MEMR);
+	udelay(10);
+}
+#endif
+
 /* setup code */
 
 static 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
 		memcpy(dev->dev_addr,  SA_prom, 6);
 	}
 
+#ifdef CONFIG_AX88796_93CX6
+	if (first_init && ax->plat->flags & AXFLG_HAS_93CX6) {
+		unsigned char mac_addr[6];
+		struct eeprom_93cx6 eeprom;
+
+		eeprom.data = ei_local;
+		eeprom.register_read = ax_eeprom_register_read;
+		eeprom.register_write = ax_eeprom_register_write;
+		eeprom.width = PCI_EEPROM_WIDTH_93C56;
+
+		eeprom_93cx6_multiread(&eeprom, 0,
+				       (__le16 __force *)mac_addr,
+				       sizeof(mac_addr) >> 1);
+
+		memcpy(dev->dev_addr,  mac_addr, 6);
+	}
+#endif
 	if (ax->plat->wordlength == 2) {
 		/* We must set the 8390 for word mode. */
 		ei_outb(ax->plat->dcr_val, ei_local->mem + EN0_DCFG);
--- 0001/include/linux/eeprom_93cx6.h
+++ work/include/linux/eeprom_93cx6.h	2007-09-27 19:17:44.000000000 +0900
@@ -21,13 +21,14 @@
 /*
 	Module: eeprom_93cx6
 	Abstract: EEPROM reader datastructures for 93cx6 chipsets.
-	Supported chipsets: 93c46 & 93c66.
+	Supported chipsets: 93c46, 93c56 and 93c66.
  */
 
 /*
  * EEPROM operation defines.
  */
 #define PCI_EEPROM_WIDTH_93C46	6
+#define PCI_EEPROM_WIDTH_93C56	8
 #define PCI_EEPROM_WIDTH_93C66	8
 #define PCI_EEPROM_WIDTH_OPCODE	3
 #define PCI_EEPROM_WRITE_OPCODE	0x05
--- 0001/include/net/ax88796.h
+++ work/include/net/ax88796.h	2007-09-27 19:17:44.000000000 +0900
@@ -14,6 +14,7 @@
 
 #define AXFLG_HAS_EEPROM		(1<<0)
 #define AXFLG_MAC_FROMDEV		(1<<1)	/* device already has MAC */
+#define AXFLG_HAS_93CX6			(1<<2)	/* use eeprom_93cx6 driver */
 
 struct ax_plat_data {
 	unsigned int	 flags;

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

* Re: ax88796: add 93cx6 eeprom support
  2007-09-27 10:51 ax88796: add 93cx6 eeprom support Magnus Damm
@ 2007-09-27 22:04 ` Andrew Morton
  2007-09-28  8:29   ` Magnus Damm
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2007-09-27 22:04 UTC (permalink / raw)
  To: Magnus Damm
  Cc: netdev, magnus.damm, lethal, jgarzik, ben-linux, Francois Romieu

On Thu, 27 Sep 2007 19:51:19 +0900
Magnus Damm <magnus.damm@gmail.com> wrote:

> ax88796: add 93cx6 eeprom support
> 
> This patch hooks up the 93cx6 eeprom code to the ax88796 driver and modifies
> 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.

I'm showing a minor reject between this and Francois's git-r8169.patch.

***************
*** 21,33 ****
  /*
  	Module: eeprom_93cx6
  	Abstract: EEPROM reader datastructures for 93cx6 chipsets.
- 	Supported chipsets: 93c46 & 93c66.
   */
  
  /*
   * EEPROM operation defines.
   */
  #define PCI_EEPROM_WIDTH_93C46	6
  #define PCI_EEPROM_WIDTH_93C66	8
  #define PCI_EEPROM_WIDTH_OPCODE	3
  #define PCI_EEPROM_WRITE_OPCODE	0x05
--- 21,34 ----
  /*
  	Module: eeprom_93cx6
  	Abstract: EEPROM reader datastructures for 93cx6 chipsets.
+ 	Supported chipsets: 93c46/93c56/93c66.
   */
  
  /*
   * EEPROM operation defines.
   */
  #define PCI_EEPROM_WIDTH_93C46	6
+ #define PCI_EEPROM_WIDTH_93C56	8
  #define PCI_EEPROM_WIDTH_93C66	8
  #define PCI_EEPROM_WIDTH_OPCODE	3
  #define PCI_EEPROM_WRITE_OPCODE	0x05


You both made the same change to eeprom_93cx6.h.  That all sounds good but
it would be comforting if you could review each other's work, please...


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

* Re: ax88796: add 93cx6 eeprom support
  2007-09-27 22:04 ` Andrew Morton
@ 2007-09-28  8:29   ` Magnus Damm
  0 siblings, 0 replies; 3+ messages in thread
From: Magnus Damm @ 2007-09-28  8:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: netdev, lethal, jgarzik, ben-linux, Francois Romieu

Hi Andrew,

Thanks for picking up the patch.

On 9/28/07, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Thu, 27 Sep 2007 19:51:19 +0900
> Magnus Damm <magnus.damm@gmail.com> wrote:
>
> > ax88796: add 93cx6 eeprom support
> >
> > This patch hooks up the 93cx6 eeprom code to the ax88796 driver and modifies
> > 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.
>
> I'm showing a minor reject between this and Francois's git-r8169.patch.

[snip]
Oh, sorry about that. I should have built the patch on top of -mm instead.

> You both made the same change to eeprom_93cx6.h.  That all sounds good but
> it would be comforting if you could review each other's work, please...

I thought I was more or less the only user, but thanks for pointing that out.

The eeprom code in the r8169 driver from
2.6.23-rc8-mm2/git-r8169.patch looks fine, but I don't understand the
point of adding the size member to the eeprom struct in
eeprom_93cx6.h. Especially since no code change is made in
eeprom_93cx6.c.

Thanks,

/ magnus

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

end of thread, other threads:[~2007-09-28  8:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-27 10:51 ax88796: add 93cx6 eeprom support Magnus Damm
2007-09-27 22:04 ` Andrew Morton
2007-09-28  8:29   ` Magnus Damm

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).