Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Put several fixes to ne(4) driver for better 8 bit mode ...
details: https://anonhg.NetBSD.org/src/rev/87d3f9c4902d
branches: trunk
changeset: 752681:87d3f9c4902d
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Wed Mar 03 13:39:57 2010 +0000
description:
Put several fixes to ne(4) driver for better 8 bit mode support,
especially on RTL8019AS which is also used for non-ISA local bus of
embedded controllers and some m68k machines like atari and x68k.
* move RTL8019 probe and attach code from each bus attachment
to MI ne2000_detect() and ne2000_attach()
* change a method for backend and attachment to specify 8 bit mode
to use a new sc->sc_quirk member, instead of sc->sc_dmawidth
* handle more NE2000 8 bit mode specific settings, including
bus_space(9) access width and available size of buffer memory
* add a function to detect NE2000 8 bit mode
(disabled by default, but enalbed by options NE2000_DETECT_8BIT
to avoid possible regression on various ISA clones)
* fix ipkdb attachment accordingly (untested)
Tested on two NE2000 ISA variants (RTL8019AS and another clone named UL0001)
in both 8 bit and 16 bit mode on i386. "Looks good" from nonaka@.
See my post on tech-kern for details:
http://mail-index.NetBSD.org/tech-kern/2010/02/26/msg007423.html
diffstat:
sys/arch/x68k/dev/if_ne_intio.c | 25 +--
sys/arch/x68k/dev/if_ne_neptune.c | 26 +--
sys/conf/files | 4 +-
sys/dev/ic/ne2000.c | 300 +++++++++++++++++++++++++------------
sys/dev/ic/ne2000var.h | 12 +-
sys/dev/isa/if_ne_isa.c | 26 +--
sys/dev/isapnp/if_ne_isapnp.c | 26 +--
7 files changed, 232 insertions(+), 187 deletions(-)
diffs (truncated from 758 to 300 lines):
diff -r 47862bddea2b -r 87d3f9c4902d sys/arch/x68k/dev/if_ne_intio.c
--- a/sys/arch/x68k/dev/if_ne_intio.c Wed Mar 03 12:09:49 2010 +0000
+++ b/sys/arch/x68k/dev/if_ne_intio.c Wed Mar 03 13:39:57 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ne_intio.c,v 1.15 2010/01/19 22:06:23 pooka Exp $ */
+/* $NetBSD: if_ne_intio.c,v 1.16 2010/03/03 13:39:57 tsutsui Exp $ */
/*
* Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ne_intio.c,v 1.15 2010/01/19 22:06:23 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ne_intio.c,v 1.16 2010/03/03 13:39:57 tsutsui Exp $");
#include "opt_inet.h"
#include "opt_ns.h"
@@ -74,8 +74,6 @@
#include <dev/ic/dp8390var.h>
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
-#include <dev/ic/rtl80x9reg.h>
-#include <dev/ic/rtl80x9var.h>
#include <arch/x68k/dev/intiovar.h>
@@ -187,21 +185,10 @@
case NE2000_TYPE_NE2000:
typestr = "NE2000";
- /*
- * Check for a Realtek 8019.
- */
- bus_space_write_1(iot, ioh, ED_P0_CR,
- ED_CR_PAGE_0 | ED_CR_STP);
- if (bus_space_read_1(iot, ioh, NERTL_RTL0_8019ID0) ==
- RTL0_8019ID0 &&
- bus_space_read_1(iot, ioh, NERTL_RTL0_8019ID1) ==
- RTL0_8019ID1) {
- typestr = "NE2000 (RTL8019)";
- dsc->sc_mediachange = rtl80x9_mediachange;
- dsc->sc_mediastatus = rtl80x9_mediastatus;
- dsc->init_card = rtl80x9_init_card;
- dsc->sc_media_init = rtl80x9_media_init;
- }
+ break;
+
+ case NE2000_TYPE_RTL8019:
+ typestr = "NE2000 (RTL8019)";
break;
default:
diff -r 47862bddea2b -r 87d3f9c4902d sys/arch/x68k/dev/if_ne_neptune.c
--- a/sys/arch/x68k/dev/if_ne_neptune.c Wed Mar 03 12:09:49 2010 +0000
+++ b/sys/arch/x68k/dev/if_ne_neptune.c Wed Mar 03 13:39:57 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ne_neptune.c,v 1.19 2010/01/19 22:06:23 pooka Exp $ */
+/* $NetBSD: if_ne_neptune.c,v 1.20 2010/03/03 13:39:57 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ne_neptune.c,v 1.19 2010/01/19 22:06:23 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ne_neptune.c,v 1.20 2010/03/03 13:39:57 tsutsui Exp $");
#include "opt_inet.h"
#include "opt_ns.h"
@@ -72,9 +72,6 @@
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
-#include <dev/ic/rtl80x9reg.h>
-#include <dev/ic/rtl80x9var.h>
-
#include <arch/x68k/dev/neptunevar.h>
static int ne_neptune_match(device_t, cfdata_t, void *);
@@ -165,21 +162,10 @@
case NE2000_TYPE_NE2000:
typestr = "NE2000";
- /*
- * Check for a Realtek 8019.
- */
- bus_space_write_1(nict, nich, ED_P0_CR,
- ED_CR_PAGE_0 | ED_CR_STP);
- if (bus_space_read_1(nict, nich, NERTL_RTL0_8019ID0) ==
- RTL0_8019ID0 &&
- bus_space_read_1(nict, nich, NERTL_RTL0_8019ID1) ==
- RTL0_8019ID1) {
- typestr = "NE2000 (RTL8019)";
- dsc->sc_mediachange = rtl80x9_mediachange;
- dsc->sc_mediastatus = rtl80x9_mediastatus;
- dsc->init_card = rtl80x9_init_card;
- dsc->sc_media_init = rtl80x9_media_init;
- }
+ break;
+
+ case NE2000_TYPE_RTL8019:
+ typestr = "NE2000 (RTL8019)";
break;
default:
diff -r 47862bddea2b -r 87d3f9c4902d sys/conf/files
--- a/sys/conf/files Wed Mar 03 12:09:49 2010 +0000
+++ b/sys/conf/files Wed Mar 03 13:39:57 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.979 2010/03/02 13:27:27 uebayasi Exp $
+# $NetBSD: files,v 1.980 2010/03/03 13:39:57 tsutsui Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
version 20090313
@@ -901,7 +901,7 @@
# Realtek 8019/8029 NE2000-compatible network interface subroutines
#
define rtl80x9
-file dev/ic/rtl80x9.c rtl80x9
+file dev/ic/rtl80x9.c rtl80x9 needs-flag
# Realtek 8129/8139 Ethernet controllers
#
diff -r 47862bddea2b -r 87d3f9c4902d sys/dev/ic/ne2000.c
--- a/sys/dev/ic/ne2000.c Wed Mar 03 12:09:49 2010 +0000
+++ b/sys/dev/ic/ne2000.c Wed Mar 03 13:39:57 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ne2000.c,v 1.67 2010/02/24 22:37:58 dyoung Exp $ */
+/* $NetBSD: ne2000.c,v 1.68 2010/03/03 13:39:57 tsutsui Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -48,10 +48,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.67 2010/02/24 22:37:58 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.68 2010/03/03 13:39:57 tsutsui Exp $");
#include "opt_ipkdb.h"
+#include "rtl80x9.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
@@ -85,6 +87,9 @@
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
+#include <dev/ic/rtl80x9reg.h>
+#include <dev/ic/rtl80x9var.h>
+
#include <dev/ic/ax88190reg.h>
int ne2000_write_mbuf(struct dp8390_softc *, struct mbuf *, int);
@@ -98,6 +103,11 @@
void ne2000_readmem(bus_space_tag_t, bus_space_handle_t,
bus_space_tag_t, bus_space_handle_t, int, u_int8_t *, size_t, int);
+#ifdef NE2000_DETECT_8BIT
+static bool ne2000_detect_8bit(bus_space_tag_t, bus_space_handle_t,
+ bus_space_tag_t, bus_space_handle_t);
+#endif
+
#define ASIC_BARRIER(asict, asich) \
bus_space_barrier((asict), (asich), 0, 0x10, \
BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
@@ -111,7 +121,7 @@
bus_space_tag_t asict = nsc->sc_asict;
bus_space_handle_t asich = nsc->sc_asich;
u_int8_t romdata[16];
- int memsize, i, useword, dmawidth;
+ int memstart, memsize, i, useword;
/*
* Detect it again unless caller specified it; this gives us
@@ -130,30 +140,46 @@
aprint_error_dev(dsc->sc_dev, "where did the card go?\n");
return (1);
case NE2000_TYPE_NE1000:
+ memstart = 8192;
memsize = 8192;
useword = 0;
- dmawidth = NE2000_DMAWIDTH_8BIT;
break;
case NE2000_TYPE_NE2000:
case NE2000_TYPE_AX88190: /* XXX really? */
case NE2000_TYPE_AX88790:
- memsize = 8192 * 2;
+#if NRTL80X9 > 0
+ case NE2000_TYPE_RTL8019:
+#endif
+ memstart = 16384;
+ memsize = 16384;
useword = 1;
- dmawidth = NE2000_DMAWIDTH_16BIT;
+ if (
+#ifdef NE2000_DETECT_8BIT
+ ne2000_detect_8bit(nict, nich, asict, asich) ||
+#endif
+ (nsc->sc_quirk & NE2000_QUIRK_8BIT) != 0) {
+ /* in 8 bit mode, only 8KB memory can be used */
+ memsize = 8192;
+ useword = 0;
+ }
break;
case NE2000_TYPE_DL10019:
case NE2000_TYPE_DL10022:
+ memstart = 8192 * 3;
memsize = 8192 * 3;
useword = 1;
- dmawidth = NE2000_DMAWIDTH_16BIT;
break;
}
nsc->sc_useword = useword;
- if (nsc->sc_dmawidth == NE2000_DMAWIDTH_UNKNOWN)
- nsc->sc_dmawidth = dmawidth;
- else
- dmawidth = nsc->sc_dmawidth;
+#if NRTL80X9 > 0
+ if (nsc->sc_type == NE2000_TYPE_RTL8019) {
+ dsc->init_card = rtl80x9_init_card;
+ dsc->sc_media_init = rtl80x9_media_init;
+ dsc->sc_mediachange = rtl80x9_mediachange;
+ dsc->sc_mediastatus = rtl80x9_mediastatus;
+ }
+#endif
dsc->cr_proto = ED_CR_RD2;
if (nsc->sc_type == NE2000_TYPE_AX88190 ||
@@ -171,8 +197,7 @@
*
* NE1000 gets byte-wide DMA, NE2000 gets word-wide DMA.
*/
- dsc->dcr_reg = ED_DCR_FT1 | ED_DCR_LS |
- ((dmawidth == NE2000_DMAWIDTH_16BIT) ? ED_DCR_WTS : 0);
+ dsc->dcr_reg = ED_DCR_FT1 | ED_DCR_LS | (useword ? ED_DCR_WTS : 0);
dsc->test_mem = ne2000_test_mem;
dsc->ring_copy = ne2000_ring_copy;
@@ -186,16 +211,14 @@
/*
* NIC memory doens't start at zero on an NE board.
* The start address is tied to the bus width.
- * (It happens to be computed the same way as mem size.)
*/
- dsc->mem_start = memsize;
-
#ifdef GWETHER
{
- int x, mstart = 0;
+ int x;
int8_t pbuf0[ED_PAGE_SIZE], pbuf[ED_PAGE_SIZE],
tbuf[ED_PAGE_SIZE];
+ memstart = 0;
for (i = 0; i < ED_PAGE_SIZE; i++)
pbuf0[i] = 0;
@@ -215,14 +238,14 @@
x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE,
useword);
if (memcmp(pbuf, tbuf, ED_PAGE_SIZE) == 0) {
- mstart = x << ED_PAGE_SHIFT;
+ memstart = x << ED_PAGE_SHIFT;
memsize = ED_PAGE_SIZE;
break;
}
}
}
- if (mstart == 0) {
+ if (memstart == 0) {
aprint_error_dev(&dsc->sc_dev, "cannot find start of RAM\n");
return (1);
}
@@ -251,11 +274,10 @@
}
printf("%s: RAM start 0x%x, size %d\n",
- device_xname(&dsc->sc_dev), mstart, memsize);
-
- dsc->mem_start = mstart;
+ device_xname(&dsc->sc_dev), memstart, memsize);
}
#endif /* GWETHER */
+ dsc->mem_start = memstart;
dsc->mem_size = memsize;
@@ -270,17 +292,19 @@
NIC_BARRIER(nict, nich);
/* Select word transfer. */
bus_space_write_1(nict, nich, ED_P0_DCR,
- ((dmawidth == NE2000_DMAWIDTH_16BIT) ? ED_DCR_WTS : 0));
+ useword ? ED_DCR_WTS : 0);
Home |
Main Index |
Thread Index |
Old Index