Newsgroups: comp.os.linux.announce
From: Laurent JULLIARD LAB GND 1267 <laurentj@samsara.grenoble.hp.com>
Subject: ** HP built-in network patch **
Message-ID: <ann-14487.771009514@cs.cornell.edu>
Date: Tue, 7 Jun 1994 17:18:48 GMT
Approved: linux-announce@tc.cornell.edu (Matt Welsh)

Hello,


  Please find below a diff to be applied to the lance.c file. This patch
allows the LANCE driver to recognize the HP built-in network interface. This
interface is based on a 79C960 and is integrated on most recent HP
platforms.

  This patch has also been submitted to comp.os.linux.announce and will 
soon be implemented by Donald Becker in the original lance.c file.

Enjoy !
--------------------------- Cut here ------------------------------------

*** lance.c.orig	Wed May 18 16:13:29 1994
--- lance.c	Tue Jun  7 08:52:05 1994
***************
*** 12,20 ****
  
      The author may be reached as becker@super.org or
      C/O Supercomputing Research Ctr., 17100 Science Dr., Bowie MD 20715
  */
  
! static char *version = "lance.c:v0.14g 12/21/93 becker@super.org\n";
  
  #include <linux/config.h>
  #include <linux/kernel.h>
--- 12,23 ----
  
      The author may be reached as becker@super.org or
      C/O Supercomputing Research Ctr., 17100 Science Dr., Bowie MD 20715
+ 
+     Modified by Laurent JULLIARD (Laurent_Julliard@grenoble.hp.com) to
+     detect built-in lance interface on HP machines
  */
  
! static char *version = "lance.c:v0.14h 07/06/94 becker@super.org\n";
  
  #include <linux/config.h>
  #include <linux/kernel.h>
*************** can be set with the low bits of the othe
*** 84,89 ****
--- 87,95 ----
  The HP-J2405A board is an exception: with this board it's easy to read the
  EEPROM-set values for the base, IRQ, and DMA.  Of course you must already
  _know_ the base address, but that entry is for changing the EEPROM.
+ Some code has been added to distinguish beetween a J2405A and a built-in
+ network interface. (Laurent_Julliard@grenoble.hp.com).
+ 
  
  III. Driver operation
  
*************** unsigned long lance_probe1(short ioaddr,
*** 241,257 ****
      struct device *dev;
      struct lance_private *lp;
      int hpJ2405A = 0;
      int i, reset_val;
  
      hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00
  		&& inb(ioaddr+2) == 0x09);
  
      /* Reset the LANCE.  */
      reset_val = inw(ioaddr+LANCE_RESET); /* Reset the LANCE */
  
      /* The Un-Reset needed is only needed for the real NE2100, and will
         confuse the HP board. */
!     if (!hpJ2405A)
  	outw(reset_val, ioaddr+LANCE_RESET);
  
      outw(0x0000, ioaddr+LANCE_ADDR); /* Switch to window 0 */
--- 247,293 ----
      struct device *dev;
      struct lance_private *lp;
      int hpJ2405A = 0;
+     int hpbuilt_in = 0;
+     int hpaccport;
      int i, reset_val;
  
+ #define HP_SIO_MARKER   0x000F00F1
+ #define HP_ACCESS_PORT  0x98
+ 
+     /* This is to detect HP machine with a built in interface. */
+     if ( *((unsigned short *) 0x000F0102) == 0x5048 ) {
+ 
+         if ( *((unsigned short *) HP_SIO_MARKER) & 1) {
+             hpaccport = HP_ACCESS_PORT + 0x400;
+         } else {
+             hpaccport = HP_ACCESS_PORT;
+         }
+ 
+         if ( (inb(hpaccport) & 0x80) && (inb(hpaccport+1) & 0x80) &&
+              !(inb(hpaccport+1) & 0x40)) {
+ 
+             /* look if the configured ioaddr matches the one given */  
+             short ioaddr_tbl[4] = {0x300, 0x320, 0x340, 0x360};
+             if ( ioaddr_tbl[inb(hpaccport+1) & 0x3] == ioaddr ) {
+                 hpbuilt_in = 1;
+             } else {
+                 return mem_start;
+             }
+         }
+     }
+ 
+     /* this is a poor manner to detect a J2405, but... */
+     if (!hpbuilt_in) {
          hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00
                      && inb(ioaddr+2) == 0x09);
+     }
  
      /* Reset the LANCE.  */
      reset_val = inw(ioaddr+LANCE_RESET); /* Reset the LANCE */
  
      /* The Un-Reset needed is only needed for the real NE2100, and will
         confuse the HP board. */
!     if (!hpJ2405A && !hpbuilt_in)
          outw(reset_val, ioaddr+LANCE_RESET);
  
      outw(0x0000, ioaddr+LANCE_ADDR); /* Switch to window 0 */
*************** unsigned long lance_probe1(short ioaddr,
*** 310,321 ****
--- 346,371 ----
      outw(0x0000, ioaddr+LANCE_ADDR);
  
      if (hpJ2405A) {
+ 
          char dma_tbl[4] = {3, 5, 6, 7};
          char irq_tbl[8] = {3, 4, 5, 9, 10, 11, 12, 15};
          short reset_val = inw(ioaddr+LANCE_RESET);
          dev->dma = dma_tbl[(reset_val >> 2) & 3];
          dev->irq = irq_tbl[(reset_val >> 4) & 7];
          printk(" HP J2405A IRQ %d DMA %d.\n", dev->irq, dev->dma);
+ 
+     } else if (hpbuilt_in) {
+ 
+         char dma_tbl[4] = {3, 5, 6, 0};
+         char irq_tbl[8] = {3, 4, 5, 9};
+         short accport_val = inb(hpaccport+1);
+         dev->dma = dma_tbl[(accport_val >> 4) & 3];
+         dev->irq = irq_tbl[(accport_val >> 2) & 3];
+         printk(" HP built-in AMD 2100 IRQ %d DMA %d.\n", dev->irq, dev->dma);
+         if (dev->dma == 0) {
+             printk("...DREQs and IRQs disabled. Reconfigure the board\n");
+             return mem_start;
+         }
      } else {
      /* The DMA channel may be passed in on this parameter. */
      if (dev->mem_start & 0x07)



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Laurent JULLIARD (Box 26)         | HPDesk: Laurent Julliard /HP6300/UM   ~
~ GND/High Speed Networking Lab     | Unix: Laurent_Julliard@grenoble.hp.com~
~ HEWLETT-PACKARD FRANCE            | Phone:  (33) 76 62 12 67              ~
~ 5, avenue Raymond Chanas - EYBENS | Telnet:        779 12 67              ~
~ 38053 GRENOBLE CEDEX 9            | Fax:    (33) 76 62 12 86              ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--
Mail submissions for comp.os.linux.announce to: linux-announce@tc.cornell.edu
Be sure to include Keywords: and a short description of your software.
