From: stsp Date: Mon, 9 Oct 2023 14:25:00 +0000 (+0000) Subject: allow dwqe.c to build on architectures that do not have machine/fdt.h X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=41e44c553d835e31b2c334ef4461b58feb973f14;p=openbsd allow dwqe.c to build on architectures that do not have machine/fdt.h Move struct if_device to a new fdt-specific softc struct, along with the gmac_id field which is only used by if_dwqe_fdt.c at present. This avoids the need to include any fdt header files in dwqe.c. ok kettenis@ --- diff --git a/sys/dev/fdt/if_dwqe_fdt.c b/sys/dev/fdt/if_dwqe_fdt.c index c6e8fe3d3f9..7a43333f673 100644 --- a/sys/dev/fdt/if_dwqe_fdt.c +++ b/sys/dev/fdt/if_dwqe_fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dwqe_fdt.c,v 1.15 2023/08/30 19:08:48 kettenis Exp $ */ +/* $OpenBSD: if_dwqe_fdt.c,v 1.16 2023/10/09 14:25:00 stsp Exp $ */ /* * Copyright (c) 2008, 2019 Mark Kettenis * Copyright (c) 2017, 2022 Patrick Wildt @@ -61,16 +61,22 @@ #include #include +struct dwqe_fdt_softc { + struct dwqe_softc sc_sc; + struct if_device sc_ifd; + int sc_gmac_id; +}; + int dwqe_fdt_match(struct device *, void *, void *); void dwqe_fdt_attach(struct device *, struct device *, void *); void dwqe_setup_jh7110(struct dwqe_softc *); void dwqe_mii_statchg_jh7110(struct device *); -void dwqe_setup_rk3568(struct dwqe_softc *); +void dwqe_setup_rk3568(struct dwqe_fdt_softc *); void dwqe_mii_statchg_rk3568(struct device *); void dwqe_mii_statchg_rk3588(struct device *); const struct cfattach dwqe_fdt_ca = { - sizeof(struct dwqe_softc), dwqe_fdt_match, dwqe_fdt_attach + sizeof(struct dwqe_fdt_softc), dwqe_fdt_match, dwqe_fdt_attach }; void dwqe_reset_phy(struct dwqe_softc *, uint32_t); @@ -87,7 +93,8 @@ dwqe_fdt_match(struct device *parent, void *cfdata, void *aux) void dwqe_fdt_attach(struct device *parent, struct device *self, void *aux) { - struct dwqe_softc *sc = (void *)self; + struct dwqe_fdt_softc *fsc = (void *)self; + struct dwqe_softc *sc = &fsc->sc_sc; struct fdt_attach_args *faa = aux; char phy_mode[16] = { 0 }; uint32_t phy, phy_supply; @@ -108,18 +115,18 @@ dwqe_fdt_attach(struct device *parent, struct device *self, void *aux) switch (faa->fa_reg[0].addr) { case 0xfe2a0000: /* RK3568 */ case 0x16030000: /* JH7110 */ - sc->sc_gmac_id = 0; + fsc->sc_gmac_id = 0; break; case 0xfe010000: /* RK3568 */ case 0x16040000: /* JH7110 */ - sc->sc_gmac_id = 1; + fsc->sc_gmac_id = 1; break; default: printf(": unknown controller at 0x%llx\n", faa->fa_reg[0].addr); return; } - printf(" gmac %d", sc->sc_gmac_id); + printf(" gmac %d", fsc->sc_gmac_id); OF_getprop(faa->fa_node, "phy-mode", phy_mode, sizeof(phy_mode)); if (strcmp(phy_mode, "rgmii") == 0) @@ -167,7 +174,7 @@ dwqe_fdt_attach(struct device *parent, struct device *self, void *aux) if (OF_is_compatible(faa->fa_node, "starfive,jh7110-dwmac")) dwqe_setup_jh7110(sc); else if (OF_is_compatible(faa->fa_node, "rockchip,rk3568-gmac")) - dwqe_setup_rk3568(sc); + dwqe_setup_rk3568(fsc); /* Power up PHY. */ phy_supply = OF_getpropint(faa->fa_node, "phy-supply", 0); @@ -252,9 +259,9 @@ dwqe_fdt_attach(struct device *parent, struct device *self, void *aux) if (sc->sc_ih == NULL) printf("%s: can't establish interrupt\n", sc->sc_dev.dv_xname); - sc->sc_ifd.if_node = faa->fa_node; - sc->sc_ifd.if_ifp = ifp; - if_register(&sc->sc_ifd); + fsc->sc_ifd.if_node = faa->fa_node; + fsc->sc_ifd.if_ifp = ifp; + if_register(&fsc->sc_ifd); /* force a configuration of the clocks/mac */ if (sc->sc_fixed_link) @@ -400,8 +407,9 @@ dwqe_mii_statchg_jh7110(struct device *self) } void -dwqe_setup_rk3568(struct dwqe_softc *sc) +dwqe_setup_rk3568(struct dwqe_fdt_softc *fsc) { + struct dwqe_softc *sc = &fsc->sc_sc; char phy_mode[32]; struct regmap *rm; uint32_t grf; @@ -439,12 +447,12 @@ dwqe_setup_rk3568(struct dwqe_softc *sc) return; /* Program clock delay lines. */ - regmap_write_4(rm, RK3568_GRF_GMACx_CON0(sc->sc_gmac_id), + regmap_write_4(rm, RK3568_GRF_GMACx_CON0(fsc->sc_gmac_id), RK3568_GMAC_CLK_TX_DL_CFG(tx_delay) | RK3568_GMAC_CLK_RX_DL_CFG(rx_delay)); /* Set interface and enable/disable clock delay. */ - regmap_write_4(rm, RK3568_GRF_GMACx_CON1(sc->sc_gmac_id), iface | + regmap_write_4(rm, RK3568_GRF_GMACx_CON1(fsc->sc_gmac_id), iface | RK3568_GMAC_TXCLK_DLY_SET(tx_delay > 0 ? 1 : 0) | RK3568_GMAC_RXCLK_DLY_SET(rx_delay > 0 ? 1 : 0)); diff --git a/sys/dev/ic/dwqe.c b/sys/dev/ic/dwqe.c index 026f4e2a00f..9880d5e7f22 100644 --- a/sys/dev/ic/dwqe.c +++ b/sys/dev/ic/dwqe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwqe.c,v 1.11 2023/08/07 20:28:47 kettenis Exp $ */ +/* $OpenBSD: dwqe.c,v 1.12 2023/10/09 14:25:00 stsp Exp $ */ /* * Copyright (c) 2008, 2019 Mark Kettenis * Copyright (c) 2017, 2022 Patrick Wildt @@ -34,19 +34,10 @@ #include #include -#include #include #include -#include -#include -#include -#include -#include -#include -#include - #include #include diff --git a/sys/dev/ic/dwqevar.h b/sys/dev/ic/dwqevar.h index 69e95a34ed3..f703cfda127 100644 --- a/sys/dev/ic/dwqevar.h +++ b/sys/dev/ic/dwqevar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dwqevar.h,v 1.6 2023/04/24 01:33:32 dlg Exp $ */ +/* $OpenBSD: dwqevar.h,v 1.7 2023/10/09 14:25:00 stsp Exp $ */ /* * Copyright (c) 2008, 2019 Mark Kettenis * Copyright (c) 2017, 2022 Patrick Wildt @@ -53,8 +53,6 @@ struct dwqe_softc { bus_dma_tag_t sc_dmat; void *sc_ih; - struct if_device sc_ifd; - struct arpcom sc_ac; #define sc_lladdr sc_ac.ac_enaddr struct mii_data sc_mii; @@ -88,7 +86,6 @@ struct dwqe_softc { uint32_t sc_clk_sel_25; uint32_t sc_clk_sel_2_5; - int sc_gmac_id; int sc_hw_feature[4]; int sc_force_thresh_dma_mode;