2008-01-19 18:56:52 +03:00
|
|
|
/* $NetBSD: if_gem_pci.c,v 1.26 2008/01/19 15:56:52 aymeric Exp $ */
|
2001-09-16 04:11:41 +04:00
|
|
|
|
|
|
|
/*
|
2004-10-18 01:49:08 +04:00
|
|
|
*
|
2001-09-16 04:11:41 +04:00
|
|
|
* Copyright (C) 2001 Eduardo Horvath.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2004-10-18 01:49:08 +04:00
|
|
|
*
|
2001-09-16 04:11:41 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2008-01-05 23:30:22 +03:00
|
|
|
* PCI bindings for Apple GMAC, Sun ERI and Sun GEM Ethernet controllers
|
2001-09-16 04:11:41 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-13 10:48:40 +03:00
|
|
|
#include <sys/cdefs.h>
|
2008-01-19 18:56:52 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: if_gem_pci.c,v 1.26 2008/01/19 15:56:52 aymeric Exp $");
|
2001-11-13 10:48:40 +03:00
|
|
|
|
2001-09-16 04:11:41 +04:00
|
|
|
#include <sys/param.h>
|
2004-10-18 01:49:08 +04:00
|
|
|
#include <sys/systm.h>
|
2001-09-16 04:11:41 +04:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <machine/endian.h>
|
|
|
|
|
|
|
|
#include <uvm/uvm_extern.h>
|
2004-10-18 01:49:08 +04:00
|
|
|
|
2001-09-16 04:11:41 +04:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
#include <net/if_ether.h>
|
|
|
|
|
2004-10-18 01:49:08 +04:00
|
|
|
#if NBPFILTER > 0
|
2001-09-16 04:11:41 +04:00
|
|
|
#include <net/bpf.h>
|
2004-10-18 01:49:08 +04:00
|
|
|
#endif
|
2001-09-16 04:11:41 +04:00
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/intr.h>
|
2001-09-16 04:11:41 +04:00
|
|
|
|
|
|
|
#include <dev/mii/mii.h>
|
|
|
|
#include <dev/mii/miivar.h>
|
|
|
|
#include <dev/mii/mii_bitbang.h>
|
|
|
|
|
|
|
|
#include <dev/ic/gemreg.h>
|
|
|
|
#include <dev/ic/gemvar.h>
|
|
|
|
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcidevs.h>
|
|
|
|
|
2001-10-18 07:55:07 +04:00
|
|
|
/* XXX Should use Properties when that's fleshed out. */
|
|
|
|
#ifdef macppc
|
|
|
|
#include <dev/ofw/openfirm.h>
|
|
|
|
#endif /* macppc */
|
2004-03-17 16:54:09 +03:00
|
|
|
#ifdef __sparc__
|
|
|
|
#include <machine/promlib.h>
|
|
|
|
#endif
|
2001-10-18 07:55:07 +04:00
|
|
|
|
2008-01-05 23:30:22 +03:00
|
|
|
#ifndef GEM_USE_LOCAL_MAC_ADDRESS
|
|
|
|
#if defined (macppc) || defined (__sparc__)
|
|
|
|
#define GEM_USE_LOCAL_MAC_ADDRESS 0 /* use system-wide address */
|
|
|
|
#else
|
|
|
|
#define GEM_USE_LOCAL_MAC_ADDRESS 1
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-09-16 04:11:41 +04:00
|
|
|
struct gem_pci_softc {
|
|
|
|
struct gem_softc gsc_gem; /* GEM device */
|
|
|
|
void *gsc_ih;
|
|
|
|
};
|
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
int gem_match_pci(struct device *, struct cfdata *, void *);
|
|
|
|
void gem_attach_pci(struct device *, struct device *, void *);
|
2001-09-16 04:11:41 +04:00
|
|
|
|
2002-10-01 00:37:04 +04:00
|
|
|
CFATTACH_DECL(gem_pci, sizeof(struct gem_pci_softc),
|
2002-10-02 20:51:16 +04:00
|
|
|
gem_match_pci, gem_attach_pci, NULL, NULL);
|
2001-09-16 04:11:41 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Attach routines need to be split out to different bus-specific files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
gem_match_pci(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
|
2004-10-18 01:49:08 +04:00
|
|
|
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SUN &&
|
2002-05-21 23:58:24 +04:00
|
|
|
(PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_ERINETWORK ||
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_GEMNETWORK))
|
2001-09-16 04:11:41 +04:00
|
|
|
return (1);
|
|
|
|
|
2004-10-18 01:49:08 +04:00
|
|
|
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE &&
|
2002-05-21 23:58:24 +04:00
|
|
|
(PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_GMAC ||
|
2002-07-10 03:57:59 +04:00
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_GMAC2 ||
|
2006-08-06 01:26:48 +04:00
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_GMAC3 ||
|
2008-01-05 23:30:22 +03:00
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_SHASTA_GMAC ||
|
2007-06-25 15:11:00 +04:00
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_K2_GMAC ||
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_INTREPID2_GMAC))
|
2001-09-16 04:11:41 +04:00
|
|
|
return (1);
|
|
|
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2008-01-05 23:30:22 +03:00
|
|
|
#if GEM_USE_LOCAL_MAC_ADDRESS
|
|
|
|
static inline int
|
|
|
|
gempromvalid(u_int8_t* buf)
|
|
|
|
{
|
|
|
|
return buf[0] == 0x18 && buf[1] == 0x00 && /* structure length */
|
|
|
|
buf[2] == 0x00 && /* revision */
|
|
|
|
(buf[3] == 0x00 || /* hme */
|
|
|
|
buf[3] == 0x80) && /* qfe */
|
|
|
|
buf[4] == PCI_SUBCLASS_NETWORK_ETHERNET && /* subclass code */
|
|
|
|
buf[5] == PCI_CLASS_NETWORK; /* class code */
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
isshared_pins(u_int8_t* buf)
|
|
|
|
{
|
|
|
|
return buf[0] == 's' && buf[1] == 'h' && buf[2] == 'a' &&
|
|
|
|
buf[3] == 'r' && buf[4] == 'e' && buf[5] == 'd' &&
|
|
|
|
buf[6] == '-' && buf[7] == 'p' && buf[8] == 'i' &&
|
|
|
|
buf[9] == 'n' && buf[10] == 's';
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
isserdes(u_int8_t* buf)
|
|
|
|
{
|
|
|
|
return buf[0] == 's' && buf[1] == 'e' && buf[2] == 'r' &&
|
|
|
|
buf[3] == 'd' && buf[4] == 'e' && buf[5] == 's';
|
|
|
|
}
|
|
|
|
|
2001-09-16 04:11:41 +04:00
|
|
|
void
|
|
|
|
gem_attach_pci(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
struct gem_pci_softc *gsc = (void *)self;
|
|
|
|
struct gem_softc *sc = &gsc->gsc_gem;
|
2001-10-18 10:28:17 +04:00
|
|
|
pci_intr_handle_t ih;
|
2001-09-16 04:11:41 +04:00
|
|
|
const char *intrstr;
|
2001-09-24 08:39:40 +04:00
|
|
|
char devinfo[256];
|
2001-10-18 19:09:15 +04:00
|
|
|
uint8_t enaddr[ETHER_ADDR_LEN];
|
2008-01-05 23:30:22 +03:00
|
|
|
#if GEM_USE_LOCAL_MAC_ADDRESS
|
|
|
|
u_int8_t *enp;
|
|
|
|
bus_space_handle_t romh;
|
|
|
|
u_int8_t buf[0x0800];
|
|
|
|
int dataoff, vpdoff, serdes;
|
|
|
|
#ifdef GEM_DEBUG
|
|
|
|
int i, j;
|
|
|
|
#endif
|
|
|
|
struct pci_vpd *vpd;
|
|
|
|
static const u_int8_t promhdr[] = { 0x55, 0xaa };
|
|
|
|
#define PROMHDR_PTR_DATA 0x18
|
|
|
|
static const u_int8_t promdat[] = {
|
|
|
|
0x50, 0x43, 0x49, 0x52, /* "PCIR" */
|
|
|
|
PCI_VENDOR_SUN & 0xff, PCI_VENDOR_SUN >> 8,
|
|
|
|
PCI_PRODUCT_SUN_GEMNETWORK & 0xff,
|
|
|
|
PCI_PRODUCT_SUN_GEMNETWORK >> 8
|
|
|
|
};
|
|
|
|
#define PROMDATA_PTR_VPD 0x08
|
|
|
|
#define PROMDATA_DATA2 0x0a
|
|
|
|
#endif /* GEM_USE_LOCAL_MAC_ADDRESS */
|
2001-09-24 08:39:40 +04:00
|
|
|
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_naive(": Ethernet controller\n");
|
|
|
|
|
2004-04-24 01:13:05 +04:00
|
|
|
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_normal(": %s (rev. 0x%02x)\n", devinfo,
|
|
|
|
PCI_REVISION(pa->pa_class));
|
2001-09-16 04:11:41 +04:00
|
|
|
|
2008-01-05 23:30:22 +03:00
|
|
|
/*
|
|
|
|
* Some Sun GEMs/ERIs do have their intpin register bogusly set to 0,
|
|
|
|
* although it should be 1. correct that.
|
|
|
|
*/
|
|
|
|
if (pa->pa_intrpin == 0)
|
|
|
|
pa->pa_intrpin = 1;
|
|
|
|
|
|
|
|
sc->sc_variant = GEM_UNKNOWN;
|
|
|
|
|
2001-09-16 04:11:41 +04:00
|
|
|
sc->sc_dmatag = pa->pa_dmat;
|
|
|
|
|
2008-01-05 23:30:22 +03:00
|
|
|
sc->sc_flags |= GEM_PCI;
|
|
|
|
|
|
|
|
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SUN) {
|
|
|
|
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_GEMNETWORK)
|
|
|
|
sc->sc_variant = GEM_SUN_GEM;
|
|
|
|
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_ERINETWORK)
|
|
|
|
sc->sc_variant = GEM_SUN_ERI;
|
|
|
|
} else if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE) {
|
|
|
|
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_GMAC ||
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_GMAC2 ||
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_GMAC3 ||
|
2008-01-19 18:56:52 +03:00
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_SHASTA_GMAC ||
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_INTREPID2_GMAC)
|
2008-01-05 23:30:22 +03:00
|
|
|
sc->sc_variant = GEM_APPLE_GMAC;
|
|
|
|
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_K2_GMAC)
|
|
|
|
sc->sc_variant = GEM_APPLE_K2_GMAC;
|
|
|
|
}
|
2001-09-16 04:11:41 +04:00
|
|
|
|
2008-01-05 23:30:22 +03:00
|
|
|
if (sc->sc_variant == GEM_UNKNOWN) {
|
|
|
|
aprint_error("%s: unknown adaptor\n", sc->sc_dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
2002-05-21 23:58:24 +04:00
|
|
|
|
2001-10-18 07:48:48 +04:00
|
|
|
#define PCI_GEM_BASEADDR (PCI_MAPREG_START + 0x00)
|
|
|
|
|
|
|
|
/* XXX Need to check for a 64-bit mem BAR? */
|
|
|
|
if (pci_mapreg_map(pa, PCI_GEM_BASEADDR,
|
|
|
|
PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
|
2006-11-24 16:01:07 +03:00
|
|
|
&sc->sc_bustag, &sc->sc_h1, NULL, NULL) != 0)
|
2001-09-16 04:11:41 +04:00
|
|
|
{
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error("%s: unable to map device registers\n",
|
2001-10-18 07:48:48 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
2001-09-16 04:11:41 +04:00
|
|
|
return;
|
|
|
|
}
|
2006-11-24 16:01:07 +03:00
|
|
|
if (bus_space_subregion(sc->sc_bustag, sc->sc_h1,
|
|
|
|
GEM_PCI_BANK2_OFFSET, GEM_PCI_BANK2_SIZE, &sc->sc_h2)) {
|
|
|
|
aprint_error("%s: unable to create bank 2 subregion\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
2001-09-16 04:11:41 +04:00
|
|
|
|
2008-01-05 23:30:22 +03:00
|
|
|
#if GEM_USE_LOCAL_MAC_ADDRESS
|
2001-10-18 07:48:48 +04:00
|
|
|
/*
|
2008-01-05 23:30:22 +03:00
|
|
|
* Dig out VPD (vital product data) and acquire Ethernet address.
|
|
|
|
* The VPD of gem resides in the PCI PROM (PCI FCode).
|
2001-10-18 07:48:48 +04:00
|
|
|
*/
|
2008-01-05 23:30:22 +03:00
|
|
|
/*
|
|
|
|
* ``Writing FCode 3.x Programs'' (newer ones, dated 1997 and later)
|
|
|
|
* chapter 2 describes the data structure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enp = NULL;
|
|
|
|
|
|
|
|
if (sc->sc_variant == GEM_SUN_GEM &&
|
|
|
|
(bus_space_subregion(sc->sc_bustag, sc->sc_h1,
|
|
|
|
GEM_PCI_ROM_OFFSET, GEM_PCI_ROM_SIZE, &romh)) == 0) {
|
|
|
|
|
|
|
|
/* read PCI Expansion PROM Header */
|
|
|
|
bus_space_read_region_1(sc->sc_bustag,
|
|
|
|
romh, 0, buf, sizeof buf);
|
|
|
|
|
|
|
|
/* Check for "shared-pins = serdes" in FCode. */
|
|
|
|
i = 0;
|
|
|
|
serdes = 0;
|
|
|
|
while (i < (sizeof buf) - sizeof "serdes") {
|
|
|
|
if (!serdes) {
|
|
|
|
if (isserdes(&buf[i]))
|
|
|
|
serdes = 1;
|
|
|
|
} else {
|
|
|
|
if (isshared_pins(&buf[i]))
|
|
|
|
serdes = 2;
|
|
|
|
}
|
|
|
|
if (serdes == 2) {
|
|
|
|
sc->sc_flags |= GEM_SERDES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
#ifdef GEM_DEBUG
|
|
|
|
/* PROM dump */
|
|
|
|
printf("%s: PROM dump (0x0000 to %04lx)\n", sc->sc_dev.dv_xname,
|
|
|
|
(sizeof buf) - 1);
|
|
|
|
i = 0;
|
|
|
|
j = 0;
|
|
|
|
printf(" %04x ", i);
|
|
|
|
while (i < sizeof buf) {
|
|
|
|
printf("%02x ", buf[i]);
|
|
|
|
if (i && !(i % 8))
|
|
|
|
printf(" ");
|
|
|
|
if (i && !(i % 16)) {
|
|
|
|
printf(" ");
|
|
|
|
while (j < i) {
|
|
|
|
if (buf[j] > 31 && buf[j] < 128)
|
|
|
|
printf("%c", buf[j]);
|
|
|
|
else
|
|
|
|
printf(".");
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
j = i;
|
|
|
|
printf("\n %04x ", i);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (memcmp(buf, promhdr, sizeof promhdr) == 0 &&
|
|
|
|
(dataoff = (buf[PROMHDR_PTR_DATA] |
|
|
|
|
(buf[PROMHDR_PTR_DATA + 1] << 8))) >= 0x1c) {
|
|
|
|
|
|
|
|
/* read PCI Expansion PROM Data */
|
|
|
|
bus_space_read_region_1(sc->sc_bustag, romh, dataoff,
|
|
|
|
buf, 64);
|
|
|
|
if (memcmp(buf, promdat, sizeof promdat) == 0 &&
|
|
|
|
gempromvalid(buf + PROMDATA_DATA2) &&
|
|
|
|
(vpdoff = (buf[PROMDATA_PTR_VPD] |
|
|
|
|
(buf[PROMDATA_PTR_VPD + 1] << 8))) >= 0x1c) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The VPD of gem is not in PCI 2.2 standard
|
|
|
|
* format. The length in the resource header
|
|
|
|
* is in big endian, and resources are not
|
|
|
|
* properly terminated (only one resource
|
|
|
|
* and no end tag).
|
|
|
|
*/
|
|
|
|
/* read PCI VPD */
|
|
|
|
bus_space_read_region_1(sc->sc_bustag, romh,
|
|
|
|
vpdoff, buf, 64);
|
|
|
|
vpd = (void *)(buf + 3);
|
|
|
|
if (PCI_VPDRES_ISLARGE(buf[0]) &&
|
|
|
|
PCI_VPDRES_LARGE_NAME(buf[0])
|
|
|
|
== PCI_VPDRES_TYPE_VPD &&
|
|
|
|
vpd->vpd_key0 == 0x4e /* N */ &&
|
|
|
|
vpd->vpd_key1 == 0x41 /* A */ &&
|
|
|
|
vpd->vpd_len == ETHER_ADDR_LEN) {
|
|
|
|
/*
|
|
|
|
* Ethernet address found
|
|
|
|
*/
|
|
|
|
enp = buf + 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enp)
|
|
|
|
memcpy(enaddr, enp, ETHER_ADDR_LEN);
|
|
|
|
else
|
|
|
|
#endif /* GEM_USE_LOCAL_MAC_ADDRESS */
|
2001-09-16 04:11:41 +04:00
|
|
|
#ifdef __sparc__
|
2001-10-18 07:48:48 +04:00
|
|
|
{
|
2008-01-05 23:30:22 +03:00
|
|
|
if (strcmp(prom_getpropstring(PCITAG_NODE(pa->pa_tag),
|
|
|
|
"shared-pins"), "serdes") == 0)
|
|
|
|
sc->sc_flags |= GEM_SERDES;
|
2004-03-17 16:54:09 +03:00
|
|
|
prom_getether(PCITAG_NODE(pa->pa_tag), enaddr);
|
2001-10-18 07:48:48 +04:00
|
|
|
}
|
2008-01-05 23:30:22 +03:00
|
|
|
#else
|
2001-10-18 07:55:07 +04:00
|
|
|
#ifdef macppc
|
|
|
|
{
|
|
|
|
int node;
|
2008-01-05 23:30:22 +03:00
|
|
|
char sp[6]; /* "serdes" */
|
2001-10-18 07:55:07 +04:00
|
|
|
|
|
|
|
node = pcidev_to_ofdev(pa->pa_pc, pa->pa_tag);
|
|
|
|
if (node == 0) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error("%s: unable to locate OpenFirmware node\n",
|
2001-10-18 07:55:07 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-05 23:30:22 +03:00
|
|
|
OF_getprop(node, "shared-pins", sp, sizeof(sp));
|
|
|
|
if (isserdes(sp))
|
|
|
|
sc->sc_flags |= GEM_SERDES;
|
2001-10-18 19:09:15 +04:00
|
|
|
OF_getprop(node, "local-mac-address", enaddr, sizeof(enaddr));
|
2001-10-18 07:55:07 +04:00
|
|
|
}
|
2008-01-05 23:30:22 +03:00
|
|
|
#else
|
|
|
|
printf("%s: no Ethernet address found\n", sc->sc_dev.dv_xname);
|
2001-10-18 07:55:07 +04:00
|
|
|
#endif /* macppc */
|
2008-01-05 23:30:22 +03:00
|
|
|
#endif /* __sparc__ */
|
2001-09-16 04:11:41 +04:00
|
|
|
|
2001-10-18 10:28:17 +04:00
|
|
|
if (pci_intr_map(pa, &ih) != 0) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error("%s: unable to map interrupt\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2001-10-18 10:28:17 +04:00
|
|
|
return;
|
2005-02-27 03:26:58 +03:00
|
|
|
}
|
2001-10-18 10:28:17 +04:00
|
|
|
intrstr = pci_intr_string(pa->pa_pc, ih);
|
|
|
|
gsc->gsc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_NET, gem_intr, sc);
|
|
|
|
if (gsc->gsc_ih == NULL) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error("%s: unable to establish interrupt",
|
2001-09-16 04:11:41 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
if (intrstr != NULL)
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_normal(" at %s", intrstr);
|
|
|
|
aprint_normal("\n");
|
2001-10-18 07:48:48 +04:00
|
|
|
return;
|
2001-09-16 04:11:41 +04:00
|
|
|
}
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_normal("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
|
2001-10-18 10:28:17 +04:00
|
|
|
|
2001-10-18 19:09:15 +04:00
|
|
|
/* Finish off the attach. */
|
|
|
|
gem_attach(sc, enaddr);
|
2001-09-16 04:11:41 +04:00
|
|
|
}
|