Subject: Re: Existing PRs
To: None <port-arm32@netbsd.org>
From: Mike Pumford <mpumford@black-star.demon.co.uk>
List: port-arm32
Date: 03/29/2001 21:19:56
This is a multipart MIME message.
--==_Exmh_-19677519560
Content-Type: text/plain; charset=us-ascii
> Actually the patch needs updating before it can be applied to current. I have
> done the mods necessary and the updated patch is attached.
>
Actually it wasn't but here it is.
Mike
--==_Exmh_-19677519560
Content-Type: application/x-patch ; name="if_ne_pbus-current.patch"
Content-Description: if_ne_pbus-current.patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="if_ne_pbus-current.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.4
diff -c -r1.1.1.4 if_ne_pbus.c
*** if_ne_pbus.c 2001/03/03 19:42:59 1.1.1.4
--- if_ne_pbus.c 2001/03/04 18:32:21
***************
*** 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 ----
***************
*** 80,86 ****
#include <arch/arm32/podulebus/podulebus.h>
#include <arch/arm32/podulebus/podules.h>
#include <arch/arm32/podulebus/if_ne_pbusreg.h>
! =
/*
* ne_pbus_softc: ne2000_softc plus podule, interrupt and bs tag info
*/
--- 78,84 ----
#include <arch/arm32/podulebus/podulebus.h>
#include <arch/arm32/podulebus/podules.h>
#include <arch/arm32/podulebus/if_ne_pbusreg.h>
! /*#define EH500 */
/*
* ne_pbus_softc: ne2000_softc plus podule, interrupt and bs tag info
*/
***************
*** 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,130 ----
*/
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 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 *));
+ =
+ #ifdef EH500
+ static void eh500_preattach __P((struct ne_pbus_softc *sc));
+ #endif
+ =
/*
* 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));
--- 139,153 ----
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,171 ****
__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
},
};
=
/*
* Determine if the device is present.
*/
--- 155,289 ----
__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 *));
} 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
+ },
+ #ifdef EH500
+ /* ICubed EtherLan500 EtherH interface */
+ {
+ MANUFACTURER_ICUBED, PODULE_ICUBED_ETHERLAN500, EH500_REGSHIF=
T,
+ EH500_NIC_OFFSET, EH500_NIC_SIZE, EH500_ASIC_OFFSET, EH500_AS=
IC_SIZE,
+ EH500_CONTROL_OFFSET, EH500_CONTROL_SIZE, NE_SPACE_MOD,
+ NE_SPACE_MOD, NE_SPACE_FAST, 0,
+ "EtherLan 500", em_ea , eh500_preattach, NULL, =
+ NULL,NULL,NULL,NULL
+ },
+ /* Acorn EtherLan500 EtherH interface */
+ {
+ MANUFACTURER_ICUBED, PODULE_ICUBED_ETHERLAN500AEH, EH500_REGS=
HIFT,
+ EH500_NIC_OFFSET, EH500_NIC_SIZE, EH500_ASIC_OFFSET, EH500_AS=
IC_SIZE,
+ EH500_CONTROL_OFFSET, EH500_CONTROL_SIZE, NE_SPACE_MOD,
+ NE_SPACE_MOD, NE_SPACE_FAST, 0, =
+ "EtherLan 500A", em_ea , eh500_preattach, NULL, =
+ NULL,NULL,NULL,NULL
+ },
+ #endif
};
=
+ =
+ #ifdef EH500
+ bs_rm_2_proto(eh500);
+ bs_wm_2_proto(eh500);
+ bs_w_2_proto(eh500);
+ =
+ void eh500_bs_w_2(void *t, bus_space_handle_t handle,
+ bus_size_t offset, u_int16_t data)
+ {
+ u_int32_t *addr =3D (u_int32_t *)handle;
+ if (offset =3D=3D NE2000_ASIC_DATA) {
+ offset =3D EH500_ASIC_DATA;
+ }
+ addr +=3D offset;
+ *addr =3D ((u_int32_t)data) << 16;
+ }
+ =
+ void eh500_bs_wm_2(void *t, bus_space_handle_t handle,
+ bus_size_t offset,const u_int16_t *datap, bus_size_t=
count)
+ {
+ u_int32_t *addr =3D (u_int32_t *)handle;
+ if (offset =3D=3D NE2000_ASIC_DATA) {
+ offset =3D EH500_ASIC_DATA;
+ }
+ addr +=3D offset;
+ count >>=3D 1;
+ while (count-- > 0) {
+ u_int32_t tmp =3D *datap++;
+ tmp <<=3D 16;
+ *addr =3D tmp;
+ }
+ }
+ =
+ void eh500_bs_rm_2(void *t, bus_space_handle_t handle,
+ bus_size_t offset, u_int16_t *datap, bus_size_t coun=
t)
+ {
+ u_int32_t *addr =3D (u_int32_t *)handle;
+ if (offset =3D=3D NE2000_ASIC_DATA) {
+ offset =3D EH500_ASIC_DATA;
+ }
+ addr +=3D offset;
+ count >>=3D 1;
+ while (count-- > 0) {
+ *datap++ =3D *addr & 0xffff;
+ }
+ }
+ #endif
+ =
+ =
/*
* Determine if the device is present.
*/
***************
*** 200,210 ****
--- 318,332 ----
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 ****
--- 354,362 ----
=
/* 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 ****
--- 366,374 ----
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 ****
--- 378,396 ----
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
--- 422,439 ----
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,304 ****
--- 448,462 ----
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;
+ dsc->sc_media_init =3D ne->init_media;
+ /* ne->init_media(dsc,&media,&nmedia,&defmedia); */
+ }
+ =
/*
* Do generic NE2000 attach. This will read the station address
* from the EEPROM.
***************
*** 310,320 ****
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);
}
=
/*
--- 468,484 ----
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.
--- 545,786 ----
printf("\n");
}
=
+ =
+ #ifdef EH500
+ /*
+ * eh500_preattach =
+ *
+ * Setup bus space write 2 wrappers for eh500 which remap writes to the=
+ * to the data port. This is a bit of a kack but will do to get things
+ * going. At some point the MI NE2K driver needs to be modded to suppor=
t
+ * moving data ports.
+ *
+ */
+ static void
+ eh500_preattach(sc)
+ struct ne_pbus_softc *sc;
+ {
+ /* struct ne2000_softc *nsc =3D &sc->sc_ne2000; */
+ /* use modified bus space multi write routines. */
+ sc->sc_tag.bs_w_2 =3D eh500_bs_w_2;
+ sc->sc_tag.bs_rm_2 =3D eh500_bs_rm_2;
+ sc->sc_tag.bs_wm_2 =3D eh500_bs_wm_2;
+ /* Set the card type to avoid the MI NE2000 probe. */
+ /* nsc->sc_type =3D NE2000_TYPE_NE2000; */
+ }
+ #endif
+ =
+ =
+ =
/*
* 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)
+ struct dp8390_softc *sc;
+ {
+ static int eh600_media[] =3D {
+ IFM_ETHER|IFM_AUTO,
+ IFM_ETHER|IFM_10_T,
+ IFM_ETHER|IFM_10_2,
+ };
+ int i, defmedia =3D IFM_ETHER|IFM_AUTO;
+ static const int eh600_nmedia =3D
+ sizeof(eh600_media) / sizeof(eh600_media[0]);
+ =
+ printf("%s: 10base2, 10baseT, auto, default auto\n",
+ sc->sc_dev.dv_xname);
+ =
+ ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus)=
;
+ for (i =3D 0; i < eh600_nmedia; i++)
+ ifmedia_add(&sc->sc_media, eh600_media[i], 0, NULL);
+ ifmedia_set(&sc->sc_media, defmedia);
+ =
+ }
+ =
+ =
+ =
+ =
+ 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)
+ struct dp8390_softc *sc;
+ {
+ static int en_media[] =3D {
+ IFM_ETHER|IFM_10_T
+ };
+ printf("%s: 10baseT, default 10baseT\n",
+ sc->sc_dev.dv_xname);
+ =
+ ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus)=
;
+ ifmedia_add(&sc->sc_media, en_media[0], 0, NULL);
+ ifmedia_set(&sc->sc_media, en_media[0]);
+ }
+ =
+ =
+ =
+ =
+ 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/02/08 23:40:04
***************
*** 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,104 ----
#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 500 definitions */
+ #define EH500_CONTROL_OFFSET 0x0800 =
+ #define EH500_CONTROL_SIZE (1 << EH500_REGSHIFT)
+ #define EH500_NIC_OFFSET 0x0000
+ #define EH500_NIC_SIZE (NE2000_NIC_NPORTS << EH500_REGSHIFT)
+ #define EH500_ASIC_OFFSET 0x800
+ /* reading 0x800 + (ASIC_RESET << EH500_REGSHIFT) hangs */
+ #define EH500_ASIC_SIZE (NE2000_ASIC_NPORTS << EH500_REGSHIFT)
+ #define EH500_REGSHIFT 2
+ #define EH500_ASIC_DATA 0x200
+ =
+ =
+ /* 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_-19677519560--