1 /* $NetBSD: dwc_gmac_fdt_subr.c,v 1.1 2026/06/22 20:26:33 jakllsch Exp $ */ 2 3 /* 4 * Copyright (c) 2026 Jonathan A. Kollasch 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #include <sys/cdefs.h> 30 __KERNEL_RCSID(0, "$NetBSD"); 31 32 #include <sys/param.h> 33 #include <sys/rndsource.h> 34 35 #include <dev/fdt/fdtvar.h> 36 #include <net/if.h> 37 #include <net/if_ether.h> 38 #include <net/if_media.h> 39 #include <dev/mii/miivar.h> 40 #include <dev/fdt/dwc_gmac_fdt_subr.h> 41 #include <dev/ic/dwc_gmac_var.h> 42 43 void 44 dwc_gmac_preattach_fdt(int phandle, struct dwc_gmac_softc *sc) 45 { 46 uint32_t pbl; 47 48 if (of_getprop_uint32(phandle, "snps,pbl", &pbl) == 0) { 49 sc->sc_rxpbl = sc->sc_txpbl = pbl; 50 } 51 if (of_getprop_uint32(phandle, "snps,txpbl", &pbl) == 0) { 52 sc->sc_txpbl = pbl; 53 } 54 if (of_getprop_uint32(phandle, "snps,rxpbl", &pbl) == 0) { 55 sc->sc_rxpbl = pbl; 56 } 57 if (of_hasprop(phandle, "snps,fixed-burst")) 58 sc->sc_flags |= DWC_GMAC_FIXED_BURST; 59 #if notyet 60 if (of_hasprop(phandle, "snps,force_thresh_dma_mode")) 61 sc->sc_flags |= DWC_GMAC_FORCE_THRESH_DMA_MODE; 62 #endif 63 } 64