Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp202217rdb; Thu, 18 Jan 2024 00:29:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IG54lJUu7efbbyOYYi6osAd/rW9Kb/Z+LCA7O3K5a+hJvaEH8JgIP2L+YSTx9kTYBXW7vUq X-Received: by 2002:a05:6a20:1590:b0:199:dab1:8b6e with SMTP id h16-20020a056a20159000b00199dab18b6emr548777pzj.39.1705566568049; Thu, 18 Jan 2024 00:29:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705566568; cv=pass; d=google.com; s=arc-20160816; b=GX2B06MDVS3lYgexxPM1TDnLf+O49mna4EjPO/ZVHOdOa8B1r3qp8Xq5G5g3VTe1jm FHOZNx4GERlTQg3MxM+VTfmr0FxgoQ/+8nLWx8NVMjsqtCL8GsIxYxeZunhKhb6f8Kog owmzpDllsOXihEPQYv7bxoiROe6cCim4H70LDDH1bCwonzoZWqU0kXmHXNROiXvaeHQn EtbUKZ7B/th58pgN+GdEccpCRoY+I2lPrsK1GWyGziz84L2q4NHcqJ96OL9yhXIB6yIM SEh6MmaMoXanN3MMqvUohVPTWKKfeDfdSpiUMl57yzQF0s3JcrdKed0fkxxkof0IPEug dqsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=oIWmmRrpkXSpmw/llP+4St+jhonk4CIclrIIBRrhniM=; fh=bwNWdyJAHmVOwi3g9ISrW3UuWobgCM+5XU1hjMHZnrU=; b=lVNnqVwBU1C8miK+O9Y4ARogdWXbZZ2rmGuEDgljOK2dgWb04y2KDuah8HNd7a5Om8 CZ/6sUn4UsJ6MWVpzbWqD4SP3mt3BDh77dPC64o9ZVt9Xq2hx7je3mWI54ugAxy3HsrG 5GIMeAEl15CO9esfXYLYn895+vmPmq+XE9qHzJrm7/aaAhqeN3xbzMqZ8QgaY/J8KZ+f NctjqVXApSi+bM46STf5YqipOxtD6CIB0N/B8bgV103s2S0XlUR96GG7Ru/oevymqPzw 6fkOMNLH4TNBcaz2tyFGKliqQDrdwle7lqygewQmYTe0gbb7MqhigSTJxkxaW52ikVdF q76Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A5KCACn9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29871-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29871-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u4-20020a63ef04000000b005c701bf0e27si1049195pgh.79.2024.01.18.00.29.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 00:29:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29871-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A5KCACn9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29871-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29871-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 89708282B2E for ; Thu, 18 Jan 2024 08:29:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B3BF2D635; Thu, 18 Jan 2024 08:23:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A5KCACn9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E79B81CFA4; Thu, 18 Jan 2024 08:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705566180; cv=none; b=UOjnG4Dbi0TndEdABD2vnBV4+eW+Sw9RBK6KNY7Br9d4Kx2yqegoZgrar0dYwhTZboZCc4AkycRQW/IEU02rNWak4pz65hAhwRw7NMj487Qs1QDYetPBM2wHQxPf6lcdKGnyHQwycp5iRqugRh+MKLjN5lujvRDtxCOMn2YfxxQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705566180; c=relaxed/simple; bh=IwsnoVL40Seia7ieHtkXTazSUMg+LsPrLcHHO9wOjQw=; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Endpoint-Received:X-Original-From:Reply-To; b=uy0+WIeHp04f2Mkas6hh19qOL2iSIJ2ywp4Q4WEFc04JtC5Z5lmPG9IUVVTXEEUZOy2Qs/1xOFy1TF/fiitaG7jb6ZslEaCxWpzmRoCf/fVIdGmoASmqgl3WD1VffSVKCwuseeDaBinzTMLiWAZkVCpagkKY0bvLuuYA3syMy0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A5KCACn9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 85090C3278B; Thu, 18 Jan 2024 08:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705566179; bh=IwsnoVL40Seia7ieHtkXTazSUMg+LsPrLcHHO9wOjQw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=A5KCACn9FlEE6w4rmYoiGi5pZHWKyEu1eEPaMbfQxq0CnrvdIzvwYyAa4zkmUfIvC IUiihBYrok5Ld1DDRBJedCXSJlUMTQqm8y1oi+6wJ2yALNTMHGtzaTcvByaVkTp4aQ ikdAGDCf6vXJPCvHMwXkYAWnHjydazKzTqXJha5XgpuZOcq8wkNcRJtqhUrqH2LTrN ujaQ9tvLRDGbrC9OHGWc4Bsnpjr3UAFUJn9yotA2UQE6x7tliXnpRD0cOKnzt5jJEW yjcOhM0kxfSUGWweyNHvirwDOFWrGGyklNXa+2AkXdwKgEp9M1sLqh1fI6Gfp62XoB xvyu2w6eQ6HcQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 753A4C47DB7; Thu, 18 Jan 2024 08:22:59 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Thu, 18 Jan 2024 11:21:01 +0300 Subject: [PATCH v7 18/39] net: cirrus: add DT support for Cirrus EP93xx Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240118-ep93xx-v7-18-d953846ae771@maquefel.me> References: <20240118-ep93xx-v7-0-d953846ae771@maquefel.me> In-Reply-To: <20240118-ep93xx-v7-0-d953846ae771@maquefel.me> To: Hartley Sweeten , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Andrew Lunn X-Mailer: b4 0.13-dev-e3e53 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705566176; l=4277; i=nikita.shubin@maquefel.me; s=20230718; h=from:subject:message-id; bh=x6ZnXV1oThsVaPrWIGHega7PwzPAvDvTbcixlLvrbzs=; =?utf-8?q?b=3DBqo6U53TLNfZ?= =?utf-8?q?A3grJiZLVc5Sbfh2Td6DcrWzKVcri77s/LKdgtDoK+UQXVgVMEhQiU0Th9zG/VXr?= TbdyXHBgDn/47bQi/QtmkPORvvk7ThWZZIs1HUPcR6qaQFlOnsl3 X-Developer-Key: i=nikita.shubin@maquefel.me; a=ed25519; pk=vqf5YIUJ7BJv3EJFaNNxWZgGuMgDH6rwufTLflwU9ac= X-Endpoint-Received: by B4 Relay for nikita.shubin@maquefel.me/20230718 with auth_id=65 X-Original-From: Nikita Shubin Reply-To: From: Nikita Shubin - add OF ID match table - get phy_id from the device tree, as part of mdio - copy_addr is now always used, as there is no SoC/board that aren't - dropped platform header Reviewed-by: Andrew Lunn Tested-by: Alexander Sverdlin Reviewed-by: Linus Walleij Signed-off-by: Nikita Shubin --- drivers/net/ethernet/cirrus/ep93xx_eth.c | 63 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c index 1c2a540db13d..be0b11014af7 100644 --- a/drivers/net/ethernet/cirrus/ep93xx_eth.c +++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c @@ -16,13 +16,12 @@ #include #include #include +#include #include #include #include #include -#include - #define DRV_MODULE_NAME "ep93xx-eth" #define RX_QUEUE_ENTRIES 64 @@ -738,25 +737,6 @@ static const struct net_device_ops ep93xx_netdev_ops = { .ndo_set_mac_address = eth_mac_addr, }; -static struct net_device *ep93xx_dev_alloc(struct ep93xx_eth_data *data) -{ - struct net_device *dev; - - dev = alloc_etherdev(sizeof(struct ep93xx_priv)); - if (dev == NULL) - return NULL; - - eth_hw_addr_set(dev, data->dev_addr); - - dev->ethtool_ops = &ep93xx_ethtool_ops; - dev->netdev_ops = &ep93xx_netdev_ops; - - dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; - - return dev; -} - - static void ep93xx_eth_remove(struct platform_device *pdev) { struct net_device *dev; @@ -786,27 +766,47 @@ static void ep93xx_eth_remove(struct platform_device *pdev) static int ep93xx_eth_probe(struct platform_device *pdev) { - struct ep93xx_eth_data *data; struct net_device *dev; struct ep93xx_priv *ep; struct resource *mem; + void __iomem *base_addr; + struct device_node *np; + u32 phy_id; int irq; int err; if (pdev == NULL) return -ENODEV; - data = dev_get_platdata(&pdev->dev); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); irq = platform_get_irq(pdev, 0); if (!mem || irq < 0) return -ENXIO; - dev = ep93xx_dev_alloc(data); + base_addr = ioremap(mem->start, resource_size(mem)); + if (!base_addr) + return dev_err_probe(&pdev->dev, -EIO, "Failed to ioremap ethernet registers\n"); + + np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); + if (!np) + return dev_err_probe(&pdev->dev, -ENODEV, "Please provide \"phy-handle\"\n"); + + err = of_property_read_u32(np, "reg", &phy_id); + of_node_put(np); + if (err) + return dev_err_probe(&pdev->dev, -ENOENT, "Failed to locate \"phy_id\"\n"); + + dev = alloc_etherdev(sizeof(struct ep93xx_priv)); if (dev == NULL) { err = -ENOMEM; goto err_out; } + + eth_hw_addr_set(dev, base_addr + 0x50); + dev->ethtool_ops = &ep93xx_ethtool_ops; + dev->netdev_ops = &ep93xx_netdev_ops; + dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; + ep = netdev_priv(dev); ep->dev = dev; SET_NETDEV_DEV(dev, &pdev->dev); @@ -822,15 +822,10 @@ static int ep93xx_eth_probe(struct platform_device *pdev) goto err_out; } - ep->base_addr = ioremap(mem->start, resource_size(mem)); - if (ep->base_addr == NULL) { - dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n"); - err = -EIO; - goto err_out; - } + ep->base_addr = base_addr; ep->irq = irq; - ep->mii.phy_id = data->phy_id; + ep->mii.phy_id = phy_id; ep->mii.phy_id_mask = 0x1f; ep->mii.reg_num_mask = 0x1f; ep->mii.dev = dev; @@ -857,12 +852,18 @@ static int ep93xx_eth_probe(struct platform_device *pdev) return err; } +static const struct of_device_id ep93xx_eth_of_ids[] = { + { .compatible = "cirrus,ep9301-eth" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ep93xx_eth_of_ids); static struct platform_driver ep93xx_eth_driver = { .probe = ep93xx_eth_probe, .remove_new = ep93xx_eth_remove, .driver = { .name = "ep93xx-eth", + .of_match_table = ep93xx_eth_of_ids, }, }; -- 2.41.0