From patchwork Sun Apr 25 00:30:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 427782 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0A63C43460 for ; Sun, 25 Apr 2021 00:30:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89B15613C4 for ; Sun, 25 Apr 2021 00:30:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbhDYAbe (ORCPT ); Sat, 24 Apr 2021 20:31:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbhDYAbd (ORCPT ); Sat, 24 Apr 2021 20:31:33 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F4190C061574 for ; Sat, 24 Apr 2021 17:30:52 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 124so1835747lff.5 for ; Sat, 24 Apr 2021 17:30:52 -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:mime-version :content-transfer-encoding; bh=GWMZ3joFDXAfixsaT3M1mL9BXCqmaTfhrxyajNcq/7M=; b=Nse9hLCSJYQ8gYGGbutxJq0dJTWct2loAtnwFpLBlNUPSClQLOb4Rebe77I5YgTh3O xwKgfyf+hg6kJNaQbvPDkggyFtqhzt0Ej9r6Jym1oos+JJB0G23f8p+K7lEh9Vcnjq3s rWpN8digbAv+eVpqIqqdwN7Nqz9YTQRwUcdLLQstPjTZYmPs00Y9QfuWnFpULQFhwpMm nq/4LxDvHT8kfFNVJhcXCdRoJyW8C/WJ0R+UAJ6f2I0dNTLyv6Y9U6fbSNtoQzc3OzzD LewKAxtCZivQuIAJDB4blLvTHtlV3nnj/HKnLpw5z9DFkpzPp5Z2m+DxavI211WxP9+y ru2g== 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:mime-version :content-transfer-encoding; bh=GWMZ3joFDXAfixsaT3M1mL9BXCqmaTfhrxyajNcq/7M=; b=jxTRg0WMcFRjlQevInt+XJjpsqBAZ7LZWVJMnN/VHHQtnq1WqGpIaiLIcYBEfc+AXe FIgGiZjAeu/UPWPerHte/wCnuBoVg1Dv9EPo8jTT1lp//FwZlv3feKYSdNMUUVWF0ihM C5NFR40uaojHrrCocc17G5HKB33SEAEmqRMHkQZAMVNKKkvMJYO60soNw0roF99PUNrt RUB9du7XF9NFQhDLRNl8DgabvsobZbv6swMeDBuUEWfff46vQ0+EW5vS4YZsEPBrJ5PQ jK/H9/3shzSkicD8fu10e3V73oFcUXIsuklT2Mph4sWZwshW0J4MtVWBmQ9t87znxCFF 9TIw== X-Gm-Message-State: AOAM530q9uSwbwtrxEcIxNnMi7Q45s8oBeHzdznmfieTnxQWwlIUmFl3 pJU89xfNb2NBTh+ziOIAG+cQVyaWd9qwxg== X-Google-Smtp-Source: ABdhPJyzfYYlfkJ0nNn+UV6oub7WXr9QW5+g6MlLlaikSiTLeHGA44Wrqo4MnsOaJEKrUGX1CEMEQQ== X-Received: by 2002:a05:6512:3e1:: with SMTP id n1mr7434540lfq.31.1619310650872; Sat, 24 Apr 2021 17:30:50 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id t5sm950352lfe.211.2021.04.24.17.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Apr 2021 17:30:50 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Andrew Lunn , Heiner Kallweit , Russell King , Linus Walleij , Zoltan HERPAI , Raylynn Knight , devicetree@vger.kernel.org Subject: [PATCH 1/3 net-next v4] net: ethernet: ixp4xx: Add DT bindings Date: Sun, 25 Apr 2021 02:30:36 +0200 Message-Id: <20210425003038.2937498-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This adds device tree bindings for the IXP4xx ethernet controller with optional MDIO bridge. Cc: Zoltan HERPAI Cc: Raylynn Knight Cc: devicetree@vger.kernel.org Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - Use a phandle to reference the NPE - Make a more verbose example with two ethernet devices sharing a MDIO bus on just one of them - Spelling fix ChangeLog v2->v3: - Designate phy nodes with ethernet-phy@ - Include phy-mode in the schema ChangeLog v1->v2: - Add schema for the (optional) embedded MDIO bus inside the ethernet controller in an "mdio" node instead of just letting the code randomly populate and present it to the operating system. - Reference the standard schemas for ethernet controller and MDIO buses. - Add intel,npe to indentify the NPE unit used with each ethernet adapter. --- .../bindings/net/intel,ixp4xx-ethernet.yaml | 102 ++++++++++++++++++ 1 file changed, 102 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..f2e91d1bf7d7 --- /dev/null +++ b/Documentation/devicetree/bindings/net/intel,ixp4xx-ethernet.yaml @@ -0,0 +1,102 @@ +# 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 + +allOf: + - $ref: "ethernet-controller.yaml#" + +maintainers: + - Linus Walleij + +description: | + The Intel IXP4xx ethernet makes use of the IXP4xx NPE (Network + Processing Engine) and the IXP4xx Queue Manager to process + the ethernet frames. It can optionally contain an MDIO bus to + talk to PHYs. + +properties: + compatible: + 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 + + phy-mode: true + + phy-handle: true + + intel,npe-handle: + $ref: '/schemas/types.yaml#/definitions/phandle-array' + maxItems: 1 + description: phandle to the NPE this ethernet instance is using + and the instance to use in the second cell + + mdio: + type: object + $ref: "mdio.yaml#" + description: optional node for embedded MDIO controller + +required: + - compatible + - reg + - queue-rx + - queue-txready + - intel,npe-handle + +additionalProperties: false + +examples: + - | + npe: npe@c8006000 { + compatible = "intel,ixp4xx-network-processing-engine"; + reg = <0xc8006000 0x1000>, <0xc8007000 0x1000>, <0xc8008000 0x1000>; + }; + + ethernet@c8009000 { + compatible = "intel,ixp4xx-ethernet"; + reg = <0xc8009000 0x1000>; + status = "disabled"; + queue-rx = <&qmgr 4>; + queue-txready = <&qmgr 21>; + intel,npe-handle = <&npe 1>; + phy-mode = "rgmii"; + phy-handle = <&phy1>; + }; + + ethernet@c800c000 { + compatible = "intel,ixp4xx-ethernet"; + reg = <0xc800c000 0x1000>; + status = "disabled"; + queue-rx = <&qmgr 3>; + queue-txready = <&qmgr 20>; + intel,npe-handle = <&npe 2>; + phy-mode = "rgmii"; + phy-handle = <&phy2>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + phy1: ethernet-phy@1 { + reg = <1>; + }; + phy2: ethernet-phy@2 { + reg = <2>; + }; + }; + }; From patchwork Sun Apr 25 00:30:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 427265 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp2511729jao; Sat, 24 Apr 2021 17:31:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPhLWtXks+gBUxZxp+oDEM8HeT1/uYf8fkUaYPBIXyH5aelrpDcH/Or7J/gT2dxlTB3vyt X-Received: by 2002:a17:906:c29a:: with SMTP id r26mr10776434ejz.259.1619310660478; Sat, 24 Apr 2021 17:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619310660; cv=none; d=google.com; s=arc-20160816; b=07OKp2+MIh5wkMhADtHv/OleUb/QPD2PDsdN2skZ2x6zhGEAZls9A/Fw0mFrZHE+Ng N0TdbWELosAogXpr18UEWA8lB2HGo9TwS2OqMtdq1HqDiTA6CCDLaGNuxNcRwyf6n6aD gQDRDktvqsfcm0V+/GquMlFCBYIebE7skHAgaxmxi1ASjaB/vfQJt58E7H7JNkivtayM uAxWiPoynEdBlah4e+Q0BGAHkRP41QBlnjChYej8YgEk1XBvR2YXQQ8nNnr/N4n2dtXE Nv4E/MsCJ++pOEcciyzPZeSHvNVb/KYB7h/rX8DKvtkpKwRyteRamYeyh4TOdit4PZWI jRAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CV0QcDYHdPhLsI1lETsCV1+IJ2hDnY14lRZaKI1aN9E=; b=Qzl8fDNIHe+NYGszZHwca3b1jKwQ/8YgvlwQHP+U2uWkaFfM6ZqtKNwuSMahRoORrT Z/4JnWNqCoCd2VpyCPaYoGaEU5DDMLbyAQFJ4vP6ehe9sSGWULBDZdjiS6cLYv4bpoxm Ii1JQfZ5WJcSsec3bWbJNtW44HqIIa5UYamKZgP4UTxjeZdSAC9YUC6+lLla+FJUsvF+ yYWcl0nkvzbjJocqzX4J6GQZNlDfSq5G+YObVLSMSwWAsecXZQ6az2bakXH9TvY7Xwzy MYpzFfwkjIXgOgZKXzWrtaJmNlmQHjJnB56aZ+T9zRxeAGr6K6yyQRSNJMRJRcsVAilY oIkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="d0L9OC/T"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si9277216edv.521.2021.04.24.17.31.00; Sat, 24 Apr 2021 17:31:00 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="d0L9OC/T"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230152AbhDYAbf (ORCPT + 8 others); Sat, 24 Apr 2021 20:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbhDYAbe (ORCPT ); Sat, 24 Apr 2021 20:31:34 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C545C06174A for ; Sat, 24 Apr 2021 17:30:54 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id s9so1897166ljj.6 for ; Sat, 24 Apr 2021 17:30:54 -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=CV0QcDYHdPhLsI1lETsCV1+IJ2hDnY14lRZaKI1aN9E=; b=d0L9OC/TPCuJfnnobfJi+VELMSvhRacjPYxNeT19dJ5+i/kZ/4qxJkSbDGGjZl6eyO eZO9FOnP5kTGqE5/rb5MSdXo3DrODq7bHarnKF4+HvHC43KTsV6TfrdEuUJRgsD4vU89 5h7BIuYn1R+sO1qmCRQ+3MtFjUpWE0z/q15ySm9f0MC3axVAkNbpWCkFIcm2T6Vo0mBu GinAWK89iD2+TPOliZCGSSKYK4QUzmA2wqeCcQ61SJ+G7G8IfLcxHdOaRiux/zYsKdfh EysuwkZNst3j6pifhqymazeoD1S0RabS2EXKMXnk5PdtSgwMvNZfAvaD02AcZbueA1bH 4OeQ== 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=CV0QcDYHdPhLsI1lETsCV1+IJ2hDnY14lRZaKI1aN9E=; b=O66HGYhs6Yu+sxpDHUSolCqVDSa2n16EhWSmHOcSmeEsAuyxEoOgX4d5TGeocOvPfe eObILKdLtjkqn6g4NM0hwXsgUYzNPOentraiBybDYrB0UyMOAATZqGogi7/KwAOuDNk0 xGXB6WurOLckJI+Xmnv0eXmPcPAlxatDsWNwJXAifKn1es++A+FXs4OkAJaQED0oXoRb wsMWuHe3qbHGknwgKf18ZbUwKl0uJ9Buw4Ge4PuaEnt3vHFJ/v+Wkfb+bFZhUi9IsgaF U+teRYCh6FcvUDWIqU58VtiLdbX+iu4eNw7GvdItOBwiyc2qMbPROBjowwVzz/b10e/K OU3A== X-Gm-Message-State: AOAM531LBMegvhZYdCjee0k/etjbru6U1ki+J82GkTla99nFEYbPR35E rqdsXiQmPvCbqGmajzeJxWn4q+LjXavDxw== X-Received: by 2002:a2e:8992:: with SMTP id c18mr7903358lji.74.1619310652505; Sat, 24 Apr 2021 17:30:52 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id t5sm950352lfe.211.2021.04.24.17.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Apr 2021 17:30:52 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Andrew Lunn , Heiner Kallweit , Russell King , Linus Walleij Subject: [PATCH 2/3 net-next v4] net: ethernet: ixp4xx: Retire ancient phy retrieveal Date: Sun, 25 Apr 2021 02:30:37 +0200 Message-Id: <20210425003038.2937498-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210425003038.2937498-1-linus.walleij@linaro.org> References: <20210425003038.2937498-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This driver was using a really dated way of obtaining the phy by printing a string and using it with phy_connect(). Switch to using more reasonable modern interfaces. Suggested-by: Andrew Lunn Reviewed-by: Andrew Lunn Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - Collect Andrew's review tag ChangeLog v1->v3: - New patch --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.29.2 diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index 9defaa21a1a9..4df2686ac5b8 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -1360,7 +1360,6 @@ static const struct net_device_ops ixp4xx_netdev_ops = { 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; @@ -1462,14 +1461,15 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) __raw_writel(DEFAULT_CORE_CNTRL, &port->regs->core_control); udelay(50); - snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, - mdio_bus->id, plat->phy); - phydev = phy_connect(ndev, phy_id, &ixp4xx_adjust_link, - PHY_INTERFACE_MODE_MII); + phydev = mdiobus_get_phy(mdio_bus, plat->phy); if (IS_ERR(phydev)) { err = PTR_ERR(phydev); goto err_free_mem; } + err = phy_connect_direct(ndev, phydev, ixp4xx_adjust_link, + PHY_INTERFACE_MODE_MII); + if (err) + goto err_free_mem; phydev->irq = PHY_POLL; From patchwork Sun Apr 25 00:30:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 427266 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp2511738jao; Sat, 24 Apr 2021 17:31:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7FuIQ9CS4HUb9m3nWMyZKL8kM0GW5wFkn0MSo6v6vPnn18rbRAF9EC3qyHuNCnwC2FWB4 X-Received: by 2002:a17:906:7257:: with SMTP id n23mr11374250ejk.412.1619310660922; Sat, 24 Apr 2021 17:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619310660; cv=none; d=google.com; s=arc-20160816; b=ii66oHW9DtzLG2fPnScXUTr5wE5jvJj7NySELqP32Ww6e/k9+yjKoKozWytp6XJRAK jTsdTx5y37Eq+q6m9Wn2smwtyQnvhtGXXVTnZ3VgDFQG9e3FQS/3mPVvtMt9Vqdca70N fNW7kJKFOiNS9GuR7/fSXg64MrQcUdSyziOZ4NOAMCqsf+q9l1wpOO+R7jqDyxoS2kDZ rZKXwgBmu2Dlc+np1mNkdQIlA6CId0bihdPL+rq+A8ECRgi5vdmU88xSRVy2SSszYLKH hqE0XzOFr/TW087Ei0RIgMZRBEJtZa+FhaEpBUvKFYYsbHrihahA/hm3YJADH4+HUXmR XS4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZkG6pGr4FYaHlJ1HtdNybKAiBJP3aFKJkNsUXoVX4As=; b=edJI+Ff77/DFSPcShlH4rF+ciPXbC2X3WifD7j54uAj6g2n6aWt8NSsVyaITK2JFXE D3Dd0p6kaLBhK/beeyYNROOuRlUHZDDkmncb7pszDyW/2n3VXfeZHoqMFnMpf3ZpuMC6 B9S+3tlQoBQZoSA8dCthXdO6JKNikCWjE5Kb9liuiF9kcY+mMPmgR7+7dL6w0HXpXWY2 mIzgAjl7hSZva3r31K1GbaOh/ZqdpClEN6ZTy+dsZlclu67DQAtKMVG83A8PRK7NXlyw gsbH5Xd+KezLn0OKBlAgMZGvXoeF2D4NtDcbxRXxtGLHd6XvU541qF5iqTAEINT1A9MH Jz1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ta1a8+E4; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si9277216edv.521.2021.04.24.17.31.00; Sat, 24 Apr 2021 17:31:00 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ta1a8+E4; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbhDYAbh (ORCPT + 8 others); Sat, 24 Apr 2021 20:31:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbhDYAbf (ORCPT ); Sat, 24 Apr 2021 20:31:35 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A31C061574 for ; Sat, 24 Apr 2021 17:30:55 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id b38so18676491ljf.5 for ; Sat, 24 Apr 2021 17:30: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=ZkG6pGr4FYaHlJ1HtdNybKAiBJP3aFKJkNsUXoVX4As=; b=ta1a8+E4Z32qoQfr0+r5AHZZZSRicgaNJzJqvsx4lqaHu3KzBuxVvM0Ag7mXQ7vtPT JmWO3EVoaJu3ZbKLAHS7hejcILGguLNCuq2Pt/cQKib5oDUyX3yOUP6Q0ZLQcU/u8Ntw DlvWCUK5Cu3eIM6/RF7ZtB2/9j13PCvmXqOBMw7bQrvPK4mY+YaWNu2S7kluSvcE2R5n 8HZOYU6oA4nfEdWyMCqJvUkxkSudYk2wNpBKHugZ+uXYo/ce6eRY4PNUX/sCQ79KfryX RJmaecZtb+pY9otBK0iUE83VnwbwWGOsKWz8NyuzZ+hAgHh/z5FyCr1RfJ6Kcn5Wht8y ukVQ== 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=ZkG6pGr4FYaHlJ1HtdNybKAiBJP3aFKJkNsUXoVX4As=; b=hWL9/Awt/buTYrr7d4r+xj9AfO7X8enParfzfTHXNF+SwIuMuHeHG4CvGOfvd0Bx/X XotcXWRfZ0DqqI3X1ksXB2SsC8OujVdKPo9+ysV4sII2iVRzYHwh76yevofjCM3uq8YG PXxgy3q3rCMpg8221xEzIEvrGKpkN3J5YeUS5h5zxgaXwYXgkkvagJrN/IuM6CjeJ75K 7RI/8dpshbBRWvKOkMIQy8d2MoIWFtOdcnp1v7JrBAVkOvqKHeoanq0JTAdm1mHWCTNH NgrFU1VTUP357SavRa+Zhau75+FpDr/l3dl/wJ8T6v1YRGXHzVgLO9Ndp5ER8W4jwZ/m oJNQ== X-Gm-Message-State: AOAM533s9Va+CyZJj5M4Z3wUZXL/XiyPlpoqMacygMG9EQNzml4NYfMk f0MArKmaGYtLwWCnSgli7D79kFIoSzuEpw== X-Received: by 2002:a2e:9b51:: with SMTP id o17mr7397382ljj.315.1619310654084; Sat, 24 Apr 2021 17:30:54 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id t5sm950352lfe.211.2021.04.24.17.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Apr 2021 17:30:53 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" Cc: Andrew Lunn , Heiner Kallweit , Russell King , Linus Walleij , Zoltan HERPAI , Raylynn Knight Subject: [PATCH 3/3 net-next v4] net: ethernet: ixp4xx: Support device tree probing Date: Sun, 25 Apr 2021 02:30:38 +0200 Message-Id: <20210425003038.2937498-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210425003038.2937498-1-linus.walleij@linaro.org> References: <20210425003038.2937498-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This adds device tree probing to the IXP4xx ethernet driver. Add a platform data bool to tell us whether to register an MDIO bus for the device or not, as well as the corresponding NPE. We need to drop the memory region request as part of this since the OF core will request the memory for the device. Cc: Zoltan HERPAI Cc: Raylynn Knight Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - Use phandle to look up the NPE instance to use ChangeLog v2->v3: - Squash in the patch doing the MDIO bus transition to OF probing. ChangeLog v1->v2: - Do not rely on earlier attempt for identifying which ports to use: we split the support clearly in a DT way and a playform data way. - Isolate the DT code better. --- drivers/net/ethernet/xscale/Kconfig | 1 + drivers/net/ethernet/xscale/ixp4xx_eth.c | 210 ++++++++++++++++------- include/linux/platform_data/eth_ixp4xx.h | 2 + 3 files changed, 150 insertions(+), 63 deletions(-) -- 2.29.2 diff --git a/drivers/net/ethernet/xscale/Kconfig b/drivers/net/ethernet/xscale/Kconfig index 7b83a6e5d894..468ffe3d1707 100644 --- a/drivers/net/ethernet/xscale/Kconfig +++ b/drivers/net/ethernet/xscale/Kconfig @@ -22,6 +22,7 @@ config IXP4XX_ETH tristate "Intel IXP4xx Ethernet support" depends on ARM && ARCH_IXP4XX && IXP4XX_NPE && IXP4XX_QMGR select PHYLIB + select OF_MDIO if OF 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 4df2686ac5b8..cb89323855d8 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -165,7 +166,6 @@ struct eth_regs { }; struct port { - struct resource *mem_res; struct eth_regs __iomem *regs; struct npe *npe; struct net_device *netdev; @@ -250,6 +250,7 @@ static inline void memcpy_swab32(u32 *dest, u32 *src, int cnt) static DEFINE_SPINLOCK(mdio_lock); static struct eth_regs __iomem *mdio_regs; /* mdio command and status only */ static struct mii_bus *mdio_bus; +static struct device_node *mdio_bus_np; static int ports_open; static struct port *npe_port_tab[MAX_NPES]; static struct dma_pool *dma_pool; @@ -533,7 +534,8 @@ static int ixp4xx_mdio_register(struct eth_regs __iomem *regs) mdio_bus->write = &ixp4xx_mdio_write; snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "ixp4xx-eth-0"); - if ((err = mdiobus_register(mdio_bus))) + err = of_mdiobus_register(mdio_bus, mdio_bus_np); + if (err) mdiobus_free(mdio_bus); return err; } @@ -1358,18 +1360,118 @@ 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 of_phandle_args npe_spec; + struct device_node *mdio_np; + struct eth_plat_info *plat; + int ret; + + plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL); + if (!plat) + return NULL; + + ret = of_parse_phandle_with_fixed_args(np, "intel,npe-handle", 1, 0, + &npe_spec); + if (ret) { + dev_err(dev, "no NPE engine specified\n"); + return NULL; + } + /* NPE ID 0x00, 0x10, 0x20... */ + plat->npe = (npe_spec.args[0] << 4); + + /* Check if this device has an MDIO bus */ + mdio_np = of_get_child_by_name(np, "mdio"); + if (mdio_np) { + plat->has_mdio = true; + mdio_bus_np = mdio_np; + /* DO NOT put the mdio_np, it will be used */ + } + + /* 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) { struct phy_device *phydev = NULL; struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; 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 (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; + } + } if (!(ndev = devm_alloc_etherdev(dev, sizeof(struct port)))) return -ENOMEM; @@ -1377,59 +1479,29 @@ 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; + port->id = plat->npe; /* 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); if (IS_ERR(port->regs)) return PTR_ERR(port->regs); - switch (port->id) { - case IXP4XX_ETH_NPEA: - /* If the MDIO bus is not up yet, defer probe */ - if (!mdio_bus) - return -EPROBE_DEFER; - 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(port->regs))) - return err; - } - if (!mdio_bus) - return -EPROBE_DEFER; - 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(port->regs))) - return err; + /* Register the MDIO bus if we have it */ + if (plat->has_mdio) { + err = ixp4xx_mdio_register(port->regs); + if (err) { + dev_err(dev, "failed to register MDIO bus\n"); + return err; } - if (!mdio_bus) - return -EPROBE_DEFER; - break; - default: - return -ENODEV; } + /* If the instance with the MDIO bus has not yet appeared, + * defer probing until it gets probed. + */ + if (!mdio_bus) + return -EPROBE_DEFER; ndev->netdev_ops = &ixp4xx_netdev_ops; ndev->ethtool_ops = &ixp4xx_ethtool_ops; @@ -1443,12 +1515,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); @@ -1461,15 +1527,26 @@ static int ixp4xx_eth_probe(struct platform_device *pdev) __raw_writel(DEFAULT_CORE_CNTRL, &port->regs->core_control); udelay(50); - phydev = mdiobus_get_phy(mdio_bus, plat->phy); - if (IS_ERR(phydev)) { - err = PTR_ERR(phydev); - goto err_free_mem; + if (np) { + phydev = of_phy_get_and_connect(ndev, np, ixp4xx_adjust_link); + } else { + phydev = mdiobus_get_phy(mdio_bus, plat->phy); + if (IS_ERR(phydev)) { + err = PTR_ERR(phydev); + 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; + } - err = phy_connect_direct(ndev, phydev, ixp4xx_adjust_link, - PHY_INTERFACE_MODE_MII); - if (err) + if (!phydev) { + err = -ENODEV; + dev_err(dev, "no phydev\n"); goto err_free_mem; + } phydev->irq = PHY_POLL; @@ -1485,8 +1562,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; } @@ -1502,12 +1577,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, }; diff --git a/include/linux/platform_data/eth_ixp4xx.h b/include/linux/platform_data/eth_ixp4xx.h index 6f652ea0c6ae..114b0940729f 100644 --- a/include/linux/platform_data/eth_ixp4xx.h +++ b/include/linux/platform_data/eth_ixp4xx.h @@ -14,6 +14,8 @@ struct eth_plat_info { 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