From patchwork Fri Feb 11 22:32:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12744008 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62C19C433EF for ; Fri, 11 Feb 2022 22:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354154AbiBKWf1 (ORCPT ); Fri, 11 Feb 2022 17:35:27 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354171AbiBKWfC (ORCPT ); Fri, 11 Feb 2022 17:35:02 -0500 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0900D79 for ; Fri, 11 Feb 2022 14:34:55 -0800 (PST) Received: by mail-lj1-x235.google.com with SMTP id e17so14370863ljk.5 for ; Fri, 11 Feb 2022 14:34:55 -0800 (PST) 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=YrNf5wawikdGcg0e0o/7nYXOhFnrAgJBeA33K99ddJI=; b=tR0sRVpfQfVtzrydfCESZVk9Q8eLJD6cwbh3uVEKyZCSHthUgpteVKjzYppMeerEeP pwRWQXqUaRoguzVaPKqFShX3igbNbq8Kly6N80wsqF6CjyEhE/V4F8G2PSByjNggSsg+ 1r3J86DCsyv3l8TjJ2/AhPMXpJI/oY0fjIZu8OWuS0WsA8oZ92hYImo0oW0Mf96l0yjv 3EAhouAnFHQLAbVOi2eX8dUrrCZ7U11VBXhyZTZxOOb/nyD157LQf4VyIt5cBEJaXAAg S1oNF7rPOiwDRetEaisJr+Q6zn1MER5BIBbQj75jAyNs/Eck7sfEru+tFKtX9ehgUmo6 H4fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YrNf5wawikdGcg0e0o/7nYXOhFnrAgJBeA33K99ddJI=; b=WATtXtERNk1gH9dOB1a0aR8PS5AAoPpD0DKWRerx12HQnnxwfdmefzEUJ0N+s5kAB+ jeJk6mOVeGEYi7uVexcEc9ix3qA1F3Nv4LDjbd9Su977HLNwC7IJvoNlTR4cmZhJBpvt FqrUMK7ASZF0eMLp367YBilesj/rhxvqwge8Uw6Yx8sN86KX/78cWVMhXRlaFOV+f4P0 ZTaq/7CUnit4j7HtHaBXTBkq2FbOjkbmRji57cHAlQIk7dad68YXX33aMgHE1EKo362p v3b+PEBZiJzJrMdu41rdlgwyW4VKYflCIZnFkKf4xDmVKqI9uJVfS8onyLwexvdIoRLx IwHQ== X-Gm-Message-State: AOAM5310946rGhShEgb4Dq3w4JL2nAJimsHpkgQ1E8W7k251TqEWWt6D o/1eQKBrGpTz+NFvQl9FRqAe75ld2RUaYwC5 X-Google-Smtp-Source: ABdhPJx1Tx41vuZ6opyJFxbMC0I1R8zJPlFhzGeJLWa+F7P7YKUEc8N+EnzvVk2KxQM7vZF05V4gbQ== X-Received: by 2002:a2e:94c5:: with SMTP id r5mr2226837ljh.17.1644618894350; Fri, 11 Feb 2022 14:34:54 -0800 (PST) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id x2sm3296300lji.27.2022.02.11.14.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 14:34:53 -0800 (PST) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, Imre Kaloz , Krzysztof Halasa Cc: Linus Walleij , "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 08/13 v2] net: ixp4xx_eth: Drop platform data support Date: Fri, 11 Feb 2022 23:32:33 +0100 Message-Id: <20220211223238.648934-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211223238.648934-1-linus.walleij@linaro.org> References: <20220211223238.648934-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org All IXP4xx platforms are converted to device tree, the platform data path is no longer used. Drop the code and custom include, confine the driver in its own file. Depend on OF and remove ifdefs around this, as we are all probing from OF now. Cc: David S. Miller Cc: Jakub Kicinski Cc: netdev@vger.kernel.org Signed-off-by: Linus Walleij Acked-by: Jakub Kicinski --- ChangeLog v1->v2: - Delete a small chunk of code I missed Network maintainers: I'm looking for an ACK to take this change through ARM SoC along with other changes removing these accessor functions. --- drivers/net/ethernet/xscale/Kconfig | 4 +- drivers/net/ethernet/xscale/ixp4xx_eth.c | 85 ++++++------------------ include/linux/platform_data/eth_ixp4xx.h | 21 ------ 3 files changed, 21 insertions(+), 89 deletions(-) delete mode 100644 include/linux/platform_data/eth_ixp4xx.h diff --git a/drivers/net/ethernet/xscale/Kconfig b/drivers/net/ethernet/xscale/Kconfig index 0e878fa6e322..b33f64c54b0e 100644 --- a/drivers/net/ethernet/xscale/Kconfig +++ b/drivers/net/ethernet/xscale/Kconfig @@ -20,9 +20,9 @@ if NET_VENDOR_XSCALE config IXP4XX_ETH tristate "Intel IXP4xx Ethernet support" - depends on ARM && ARCH_IXP4XX && IXP4XX_NPE && IXP4XX_QMGR + depends on ARM && ARCH_IXP4XX && IXP4XX_NPE && IXP4XX_QMGR && OF select PHYLIB - select OF_MDIO if OF + select OF_MDIO select NET_PTP_CLASSIFY help Say Y here if you want to use built-in Ethernet ports diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index df77a22d1b81..d947955621ee 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -38,6 +37,11 @@ #include #include #include +#include + +#define IXP4XX_ETH_NPEA 0x00 +#define IXP4XX_ETH_NPEB 0x10 +#define IXP4XX_ETH_NPEC 0x20 #include "ixp46x_ts.h" @@ -147,6 +151,16 @@ typedef void buffer_t; #define free_buffer_irq kfree #endif +/* Information about built-in Ethernet MAC interfaces */ +struct eth_plat_info { + u8 phy; /* MII PHY ID, 0 - 31 */ + u8 rxq; /* configurable, currently 0 - 31 only */ + u8 txreadyq; + u8 hwaddr[6]; + u8 npe; /* NPE instance used by this interface */ + bool has_mdio; /* If this instance has an MDIO bus */ +}; + struct eth_regs { u32 tx_control[2], __res1[2]; /* 000 */ u32 rx_control[2], __res2[2]; /* 010 */ @@ -1366,7 +1380,6 @@ 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; @@ -1417,12 +1430,6 @@ static struct eth_plat_info *ixp4xx_of_get_platdata(struct device *dev) 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) { @@ -1434,49 +1441,9 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) struct port *port; int err; - if (np) { - plat = ixp4xx_of_get_platdata(dev); - if (!plat) - return -ENODEV; - } else { - plat = dev_get_platdata(dev); - if (!plat) - return -ENODEV; - plat->npe = pdev->id; - switch (plat->npe) { - case IXP4XX_ETH_NPEA: - /* If the MDIO bus is not up yet, defer probe */ - 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 we have the MDIO bus here. - */ - if (!cpu_is_ixp43x()) { - if (!(ixp4xx_read_feature_bits() & - IXP4XX_FEATURE_NPEB_ETH0)) - return -ENODEV; - /* Else register the MDIO bus on NPE-B */ - plat->has_mdio = true; - } - break; - case IXP4XX_ETH_NPEC: - /* IXP43x lacks NPE-B and uses NPE-C for the MDIO bus - * access, if 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-B */ - plat->has_mdio = true; - } - break; - default: - return -ENODEV; - } - } + plat = ixp4xx_of_get_platdata(dev); + if (!plat) + return -ENODEV; if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port)))) return -ENOMEM; @@ -1530,21 +1497,7 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) __raw_writel(DEFAULT_CORE_CNTRL, &port->regs->core_control); udelay(50); - if (np) { - phydev = of_phy_get_and_connect(ndev, np, ixp4xx_adjust_link); - } else { - phydev = mdiobus_get_phy(mdio_bus, plat->phy); - if (!phydev) { - err = -ENODEV; - dev_err(dev, "could not connect phydev (%d)\n", err); - goto err_free_mem; - } - err = phy_connect_direct(ndev, phydev, ixp4xx_adjust_link, - PHY_INTERFACE_MODE_MII); - if (err) - goto err_free_mem; - - } + phydev = of_phy_get_and_connect(ndev, np, ixp4xx_adjust_link); if (!phydev) { err = -ENODEV; dev_err(dev, "no phydev\n"); diff --git a/include/linux/platform_data/eth_ixp4xx.h b/include/linux/platform_data/eth_ixp4xx.h deleted file mode 100644 index 114b0940729f..000000000000 --- a/include/linux/platform_data/eth_ixp4xx.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __PLATFORM_DATA_ETH_IXP4XX -#define __PLATFORM_DATA_ETH_IXP4XX - -#include - -#define IXP4XX_ETH_NPEA 0x00 -#define IXP4XX_ETH_NPEB 0x10 -#define IXP4XX_ETH_NPEC 0x20 - -/* Information about built-in Ethernet MAC interfaces */ -struct eth_plat_info { - u8 phy; /* MII PHY ID, 0 - 31 */ - u8 rxq; /* configurable, currently 0 - 31 only */ - u8 txreadyq; - u8 hwaddr[6]; - u8 npe; /* NPE instance used by this interface */ - bool has_mdio; /* If this instance has an MDIO bus */ -}; - -#endif From patchwork Fri Feb 11 22:32:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12744009 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6198FC433FE for ; Fri, 11 Feb 2022 22:35:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354253AbiBKWf2 (ORCPT ); Fri, 11 Feb 2022 17:35:28 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354183AbiBKWfD (ORCPT ); Fri, 11 Feb 2022 17:35:03 -0500 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FF82D82 for ; Fri, 11 Feb 2022 14:34:58 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id 13so19182843lfp.7 for ; Fri, 11 Feb 2022 14:34:58 -0800 (PST) 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=ydAMZrV8y3PpgB8uEETNV3djZfWmnSWpnhp3QVaSOR0=; b=B6XAOl9/37tvd4e2dLwqre0rTB01bjLgeirYECLZO2wt8kdIApImlH8XvncHF8egxi MVmUBy+sWx5oOBxSEy1yG70gtTAUAvx+qvjbk/RDKHexJ3nsPeyer9N0XJY/nQgN88G0 F6dK3lLeapyLjIch4IViHAzKpfarj2mwtC2lUAThIs/xOpIV2Sd6m1iSov2ddNqPSCTL XldsonPWERPN5shOGgFN2zvs6UaFbEA5AIVKzIT9os2xFEjWnB9Tz6QoBIRsSdpQKc9B ccnARAUPLq866zvp7LP3Mig9R/Zy/jqsBGpzOD67Kp/YyfAgFKTiRExdbZ4KMarZ1U1K c7yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ydAMZrV8y3PpgB8uEETNV3djZfWmnSWpnhp3QVaSOR0=; b=vQ0PfJICmuFmQP3H5jnNeHTg2WYvAr7yQoHOQmH2LA3lNoY+ayUfI7KXKTJsMS+ClB DvFXhcEsMvW6qiChXXc+MXF7RPEP8o5HEc3tssU8vDbok3lRgTAGbV3nC9adaifge16e JJeW6yPCsGyhrUIQBeHjPRJFBA+IwUxaKjPK3IWZ9Sz9Gkhkb+OGYUzSf28VxXJgs1Se dx5lysQt2bWJfkhdg2fBErcQYDcwtdMN86KwFd6hw7mvHHc203RPzM50omL5c2RBHCdV ooLgCKPV4AiKM2LAaw7ASsb2wvXaT4dwwQEZTDVl5lyoIYRwrE6LEWs8xNDx4GDxElzf bqyw== X-Gm-Message-State: AOAM533vAd8sspX+NhLprRKYSLPjkA+ffauA9bdosPpPzznnMYCQp3HC y7d5IiNYl6vRDlpbcXfgHdNf+Kalx95ivwGE X-Google-Smtp-Source: ABdhPJxvVzhNq8tLEkvgY2SXve6m3vkkiarjh8J86JFx5qFzqWqb3AnW30/CRqqJ0tMZCg4RhVJeUQ== X-Received: by 2002:a05:6512:3d02:: with SMTP id d2mr2746538lfv.138.1644618895847; Fri, 11 Feb 2022 14:34:55 -0800 (PST) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id x2sm3296300lji.27.2022.02.11.14.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 14:34:55 -0800 (PST) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, Imre Kaloz , Krzysztof Halasa Cc: Linus Walleij , "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH 09/13 v2] net: ixp4xx_hss: Check features using syscon Date: Fri, 11 Feb 2022 23:32:34 +0100 Message-Id: <20220211223238.648934-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211223238.648934-1-linus.walleij@linaro.org> References: <20220211223238.648934-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If we access the syscon (expansion bus config registers) using the syscon regmap instead of relying on direct accessor functions, we do not need to call this static code in the machine (arch/arm/mach-ixp4xx/common.c) which makes things less dependent on custom machine-dependent code. Look up the syscon regmap and handle the error: this will make deferred probe work with relation to the syscon. Select the syscon in Kconfig and depend on OF so we know that all we need will be available. Cc: David S. Miller Cc: Jakub Kicinski Cc: netdev@vger.kernel.org Signed-off-by: Linus Walleij Acked-by: Jakub Kicinski --- ChangeLog v1->v2: - No changes. Network maintainers: I'm looking for an ACK to take this change through ARM SoC along with other changes removing these accessor functions. --- drivers/net/wan/Kconfig | 3 ++- drivers/net/wan/ixp4xx_hss.c | 39 ++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig index 592a8389fc5a..140780ac1745 100644 --- a/drivers/net/wan/Kconfig +++ b/drivers/net/wan/Kconfig @@ -293,7 +293,8 @@ config SLIC_DS26522 config IXP4XX_HSS tristate "Intel IXP4xx HSS (synchronous serial port) support" depends on HDLC && IXP4XX_NPE && IXP4XX_QMGR - depends on ARCH_IXP4XX + depends on ARCH_IXP4XX && OF + select MFD_SYSCON help Say Y here if you want to use built-in HSS ports on IXP4xx processor. diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c index 0b7d9f2f2b8b..863c3e34e136 100644 --- a/drivers/net/wan/ixp4xx_hss.c +++ b/drivers/net/wan/ixp4xx_hss.c @@ -16,8 +16,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -1389,9 +1391,28 @@ static int ixp4xx_hss_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct net_device *ndev; struct device_node *np; + struct regmap *rmap; struct port *port; hdlc_device *hdlc; int err; + u32 val; + + /* + * Go into the syscon and check if we have the HSS and HDLC + * features available, else this will not work. + */ + rmap = syscon_regmap_lookup_by_compatible("syscon"); + if (IS_ERR(rmap)) + return dev_err_probe(dev, PTR_ERR(rmap), + "failed to look up syscon\n"); + + val = cpu_ixp4xx_features(rmap); + + if ((val & (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) != + (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) { + dev_err(dev, "HDLC and HSS feature unavailable in platform\n"); + return -ENODEV; + } np = dev->of_node; @@ -1516,25 +1537,9 @@ static struct platform_driver ixp4xx_hss_driver = { .probe = ixp4xx_hss_probe, .remove = ixp4xx_hss_remove, }; - -static int __init hss_init_module(void) -{ - if ((ixp4xx_read_feature_bits() & - (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) != - (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) - return -ENODEV; - - return platform_driver_register(&ixp4xx_hss_driver); -} - -static void __exit hss_cleanup_module(void) -{ - platform_driver_unregister(&ixp4xx_hss_driver); -} +module_platform_driver(ixp4xx_hss_driver); MODULE_AUTHOR("Krzysztof Halasa"); MODULE_DESCRIPTION("Intel IXP4xx HSS driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:ixp4xx_hss"); -module_init(hss_init_module); -module_exit(hss_cleanup_module);