From nobody Tue Apr 12 22:52:10 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C6F631AF637C; Tue, 12 Apr 2022 22:52:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KdLZf5J73z3Nx9; Tue, 12 Apr 2022 22:52:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649803930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RH2sUbwnt1586acHpBh38xcwgNL2QQJ4P6ONWQFZa7U=; b=eA9mAcKT8y0V9uhQMe0cAV1UYuIUmVJb6wvcjDRphzEbwLOS3W54/+2FQ3e06KH2ZfHl5H jqTl7NPlwlBpvLlVyFLj6Yzbou+uxLlBVxPtotfERheTrS31EpWFuzXInD3H54XyEa6Y+1 YCzLsaYnnu6uRaAjx7rijtJN/9Dwmc2t1tKo32ZIZ3cZLcf3q8boSfTJZc3sBGcjhJvs78 NfxcfW8WCveaBFjWqoR7+JwA804KNZ+5x7ZRkUBAQfZULCnToxhwL6cFaGta9hD5PKBLU+ obAyQlTbth4zxeRbKcEL7atigHO0egL278sN7K8wKyjCLeb09ulGjQyCFVOBSg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 953F420379; Tue, 12 Apr 2022 22:52:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23CMqA7P015672; Tue, 12 Apr 2022 22:52:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23CMqAv6015671; Tue, 12 Apr 2022 22:52:10 GMT (envelope-from git) Date: Tue, 12 Apr 2022 22:52:10 GMT Message-Id: <202204122252.23CMqAv6015671@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 66cc0c61b023 - main - cgem: rework hardware quirk detection List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 66cc0c61b023a5d8ae1c05897bfaf7726be40934 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649803930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RH2sUbwnt1586acHpBh38xcwgNL2QQJ4P6ONWQFZa7U=; b=plqI1eF90CdZ4mTsl+uZlLNawX8DMpPuTf+zKQkQjwwNoTXxm7ElDLQFw10L9mQZDJiVu6 Ki9aS4WFtfBm2H3AY1zZlzCE2+W7lmNnmcxsy+YoBtkE+mZK/hSi8WJjaIdxFL+3ryVLv2 hm3LH7gzziIMD7lPlAFwPvW9x89kTxPpPBmOs8MguKDJWDujha3fWUvXrbEbDhvtqXRrE7 NwiNWQIhEI0GgkO66WeMgyuucBw3tjslbryjcpgbyDROoCru1Tg407eEzmthRXmdeLH6p9 zv0LNZCzInrzYjtNlrtIgbhVUyg15bGXTNy8lAFCCxi6QD9kWIrqscZGqZGgGQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649803930; a=rsa-sha256; cv=none; b=lTZoIayrv3ChXzIrQ4XWq25WXCC6/MohL/mO+gVla+i14/G2XsQm3FRNHokzp/BszO0UJh goDkpBnWS2liM75GM/BvHCsJZda/7iQ/t5RguawcccmexINd63Hl7onm9qgHC9CBkh54jQ /7ZAWb7Y8staS3omy32wz31h2/P5jktX9rdACyVQNe3Jq1QElDhkvESm9EfQl93vJJEpt0 rY1w/MvjxaXsvK58p0YFA0iP/izBg05rrZcKU8HwUym1cME/2Jtr69D5TGVT61/x5NbFAO uz+RE8sMia2FSX73I2og+GFIM+1PbkdzzvB2kjXw4VQKLIw03yUFVQVPO2aDHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=66cc0c61b023a5d8ae1c05897bfaf7726be40934 commit 66cc0c61b023a5d8ae1c05897bfaf7726be40934 Author: Milan Obuch AuthorDate: 2022-04-07 12:57:25 +0000 Commit: Mitchell Horne CommitDate: 2022-04-12 22:51:17 +0000 cgem: rework hardware quirk detection Rather than doing these checks based on the detected hardware variant, allow quirks to be specified as a set of flags for each compatible string. This simplifies adding support for new compatible hardware. Reviewed by: mhorne MFC after: 1 week Sponsored by: Conclusive Engineering Differential Revision: https://reviews.freebsd.org/D34764 --- sys/dev/cadence/if_cgem.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sys/dev/cadence/if_cgem.c b/sys/dev/cadence/if_cgem.c index 6b9d5a090aff..979ca524c624 100644 --- a/sys/dev/cadence/if_cgem.c +++ b/sys/dev/cadence/if_cgem.c @@ -100,18 +100,19 @@ __FBSDID("$FreeBSD$"); #define CGEM_CKSUM_ASSIST (CSUM_IP | CSUM_TCP | CSUM_UDP | \ CSUM_TCP_IPV6 | CSUM_UDP_IPV6) -#define HWTYPE_GENERIC_GEM 1 -#define HWTYPE_ZYNQ 2 -#define HWTYPE_ZYNQMP 3 -#define HWTYPE_SIFIVE 4 +#define HWQUIRK_NONE 0 +#define HWQUIRK_NEEDNULLQS 1 +#define HWQUIRK_RXHANGWAR 2 +#define HWQUIRK_TXCLK 4 +#define HWQUIRK_PCLK 8 static struct ofw_compat_data compat_data[] = { - { "cdns,zynq-gem", HWTYPE_ZYNQ }, - { "cdns,zynqmp-gem", HWTYPE_ZYNQMP }, - { "sifive,fu540-c000-gem", HWTYPE_SIFIVE }, - { "sifive,fu740-c000-gem", HWTYPE_SIFIVE }, - { "cdns,gem", HWTYPE_GENERIC_GEM }, - { "cadence,gem", HWTYPE_GENERIC_GEM }, + { "cdns,zynq-gem", HWQUIRK_RXHANGWAR | HWQUIRK_TXCLK }, + { "cdns,zynqmp-gem", HWQUIRK_NEEDNULLQS | HWQUIRK_TXCLK }, + { "sifive,fu540-c000-gem", HWQUIRK_PCLK }, + { "sifive,fu740-c000-gem", HWQUIRK_PCLK }, + { "cdns,gem", HWQUIRK_NONE }, + { "cadence,gem", HWQUIRK_NONE }, { NULL, 0 } }; @@ -1712,7 +1713,7 @@ cgem_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_str == NULL) return (ENXIO); device_set_desc(dev, "Cadence CGEM Gigabit Ethernet Interface"); @@ -1726,25 +1727,25 @@ cgem_attach(device_t dev) if_t ifp = NULL; int rid, err; u_char eaddr[ETHER_ADDR_LEN]; - int hwtype; + int hwquirks; sc->dev = dev; CGEM_LOCK_INIT(sc); /* Key off of compatible string and set hardware-specific options. */ - hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data; - if (hwtype == HWTYPE_ZYNQMP) + hwquirks = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + if ((hwquirks & HWQUIRK_NEEDNULLQS) != 0) sc->neednullqs = 1; - if (hwtype == HWTYPE_ZYNQ) + if ((hwquirks & HWQUIRK_RXHANGWAR) != 0) sc->rxhangwar = 1; - - if (hwtype == HWTYPE_ZYNQ || hwtype == HWTYPE_ZYNQMP) { + if ((hwquirks & HWQUIRK_TXCLK) != 0) { if (clk_get_by_ofw_name(dev, 0, "tx_clk", &sc->ref_clk) != 0) device_printf(dev, "could not retrieve reference clock.\n"); else if (clk_enable(sc->ref_clk) != 0) device_printf(dev, "could not enable clock.\n"); - } else if (hwtype == HWTYPE_SIFIVE) { + } + if ((hwquirks & HWQUIRK_PCLK) != 0) { if (clk_get_by_ofw_name(dev, 0, "pclk", &sc->ref_clk) != 0) device_printf(dev, "could not retrieve reference clock.\n");