Deleted Added
full compact
axphy.c (213893) axphy.c (221407)
1/*-
2 * Copyright (c) 2009, M. Warner Losh
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

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

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#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009, M. Warner Losh
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

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

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#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/mii/axphy.c 213893 2010-10-15 14:52:11Z marius $");
28__FBSDID("$FreeBSD: head/sys/dev/mii/axphy.c 221407 2011-05-03 19:51:29Z marius $");
29
30/*
31 * driver for internal phy in the AX88x9x chips.
32 */
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>

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

68};
69
70DRIVER_MODULE(axphy, miibus, axphy_driver, axphy_devclass, 0, 0);
71
72static int axphy_service(struct mii_softc *, struct mii_data *, int);
73static void axphy_status(struct mii_softc *);
74
75static const struct mii_phydesc axphys[] = {
29
30/*
31 * driver for internal phy in the AX88x9x chips.
32 */
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>

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

68};
69
70DRIVER_MODULE(axphy, miibus, axphy_driver, axphy_devclass, 0, 0);
71
72static int axphy_service(struct mii_softc *, struct mii_data *, int);
73static void axphy_status(struct mii_softc *);
74
75static const struct mii_phydesc axphys[] = {
76 MII_PHY_DESC(ASIX, AX88X9X),
76 MII_PHY_DESC(xxASIX, AX88X9X),
77 MII_PHY_END
78};
79
77 MII_PHY_END
78};
79
80static const struct mii_phy_funcs axphy_funcs = {
81 axphy_service,
82 axphy_status,
83 mii_phy_reset
84};
85
80static int
81axphy_probe(device_t dev)
82{
83
84 return (mii_phy_dev_probe(dev, axphys, BUS_PROBE_DEFAULT));
85}
86
87static int
88axphy_attach(device_t dev)
89{
90 struct mii_softc *sc;
86static int
87axphy_probe(device_t dev)
88{
89
90 return (mii_phy_dev_probe(dev, axphys, BUS_PROBE_DEFAULT));
91}
92
93static int
94axphy_attach(device_t dev)
95{
96 struct mii_softc *sc;
91 struct mii_attach_args *ma;
92 struct mii_data *mii;
93
94 sc = device_get_softc(dev);
97
98 sc = device_get_softc(dev);
95 ma = device_get_ivars(dev);
96 sc->mii_dev = device_get_parent(dev);
97 mii = ma->mii_data;
98 LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
99
99
100 sc->mii_flags = miibus_get_flags(dev);
101 sc->mii_inst = mii->mii_instance++;
102 sc->mii_phy = ma->mii_phyno;
103 sc->mii_service = axphy_service;
104 sc->mii_pdata = mii;
105
106 sc->mii_flags |= MIIF_NOISOLATE;
107
108 mii_phy_reset(sc);
109
110 sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
111 device_printf(dev, " ");
112 mii_phy_add_media(sc);
113 printf("\n");
114
115 MIIBUS_MEDIAINIT(sc->mii_dev);
100 mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
101 &axphy_funcs, 1);
116 mii_phy_setmedia(sc);
117
118 return (0);
119}
120
121static int
122axphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
123{

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

138
139 case MII_TICK:
140 if (mii_phy_tick(sc) == EJUSTRETURN)
141 return (0);
142 break;
143 }
144
145 /* Update the media status. */
102 mii_phy_setmedia(sc);
103
104 return (0);
105}
106
107static int
108axphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
109{

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

124
125 case MII_TICK:
126 if (mii_phy_tick(sc) == EJUSTRETURN)
127 return (0);
128 break;
129 }
130
131 /* Update the media status. */
146 axphy_status(sc);
132 PHY_STATUS(sc);
147
148 /* Callback if something changed. */
149 mii_phy_update(sc, cmd);
150 return (0);
151}
152
153static void
154axphy_status(struct mii_softc *sc)

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

182
183#if 0
184 scr = PHY_READ(sc, MII_AXPHY_SCR);
185 if (scr & SCR_S100)
186 mii->mii_media_active |= IFM_100_TX;
187 else
188 mii->mii_media_active |= IFM_10_T;
189 if (scr & SCR_FDX)
133
134 /* Callback if something changed. */
135 mii_phy_update(sc, cmd);
136 return (0);
137}
138
139static void
140axphy_status(struct mii_softc *sc)

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

168
169#if 0
170 scr = PHY_READ(sc, MII_AXPHY_SCR);
171 if (scr & SCR_S100)
172 mii->mii_media_active |= IFM_100_TX;
173 else
174 mii->mii_media_active |= IFM_10_T;
175 if (scr & SCR_FDX)
190 mii->mii_media_active |= IFM_FDX;
176 mii->mii_media_active |=
177 IFM_FDX | mii_phy_flowstatus(sc);
191 else
192 mii->mii_media_active |= IFM_HDX;
193#endif
194 } else
195 mii->mii_media_active = ife->ifm_media;
196}
178 else
179 mii->mii_media_active |= IFM_HDX;
180#endif
181 } else
182 mii->mii_media_active = ife->ifm_media;
183}