From owner-svn-src-head@freebsd.org Sat Sep 9 11:54:06 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32B5AE11F30; Sat, 9 Sep 2017 11:54:06 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0DF4C6618A; Sat, 9 Sep 2017 11:54:05 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v89Bs5oD094978; Sat, 9 Sep 2017 11:54:05 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v89Bs4b9094975; Sat, 9 Sep 2017 11:54:04 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201709091154.v89Bs4b9094975@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Sat, 9 Sep 2017 11:54:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323362 - in head/sys: conf dev/neta X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys: conf dev/neta X-SVN-Commit-Revision: 323362 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Sep 2017 11:54:06 -0000 Author: mw Date: Sat Sep 9 11:54:04 2017 New Revision: 323362 URL: https://svnweb.freebsd.org/changeset/base/323362 Log: Add support for Armada 3700 in the NETA driver This patch enables using NETA driver on Marvell Armada 3700 SoC by introducing new compatible string, modifying clock source obtaining and also excluding unnecessary parts. The driver is added as a build option for arm64 platforms as well. Submitted by: Patryk Duda Obtained from: Semihalf Sponsored by: Semihalf Differential Revision: https://reviews.freebsd.org/D12258 Modified: head/sys/conf/files.arm64 head/sys/dev/neta/if_mvneta.c head/sys/dev/neta/if_mvneta_fdt.c Modified: head/sys/conf/files.arm64 ============================================================================== --- head/sys/conf/files.arm64 Sat Sep 9 11:49:36 2017 (r323361) +++ head/sys/conf/files.arm64 Sat Sep 9 11:54:04 2017 (r323362) @@ -167,6 +167,8 @@ dev/hwpmc/hwpmc_arm64_md.c optional hwpmc dev/mbox/mbox_if.m optional soc_brcm_bcm2837 dev/mmc/host/dwmmc.c optional dwmmc fdt dev/mmc/host/dwmmc_hisi.c optional dwmmc fdt soc_hisi_hi6220 +dev/neta/if_mvneta_fdt.c optional neta fdt +dev/neta/if_mvneta.c optional neta mdio mii dev/ofw/ofw_cpu.c optional fdt dev/ofw/ofwpci.c optional fdt pci dev/pci/pci_host_generic.c optional pci Modified: head/sys/dev/neta/if_mvneta.c ============================================================================== --- head/sys/dev/neta/if_mvneta.c Sat Sep 9 11:49:36 2017 (r323361) +++ head/sys/dev/neta/if_mvneta.c Sat Sep 9 11:54:04 2017 (r323362) @@ -74,9 +74,12 @@ __FBSDID("$FreeBSD$"); #include -#include #include + +#if !defined(__aarch64__) +#include #include +#endif #include "if_mvnetareg.h" #include "if_mvnetavar.h" @@ -92,6 +95,18 @@ __FBSDID("$FreeBSD$"); #define DASSERT(x) KASSERT((x), (#x)) +#define A3700_TCLK_250MHZ 250000000 + +STATIC uint32_t +mvneta_get_clk() +{ +#if defined(__aarch64__) + return (A3700_TCLK_250MHZ); +#else + return (get_tclk()); +#endif +} + /* Device Register Initialization */ STATIC int mvneta_initreg(struct ifnet *); @@ -464,7 +479,7 @@ mvneta_dma_create(struct mvneta_softc *sc) error = mvneta_ring_alloc_tx_queue(sc, q); if (error != 0) { device_printf(sc->dev, - "Failed to allocate DMA safe memory for TxQ: %d\n", q); + "Failed to allocate DMA safe memory for TxQ: %zu\n", q); goto fail; } } @@ -512,7 +527,7 @@ mvneta_dma_create(struct mvneta_softc *sc) for (q = 0; q < MVNETA_RX_QNUM_MAX; q++) { if (mvneta_ring_alloc_rx_queue(sc, q) != 0) { device_printf(sc->dev, - "Failed to allocate DMA safe memory for RxQ: %d\n", q); + "Failed to allocate DMA safe memory for RxQ: %zu\n", q); goto fail; } } @@ -533,7 +548,9 @@ mvneta_attach(device_t self) device_t child; int ifm_target; int q, error; +#if !defined(__aarch64__) uint32_t reg; +#endif sc = device_get_softc(self); sc->dev = self; @@ -556,6 +573,7 @@ mvneta_attach(device_t self) MVNETA_WRITE(sc, MVNETA_PRXINIT, 0x00000001); MVNETA_WRITE(sc, MVNETA_PTXINIT, 0x00000001); +#if !defined(__aarch64__) /* * Disable port snoop for buffers and descriptors * to avoid L2 caching of both without DRAM copy. @@ -568,6 +586,7 @@ mvneta_attach(device_t self) reg &= ~MVNETA_PSNPCFG_BUFSNP_MASK; MVNETA_WRITE(sc, MVNETA_PSNPCFG, reg); } +#endif /* * MAC address @@ -1363,7 +1382,7 @@ mvneta_ring_init_rx_queue(struct mvneta_softc *sc, int rx = MVNETA_RX_RING(sc, q); rx->dma = rx->cpu = 0; rx->queue_th_received = MVNETA_RXTH_COUNT; - rx->queue_th_time = (get_tclk() / 1000) / 10; /* 0.1 [ms] */ + rx->queue_th_time = (mvneta_get_clk() / 1000) / 10; /* 0.1 [ms] */ /* Initialize LRO */ rx->lro_enabled = FALSE; @@ -3344,7 +3363,7 @@ sysctl_set_queue_rxthtime(SYSCTL_HANDLER_ARGS) mvneta_rx_lockq(sc, arg->queue); rx = MVNETA_RX_RING(sc, arg->queue); time_mvtclk = rx->queue_th_time; - time_us = ((uint64_t)time_mvtclk * 1000ULL * 1000ULL) / get_tclk(); + time_us = ((uint64_t)time_mvtclk * 1000ULL * 1000ULL) / mvneta_get_clk(); mvneta_rx_unlockq(sc, arg->queue); mvneta_sc_unlock(sc); @@ -3362,7 +3381,7 @@ sysctl_set_queue_rxthtime(SYSCTL_HANDLER_ARGS) return (EINVAL); } time_mvtclk = - (uint64_t)get_tclk() * (uint64_t)time_us / (1000ULL * 1000ULL); + (uint64_t)mvneta_get_clk() * (uint64_t)time_us / (1000ULL * 1000ULL); rx->queue_th_time = time_mvtclk; reg = MVNETA_PRXITTH_RITT(rx->queue_th_time); MVNETA_WRITE(sc, MVNETA_PRXITTH(arg->queue), reg); Modified: head/sys/dev/neta/if_mvneta_fdt.c ============================================================================== --- head/sys/dev/neta/if_mvneta_fdt.c Sat Sep 9 11:49:36 2017 (r323361) +++ head/sys/dev/neta/if_mvneta_fdt.c Sat Sep 9 11:54:04 2017 (r323362) @@ -83,6 +83,12 @@ DRIVER_MODULE(mvneta, simplebus, mvneta_fdt_driver, mv static int mvneta_fdt_phy_acquire(device_t); +static struct ofw_compat_data compat_data[] = { + {"marvell,armada-370-neta", true}, + {"marvell,armada-3700-neta", true}, + {NULL, false} +}; + static int mvneta_fdt_probe(device_t dev) { @@ -90,7 +96,7 @@ mvneta_fdt_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "marvell,armada-370-neta")) + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) return (ENXIO); device_set_desc(dev, "NETA controller");