From: Jacky Chou <jacky_chou@aspeedtech.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Andrew Lunn <andrew@lunn.ch>,
Jacky Chou <jacky_chou@aspeedtech.com>,
Simon Horman <horms@kernel.org>
Subject: [PATCH net-next v3 02/15] net: ftgmac100: Add match data containing MAC ID
Date: Mon, 2 Feb 2026 14:56:56 +0800 [thread overview]
Message-ID: <20260202-ftgmac-cleanup-v3-2-6a6a8d45280a@aspeedtech.com> (raw)
In-Reply-To: <20260202-ftgmac-cleanup-v3-0-6a6a8d45280a@aspeedtech.com>
From: Andrew Lunn <andrew@lunn.ch>
The driver supports 4 different versions of the FTGMAC core. Extend
the compatible matching to include match data, which indicates the
version of the MAC. Default to the initial Faraday device if DT is not
being used. Lookup the match data early in probe to keep error handing
simple.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
drivers/net/ethernet/faraday/ftgmac100.c | 55 +++++++++++++++++++++++++++++---
1 file changed, 50 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index bd768a93b9e6..104eb7b1f5bb 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -33,6 +33,17 @@
#define DRV_NAME "ftgmac100"
+enum ftgmac100_mac_id {
+ FTGMAC100_FARADAY = 1,
+ FTGMAC100_AST2400,
+ FTGMAC100_AST2500,
+ FTGMAC100_AST2600
+};
+
+struct ftgmac100_match_data {
+ enum ftgmac100_mac_id mac_id;
+};
+
/* Arbitrary values, I am not sure the HW has limits */
#define MAX_RX_QUEUE_ENTRIES 1024
#define MAX_TX_QUEUE_ENTRIES 1024
@@ -66,6 +77,8 @@ struct ftgmac100 {
struct resource *res;
void __iomem *base;
+ enum ftgmac100_mac_id mac_id;
+
/* Rx ring */
unsigned int rx_q_entries;
struct ftgmac100_rxdes *rxdes;
@@ -1835,6 +1848,8 @@ static bool ftgmac100_has_child_node(struct device_node *np, const char *name)
static int ftgmac100_probe(struct platform_device *pdev)
{
+ const struct ftgmac100_match_data *match_data;
+ enum ftgmac100_mac_id mac_id;
struct resource *res;
int irq;
struct net_device *netdev;
@@ -1843,6 +1858,16 @@ static int ftgmac100_probe(struct platform_device *pdev)
struct device_node *np;
int err = 0;
+ np = pdev->dev.of_node;
+ if (np) {
+ match_data = of_device_get_match_data(&pdev->dev);
+ if (!match_data)
+ return -EINVAL;
+ mac_id = match_data->mac_id;
+ } else {
+ mac_id = FTGMAC100_FARADAY;
+ }
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENXIO;
@@ -1870,6 +1895,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
priv = netdev_priv(netdev);
priv->netdev = netdev;
priv->dev = &pdev->dev;
+ priv->mac_id = mac_id;
INIT_WORK(&priv->reset_task, ftgmac100_reset_task);
/* map io memory */
@@ -1900,7 +1926,6 @@ static int ftgmac100_probe(struct platform_device *pdev)
if (err)
goto err_phy_connect;
- np = pdev->dev.of_node;
if (np && (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
of_device_is_compatible(np, "aspeed,ast2500-mac") ||
of_device_is_compatible(np, "aspeed,ast2600-mac"))) {
@@ -2090,11 +2115,31 @@ static void ftgmac100_remove(struct platform_device *pdev)
free_netdev(netdev);
}
+static const struct ftgmac100_match_data ftgmac100_match_data_ast2400 = {
+ .mac_id = FTGMAC100_AST2400
+};
+
+static const struct ftgmac100_match_data ftgmac100_match_data_ast2500 = {
+ .mac_id = FTGMAC100_AST2500
+};
+
+static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = {
+ .mac_id = FTGMAC100_AST2600
+};
+
+static const struct ftgmac100_match_data ftgmac100_match_data_faraday = {
+ .mac_id = FTGMAC100_FARADAY
+};
+
static const struct of_device_id ftgmac100_of_match[] = {
- { .compatible = "aspeed,ast2400-mac" },
- { .compatible = "aspeed,ast2500-mac" },
- { .compatible = "aspeed,ast2600-mac" },
- { .compatible = "faraday,ftgmac100" },
+ { .compatible = "aspeed,ast2400-mac",
+ .data = &ftgmac100_match_data_ast2400},
+ { .compatible = "aspeed,ast2500-mac",
+ .data = &ftgmac100_match_data_ast2500 },
+ { .compatible = "aspeed,ast2600-mac",
+ .data = &ftgmac100_match_data_ast2600 },
+ { .compatible = "faraday,ftgmac100",
+ .data = &ftgmac100_match_data_faraday },
{ }
};
MODULE_DEVICE_TABLE(of, ftgmac100_of_match);
--
2.34.1
next prev parent reply other threads:[~2026-02-02 7:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-02 6:56 [PATCH net-next v3 00/15] net: ftgmac100: Various probe cleanups Jacky Chou
2026-02-02 6:56 ` [PATCH net-next v3 01/15] net: ftgmac100: List all compatibles Jacky Chou
2026-02-02 6:56 ` Jacky Chou [this message]
2026-02-02 6:56 ` [PATCH net-next v3 03/15] net: ftgmac100: Replace all of_device_is_compatible() Jacky Chou
2026-02-02 6:56 ` [PATCH net-next v3 04/15] net: ftgmac100: Use devm_alloc_etherdev() Jacky Chou
2026-02-02 6:56 ` [PATCH net-next v3 05/15] net: ftgmac100: Use devm_request_memory_region/devm_ioremap Jacky Chou
2026-02-02 6:57 ` [PATCH net-next v3 06/15] net: ftgmac100: Use devm_clk_get_enabled Jacky Chou
2026-02-02 6:57 ` [PATCH net-next v3 07/15] net: ftgmac100: Simplify error handling for ftgmac100_initial_mac Jacky Chou
2026-02-02 6:57 ` [PATCH net-next v3 08/15] net: ftgmac100: Move NCSI probe code into a helper Jacky Chou
2026-02-04 3:34 ` [net-next,v3,08/15] " Jakub Kicinski
2026-02-02 6:57 ` [PATCH net-next v3 09/15] net: ftgmac100: Always register the MDIO bus when it exists Jacky Chou
2026-02-02 6:57 ` [PATCH net-next v3 10/15] net: ftgmac100: Simplify legacy MDIO setup Jacky Chou
2026-02-02 6:57 ` [PATCH net-next v3 11/15] net: ftgmac100: Move DT probe into a helper Jacky Chou
2026-02-02 6:57 ` [PATCH net-next v3 12/15] net: ftgmac100: Remove redundant PHY_POLL Jacky Chou
2026-02-02 6:57 ` [PATCH net-next v3 13/15] net: ftgmac100: Simplify condition on HW arbitration Jacky Chou
2026-02-02 6:57 ` [PATCH net-next v3 14/15] net: ftgmac100: Fix wrong netif_napi_del in release Jacky Chou
2026-02-02 6:57 ` [PATCH net-next v3 15/15] net: ftgmac100: Use devm_mdiobus_alloc/devm_of_mdiobus_register Jacky Chou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260202-ftgmac-cleanup-v3-2-6a6a8d45280a@aspeedtech.com \
--to=jacky_chou@aspeedtech.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox