attach it.
ok dlg@
-/* $OpenBSD: if_dwqe_fdt.c,v 1.7 2023/04/07 06:33:49 dlg Exp $ */
+/* $OpenBSD: if_dwqe_fdt.c,v 1.8 2023/04/07 08:53:03 kettenis Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
{
struct dwqe_softc *sc = (void *)self;
struct fdt_attach_args *faa = aux;
+ char phy_mode[16] = { 0 };
uint32_t phy, phy_supply;
uint32_t axi_config;
struct ifnet *ifp;
return;
}
+ OF_getprop(faa->fa_node, "phy-mode", phy_mode, sizeof(phy_mode));
+ if (strcmp(phy_mode, "rgmii") == 0)
+ sc->sc_phy_mode = DWQE_PHY_MODE_RGMII;
+ else if (strcmp(phy_mode, "rgmii-rxid") == 0)
+ sc->sc_phy_mode = DWQE_PHY_MODE_RGMII_RXID;
+ else if (strcmp(phy_mode, "rgmii-txid") == 0)
+ sc->sc_phy_mode = DWQE_PHY_MODE_RGMII_TXID;
+ else if (strcmp(phy_mode, "rgmii-id") == 0)
+ sc->sc_phy_mode = DWQE_PHY_MODE_RGMII_ID;
+ else
+ sc->sc_phy_mode = DWQE_PHY_MODE_UNKNOWN;
+
/* Lookup PHY. */
phy = OF_getpropint(faa->fa_node, "phy", 0);
if (phy == 0)
-/* $OpenBSD: dwqe.c,v 1.3 2023/03/22 21:41:28 jsg Exp $ */
+/* $OpenBSD: dwqe.c,v 1.4 2023/04/07 08:53:03 kettenis Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
{
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);
}
+ switch (sc->sc_phy_mode) {
+ case DWQE_PHY_MODE_RGMII:
+ mii_flags |= MIIF_SETDELAY;
+ break;
+ case DWQE_PHY_MODE_RGMII_ID:
+ mii_flags |= MIIF_SETDELAY | MIIF_RXID | MIIF_TXID;
+ break;
+ case DWQE_PHY_MODE_RGMII_RXID:
+ mii_flags |= MIIF_SETDELAY | MIIF_RXID;
+ break;
+ case DWQE_PHY_MODE_RGMII_TXID:
+ mii_flags |= MIIF_SETDELAY | MIIF_TXID;
+ break;
+ default:
+ break;
+ }
+
mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, sc->sc_phyloc,
- (sc->sc_phyloc == MII_PHY_ANY) ? 0 : MII_OFFSET_ANY, 0);
+ (sc->sc_phyloc == MII_PHY_ANY) ? 0 : MII_OFFSET_ANY, mii_flags);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
printf("%s: no PHY found!\n", sc->sc_dev.dv_xname);
ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL);
-/* $OpenBSD: dwqevar.h,v 1.2 2023/03/19 09:46:40 kettenis Exp $ */
+/* $OpenBSD: dwqevar.h,v 1.3 2023/04/07 08:53:03 kettenis Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+enum dwqe_phy_mode {
+ DWQE_PHY_MODE_UNKNOWN,
+ DWQE_PHY_MODE_RGMII,
+ DWQE_PHY_MODE_RGMII_ID,
+ DWQE_PHY_MODE_RGMII_TXID,
+ DWQE_PHY_MODE_RGMII_RXID,
+};
+
struct dwqe_buf {
bus_dmamap_t tb_map;
struct mbuf *tb_m;
#define sc_media sc_mii.mii_media
int sc_link;
int sc_phyloc;
+ enum dwqe_phy_mode sc_phy_mode;
struct dwqe_dmamem *sc_txring;
struct dwqe_buf *sc_txbuf;