From nobody Mon May 16 13:51:21 2022 X-Original-To: dev-commits-src-branches@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 1EB301B354ED; Mon, 16 May 2022 13:51:23 +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 4L20yy0wVRz3Gm5; Mon, 16 May 2022 13:51:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652709082; 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=GKjq97DgyODY5UUlDubteiwdUc6k7NjtzqT56MPxHpw=; b=reiGZfwx2SMcEz/2ywJAGJLa7I5zjNRXHrzARTYr9ncMYIWacvAsXyj6JpwuM87Bph82YG ryFkr8vhGuePkEWEhSv1l4k+02PLStDOEiOMDdvUe1K3zEuPXshK7GqA+UkjgooyiYpvzM feoUu0jUJ6/OF9QMJUY3hPgJTWl3TWyIDQXaS/Yks+UAyWf8FX0Sf2fDlRsjR+4h8Mv7oF Su5vmMCTDYqrMwGZpRpb1DyM2HWsmzQY/wNCHB8v7WVcZlqQbjF067b7LFpxGgJUaPCTNF 1uLQcxRsdCcbHmG4IDwvYYIef/QiiuEafTIjRwdv3c6TDYkPibSYsDhRVky7rg== 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 804B0210E9; Mon, 16 May 2022 13:51:21 +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 24GDpLGl079719; Mon, 16 May 2022 13:51:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24GDpLZn079718; Mon, 16 May 2022 13:51:21 GMT (envelope-from git) Date: Mon, 16 May 2022 13:51:21 GMT Message-Id: <202205161351.24GDpLZn079718@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: a1785a30090c - stable/13 - cgem: rework hardware quirk detection List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: a1785a30090cf909897f6a37c03f7632fb85b86e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652709082; 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=GKjq97DgyODY5UUlDubteiwdUc6k7NjtzqT56MPxHpw=; b=UigYfy66RKT7bdYPopFrI22dW4px0IlWJLVKkg+9aRJgm5lHqdjpjQE7E5lfDmYGjsgshV YxuhKZYIjVS+kjMwiKgaOgkBcdBzMSxYjD7Q+bVT29z4jw28EgFDTZAietKIzNkbxaUQYm vZAKtjWklc1KWwlukBc9kr7gqts+PLQWNP8WrNtmAiPzzE9xWxx/PvSAlYDIsx6bUiQumz fmLfPMsiyX8IZLGsdojRj93wLTQgWZt9PxrWlWiUqA0XNXPTmQSV9VeqWSV/87NAMmwRoJ dVGn5e9q+tzvh/2drx415z+oMl2kc0RK3qaZsPVcawSunC4jrfhxTz33mcDLhw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652709082; a=rsa-sha256; cv=none; b=Mn87JHkUX8qU2gi9QIwE3TkoZcfQBkrnh8hD3J/tYhEwPRW95Ed6LQjY+fVwVK3ViUIbFP f4q8JBrlv80FLihlN8tciMUYqfqXQrVSKnYnrG9BNqR5DOGZioGYsdNI0Ghgu7p1jD+QXe CmKjpTY228/od0CFiGnjJJ8R73pm89KW4SNED+zjcKP9eolWZh6nm03jJ2d7sfMtNVVJic cXZncOJvYNIwk5VzAQY6haR7reuAR6BQJJUfgw8YGcwk0QNlw2spLlAwMUGhivquybeFin LE7UIrKSL5Gq+eh8/yrrl//1z134yUsAhbrla2zDD9paMwnLFP0Q+ZtfF+ra0w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=a1785a30090cf909897f6a37c03f7632fb85b86e commit a1785a30090cf909897f6a37c03f7632fb85b86e Author: Milan Obuch AuthorDate: 2022-04-07 12:57:25 +0000 Commit: Mitchell Horne CommitDate: 2022-05-16 13:34:04 +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 (cherry picked from commit 66cc0c61b023a5d8ae1c05897bfaf7726be40934) --- 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");