Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4590405iob; Sun, 8 May 2022 18:27:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymfj57ZyqKHy9OLDL6AKIhCNMFTVfgRDiQOtVUqnA2siwZ0WPTkBL615w8zSUJfx+8p8h8 X-Received: by 2002:a63:9043:0:b0:3c6:3550:6467 with SMTP id a64-20020a639043000000b003c635506467mr11238857pge.521.1652059635695; Sun, 08 May 2022 18:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652059635; cv=none; d=google.com; s=arc-20160816; b=Czx01aQ+PYWwxYj0/r9ZJKEFgzWr4Sy8cK19vM8fRbbKXUfHOcYs1rmbEJ61yNBnYW LeZosdop6oBtl4mGMyuQO6U2is4kv2iCY76UB1ii9AWgXziwVCtez3Tiuf1TXQZ3b+dd eD439N86dZplhv+4iR1DZxFcpodAiZ7k6L5YJr3JgDnbm/KCU7+47P5SHk7WQ+ufY+gL KUvjeRNRcqKilesKJdyMvdB/cHCqd091BKxQUFMGcBLMw9rHwJcDaO+lhYKqvUFTYSmf AHqgPTXNGYPwygCcdwfJVn1UhZkOB1GvkE1afgrf1ZIVPGW0+JaKR0GcLS9ZWmlCkqMz wwNQ== 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=BOY0bxdUhNN3M6I8q15fOn3ipf8lrnx60tc5aC+4lnk=; b=Mmy+m7/nUzmjgcGsfc+rn/Z7B77DGnrXfcGzXvu6I7FqyA3lnavVDaeXT1WKeeAxt5 PPMLbecJzsUVOwTMW90TzJYqnubMafTac7Wfl1U8h93cEjln37mRmQmOG19vk9kbFDxS +LNbq2NF0ZEOh70Cr510ajjFHJlfbidm1N4Cuky4FoxIVzNlU/0PpmQIhsDiC1asdEvh /d0TwuVunDGxVK9cO0c5zjFahdfoKr2WA7D9Zc913ocnpU+ruO+EaNUcfM19+v0lPcKb XPw4m1k6VpHDD3h440shi7oMFL/k5qrKuiebkxy/vntPzJjVbEY5eCvMy6PS+TrWRlU9 NLuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mailerdienst.de header.s=20200217 header.b=nqkLXOeS; 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 q8-20020a656a88000000b003aa91d7703esi13737093pgu.812.2022.05.08.18.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 18:27:15 -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=nqkLXOeS; 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 98289167C9; Sun, 8 May 2022 18:26:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446688AbiEGRKA (ORCPT + 99 others); Sat, 7 May 2022 13:10:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1446663AbiEGRIm (ORCPT ); Sat, 7 May 2022 13:08:42 -0400 Received: from mxout2.routing.net (mxout2.routing.net [IPv6:2a03:2900:1:a::b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42D8E1BEB6; Sat, 7 May 2022 10:04:55 -0700 (PDT) Received: from mxbox4.masterlogin.de (unknown [192.168.10.79]) by mxout2.routing.net (Postfix) with ESMTP id 787F05FBBE; Sat, 7 May 2022 17:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1651943093; 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=BOY0bxdUhNN3M6I8q15fOn3ipf8lrnx60tc5aC+4lnk=; b=nqkLXOeSkx0VfNka4n7l/jrc0pql7icRrrm1B91MdHmrdpcESrNV1P4BaIkCM3JCbqM2hD 9O1tZEwMLOfWwvClUDqVJz2knCu6bIURMi5440WnFj796Ib/kVEBvjMY9kWMn6kfrhwLVd OrOYwZNMTn/YUNw7Yj2sg0TEqKO8eZg= Received: from localhost.localdomain (fttx-pool-80.245.74.2.bambit.de [80.245.74.2]) by mxbox4.masterlogin.de (Postfix) with ESMTPSA id 618EA800E7; Sat, 7 May 2022 17:04:52 +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" , 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 v3 3/6] net: dsa: mt7530: rework mt753[01]_setup Date: Sat, 7 May 2022 19:04:37 +0200 Message-Id: <20220507170440.64005-4-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507170440.64005-1-linux@fw-web.de> References: <20220507170440.64005-1-linux@fw-web.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mail-ID: fbc2c6b2-366b-40c3-9cbd-9defd045faa2 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 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 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