Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1613833iol; Fri, 10 Jun 2022 10:57:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/xcltqmv4HHNUK1rSQZBXIR5XUljae0mVjxTJKhu6uhGz0mpN1HSDPeMdxhccfs3zryII X-Received: by 2002:a17:90b:240e:b0:1e0:775b:f8fc with SMTP id nr14-20020a17090b240e00b001e0775bf8fcmr913396pjb.132.1654883866709; Fri, 10 Jun 2022 10:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654883866; cv=none; d=google.com; s=arc-20160816; b=Ecqo0/5aLbB1zSBLD9Vp7gh5b85bNQqDTJCHr8vlmsf9fcHbtoqIpDvQggk+kvRmhD 2XIavUomZDu2u7fY6hk7t/f3sr6EMVMUcGy5GaagQ6d7QYedLki9rv1UqthxM0cUEdoH tCClWkUawTpPChrXFOG5d2hLjqP/slPTvgJ7Wp+iQDSnNU91/IlHwiEFFe94oA0hMGaJ AfC7YYTIR9sdMyW+4uQNgBFZDgvLOr23W2Qfqk+uSotwMDBma3zvso0Odazg/yZQZUiD WqOfIP5vv9vRH/ato5gkevF4CrlMOaKj2k/ToiEP1c0cZztMD6korR5sgehMDmwhcahd Xnwg== 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=pxv03Pmlp9C51iPM8l4XVYMHrHTRmQJueLNoENFoo/4=; b=mNus3qFrutls1UpVT331JV3YdYCBDGtNtXv4/zgMUyEKGeYxqJYNgbW79388hu9uPD R8vM+QsaRq9uKtNnBl+Mm8pjNibRqdJ0jUn7Wgdk9pN9ZgtsBn9Sjnmuxzm3X9jJdShU xfOoZJ0lqRG2Z3WP5vdAny6O+66cZnka5wO5a8Lu9SmQuA4qGY+oCeXkKMkiVuPlD5ov Imqsh6HMM97jG3sDjFKdZFGx6Ry+YuI7qCN3cWgsjWtXfM2NKjV/BRwT10Wts8cQSRFn EqhSPDG9RIqAG/RWNqIqaRrg2IhJVF135dHg+TaAMIZJLLa162cA2yXFXQiXmMsr8gIb s87w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b="U7/Qt9io"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020a170902e89100b001620ad77764si29966809plg.522.2022.06.10.10.57.34; Fri, 10 Jun 2022 10:57:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b="U7/Qt9io"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350133AbiFJRHD (ORCPT + 99 others); Fri, 10 Jun 2022 13:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243758AbiFJRGQ (ORCPT ); Fri, 10 Jun 2022 13:06:16 -0400 Received: from mxout4.routing.net (mxout4.routing.net [IPv6:2a03:2900:1:a::9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D0E18B28; Fri, 10 Jun 2022 10:06:13 -0700 (PDT) Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout4.routing.net (Postfix) with ESMTP id ACCEC10075B; Fri, 10 Jun 2022 17:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1654880771; 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=pxv03Pmlp9C51iPM8l4XVYMHrHTRmQJueLNoENFoo/4=; b=U7/Qt9io0Kjg8X/YQDUSxgtln8W/s/mX7n3rczykJespwE+Hl/yhIBf4zZTAN64adoWoEL /2ESM+wI0d9hwOBW4dVAHeZzFXdhYlVHoR5Cr47fFc8h3QeMQjXKHnU/Pr7rgsceRR8Ca7 bkdcKdyzsPsgHUBPA4RG2CXE3SczoTA= Received: from frank-G5.. (fttx-pool-217.61.154.155.bambit.de [217.61.154.155]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id 45CFE1008BF; Fri, 10 Jun 2022 17:06:09 +0000 (UTC) From: Frank Wunderlich To: linux-rockchip@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Frank Wunderlich , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Heiko Stuebner , Sean Wang , Landen Chao , DENG Qingfang , Peter Geis , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Greg Ungerer , =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= , "Mauro Carvalho Chehab" Subject: [PATCH v4 3/6] net: dsa: mt7530: rework mt753[01]_setup Date: Fri, 10 Jun 2022 19:05:38 +0200 Message-Id: <20220610170541.8643-4-linux@fw-web.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220610170541.8643-1-linux@fw-web.de> References: <20220610170541.8643-1-linux@fw-web.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mail-ID: 02da0cd3-b505-41b5-8d21-d43d11ee0763 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 Reviewed-by: Vladimir Oltean --- 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 c1922eaba67a..9c14e46692ee 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2092,11 +2092,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; @@ -2104,7 +2105,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; @@ -2266,6 +2279,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; @@ -2338,8 +2352,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.34.1