-/* $OpenBSD: if_dwqe_fdt.c,v 1.10 2023/04/22 05:01:44 dlg Exp $ */
+/* $OpenBSD: if_dwqe_fdt.c,v 1.11 2023/04/24 01:33:32 dlg Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
char phy_mode[16] = { 0 };
uint32_t phy, phy_supply;
uint32_t axi_config;
- struct ifnet *ifp;
+ struct ifnet *ifp = &sc->sc_ac.ac_if;
int i, node;
sc->sc_node = faa->fa_node;
/* Reset PHY */
dwqe_reset_phy(sc, phy);
+ node = OF_getnodebyname(sc->sc_node, "fixed-link");
+ if (node) {
+ sc->sc_fixed_link = 1;
+
+ ifp->if_baudrate = IF_Mbps(OF_getpropint(node, "speed", 0));
+ ifp->if_link_state = OF_getpropbool(node, "full-duplex") ?
+ LINK_STATE_FULL_DUPLEX : LINK_STATE_HALF_DUPLEX;
+ }
+
sc->sc_clk = clock_get_frequency(faa->fa_node, "stmmaceth");
if (sc->sc_clk > 500000000)
sc->sc_clk = GMAC_MAC_MDIO_ADDR_CR_500_800;
if (sc->sc_ih == NULL)
printf("%s: can't establish interrupt\n", sc->sc_dev.dv_xname);
- ifp = &sc->sc_ac.ac_if;
sc->sc_ifd.if_node = faa->fa_node;
sc->sc_ifd.if_ifp = ifp;
if_register(&sc->sc_ifd);
+
+ /* force a configuraton of the clocks/mac */
+ if (sc->sc_fixed_link)
+ sc->sc_mii.mii_statchg(self);
}
void
-/* $OpenBSD: dwqe.c,v 1.7 2023/04/23 06:22:15 dlg Exp $ */
+/* $OpenBSD: dwqe.c,v 1.8 2023/04/24 01:33:32 dlg Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
int dwqe_media_change(struct ifnet *);
void dwqe_media_status(struct ifnet *, struct ifmediareq *);
+void dwqe_mii_attach(struct dwqe_softc *);
int dwqe_mii_readreg(struct device *, int, int);
void dwqe_mii_writereg(struct device *, int, int, int);
void dwqe_mii_statchg(struct device *);
{
struct ifnet *ifp;
uint32_t version, mode;
- int mii_flags = 0;
int i;
version = dwqe_read(sc, GMAC_VERSION);
dwqe_write(sc, GMAC_SYS_BUS_MODE, mode);
}
+ if (!sc->sc_fixed_link)
+ dwqe_mii_attach(sc);
+
+ if_attach(ifp);
+ ether_ifattach(ifp);
+
+ /* Disable interrupts. */
+ dwqe_write(sc, GMAC_INT_EN, 0);
+ dwqe_write(sc, GMAC_CHAN_INTR_ENA(0), 0);
+
+ return 0;
+}
+
+void
+dwqe_mii_attach(struct dwqe_softc *sc)
+{
+ int mii_flags = 0;
+
switch (sc->sc_phy_mode) {
case DWQE_PHY_MODE_RGMII:
mii_flags |= MIIF_SETDELAY;
ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL);
} else
ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_AUTO);
-
- if_attach(ifp);
- ether_ifattach(ifp);
-
- /* Disable interrupts. */
- dwqe_write(sc, GMAC_INT_EN, 0);
- dwqe_write(sc, GMAC_CHAN_INTR_ENA(0), 0);
-
- return 0;
}
uint32_t
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
- error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
+ if (sc->sc_fixed_link)
+ error = ENOTTY;
+ else
+ error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
case SIOCGIFRXR:
GMAC_CHAN_INTR_ENA_RIE |
GMAC_CHAN_INTR_ENA_TIE);
- timeout_add_sec(&sc->sc_phy_tick, 1);
+ if (!sc->sc_fixed_link)
+ timeout_add_sec(&sc->sc_phy_tick, 1);
}
void
int i;
timeout_del(&sc->sc_rxto);
- timeout_del(&sc->sc_phy_tick);
+ if (!sc->sc_fixed_link)
+ timeout_del(&sc->sc_phy_tick);
ifp->if_flags &= ~IFF_RUNNING;
ifq_clr_oactive(&ifp->if_snd);
-/* $OpenBSD: dwqevar.h,v 1.5 2023/04/23 06:22:15 dlg Exp $ */
+/* $OpenBSD: dwqevar.h,v 1.6 2023/04/24 01:33:32 dlg Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
int sc_phyloc;
enum dwqe_phy_mode sc_phy_mode;
struct timeout sc_phy_tick;
+ int sc_fixed_link;
struct dwqe_dmamem *sc_txring;
struct dwqe_buf *sc_txbuf;