Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4504036rdb; Fri, 15 Sep 2023 04:31:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHS7zXbGsazPyRCXSt5cUcb0VTnmmBL+n3VPJUL3Y7SjDWCdVrXlpKVlWRHgldC1kG0/6bb X-Received: by 2002:a05:6a00:178c:b0:68f:ba5d:c7c8 with SMTP id s12-20020a056a00178c00b0068fba5dc7c8mr1519697pfg.10.1694777466756; Fri, 15 Sep 2023 04:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694777466; cv=none; d=google.com; s=arc-20160816; b=TjBTmfjIvU392ocoMw5j1jtWM9wRm539AciJXDwt1il7Ph5H34SXAOaWC62eAqw6px c2qDHEucGtBMdkZxXicIWX7utngzimeXxlwmceVm66prMoWe6iB0XppRCFdkQJPbUeM8 weYuUMOjDZ0AGZBaohlhgWLdyTpdnTdUxX58OJrTsCWVcvlT3AEU9f/FGU6ca0KFwlZ0 v2hElN44oNK1w3J/v8y849dHok3OMqILOYycZBEVymA2or1MMSi6QE1aBum1jw5lEG+Z dyBf7B9el1dajQllHc5wqAqErGdJtanCPNXQDPXh6I4pnI0Ei3/CffRw8k2rVv8ScsZ7 2deg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=74jWxhzPiaPB26v+cTD+7rFhygUJu5XDlyu/xoImVIU=; fh=TqMaEVKIqulpeXgqAxw8nzOQsegrboiEixWRA9pw018=; b=T3+3joLssaU/XiHD+oNemVzG045noJEdB2DaQRraq2twS7/+v9NUh7jGPtBw9FZrLH 5enkfW/j0aXurNI6JiafQMOC53UguRnaVp1q7J0tpgpaikM996uDNlL3v4/ZFhGVwm9k lPJd+0V2QD8h1JX2yWoNU+dcM4+6ydKupA6aPRgS9mxN0+SWdPHWCBnR+083xL4n2ORI k0thfCXIQiIqtqz+NZW/6iEC5/UgePdbsu8R6/nniCZzoQNlneOfCJhEr9gEhZ8H6W69 apxiGknzwk3WZVvwGvUTwi5yl0SIaq12f1i9My7q/PvNjL+bOzTf+Pl+O+B8bHUnpgI+ O0xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a+EMsNxb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y3-20020a636403000000b00577d99bd05esi3174696pgb.743.2023.09.15.04.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 04:31:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a+EMsNxb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 39BB78327F83; Fri, 15 Sep 2023 01:13:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233156AbjIOINK (ORCPT + 99 others); Fri, 15 Sep 2023 04:13:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232987AbjIOIMn (ORCPT ); Fri, 15 Sep 2023 04:12:43 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F592272D for ; Fri, 15 Sep 2023 01:12:13 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPS id 72051C116B1; Fri, 15 Sep 2023 08:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694765529; bh=y9p3UYAIMJYjb40CC2T6cih6I1fY4W9Hbg/V6sTn8TY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=a+EMsNxbv65R0S68VXBg/YQjWQdnESJwPYzIgKQ9hNwkqXRaVMlOaEMFTn0+1YCVr g0N4tGIDPk25hgEtlsF0cR+0xgrEdhyCwWcs95bImZC7ZM0Pr9+a4e4sWWKMYISIUJ HPDj6EsANQd4WH7wW4D4IERfp7eCqDW/vtQAKzVYQaB5mCUWkEyejShOA9andrZBrh 16EJopjAK/9GCwNPCU4a5vcAz2p5KrWA0EGlAbcukRBNcsbHBby+se7OCfLtEScVuu dP8m3jneIpw2fYVBAHtO/YC/jaykC7VVmwilIFM2BUacSOkNkzk83VkjFDpz/l9JHd 3mfqa1YW++rxQ== 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 5EA92EE6436; Fri, 15 Sep 2023 08:12:09 +0000 (UTC) From: Nikita Shubin via B4 Relay Date: Fri, 15 Sep 2023 11:11:04 +0300 Subject: [PATCH v4 22/42] net: cirrus: add DT support for Cirrus EP93xx MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230915-ep93xx-v4-22-a1d779dcec10@maquefel.me> References: <20230915-ep93xx-v4-0-a1d779dcec10@maquefel.me> In-Reply-To: <20230915-ep93xx-v4-0-a1d779dcec10@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 , Alexander Sverdlin , Andrew Lunn X-Mailer: b4 0.13-dev-e3e53 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694765525; l=4243; i=nikita.shubin@maquefel.me; s=20230718; h=from:subject:message-id; bh=eU0c+xJYiL6WXg+xPK7wne9lsQqNb34seN7qAKH0NSo=; =?utf-8?q?b=3DhlTb95jDHGyi?= =?utf-8?q?U+9gdcAS+r4p73ccnIxPPFRzGdo1wUr6Mt23BoOptBIP96EGc8xVjN2DP7KmqJ05?= m2MhCMi3CShYhmjDdntb7QpcyUgB3gc2nfdQbzEO9kWFQVlNpEHp 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: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 01:13:17 -0700 (PDT) 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 8627ab19d470..3106dd97fe74 100644 --- a/drivers/net/ethernet/cirrus/ep93xx_eth.c +++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c @@ -17,12 +17,11 @@ #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 int ep93xx_eth_remove(struct platform_device *pdev) { struct net_device *dev; @@ -788,27 +768,47 @@ static int 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); @@ -824,15 +824,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; @@ -859,12 +854,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 = ep93xx_eth_remove, .driver = { .name = "ep93xx-eth", + .of_match_table = ep93xx_eth_of_ids, }, }; -- 2.39.2