Deleted Added
full compact
if_fxp.c (23964) if_fxp.c (24079)
1/*
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $Id: if_fxp.c,v 1.29 1997/02/22 09:44:05 peter Exp $
27 * $Id: if_fxp.c,v 1.30 1997/03/17 11:08:14 davidg Exp $
28 */
29
30/*
31 * Intel EtherExpress Pro/100B PCI Fast Ethernet driver
32 */
33
34#include "bpfilter.h"
35

--- 921 unchanged lines hidden (view full) ---

957 */
958 fxp_scb_wait(csr);
959 csr->scb_general = vtophys(sc->rfa_headm->m_ext.ext_buf);
960 csr->scb_command = FXP_SCB_COMMAND_RU_START;
961
962 /*
963 * Toggle a few bits in the DP83840 PHY.
964 */
28 */
29
30/*
31 * Intel EtherExpress Pro/100B PCI Fast Ethernet driver
32 */
33
34#include "bpfilter.h"
35

--- 921 unchanged lines hidden (view full) ---

957 */
958 fxp_scb_wait(csr);
959 csr->scb_general = vtophys(sc->rfa_headm->m_ext.ext_buf);
960 csr->scb_command = FXP_SCB_COMMAND_RU_START;
961
962 /*
963 * Toggle a few bits in the DP83840 PHY.
964 */
965 if (sc->phy_primary_device == FXP_PHY_DP83840) {
965 if (sc->phy_primary_device == FXP_PHY_DP83840 ||
966 sc->phy_primary_device == FXP_PHY_DP83840A) {
966 fxp_mdi_write(sc->csr, sc->phy_primary_addr, FXP_DP83840_PCR,
967 fxp_mdi_read(sc->csr, sc->phy_primary_addr, FXP_DP83840_PCR) |
968 FXP_DP83840_PCR_LED4_MODE | /* LED4 always indicates duplex */
969 FXP_DP83840_PCR_F_CONNECT | /* force link disconnect bypass */
970 FXP_DP83840_PCR_BIT10); /* XXX I have no idea */
967 fxp_mdi_write(sc->csr, sc->phy_primary_addr, FXP_DP83840_PCR,
968 fxp_mdi_read(sc->csr, sc->phy_primary_addr, FXP_DP83840_PCR) |
969 FXP_DP83840_PCR_LED4_MODE | /* LED4 always indicates duplex */
970 FXP_DP83840_PCR_F_CONNECT | /* force link disconnect bypass */
971 FXP_DP83840_PCR_BIT10); /* XXX I have no idea */
972 /*
973 * If link0 is set, disable auto-negotiation and then:
974 * If link1 is unset = 10Mbps
975 * If link1 is set = 100Mbps
976 * If link2 is unset = half duplex
977 * If link2 is set = full duplex
978 */
979 if (ifp->if_flags & IFF_LINK0) {
980 int flags;
981
982 flags = (ifp->if_flags & IFF_LINK1) ?
983 FXP_DP83840_BMCR_SPEED_100M : 0;
984 flags |= (ifp->if_flags & IFF_LINK2) ?
985 FXP_DP83840_BMCR_FULLDUPLEX : 0;
986 fxp_mdi_write(sc->csr, sc->phy_primary_addr, FXP_DP83840_BMCR,
987 (fxp_mdi_read(sc->csr, sc->phy_primary_addr, FXP_DP83840_BMCR) &
988 ~(FXP_DP83840_BMCR_AUTOEN | FXP_DP83840_BMCR_SPEED_100M |
989 FXP_DP83840_BMCR_FULLDUPLEX)) | flags);
990 } else {
991 fxp_mdi_write(sc->csr, sc->phy_primary_addr, FXP_DP83840_BMCR,
992 (fxp_mdi_read(sc->csr, sc->phy_primary_addr, FXP_DP83840_BMCR) |
993 FXP_DP83840_BMCR_AUTOEN));
994 }
995 } else {
996 printf("fxp%d: warning: unsupported PHY, type = %d, addr = %d\n",
997 ifp->if_unit, sc->phy_primary_device, sc->phy_primary_addr);
971 }
972
973 ifp->if_flags |= IFF_RUNNING;
974 ifp->if_flags &= ~IFF_OACTIVE;
975 splx(s);
976
977 /*
978 * Start stats updater.

--- 58 unchanged lines hidden (view full) ---

1037 } else {
1038 sc->rfa_headm = m;
1039 }
1040 sc->rfa_tailm = m;
1041
1042 return (m == oldm);
1043}
1044
998 }
999
1000 ifp->if_flags |= IFF_RUNNING;
1001 ifp->if_flags &= ~IFF_OACTIVE;
1002 splx(s);
1003
1004 /*
1005 * Start stats updater.

--- 58 unchanged lines hidden (view full) ---

1064 } else {
1065 sc->rfa_headm = m;
1066 }
1067 sc->rfa_tailm = m;
1068
1069 return (m == oldm);
1070}
1071
1045static int
1072static volatile int
1046fxp_mdi_read(csr, phy, reg)
1047 struct fxp_csr *csr;
1048 int phy;
1049 int reg;
1050{
1051 int count = 10000;
1073fxp_mdi_read(csr, phy, reg)
1074 struct fxp_csr *csr;
1075 int phy;
1076 int reg;
1077{
1078 int count = 10000;
1079 int value;
1052
1053 csr->mdi_control = (FXP_MDI_READ << 26) | (reg << 16) | (phy << 21);
1054
1080
1081 csr->mdi_control = (FXP_MDI_READ << 26) | (reg << 16) | (phy << 21);
1082
1055 while ((csr->mdi_control & 0x10000000) == 0 && count--)
1056 DELAY(1);
1083 while (((value = csr->mdi_control) & 0x10000000) == 0 && count--)
1084 DELAY(10);
1057
1058 if (count <= 0)
1059 printf("fxp_mdi_read: timed out\n");
1060
1085
1086 if (count <= 0)
1087 printf("fxp_mdi_read: timed out\n");
1088
1061 return (csr->mdi_control & 0xffff);
1089 return (value & 0xffff);
1062}
1063
1064static void
1065fxp_mdi_write(csr, phy, reg, value)
1066 struct fxp_csr *csr;
1067 int phy;
1068 int reg;
1069 int value;
1070{
1071 int count = 10000;
1072
1073 csr->mdi_control = (FXP_MDI_WRITE << 26) | (reg << 16) | (phy << 21)
1074 | (value & 0xffff);
1075
1090}
1091
1092static void
1093fxp_mdi_write(csr, phy, reg, value)
1094 struct fxp_csr *csr;
1095 int phy;
1096 int reg;
1097 int value;
1098{
1099 int count = 10000;
1100
1101 csr->mdi_control = (FXP_MDI_WRITE << 26) | (reg << 16) | (phy << 21)
1102 | (value & 0xffff);
1103
1076 while ((csr->mdi_control & 10000000) == 0 && count--)
1077 DELAY(1);
1104 while ((csr->mdi_control & 0x10000000) == 0 && count--)
1105 DELAY(10);
1078
1079 if (count <= 0)
1080 printf("fxp_mdi_write: timed out\n");
1081}
1082
1083static int
1084fxp_ioctl(ifp, command, data)
1085 struct ifnet *ifp;

--- 50 unchanged lines hidden ---
1106
1107 if (count <= 0)
1108 printf("fxp_mdi_write: timed out\n");
1109}
1110
1111static int
1112fxp_ioctl(ifp, command, data)
1113 struct ifnet *ifp;

--- 50 unchanged lines hidden ---