Wed Dec 2 12:51:50 2009 UTC ()
Maybe supported LAN9218 Family.


(kiyohara)
diff -r1.9 -r1.10 src/sys/dev/ic/lan9118.c
diff -r1.1 -r1.2 src/sys/dev/ic/lan9118reg.h

cvs diff -r1.9 -r1.10 src/sys/dev/ic/lan9118.c (expand / switch to unified diff)

--- src/sys/dev/ic/lan9118.c 2009/11/29 10:17:01 1.9
+++ src/sys/dev/ic/lan9118.c 2009/12/02 12:51:50 1.10
@@ -1,58 +1,60 @@ @@ -1,58 +1,60 @@
1/* $NetBSD: lan9118.c,v 1.9 2009/11/29 10:17:01 kiyohara Exp $ */ 1/* $NetBSD: lan9118.c,v 1.10 2009/12/02 12:51:50 kiyohara Exp $ */
2/* 2/*
3 * Copyright (c) 2008 KIYOHARA Takashi 3 * Copyright (c) 2008 KIYOHARA Takashi
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27#include <sys/cdefs.h> 27#include <sys/cdefs.h>
28__KERNEL_RCSID(0, "$NetBSD: lan9118.c,v 1.9 2009/11/29 10:17:01 kiyohara Exp $"); 28__KERNEL_RCSID(0, "$NetBSD: lan9118.c,v 1.10 2009/12/02 12:51:50 kiyohara Exp $");
29 29
30/* 30/*
31 * The LAN9118 Family 31 * The LAN9118 Family
32 * 
33 * * The LAN9118 is targeted for 32-bit applications requiring high 32 * * The LAN9118 is targeted for 32-bit applications requiring high
34 * performance, and provides the highest level of performance possible for 33 * performance, and provides the highest level of performance possible for
35 * a non-PCI 10/100 Ethernet controller. 34 * a non-PCI 10/100 Ethernet controller.
36 * 35 *
37 * * The LAN9117 is designed to provide the highest level of performance 36 * * The LAN9117 is designed to provide the highest level of performance
38 * possible for 16-bit applications. It also has an external MII interface, 37 * possible for 16-bit applications. It also has an external MII interface,
39 * which can be used to attach an external PHY. 38 * which can be used to attach an external PHY.
40 * 39 *
41 * * The LAN9116 and LAN9115 are designed for performance-sensitive 40 * * The LAN9116 and LAN9115 are designed for performance-sensitive
42 * applications with less intensive performance requirements. The LAN9116 41 * applications with less intensive performance requirements. The LAN9116
43 * is for 32-bit host processors, while the LAN9115 is for 16-bit 42 * is for 32-bit host processors, while the LAN9115 is for 16-bit
44 * applications, which may also require an external PHY. Both devices 43 * applications, which may also require an external PHY. Both devices
45 * deliver superior levels of performance. 44 * deliver superior levels of performance.
 45 *
 46 * The LAN9218 Family
 47 * Also support HP Auto-MDIX.
46 */ 48 */
47 49
48#include "bpfilter.h" 50#include "bpfilter.h"
49#include "rnd.h" 51#include "rnd.h"
50 52
51#include <sys/param.h> 53#include <sys/param.h>
52#include <sys/callout.h> 54#include <sys/callout.h>
53#include <sys/device.h> 55#include <sys/device.h>
54#include <sys/errno.h> 56#include <sys/errno.h>
55#include <sys/bus.h> 57#include <sys/bus.h>
56#include <sys/ioctl.h> 58#include <sys/ioctl.h>
57#include <sys/kernel.h> 59#include <sys/kernel.h>
58#include <sys/proc.h> 60#include <sys/proc.h>
@@ -168,28 +170,28 @@ lan9118_attach(struct lan9118_softc *sc) @@ -168,28 +170,28 @@ lan9118_attach(struct lan9118_softc *sc)
168 /* byte swap mode */ 170 /* byte swap mode */
169 bus_space_write_4(sc->sc_iot, sc->sc_ioh, LAN9118_WORD_SWAP, 171 bus_space_write_4(sc->sc_iot, sc->sc_ioh, LAN9118_WORD_SWAP,
170 0xffffffff); 172 0xffffffff);
171 val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_BYTE_TEST); 173 val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_BYTE_TEST);
172 if (val != LAN9118_BYTE_TEST_VALUE) { 174 if (val != LAN9118_BYTE_TEST_VALUE) {
173 aprint_error(": failed to detect chip\n"); 175 aprint_error(": failed to detect chip\n");
174 return EINVAL; 176 return EINVAL;
175 } 177 }
176 178
177 val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_ID_REV); 179 val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_ID_REV);
178 sc->sc_id = LAN9118_ID_REV_ID(val); 180 sc->sc_id = LAN9118_ID_REV_ID(val);
179 sc->sc_rev = LAN9118_ID_REV_REV(val); 181 sc->sc_rev = LAN9118_ID_REV_REV(val);
180 182
181#define LAN9xxx_ID(id) ((id) >= 0x9000 ? (id) & 0xfff : \ 183#define LAN9xxx_ID(id) \
182 ((id) >= 0x1000 ? ((id) >> 4) + 0x100 : (id))) 184 (IS_LAN9118(id) ? (id) : (IS_LAN9218(id) ? ((id) >> 4) + 0x100 : (id) & 0xfff))
183 185
184 aprint_normal(": SMSC LAN9%03x Rev %d\n", 186 aprint_normal(": SMSC LAN9%03x Rev %d\n",
185 LAN9xxx_ID(sc->sc_id), sc->sc_rev); 187 LAN9xxx_ID(sc->sc_id), sc->sc_rev);
186 188
187 if (sc->sc_flags & LAN9118_FLAGS_SWAP) 189 if (sc->sc_flags & LAN9118_FLAGS_SWAP)
188 aprint_normal_dev(sc->sc_dev, "byte swap mode\n"); 190 aprint_normal_dev(sc->sc_dev, "byte swap mode\n");
189 191
190 timo = 3 * 1000 * 1000; /* XXXX 3sec */ 192 timo = 3 * 1000 * 1000; /* XXXX 3sec */
191 do { 193 do {
192 val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, 194 val = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
193 LAN9118_MAC_CSR_CMD); 195 LAN9118_MAC_CSR_CMD);
194 if (!(val & LAN9118_MAC_CSR_CMD_BUSY)) 196 if (!(val & LAN9118_MAC_CSR_CMD_BUSY))
195 break; 197 break;
@@ -226,27 +228,28 @@ lan9118_attach(struct lan9118_softc *sc) @@ -226,27 +228,28 @@ lan9118_attach(struct lan9118_softc *sc)
226 IFQ_SET_READY(&ifp->if_snd); 228 IFQ_SET_READY(&ifp->if_snd);
227 229
228#if 0 /* Not support 802.1Q VLAN-sized frames yet. */ 230#if 0 /* Not support 802.1Q VLAN-sized frames yet. */
229 sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU; 231 sc->sc_ec.ec_capabilities |= ETHERCAP_VLAN_MTU;
230#endif 232#endif
231 233
232 ifmedia_init(&sc->sc_mii.mii_media, 0, 234 ifmedia_init(&sc->sc_mii.mii_media, 0,
233 lan9118_ifm_change, lan9118_ifm_status); 235 lan9118_ifm_change, lan9118_ifm_status);
234 /* 236 /*
235 * Number of instance of Internal PHY is always 0. External PHY 237 * Number of instance of Internal PHY is always 0. External PHY
236 * number that above. 238 * number that above.
237 */ 239 */
238 sc->sc_mii.mii_instance++; 240 sc->sc_mii.mii_instance++;
239 if (sc->sc_id == LAN9118_ID_9115 || sc->sc_id == LAN9118_ID_9117) { 241 if (sc->sc_id == LAN9118_ID_9115 || sc->sc_id == LAN9118_ID_9117 ||
 242 sc->sc_id == LAN9218_ID_9215 || sc->sc_id == LAN9218_ID_9217) {
240 if (bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_HW_CFG) & 243 if (bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_HW_CFG) &
241 LAN9118_HW_CFG_EXT_PHY_DET) { 244 LAN9118_HW_CFG_EXT_PHY_DET) {
242 /* 245 /*
243 * We always have a internal PHY at phy1. 246 * We always have a internal PHY at phy1.
244 * In addition, external PHY is attached. 247 * In addition, external PHY is attached.
245 */ 248 */
246 DPRINTFN(1, ("%s: detect External PHY\n", __func__)); 249 DPRINTFN(1, ("%s: detect External PHY\n", __func__));
247 250
248 sc->sc_mii.mii_readreg = lan9118_miibus_readreg; 251 sc->sc_mii.mii_readreg = lan9118_miibus_readreg;
249 sc->sc_mii.mii_writereg = lan9118_miibus_writereg; 252 sc->sc_mii.mii_writereg = lan9118_miibus_writereg;
250 sc->sc_mii.mii_statchg = lan9118_miibus_statchg; 253 sc->sc_mii.mii_statchg = lan9118_miibus_statchg;
251 254
252 /* Switch MII and SMI */ 255 /* Switch MII and SMI */

cvs diff -r1.1 -r1.2 src/sys/dev/ic/lan9118reg.h (expand / switch to unified diff)

--- src/sys/dev/ic/lan9118reg.h 2009/08/09 06:40:10 1.1
+++ src/sys/dev/ic/lan9118reg.h 2009/12/02 12:51:50 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lan9118reg.h,v 1.1 2009/08/09 06:40:10 kiyohara Exp $ */ 1/* $NetBSD: lan9118reg.h,v 1.2 2009/12/02 12:51:50 kiyohara Exp $ */
2/* 2/*
3 * Copyright (c) 2008 KIYOHARA Takashi 3 * Copyright (c) 2008 KIYOHARA Takashi
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -20,30 +20,36 @@ @@ -20,30 +20,36 @@
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28#ifndef _LAN9118REG_H_ 28#ifndef _LAN9118REG_H_
29#define _LAN9118REG_H_ 29#define _LAN9118REG_H_
30 30
31#define LAN9118_IOSIZE 0x100 31#define LAN9118_IOSIZE 0x100
32 32
33#define LAN9118_ID_9115 0x115 33#define LAN9118_ID_9115 0x0115
34#define LAN9118_ID_9116 0x116 34#define LAN9118_ID_9116 0x0116
35#define LAN9118_ID_9117 0x117 35#define LAN9118_ID_9117 0x0117
36#define LAN9118_ID_9118 0x118 36#define LAN9118_ID_9118 0x0118
 37#define LAN9218_ID_9215 0x115a
 38#define LAN9218_ID_9217 0x117a
 39#define LAN9218_ID_9218 0x118a
 40
 41#define IS_LAN9118(id) ((id) >= LAN9118_ID_9115 && (id) <= LAN9118_ID_9118)
 42#define IS_LAN9218(id) ((id) >= LAN9218_ID_9215 && (id) <= LAN9218_ID_9218)
37 43
38#define LAN9118_IPHY_ADDR 0x01 /* Internal PHY Address */ 44#define LAN9118_IPHY_ADDR 0x01 /* Internal PHY Address */
39 45
40 46
41#define LAN9118_RXDFIFOP 0x00 /* RX Data FIFO Port */ 47#define LAN9118_RXDFIFOP 0x00 /* RX Data FIFO Port */
42#define LAN9118_RXDFIFOAP 0x04 /* RX Data FIFO Alias Ports */ 48#define LAN9118_RXDFIFOAP 0x04 /* RX Data FIFO Alias Ports */
43#define LAN9118_TXDFIFOP 0x20 /* TX Data FIFO Port */ 49#define LAN9118_TXDFIFOP 0x20 /* TX Data FIFO Port */
44#define LAN9118_TXDFIFOAP 0x24 /* TX Data FIFO Alias Ports */ 50#define LAN9118_TXDFIFOAP 0x24 /* TX Data FIFO Alias Ports */
45#define LAN9118_RXSFIFOP 0x40 /* RX Status FIFO Port */ 51#define LAN9118_RXSFIFOP 0x40 /* RX Status FIFO Port */
46#define LAN9118_RXSFIFOPEEK 0x44 /* RX Status FIFO PEEK */ 52#define LAN9118_RXSFIFOPEEK 0x44 /* RX Status FIFO PEEK */
47#define LAN9118_TXSFIFOP 0x48 /* TX Status FIFO Port */ 53#define LAN9118_TXSFIFOP 0x48 /* TX Status FIFO Port */
48#define LAN9118_TXSFIFOPEEK 0x4c /* TX Status FIFO PEEK */ 54#define LAN9118_TXSFIFOPEEK 0x4c /* TX Status FIFO PEEK */
49 55