| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_admsw.c,v 1.26 2019/12/05 03:15:20 msaitoh Exp $ */ | | 1 | /* $NetBSD: if_admsw.c,v 1.27 2019/12/05 06:25:33 msaitoh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko. | | 4 | * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or | | 7 | * Redistribution and use in source and binary forms, with or |
8 | * without modification, are permitted provided that the following | | 8 | * without modification, are permitted provided that the following |
9 | * conditions are met: | | 9 | * conditions are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above | | 12 | * 2. Redistributions in binary form must reproduce the above |
13 | * copyright notice, this list of conditions and the following | | 13 | * copyright notice, this list of conditions and the following |
14 | * disclaimer in the documentation and/or other materials provided | | 14 | * disclaimer in the documentation and/or other materials provided |
| @@ -66,27 +66,27 @@ | | | @@ -66,27 +66,27 @@ |
66 | */ | | 66 | */ |
67 | | | 67 | |
68 | /* | | 68 | /* |
69 | * Device driver for Alchemy Semiconductor Au1x00 Ethernet Media | | 69 | * Device driver for Alchemy Semiconductor Au1x00 Ethernet Media |
70 | * Access Controller. | | 70 | * Access Controller. |
71 | * | | 71 | * |
72 | * TODO: | | 72 | * TODO: |
73 | * | | 73 | * |
74 | * Better Rx buffer management; we want to get new Rx buffers | | 74 | * Better Rx buffer management; we want to get new Rx buffers |
75 | * to the chip more quickly than we currently do. | | 75 | * to the chip more quickly than we currently do. |
76 | */ | | 76 | */ |
77 | | | 77 | |
78 | #include <sys/cdefs.h> | | 78 | #include <sys/cdefs.h> |
79 | __KERNEL_RCSID(0, "$NetBSD: if_admsw.c,v 1.26 2019/12/05 03:15:20 msaitoh Exp $"); | | 79 | __KERNEL_RCSID(0, "$NetBSD: if_admsw.c,v 1.27 2019/12/05 06:25:33 msaitoh Exp $"); |
80 | | | 80 | |
81 | | | 81 | |
82 | #include <sys/param.h> | | 82 | #include <sys/param.h> |
83 | #include <sys/bus.h> | | 83 | #include <sys/bus.h> |
84 | #include <sys/callout.h> | | 84 | #include <sys/callout.h> |
85 | #include <sys/device.h> | | 85 | #include <sys/device.h> |
86 | #include <sys/endian.h> | | 86 | #include <sys/endian.h> |
87 | #include <sys/errno.h> | | 87 | #include <sys/errno.h> |
88 | #include <sys/intr.h> | | 88 | #include <sys/intr.h> |
89 | #include <sys/ioctl.h> | | 89 | #include <sys/ioctl.h> |
90 | #include <sys/kernel.h> | | 90 | #include <sys/kernel.h> |
91 | #include <sys/malloc.h> | | 91 | #include <sys/malloc.h> |
92 | #include <sys/mbuf.h> | | 92 | #include <sys/mbuf.h> |
| @@ -1227,41 +1227,41 @@ admsw_add_rxbuf(struct admsw_softc *sc, | | | @@ -1227,41 +1227,41 @@ admsw_add_rxbuf(struct admsw_softc *sc, |
1227 | if (high) | | 1227 | if (high) |
1228 | ADMSW_INIT_RXHDESC(sc, idx); | | 1228 | ADMSW_INIT_RXHDESC(sc, idx); |
1229 | else | | 1229 | else |
1230 | ADMSW_INIT_RXLDESC(sc, idx); | | 1230 | ADMSW_INIT_RXLDESC(sc, idx); |
1231 | | | 1231 | |
1232 | return 0; | | 1232 | return 0; |
1233 | } | | 1233 | } |
1234 | | | 1234 | |
1235 | int | | 1235 | int |
1236 | admsw_mediachange(struct ifnet *ifp) | | 1236 | admsw_mediachange(struct ifnet *ifp) |
1237 | { | | 1237 | { |
1238 | struct admsw_softc *sc = ifp->if_softc; | | 1238 | struct admsw_softc *sc = ifp->if_softc; |
1239 | int port = (struct ethercom *)ifp - sc->sc_ethercom; /* XXX */ | | 1239 | int port = (struct ethercom *)ifp - sc->sc_ethercom; /* XXX */ |
1240 | struct ifmedia_entry *ife = sc->sc_ifmedia[port].ifm_cur; | | 1240 | struct ifmedia *ifm = &sc->sc_ifmedia[port]; |
1241 | int old, new, val; | | 1241 | int old, new, val; |
1242 | | | 1242 | |
1243 | if (IFM_TYPE(ife->ifm_media) != IFM_ETHER) | | 1243 | if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) |
1244 | return EINVAL; | | 1244 | return EINVAL; |
1245 | | | 1245 | |
1246 | if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) { | | 1246 | if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO) { |
1247 | val = PHY_CNTL2_AUTONEG | PHY_CNTL2_100M | PHY_CNTL2_FDX; | | 1247 | val = PHY_CNTL2_AUTONEG | PHY_CNTL2_100M | PHY_CNTL2_FDX; |
1248 | } else if (IFM_SUBTYPE(ife->ifm_media) == IFM_100_TX) { | | 1248 | } else if (IFM_SUBTYPE(ifm->ifm_media) == IFM_100_TX) { |
1249 | if ((ife->ifm_media & IFM_FDX) != 0) | | 1249 | if ((ifm->ifm_media & IFM_FDX) != 0) |
1250 | val = PHY_CNTL2_100M | PHY_CNTL2_FDX; | | 1250 | val = PHY_CNTL2_100M | PHY_CNTL2_FDX; |
1251 | else | | 1251 | else |
1252 | val = PHY_CNTL2_100M; | | 1252 | val = PHY_CNTL2_100M; |
1253 | } else if (IFM_SUBTYPE(ife->ifm_media) == IFM_10_T) { | | 1253 | } else if (IFM_SUBTYPE(ifm->ifm_media) == IFM_10_T) { |
1254 | if ((ife->ifm_media & IFM_FDX) != 0) | | 1254 | if ((ifm->ifm_media & IFM_FDX) != 0) |
1255 | val = PHY_CNTL2_FDX; | | 1255 | val = PHY_CNTL2_FDX; |
1256 | else | | 1256 | else |
1257 | val = 0; | | 1257 | val = 0; |
1258 | } else | | 1258 | } else |
1259 | return EINVAL; | | 1259 | return EINVAL; |
1260 | | | 1260 | |
1261 | old = REG_READ(PHY_CNTL2_REG); | | 1261 | old = REG_READ(PHY_CNTL2_REG); |
1262 | new = old & ~((PHY_CNTL2_AUTONEG | PHY_CNTL2_100M | PHY_CNTL2_FDX) | | 1262 | new = old & ~((PHY_CNTL2_AUTONEG | PHY_CNTL2_100M | PHY_CNTL2_FDX) |
1263 | << port); | | 1263 | << port); |
1264 | new |= (val << port); | | 1264 | new |= (val << port); |
1265 | | | 1265 | |
1266 | if (new != old) | | 1266 | if (new != old) |
1267 | REG_WRITE(PHY_CNTL2_REG, new); | | 1267 | REG_WRITE(PHY_CNTL2_REG, new); |