Subject: Re: EtherH (was Re: Packages and things)
To: Chris Gilbert <chris@paradox.demon.co.uk>
From: Mike Pumford <mpumford@black-star.demon.co.uk>
List: port-arm32
Date: 02/03/2001 21:34:15
This is a multipart MIME message.

--==_Exmh_-3926837680
Content-Type: text/plain; charset=us-ascii

> On Friday 02 February 2001 10:03 pm, Chris Cowdery wrote:
> > And has Mike Pumfords Etherh stuff gone in yet?, i.e. will it
> > 'just work' or do you need to run RiscOS first?
> 
> A quick rummage around shows there's an outstanding patch in the PR system, 
> try grabbing the patch from:
> http://www.NetBSD.org/cgi-bin/query-pr-single.pl?number=8765
> 
That patch is more than a little out of date though. You might like to give 
this one a try. It has all the features from PR8795 as well as support for 
enabling the card without help from RISC OS. It also makes full use of the 
extra buffer memory provided by the EtherH.


Mike

--==_Exmh_-3926837680
Content-Type: text/plain ; name="ne_pbus.patch"; charset=us-ascii
Content-Description: ne_pbus.patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="ne_pbus.patch"

Index: if_ne_pbus.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /overflow/cvsrep/netbsd/sys/arch/arm32/podulebus/if_ne_pbus.c,v=

retrieving revision 1.1.1.3
diff -c -r1.1.1.3 if_ne_pbus.c
*** if_ne_pbus.c	2001/01/10 00:10:17	1.1.1.3
--- if_ne_pbus.c	2001/01/25 23:11:09
***************
*** 8,13 ****
--- 8,14 ----
   * by Mark Brinicombe of Causality Limited.
   *
   * EtherH code Copyright (c) 1998 Mike Pumford
+  * EtherN/EtherI code Copyright (c) 1999 Mike Pumford
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
***************
*** 43,60 ****
   *
   * Currently supports:
   *	ANT EtherM network slot cards
!  *	ICubed EtherH network slot cards
!  */
! =

! /* =

!  * TO DO List for this driver.
   *
!  * EtherH - The driver currently relies on some part if the RISCOS driv=
er =

!  * initialisation code to work correctly. This dependancy needs to be
!  * removed.
   *
!  * Needs to be converted to use media a'la if_ne_pci.c, not the home-gr=
own
!  * hack it currently uses.
   */
  =

  #include <sys/param.h>
--- 44,59 ----
   *
   * Currently supports:
   *	ANT EtherM network slot cards
!  *	ICubed Etherlan 600 (EtherH) network slot cards
!  *      Irlam EtherN podules
!  *      Acorn EtherI podules (identical hardware to EtherN)
!  *
!  * Thanks go to Stephen Borrill for providing the EtherN card
!  * and information to program it.
   *
!  * TO DO List for this Driver.
   *
!  * EtherM - Needs proper media support.
   */
  =

  #include <sys/param.h>
***************
*** 71,77 ****
  #include <machine/bus.h>
  #include <machine/irqhandler.h>
  #include <machine/io.h>
- =

  #include <dev/ic/dp8390reg.h>
  #include <dev/ic/dp8390var.h>
  #include <dev/ic/ne2000reg.h>
--- 70,75 ----
***************
*** 89,99 ****
  	int			sc_podule_number;
  	podule_t		*sc_podule;
  	struct bus_space	sc_tag;			/* Patched tag */
! 	void			*sc_ih;			/* Interrupt handler */
! 	int			sc_mediatype;		/* Media Info */
! #define NE_MEDIA_AUTO		0 =

! #define	NE_MEDIA_10BASET	1
! #define NE_MEDIA_10BASE2	2
  };
  =

  /*
--- 87,95 ----
  	int			sc_podule_number;
  	podule_t		*sc_podule;
  	struct bus_space	sc_tag;			/* Patched tag */
! 	bus_space_handle_t      sc_extrah;            /* Bus handle for any
! 							 * extra registers */
! 	irqhandler_t		sc_ih;			/* Interrupt handler */
  };
  =

  /*
***************
*** 111,120 ****
   */
  static u_int8_t *em_ea		__P((struct ne_pbus_softc *sc, u_int8_t *buffer=
));
  static void em_postattach	__P((struct ne_pbus_softc *sc));
- static void eh600_preattach	__P((struct ne_pbus_softc *sc));
  static void eh600_postattach	__P((struct ne_pbus_softc *sc));
  static u_int8_t *eh600_ea	__P((struct ne_pbus_softc *sc, u_int8_t *buff=
er));
  =

  /*
   * Define a structure to hold all the information required on an NE2000=

   * clone interface.
--- 107,126 ----
   */
  static u_int8_t *em_ea		__P((struct ne_pbus_softc *sc, u_int8_t *buffer=
));
  static void em_postattach	__P((struct ne_pbus_softc *sc));
  static void eh600_postattach	__P((struct ne_pbus_softc *sc));
+ static void eh600_preattach	__P((struct ne_pbus_softc *sc));
  static u_int8_t *eh600_ea	__P((struct ne_pbus_softc *sc, u_int8_t *buff=
er));
  =

+ int	eh600_mediachange       __P((struct dp8390_softc *));
+ void	eh600_mediastatus       __P((struct dp8390_softc *, struct ifmedia=
req *));
+ void	eh600_init_card         __P((struct dp8390_softc *));
+ void	eh600_init_media        __P((struct dp8390_softc *, int **, int *,=
 int *));
+ =

+ int	en_mediachange          __P((struct dp8390_softc *));
+ void	en_mediastatus          __P((struct dp8390_softc *, struct ifmedia=
req *));
+ void	en_init_card            __P((struct dp8390_softc *));
+ void	en_init_media           __P((struct dp8390_softc *, int **, int *,=
 int *));
+ =

  /*
   * Define a structure to hold all the information required on an NE2000=

   * clone interface.
***************
*** 129,140 ****
  	unsigned int	nicsize;	/* size of NIC (regs) */
  	unsigned int	asicbase;	/* byte offset of ASIC */
  	unsigned int	asicsize;	/* size of ASIC (regs) */
! 	unsigned char	nicspace;	/* fast or mod space ? */
! 	unsigned char	asicspace;	/* fast or mod space ? */
  #define NE_SPACE_FAST		0
  #define NE_SPACE_MOD		1
  	unsigned char	reserved0;	/* not used (padding) */
- 	unsigned char	reserved1;	/* not used (padding) */
  	const char	*name;		/* name */
  	u_int8_t *	(*getea)	/* do this to get the MAC */
  			    __P((struct ne_pbus_softc *sc, u_int8_t *buffer));
--- 135,149 ----
  	unsigned int	nicsize;	/* size of NIC (regs) */
  	unsigned int	asicbase;	/* byte offset of ASIC */
  	unsigned int	asicsize;	/* size of ASIC (regs) */
! 	unsigned int    extrabase;      /* extra registers byte offset */
! 	unsigned int    extrasize;      /* size of extra registers(regs) */
! 	unsigned char	nicspace;	/* easi,fast or mod space ? */
! 	unsigned char	asicspace;	/* easi,fast or mod space ? */
! 	unsigned char   extraspace;     /* easi,fast or mod space ? */
  #define NE_SPACE_FAST		0
  #define NE_SPACE_MOD		1
+ #define NE_SPACE_EASI           2
  	unsigned char	reserved0;	/* not used (padding) */
  	const char	*name;		/* name */
  	u_int8_t *	(*getea)	/* do this to get the MAC */
  			    __P((struct ne_pbus_softc *sc, u_int8_t *buffer));
***************
*** 142,168 ****
  			    __P((struct ne_pbus_softc *sc));
  	void		(*postattach)	/* do this after attach */
  			    __P((struct ne_pbus_softc *sc));
  } ne_clones[] =3D {
  	/* ANT EtherM netslot interface */
  	{
  	  MANUFACTURER_ANT, PODULE_ANT_ETHERM, EM_REGSHIFT,
  	  EM_NIC_OFFSET, EM_NIC_SIZE, EM_ASIC_OFFSET, EM_ASIC_SIZE,
! 	  NE_SPACE_FAST, NE_SPACE_FAST, 0, 0,
! 	  "EtherM", em_ea, NULL, em_postattach
  	},
  	/* ICubed EtherLan EtherH netslot interface */
  	{
  	  MANUFACTURER_ICUBED, PODULE_ICUBED_ETHERLAN600, EH600_REGSHIFT,
  	  EH600_NIC_OFFSET, EH600_NIC_SIZE, EH600_ASIC_OFFSET, EH600_ASIC_SIZE=
,
! 	  NE_SPACE_FAST, NE_SPACE_FAST, 0, 0,
! 	  "EtherLan 600", eh600_ea, eh600_preattach, eh600_postattach
  	},
  	/* Acorn EtherLan EtherH netslot interface */
  	{
  	  MANUFACTURER_ICUBED, PODULE_ICUBED_ETHERLAN600AEH, EH600_REGSHIFT,
  	  EH600_NIC_OFFSET, EH600_NIC_SIZE, EH600_ASIC_OFFSET, EH600_ASIC_SIZE=
,
! 	  NE_SPACE_FAST, NE_SPACE_FAST, 0, 0,
! 	  "EtherLan 600A", eh600_ea , eh600_preattach, eh600_postattach
  	},
  };
  =

--- 151,213 ----
  			    __P((struct ne_pbus_softc *sc));
  	void		(*postattach)	/* do this after attach */
  			    __P((struct ne_pbus_softc *sc));
+         int          	(*mediachange)  /* media change */
+                             __P((struct dp8390_softc *));
+         void          	(*mediastatus)  /* media status */
+                             __P((struct dp8390_softc *, struct ifmediar=
eq *));
+         void          	(*init_card)    /* media init card */
+                             __P((struct dp8390_softc *));
+         void          	(*init_media)   /* media init */
+                             __P((struct dp8390_softc *, int **, int *, =
int *));
  } ne_clones[] =3D {
  	/* ANT EtherM netslot interface */
  	{
  	  MANUFACTURER_ANT, PODULE_ANT_ETHERM, EM_REGSHIFT,
  	  EM_NIC_OFFSET, EM_NIC_SIZE, EM_ASIC_OFFSET, EM_ASIC_SIZE,
! 	  0,0, NE_SPACE_FAST,
! 	  NE_SPACE_FAST, NE_SPACE_FAST, 0,
! 	  "EtherM", em_ea, NULL, em_postattach,
! 	  NULL,NULL,NULL,NULL
  	},
  	/* ICubed EtherLan EtherH netslot interface */
  	{
  	  MANUFACTURER_ICUBED, PODULE_ICUBED_ETHERLAN600, EH600_REGSHIFT,
  	  EH600_NIC_OFFSET, EH600_NIC_SIZE, EH600_ASIC_OFFSET, EH600_ASIC_SIZE=
,
! 	  EH600_CONTROL_OFFSET, EH600_CONTROL_SIZE, NE_SPACE_FAST,
! 	  NE_SPACE_FAST, NE_SPACE_FAST, 0,
! 	  "EtherLan 600", eh600_ea, eh600_preattach, eh600_postattach,
! 	  eh600_mediachange, eh600_mediastatus, eh600_init_card,
! 	  eh600_init_media
  	},
  	/* Acorn EtherLan EtherH netslot interface */
  	{
  	  MANUFACTURER_ICUBED, PODULE_ICUBED_ETHERLAN600AEH, EH600_REGSHIFT,
  	  EH600_NIC_OFFSET, EH600_NIC_SIZE, EH600_ASIC_OFFSET, EH600_ASIC_SIZE=
,
! 	  EH600_CONTROL_OFFSET, EH600_CONTROL_SIZE, NE_SPACE_FAST,
! 	  NE_SPACE_FAST, NE_SPACE_FAST, 0,
! 	  "EtherLan 600A", eh600_ea , eh600_preattach, eh600_postattach,
! 	  eh600_mediachange, eh600_mediastatus, eh600_init_card,
! 	  eh600_init_media
! 	},
! 	/* Irlam EtherN podule. (supplied with NC) */
! 	{
! 	  MANUFACTURER_IRLAM ,PODULE_IRLAM_ETHERN ,EN_REGSHIFT,
! 	  EN_NIC_OFFSET, EN_NIC_SIZE, EN_ASIC_OFFSET, EN_ASIC_SIZE,
! 	  0,0, NE_SPACE_EASI,
! 	  NE_SPACE_EASI, NE_SPACE_EASI, 0,
! 	  "EtherN", em_ea, NULL ,NULL,
! 	  en_mediachange, en_mediastatus, en_init_card,
! 	  en_init_media
! 	},
! 	/* Acorn EtherI podule. (supplied with NC) */
! 	{
! 	  MANUFACTURER_ACORN ,PODULE_ACORN_ETHERI ,EN_REGSHIFT,
! 	  EN_NIC_OFFSET, EN_NIC_SIZE, EN_ASIC_OFFSET, EN_ASIC_SIZE,
! 	  0,0, NE_SPACE_EASI,
! 	  NE_SPACE_EASI, NE_SPACE_EASI, 0,
! 	  "EtherI", em_ea, NULL ,NULL,
! 	  en_mediachange, en_mediastatus, en_init_card,
! 	  en_init_media
  	},
  };
  =

***************
*** 200,210 ****
--- 245,259 ----
  	struct ne_pbus_softc *npsc =3D (void *)self;
  	struct ne2000_softc *nsc =3D &npsc->sc_ne2000;
  	struct dp8390_softc *dsc =3D &nsc->sc_dp8390;
+ =

+  	int *media, nmedia, defmedia;
  	struct ne_clone *ne =3D NULL;
  	u_int8_t buffer[6];
  	u_int8_t *myea;
  	int loop;
  =

+ 	media =3D NULL;
+ 	nmedia =3D defmedia =3D 0;
  	/* Check a few things about the attach args */
  =

  	if (pa->pa_podule_number =3D=3D -1)
***************
*** 232,237 ****
--- 281,289 ----
  =

  	/* Update the nic and asic base addresses appropriately */
  	switch (ne->nicspace) {
+ 	case NE_SPACE_EASI:
+ 		ne->nicbase +=3D npsc->sc_podule->easi_base;
+ 		break;
  	case NE_SPACE_MOD:
  		ne->nicbase +=3D npsc->sc_podule->mod_base;
  		break;
***************
*** 241,246 ****
--- 293,301 ----
  		break;
  	}
  	switch (ne->asicspace) {
+ 	case NE_SPACE_EASI:
+ 		ne->asicbase +=3D npsc->sc_podule->easi_base;
+ 		break;
  	case NE_SPACE_MOD:
  		ne->asicbase +=3D npsc->sc_podule->mod_base;
  		break;
***************
*** 250,255 ****
--- 305,323 ----
  		break;
  	}
  =

+ 	switch (ne->extraspace) {
+ 	case NE_SPACE_EASI:
+ 		ne->extrabase +=3D npsc->sc_podule->easi_base;
+ 		break;
+ 	case NE_SPACE_MOD:
+ 		ne->extrabase +=3D npsc->sc_podule->mod_base;
+ 		break;
+ 	case NE_SPACE_FAST:
+ 	default:
+ 		ne->extrabase +=3D npsc->sc_podule->fast_base;
+ 		break;
+ 	}
+ =

  	/* Report the interface name */
  	printf(" %s ethernet\n", ne->name);
  =

***************
*** 281,290 ****
  		printf("%s: cannot map i/o space\n", dsc->sc_dev.dv_xname);
  		return;
  	}
  =

  	/* This interface is always enabled. */
  	dsc->sc_enabled =3D 1;
- 	npsc->sc_mediatype =3D NE_MEDIA_AUTO;	/* Default */
  =

  	/*
  	 * Now get the ethernet address in an interface specific manner if
--- 349,366 ----
  		printf("%s: cannot map i/o space\n", dsc->sc_dev.dv_xname);
  		return;
  	}
+ 	/* Map any extra register space required by the card */
+ 	if (ne->extrasize > 0) {
+ 		if (bus_space_map(&npsc->sc_tag, ne->extrabase, ne->extrasize,
+ 				  0, &npsc->sc_extrah)) {
+ 			printf("%s: cannot map extra space\n",
+ 			       dsc->sc_dev.dv_xname);
+ 			return;
+ 		}
+ 	}
  =

  	/* This interface is always enabled. */
  	dsc->sc_enabled =3D 1;
  =

  	/*
  	 * Now get the ethernet address in an interface specific manner if
***************
*** 299,320 ****
  	if (ne->preattach)
  		ne->preattach(npsc);
  =

  	/*
  	 * Do generic NE2000 attach.  This will read the station address
  	 * from the EEPROM.
  	 */
! 	ne2000_attach(nsc, myea, NULL, 0, 0);
  =

  	/* Does the interface need a postattach call ? */
  	if (ne->postattach)
  		ne->postattach(npsc);
  =

  	/* Install an interrupt handler */
! 	npsc->sc_ih =3D intr_claim(npsc->sc_podule->interrupt, IPL_NET,
! 	    "if_ne", dp8390_intr, dsc);
! 	if (npsc->sc_ih =3D=3D NULL)
  		panic("%s: Cannot install interrupt handler",
  		   dsc->sc_dev.dv_xname);
  }
  =

  /*
--- 375,410 ----
  	if (ne->preattach)
  		ne->preattach(npsc);
  =

+ 	/* if the interface has media support initialise it */
+ 	if (ne->init_media) {
+ 		dsc->sc_mediachange =3D ne->mediachange;
+ 		dsc->sc_mediastatus =3D ne->mediastatus;
+ 		dsc->init_card =3D ne->init_card;
+ 		ne->init_media(dsc,&media,&nmedia,&defmedia);
+ 	}
+ =

  	/*
  	 * Do generic NE2000 attach.  This will read the station address
  	 * from the EEPROM.
  	 */
! 	ne2000_attach(nsc, myea, media, nmedia, defmedia);
  =

  	/* Does the interface need a postattach call ? */
  	if (ne->postattach)
  		ne->postattach(npsc);
  =

  	/* Install an interrupt handler */
! 	npsc->sc_ih.ih_func =3D dp8390_intr;
! 	npsc->sc_ih.ih_arg =3D dsc;
! 	npsc->sc_ih.ih_level =3D IPL_NET;
! 	npsc->sc_ih.ih_name =3D "if_ne";
! 	npsc->sc_ih.ih_maskaddr =3D npsc->sc_podule->irq_addr;
! 	npsc->sc_ih.ih_maskbits =3D npsc->sc_podule->irq_mask;
! =

! 	if (irq_claim(npsc->sc_podule->interrupt,&(npsc->sc_ih)) < 0) {
  		panic("%s: Cannot install interrupt handler",
  		   dsc->sc_dev.dv_xname);
+ 	}
  }
  =

  /*
***************
*** 381,430 ****
  	printf("\n");
  }
  =

  /*
   * eh600_preattach()
   *
!  * Detect whether the BNC or UTP media attachment is being used.
   */
  static void
  eh600_preattach(sc)
  	struct ne_pbus_softc *sc;
  {
! 	u_int8_t tmp;
! 	bus_space_tag_t nict =3D sc->sc_ne2000.sc_dp8390.sc_regt;
! 	bus_space_handle_t nich =3D sc->sc_ne2000.sc_dp8390.sc_regh;
! =

! 	/* now try and detect a UTP connection */
! 	tmp =3D bus_space_read_1(nict, nich, EH600_MCRB);
! 	tmp =3D (tmp & 0xf8) | EH600_10BTSEL;
! 	bus_space_write_1(nict, nich, EH600_MCRB, tmp);
! 	tmp =3D bus_space_read_1(nict, nich, EH600_MCRB);
! 	if ((tmp & 0x04) =3D=3D 0x04)
! 		/* UTP link detected */
! 		sc->sc_mediatype =3D NE_MEDIA_10BASET;
! 	else {
! 		/* No UTP use BNC */
! 		tmp =3D (tmp & 0xf8) | EH600_10B2SEL;
! 		bus_space_write_1(nict, nich, EH600_MCRB, tmp);
! 		sc->sc_mediatype =3D NE_MEDIA_10BASE2;
! 	}
  }
  =

  /*
!  * eh600_postattach()
   *
!  * Report the media connection detected in the preattach routine
   */
  static void
  eh600_postattach(sc)
  	struct ne_pbus_softc *sc;
  {
! 	printf("%s: using ", sc->sc_ne2000.sc_dp8390.sc_dev.dv_xname);
! 	if (sc->sc_mediatype =3D=3D NE_MEDIA_10BASET)
! 		printf("10BaseT/UTP\n");
! 	else
! 		printf("10Base2/BNC\n");
  }
  =

  /* =

   * extracts the station address from the Podule description string.
--- 471,685 ----
  	printf("\n");
  }
  =

+ =

+ =

+ =

+ =

  /*
   * eh600_preattach()
   *
!  * pre-initialise the AT/Lantic chipset so that the card probes and =

!  * detects properly. =

   */
  static void
  eh600_preattach(sc)
  	struct ne_pbus_softc *sc;
  {
! 	u_char tmp;
! 	struct ne2000_softc *nsc =3D &sc->sc_ne2000;
! 	struct dp8390_softc *dsc =3D &nsc->sc_dp8390;
! 	bus_space_tag_t nict =3D dsc->sc_regt;
! 	bus_space_handle_t nich =3D dsc->sc_regh;
! 	=

! 	/* initialise EH600 config register */
! 	bus_space_read_1(nict, nich, EH600_MCRA);
! 	bus_space_write_1(nict,nich,EH600_MCRA,0x18);
! =

! 	/* enable interrupts for the card */
! 	tmp =3D bus_space_read_1(&sc->sc_tag,sc->sc_extrah,0); =

! 	tmp |=3D EH_INTR_MASK;
! 	bus_space_write_1(&sc->sc_tag,sc->sc_extrah,0,tmp); =

  }
  =

  /*
!  * eh600_posttach()
   *
!  * Etherlan 600 has 32k of buffer memory as it runs the AT/Lantic =

!  * DP8390 clone in IO non-compatible mode. We need to adjust the memory=
 =

!  * description set up by dp8390.c and ne2000.c to reflect this.
   */
  static void
  eh600_postattach(sc)
  	struct ne_pbus_softc *sc;
  {
! 	struct ne2000_softc *nsc =3D &sc->sc_ne2000;
! 	struct dp8390_softc *dsc =3D &nsc->sc_dp8390;
! 	/* first page is mapped to the PROM. so start at 2nd page */
! 	dsc->mem_start =3D EH600_MEM_START;
! 	dsc->mem_size =3D EH600_MEM_END - EH600_MEM_START;
! 	dsc->mem_end =3D EH600_MEM_END;
! 	dsc->txb_cnt =3D 3; /* >16k of ram setup 3 tx buffers */
! 	/* recompute the mem ring (taken straight from the ne2000 init code) *=
/
! 	dsc->mem_ring =3D =

! 		dsc->mem_start + =

! 		(((dsc->txb_cnt + 1) * ED_TXBUF_SIZE ) <<
! 		 ED_PAGE_SHIFT);
! =

! 	/* recompute the dp8390 register values. (from dp8390 init code) */
! 	dsc->tx_page_start =3D dsc->mem_start >> ED_PAGE_SHIFT;
! =

! 	dsc->rec_page_start =3D dsc->tx_page_start + =

! 		(dsc->txb_cnt + 1) * ED_TXBUF_SIZE;
! =

! 	dsc->rec_page_stop =3D dsc->tx_page_start + =

! 		(dsc->mem_size >> ED_PAGE_SHIFT);
! 	printf("%s: 32KB buffer memory\n", dsc->sc_dev.dv_xname);
! =

  }
+ /*
+  * EtherLan 600 media.
+  */
+ void eh600_init_media(sc, mediap,nmediap, defmediap)
+ 	struct dp8390_softc *sc;
+ 	int **mediap, *nmediap, *defmediap;
+ {
+ 	static int eh600_media[] =3D {
+ 		IFM_ETHER|IFM_AUTO,
+ 		IFM_ETHER|IFM_10_T,
+ 		IFM_ETHER|IFM_10_2,
+ 	};
+ 	printf("%s: 10base2, 10baseT, auto, default auto\n",
+ 	    sc->sc_dev.dv_xname);
+ =

+ 	*mediap =3D eh600_media;
+ 	*nmediap =3D sizeof(eh600_media) / sizeof(eh600_media[0]);
+ 	*defmediap =3D IFM_ETHER|IFM_AUTO;
+ }
+ =

+ =

+ =

+ =

+ void eh600_init_card(sc)
+      struct dp8390_softc *sc;
+ {
+ 	struct ifmedia *ifm =3D &sc->sc_media;
+ 	bus_space_tag_t nict =3D sc->sc_regt;
+ 	bus_space_handle_t nich =3D sc->sc_regh;
+ 	u_int8_t reg;
+ =

+ =

+ 	/* Set basic media type. */
+ 	switch (IFM_SUBTYPE(ifm->ifm_cur->ifm_media)) {
+ 	case IFM_AUTO:
+ 		/* software auto detect the media */
+ 		reg =3D bus_space_read_1(nict, nich, EH600_MCRB);
+ 		reg =3D (reg & 0xf8) | EH600_10BTSEL;
+ 		bus_space_write_1(nict, nich, EH600_MCRB, reg);
+ 		reg =3D bus_space_read_1(nict, nich, EH600_MCRB);
+ 		if ((reg & 0x04) !=3D 0x04) {
+ 			/* No UTP use BNC */
+ 			reg =3D (reg & 0xf8) | EH600_10B2SEL;
+ 			bus_space_write_1(nict, nich, EH600_MCRB, reg);
+ 		} =

+ =

+ 		break;
+ =

+ 	case IFM_10_T:
+ 		reg =3D bus_space_read_1(nict, nich, EH600_MCRB);
+ 		reg =3D (reg & 0xf8) | EH600_10BTSEL;
+ 		bus_space_write_1(nict, nich, EH600_MCRB, reg);
+ 		/* seems that re-reading config B here is required to =

+ 	         * prevent the interface hanging when manually selecting.
+ 		 */
+ 		bus_space_read_1(nict, nich, EH600_MCRB);
+ 		break;
+ =

+ 	case IFM_10_2:
+ 		reg =3D bus_space_read_1(nict, nich, EH600_MCRB);
+ 		reg =3D (reg & 0xf8) | EH600_10B2SEL;
+ 		bus_space_write_1(nict, nich, EH600_MCRB,reg);
+ 		/* seems that re-reading config B here is required to =

+ 	         * prevent the interface hanging when manually selecting.
+ 		 */
+ 		bus_space_read_1(nict, nich, EH600_MCRB);
+ 		break;
+ 	}
+ }
+ =

+ int
+ eh600_mediachange(dsc)
+ 	struct dp8390_softc *dsc;
+ {
+ 	/* media is already set up. Interface reset will invoke new
+ 	 * new media setting. */
+ 	dp8390_reset(dsc);
+ 	return (0);
+ }
+ =

+ =

+ void
+ eh600_mediastatus(sc, ifmr)
+ 	struct dp8390_softc *sc;
+ 	struct ifmediareq *ifmr;
+ {
+ 	bus_space_tag_t nict =3D sc->sc_regt;
+ 	bus_space_handle_t nich =3D sc->sc_regh;
+ 	u_int8_t reg;
+ 	reg =3D bus_space_read_1(nict, nich, EH600_MCRB);
+ 	if ((reg & 0x3) =3D=3D 1) {
+ 		ifmr->ifm_active =3D IFM_ETHER|IFM_10_2;
+ 	}
+ 	else {
+ 		ifmr->ifm_active =3D IFM_ETHER|IFM_10_T;
+ 	}
+ }
+ =

+ =

+ /*
+  * EtherN media.
+  */
+ void
+ en_init_media(sc, mediap,nmediap, defmediap)
+ 	struct dp8390_softc *sc;
+ 	int **mediap, *nmediap, *defmediap;
+ {
+ 	static int en_media[] =3D {
+ 		IFM_ETHER|IFM_10_T
+ 	};
+ 	printf("%s: 10baseT, default 10baseT\n",
+ 	    sc->sc_dev.dv_xname);
+ =

+ 	*mediap =3D en_media;
+ 	*nmediap =3D sizeof(en_media) / sizeof(en_media[0]);
+ 	*defmediap =3D IFM_ETHER|IFM_10_T;
+ }
+ =

+ =

+ =

+ =

+ void
+ en_init_card(sc)
+      struct dp8390_softc *sc;
+ {
+ }
+ =

+ int
+ en_mediachange(dsc)
+ 	struct dp8390_softc *dsc;
+ {
+ 	/* media is static so any change is invalid. */
+ 	return (EINVAL);
+ }
+ =

+ =

+ void
+ en_mediastatus(sc, ifmr)
+ 	struct dp8390_softc *sc;
+ 	struct ifmediareq *ifmr;
+ {
+ 	ifmr->ifm_active =3D IFM_ETHER|IFM_10_T;
+ }
+ =

  =

  /* =

   * extracts the station address from the Podule description string.
Index: if_ne_pbusreg.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /overflow/cvsrep/netbsd/sys/arch/arm32/podulebus/if_ne_pbusreg.=
h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 if_ne_pbusreg.h
*** if_ne_pbusreg.h	1998/03/22 22:35:51	1.1.1.1
--- if_ne_pbusreg.h	2001/01/25 20:56:10
***************
*** 60,65 ****
--- 60,67 ----
  #define EM_DSR_UTP	(1 << 7) /* Twisted pair selected */
  =

  /* EtherLan 600 definitions */
+ #define EH600_CONTROL_OFFSET    0x0a00
+ #define EH600_CONTROL_SIZE      (1 << EH600_REGSHIFT)
  #define EH600_NIC_OFFSET	0x0800
  #define EH600_NIC_SIZE		(NE2000_NIC_NPORTS << EH600_REGSHIFT)
  #define EH600_ASIC_OFFSET	(EH600_NIC_OFFSET + (NE2000_ASIC_OFFSET \
***************
*** 71,73 ****
--- 73,92 ----
  #define EH600_MCRB		0x0b	/* master control reg B */
  #define EH600_10BTSEL		0	/* 10BaseT interface */
  #define EH600_10B2SEL		1	/* 10Base2 interface */
+ #define EH600_MEM_START         0x100   /* buffer ram start */
+ #define EH600_MEM_END           0x8000  /* buffer ram end */
+ =

+ /* Acorn EtherN registers */
+ #define EN_REGSHIFT             3
+ #define EN_NIC_OFFSET           0x400000
+ #define EN_NIC_SIZE             (NE2000_NIC_NPORTS << EN_REGSHIFT)
+ #define EN_ASIC_OFFSET	        (EN_NIC_OFFSET + (NE2000_ASIC_OFFSET \
+ 				    << EN_REGSHIFT))
+ #define EN_ASIC_SIZE		(NE2000_ASIC_NPORTS << EN_REGSHIFT)
+ =

+ /* Etherlan 600 control register */
+ /*Write only */
+ #define EH_INTR_MASK    (1 << 0)        /* Interrupt Mask.             =
 */
+ #define EH_ID_CONTROL   (1 << 1)        /* ID control.                 =
 */
+ /* Read only */
+ #define EH_INTR_STAT    (1 << 0)        /* Interrupt status.           =
 */

--==_Exmh_-3926837680--