From patchwork Fri May 24 16:20:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1105025 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="plEXrYIt"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 459WnP5sccz9s1c for ; Sat, 25 May 2019 02:20:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390834AbfEXQUl (ORCPT ); Fri, 24 May 2019 12:20:41 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:39049 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390662AbfEXQUk (ORCPT ); Fri, 24 May 2019 12:20:40 -0400 Received: by mail-lf1-f66.google.com with SMTP id f1so7571186lfl.6 for ; Fri, 24 May 2019 09:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LoimZJhuiC3VDcIUaJDNR8VzM40c8PjtWlQoyk09Hqw=; b=plEXrYItN9TO/ik5u5tUB8RWHButrQ51yNOT5f7KnUxjmK4Rxk3qM6qh8r8ax5tGfw NtoJjyC8BM1nwS92a0ziPMwQZ2TxaHNz4Mvsqd4z7Rw9rArHGR3URX6i8fcBPbE+8WtM EvNohZtlaCxuoqZv9P4KfU3TukeCctqASewL66ptLjY+s2fKTj3NSzo8dYfyLaxvHRpj GnFwVRLoHCaFNJjHyiMcLXV/F3En0TXHAWCx17AsD0pj9uKFASY15bfQJhtjrBYSZqrd mq+zYtJvUrNhN+dLh3UVkFiJOVLaNMbEPY0ELUUP6cDzqOZEVkul5QmIssxP/O/mGYl+ MxhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LoimZJhuiC3VDcIUaJDNR8VzM40c8PjtWlQoyk09Hqw=; b=G0mxvF3TU/QOzBxI0wDeUm4kJ1xe+XEPsqDHBD4Jd323gw9ujiPMH+wijzI0Q+Hidh +2ZRQwSnC9fIwbbGczgLy51FDf5NlhyztPe6jZmq4h0HAEJAJtSiBnp23bdm0pzyh4mZ ECiA7c6w8wTQRkJ18DBAIDExsTgEI44H11be4TOAW8036znopQXOtNnlJjhbYT6FE9pe sYelnw1X/en9Q6sH9r2B7tRKB0Z+OAiGyoV2GHwpkKRL7fl8EgYN5+jvNJoWTJ13bUPY IQsTzzoxc8LiHS6GlAJq0HbKdOyfRa8tfoyWjM8/3ifupGOjzcbfIGXM9k0Daa72DMaK JfKA== X-Gm-Message-State: APjAAAXYXPD8E6gpP0j8E1BylnO2iCpeHiF1DTWhduwe9r5Tbhkk2+bz bz39IfZo9V6c83t43iIZnxqaOSbELUQ= X-Google-Smtp-Source: APXvYqym3pmqT3PgU9V9DAZ4CXF/TiYaQn67g4W4XlZbNGBfeVqHLa5g6Po+80DLaGRNZ9LcKqxg1A== X-Received: by 2002:ac2:4312:: with SMTP id l18mr39444415lfh.139.1558714837493; Fri, 24 May 2019 09:20:37 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-d2cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.210]) by smtp.gmail.com with ESMTPSA id y4sm618075lje.24.2019.05.24.09.20.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:20:36 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Krzysztof Halasa , Linus Walleij Subject: [PATCH 1/8] net: ethernet: ixp4xx: Standard module init Date: Fri, 24 May 2019 18:20:16 +0200 Message-Id: <20190524162023.9115-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162023.9115-1-linus.walleij@linaro.org> References: <20190524162023.9115-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The IXP4xx driver was initializing the MDIO bus before even probing, in the callbacks supposed to be used for setting up the module itself, and with the side effect of trying to register the MDIO bus as soon as this module was loaded or compiled into the kernel whether the device was discovered or not. This does not work with multiplatform environments. To get rid of this: set up the MDIO bus from the probe() callback and remove it in the remove() callback. Rename the probe() and remove() calls to reflect the most common conventions. Since there is a bit of checking for the ethernet feature to be present in the MDIO registering function, making the whole module not even be registered if we can't find an MDIO bus, we need something similar: register the MDIO bus when the corresponding ethernet is probed, and return -EPROBE_DEFER on the other interfaces until this happens. If no MDIO bus is present on any of the registered interfaces we will eventually bail out. None of the platforms I've seen has e.g. MDIO on EthB and only uses EthC, there is always a Ethernet hardware on the NPE (B, C) that has the MDIO bus, we just might have to wait for it. Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 82 ++++++++++++------------ 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 319db3ece263..ae69836d0080 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -521,25 +521,14 @@ static int ixp4xx_mdio_write(struct mii_bus *bus, int phy_id, int location, return ret; } -static int ixp4xx_mdio_register(void) +static int ixp4xx_mdio_register(struct eth_regs __iomem *regs) { int err; if (!(mdio_bus = mdiobus_alloc())) return -ENOMEM; - if (cpu_is_ixp43x()) { - /* IXP43x lacks NPE-B and uses NPE-C for MII PHY access */ - if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEC_ETH)) - return -ENODEV; - mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT; - } else { - /* All MII PHY accesses use NPE-B Ethernet registers */ - if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEB_ETH0)) - return -ENODEV; - mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT; - } - + mdio_regs = regs; __raw_writel(DEFAULT_CORE_CNTRL, &mdio_regs->core_control); spin_lock_init(&mdio_lock); mdio_bus->name = "IXP4xx MII Bus"; @@ -1378,7 +1367,7 @@ static const struct net_device_ops ixp4xx_netdev_ops = { .ndo_validate_addr = eth_validate_addr, }; -static int eth_init_one(struct platform_device *pdev) +static int ixp4xx_eth_probe(struct platform_device *pdev) { struct port *port; struct net_device *dev; @@ -1398,14 +1387,46 @@ static int eth_init_one(struct platform_device *pdev) switch (port->id) { case IXP4XX_ETH_NPEA: + /* If the MDIO bus is not up yet, defer probe */ + if (!mdio_bus) + return -EPROBE_DEFER; port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT; regs_phys = IXP4XX_EthA_BASE_PHYS; break; case IXP4XX_ETH_NPEB: + /* + * On all except IXP43x, NPE-B is used for the MDIO bus. + * If there is no NPE-B in the feature set, bail out, else + * register the MDIO bus. + */ + if (!cpu_is_ixp43x()) { + if (!(ixp4xx_read_feature_bits() & + IXP4XX_FEATURE_NPEB_ETH0)) + return -ENODEV; + /* Else register the MDIO bus on NPE-B */ + if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT))) + return err; + } + if (!mdio_bus) + return -EPROBE_DEFER; port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT; regs_phys = IXP4XX_EthB_BASE_PHYS; break; case IXP4XX_ETH_NPEC: + /* + * IXP43x lacks NPE-B and uses NPE-C for the MDIO bus access, + * of there is no NPE-C, no bus, nothing works, so bail out. + */ + if (cpu_is_ixp43x()) { + if (!(ixp4xx_read_feature_bits() & + IXP4XX_FEATURE_NPEC_ETH)) + return -ENODEV; + /* Else register the MDIO bus on NPE-C */ + if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT))) + return err; + } + if (!mdio_bus) + return -EPROBE_DEFER; port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT; regs_phys = IXP4XX_EthC_BASE_PHYS; break; @@ -1474,7 +1495,7 @@ static int eth_init_one(struct platform_device *pdev) return err; } -static int eth_remove_one(struct platform_device *pdev) +static int ixp4xx_eth_remove(struct platform_device *pdev) { struct net_device *dev = platform_get_drvdata(pdev); struct phy_device *phydev = dev->phydev; @@ -1482,6 +1503,7 @@ static int eth_remove_one(struct platform_device *pdev) unregister_netdev(dev); phy_disconnect(phydev); + ixp4xx_mdio_remove(); npe_port_tab[NPE_ID(port->id)] = NULL; npe_release(port->npe); release_resource(port->mem_res); @@ -1491,36 +1513,12 @@ static int eth_remove_one(struct platform_device *pdev) static struct platform_driver ixp4xx_eth_driver = { .driver.name = DRV_NAME, - .probe = eth_init_one, - .remove = eth_remove_one, + .probe = ixp4xx_eth_probe, + .remove = ixp4xx_eth_remove, }; - -static int __init eth_init_module(void) -{ - int err; - - /* - * FIXME: we bail out on device tree boot but this really needs - * to be fixed in a nicer way: this registers the MDIO bus before - * even matching the driver infrastructure, we should only probe - * detected hardware. - */ - if (of_have_populated_dt()) - return -ENODEV; - if ((err = ixp4xx_mdio_register())) - return err; - return platform_driver_register(&ixp4xx_eth_driver); -} - -static void __exit eth_cleanup_module(void) -{ - platform_driver_unregister(&ixp4xx_eth_driver); - ixp4xx_mdio_remove(); -} +module_platform_driver(ixp4xx_eth_driver); MODULE_AUTHOR("Krzysztof Halasa"); MODULE_DESCRIPTION("Intel IXP4xx Ethernet driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:ixp4xx_eth"); -module_init(eth_init_module); -module_exit(eth_cleanup_module); From patchwork Fri May 24 16:20:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1105026 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NjZRAoLx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 459WnV5RQrz9s1c for ; Sat, 25 May 2019 02:20:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390874AbfEXQUp (ORCPT ); Fri, 24 May 2019 12:20:45 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:37598 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390662AbfEXQUp (ORCPT ); Fri, 24 May 2019 12:20:45 -0400 Received: by mail-lf1-f67.google.com with SMTP id m15so6970605lfh.4 for ; Fri, 24 May 2019 09:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+YTaRWfG9Yuoc1VN58/KFdiQHjekpSnoND3oo5X7AWA=; b=NjZRAoLxo+Ip5dEbPdESYrjYCfaLVSmU05FgO/wDT0mwXn769CYCivZYZEUqwqYZ0r ud5tTPimwETjf05D9g8zyAXhWvzxQXH26CjXkKw22blyRIS1PMn2ZjWgJDn/Ga3a2xBf CC6Vo68JmkGQCDekb3KZvNQQ4cgW7C8bqJJevS/WoUM8wYlMg/hn2Arc78ny0rLmUduN PY4lV8VQNpXtPA+NZDtxNPsP/L61POrZ1OUmQs083KUiiYaKcxgumRVcHwMJ3raAhZ9O 6hji68iQWJeQNo/bD22kEw29OP2Bnh+OSlstU/mA/uPt+u+dRNkdHZb9JEch7wEZ7/4K r2rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+YTaRWfG9Yuoc1VN58/KFdiQHjekpSnoND3oo5X7AWA=; b=l/ZHUnoAc9fY1yjY7SZrFLSkmmkC1krbzuL1ZaUWHD56aSPqvvkm8HjdqfWlae3JtB YnLBN3Z60K7iCRtohGpDxVu5Icx5oEB+U5NTSYuo/QQ4Lxs0mgGUWtdWKLn8LlxvaBek MjL/ZZQsv2KJ1DnXJr/Yb4mwHyBp/QsTxQYmc9LjHwTCehNI7cfEpJHoapOZfnFaSe2T pis0/mMPiOSEEKXXLPntPJBIlLUuD1OlCCQVs1IiivoQ1pSZlwaxale8F/O6h4t1sypS 1iyQY1RQyeTQJ+B30LykOGa6tOfYOVnYixB1BQMZ4pZ7DM2fDFe01CEjCLjkjgW3gHYN 7jUg== X-Gm-Message-State: APjAAAXk0zhdD++PERqoKoGCWnvXGtCyjdt2KzrFYoFMKrgrvefWjvNm Yb+L3IWuzms6P8wYxosyavLIEGqD+HE= X-Google-Smtp-Source: APXvYqx7j3ZfuK71RqYfUCuZn9nSibcP1yzz0ipyn1zKNeIsPoofBGmz8PtIl5eu8FQE9wF71cs1Cw== X-Received: by 2002:ac2:528f:: with SMTP id q15mr33624519lfm.37.1558714842202; Fri, 24 May 2019 09:20:42 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-d2cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.210]) by smtp.gmail.com with ESMTPSA id y4sm618075lje.24.2019.05.24.09.20.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:20:41 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Krzysztof Halasa , Linus Walleij Subject: [PATCH 2/8] net: ethernet: ixp4xx: Use distinct local variable Date: Fri, 24 May 2019 18:20:17 +0200 Message-Id: <20190524162023.9115-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162023.9115-1-linus.walleij@linaro.org> References: <20190524162023.9115-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use "ndev" for the struct net_device and "dev" for the struct device in probe() and remove(). Add the local "dev" pointer for later use in refactoring. Take this opportunity to fix inverse christmas tree coding style. Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 51 +++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index ae69836d0080..a0c02458f456 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1369,20 +1369,23 @@ static const struct net_device_ops ixp4xx_netdev_ops = { static int ixp4xx_eth_probe(struct platform_device *pdev) { - struct port *port; - struct net_device *dev; - struct eth_plat_info *plat = dev_get_platdata(&pdev->dev); + char phy_id[MII_BUS_ID_SIZE + 3]; struct phy_device *phydev = NULL; + struct device *dev = &pdev->dev; + struct eth_plat_info *plat; + struct net_device *ndev; + struct port *port; u32 regs_phys; - char phy_id[MII_BUS_ID_SIZE + 3]; int err; - if (!(dev = alloc_etherdev(sizeof(struct port)))) + plat = dev_get_platdata(dev); + + if (!(ndev = alloc_etherdev(sizeof(struct port)))) return -ENOMEM; - SET_NETDEV_DEV(dev, &pdev->dev); - port = netdev_priv(dev); - port->netdev = dev; + SET_NETDEV_DEV(ndev, dev); + port = netdev_priv(ndev); + port->netdev = ndev; port->id = pdev->id; switch (port->id) { @@ -1435,18 +1438,18 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) goto err_free; } - dev->netdev_ops = &ixp4xx_netdev_ops; - dev->ethtool_ops = &ixp4xx_ethtool_ops; - dev->tx_queue_len = 100; + ndev->netdev_ops = &ixp4xx_netdev_ops; + ndev->ethtool_ops = &ixp4xx_ethtool_ops; + ndev->tx_queue_len = 100; - netif_napi_add(dev, &port->napi, eth_poll, NAPI_WEIGHT); + netif_napi_add(ndev, &port->napi, eth_poll, NAPI_WEIGHT); if (!(port->npe = npe_request(NPE_ID(port->id)))) { err = -EIO; goto err_free; } - port->mem_res = request_mem_region(regs_phys, REGS_SIZE, dev->name); + port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name); if (!port->mem_res) { err = -EBUSY; goto err_npe_rel; @@ -1454,9 +1457,9 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) port->plat = plat; npe_port_tab[NPE_ID(port->id)] = port; - memcpy(dev->dev_addr, plat->hwaddr, ETH_ALEN); + memcpy(ndev->dev_addr, plat->hwaddr, ETH_ALEN); - platform_set_drvdata(pdev, dev); + platform_set_drvdata(pdev, ndev); __raw_writel(DEFAULT_CORE_CNTRL | CORE_RESET, &port->regs->core_control); @@ -1466,7 +1469,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, mdio_bus->id, plat->phy); - phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, + phydev = phy_connect(ndev, phy_id, &ixp4xx_adjust_link, PHY_INTERFACE_MODE_MII); if (IS_ERR(phydev)) { err = PTR_ERR(phydev); @@ -1475,10 +1478,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) phydev->irq = PHY_POLL; - if ((err = register_netdev(dev))) + if ((err = register_netdev(ndev))) goto err_phy_dis; - printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy, + printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy, npe_name(port->npe)); return 0; @@ -1491,23 +1494,23 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) err_npe_rel: npe_release(port->npe); err_free: - free_netdev(dev); + free_netdev(ndev); return err; } static int ixp4xx_eth_remove(struct platform_device *pdev) { - struct net_device *dev = platform_get_drvdata(pdev); - struct phy_device *phydev = dev->phydev; - struct port *port = netdev_priv(dev); + struct net_device *ndev = platform_get_drvdata(pdev); + struct phy_device *phydev = ndev->phydev; + struct port *port = netdev_priv(ndev); - unregister_netdev(dev); + unregister_netdev(ndev); phy_disconnect(phydev); ixp4xx_mdio_remove(); npe_port_tab[NPE_ID(port->id)] = NULL; npe_release(port->npe); release_resource(port->mem_res); - free_netdev(dev); + free_netdev(ndev); return 0; } From patchwork Fri May 24 16:20:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1105027 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="i6xELpGR"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 459WnY436Bz9s1c for ; Sat, 25 May 2019 02:20:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390885AbfEXQUs (ORCPT ); Fri, 24 May 2019 12:20:48 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41972 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390662AbfEXQUs (ORCPT ); Fri, 24 May 2019 12:20:48 -0400 Received: by mail-lj1-f194.google.com with SMTP id q16so794534ljj.8 for ; Fri, 24 May 2019 09:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FHdSK5ctE9Fl6lcAriQFgB7IwJUTOwGKZw22HMzJTEE=; b=i6xELpGRMdbIkrAGCt9rzvt5XKPqayXijqBWHfJqxlTfim7PKZjNS8O8kxOS5PIfTq CAox9ya/TJ2LHsoA9iE/VSJMSmCWZXkm05DxoIYYKQT6FHkUD5MPEMW/ppRdycDXmVli 2Z3REwBfzxGS/NFADjflmVD5mITdtq3iYy8J0+3MT4E/T4MM9sYC6DMvnIEJJzi2XMTD ZSzSCVwYNVXl6jnoRubK7hK21GbyYJzXpKcpbsFjTXKoIy4Ooo10qjq+ZXvAkN+yEg2j vOp0v9f9kN9W3ROveoNLlUIQmvvYy1SMzvMM3lMZYFbmHrbr4Xl64Isr/v6JQvVP4pdM pAhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FHdSK5ctE9Fl6lcAriQFgB7IwJUTOwGKZw22HMzJTEE=; b=YZT9c/AHvBZJD63WA7olCwGL0DpuMib6FTElVRIiYb3n/t9y4u+kI5THPBJ2Tpv/cr i/UA8LkrhIZZWuwLmmcGtRjwUsDQc25ijLpad+8ga+qAk3B5NpZdWgmk7Vig1r6/CXEL AAcYIZj2i/vyPYnnF6z6aGXJTJY36oeiVvFEavAueBugjdVfLkr2cFZAr8BZq1ET/a1M rNuJc0ScEFUKStxhTIgPq+Iq2hBTJ++IhTieGJHseL8cXGRPFW4HtnTpYXJxvF2atrWA UFGSoAh0N4HUDtWReAcz8m/27qGQEF5mxRY4Cd6lCZZGzrrTQdOZuA6cZPzP8JUiwDpG i0uA== X-Gm-Message-State: APjAAAXce+Z1xKl9v4Gcimm15vEDaEe+PI6Cm4BP+KwYmNe3KGCT9m/s HAYYq5hkYMYlj3Rra3Yk5SrEMytD4hc= X-Google-Smtp-Source: APXvYqwRwW3iWY8iE7eRVI8sAvifdKDk3FfvE18F2Dc2YKJd54cbtk2BgVWMWLWvCbLTQOK27H2MMg== X-Received: by 2002:a2e:7d02:: with SMTP id y2mr26588406ljc.62.1558714845915; Fri, 24 May 2019 09:20:45 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-d2cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.210]) by smtp.gmail.com with ESMTPSA id y4sm618075lje.24.2019.05.24.09.20.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:20:45 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Krzysztof Halasa , Linus Walleij Subject: [PATCH 3/8] net: ehernet: ixp4xx: Use devm_alloc_etherdev() Date: Fri, 24 May 2019 18:20:18 +0200 Message-Id: <20190524162023.9115-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162023.9115-1-linus.walleij@linaro.org> References: <20190524162023.9115-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Using the devm_alloc_etherdev() function simplifies the error path. I also patch the message to use dev_info(). Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index a0c02458f456..064ff0886cc3 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1380,7 +1380,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) plat = dev_get_platdata(dev); - if (!(ndev = alloc_etherdev(sizeof(struct port)))) + if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port)))) return -ENOMEM; SET_NETDEV_DEV(ndev, dev); @@ -1434,8 +1434,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) regs_phys = IXP4XX_EthC_BASE_PHYS; break; default: - err = -ENODEV; - goto err_free; + return -ENODEV; } ndev->netdev_ops = &ixp4xx_netdev_ops; @@ -1444,10 +1443,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) netif_napi_add(ndev, &port->napi, eth_poll, NAPI_WEIGHT); - if (!(port->npe = npe_request(NPE_ID(port->id)))) { - err = -EIO; - goto err_free; - } + if (!(port->npe = npe_request(NPE_ID(port->id)))) + return -EIO; port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name); if (!port->mem_res) { @@ -1481,8 +1478,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) if ((err = register_netdev(ndev))) goto err_phy_dis; - printk(KERN_INFO "%s: MII PHY %i on %s\n", ndev->name, plat->phy, - npe_name(port->npe)); + dev_info(dev, "%s: MII PHY %i on %s\n", ndev->name, plat->phy, + npe_name(port->npe)); return 0; @@ -1493,8 +1490,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) release_resource(port->mem_res); err_npe_rel: npe_release(port->npe); -err_free: - free_netdev(ndev); return err; } @@ -1510,7 +1505,6 @@ static int ixp4xx_eth_remove(struct platform_device *pdev) npe_port_tab[NPE_ID(port->id)] = NULL; npe_release(port->npe); release_resource(port->mem_res); - free_netdev(ndev); return 0; } From patchwork Fri May 24 16:20:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1105028 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dIOuYxlz"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 459Wng5X4rz9s1c for ; Sat, 25 May 2019 02:20:55 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390887AbfEXQUy (ORCPT ); Fri, 24 May 2019 12:20:54 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:37607 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390308AbfEXQUy (ORCPT ); Fri, 24 May 2019 12:20:54 -0400 Received: by mail-lf1-f67.google.com with SMTP id m15so6970932lfh.4 for ; Fri, 24 May 2019 09:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bBARK8vNqygviud0La4Tdob+SuFOP0uNrEGVX2JRO4E=; b=dIOuYxlzCPlrdhjwthLVuivPss5LuD4xVyueVHQ91FoB2wY0iWoO6xPgzPQOtyI8Xt ACv1EF/Yemp22Kjx9EN6iPAUh3k7+xqshCjkyOpsPoP7bG6LfBym6BgDlrpxfeo7ZhPa HJuwj++zt2nhZKLx1wPoDTnf2+Q8aqDlSkDRSpWjmzuthDv8EybGKbVdZ3v9hTZymwb/ CKiEu6unhmeqPl5sQcpbr96g9YBnRNg2LwPwsVbqzc402k5Ovjz0jdAYEhjUZaLckz/T lJn3cM9s0bLkHcunk4z6AqOxGkYdqCumfc9UJuC4FZhLAx4D8jZXBMelPewhgeyGWBZd WQUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bBARK8vNqygviud0La4Tdob+SuFOP0uNrEGVX2JRO4E=; b=n9oJOu0Znkfc5qLHmCiXhjKp17YbT2b4WDNzLeRQvDUT6/IVuK5S0ZVqAaXSs97TGZ lW8dwHASEcYRQRpIbQzEbfDX2993iwlpPxCQdDaOQBJ+K6J8O/2uTmplBpM6Zj87hegZ deIdg4jNSayuPwe5DQql9FRvltpxPiC6NB8XPebYABFavcCITg0PD71VvaT6opiTno6B gKc/X8U2jH4brqixmV8KNdG272VsEtohZusXdHO3L67bfcmLIRDzfNog7czc8A6yOxPd idkwe0M5TOm9FwlvQUeIXwq0gp5KE43OKRBeel4WF9ro9Tl2TXqOAGS32M6yVAFWGT93 BYkw== X-Gm-Message-State: APjAAAVWV6PVtq59TLhd1kkzTe647p1jFozAIcVY8Ea+I6SCgqmuAR/k qKGebbJg96PTEbAsoLFIpbvATPwrWz0= X-Google-Smtp-Source: APXvYqwcDI+/YHs4L/agtMWq45gAVG3L6wSyhOzpYhRfr31JMeUdGmbHIHaxjC0pageYG+wp5KLx2g== X-Received: by 2002:ac2:59c7:: with SMTP id x7mr13887342lfn.75.1558714848845; Fri, 24 May 2019 09:20:48 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-d2cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.210]) by smtp.gmail.com with ESMTPSA id y4sm618075lje.24.2019.05.24.09.20.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:20:48 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Krzysztof Halasa , Linus Walleij Subject: [PATCH 4/8] ARM/net: ixp4xx: Pass ethernet physical base as resource Date: Fri, 24 May 2019 18:20:19 +0200 Message-Id: <20190524162023.9115-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162023.9115-1-linus.walleij@linaro.org> References: <20190524162023.9115-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In order to probe this ethernet interface from the device tree all physical MMIO regions must be passed as resources. Begin this rewrite by first passing the port base address as a resource for all platforms using this driver, remap it in the driver and avoid using any reference of the statically mapped virtual address in the driver. Signed-off-by: Linus Walleij --- arch/arm/mach-ixp4xx/fsg-setup.c | 20 ++++++++++++++++++++ arch/arm/mach-ixp4xx/goramo_mlr.c | 20 ++++++++++++++++++++ arch/arm/mach-ixp4xx/ixdp425-setup.c | 20 ++++++++++++++++++++ arch/arm/mach-ixp4xx/nas100d-setup.c | 10 ++++++++++ arch/arm/mach-ixp4xx/nslu2-setup.c | 10 ++++++++++ arch/arm/mach-ixp4xx/omixp-setup.c | 20 ++++++++++++++++++++ arch/arm/mach-ixp4xx/vulcan-setup.c | 20 ++++++++++++++++++++ drivers/net/ethernet/xscale/ixp4xx_eth.c | 20 +++++++++++--------- 8 files changed, 131 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-ixp4xx/fsg-setup.c b/arch/arm/mach-ixp4xx/fsg-setup.c index 648932d8d7a8..507ee3878769 100644 --- a/arch/arm/mach-ixp4xx/fsg-setup.c +++ b/arch/arm/mach-ixp4xx/fsg-setup.c @@ -132,6 +132,22 @@ static struct platform_device fsg_leds = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource fsg_eth_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource fsg_eth_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info fsg_plat_eth[] = { { .phy = 5, @@ -151,12 +167,16 @@ static struct platform_device fsg_eth[] = { .dev = { .platform_data = fsg_plat_eth, }, + .num_resources = ARRAY_SIZE(fsg_eth_npeb_resources), + .resource = fsg_eth_npeb_resources, }, { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEC, .dev = { .platform_data = fsg_plat_eth + 1, }, + .num_resources = ARRAY_SIZE(fsg_eth_npec_resources), + .resource = fsg_eth_npec_resources, } }; diff --git a/arch/arm/mach-ixp4xx/goramo_mlr.c b/arch/arm/mach-ixp4xx/goramo_mlr.c index 4d805080020e..7db396cc4353 100644 --- a/arch/arm/mach-ixp4xx/goramo_mlr.c +++ b/arch/arm/mach-ixp4xx/goramo_mlr.c @@ -270,6 +270,22 @@ static struct platform_device device_uarts = { /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource eth_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource eth_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info eth_plat[] = { { .phy = 0, @@ -287,10 +303,14 @@ static struct platform_device device_eth_tab[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = eth_plat, + .num_resources = ARRAY_SIZE(eth_npeb_resources), + .resource = eth_npeb_resources, }, { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEC, .dev.platform_data = eth_plat + 1, + .num_resources = ARRAY_SIZE(eth_npec_resources), + .resource = eth_npec_resources, } }; diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c index 6f0f7ed18ea8..45d5b720ded6 100644 --- a/arch/arm/mach-ixp4xx/ixdp425-setup.c +++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c @@ -187,6 +187,22 @@ static struct platform_device ixdp425_uart = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource ixp425_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource ixp425_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info ixdp425_plat_eth[] = { { .phy = 0, @@ -204,10 +220,14 @@ static struct platform_device ixdp425_eth[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = ixdp425_plat_eth, + .num_resources = ARRAY_SIZE(ixp425_npeb_resources), + .resource = ixp425_npeb_resources, }, { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEC, .dev.platform_data = ixdp425_plat_eth + 1, + .num_resources = ARRAY_SIZE(ixp425_npec_resources), + .resource = ixp425_npec_resources, } }; diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c index c142cfa8c5d6..6959ad2e3aec 100644 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c @@ -165,6 +165,14 @@ static struct platform_device nas100d_uart = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource nas100d_eth_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info nas100d_plat_eth[] = { { .phy = 0, @@ -178,6 +186,8 @@ static struct platform_device nas100d_eth[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = nas100d_plat_eth, + .num_resources = ARRAY_SIZE(nas100d_eth_resources), + .resource = nas100d_eth_resources, } }; diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c index ee1877fcfafe..a428bb918703 100644 --- a/arch/arm/mach-ixp4xx/nslu2-setup.c +++ b/arch/arm/mach-ixp4xx/nslu2-setup.c @@ -185,6 +185,14 @@ static struct platform_device nslu2_uart = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource nslu2_eth_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info nslu2_plat_eth[] = { { .phy = 1, @@ -198,6 +206,8 @@ static struct platform_device nslu2_eth[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = nslu2_plat_eth, + .num_resources = ARRAY_SIZE(nslu2_eth_resources), + .resource = nslu2_eth_resources, } }; diff --git a/arch/arm/mach-ixp4xx/omixp-setup.c b/arch/arm/mach-ixp4xx/omixp-setup.c index 2d494b454376..6f86c27b725e 100644 --- a/arch/arm/mach-ixp4xx/omixp-setup.c +++ b/arch/arm/mach-ixp4xx/omixp-setup.c @@ -171,6 +171,22 @@ static struct platform_device mic256_leds = { }; /* Built-in 10/100 Ethernet MAC interfaces */ +static struct resource ixp425_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource ixp425_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info ixdp425_plat_eth[] = { { .phy = 0, @@ -188,10 +204,14 @@ static struct platform_device ixdp425_eth[] = { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEB, .dev.platform_data = ixdp425_plat_eth, + .num_resources = ARRAY_SIZE(ixp425_npeb_resources), + .resource = ixp425_npeb_resources, }, { .name = "ixp4xx_eth", .id = IXP4XX_ETH_NPEC, .dev.platform_data = ixdp425_plat_eth + 1, + .num_resources = ARRAY_SIZE(ixp425_npec_resources), + .resource = ixp425_npec_resources, }, }; diff --git a/arch/arm/mach-ixp4xx/vulcan-setup.c b/arch/arm/mach-ixp4xx/vulcan-setup.c index 2c03d2f6b647..783c291f8f4c 100644 --- a/arch/arm/mach-ixp4xx/vulcan-setup.c +++ b/arch/arm/mach-ixp4xx/vulcan-setup.c @@ -122,6 +122,22 @@ static struct platform_device vulcan_uart = { .num_resources = ARRAY_SIZE(vulcan_uart_resources), }; +static struct resource vulcan_npeb_resources[] = { + { + .start = IXP4XX_EthB_BASE_PHYS, + .end = IXP4XX_EthB_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource vulcan_npec_resources[] = { + { + .start = IXP4XX_EthC_BASE_PHYS, + .end = IXP4XX_EthC_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, +}; + static struct eth_plat_info vulcan_plat_eth[] = { [0] = { .phy = 0, @@ -142,6 +158,8 @@ static struct platform_device vulcan_eth[] = { .dev = { .platform_data = &vulcan_plat_eth[0], }, + .num_resources = ARRAY_SIZE(vulcan_npeb_resources), + .resource = vulcan_npeb_resources, }, [1] = { .name = "ixp4xx_eth", @@ -149,6 +167,8 @@ static struct platform_device vulcan_eth[] = { .dev = { .platform_data = &vulcan_plat_eth[1], }, + .num_resources = ARRAY_SIZE(vulcan_npec_resources), + .resource = vulcan_npec_resources, }, }; diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 064ff0886cc3..17d3291d79b4 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1373,9 +1373,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) struct phy_device *phydev = NULL; struct device *dev = &pdev->dev; struct eth_plat_info *plat; + resource_size_t regs_phys; struct net_device *ndev; + struct resource *res; struct port *port; - u32 regs_phys; int err; plat = dev_get_platdata(dev); @@ -1388,13 +1389,18 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) port->netdev = ndev; port->id = pdev->id; + /* Get the port resource and remap */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + regs_phys = res->start; + port->regs = devm_ioremap_resource(dev, res); + switch (port->id) { case IXP4XX_ETH_NPEA: /* If the MDIO bus is not up yet, defer probe */ if (!mdio_bus) return -EPROBE_DEFER; - port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT; - regs_phys = IXP4XX_EthA_BASE_PHYS; break; case IXP4XX_ETH_NPEB: /* @@ -1407,13 +1413,11 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) IXP4XX_FEATURE_NPEB_ETH0)) return -ENODEV; /* Else register the MDIO bus on NPE-B */ - if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT))) + if ((err = ixp4xx_mdio_register(port->regs))) return err; } if (!mdio_bus) return -EPROBE_DEFER; - port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT; - regs_phys = IXP4XX_EthB_BASE_PHYS; break; case IXP4XX_ETH_NPEC: /* @@ -1425,13 +1429,11 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) IXP4XX_FEATURE_NPEC_ETH)) return -ENODEV; /* Else register the MDIO bus on NPE-C */ - if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT))) + if ((err = ixp4xx_mdio_register(port->regs))) return err; } if (!mdio_bus) return -EPROBE_DEFER; - port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT; - regs_phys = IXP4XX_EthC_BASE_PHYS; break; default: return -ENODEV; From patchwork Fri May 24 16:20:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1105029 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YBQgvCjd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 459Wnk3NhJz9s1c for ; Sat, 25 May 2019 02:20:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390915AbfEXQU5 (ORCPT ); Fri, 24 May 2019 12:20:57 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37339 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390308AbfEXQU4 (ORCPT ); Fri, 24 May 2019 12:20:56 -0400 Received: by mail-lj1-f193.google.com with SMTP id h19so779581ljj.4 for ; Fri, 24 May 2019 09:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i7OSJeT4ISWaBZXsLc0uF5tUfx/CAFdEtfJjJMrSp3E=; b=YBQgvCjdVW+kRQYH8du/SNwiklf/u0MF0ZIQi9It1XN362K8HTZjGwTiuIg/1wvgBa geyae65n+B9tORTMWcOkfj7CHSsMJZI2wPlE/lcE4K9Y/UJmXeg0w18p+HSfGBz+cZZK HnEyRzyQREt3LXf5zLbOcMjg0Wj6rHZPm10d4NB3wUP2W0UzAwdepr4xLt3vWujc4LS8 fODByJ30U+or+7v/j3JU/1AKIf7Eky/u08Yx5pyDKHa7sUj+eHRnHwfrG/4/QdRrSeXs Muy8XFcSxZPIEafec+gyYngI3e739I2YF8WD4/MKKN3bJOoBqoM4zwHB9Qq/jfY6mpP3 aL6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i7OSJeT4ISWaBZXsLc0uF5tUfx/CAFdEtfJjJMrSp3E=; b=Ifa6ck0Vx1cvOClJq6qldI9luuhunf+SMCb5SrYA43uEyDBRLQJiBuj4lEeFOWWJxE s8bwu9J4EX5PZfFmqubo63FnuWyS54+eOuDcCnGbgZTi3anhbwTSZ30tTse3VEREmSF0 0DZiNjT0dvHOvrQH3z3blEK0C/CIQERjeaEZaUl5A8JMWsUfAPjLMsZgIhYu7AieEaWN O2VkGjhB4VebNyvvZAKvpBqovZwYS51GVCa2a58FFNtj5X5AqHNYf02cIY6laBFhmanl zICq6/q/iIVAHzp4Ris/9Gv4iXoBpox/KwEubEGTEHGJjndSFhkG4lnxC4r2jZNvnYF2 QKXg== X-Gm-Message-State: APjAAAWxpVhGQU52MOc5yAUmFFOB/ecsIiFC8Gvynu4GYwU9OrWDfYzN 1DOoLzx8rM+Zc2Qehh6A2P27GXKsHa8= X-Google-Smtp-Source: APXvYqw3rXafyUAXjeDwlUBnI3xFYbcL8U+K9coTazxDTvGEoOoo+M3fqiNo2r9kn2GHh10Oveif+g== X-Received: by 2002:a2e:8985:: with SMTP id c5mr8690449lji.84.1558714854437; Fri, 24 May 2019 09:20:54 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-d2cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.210]) by smtp.gmail.com with ESMTPSA id y4sm618075lje.24.2019.05.24.09.20.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:20:53 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Krzysztof Halasa , Linus Walleij Subject: [PATCH 5/8] net: ethernet: ixp4xx: Get port ID from base address Date: Fri, 24 May 2019 18:20:20 +0200 Message-Id: <20190524162023.9115-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162023.9115-1-linus.walleij@linaro.org> References: <20190524162023.9115-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The port->id was picked from the platform device .id field, but this is not supposed to be used for passing around random numbers in hardware. Identify the port ID number from the base address instead. Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 17d3291d79b4..600f62e95fb0 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1387,7 +1387,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) SET_NETDEV_DEV(ndev, dev); port = netdev_priv(ndev); port->netdev = ndev; - port->id = pdev->id; /* Get the port resource and remap */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1396,13 +1395,15 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) regs_phys = res->start; port->regs = devm_ioremap_resource(dev, res); - switch (port->id) { - case IXP4XX_ETH_NPEA: + switch (res->start) { + case 0xc800c000: + port->id = IXP4XX_ETH_NPEA; /* If the MDIO bus is not up yet, defer probe */ if (!mdio_bus) return -EPROBE_DEFER; break; - case IXP4XX_ETH_NPEB: + case 0xc8009000: + port->id = IXP4XX_ETH_NPEB; /* * On all except IXP43x, NPE-B is used for the MDIO bus. * If there is no NPE-B in the feature set, bail out, else @@ -1419,7 +1420,8 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) if (!mdio_bus) return -EPROBE_DEFER; break; - case IXP4XX_ETH_NPEC: + case 0xc800a000: + port->id = IXP4XX_ETH_NPEC; /* * IXP43x lacks NPE-B and uses NPE-C for the MDIO bus access, * of there is no NPE-C, no bus, nothing works, so bail out. From patchwork Fri May 24 16:20:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1105030 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="uzUrotqJ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 459Wnp3qcZz9s1c for ; Sat, 25 May 2019 02:21:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390955AbfEXQVB (ORCPT ); Fri, 24 May 2019 12:21:01 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40708 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390308AbfEXQVB (ORCPT ); Fri, 24 May 2019 12:21:01 -0400 Received: by mail-lj1-f195.google.com with SMTP id q62so9168361ljq.7 for ; Fri, 24 May 2019 09:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OUow8Idp71iR0dh6G9x5edE4axHg7RMQg95y9XAt+Qw=; b=uzUrotqJON7yaFM+63pGhO8BnKVC8rA4dQ1V6qpQcg/RxHN5VuTFGSNNknKMBm+y3N TO+f8PuACdU1PfzFIivAbYmEL5ec06Ko+Yf1HLj0GTXdrn+JTML7DTWqKG8cAN8BzKhQ PI8Jb9DLj0bmyHTLs48CvjYFeRrqGlGiidGvU8vBdM+qLslXTvqAsypukY/uFR/HX4O0 6TQXJsO6CbWF8rYtDV71mZYF7UncFr43bDt944mF2qmLPYl23sjBWr2vtWYgt2/IkMoG FsdoHKAtURbsf/sz2WqyP+riP+1RMZUUyBUUARRnMQqxMRay6jEF0u4iZwwjoPm/+8Ac FHAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OUow8Idp71iR0dh6G9x5edE4axHg7RMQg95y9XAt+Qw=; b=bNOd0DoGH6pB2zt2YDAcb29n6Ja9E2xdlpQ0YdaMFQ8YTMOPv95e0t217wANSF1+aw HEfqhYFlvrVhdsipBTWFuccsKooas1Fv6HQUsSe3av/YcSwpIN2OyInFtLkW2TJLpDlQ LdDjtvQat9DJjLUHJF/IuSxL3Y/HiwxsQ2XAujXGjtTMtKI5Oyh7UyE3bnF+JBZabpJU 0MxXvWHRHV4anICg2u+J3+1mq0kw/a1DR2HixgUhZHPIwKbHF/2Y09qaig2tTRqL5DOW Cr0uoU55kuDIvO7C3EapCeBnveRr+xy22tCc3SV+YhISts23lSt8WXeuCxyQ9R/maT/K ceDw== X-Gm-Message-State: APjAAAV/2ZUaQxoTh/B05VPJYy3s9q4yWpeTjP6QnvpPQmR9Rj9wzrwV +py3hGgoGM+1J0Z8CJvSnvNPIyR+Ju4= X-Google-Smtp-Source: APXvYqw70+XYarZcexEHcNX4Fvnh3w9WKcg0w70gu3yFdnYnSyKMl6Dwd76Zy0ze8VpkFiyjYWHhlQ== X-Received: by 2002:a2e:95d2:: with SMTP id y18mr30639520ljh.167.1558714858626; Fri, 24 May 2019 09:20:58 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-d2cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.210]) by smtp.gmail.com with ESMTPSA id y4sm618075lje.24.2019.05.24.09.20.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:20:57 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Krzysztof Halasa , Linus Walleij Subject: [PATCH 6/8] net: ethernet: ixp4xx: Use parent dev for DMA pool Date: Fri, 24 May 2019 18:20:21 +0200 Message-Id: <20190524162023.9115-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162023.9115-1-linus.walleij@linaro.org> References: <20190524162023.9115-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the netdevice struct device .parent field when calling dma_pool_create(): the .dma_coherent_mask and .dma_mask pertains to the bus device on the hardware (platform) bus in this case, not the struct device inside the network device. This makes the pool allocation work. Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 600f62e95fb0..8b883563a3d3 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1092,7 +1092,7 @@ static int init_queues(struct port *port) int i; if (!ports_open) { - dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev, + dma_pool = dma_pool_create(DRV_NAME, port->netdev->dev.parent, POOL_ALLOC_SIZE, 32, 0); if (!dma_pool) return -ENOMEM; From patchwork Fri May 24 16:20:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1105031 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jKHxlc1G"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 459Wns0hxhz9s1c for ; Sat, 25 May 2019 02:21:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390978AbfEXQVE (ORCPT ); Fri, 24 May 2019 12:21:04 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:46046 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390308AbfEXQVD (ORCPT ); Fri, 24 May 2019 12:21:03 -0400 Received: by mail-lf1-f67.google.com with SMTP id n22so7561242lfe.12 for ; Fri, 24 May 2019 09:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CAbrTVrDd+vquw7c4UOJK7pyKOUo+ZWe2OOzzUZ1h+M=; b=jKHxlc1G0LUY1Zxsau5zBjmYumkEqZpUDKPeKmrfDlfbyK4pY1ZLdr3f/jHIIvJJxW P1WUYhGmq+YaBWXbFOoGpwK1rDvhOcxQ0JZD8ISWhl0gYOpSjkrBVStaNgj7GfYQm2z7 NILG1Gg2kuQgzu41xJbHuJ1ADG1RAhsyqYNiJoa6YNmJ5q7SVQ4KhczK4cTHILv8U+Ih N13AGZhL9L4rlgHckHag7JCjgnbkUPuIU88pTsJaDUUUBPYvZKbynWOvPgDgD12xU3Lj LlI6JZuiK1FLBU7FkMpl1HworzXTzzqLqOvDc8rLWlA3P696jpy+xXOy3o3TZzie7L0G 60PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CAbrTVrDd+vquw7c4UOJK7pyKOUo+ZWe2OOzzUZ1h+M=; b=sXJqA5tRMUNgLZc6VZJahnrLUbj8kwskbvKyk6lQ2asfkBxh/S5U49mFH/OXF1RiQX 6igwIqvWBnuJrr7cPRsTMEEPIdxQ3OofkenwsxFJwEvON9qzEQ6+JAjIk4MOFrwiADMb MUQ6GZgccJ/R/I7xmMFM+eLfv/T4i1lkAkPdBEsPvVk1z5Bq8/BdvAzcr6yOJZjHsUHF 3rJtlaaWUTBuwobHWB086aRKoVLxPGS8vQnnK/sBKKdzcOs4B6fkQM6qK2llg7/SqkxM wmL+W9xGyJUkA1BIDQlalOxWT/tryvIboR0OfkhFUQ93Bp4gBLpIuKD3av+y+lzs/M69 jrOw== X-Gm-Message-State: APjAAAWgIH8XFZm4wBSwpUkMY2PtXCj9W7IAa2PBYWW+5eSVnJKhZkT1 T6GMB8bIqPoYGjV091iC2WWLVliF2Kk= X-Google-Smtp-Source: APXvYqys3iTt/2thnzFGgd97nOy6riZ/LPK7Jdn3XJi/k6rf/8FvRWndTyHm37c1A4X8iDNSkMvZZQ== X-Received: by 2002:ac2:5546:: with SMTP id l6mr20486653lfk.50.1558714861395; Fri, 24 May 2019 09:21:01 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-d2cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.210]) by smtp.gmail.com with ESMTPSA id y4sm618075lje.24.2019.05.24.09.21.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:21:00 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Krzysztof Halasa , Linus Walleij Subject: [PATCH 7/8] net: ethernet: ixp4xx: Add DT bindings Date: Fri, 24 May 2019 18:20:22 +0200 Message-Id: <20190524162023.9115-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162023.9115-1-linus.walleij@linaro.org> References: <20190524162023.9115-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This adds device tree bindings for the IXP4xx ethernet. Signed-off-by: Linus Walleij --- .../bindings/net/intel,ixp4xx-ethernet.yaml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/intel,ixp4xx-ethernet.yaml diff --git a/Documentation/devicetree/bindings/net/intel,ixp4xx-ethernet.yaml b/Documentation/devicetree/bindings/net/intel,ixp4xx-ethernet.yaml new file mode 100644 index 000000000000..4575a7e5aa4a --- /dev/null +++ b/Documentation/devicetree/bindings/net/intel,ixp4xx-ethernet.yaml @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2018 Linaro Ltd. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/net/intel-ixp4xx-ethernet.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel IXP4xx ethernet + +maintainers: + - Linus Walleij + +description: | + The Intel IXP4xx ethernet makes use of the IXP4xx NPE (Network + Processing Engine) and the IXP4xx Queue Mangager to process + the ethernet frames. It can optionally contain an MDIO bus to + talk to PHYs. + +properties: + compatible: + oneOf: + - items: + - const: intel,ixp4xx-ethernet + + reg: + maxItems: 1 + description: Ethernet MMIO address range + + queue-rx: + $ref: '/schemas/types.yaml#/definitions/phandle-array' + maxItems: 1 + description: phandle to the RX queue on the NPE + + queue-txready: + $ref: '/schemas/types.yaml#/definitions/phandle-array' + maxItems: 1 + description: phandle to the TX READY queue on the NPE + +required: + - compatible + - reg + - queue-rx + - queue-txready + +examples: + - | + ethernet@c8009000 { + compatible = "intel,ixp4xx-ethernet"; + reg = <0xc8009000 0x1000>; + status = "disabled"; + queue-rx = <&qmgr 3>; + queue-txready = <&qmgr 20>; + }; From patchwork Fri May 24 16:20:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1105032 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="GLxaiBAd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 459Wp03n5Yz9s1c for ; Sat, 25 May 2019 02:21:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391014AbfEXQVL (ORCPT ); Fri, 24 May 2019 12:21:11 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:44513 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390308AbfEXQVL (ORCPT ); Fri, 24 May 2019 12:21:11 -0400 Received: by mail-lf1-f68.google.com with SMTP id n134so7566276lfn.11 for ; Fri, 24 May 2019 09:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eTEsCb23TLeixRMcycF5JVraveYSjIoqfPZsqxuqIKU=; b=GLxaiBAdC5vmdEh/Nwlo5dRur66uY3HBkEyNriBkuevfdORykw6ng1WzHXj0AggSi4 +LSbOuVLeEEw6BNJAR12M8viisLPxMt+Ma6wMRvQFrfq9YRxlMw+qVEJervS/4UZEZkn hB3PoG9kEcmbqnhR2v9v13DPveEqqUJK5UryNHxZeCxV0/dlFLe+DzIZ2Q0ljgFbkABF qP7x2iEjE67e5+LfTNw6jhxVaWGfx9qkxcCkWEBSnTB8uhgfoOpEFWSLoHc5VmoFELve qjjLxSyIfiAs9sz/fEinszjSiHIdRDxA7lsAITygdnYfeTghNQJdTX/iPbq6gIn4bHiK 982A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eTEsCb23TLeixRMcycF5JVraveYSjIoqfPZsqxuqIKU=; b=Ydh2xqpOjpZhMPmq/4LIf87mfnf3Nt9ejai1objluutiSodaaWN9qJN+94X2MI+V8Z JJMrnxLW0BgyfBKrbA/XtOfIB/lIiX5oxB6e2NA6j+5wxSIIdL5w5qrJz9MtDjxd+/Bl wB5e3QO/XLlNihbiAUeaYkPeaHYFl7YP0IQLNKRAXmtvXfqYA3e3Bj5ukRn8nkd2TOmc aaAxe2jtiwFS4yLtCzSSNq6AonHODlcxGiKZNCSK+nyvdMiM1wJso02OKWAYhPlxzU4+ wX9VC/56QFAVgpa+LkO6GOWWldkpejmtWOZj1iIj1blFIZb/ye67AEE5qsse2anhhYDS XCpQ== X-Gm-Message-State: APjAAAWRuSj2/Q7x2KQteSkfH+mvFA/LtyMiXsgHYqrvFkeJWcoqCClC OVUXDbdTej+7J/Z8uA5TVq9OgYaz1pI= X-Google-Smtp-Source: APXvYqyM5TaiGMATOMBmFqwSAfvuomqWR0zCHe13rIIZT+QTmy6cEa4x6g9VQMFZF7FxAbhpKKRmXw== X-Received: by 2002:a19:521a:: with SMTP id m26mr4815219lfb.134.1558714868390; Fri, 24 May 2019 09:21:08 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-d2cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.210]) by smtp.gmail.com with ESMTPSA id y4sm618075lje.24.2019.05.24.09.21.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 May 2019 09:21:07 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Krzysztof Halasa , Linus Walleij Subject: [PATCH 8/8] net: ethernet: ixp4xx: Support device tree probing Date: Fri, 24 May 2019 18:20:23 +0200 Message-Id: <20190524162023.9115-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162023.9115-1-linus.walleij@linaro.org> References: <20190524162023.9115-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This adds device tree probing to the IXP4xx ethernet driver. We need to drop the memory region request as part of this since the OF core will request the memory for the device. Signed-off-by: Linus Walleij --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 80 +++++++++++++++++++----- 1 file changed, 66 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 8b883563a3d3..65fdc82d45a4 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -167,7 +167,6 @@ struct eth_regs { }; struct port { - struct resource *mem_res; struct eth_regs __iomem *regs; struct npe *npe; struct net_device *netdev; @@ -1367,19 +1366,72 @@ static const struct net_device_ops ixp4xx_netdev_ops = { .ndo_validate_addr = eth_validate_addr, }; +#ifdef CONFIG_OF +static struct eth_plat_info *ixp4xx_of_get_platdata(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct of_phandle_args queue_spec; + struct eth_plat_info *plat; + u32 val; + int ret; + + plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL); + if (!plat) + return NULL; + + /* FIXME: get from MDIO handle */ + ret = of_property_read_u32(np, "phy", &val); + if (ret) { + dev_err(dev, "no phy\n"); + return NULL; + } + plat->phy = val; + + /* Get the rx queue as a resource from queue manager */ + ret = of_parse_phandle_with_fixed_args(np, "queue-rx", 1, 0, + &queue_spec); + if (ret) { + dev_err(dev, "no rx queue phandle\n"); + return NULL; + } + plat->rxq = queue_spec.args[0]; + + /* Get the txready queue as resource from queue manager */ + ret = of_parse_phandle_with_fixed_args(np, "queue-txready", 1, 0, + &queue_spec); + if (ret) { + dev_err(dev, "no txready queue phandle\n"); + return NULL; + } + plat->txreadyq = queue_spec.args[0]; + + return plat; +} +#else +static struct eth_plat_info *ixp4xx_of_get_platdata(struct device *dev) +{ + return NULL; +} +#endif + static int ixp4xx_eth_probe(struct platform_device *pdev) { char phy_id[MII_BUS_ID_SIZE + 3]; struct phy_device *phydev = NULL; struct device *dev = &pdev->dev; struct eth_plat_info *plat; - resource_size_t regs_phys; struct net_device *ndev; struct resource *res; struct port *port; int err; - plat = dev_get_platdata(dev); + if (dev->of_node) + plat = ixp4xx_of_get_platdata(dev); + else + plat = dev_get_platdata(dev); + + if (!plat) + return -ENODEV; if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port)))) return -ENOMEM; @@ -1392,7 +1444,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; - regs_phys = res->start; port->regs = devm_ioremap_resource(dev, res); switch (res->start) { @@ -1450,12 +1501,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) if (!(port->npe = npe_request(NPE_ID(port->id)))) return -EIO; - port->mem_res = request_mem_region(regs_phys, REGS_SIZE, ndev->name); - if (!port->mem_res) { - err = -EBUSY; - goto err_npe_rel; - } - port->plat = plat; npe_port_tab[NPE_ID(port->id)] = port; memcpy(ndev->dev_addr, plat->hwaddr, ETH_ALEN); @@ -1491,8 +1536,6 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) phy_disconnect(phydev); err_free_mem: npe_port_tab[NPE_ID(port->id)] = NULL; - release_resource(port->mem_res); -err_npe_rel: npe_release(port->npe); return err; } @@ -1508,12 +1551,21 @@ static int ixp4xx_eth_remove(struct platform_device *pdev) ixp4xx_mdio_remove(); npe_port_tab[NPE_ID(port->id)] = NULL; npe_release(port->npe); - release_resource(port->mem_res); return 0; } +static const struct of_device_id ixp4xx_eth_of_match[] = { + { + .compatible = "intel,ixp4xx-ethernet", + }, + { }, +}; + static struct platform_driver ixp4xx_eth_driver = { - .driver.name = DRV_NAME, + .driver = { + .name = DRV_NAME, + .of_match_table = of_match_ptr(ixp4xx_eth_of_match), + }, .probe = ixp4xx_eth_probe, .remove = ixp4xx_eth_remove, };