Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp192489iob; Mon, 2 May 2022 16:48:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiPLHC8uzyj+q/s3LF7/lpUKGrvpR4tmsvjSIq/wZ8QhGY030HEPF99L4rZCiIvSNeROju X-Received: by 2002:a17:90a:4581:b0:1bc:d215:8722 with SMTP id v1-20020a17090a458100b001bcd2158722mr1724781pjg.149.1651535310605; Mon, 02 May 2022 16:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651535310; cv=none; d=google.com; s=arc-20160816; b=wQa+57CJ2fjc9pCwreJXD/FPEjuhE/9JcuoyOkpeF3UAgpczpnsgWK97/f5GR2j7Zh BoXlHizm2pAt7L7LnywPsSSIbSutCdzm9v4gVHQUO851KJ5KZc8riKM2+0IYneGO77LA s/lA3Sp438b0/Dg7N7/2/9wzpef+McA6zNNZQGKqw1AafuWp4U6jQbLKqq5cOYWPymaW obFBvkSvpz54vkGv950M0RwNVvUrKes5cNItqEohXFjoHbvu0dpy9pZz6s6mPwsul6GX t9HFq71KT7+1AEbo8ZbRu9Mv1S62NYq+aN2Q4IpBpNXdsAnZTDR0XNc9S3NmV4+4hUfw LbZg== 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=LfsvQJQSzl8CIsJRZhpttH4V4tci5c+LrDqCSmvZG2E=; b=WhdZ52v4u/dhgTyxyNte2zYe07H54TyDA3C4F2FbvYCdo1wx2ot1kWRCKkXNDxqxZy coDX5tOCAP2GQFGydyIFQo1Cpe34VgpE46Svl33JwpnYu44swxOHPgYrDgh3fm/ZcQ0R 7qd7NTfjrqL9M/FKmqYfb9CNEbMrUrJwlMOqxSGRPbz1whQy2LrM08AhT2DJyUOpnqIC RiZYnLVupNGXwcijOI7v8QUTCPmVhOOMDwLXZByet2dms/npMNmmHhHw1ZS2Q3tIzvfL J0xLRh8QrHbIVHQ9EBJ0IYcZjwgjEakHCEFtPaacBXcL5/kFLdVLYht7f+GZA/4SKpBm hyWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b=ZTEMI1rK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pf14-20020a17090b1d8e00b001c9e1e7acc8si758630pjb.22.2022.05.02.16.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:48:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b=ZTEMI1rK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3ACC5338AA; Mon, 2 May 2022 16:48:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382632AbiD3NHd (ORCPT + 99 others); Sat, 30 Apr 2022 09:07:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382595AbiD3NH0 (ORCPT ); Sat, 30 Apr 2022 09:07:26 -0400 Received: from mxout3.routing.net (mxout3.routing.net [IPv6:2a03:2900:1:a::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3735A80722; Sat, 30 Apr 2022 06:04:03 -0700 (PDT) Received: from mxbox3.masterlogin.de (unknown [192.168.10.78]) by mxout3.routing.net (Postfix) with ESMTP id 695D060558; Sat, 30 Apr 2022 13:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1651323842; 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=LfsvQJQSzl8CIsJRZhpttH4V4tci5c+LrDqCSmvZG2E=; b=ZTEMI1rKV8GDE6M6mu1N2eCI7XNXn7tl0UQr2KIYUdn8YCDBjwMrTQ7HJcrYlZJ4REZ/G/ CvF5jxPiMkDvbl1ieKdY1cB5AL9GALl1SSoIo4/Lq6ETm0+AicgFp5oyYX94WlyE8GnNoH XOWldNgLLH58VSRaWkzHD6moPx7RS+s= Received: from localhost.localdomain (fttx-pool-80.245.72.211.bambit.de [80.245.72.211]) by mxbox3.masterlogin.de (Postfix) with ESMTPSA id 4E44B3605FC; Sat, 30 Apr 2022 13:04:01 +0000 (UTC) From: Frank Wunderlich To: linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Frank Wunderlich , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Peter Geis , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC v2 2/4] net: dsa: mt7530: rework mt753[01]_setup Date: Sat, 30 Apr 2022 15:03:45 +0200 Message-Id: <20220430130347.15190-3-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220430130347.15190-1-linux@fw-web.de> References: <20220430130347.15190-1-linux@fw-web.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mail-ID: 4c126447-4b4c-4737-bb96-3b868640f48f X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frank Wunderlich Enumerate available cpu-ports instead of using hardcoded constant. Suggested-by: Vladimir Oltean Signed-off-by: Frank Wunderlich --- drivers/net/dsa/mt7530.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 46dee0714382..144c29f8fefc 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2087,11 +2087,12 @@ static int mt7530_setup(struct dsa_switch *ds) { struct mt7530_priv *priv = ds->priv; + struct device_node *dn = NULL; struct device_node *phy_node; struct device_node *mac_np; struct mt7530_dummy_poll p; phy_interface_t interface; - struct device_node *dn; + struct dsa_port *cpu_dp; u32 id, val; int ret, i; @@ -2099,7 +2100,19 @@ mt7530_setup(struct dsa_switch *ds) * controller also is the container for two GMACs nodes representing * as two netdev instances. */ - dn = dsa_to_port(ds, MT7530_CPU_PORT)->master->dev.of_node->parent; + dsa_switch_for_each_cpu_port(cpu_dp, ds) { + dn = cpu_dp->master->dev.of_node->parent; + /* It doesn't matter which CPU port is found first, + * their masters should share the same parent OF node + */ + break; + } + + if (!dn) { + dev_err(ds->dev, "parent OF node of DSA master not found"); + return -EINVAL; + } + ds->assisted_learning_on_cpu_port = true; ds->mtu_enforcement_ingress = true; @@ -2260,6 +2273,7 @@ mt7531_setup(struct dsa_switch *ds) { struct mt7530_priv *priv = ds->priv; struct mt7530_dummy_poll p; + struct dsa_port *cpu_dp; u32 val, id; int ret, i; @@ -2332,8 +2346,11 @@ mt7531_setup(struct dsa_switch *ds) CORE_PLL_GROUP4, val); /* BPDU to CPU port */ - mt7530_rmw(priv, MT7531_CFC, MT7531_CPU_PMAP_MASK, - BIT(MT7530_CPU_PORT)); + dsa_switch_for_each_cpu_port(cpu_dp, ds) { + mt7530_rmw(priv, MT7531_CFC, MT7531_CPU_PMAP_MASK, + BIT(cpu_dp->index)); + break; + } mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK, MT753X_BPDU_CPU_ONLY); -- 2.25.1