From patchwork Thu Jun 30 14:02:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12901920 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 BBB6ECCA482 for ; Thu, 30 Jun 2022 14:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236078AbiF3OTP (ORCPT ); Thu, 30 Jun 2022 10:19:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237349AbiF3OSA (ORCPT ); Thu, 30 Jun 2022 10:18:00 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42FD250707; Thu, 30 Jun 2022 07:02:49 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id DA0F522248; Thu, 30 Jun 2022 16:02:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656597767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ass4dmeUBL1qbJ56Qd90hEzwbZXn4e7pswz+/m2UBRk=; b=XBGzYxbEe8yNmRuCYQV3Mm+5nZvD3U9eVQfguks0tK5VG7PGFDd5prmlhfl5MRyCV1jAm+ IEjXAZMz6fnp9oD2nlJo5uHxtmO+/4pLXME6nKXMzNUxJbMpQ6/o0CIi9R05J4/eMLgW2m VrKn19wzHs1fV9xvx+Hum1jhfnA7CPY= From: Michael Walle To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Horatiu Vultur Cc: UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net-next 1/4] net: lan966x: hardcode the number of external ports Date: Thu, 30 Jun 2022 16:02:34 +0200 Message-Id: <20220630140237.692986-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220630140237.692986-1-michael@walle.cc> References: <20220630140237.692986-1-michael@walle.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Instead of counting the child nodes in the device tree, hardcode the number of ports in the driver itself. The counting won't work at all if an ethernet port is marked as disabled, eg. because it is not connected on the board at all. This is hardcoding the number of ports to eight for the generic compatible string "microchip,lan966x-switch", although it clearly only applies to the LAN9668. This is because, first, there is only one user for now, and that is the LAN9668 and second, the generic compatible string will be deprecated in favor of a more specific one. Therefore, if there will be support for the LAN9662, it can be added by another specific compatible string. Signed-off-by: Michael Walle --- .../ethernet/microchip/lan966x/lan966x_main.c | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 5784c4161e5e..d611b52d3a07 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -26,8 +26,16 @@ #define IO_RANGES 2 +struct lan966x_info { + u8 num_phys_ports; +}; + +static const struct lan966x_info lan9668_info = { + .num_phys_ports = 8, +}; + static const struct of_device_id lan966x_match[] = { - { .compatible = "microchip,lan966x-switch" }, + { .compatible = "microchip,lan966x-switch", .data = &lan9668_info }, { } }; MODULE_DEVICE_TABLE(of, lan966x_match); @@ -992,9 +1000,10 @@ static int lan966x_reset_switch(struct lan966x *lan966x) static int lan966x_probe(struct platform_device *pdev) { struct fwnode_handle *ports, *portnp; + const struct lan966x_info *info; struct lan966x *lan966x; u8 mac_addr[ETH_ALEN]; - int err, i; + int err; lan966x = devm_kzalloc(&pdev->dev, sizeof(*lan966x), GFP_KERNEL); if (!lan966x) @@ -1003,6 +1012,10 @@ static int lan966x_probe(struct platform_device *pdev) platform_set_drvdata(pdev, lan966x); lan966x->dev = &pdev->dev; + info = device_get_match_data(&pdev->dev); + if (!info) + return -ENODEV; + if (!device_get_mac_address(&pdev->dev, mac_addr)) { ether_addr_copy(lan966x->base_mac, mac_addr); } else { @@ -1025,11 +1038,7 @@ static int lan966x_probe(struct platform_device *pdev) if (err) return dev_err_probe(&pdev->dev, err, "Reset failed"); - i = 0; - fwnode_for_each_available_child_node(ports, portnp) - ++i; - - lan966x->num_phys_ports = i; + lan966x->num_phys_ports = info->num_phys_ports; lan966x->ports = devm_kcalloc(&pdev->dev, lan966x->num_phys_ports, sizeof(struct lan966x_port *), GFP_KERNEL); From patchwork Thu Jun 30 14:02:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12901918 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 4EF00C43334 for ; Thu, 30 Jun 2022 14:19:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235863AbiF3OTK (ORCPT ); Thu, 30 Jun 2022 10:19:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237359AbiF3OSB (ORCPT ); Thu, 30 Jun 2022 10:18:01 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE6DC5072F; Thu, 30 Jun 2022 07:02:49 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 9D0F42224D; Thu, 30 Jun 2022 16:02:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656597767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=12Z1dZv/k/yp4l3O9HLH7NjySFJLvOxGysIjdKUevr8=; b=AKQpvAMWVQwCaE1ZFZAXrVaId7Qck7dGHqzTvkcDIcjrhcLRnIvEO9vNg0yGsISkBs9+BN P6L1CYp2ULKGDaSvQMVyjNpjiFIEpxQmfV9VA6DFKdyQlxpUn2NHSHFDnMgvIMn3Pf/pQW D/+h+G//ZN11p1qUyNEUJQoDU17NXSw= From: Michael Walle To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Horatiu Vultur Cc: UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net-next 2/4] dt-bindings: net: lan966x: add specific compatible string Date: Thu, 30 Jun 2022 16:02:35 +0200 Message-Id: <20220630140237.692986-3-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220630140237.692986-1-michael@walle.cc> References: <20220630140237.692986-1-michael@walle.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add a specific compatible string for the LAN9668 and deprecate the old one. Signed-off-by: Michael Walle --- .../devicetree/bindings/net/microchip,lan966x-switch.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/net/microchip,lan966x-switch.yaml b/Documentation/devicetree/bindings/net/microchip,lan966x-switch.yaml index dc116f14750e..efd6bbd51d68 100644 --- a/Documentation/devicetree/bindings/net/microchip,lan966x-switch.yaml +++ b/Documentation/devicetree/bindings/net/microchip,lan966x-switch.yaml @@ -20,7 +20,10 @@ properties: pattern: "^switch@[0-9a-f]+$" compatible: - const: microchip,lan966x-switch + oneOf: + - const: microchip,lan9668-switch + - const: microchip,lan966x-switch + deprecated: true reg: items: From patchwork Thu Jun 30 14:02:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12901917 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 318C0CCA481 for ; Thu, 30 Jun 2022 14:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235521AbiF3OTI (ORCPT ); Thu, 30 Jun 2022 10:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237361AbiF3OSB (ORCPT ); Thu, 30 Jun 2022 10:18:01 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 630DA50734; Thu, 30 Jun 2022 07:02:50 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 8706422249; Thu, 30 Jun 2022 16:02:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656597768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kQyPXI6BbKEMw79a2SpHlnjL6fNse7z3fzhKXJC+JgE=; b=UxGIrxTsgQhg7VufwvHneZzuNX03YyraxI2wV56TO6geI0Mi+JOI71vvIH+zt8Dp6EHDW6 TZVCUqvYthlUdNoyNFuc93hNMikSr1Vmz+SNCulN6TX4dlFwxKfHxfJNC/Zzp6nniXxlMB 8uTTtAXf2Ls7IpahT2OVItd4EBcjcK8= From: Michael Walle To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Horatiu Vultur Cc: UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net-next 3/4] net: lan966x: add new compatible microchip,lan9668-switch Date: Thu, 30 Jun 2022 16:02:36 +0200 Message-Id: <20220630140237.692986-4-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220630140237.692986-1-michael@walle.cc> References: <20220630140237.692986-1-michael@walle.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The old generic compatible string is deprecated. Add the new specific one. Signed-off-by: Michael Walle --- drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index d611b52d3a07..adc5474041a6 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -35,6 +35,7 @@ static const struct lan966x_info lan9668_info = { }; static const struct of_device_id lan966x_match[] = { + { .compatible = "microchip,lan9668-switch", .data = &lan9668_info }, { .compatible = "microchip,lan966x-switch", .data = &lan9668_info }, { } }; From patchwork Thu Jun 30 14:02:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12901921 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 81A65C433EF for ; Thu, 30 Jun 2022 14:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236899AbiF3OTQ (ORCPT ); Thu, 30 Jun 2022 10:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237367AbiF3OSC (ORCPT ); Thu, 30 Jun 2022 10:18:02 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCA0C50736; Thu, 30 Jun 2022 07:02:50 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id CDA4C2224E; Thu, 30 Jun 2022 16:02:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656597769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3CR+PnyevN7pgniuldx+d+XwCOYJhZzOjzZDWONl6gI=; b=R02lbuCh2RmzAMQ4bLQsGfBhtYPwp6ltpBggNoL4dL04NWUS8Orjjp5OQuXDY/PaDwES34 Q3m3VvDI/gJ/AnOzjG4eFXo+Rny4MdpjHE03aTTKU9hkRieUYMb1HGeiFNv2A0TKlSo39u rIqkIEw2XnNfT/zYHQpayydWU7YxOyM= From: Michael Walle To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Horatiu Vultur Cc: UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net-next 4/4] ARM: dts: lan966x: use new microchip,lan9668-switch compatible Date: Thu, 30 Jun 2022 16:02:37 +0200 Message-Id: <20220630140237.692986-5-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220630140237.692986-1-michael@walle.cc> References: <20220630140237.692986-1-michael@walle.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The old generic microchip,lan966x-switch compatible string was deprecated. Use the new one. Signed-off-by: Michael Walle --- arch/arm/boot/dts/lan966x.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/lan966x.dtsi b/arch/arm/boot/dts/lan966x.dtsi index 48971d80c82c..da0657c57cdf 100644 --- a/arch/arm/boot/dts/lan966x.dtsi +++ b/arch/arm/boot/dts/lan966x.dtsi @@ -85,7 +85,7 @@ soc { ranges; switch: switch@e0000000 { - compatible = "microchip,lan966x-switch"; + compatible = "microchip,lan9668-switch"; reg = <0xe0000000 0x0100000>, <0xe2000000 0x0800000>; reg-names = "cpu", "gcb";