Lines Matching +full:conf +full:- +full:mdio

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (c) 2011-2012 Stefan Bethke.
56 #include <dev/mdio/mdio.h>
86 if (device_find_child(parent, "ip17x", -1) == NULL) in ip17x_identify()
123 sc->sc_switchtype = IP17X_SWITCH_IP175A; in ip17x_probe()
126 sc->sc_switchtype = IP17X_SWITCH_IP175C; in ip17x_probe()
138 sc->sc_switchtype = IP17X_SWITCH_IP175D; in ip17x_probe()
143 sc->sc_switchtype = IP17X_SWITCH_IP178C; in ip17x_probe()
146 sc->miipoll = 1; in ip17x_probe()
148 if ((OF_getencprop(ip17x_node, "mii-poll", in ip17x_probe()
150 sc->miipoll = cell ? 1 : 0; in ip17x_probe()
153 "mii-poll", &sc->miipoll); in ip17x_probe()
168 snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev)); in ip17x_attach_phys()
170 if (((1 << phy) & sc->phymask) == 0) in ip17x_attach_phys()
172 sc->phyport[phy] = port; in ip17x_attach_phys()
173 sc->portphy[port] = phy; in ip17x_attach_phys()
174 sc->ifp[port] = if_alloc(IFT_ETHER); in ip17x_attach_phys()
175 if_setsoftc(sc->ifp[port], sc); in ip17x_attach_phys()
176 if_setflags(sc->ifp[port], IFF_UP | IFF_BROADCAST | in ip17x_attach_phys()
178 if_initname(sc->ifp[port], name, port); in ip17x_attach_phys()
179 sc->miibus[port] = malloc(sizeof(device_t), M_IP17X, in ip17x_attach_phys()
181 err = mii_attach(sc->sc_dev, sc->miibus[port], sc->ifp[port], in ip17x_attach_phys()
184 DPRINTF(sc->sc_dev, "%s attached to pseudo interface %s\n", in ip17x_attach_phys()
185 device_get_nameunit(*sc->miibus[port]), in ip17x_attach_phys()
186 if_name(sc->ifp[port])); in ip17x_attach_phys()
188 device_printf(sc->sc_dev, in ip17x_attach_phys()
193 sc->info.es_nports = port + 1; in ip17x_attach_phys()
194 if (++port >= sc->numports) in ip17x_attach_phys()
208 sc->sc_dev = dev; in ip17x_attach()
209 mtx_init(&sc->sc_mtx, "ip17x", NULL, MTX_DEF); in ip17x_attach()
210 strlcpy(sc->info.es_name, device_get_desc(dev), in ip17x_attach()
211 sizeof(sc->info.es_name)); in ip17x_attach()
214 sc->phymask = 0x0f; in ip17x_attach()
215 sc->media = 100; in ip17x_attach()
218 "phymask", &sc->phymask); in ip17x_attach()
221 sc->info.es_nvlangroups = IP17X_MAX_VLANS; in ip17x_attach()
229 /* We don't have support to all the models yet :-/ */ in ip17x_attach()
233 sc->phymask |= (1 << sc->cpuport); in ip17x_attach()
235 sc->ifp = malloc(sizeof(if_t) * sc->numports, M_IP17X, in ip17x_attach()
237 sc->pvid = malloc(sizeof(uint32_t) * sc->numports, M_IP17X, in ip17x_attach()
239 sc->miibus = malloc(sizeof(device_t *) * sc->numports, M_IP17X, in ip17x_attach()
241 sc->portphy = malloc(sizeof(int) * sc->numports, M_IP17X, in ip17x_attach()
245 sc->hal.ip17x_reset(sc); in ip17x_attach()
258 sc->hal.ip17x_set_vlan_mode(sc, ETHERSWITCH_VLAN_PORT); in ip17x_attach()
264 if (sc->miipoll) { in ip17x_attach()
265 callout_init(&sc->callout_tick, 0); in ip17x_attach()
280 if (sc->miipoll) in ip17x_detach()
281 callout_drain(&sc->callout_tick); in ip17x_detach()
284 if (((1 << i) & sc->phymask) == 0) in ip17x_detach()
286 port = sc->phyport[i]; in ip17x_detach()
287 if (sc->miibus[port] != NULL) in ip17x_detach()
288 device_delete_child(dev, (*sc->miibus[port])); in ip17x_detach()
289 if (sc->ifp[port] != NULL) in ip17x_detach()
290 if_free(sc->ifp[port]); in ip17x_detach()
291 free(sc->miibus[port], M_IP17X); in ip17x_detach()
294 free(sc->portphy, M_IP17X); in ip17x_detach()
295 free(sc->miibus, M_IP17X); in ip17x_detach()
296 free(sc->pvid, M_IP17X); in ip17x_detach()
297 free(sc->ifp, M_IP17X); in ip17x_detach()
300 sc->hal.ip17x_reset(sc); in ip17x_detach()
303 mtx_destroy(&sc->sc_mtx); in ip17x_detach()
312 if (port < 0 || port > sc->numports) in ip17x_miiforport()
314 return (device_get_softc(*sc->miibus[port])); in ip17x_miiforport()
321 if (port < 0 || port > sc->numports) in ip17x_ifpforport()
323 return (sc->ifp[port]); in ip17x_ifpforport()
339 if (((1 << i) & sc->phymask) == 0) in ip17x_miipollstat()
341 port = sc->phyport[i]; in ip17x_miipollstat()
342 if ((*sc->miibus[port]) == NULL) in ip17x_miipollstat()
344 mii = device_get_softc(*sc->miibus[port]); in ip17x_miipollstat()
345 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) { in ip17x_miipollstat()
346 if (IFM_INST(mii->mii_media.ifm_cur->ifm_media) != in ip17x_miipollstat()
347 miisc->mii_inst) in ip17x_miipollstat()
362 callout_reset(&sc->callout_tick, hz, ip17x_tick, sc); in ip17x_tick()
391 return (&sc->info); in ip17x_getinfo()
403 if (p->es_port < 0 || p->es_port >= sc->numports) in ip17x_getport()
406 phy = sc->portphy[p->es_port]; in ip17x_getport()
409 p->es_pvid = sc->pvid[phy]; in ip17x_getport()
412 if (sc->addtag & (1 << phy)) in ip17x_getport()
413 p->es_flags |= ETHERSWITCH_PORT_ADDTAG; in ip17x_getport()
414 if (sc->striptag & (1 << phy)) in ip17x_getport()
415 p->es_flags |= ETHERSWITCH_PORT_STRIPTAG; in ip17x_getport()
417 ifmr = &p->es_ifmr; in ip17x_getport()
420 if (p->es_ifmr.ifm_count == 0) in ip17x_getport()
423 mii = ip17x_miiforport(sc, p->es_port); in ip17x_getport()
426 if (phy == sc->cpuport) { in ip17x_getport()
428 p->es_flags |= ETHERSWITCH_PORT_CPU; in ip17x_getport()
429 ifmr->ifm_count = 0; in ip17x_getport()
430 if (sc->media == 100) in ip17x_getport()
431 ifmr->ifm_current = ifmr->ifm_active = in ip17x_getport()
434 ifmr->ifm_current = ifmr->ifm_active = in ip17x_getport()
436 ifmr->ifm_mask = 0; in ip17x_getport()
437 ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID; in ip17x_getport()
439 err = ifmedia_ioctl(mii->mii_ifp, &p->es_ifr, in ip17x_getport()
440 &mii->mii_media, SIOCGIFMEDIA); in ip17x_getport()
457 if (p->es_port < 0 || p->es_port >= sc->numports) in ip17x_setport()
460 phy = sc->portphy[p->es_port]; in ip17x_setport()
461 ifp = ip17x_ifpforport(sc, p->es_port); in ip17x_setport()
462 mii = ip17x_miiforport(sc, p->es_port); in ip17x_setport()
467 if (sc->vlan_mode == ETHERSWITCH_VLAN_DOT1Q) { in ip17x_setport()
470 if (p->es_pvid != 0) { in ip17x_setport()
472 p->es_pvid > IP175C_LAST_VLAN) in ip17x_setport()
474 sc->pvid[phy] = p->es_pvid; in ip17x_setport()
478 if (p->es_flags & ETHERSWITCH_PORT_ADDTAG && in ip17x_setport()
479 p->es_flags & ETHERSWITCH_PORT_STRIPTAG) in ip17x_setport()
483 sc->addtag &= ~(1 << phy); in ip17x_setport()
484 sc->striptag &= ~(1 << phy); in ip17x_setport()
487 if (p->es_flags & ETHERSWITCH_PORT_ADDTAG) in ip17x_setport()
488 sc->addtag |= (1 << phy); in ip17x_setport()
489 if (p->es_flags & ETHERSWITCH_PORT_STRIPTAG) in ip17x_setport()
490 sc->striptag |= (1 << phy); in ip17x_setport()
494 if (sc->hal.ip17x_hw_setup(sc)) in ip17x_setport()
498 if (phy == sc->cpuport) in ip17x_setport()
502 if (p->es_ifmr.ifm_count == 0) in ip17x_setport()
505 ifm = &mii->mii_media; in ip17x_setport()
506 return (ifmedia_ioctl(ifp, &p->es_ifr, ifm, SIOCSIFMEDIA)); in ip17x_setport()
523 DPRINTF(sc->sc_dev, "%s\n", __func__); in ip17x_ifmedia_upd()
539 DPRINTF(sc->sc_dev, "%s\n", __func__); in ip17x_ifmedia_sts()
544 ifmr->ifm_active = mii->mii_media_active; in ip17x_ifmedia_sts()
545 ifmr->ifm_status = mii->mii_media_status; in ip17x_ifmedia_sts()
573 ip17x_getconf(device_t dev, etherswitch_conf_t *conf) in ip17x_getconf() argument
580 conf->cmd = ETHERSWITCH_CONF_VLAN_MODE; in ip17x_getconf()
581 conf->vlan_mode = sc->hal.ip17x_get_vlan_mode(sc); in ip17x_getconf()
587 ip17x_setconf(device_t dev, etherswitch_conf_t *conf) in ip17x_setconf() argument
594 if (conf->cmd & ETHERSWITCH_CONF_VLAN_MODE) in ip17x_setconf()
595 sc->hal.ip17x_set_vlan_mode(sc, conf->vlan_mode); in ip17x_setconf()
615 /* MDIO interface */
640 DRIVER_MODULE(ip17x, mdio, ip17x_driver, 0, 0);
646 MODULE_DEPEND(ip17x, mdio, 1, 1, 1); /* XXX which versions? */
648 DRIVER_MODULE(mdio, ip17x, mdio_driver, 0, 0);