From: Alexander Sverdlin <alexander.sverdlin@gmail.com>
To: Nikita Shubin <nikita.shubin@maquefel.me>,
Arnd Bergmann <arnd@arndb.de>,
Linus Walleij <linus.walleij@linaro.org>,
Hartley Sweeten <hsweeten@visionengravers.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Michael Peters <mpeters@embeddedTS.com>,
Kris Bahnsen <kris@embeddedTS.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx
Date: Sun, 04 Jun 2023 17:51:52 +0200 [thread overview]
Message-ID: <56eaf569893c0cd6505b4dc975c4d892f9c96603.camel@gmail.com> (raw)
In-Reply-To: <20230601054549.10843-2-nikita.shubin@maquefel.me>
Hi!
On Thu, 2023-06-01 at 08:45 +0300, Nikita Shubin wrote:
> - find register range from the device tree
> - get "copy_addr" from the device tree
> - get phy_id from the device tree
>
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Works fine on EDB9302
Tested-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> ---
>
> Notes:
> v0 -> v1:
>
> - dropped platform data entirely
> - dropped copy_addr
> - use phy-handle instead of using non-conventional phy-id
>
> arch/arm/mach-ep93xx/platform.h | 2 +-
> drivers/net/ethernet/cirrus/ep93xx_eth.c | 67 +++++++++++++-----------
> 2 files changed, 37 insertions(+), 32 deletions(-)
>
> diff --git a/arch/arm/mach-ep93xx/platform.h b/arch/arm/mach-ep93xx/platform.h
> index 5fb1b919133f..3cf2113491d8 100644
> --- a/arch/arm/mach-ep93xx/platform.h
> +++ b/arch/arm/mach-ep93xx/platform.h
> @@ -5,8 +5,8 @@
>
> #ifndef __ASSEMBLY__
>
> -#include <linux/platform_data/eth-ep93xx.h>
> #include <linux/reboot.h>
> +#include <linux/platform_data/eth-ep93xx.h>
>
> struct device;
> struct i2c_board_info;
> diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c
> index 8627ab19d470..41096d4830ff 100644
> --- a/drivers/net/ethernet/cirrus/ep93xx_eth.c
> +++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c
> @@ -17,12 +17,11 @@
> #include <linux/interrupt.h>
> #include <linux/moduleparam.h>
> #include <linux/platform_device.h>
> +#include <linux/of.h>
> #include <linux/delay.h>
> #include <linux/io.h>
> #include <linux/slab.h>
>
> -#include <linux/platform_data/eth-ep93xx.h>
> -
> #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,51 @@ 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) {
> + dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
> + return -EIO;
> + }
> +
> + np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
> + if (!np) {
> + dev_err(&pdev->dev, "Please provide \"phy-handle\"\n");
> + return -ENODEV;
> + }
> +
> + if (of_property_read_u32(np, "reg", &phy_id)) {
> + dev_err(&pdev->dev, "Failed to locate \"phy_id\"\n");
> + return -ENOENT;
> + }
> +
> + 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 +828,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 +858,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,
> },
> };
>
--
Alexander Sverdlin.
prev parent reply other threads:[~2023-06-04 15:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 12:34 [PATCH 00/43] ep93xx device tree conversion Nikita Shubin
2023-04-24 11:31 ` Arnd Bergmann
[not found] ` <20230424152933.48b2ede1@kernel.org>
2023-04-25 9:20 ` Krzysztof Kozlowski
2023-04-25 13:27 ` Arnd Bergmann
2023-04-24 12:34 ` [PATCH 18/43] dt-bindings: net: Add DT bindings ep93xx eth Nikita Shubin
2023-04-24 16:11 ` Rob Herring
[not found] ` <7f05ecdc-cbbd-40b0-9a40-229e18aec721@lunn.ch>
2023-05-15 13:42 ` Nikita Shubin
2023-04-24 12:34 ` [PATCH 19/43] net: cirrus: add DT support for Cirrus EP93xx Nikita Shubin
2023-04-26 20:56 ` [PATCH 00/43] ep93xx device tree conversion Linus Walleij
[not found] ` <b5396ef5-3fed-4e98-8f37-a9cd4473bddc@sirena.org.uk>
2023-04-26 21:06 ` Linus Walleij
2023-05-16 3:47 ` Florian Fainelli
2023-05-16 10:37 ` Nikita Shubin
2023-06-01 5:45 ` [PATCH v1 19/43] dt-bindings: net: Add Cirrus EP93xx Nikita Shubin
2023-06-01 5:45 ` [PATCH v1 20/43] net: cirrus: add DT support for " Nikita Shubin
2023-06-02 7:27 ` Linus Walleij
2023-06-02 12:09 ` Andrew Lunn
2023-06-03 20:30 ` andy.shevchenko
2023-06-04 15:51 ` Alexander Sverdlin [this message]
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=56eaf569893c0cd6505b4dc975c4d892f9c96603.camel@gmail.com \
--to=alexander.sverdlin@gmail.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hsweeten@visionengravers.com \
--cc=kris@embeddedTS.com \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mpeters@embeddedTS.com \
--cc=netdev@vger.kernel.org \
--cc=nikita.shubin@maquefel.me \
--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;
as well as URLs for NNTP newsgroup(s).