From patchwork Fri Apr 21 14:36:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220169 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB92AC77B71 for ; Fri, 21 Apr 2023 14:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Sx7QT+CfbRJuf7ipyvzI9VLyvr32Uv9zIwCFOCdllC4=; b=o1Bfg2v2FFqEnl MN6C1+x4jMicX6gd2/RXin9x6y6RHI+CHfRbYDaZDCnE9NRaASv1GmbflJ2nPZE4DZc948U/eSrbv M17UGqmWiMbVyLviZrGVpTr+ZSbOfKaTmLY3kgIWxpp8/vRqGAe7lxsx47Dcsap+zKqnY6bgueUN4 pZUY9nAd0PQEsk5I6r5YsRC3fknaJtQQRjDc2sclmmH4oBQMCKaKJNoHO6Fq9lN3SA1EyU/LkQOzl tLwESxRcwgmyMqWiQDONIG6hGyO6YJHpscBVeIgs70EH3i73Y7aTl5j2mtYhD2MgF6YaTE77WO6Oq y8h2958I7D7xKuRCdL8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprss-00B7Qw-0d; Fri, 21 Apr 2023 14:37:10 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprsh-00B7MI-14; Fri, 21 Apr 2023 14:37:00 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-506bfe81303so2882074a12.1; Fri, 21 Apr 2023 07:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087817; x=1684679817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Sx7QT+CfbRJuf7ipyvzI9VLyvr32Uv9zIwCFOCdllC4=; b=KqBupMCSod70Y958ehISGx6H0Hk58VkXRikprYBBIiecgLGS2MTLleCo9SvhmvEkKU jz8vsoBNeqrXcrN/Scju08aE8xCnHKNyPIlAli3EUe30khELo6b869qwOPDjJMGW4WSb Ok5wOYo8sXFwMCJsD50BKU1ISbchY0wIMPXyYBM6hn1lAWrZF9oLi24Y3npmGA6fKixt oP0dEmwcIby2+JVIyKO8PB1MREpqZ6FTmn6woSIsssN1H6QdVXY3MirHpdu/heK45XNT MHqCbJpAG+37GRfLIlTGePKQysSzWtbNtOQoec9KNjm5OpmtW43wlpJa3WZCZ85114/Y LxIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087817; x=1684679817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sx7QT+CfbRJuf7ipyvzI9VLyvr32Uv9zIwCFOCdllC4=; b=AUgEruWc31LAEHWVC3f9mitRt4aaXYGuLcweDjnlLy+Cncd17B+ghtSlRi51cDfouS HVRB86tA5/3FMfbZ/Jjvr0Bq0pCDEktvvhGSVz57gT2c/w58nuFsdgF7snPhMQgxfnIs WrwXICVfie3p7hocRQIkd065T81+7pwPEyaAeqESgaiws6on+UWz50WpaorEgpjiV58U FF2QR3CFlTC5rtjAg0pzy0Rt4Zl32DTzXydans7uCgTwV72VJLY8wGEIyjk9cTqFqgup kZHRl3HzgfggtV/D1wpFirK9lwzZYB0HLXZy7m4g8WGJmWYbJ5hr+9scl3ObtZrCCyBa q6Gg== X-Gm-Message-State: AAQBX9cUdGKJH52fjtbe5zWXy9hvv6OAr8e5d2RqX8IpGGhjA76JkDl0 MUkW4ZUftJLIKdw0/tBvbxA= X-Google-Smtp-Source: AKy350bB4/HdrT8woCCbxfnAVBekFnXUuEGFqFUKrXHi90jUUFu7MVJKe0mP9T5GsJvC/eqr454dDg== X-Received: by 2002:a17:907:9503:b0:92c:8e4a:1a42 with SMTP id ew3-20020a170907950300b0092c8e4a1a42mr2100787ejc.32.1682087817083; Fri, 21 Apr 2023 07:36:57 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:36:56 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 01/22] net: dsa: mt7530: add missing @p5_interface to mt7530_priv description Date: Fri, 21 Apr 2023 17:36:27 +0300 Message-Id: <20230421143648.87889-2-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073659_365962_3C36CCE5 X-CRM114-Status: GOOD ( 11.05 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL Add the missing p5_interface field to the mt7530_priv description. Sort out the description in the process. Signed-off-by: Arınç ÜNAL Acked-by: Daniel Golle --- drivers/net/dsa/mt7530.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 5084f48a8869..845f5dd16d83 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -746,7 +746,8 @@ struct mt753x_info { * @ports: Holding the state among ports * @reg_mutex: The lock for protecting among process accessing * registers - * @p6_interface Holding the current port 6 interface + * @p6_interface: Holding the current port 6 interface + * @p5_interface: Holding the current port 5 interface * @p5_intf_sel: Holding the current port 5 interface select * @irq: IRQ number of the switch * @irq_domain: IRQ domain of the switch irq_chip From patchwork Fri Apr 21 14:36:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220170 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B271EC77B7D for ; Fri, 21 Apr 2023 14:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ky+vCKIfIiAses7wm+VhQnJsA7JRQIkV7aT9O8NnSM4=; b=tf3twdk/SSJjf7 rdobPcRCCeXKPWaAjvlY3LJCYEmKMEiP7PzB5Ak77xq1JQf7h2aKjE6sjF3H49l+t1l/uYPzD0mKE AziuSIvZsVcuvSwHC1ixd4GfIS1ZjjXJLnFRe0DhYrc1XC+XNBcux7Dw9meViRFq08CrnwOtLO5HN mrQwP2LaRvx6x2iD/bi1JPuB65uO0ZzgUR5L2aOx413ZE5ke0YlmlMc7rOlsBvQkV/TkGzbsRsHm9 Ze3DP+N4UrzyxUNd6dq4NbSDHreHSDIt1acZnFvrnOw7D68onUiAGYtz8S2xByysDhBgP9hnIsGuD eWJwUITueaZ+htoVGTJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprsx-00B7Ty-1r; Fri, 21 Apr 2023 14:37:15 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprsj-00B7Me-2A; Fri, 21 Apr 2023 14:37:03 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-504e232fe47so3055603a12.2; Fri, 21 Apr 2023 07:37:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087819; x=1684679819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ky+vCKIfIiAses7wm+VhQnJsA7JRQIkV7aT9O8NnSM4=; b=JkNU3RYgFoSLMWgh/VBkhcwU7mLl8IiDCifX8wVnqze/zgB1CeEZGvERps4u1RBZFE M2R2OUPNjjEvXJA3Or//um/W0YjpmqUvwXxpNRpjytT3INQY8bnvf/3ZUe3Lsfu78XHt 0mNJXEdZkn3HLmOF+KmUiyEnYe6x9SVznI7dKN3bunN5qweRKS/o+0VQ7LaWs9HI7Raj 4TJD7/iRte+KdeyzVWCPvwSfhB28YqkxaJyHGTZzAs9DLFGqWShrI/ZYXCYzGdRij/LS Hx+7I4uLHvYorXR7XYC691xbyxAlqgpNmoY/78A5bmf5Xd7HTSxjS2JMeblqwtxXZDU/ 5dGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087819; x=1684679819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ky+vCKIfIiAses7wm+VhQnJsA7JRQIkV7aT9O8NnSM4=; b=lFnUPUHXB9Ju/vslLPTU/7+KmyUbcBgeG9Ettvs/DVbe4p271IkDslXlxQJ2WsclYh fE5mGrV8o2DBj5GAIE+HZ0VkkSvWCKiufyIDV3sFhB/7WWYOrHPT4l44bvIBgNdGRfzN 22xEOkmVCymPW531i7ZqkdHBJsDCEKwI8FjqYisN/n3Vtdcaq/Ifczr+GDqmfhYBTQtr G9TXiKw/Xh7u6mfKbCtM702+E6esJF57cCZAiZ40Z/ydglFLK8ay7nE4/GUdU+bOBSZm Yd610+GKjig3a6dB59jR7BWk7bEXU/ACQlKoebsU/OSRgefvxWpZ3spK+rFQmVNBX87K jHEQ== X-Gm-Message-State: AAQBX9fTL1PNFvlOPNtc/UQ+SZqY9FEn2p74vUVZkjzNuSKpT3E60+Vr zmtWJgE5a8rqyLjEl3OVCFg= X-Google-Smtp-Source: AKy350ZHGVK6DhQPdnGjNA5o+ZJP/s1xmVPUOGC6O2Hiw050NMaMz7fy8HuE7hXWqtji8iXZX9EFwg== X-Received: by 2002:a17:906:114c:b0:94f:3312:3daf with SMTP id i12-20020a170906114c00b0094f33123dafmr2160291eja.66.1682087819307; Fri, 21 Apr 2023 07:36:59 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:36:59 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 02/22] net: dsa: mt7530: use p5_interface_select as data type for p5_intf_sel Date: Fri, 21 Apr 2023 17:36:28 +0300 Message-Id: <20230421143648.87889-3-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073701_713236_EBD05351 X-CRM114-Status: GOOD ( 11.67 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL Use the p5_interface_select enumeration as the data type for the p5_intf_sel field. This ensures p5_intf_sel can only take the values defined in the p5_interface_select enumeration. Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 845f5dd16d83..703f8a528317 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -674,13 +674,13 @@ struct mt7530_port { }; /* Port 5 interface select definitions */ -enum p5_interface_select { - P5_DISABLED = 0, +typedef enum { + P5_DISABLED, P5_INTF_SEL_PHY_P0, P5_INTF_SEL_PHY_P4, P5_INTF_SEL_GMAC5, P5_INTF_SEL_GMAC5_SGMII, -}; +} p5_interface_select; struct mt7530_priv; @@ -768,7 +768,7 @@ struct mt7530_priv { bool mcm; phy_interface_t p6_interface; phy_interface_t p5_interface; - unsigned int p5_intf_sel; + p5_interface_select p5_intf_sel; u8 mirror_rx; u8 mirror_tx; struct mt7530_port ports[MT7530_NUM_PORTS]; From patchwork Fri Apr 21 14:36:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220171 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA9E2C77B71 for ; Fri, 21 Apr 2023 14:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zGGNzhXShPLMVaiTvqZE9O4HeSyZ18wv+0vr2UWbe/Q=; b=E1bIdhAf0rU55y On8bpAjaBHppfGtM3rb6REzL5lkcWbMlnBOReUQIcaMl78T4ASoT20BMlFJPlg7OBMWdzRzNpClOv K/zKIiEaZsq02VSgjSeh3WZeknbLue8lS8GvXWf8xvWfSsjQ6bv0YnYVackD+/X1QGRxkJ0UNjmwj jF4eFqINmaAWYrqm/FD+PY/tT864CuOe40o5W0kOa+X9LVkx6YLWa7xFLBPuwZdnmsEmTyTnc5nup vyTrzhJvnGqehbgocdFWvSxsLfrMusRm/xDqV0GydpPhsrKnXmHdGD+Wpkjx7yw+CUIKr9oc29JPK 4FQ7tVgysxF60F8JtF2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprt6-00B7ZV-1e; Fri, 21 Apr 2023 14:37:24 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprsl-00B7NP-2R; Fri, 21 Apr 2023 14:37:05 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-50506ac462bso2549064a12.3; Fri, 21 Apr 2023 07:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087822; x=1684679822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zGGNzhXShPLMVaiTvqZE9O4HeSyZ18wv+0vr2UWbe/Q=; b=H4B75APs962gps+u8PNzSRdqU0ZnR1s9VCyva44nb9eU7BqoNCErWJTBGFB7xwwMow 5e2kFhbBTH8+WpttwJo9Ma+uxklJ0v1dgEPRdMNG7tBOQFn9XvXZBShc9s+hHwr+Y/xU 6kidxKt2u1TEwRG9UY4pZBv9UluTEiNL38JkO1VTJpdtqcVSZrt0cru4Lo3Zx347uqZQ 8NtBgdZ+qI6Qn5vmitfsBPhtxQRO8r0Pv00mMjJSFxbIBQoGYNhcSbNmNdjVkXQHrgcz JrskGLCIe8bPY8Ddmdwi2u/TOrCBO/nXfYfCxhfquwaET9tDtxTJ4phLeHceg9HKiNIR kARQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087822; x=1684679822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zGGNzhXShPLMVaiTvqZE9O4HeSyZ18wv+0vr2UWbe/Q=; b=Jr0DCm+s9x4nxky3ID4Q467AcOXz1hxX2tiLUHnGdEr54gZ+u6a0zCcs2xGrcxmM7G txGp1Ui97DVR5Ev+9FmvrzKbZtkITZZmBCj8gbo3RjK9ZJpD8VWnfx5wmOHK+pgJZ/Vh /QSxYMQRpl/60Q5NTeDPMQEBJ3kJxcC3oVtrhIPR/DJXnRPEB+k6hpKkU2dyJqn2yvuo kcWgEgV2luvyYMSPU1lkWHKTRXrJLAV+GdADlbXlwRgwpPHi93paAGdbX5s0s0b+Usif 4fLTC0Qds9cY8WnT+E+YCZR01aEK5EMH+yHDSqMfLDh2GAbbMt5b+uJJxpuivKft56bU 7hLQ== X-Gm-Message-State: AAQBX9e02jDghh31/qZb+hpA6onGnIgXkbTu0Pe26TpIx8LV6kIUMgBX yweg0sHySRVi+Y9e1lKUNr8= X-Google-Smtp-Source: AKy350Zf2dmwIwSlIQVmIx3LcCmpPvSapslCHsJgVvA21Dh7lFd1teYYP0qB7uF9pMpAcGtkmTRFZQ== X-Received: by 2002:a17:906:2c58:b0:953:5eb4:fe45 with SMTP id f24-20020a1709062c5800b009535eb4fe45mr2338187ejh.23.1682087821491; Fri, 21 Apr 2023 07:37:01 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:01 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 03/22] net: dsa: mt7530: properly support MT7531AE and MT7531BE Date: Fri, 21 Apr 2023 17:36:29 +0300 Message-Id: <20230421143648.87889-4-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073703_791080_B673F927 X-CRM114-Status: GOOD ( 23.26 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL Introduce the p5_sgmii pointer to store the information for whether port 5 has got SGMII or not. Print "found MT7531AE" if it's got it, print "found MT7531BE" if it hasn't. Move the comment about MT7531AE and MT7531BE to mt7531_setup(), where the switch is identified. Get rid of mt7531_dual_sgmii_supported() now that priv->p5_sgmii stores the information. Address the code where mt7531_dual_sgmii_supported() is used. Get rid of mt7531_is_rgmii_port() which just prints the opposite of priv->p5_sgmii. Remove P5_INTF_SEL_GMAC5_SGMII. The p5_interface_select enum is supposed to represent the mode that port 5 is used in, not the hardware information of port 5. Set p5_intf_sel to P5_INTF_SEL_GMAC5 instead, if port 5 is not dsa_is_unused_port(). Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530-mdio.c | 7 ++--- drivers/net/dsa/mt7530.c | 49 +++++++++++++++-------------------- drivers/net/dsa/mt7530.h | 6 +++-- 3 files changed, 27 insertions(+), 35 deletions(-) diff --git a/drivers/net/dsa/mt7530-mdio.c b/drivers/net/dsa/mt7530-mdio.c index 088533663b83..fa3ee85a99c1 100644 --- a/drivers/net/dsa/mt7530-mdio.c +++ b/drivers/net/dsa/mt7530-mdio.c @@ -81,17 +81,14 @@ static const struct regmap_bus mt7530_regmap_bus = { }; static int -mt7531_create_sgmii(struct mt7530_priv *priv, bool dual_sgmii) +mt7531_create_sgmii(struct mt7530_priv *priv) { struct regmap_config *mt7531_pcs_config[2] = {}; struct phylink_pcs *pcs; struct regmap *regmap; int i, ret = 0; - /* MT7531AE has two SGMII units for port 5 and port 6 - * MT7531BE has only one SGMII unit for port 6 - */ - for (i = dual_sgmii ? 0 : 1; i < 2; i++) { + for (i = priv->p5_sgmii ? 0 : 1; i < 2; i++) { mt7531_pcs_config[i] = devm_kzalloc(priv->dev, sizeof(struct regmap_config), GFP_KERNEL); diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index c680873819b0..edc34be745b2 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -473,15 +473,6 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) return 0; } -static bool mt7531_dual_sgmii_supported(struct mt7530_priv *priv) -{ - u32 val; - - val = mt7530_read(priv, MT7531_TOP_SIG_SR); - - return (val & PAD_DUAL_SGMII_EN) != 0; -} - static int mt7531_pad_setup(struct dsa_switch *ds, phy_interface_t interface) { @@ -496,7 +487,7 @@ mt7531_pll_setup(struct mt7530_priv *priv) u32 xtal; u32 val; - if (mt7531_dual_sgmii_supported(priv)) + if (priv->p5_sgmii) return; val = mt7530_read(priv, MT7531_CREV); @@ -907,8 +898,6 @@ static const char *p5_intf_modes(unsigned int p5_interface) return "PHY P4"; case P5_INTF_SEL_GMAC5: return "GMAC5"; - case P5_INTF_SEL_GMAC5_SGMII: - return "GMAC5_SGMII"; default: return "unknown"; } @@ -2440,6 +2429,18 @@ mt7531_setup(struct dsa_switch *ds) return -ENODEV; } + /* MT7531AE has got two SGMII units. One for port 5, one for port 6. + * MT7531BE has got only one SGMII unit which is for port 6. + */ + val = mt7530_read(priv, MT7531_TOP_SIG_SR); + + if ((val & PAD_DUAL_SGMII_EN) != 0) { + priv->p5_sgmii = true; + dev_info(priv->dev, "found MT7531AE\n"); + } else { + dev_info(priv->dev, "found MT7531BE\n"); + } + /* all MACs must be forced link-down before sw reset */ for (i = 0; i < MT7530_NUM_PORTS; i++) mt7530_write(priv, MT7530_PMCR_P(i), MT7531_FORCE_LNK); @@ -2451,19 +2452,16 @@ mt7531_setup(struct dsa_switch *ds) mt7531_pll_setup(priv); - if (mt7531_dual_sgmii_supported(priv)) { - priv->p5_intf_sel = P5_INTF_SEL_GMAC5_SGMII; - + if (priv->p5_sgmii) { /* Let ds->slave_mii_bus be able to access external phy. */ mt7530_rmw(priv, MT7531_GPIO_MODE1, MT7531_GPIO11_RG_RXD2_MASK, MT7531_EXT_P_MDC_11); mt7530_rmw(priv, MT7531_GPIO_MODE1, MT7531_GPIO12_RG_RXD3_MASK, MT7531_EXT_P_MDIO_12); - } else { - priv->p5_intf_sel = P5_INTF_SEL_GMAC5; } - dev_dbg(ds->dev, "P5 support %s interface\n", - p5_intf_modes(priv->p5_intf_sel)); + + if (!dsa_is_unused_port(ds, 5)) + priv->p5_intf_sel = P5_INTF_SEL_GMAC5; mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK, MT7531_GPIO0_INTERRUPT); @@ -2523,11 +2521,6 @@ static void mt7530_mac_port_get_caps(struct dsa_switch *ds, int port, } } -static bool mt7531_is_rgmii_port(struct mt7530_priv *priv, u32 port) -{ - return (port == 5) && (priv->p5_intf_sel != P5_INTF_SEL_GMAC5_SGMII); -} - static void mt7531_mac_port_get_caps(struct dsa_switch *ds, int port, struct phylink_config *config) { @@ -2540,7 +2533,7 @@ static void mt7531_mac_port_get_caps(struct dsa_switch *ds, int port, break; case 5: /* 2nd cpu port supports either rgmii or sgmii/8023z */ - if (mt7531_is_rgmii_port(priv, port)) { + if (!priv->p5_sgmii) { phy_interface_set_rgmii(config->supported_interfaces); break; } @@ -2607,7 +2600,7 @@ static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, { u32 val; - if (!mt7531_is_rgmii_port(priv, port)) { + if (priv->p5_sgmii) { dev_err(priv->dev, "RGMII mode is not available for port %d\n", port); return -EINVAL; @@ -2860,7 +2853,7 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) switch (port) { case 5: - if (mt7531_is_rgmii_port(priv, port)) + if (!priv->p5_sgmii) interface = PHY_INTERFACE_MODE_RGMII; else interface = PHY_INTERFACE_MODE_2500BASEX; @@ -3019,7 +3012,7 @@ mt753x_setup(struct dsa_switch *ds) mt7530_free_irq_common(priv); if (priv->create_sgmii) { - ret = priv->create_sgmii(priv, mt7531_dual_sgmii_supported(priv)); + ret = priv->create_sgmii(priv); if (ret && priv->irq) mt7530_free_irq(priv); } diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 703f8a528317..f58828577520 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -679,7 +679,6 @@ typedef enum { P5_INTF_SEL_PHY_P0, P5_INTF_SEL_PHY_P4, P5_INTF_SEL_GMAC5, - P5_INTF_SEL_GMAC5_SGMII, } p5_interface_select; struct mt7530_priv; @@ -749,6 +748,8 @@ struct mt753x_info { * @p6_interface: Holding the current port 6 interface * @p5_interface: Holding the current port 5 interface * @p5_intf_sel: Holding the current port 5 interface select + * @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch + * has got SGMII * @irq: IRQ number of the switch * @irq_domain: IRQ domain of the switch irq_chip * @irq_enable: IRQ enable bits, synced to SYS_INT_EN @@ -769,6 +770,7 @@ struct mt7530_priv { phy_interface_t p6_interface; phy_interface_t p5_interface; p5_interface_select p5_intf_sel; + bool p5_sgmii; u8 mirror_rx; u8 mirror_tx; struct mt7530_port ports[MT7530_NUM_PORTS]; @@ -778,7 +780,7 @@ struct mt7530_priv { int irq; struct irq_domain *irq_domain; u32 irq_enable; - int (*create_sgmii)(struct mt7530_priv *priv, bool dual_sgmii); + int (*create_sgmii)(struct mt7530_priv *priv); }; struct mt7530_hw_vlan_entry { From patchwork Fri Apr 21 14:36:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220172 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9971EC7618E for ; Fri, 21 Apr 2023 14:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZzMK7vF3K2CEqwtvJdFcGt8aeUfJvcS1teZcz3caE9E=; b=E52WKjY0o5fSFw xb+bRFaAGhqfbfYrZPUittL8gVhO+iVgtoSHjRvSryAu8m6uVkFZsTRb67Nq+GuvJTOOo63wXpKwM 9S9Watvtu0w2nLFY9J5sCJzQFDuL+2BXm/pxEdLUCNEuV8F9pDzo2XZyflfSq3UsLn0AbeXJPCMHK 2pnAkzLG4u+jVskFWLKcV8AK4zoRBrqnImmhvyI95GQh27agO8Y3rKXyCPiDVGrNbB4wnx2PCMC3/ Ihr/anvsp23qsdfQqB9pDl3yBciiYEIroJJ8ca2GaLH00q7apZjKTX77B2RxKuQ982EussRv6r18m bYc258GtfRxy+zoe+isg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprtF-00B7gY-01; Fri, 21 Apr 2023 14:37:33 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprsn-00B7OA-2B; Fri, 21 Apr 2023 14:37:07 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9536df4b907so290033166b.0; Fri, 21 Apr 2023 07:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087824; x=1684679824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZzMK7vF3K2CEqwtvJdFcGt8aeUfJvcS1teZcz3caE9E=; b=sM3ffQEoXLR2QcBxnhSJwnPaaRFFvBGoWqzc/G98cgBTFfqCP9p3/mdmbO4pPZq4JE yO/dR5pNXlkxCZzt3+MNZi98uTlR9PVoLpzGVRF3whPJAJhbrSQbzg4TcqJ0tyVDZ1BK vsRxqBHGuHnSNCqHKa/NEP8yA7u5BxEsPENB6JIrjlr7cnnNPRMXieUndMWQHyNIzNMQ l0Wkwd/R7Ulgtgrvvp1L5KG+BF8pBJxaRng3/yfp3FSinPfIK0YrVz1rLs032F0IMM76 lnhhdlCW2ukN1zQ3ugc1RT8mWvq+zBXGF5E1MoOwd6lGunyaqKU0O5vyFfP0ufaEeu0P m24w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087824; x=1684679824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZzMK7vF3K2CEqwtvJdFcGt8aeUfJvcS1teZcz3caE9E=; b=PxR0o+IXtM5HNc85LeiiCPfy5ypc+KzjtKL4OzWLxMw0zkTgX3rnldS8zEXXff2R/V vy+AgeG2D7RQPDU6yE7j0J8Fh8ZTB4tlRoxKPy706HJsrzlvOv6M4H14t+w1Ed8axGRM u9Hixj3TvXpAvQiRN+6ASMOcEUR+0QE1Zd6axsm648AWopMCZc3w/GwfakrOXesm0P3E Zbiy6uHWXC5T7zSg/3rXxZzxx9FGjZrSKANeYlaqxp6iZobQgo26EL+pi8LdRt44HUpb snubx1+p7MRz8ifqFT1QZM1x+tbKYbZrTtnK4qdRyouxS5V4i9+HWIFSs7pmk0oXUPe+ OYqA== X-Gm-Message-State: AAQBX9crnYAJVw4Yi8Ak9HAmC1seooq81Fn90nBdLiu/ic/ZofbehaGZ 2VS5YH5tYVU4572FTqteSJM= X-Google-Smtp-Source: AKy350YGydwy0/ywHqLVQVLP6Ui7/86QStLDq5oJdInniAwp66LsSXx1hsDrDfottCNzePunSDkFbg== X-Received: by 2002:a17:906:224d:b0:94f:3eca:ab05 with SMTP id 13-20020a170906224d00b0094f3ecaab05mr2736418ejr.59.1682087823763; Fri, 21 Apr 2023 07:37:03 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:03 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 04/22] net: dsa: mt7530: improve comments regarding port 5 and 6 Date: Fri, 21 Apr 2023 17:36:30 +0300 Message-Id: <20230421143648.87889-5-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073705_719026_624F990F X-CRM114-Status: GOOD ( 13.38 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL There's no logic to numerically order the CPU ports. State the port number and its capability of being used as a CPU port instead. Remove the irrelevant PHY muxing information from mt7530_mac_port_get_caps(). Explain the supported MII modes instead. Remove the out of place PHY muxing information from mt753x_phylink_mac_config(). The function is for both the MT7530 and MT7531 switches but there's no PHY muxing on MT7531. These comments were gradually introduced with the commits below. ca366d6c889b ("net: dsa: mt7530: Convert to PHYLINK API") 38f790a80560 ("net: dsa: mt7530: Add support for port 5") 88bdef8be9f6 ("net: dsa: mt7530: Extend device data ready for adding a new hardware") c288575f7810 ("net: dsa: mt7530: Add the support of MT7531 switch") Signed-off-by: Arınç ÜNAL Acked-by: Daniel Golle --- drivers/net/dsa/mt7530.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index edc34be745b2..e956ffa1eea8 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2504,7 +2504,9 @@ static void mt7530_mac_port_get_caps(struct dsa_switch *ds, int port, config->supported_interfaces); break; - case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */ + case 5: /* Port 5 which can be used as a CPU port supports rgmii with + * delays, mii, and gmii. + */ phy_interface_set_rgmii(config->supported_interfaces); __set_bit(PHY_INTERFACE_MODE_MII, config->supported_interfaces); @@ -2512,7 +2514,9 @@ static void mt7530_mac_port_get_caps(struct dsa_switch *ds, int port, config->supported_interfaces); break; - case 6: /* 1st cpu port */ + case 6: /* Port 6 which can be used as a CPU port supports rgmii and + * trgmii. + */ __set_bit(PHY_INTERFACE_MODE_RGMII, config->supported_interfaces); __set_bit(PHY_INTERFACE_MODE_TRGMII, @@ -2532,14 +2536,17 @@ static void mt7531_mac_port_get_caps(struct dsa_switch *ds, int port, config->supported_interfaces); break; - case 5: /* 2nd cpu port supports either rgmii or sgmii/8023z */ + case 5: /* Port 5 which can be used as a CPU port supports rgmii with + * delays on MT7531BE, sgmii/802.3z on MT7531AE. + */ if (!priv->p5_sgmii) { phy_interface_set_rgmii(config->supported_interfaces); break; } fallthrough; - case 6: /* 1st cpu port supports sgmii/8023z only */ + case 6: /* Port 6 which can be used as a CPU port supports sgmii/802.3z. + */ __set_bit(PHY_INTERFACE_MODE_SGMII, config->supported_interfaces); __set_bit(PHY_INTERFACE_MODE_1000BASEX, @@ -2731,7 +2738,7 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, state->interface != PHY_INTERFACE_MODE_INTERNAL) goto unsupported; break; - case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */ + case 5: /* Port 5, can be used as a CPU port. */ if (priv->p5_interface == state->interface) break; @@ -2741,7 +2748,7 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, if (priv->p5_intf_sel != P5_DISABLED) priv->p5_interface = state->interface; break; - case 6: /* 1st cpu port */ + case 6: /* Port 6, can be used as a CPU port. */ if (priv->p6_interface == state->interface) break; From patchwork Fri Apr 21 14:36:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220173 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4A10C7618E for ; Fri, 21 Apr 2023 14:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DnhLc2FNX94+xwHWTwQbzfts7CiDXWRNDdKOnOqCup4=; b=G/9MVcH6+oozuL WxRxBP8/4gSVDVU8cjZ39im2kcm8FZxWc6QE5OrZgCsincJ9RJAThXJ8lTKDDClHsBTgLMaG7VFAO LZh1w6KfUinmDU6eMz/IzCEZX/9hoVgA2isgNtMmjiRCjCafF7T5sH2E1CQXyE+nyV68AQcuWgfZO NoGRwre/WCYJ/eRJVyMXH7adymOtELGrTn4Pkck/tZNxjAh8oClngonHkBsHF7HkjO81Cr15K1WAV Me+QMhonDe4YuW9c7fh3nF7gvKyvpx71GswiWsC0fp2CpeIAYBGzuv5Hv8hnfUaky3GiYpdvcZZnl 5n78o4BPH9aeH1tHEGwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprtR-00B7q7-0p; Fri, 21 Apr 2023 14:37:45 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprsq-00B7Ov-0l; Fri, 21 Apr 2023 14:37:09 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9505214c47fso288241266b.1; Fri, 21 Apr 2023 07:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087826; x=1684679826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DnhLc2FNX94+xwHWTwQbzfts7CiDXWRNDdKOnOqCup4=; b=ZfplyYY8FBBsOYOz/1YZN5onQ7ZolL5O8v8pYM0BkG79g3XCnEc0ii9N2n+Swi7ZCp JG2MDFq3850J8mhyqBuLlLqlylW3jYjVgrenC1kNRL10/sMeF7TfAnl15iRRakJGQucA 9qqoaxGkk5PqT15iI1IxUGTt3GDyIsYobss2f0KXQYr2zR2h2Deq/TA0YykhXe7doJSX vqZTXq42eVbNh91sxsRsN0MZbwL0JSL9hoz4HKbz2fOu/PuJ5cH5aP5XN392g/lX2a7u n1pKXrKaZTgmJ0AEmySAxEnYhiWz4VQrumuirOmrqXra5KcfFB4NXcU/iuhTS3kNNpTe 0oBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087826; x=1684679826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DnhLc2FNX94+xwHWTwQbzfts7CiDXWRNDdKOnOqCup4=; b=i5hFy0LvbPiSor4ell2OIiMHHOUMPP2B9a4obLwITp4M8uVnYXL31dxi7gtdkG9CD8 h1hfSON6lrpGydeqWw43YHZekCy124f7IBYYvgkDitCr2XeCMuOvruKg01gE9wFxj48d Ne+schUIb1pUTSlHwy0XWRZBt9YFvO2lpNDofy8z7yHvSAW3bNzw5iupBMpM8qHd90WK Fv91p2S2C+l3wU09ytAZ2lHpKtNvU7XwSBN09oStR7wWeIlo2k4kdyI1ejWPWew9qxD/ lbnUIw0C1lBmBQBLjt7elX+E7Zj4ANUWGUimFdGdW6Y2C0BUlKEctb4ztNjJArPjK0Ui oP2A== X-Gm-Message-State: AAQBX9d2GKNiTNg3Bof1FxhOdylJ8dMc0DC50o96fvpbN7gdelJ70c12 IlA8v8NeKZblVA+cwMrUJ/s= X-Google-Smtp-Source: AKy350ZqzYQrqGoBR9DHsnACsf12BT62R4GZLXzYkBwQJ6WLs1oUkD7PNNKFL264rZDENkDoVbhmNw== X-Received: by 2002:a17:906:8993:b0:94e:fe0f:b2be with SMTP id gg19-20020a170906899300b0094efe0fb2bemr2213016ejc.14.1682087825965; Fri, 21 Apr 2023 07:37:05 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:05 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 05/22] net: dsa: mt7530: read XTAL value from correct register Date: Fri, 21 Apr 2023 17:36:31 +0300 Message-Id: <20230421143648.87889-6-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073708_309406_690706D4 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL On commit 7ef6f6f8d237 ("net: dsa: mt7530: Add MT7621 TRGMII mode support") bit mask macros were added under the MT7530_HWTRAP register to read the crystal frequency. However, the value given to the xtal variable on mt7530_pad_clk_setup() is read from the MT7530_MHWTRAP register instead. It doesn't seem to matter as my testing on MCM and standalone MT7530 shows the value is correctly read from both registers but change it anyway. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index e956ffa1eea8..30553044d4b7 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -406,7 +406,7 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) struct mt7530_priv *priv = ds->priv; u32 ncpo1, ssc_delta, trgint, xtal; - xtal = mt7530_read(priv, MT7530_MHWTRAP) & HWTRAP_XTAL_MASK; + xtal = mt7530_read(priv, MT7530_HWTRAP) & HWTRAP_XTAL_MASK; if (xtal == HWTRAP_XTAL_20MHZ) { dev_err(priv->dev, From patchwork Fri Apr 21 14:36:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220174 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 109FAC7618E for ; Fri, 21 Apr 2023 14:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BEQa4/xHb6zNxlzp+nQz3Th+D0wsYwHJEzOMjCihAA0=; b=J0olRf9Aojl/+1 0ySlO+CXeJaxGKDbLxILUULMEdzJ2xvR5olEfrDIYMrTH9q1S5KpdlVca/UCxjjFB1PNDEq7Yj+h0 OTfQa+ViXtj10FKaKlbHAL1siZGvihSZv0dahagpuYDOolgG6awZmIhUq+eN7OyyZ5CxuW88XwAQN Y9fEJX42m9Qv6/WQpwhLwuxF9Bp2XTHiS6ocV5PzSdf+eAFbbRxFDSc9L2ufFsuYhFHW/UFxTC0Dm z20i9s3tLSK4lFisbfkmTrAiTaDYo0pPJMggGQMJSNKksW+EWJ2TWHcH+xEZ41hH+fB7TUxkAKzSZ iu4atP6JdiYVxA0chP9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprte-00B80L-1E; Fri, 21 Apr 2023 14:37:58 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprsq-00B7NP-2t; Fri, 21 Apr 2023 14:37:10 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-50506ac462bso2549296a12.3; Fri, 21 Apr 2023 07:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087828; x=1684679828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BEQa4/xHb6zNxlzp+nQz3Th+D0wsYwHJEzOMjCihAA0=; b=ZLiz7VI1LgCRTrl6vuhh0Ya1V50x4rqu6D/kmhJ4UHrdgB/mMJHYQkQYrsg+Y+kID2 ZrAzSyHbSBnBngaySNZZz6RJyf3nkcWbaV1Hc6qyoevLGH6nN8tEBZDCBewM0ovE+yTE 6vX5eR74L4i7Cvi3wCnjqggrtwXEPVds4Jzz64X2oJY35U+Qm9cf55rGYkPcqu8VXyhY 7ruEraMsbDx/1qDhyyzdJgfm4QQghUoPq2PSYtLkEIrzlkHlMk0baKzlgn6bTBh6NvX2 YXTq76Vpysm8U32kc8euQkRQS+9SWhtUrkTrjOBxEc9fkGsnKi8StkloxnLZwFM3WWPL ginw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087828; x=1684679828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BEQa4/xHb6zNxlzp+nQz3Th+D0wsYwHJEzOMjCihAA0=; b=iClx6TkQD/1vd6Yd51LWqEg2/pftud2t8yFVQGx6mCtHcHQo6Pm8Dg3NNCKHyu2oA/ /ECSuvJFPaYWfRz+hsw5dHhltkUXv+VFok5P1esPevn6yKDxC28YoMna6UJ5lpJE/tkI 6gz4R3wIXQf+95JiFSPUI+8gJdf1ddJt/U/Zt0lE87hWmd1bA7p8pWdv+rxrL30+ZUGi xOl++D34FnJfkRbX6mTji6LkWmm8pza8/CqrFAlKQ9kP3SnFaLbEHNYYqQ5itSoO6EFY G+MT3QdMtajWNl1kajQc02EjvHMmlQJQGSrCJHPPhZ3931yZOSFkTMwmZcG3hMsG7loh 8Wzg== X-Gm-Message-State: AAQBX9cSxAIC16Oz2Ekg/MxeEpRyww89cpzmT49a7Eop5cABtA6ihJ5c 1fs7Y5FOvCTjlRO4snA++Qc= X-Google-Smtp-Source: AKy350aYC8vZhVhjqQTuEMfzGSYTGJE29X38itrkcvfN2wPBmLh7N3Xsl7f7jIM8oO1qa+oppffqeA== X-Received: by 2002:a17:907:a40e:b0:94f:a292:20cc with SMTP id sg14-20020a170907a40e00b0094fa29220ccmr2834815ejc.41.1682087828142; Fri, 21 Apr 2023 07:37:08 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:07 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 06/22] net: dsa: mt7530: improve code path for setting up port 5 Date: Fri, 21 Apr 2023 17:36:32 +0300 Message-Id: <20230421143648.87889-7-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073708_977569_36122146 X-CRM114-Status: GOOD ( 19.99 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL There're two code paths for setting up port 5: mt7530_setup() -> mt7530_setup_port5() mt753x_phylink_mac_config() -> mt753x_mac_config() -> mt7530_mac_config() -> mt7530_setup_port5() Currently mt7530_setup_port5() from mt7530_setup() always runs. If port 5 is used as a CPU, DSA, or user port, mt7530_setup_port5() from mt753x_phylink_mac_config() won't run. That is because priv->p5_interface set on mt7530_setup_port5() will match state->interface on mt753x_phylink_mac_config() which will stop running mt7530_setup_port5() again. mt7530_setup_port5() from mt753x_phylink_mac_config() won't run when port 5 is disabled or used for PHY muxing as port 5 won't be defined on the devicetree. Therefore, mt7530_setup_port5() will never run from mt753x_phylink_mac_config(). Address this by not running mt7530_setup_port5() from mt7530_setup() if port 5 is used as a CPU, DSA, or user port. For the cases of PHY muxing or the port being disabled, call mt7530_setup_port5() from mt7530_setup(). Do not set priv->p5_interface on mt7530_setup_port5(). There won't be a case where mt753x_phylink_mac_config() runs after mt7530_setup_port5() anymore. Do not set priv->p5_intf_sel to P5_DISABLED. It is already set to that when "priv" is allocated. Move setting the interface to a more specific location. It's supposed to be overwritten if PHY muxing is detected. Improve the comment which explain the process. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 30553044d4b7..591df09c8bb5 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -968,8 +968,6 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) dev_dbg(ds->dev, "Setup P5, HWTRAP=0x%x, intf_sel=%s, phy-mode=%s\n", val, p5_intf_modes(priv->p5_intf_sel), phy_modes(interface)); - priv->p5_interface = interface; - unlock_exit: mutex_unlock(&priv->reg_mutex); } @@ -2277,16 +2275,15 @@ mt7530_setup(struct dsa_switch *ds) return ret; /* Setup port 5 */ - priv->p5_intf_sel = P5_DISABLED; - interface = PHY_INTERFACE_MODE_NA; - if (!dsa_is_unused_port(ds, 5)) { priv->p5_intf_sel = P5_INTF_SEL_GMAC5; - ret = of_get_phy_mode(dsa_to_port(ds, 5)->dn, &interface); - if (ret && ret != -ENODEV) - return ret; } else { - /* Scan the ethernet nodes. look for GMAC1, lookup used phy */ + /* Scan the ethernet nodes. Look for GMAC1, lookup the used PHY. + * Set priv->p5_intf_sel to the appropriate value if PHY muxing + * is detected. + */ + interface = PHY_INTERFACE_MODE_NA; + for_each_child_of_node(dn, mac_np) { if (!of_device_is_compatible(mac_np, "mediatek,eth-mac")) @@ -2317,6 +2314,8 @@ mt7530_setup(struct dsa_switch *ds) of_node_put(phy_node); break; } + + mt7530_setup_port5(ds, interface); } #ifdef CONFIG_GPIOLIB @@ -2327,8 +2326,6 @@ mt7530_setup(struct dsa_switch *ds) } #endif /* CONFIG_GPIOLIB */ - mt7530_setup_port5(ds, interface); - /* Flush the FDB table */ ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL); if (ret < 0) From patchwork Fri Apr 21 14:36:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220175 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CA18C77B76 for ; Fri, 21 Apr 2023 14:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VA0Xuk7MTgGa91dYwTC92d17A98m4rbax3BNrbxXgxg=; b=J8VdtPs4oEG2Tt T2gsodXHVU4tnJMoUg7CPZ/agCCWNLKyEj741Sq4h9JySP8CezniEMDCoFolI3lcZ2HpMSGfUlKrE Pg13qP0R8TJb7KzYddwEW7ty2MaBZwk1C5e/5MhEexNVuVQl+ACKKOaZJW/TbJxuU2P/nAV3k2LeN 6cnt5luPBrlFRnz61RmmnNNgdUFL6Qo6k7WdFv0Il00pqThycNRaqsYZCnD/8LivrSsYfo2DL07o7 eV6iMhGx0afQn2+PLJ2oqw7TH9HQEnQM2sujvVuC8oPNZdRgaFJtprD54XbF6bN23Nz1ETy9Wtd6e hxoW6Ct7P5/tH1FxREGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprtn-00B86c-2V; Fri, 21 Apr 2023 14:38:07 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprsu-00B7RU-1q; Fri, 21 Apr 2023 14:37:13 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-504eb1155d3so12776473a12.1; Fri, 21 Apr 2023 07:37:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087830; x=1684679830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VA0Xuk7MTgGa91dYwTC92d17A98m4rbax3BNrbxXgxg=; b=M4UWnciomcUE4HK+mDFOEhaQpLMON/yMq1egd2eGD0WjqLi+0EO8LKCpuYv/hx30WT nhwfgfnd8DOh+GrNePxRaULnUkLzivdzGvaE8i3r/QtreW8oXp68KJttbMRL/gv+4SqY q9hBwdaSa5lbn1G4FlJ0xKusB6GQET/Lw1o1BTFaSvho5tKvyql2BDBAnn0bj6QcMCDD HQTaxEG0hAMhP7kxEAhW8QOxumCzrHRruAk/Y2nXsU6dVu4zTFPF5e2/pk9wjnTCbdJW qBC0hiFpBRl3zD3KC9ZZVOA+LqLwQF3C1/0qrp2ADUL2DuRyPGWgi3d6hMS8AItrDZ7f thqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087830; x=1684679830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VA0Xuk7MTgGa91dYwTC92d17A98m4rbax3BNrbxXgxg=; b=LLoWFYK1minU3cDCoJfRJnoKbGmOj8xY4LP5BlSxWLpfPpfKbtzF2IL3xsGfzugDTr RPtpI0Gbmu2yZSQz8HWmuD6QJjONCtNBIDtxHpkJnglZAj5eIYCyjs0eKdSnCC5XZmhn vUHYfpBfjvqbmdzH2gPnHQ62NDQmCdtzL0yQaw7amuNcxOfeW6rLOSwB+X697OZfwXf/ NZ6QUCay7WuI0IS35AKVtp5mcAvGSePBLHU8RzRc+Brw25hRJYrTeMYYYRrH7vj1ARtx B/BWlPENxQ4KQ5SKlyEzksm9guO+qwPKtohF+Xbsb+7Vp+pZDXqWlA1Jz9xTImwV6fBb T/kw== X-Gm-Message-State: AAQBX9f+xsmLlSvqNbIXx/kJ80E05LlP7Lb6iuw5kiSgpDYmQXoFsLPH Hgj7P1eTp83/t+866RPnU2w= X-Google-Smtp-Source: AKy350b1lI/7oYXC7o4YA2rNQhIhx/wnN+4LOaI5v5kCAlbObHDch3hFRAM8039Bj2AeoQ/vDBwLKw== X-Received: by 2002:a17:906:4ec5:b0:94e:80b2:51e3 with SMTP id i5-20020a1709064ec500b0094e80b251e3mr2310031ejv.27.1682087830425; Fri, 21 Apr 2023 07:37:10 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:10 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 07/22] net: dsa: mt7530: do not run mt7530_setup_port5() if port 5 is disabled Date: Fri, 21 Apr 2023 17:36:33 +0300 Message-Id: <20230421143648.87889-8-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073712_609643_1B3041F2 X-CRM114-Status: GOOD ( 13.43 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL There's no need to run all the code on mt7530_setup_port5() if port 5 is disabled. The only case for calling mt7530_setup_port5() from mt7530_setup() is when PHY muxing is enabled. That is because port 5 is not defined as a port on the devicetree, therefore, it cannot be controlled by phylink. Because of this, run mt7530_setup_port5() if priv->p5_intf_sel is P5_INTF_SEL_PHY_P0 or P5_INTF_SEL_PHY_P4. Remove the P5_DISABLED case from mt7530_setup_port5(). Stop initialising the interface variable as the remaining cases will always call mt7530_setup_port5() with it initialised. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 591df09c8bb5..bac2388319a3 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -932,9 +932,6 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) /* MT7530_P5_MODE_GMAC: P5 -> External phy or 2nd GMAC */ val &= ~MHWTRAP_P5_DIS; break; - case P5_DISABLED: - interface = PHY_INTERFACE_MODE_NA; - break; default: dev_err(ds->dev, "Unsupported p5_intf_sel %d\n", priv->p5_intf_sel); @@ -2282,8 +2279,6 @@ mt7530_setup(struct dsa_switch *ds) * Set priv->p5_intf_sel to the appropriate value if PHY muxing * is detected. */ - interface = PHY_INTERFACE_MODE_NA; - for_each_child_of_node(dn, mac_np) { if (!of_device_is_compatible(mac_np, "mediatek,eth-mac")) @@ -2315,7 +2310,9 @@ mt7530_setup(struct dsa_switch *ds) break; } - mt7530_setup_port5(ds, interface); + if (priv->p5_intf_sel == P5_INTF_SEL_PHY_P0 || + priv->p5_intf_sel == P5_INTF_SEL_PHY_P4) + mt7530_setup_port5(ds, interface); } #ifdef CONFIG_GPIOLIB From patchwork Fri Apr 21 14:36:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220177 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24B36C77B76 for ; Fri, 21 Apr 2023 14:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rqdViajAeNRKoM+fdqJjjwXsteiyCgJeOZmgusmlzx4=; b=kFr3TuYXhwxb0j hdBaBF5jERxLl8VFppgi6TJ0pDMbDGyVxbOXYiEgH5YN0ZpzxmaE/lA7xFe8zla9JaTVBJomLV2xD 4HSgrR3maMzee4dK+KU2c9XT3mLxY3y4pa9j/CTlO8gd2eDioO912lQLPAgpUjnOwDytu2bnQCTD9 2hVe4IrqiSTt1NWLNUI9JdjAoUkRaFZ/iJ/eESf0XrPr0S0yK7qEouSFQOF9nsQuIAbZDf+egWtO0 UqmHAizaSOBmpe+lsKyR6f7Eyhv+P6jMZRkL3dBcvSWKeO1q64Wq11RK+pWTcfZW9GZzpetqacHNn HjOMUmOtkozKIVTuiwcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprtx-00B8DT-1k; Fri, 21 Apr 2023 14:38:17 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprsw-00B7Sh-2t; Fri, 21 Apr 2023 14:37:16 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-94eee951c70so250017966b.3; Fri, 21 Apr 2023 07:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087832; x=1684679832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rqdViajAeNRKoM+fdqJjjwXsteiyCgJeOZmgusmlzx4=; b=Dg80eefg4baD6Cj47D57vpBsiKF6d5o7WWzYvZ3aouHw/GUuVslih+JSx5ay1XFeIy M82YmVWKmCFIDuE/rilLhKwuaUaBOQPWzQstA7BDz6kGsLdQTQQMmVaDuCrfoAn27Bx3 DOParXeqagyhjSNTuWSKYBPbOLwbGS6MYx++RZHJvW8amQ1f1sCNc4dQhH7x3eE0MXDF B/rUMIXebo2VzzbV4AbASrA4l3ImcoTVY1flXg4qEY2tgO8WKFppGP0Sowouzqseuq16 Cn6Wb/UyXitsxZzfcQv4zqmzLRSrt5WH8Y7ypwkygMJtQVF3hYn38STGe/A6/We9KDqf X7ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087832; x=1684679832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rqdViajAeNRKoM+fdqJjjwXsteiyCgJeOZmgusmlzx4=; b=AFIQk3gk7Pub9apQPzbeb7Rs2Kj6N9gaLKu3vqort980va3EIpj/KIg875lOEOzIDu P/LkQtPmIDcQDvtzrEjks76Lk/ziT0DoUraVtdF8jbCY65yO0qIVSZ+lQ6dQGlABsp0O H2WQivBXQ12Y0BduEDS9xZUsqf0X9/0gyLQKbWYNnLfJVXy1FbWgvkbcgkSR27288Fcm E8RP6dnB1AjhUrIreboWb3CO3DIP5iu1SNbE72VlykiTzqIljWdgtz1iY4s8Bv8t2AqT Sz3gPSjrbePTNUiEcawpnOVOPTbcwiz8tkIfBikLmKUCyyEGTeQ/+U6sxnRzJoBKc0Hb IurA== X-Gm-Message-State: AAQBX9fMgZs32T5+Vbi1I/p1L7pV+WDuId7QIfFvsOpyZMN9PY6KbLP+ llVvDsAzm2Djlt/ZvsD5irY= X-Google-Smtp-Source: AKy350ahf3obWs94ix/YXjEXuZI1y8KeY5KkZOuNplbHTOqwHwb07LMntJ96k+NtedAjVDrnzuuMpw== X-Received: by 2002:a17:906:fcd4:b0:94f:50d:e16e with SMTP id qx20-20020a170906fcd400b0094f050de16emr2808682ejb.12.1682087832574; Fri, 21 Apr 2023 07:37:12 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:12 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 08/22] net: dsa: mt7530: change p{5,6}_interface to p{5,6}_configured Date: Fri, 21 Apr 2023 17:36:34 +0300 Message-Id: <20230421143648.87889-9-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073714_973470_5B43C715 X-CRM114-Status: GOOD ( 17.45 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL The idea of p5_interface and p6_interface pointers is to prevent mt753x_mac_config() from running twice for MT7531, as it's already run with mt753x_cpu_port_enable() from mt7531_setup_common(), if the port is used as a CPU port. Change p5_interface and p6_interface to p5_configured and p6_configured. Make them boolean. Do not set them for any other reason. The priv->p5_intf_sel check is useless as in this code path, it will always be P5_INTF_SEL_GMAC5. There was also no need to set priv->p5_interface and priv->p6_interface to PHY_INTERFACE_MODE_NA on mt7530_setup() and mt7531_setup() as they would already be set to that when "priv" is allocated. The pointers were of the phy_interface_t enumeration type, and the first element of the enum is PHY_INTERFACE_MODE_NA. There was nothing in between that would change this beforehand. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL Acked-by: Daniel Golle --- drivers/net/dsa/mt7530.c | 19 ++++--------------- drivers/net/dsa/mt7530.h | 10 ++++++---- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index bac2388319a3..2f670e512415 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2237,8 +2237,6 @@ mt7530_setup(struct dsa_switch *ds) val |= MHWTRAP_MANUAL; mt7530_write(priv, MT7530_MHWTRAP, val); - priv->p6_interface = PHY_INTERFACE_MODE_NA; - /* Enable and reset MIB counters */ mt7530_mib_reset(ds); @@ -2460,10 +2458,6 @@ mt7531_setup(struct dsa_switch *ds) mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK, MT7531_GPIO0_INTERRUPT); - /* Let phylink decide the interface later. */ - priv->p5_interface = PHY_INTERFACE_MODE_NA; - priv->p6_interface = PHY_INTERFACE_MODE_NA; - /* Enable PHY core PLL, since phy_device has not yet been created * provided for phy_[read,write]_mmd_indirect is called, we provide * our own mt7531_ind_mmd_phy_[read,write] to complete this @@ -2733,25 +2727,20 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, goto unsupported; break; case 5: /* Port 5, can be used as a CPU port. */ - if (priv->p5_interface == state->interface) + if (priv->p5_configured) break; if (mt753x_mac_config(ds, port, mode, state) < 0) goto unsupported; - - if (priv->p5_intf_sel != P5_DISABLED) - priv->p5_interface = state->interface; break; case 6: /* Port 6, can be used as a CPU port. */ - if (priv->p6_interface == state->interface) + if (priv->p6_configured) break; mt753x_pad_setup(ds, state); if (mt753x_mac_config(ds, port, mode, state) < 0) goto unsupported; - - priv->p6_interface = state->interface; break; default: unsupported: @@ -2859,12 +2848,12 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) else interface = PHY_INTERFACE_MODE_2500BASEX; - priv->p5_interface = interface; + priv->p5_configured = true; break; case 6: interface = PHY_INTERFACE_MODE_2500BASEX; - priv->p6_interface = interface; + priv->p6_configured = true; break; default: return -EINVAL; diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index f58828577520..c3a37a0f4843 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -745,8 +745,10 @@ struct mt753x_info { * @ports: Holding the state among ports * @reg_mutex: The lock for protecting among process accessing * registers - * @p6_interface: Holding the current port 6 interface - * @p5_interface: Holding the current port 5 interface + * @p6_configured: Flag for distinguishing if port 6 of the MT7531 switch + * is already configured + * @p5_configured: Flag for distinguishing if port 5 of the MT7531 switch + * is already configured * @p5_intf_sel: Holding the current port 5 interface select * @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch * has got SGMII @@ -767,8 +769,8 @@ struct mt7530_priv { const struct mt753x_info *info; unsigned int id; bool mcm; - phy_interface_t p6_interface; - phy_interface_t p5_interface; + bool p6_configured; + bool p5_configured; p5_interface_select p5_intf_sel; bool p5_sgmii; u8 mirror_rx; From patchwork Fri Apr 21 14:36:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220176 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85771C77B71 for ; Fri, 21 Apr 2023 14:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GIUfI9zYtHK2jC08JSP+sw+iUpDI1NVNrxb5eq8tcPY=; b=XCtPQ3HTbb5uia OlGfNhtdWNd99cXdkMDUcdXpgUcb00vgn/4mH0804QeC5dcpU8jvGlYoYGVPjjwkmH1BYwE+08tMY ipAzPthyENijEtEwgjDYLAcvUsoKseOnCPZD4CM08S8YzkLFISnn5CiZ6UFLQU++ZEbqVi9lHBhv4 SBzz/qcQg6nUnJ8T7CH95Lf3FZyMQN1jfKeGhCR1JTL79R6SC3SFcVHl6KP/5b563M3l0mhsVXu67 L0JWPOgHkf9GpQkfGo1lxNU8hrpLaNv6iVnlTh6Rx/Hxh0QH9ZmRC3etxE4gMy+PSlWKYU6QUlPor XZwLLm98l2Dl24wjUQ5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprtz-00B8F4-2y; Fri, 21 Apr 2023 14:38:20 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprsx-00B7NP-1b; Fri, 21 Apr 2023 14:37:16 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-50506ac462bso2549535a12.3; Fri, 21 Apr 2023 07:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087835; x=1684679835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GIUfI9zYtHK2jC08JSP+sw+iUpDI1NVNrxb5eq8tcPY=; b=EljJWrJfUjgKLFZf4IOQcisR2n+YvpKGILxQA0DY8LRAmGKjAkYxrBbV9zkWaEzEEZ ToBPIz31lbts9A6vbTHwyo2Qy1xfD+C+ZOxQHBmdmh9VggFiup2xf42NeV15y2/ZEZxz CFBeSREVfQk5ERVAUslmpDlkte6lEProXiA8Ysgf2iphfR4iFI3x4k9i6LS8xqNj43gw l51i+L6mswdX4zOPFozwD9GLu6Nci8Fpv4t57BW+80VWM4nygIVSjC8WmUnxvQwGeyVg H5IxkknOJ90pXzQ0w6PX0/AweMVWH8Z7YxNDwM+u0vX24vRWnU6L6z0QoKZtMtDhD9jn FWvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087835; x=1684679835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GIUfI9zYtHK2jC08JSP+sw+iUpDI1NVNrxb5eq8tcPY=; b=Y7Yk+SbhbStPJTXmbSyit/VjnUe4uRDvaPW+U2J86IZ2i8jxyJAOWAcNzvscH50dZB 4ZpnkNA6hSwqno3u83zvkheT9dBAdZVY4XSOoEHOB4NdDKjJDy28yDG5iQkOYyAnutNw CHmiXp5SpNZu9yu+1EQhdq7F6RCMbM2YBn43e26ngE+ECcEyEC0obOYrOsiswRokwlvI U2ftYu6E/N3lVbx9p+IoUGbe6KKzHoH2DwV4uayhxQ2Chj98IDUEfMjg7FoPL7wLKM0m qaSaSxxySbHUGnRtAWiQd8013Rxa4ehPp9DrbhYC/JnIdam5xJf9AYQozKTlvxY0+kow FDDA== X-Gm-Message-State: AAQBX9c1B9pGw4/rMkKkkEz+SuBHm0P1oqZXA+HCPxH6rrFl/gw4H/Au oFDdeIgjnWd78fOtDcHvm+o= X-Google-Smtp-Source: AKy350at4m7vdCl2YFdYMq3ekSHRb756GOmIXElLgvBQAuem9vck2/IxIws8+YBBhwPfX8U3p0vQdg== X-Received: by 2002:a17:906:5d0:b0:94e:ef09:544c with SMTP id t16-20020a17090605d000b0094eef09544cmr2370576ejt.10.1682087834761; Fri, 21 Apr 2023 07:37:14 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:14 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 09/22] net: dsa: mt7530: empty default case on mt7530_setup_port5() Date: Fri, 21 Apr 2023 17:36:35 +0300 Message-Id: <20230421143648.87889-10-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073715_558676_21F52AA3 X-CRM114-Status: GOOD ( 12.00 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL There're two code paths for setting up port 5: mt7530_setup() -> mt7530_setup_port5() mt753x_phylink_mac_config() -> mt753x_mac_config() -> mt7530_mac_config() -> mt7530_setup_port5() On the first code path, priv->p5_intf_sel is either set to P5_INTF_SEL_PHY_P0 or P5_INTF_SEL_PHY_P4 when mt7530_setup_port5() is run. On the second code path, priv->p5_intf_sel is set to P5_INTF_SEL_GMAC5 when mt7530_setup_port5() is run. Empty the default case which will never run but is needed nonetheless to handle all the remaining enumeration values. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 2f670e512415..be143da94add 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -933,9 +933,7 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) val &= ~MHWTRAP_P5_DIS; break; default: - dev_err(ds->dev, "Unsupported p5_intf_sel %d\n", - priv->p5_intf_sel); - goto unlock_exit; + break; } /* Setup RGMII settings */ @@ -965,7 +963,6 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) dev_dbg(ds->dev, "Setup P5, HWTRAP=0x%x, intf_sel=%s, phy-mode=%s\n", val, p5_intf_modes(priv->p5_intf_sel), phy_modes(interface)); -unlock_exit: mutex_unlock(&priv->reg_mutex); } From patchwork Fri Apr 21 14:36:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220178 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB531C7618E for ; Fri, 21 Apr 2023 14:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dGp4Tpz0L6Hnx+AZWBjvMZvm9IQMQXkz0B/FgdPBTn4=; b=NFSulbclqbBYPN 2z9JkecxtLl7aLm92eziaxyRQHWMYPkbe/VI6hiwiYjSUQrXup9jrFBQ4N2mrBbeNuvlR/kYsOQUk mJ24H2LVPrqU5/ZEx90t4q9ULfQQf4t7EAikg9rdI/EGmB0/G2lHXSpMhIF+F/fhs1msafFe2Cuap fz84rzpEHOEr4KFtJFQ4Ss0yIsWcPF14Jd+31SfhyBMrpfZAMOaiaMab4FGYMqKlDB0LEMhOHhCGc w2yMzfF3P5b4riXRLmR6/6JXyZeuqAHX1r/0YkqiB/eoPxP9+PPmKoclyra9LXJGUwzwnB5NWlOsw rwYARxPsJY3P4S9xyWQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppru7-00B8Ks-2I; Fri, 21 Apr 2023 14:38:27 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprt1-00B7VG-0c; Fri, 21 Apr 2023 14:37:20 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5069097bac7so2999240a12.0; Fri, 21 Apr 2023 07:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087837; x=1684679837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dGp4Tpz0L6Hnx+AZWBjvMZvm9IQMQXkz0B/FgdPBTn4=; b=DKxnRcq+RzWJO70d64SCwn8dKlPjog49hc1bI/lDUd7zvlQYM1FDq/Uo0qUyQmhe6C XP29nVBG8TX2btLkfSZkKnuIZZD4/9USpgryKZHyukz1kwwLgkmrARL/z9tECfFyHF+C +L5anr9HLc5WuXgyatHdVLa7hvHrnr0L+MPIiofw/C25wuOmG2+0/ugEZuWQh7jdA8S1 DmqqAbadrq7BjVR3QyNXQiUHSw2pUsqQVFcj80FHg0Nh0QJwGfYGpGt8gCZJRPp1+F2m MztENz1X7w+8PIij286h4jj6YK7bG2T+D+RK3MZnbe2PcIauAxTTGMitEGzmGusGfDxN DRHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087837; x=1684679837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dGp4Tpz0L6Hnx+AZWBjvMZvm9IQMQXkz0B/FgdPBTn4=; b=Azq8YrZRCYjyi5RIq8wP1UGf4YjgjGCgjklDGPsx4bqtB+KD1aT5EE/A33d1i6oDeT C8vuVPlRepZwUnwfWjHKwulxXje89MgXyojfCB3LtagU+f51/Y/VyfgiMmO9Vg6JcY+p gQou3tplHE9nqtfn0m2bdOR0aW6ozVfey3QFBrjXzxVg6JMx08IAtsGkuoPy1c7Hk/xO TmH5YERMgL2fefVPzldGl9SE3co0ototsdlAIWojnAmyPqCVtgNSJeyZdAxShBwLVwGY kPA6jyroXuRIWOKH4n8uCh3gdIJ8ptWRMqH37VrCskfnwSrQ06ZuEVPSb9qsgzOZuV4w BtoQ== X-Gm-Message-State: AAQBX9csLe8YVdiNWbXLdPH0ZnlqbkzpTcEvoyYGU3akAyIh/VQS/mGZ OSIdpOUb2Yrw5eqPr+bojfY= X-Google-Smtp-Source: AKy350ZyJxzUXfFeHkyBC3lf1xyUpQmcxh9PNWSCXHCnxZOLSjFWKs9A4jyqL5PVYZjHgRPrZllv2g== X-Received: by 2002:a17:907:2090:b0:94a:5ecb:6ea7 with SMTP id pv16-20020a170907209000b0094a5ecb6ea7mr2424974ejb.43.1682087836909; Fri, 21 Apr 2023 07:37:16 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:16 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 10/22] net: dsa: mt7530: call port 6 setup from mt7530_mac_config() Date: Fri, 21 Apr 2023 17:36:36 +0300 Message-Id: <20230421143648.87889-11-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073719_229353_B3ECD954 X-CRM114-Status: GOOD ( 16.47 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL mt7530_pad_clk_setup() is called if port 6 is enabled. It used to do more things than setting up port 6. That part was moved to more appropriate locations, mt7530_setup() and mt7530_pll_setup(). Now that all it does is set up port 6, rename it to mt7530_setup_port6(), and move it to a more appropriate location, under mt7530_mac_config(). Leave an empty mt7530_pad_clk_setup() to satisfy the pad_setup function pointer. This is the call path for setting up the ports before: mt753x_phylink_mac_config() -> mt753x_mac_config() -> mt7530_mac_config() -> mt7530_setup_port5() -> mt753x_pad_setup() -> mt7530_pad_clk_setup() This is after: mt753x_phylink_mac_config() -> mt753x_mac_config() -> mt7530_mac_config() -> mt7530_setup_port5() -> mt7530_setup_port6() Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index be143da94add..58eff6568d4c 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -401,7 +401,7 @@ static void mt7530_pll_setup(struct mt7530_priv *priv) /* Setup port 6 interface mode and TRGMII TX circuit */ static int -mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) +mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) { struct mt7530_priv *priv = ds->priv; u32 ncpo1, ssc_delta, trgint, xtal; @@ -473,6 +473,12 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) return 0; } +static int +mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) +{ + return 0; +} + static int mt7531_pad_setup(struct dsa_switch *ds, phy_interface_t interface) { @@ -2576,12 +2582,15 @@ mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface) { struct mt7530_priv *priv = ds->priv; + int ret; - /* Only need to setup port5. */ - if (port != 5) - return 0; - - mt7530_setup_port5(priv->ds, interface); + if (port == 5) { + mt7530_setup_port5(priv->ds, interface); + } else if (port == 6) { + ret = mt7530_setup_port6(priv->ds, interface); + if (ret) + return ret; + } return 0; } From patchwork Fri Apr 21 14:36:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220179 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 907D3C77B71 for ; Fri, 21 Apr 2023 14:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4KiBaVS3rBZL46ZkQA5szEuPGIfAQTTXY9i0okmVBlQ=; b=oT7dTLhrCrpcJi hAKLTzBv9wn8k/oBNeJpbRfJ2cs1+lL7IlyFK3P8ra81+XvVIpCXxRkLonFgBhiDZHhIVzItdNAQa vQ045wJEzbmqj85ttKygmbvJqwGRxwlt8Qdq6JRsDJeS2OPoKr6Bxie8SMSyWYPEK2P6uGd70Qfxd j9tJCW8BEOBCN1HNf6h9EEAGbVKNejedlFhWAowUc40TIyG7bju/o5CTq1uT6edRLnCMTw8sOpzgk zTkb7qI/4z1FIqYpp9SKk/aBnqeQrpMKd3/nB+TmwzfRaJzGky5PLsAU1tKUjx4oZXEOjbz6R/R7n nH10UyWL7IzGj63fC7Rg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppruF-00B8Qh-05; Fri, 21 Apr 2023 14:38:35 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprt2-00B7WR-26; Fri, 21 Apr 2023 14:37:22 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-94eff00bcdaso288447866b.1; Fri, 21 Apr 2023 07:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087839; x=1684679839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4KiBaVS3rBZL46ZkQA5szEuPGIfAQTTXY9i0okmVBlQ=; b=cZ6sRw0lbJpWLND6lATpwXgJ92zCE3aNNRpTtdZph7X3D7ft5vWHRKzIV5epNP1v96 2w2xjIsERO9EJOrPXYOnzYJpPx0Ce2umfFQz/dqR2dXzeU3o0VpnEsQSO3mBP5NBzUTW 5sU6pExF59smx7ZTWZsllRvG1fDZdmYBQjacd8AmP4BkRRXqRZVBvd42XzcYoYgx4ukO pEEM7emL57SXMJyMRQs8QV/fsxXTG5yHRzaOrS3xqqHrsxqdSKhWFz91Nt975t8/XLp5 Bsfaz26iztGa7H2Ndt1FENtsndXQGRGJxXj0SQfXNvkyYNc6ML3TbldTATqINp6c9ebG 9g9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087839; x=1684679839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4KiBaVS3rBZL46ZkQA5szEuPGIfAQTTXY9i0okmVBlQ=; b=B8FMhbhkCt44XRciEFeX+RDQ5Bswb7Un6TnmuZCgyYHNFJHBh342o7fLe3mHmg/fyc LWCJFIpHVwAOsLQCcVl80QO8tNjpwFM6C306LGQhPjdvQgpbGTtNqMj8jlzEDqRGSmd+ M5+ULnIt6QekTQCCslXJ4JmD9umWYBR09ozT6ogzA+/IkO4G15vS87CWh3YHjj+wy1BB 0KsWelxklOm4cmKIsyeasHHs4Q3/TS6fZhTrNyMoBUc/W094fqzp3kg3pR+pAtoKBu0a JTLgr7wmMam85kiILN1J+KJ9KlA/npmnLAssxP5lgiYM9NHX8kJkcUoHzRPDAfrznirZ VCfQ== X-Gm-Message-State: AAQBX9dVcDj6JrfZIAtSEiEL35aXQXqdDDdDBlAf4YgqdFkOgY3cB4hD RmPMr+UVjSr8lkYtD5pEUWM= X-Google-Smtp-Source: AKy350YK6ZXedBig5mHmtOyoPrGMFSbVmiHuPdA1NfRLq4EnkOhsj3geYQNtVkOLVZKiA/kig5Xpcg== X-Received: by 2002:a17:906:f757:b0:94e:c142:df98 with SMTP id jp23-20020a170906f75700b0094ec142df98mr2497344ejb.60.1682087839104; Fri, 21 Apr 2023 07:37:19 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:18 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 11/22] net: dsa: mt7530: remove pad_setup function pointer Date: Fri, 21 Apr 2023 17:36:37 +0300 Message-Id: <20230421143648.87889-12-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073720_724727_C5567AA4 X-CRM114-Status: GOOD ( 17.68 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL The pad_setup function pointer was introduced with 88bdef8be9f6 ("net: dsa: mt7530: Extend device data ready for adding a new hardware"). It was being used to set up the core clock and port 6 of the MT7530 switch, and pll of the MT7531 switch. All of these were moved to more appropriate locations, and it was never used for the switch on the MT7988 SoC. Therefore, this function pointer hasn't got a use anymore. Remove it. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL Acked-by: Daniel Golle --- drivers/net/dsa/mt7530.c | 36 ++---------------------------------- drivers/net/dsa/mt7530.h | 3 --- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 58eff6568d4c..a1627e20675d 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -473,18 +473,6 @@ mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) return 0; } -static int -mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) -{ - return 0; -} - -static int -mt7531_pad_setup(struct dsa_switch *ds, phy_interface_t interface) -{ - return 0; -} - static void mt7531_pll_setup(struct mt7530_priv *priv) { @@ -2569,14 +2557,6 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port, } } -static int -mt753x_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state) -{ - struct mt7530_priv *priv = ds->priv; - - return priv->info->pad_setup(ds, state->interface); -} - static int mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface) @@ -2743,8 +2723,6 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, if (priv->p6_configured) break; - mt753x_pad_setup(ds, state); - if (mt753x_mac_config(ds, port, mode, state) < 0) goto unsupported; break; @@ -3046,11 +3024,6 @@ static int mt753x_set_mac_eee(struct dsa_switch *ds, int port, return 0; } -static int mt7988_pad_setup(struct dsa_switch *ds, phy_interface_t interface) -{ - return 0; -} - static int mt7988_setup(struct dsa_switch *ds) { struct mt7530_priv *priv = ds->priv; @@ -3112,7 +3085,6 @@ const struct mt753x_info mt753x_table[] = { .phy_write_c22 = mt7530_phy_write_c22, .phy_read_c45 = mt7530_phy_read_c45, .phy_write_c45 = mt7530_phy_write_c45, - .pad_setup = mt7530_pad_clk_setup, .mac_port_get_caps = mt7530_mac_port_get_caps, .mac_port_config = mt7530_mac_config, }, @@ -3124,7 +3096,6 @@ const struct mt753x_info mt753x_table[] = { .phy_write_c22 = mt7530_phy_write_c22, .phy_read_c45 = mt7530_phy_read_c45, .phy_write_c45 = mt7530_phy_write_c45, - .pad_setup = mt7530_pad_clk_setup, .mac_port_get_caps = mt7530_mac_port_get_caps, .mac_port_config = mt7530_mac_config, }, @@ -3136,7 +3107,6 @@ const struct mt753x_info mt753x_table[] = { .phy_write_c22 = mt7531_ind_c22_phy_write, .phy_read_c45 = mt7531_ind_c45_phy_read, .phy_write_c45 = mt7531_ind_c45_phy_write, - .pad_setup = mt7531_pad_setup, .cpu_port_config = mt7531_cpu_port_config, .mac_port_get_caps = mt7531_mac_port_get_caps, .mac_port_config = mt7531_mac_config, @@ -3149,7 +3119,6 @@ const struct mt753x_info mt753x_table[] = { .phy_write_c22 = mt7531_ind_c22_phy_write, .phy_read_c45 = mt7531_ind_c45_phy_read, .phy_write_c45 = mt7531_ind_c45_phy_write, - .pad_setup = mt7988_pad_setup, .cpu_port_config = mt7988_cpu_port_config, .mac_port_get_caps = mt7988_mac_port_get_caps, .mac_port_config = mt7988_mac_config, @@ -3179,9 +3148,8 @@ mt7530_probe_common(struct mt7530_priv *priv) /* Sanity check if these required device operations are filled * properly. */ - if (!priv->info->sw_setup || !priv->info->pad_setup || - !priv->info->phy_read_c22 || !priv->info->phy_write_c22 || - !priv->info->mac_port_get_caps || + if (!priv->info->sw_setup || !priv->info->phy_read_c22 || + !priv->info->phy_write_c22 || !priv->info->mac_port_get_caps || !priv->info->mac_port_config) return -EINVAL; diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index c3a37a0f4843..cad9115de22b 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -696,8 +696,6 @@ struct mt753x_pcs { * @phy_write_c22: Holding the way writing PHY port using C22 * @phy_read_c45: Holding the way reading PHY port using C45 * @phy_write_c45: Holding the way writing PHY port using C45 - * @pad_setup: Holding the way setting up the bus pad for a certain - * MAC port * @phy_mode_supported: Check if the PHY type is being supported on a certain * port * @mac_port_validate: Holding the way to set addition validate type for a @@ -718,7 +716,6 @@ struct mt753x_info { int regnum); int (*phy_write_c45)(struct mt7530_priv *priv, int port, int devad, int regnum, u16 val); - int (*pad_setup)(struct dsa_switch *ds, phy_interface_t interface); int (*cpu_port_config)(struct dsa_switch *ds, int port); void (*mac_port_get_caps)(struct dsa_switch *ds, int port, struct phylink_config *config); From patchwork Fri Apr 21 14:36:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220180 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F302C7618E for ; Fri, 21 Apr 2023 14:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p+dofZHOOW69JOLHI22sQ8OPoJMkGCG8x3AI17TiDqs=; b=3vlBBRNCJsgchc lVQjRNC45ptf82FW7CKZPe+XgonC5+sRyTvk2MBd7hEKvAX443HJGZxC7gFHE2aGu8RKTSkGC2+hJ PxWodvvPQzmz/MhSRpWmgiLzlajqIG7iVM4SCxNQhRtfxh3NwJ0FoXWD/7nauNlRRpHzmcAaTNxdr ov0rt6Mhnah1A8/TTA2aO3DoCA+q9cmaT/jrYQKPKa+/pXWQsCUdi+Ku/7E3qRKREIcQ4eJsVX+c5 EjDWPOEcKhz27fvCa+EbT2sg1I7rbXvNCmZkRtLgZFgp3yX4DcqzfIQeYvumBs+alSOaPLHtaG3z8 CnhulqUBkLGJLnE2V7+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppruI-00B8TA-0B; Fri, 21 Apr 2023 14:38:38 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprt5-00B7XX-0u; Fri, 21 Apr 2023 14:37:26 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5066ce4f490so2550893a12.2; Fri, 21 Apr 2023 07:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087841; x=1684679841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p+dofZHOOW69JOLHI22sQ8OPoJMkGCG8x3AI17TiDqs=; b=fXw97UmiJ/MMCmvWZV6wGK4K+sByF72DQK538kfvhJ4Fdvmy6QXu1cPLN5YefNNSpG 88YqFD0qkMpghVdRxjdcZBdim6DnGfZcA11nK+dOOgT6WEGv5nIVggWUPf8zEcpgN/Ev 8AsRipc0PafM+bi/fm+Z/u42rj9tVNlVP5BxtJm6s4YBoRRfAyJPkfr9VVaEI4Yq1+ys nggpgDmcN3TgCFV1cajMPxaZ48lT5XE9aF8SBpfwotQhWJzWMF6yQv9qgaIi8FtuX92X DiBtjDD6jxEL8Ckn7/M2VdwAGahE8ujMxvb6+KUbb4zuuskoHRdanMBD4bCt6wsXIV75 wVnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087841; x=1684679841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p+dofZHOOW69JOLHI22sQ8OPoJMkGCG8x3AI17TiDqs=; b=E007oZB7rmkA3e5tAAagAeaF7zKcumCKZs7Tx/FkYLKnLSOoRpvqQHiIdfixMmmb24 gGEWlHoDAOxfPOl1w7OQ3f1rmhIEVHC9lF6Y+At4cBfE6dt2HZisBxUD7j+c7ozy+We7 dt6g9Y7yi6BP/Mk57kUXl/HWt5WyoLO81C57F/upYugD89yichr58NEI9O9fATxlfk8P SSfdrLhoO4dlj2b7fhVUpKEOyaTwAvbeYXOzPHHqsbyT3AQ8lAFGg4L15DOefXz2lYZk aONWBb9hoXpvUd8pZHvO2uqs0FjKc56arULWwdxFO7LE/HwVi3odRzZw4N90ihI+MFaA lqoA== X-Gm-Message-State: AAQBX9cq19+md243E/gkdxSbMO+NxwfMwiAXauW9o4QhJa+ekw4172d3 zc3xdd/RTHTet5++9h3BgvM= X-Google-Smtp-Source: AKy350aULjZUKC1bGLSUxBB90hqtc9kUEcTXJTE84prab1d7nVL3w+d/kkEZm0sKgE9SE4JKFv0E5w== X-Received: by 2002:a17:906:2c58:b0:953:5eb4:fe45 with SMTP id f24-20020a1709062c5800b009535eb4fe45mr2339306ejh.23.1682087841265; Fri, 21 Apr 2023 07:37:21 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:21 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 12/22] net: dsa: mt7530: move XTAL check to mt7530_setup() Date: Fri, 21 Apr 2023 17:36:38 +0300 Message-Id: <20230421143648.87889-13-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073723_337987_8EBF5450 X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL The crystal frequency concerns the switch core. The frequency should be checked when the switch is being set up so the driver can reject the unsupported hardware earlier and without requiring port 6 to be used. Move it to mt7530_setup(). Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index a1627e20675d..eaa36d41e8b9 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -408,13 +408,6 @@ mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) xtal = mt7530_read(priv, MT7530_HWTRAP) & HWTRAP_XTAL_MASK; - if (xtal == HWTRAP_XTAL_20MHZ) { - dev_err(priv->dev, - "%s: MT7530 with a 20MHz XTAL is not supported!\n", - __func__); - return -EINVAL; - } - switch (interface) { case PHY_INTERFACE_MODE_RGMII: trgint = 0; @@ -2136,7 +2129,7 @@ mt7530_setup(struct dsa_switch *ds) struct mt7530_dummy_poll p; phy_interface_t interface; struct dsa_port *cpu_dp; - u32 id, val; + u32 id, val, xtal; int ret, i; /* The parent node of master netdev which holds the common system @@ -2206,6 +2199,15 @@ mt7530_setup(struct dsa_switch *ds) return -ENODEV; } + xtal = mt7530_read(priv, MT7530_HWTRAP) & HWTRAP_XTAL_MASK; + + if (xtal == HWTRAP_XTAL_20MHZ) { + dev_err(priv->dev, + "%s: MT7530 with a 20MHz XTAL is not supported!\n", + __func__); + return -EINVAL; + } + /* Reset the switch through internal reset */ mt7530_write(priv, MT7530_SYS_CTRL, SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST | From patchwork Fri Apr 21 14:36:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220181 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D358C7618E for ; Fri, 21 Apr 2023 14:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Mjphz1SQ1OrOeSXiEFiIHbe85DtwLLcL9ymLDLdzxyQ=; b=T5/6aRh3Dvrj+e UYX4metXstGpvdAIhQbtPqz/VeP3x7OPLNbxhiIMhnug9lC9O3O7JeapP8g7KGXSnOUGWYo7QM82E KdDntNGKIoxqOzSAsJidy1negM17p6E9Gj6v/rxXIeVT0Y4jukGXoZIZd6v+b/2SJiJEGSXSg9fsh uCxDAMMlOG5L4WdZVzRtXSpd16HoEpeYuoKsu71O/RORdrv+pbNbsS+gjsUrnrYKkocHlppZaN9C7 VojhGbksSzo/f0WlCMzRo2NRBQxM7pSRYr2GOKa5Y4skmVqsXfVEfxDRakPXayKCi7l3h/uxnfzRG NDCncsnnv6pBzkehIiKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppruY-00B8iH-2V; Fri, 21 Apr 2023 14:38:54 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprt8-00B7ZH-0h; Fri, 21 Apr 2023 14:37:27 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-504ecbfddd5so2535009a12.0; Fri, 21 Apr 2023 07:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087844; x=1684679844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mjphz1SQ1OrOeSXiEFiIHbe85DtwLLcL9ymLDLdzxyQ=; b=cnBzdhaf0YmeisJZ6iXXODyfaLPtrxG+H99ayoHqrmFef08H+RwHTPatggPRoIdvBG DQk4Yi2+zGHRCvJiEcPGc2oiZwcTUa8iqjUOAVZvHKqRCPLAU0aHQ7c6QUdiZ00NJp0B IPk34XNVA9+9Y5KiIvzh01nys8UkR7KXDkZqGpowv+DLAZPrNhSwICIJWFCT2zZHSP/E m1oz5h0XYOXTeRQgkMj1A0UfAcWje8uJGtBNtFqetJNy+9vpGHOTefudrid6DXtaIH0v VbVu4EkfrPQv3PC5tb/PMFcN7N3pG0N/Iji2jbLcMTwFvgozWDF2q4/JOjvOwabqKWnL EKfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087844; x=1684679844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mjphz1SQ1OrOeSXiEFiIHbe85DtwLLcL9ymLDLdzxyQ=; b=AWiRPcUI979YlaUAZ8+u2Pjf+Vud1Fd+6+5dSTwnmNAUeECwfPaWzUmPaCzyK8ow74 x+YCYRBa897lIBR+lWDdXbcmzWtkIp6cbeB0Z9z+SXjgLntd6TkBNeY8MGeurEBwuUzu YY5kwt42ybPK1MihpsB6PWlAtWXFBIp1d4phSh30yNAlMPproiqB5lLiUrxyrb4kkRzl lUsf0XnqAdF15Uvs6MJ/tOpbYGblAlcnh6lq6ZK171tkz2XlBzFAhDNbzgnSONk7rrDX LhJo7NAkN0JkeOP/Ak19or3ln74512mkopWdOsX5Qg0XtWu5ruFjSSz9ZWRZgDJgc0ZY nvBA== X-Gm-Message-State: AAQBX9fECekdxhEdEmTb0HRimWhzuLabPMSPFbWq588ZsmPntJWltabC CSPUdhvPSFsBsPOGKJaYMAs= X-Google-Smtp-Source: AKy350avDHrE1AHP0UASNUQGVphBKj5SjdYshuXQsFJQXaQYtBX6uitIm0GFXha004CfnFV37GEqeA== X-Received: by 2002:a17:906:bc43:b0:94d:cebe:691 with SMTP id s3-20020a170906bc4300b0094dcebe0691mr2481692ejv.69.1682087843438; Fri, 21 Apr 2023 07:37:23 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:23 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 13/22] net: dsa: mt7530: move enabling port 6 to mt7530_setup_port6() Date: Fri, 21 Apr 2023 17:36:39 +0300 Message-Id: <20230421143648.87889-14-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073726_276942_A74C9478 X-CRM114-Status: GOOD ( 11.82 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL Enable port 6 only when port 6 is being used. Update the comment on mt7530_setup() with a better explanation. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index eaa36d41e8b9..8fe9b1e6932c 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -404,7 +404,11 @@ static int mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) { struct mt7530_priv *priv = ds->priv; - u32 ncpo1, ssc_delta, trgint, xtal; + u32 ncpo1, ssc_delta, trgint, xtal, val; + + val = mt7530_read(priv, MT7530_MHWTRAP); + val &= ~MHWTRAP_P6_DIS; + mt7530_write(priv, MT7530_MHWTRAP, val); xtal = mt7530_read(priv, MT7530_HWTRAP) & HWTRAP_XTAL_MASK; @@ -2224,9 +2228,9 @@ mt7530_setup(struct dsa_switch *ds) mt7530_rmw(priv, MT7530_TRGMII_RD(i), RD_TAP_MASK, RD_TAP(16)); - /* Enable port 6 */ + /* Enable PHY access and operate in manual mode */ val = mt7530_read(priv, MT7530_MHWTRAP); - val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS; + val &= ~MHWTRAP_PHY_ACCESS; val |= MHWTRAP_MANUAL; mt7530_write(priv, MT7530_MHWTRAP, val); From patchwork Fri Apr 21 14:36:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220182 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3BF1C77B76 for ; Fri, 21 Apr 2023 14:39:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BFh2cVYNVWNH2e/B2Q9MnHN00EOGUMNPev4l4KjaQPQ=; b=Nv54CWf8GTe6yg /cBh8vghkIviIyMNZj7S/jzDnLn+MmAOsDOS5adGeF6DO+k+rfqlqOL2nsFoB/RE33Q68PMtQDq72 4y1t0Bb/4s6Aj5vfeRZpYfh4Z47sMWcf8LEPxS7Y7C8jK5arSrTVdts/sIY5H659pkXN6MktyxWi7 jZtiAnGdY/h5FlBg7lBuLKUcQL0XjsxmWIL1vjQXgsN6QTcieaEZda5N80MklugTURchttbixm6aK LXm4k5My/72kDuusrzUXC07wYub08I9uWPR5EvwaxR6DlwGSvVYCVCVC62SVeeY71MPNYFTGczOT+ 8rODo8ht6lu3DkpNbLoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprug-00B8p7-1N; Fri, 21 Apr 2023 14:39:02 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprtA-00B7aq-1K; Fri, 21 Apr 2023 14:37:29 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-506bdf29712so12863107a12.0; Fri, 21 Apr 2023 07:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087846; x=1684679846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BFh2cVYNVWNH2e/B2Q9MnHN00EOGUMNPev4l4KjaQPQ=; b=Eji7XoaMdAzuLZN23yCesTBFPa6Gx7VFBSGwOlbm/mx/yEJNkFWxiSoy9sZbvFQTDH R2EopPYhnBw+zEqsC4T4JFkh+694rd14o1UvM9MwCZf/PlBPn94u7J6jP9yQBjyXGtV/ zOqtHTFzvaAjPCUoWT2D32fCkRLRJm69Oac5h4L5mqxz8aWc2A27GxS/4rPBlkdn+J8B BBUQ9JlQkva8CaildHU7EdmGper61dY/YdcEp+vaEgCQpP8NuOhV3vjBE5B1592O4BcM J4lj4YYfzyhekhv78/Gah9fer+cNGvjrHJNLtUQHjurp1KtykNLJG5S50xOq1H4xv2Ui QJYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087846; x=1684679846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BFh2cVYNVWNH2e/B2Q9MnHN00EOGUMNPev4l4KjaQPQ=; b=Ml1hjIKWNFCaf1OK5v7Rmy7qkGR2TmAmIdXeM2UB65EH1hfdsMTeB+0HLLXQGG1VLj X0E2nFp8VCSKxBpaSKcAGOaJdGz2O4CwLecutVy2z+PXGCKYPWlFqFR4BwhO93GzVgkS SCRVhJxKbr+0KH+pswuOSURqkZlwNVBolfUqLNP+Dc9+/xNMDZM5djWnisc9H8eJt3B0 Mb7niJRP0IfBaKzWZdxYcUM5wbNnirzSSfYVS2AGnZQ1xP9jYqj6Db4xUgpPAzGYtXLw gPX6M5JgZ0qLkqbUGOXicaVQbv1HGkheACMaHrt+L94Ep340/j7EbYBLUg5k7JD5ZoeO UOyg== X-Gm-Message-State: AAQBX9f+URs515lG0406mwbkLoLTt11aJmSBI7dn3u4x2fXpb+p65Yi9 2kF6l1r+WtXuRWXPR5ghamI= X-Google-Smtp-Source: AKy350bbVTzvWAyw1Pzyv3JZvCjOYIu5BlzcjdfB57uvypsYM9/7E18cQ+2Yd/+fSMrEkeBkXKLRJA== X-Received: by 2002:a17:906:4557:b0:957:1dda:853b with SMTP id s23-20020a170906455700b009571dda853bmr2170790ejq.24.1682087845626; Fri, 21 Apr 2023 07:37:25 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:25 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 14/22] net: dsa: mt7530: switch to if/else statements on mt7530_setup_port6() Date: Fri, 21 Apr 2023 17:36:40 +0300 Message-Id: <20230421143648.87889-15-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073728_450631_183EE0D0 X-CRM114-Status: GOOD ( 15.62 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL This code is from before this driver was converted to phylink API. Phylink deals with the unsupported interface cases before mt7530_setup_port6() is run. Therefore, the default case would never run. However, it must be defined nonetheless to handle all the remaining enumeration values, the phy-modes. Switch to if/else statements which simplifies the code. Change mt7530_setup_port6() to void now that there're no error cases left. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 8fe9b1e6932c..610828b56eac 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -400,11 +400,11 @@ static void mt7530_pll_setup(struct mt7530_priv *priv) } /* Setup port 6 interface mode and TRGMII TX circuit */ -static int +static void mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) { struct mt7530_priv *priv = ds->priv; - u32 ncpo1, ssc_delta, trgint, xtal, val; + u32 ncpo1, ssc_delta, xtal, val; val = mt7530_read(priv, MT7530_MHWTRAP); val &= ~MHWTRAP_P6_DIS; @@ -412,16 +412,18 @@ mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) xtal = mt7530_read(priv, MT7530_HWTRAP) & HWTRAP_XTAL_MASK; - switch (interface) { - case PHY_INTERFACE_MODE_RGMII: - trgint = 0; - break; - case PHY_INTERFACE_MODE_TRGMII: - trgint = 1; + if (interface == PHY_INTERFACE_MODE_RGMII) { + mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK, + P6_INTF_MODE(0)); + } else { + mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK, + P6_INTF_MODE(1)); + if (xtal == HWTRAP_XTAL_25MHZ) ssc_delta = 0x57; else ssc_delta = 0x87; + if (priv->id == ID_MT7621) { /* PLL frequency: 150MHz: 1.2GBit */ if (xtal == HWTRAP_XTAL_40MHZ) @@ -434,17 +436,7 @@ mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) if (xtal == HWTRAP_XTAL_25MHZ) ncpo1 = 0x1400; } - break; - default: - dev_err(priv->dev, "xMII interface %d not supported\n", - interface); - return -EINVAL; - } - mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK, - P6_INTF_MODE(trgint)); - - if (trgint) { /* Disable the MT7530 TRGMII clocks */ core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN); @@ -466,8 +458,6 @@ mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) /* Enable the MT7530 TRGMII clocks */ core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN); } - - return 0; } static void @@ -2568,14 +2558,11 @@ mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface) { struct mt7530_priv *priv = ds->priv; - int ret; if (port == 5) { mt7530_setup_port5(priv->ds, interface); } else if (port == 6) { - ret = mt7530_setup_port6(priv->ds, interface); - if (ret) - return ret; + mt7530_setup_port6(priv->ds, interface); } return 0; From patchwork Fri Apr 21 14:36:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220183 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CD94C7618E for ; Fri, 21 Apr 2023 14:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iqk+YQP+i1PdHjajC4dyLWTaH2it3zPPQXlXdlRzGds=; b=Nj1pzQ+yLQtxiS gap/anNHdVj+60v5GEZvqbab535HvNlFPqgCoF1wTuJA5lucOlYwHTGJNRxCJBa/WlwPX/9fmJUDD bZP5LZXtzqJyaSH+W2ni9soMwShDYjgaELoOxQj7abEB+34Vtl/8w+W3JtO99Dn9gYq2ppQzlTw8c EZ8Y8IMQ/tQLc0BE6u5+uI0aDRxEEHar1VGdxyDx1V7PGUW8NF8AnTptQSX5b9vEIeJf4iA9x26UC qyu/0MZGuhW1vvHNmQvy78WE1LKQIEtHMOBjRTA0tJfEopHWs6mH62yLEG8dakmOpNO8cS9JYtC1z qiBfW78/jhzfU+BpAxcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppruj-00B8sL-3C; Fri, 21 Apr 2023 14:39:06 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprtA-00B7RU-23; Fri, 21 Apr 2023 14:37:30 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-504eb1155d3so12779085a12.1; Fri, 21 Apr 2023 07:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087848; x=1684679848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iqk+YQP+i1PdHjajC4dyLWTaH2it3zPPQXlXdlRzGds=; b=cf0zqaREVOCi7KHT07q3yLerukZj1DdsamHxw3nAfGf21FvfVLMwaFHxjD2YoWIXgI drCjiWM9q8hPTIOp6pBsWcDaK+ikNLb8nOIDTI0LrEBkHUGePoE4jjq2G/ZJY4nG2At6 GiS/p0NHBqabpE1dl14vNEzHRQ7K3rShpPZ7SqjkNqNYYGcgRFdctl+YBgEvha1KLeDB KE9P5pZ1Z9ktkTocVlxJX+5IgZvQD35YupLPh/asFLqJuHBHM95yTQKH5fbKpK2bgLAH IQBr1GfuK67lufwBpuT2FZeXAcqjch52zWBszntCOrp6Nts1CMenoOi9yX4ScYqpz13Y lfxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087848; x=1684679848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iqk+YQP+i1PdHjajC4dyLWTaH2it3zPPQXlXdlRzGds=; b=P1FgdfBPxnhM++EGMDglQK4KiErxWjh4eK6I/C320fJvXlOG1ijqvQH6dqAOr86V4g kbvHIom8WSVkrIX2Umdkj8ucjYMcx8ZKXKzYrCoUxsUmZFrJ/flGf0mD2vAgTQFrRV2K Y2zVEMm2Jk8F8jf3Kt40DWfxoLOEm08+FxapZV9wi3emMu0o9A6Bg3PfxaRFlpAf7obK xtQFNxnOlzl/oAPG73gZpf7iTgTs0iRWDk0gRuoksbqJhElrHVKFhCnP/zUDLeG3bgHe RYNChPnNEpMYipabi5SThIySE+6tkZ52Q3fBfv5D1J4g73CLKUa8SrZjoF4CfgqgdgPt gMdQ== X-Gm-Message-State: AAQBX9ftMgRJ6qUPKzP9EEZ2qEFEd4yEBjm6xfH22CewDvNhykTsrtKv vr2cMUvBkjghva2+D9PLV3k= X-Google-Smtp-Source: AKy350aPdNFYI49dGLs5/XT2/bnUBnFqKOWqWRnqhq9XX7GP1nm0/K86h6KfOywXTrmQtK7UoDHnWg== X-Received: by 2002:a17:906:1387:b0:94a:6229:8fc1 with SMTP id f7-20020a170906138700b0094a62298fc1mr2596198ejc.31.1682087847872; Fri, 21 Apr 2023 07:37:27 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:27 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 15/22] net: dsa: mt7530: set TRGMII RD TAP if trgmii is being used Date: Fri, 21 Apr 2023 17:36:41 +0300 Message-Id: <20230421143648.87889-16-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073728_770891_8480FDAE X-CRM114-Status: GOOD ( 16.26 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL This code sets the Read Data (RD) TAP value to 16 for all TRGMII control registers. The for loop iterates over all the TRGMII control registers, and mt7530_rmw() function is used to perform a read-modify-write operation on each register's RD_TAP field to set its value to 16. This operation is used to tune the timing of the read data signal in TRGMII to match the TX signal of the link partner. Run this if trgmii is being used. Since this code doesn't lower the driving, there's no apparent benefit to run this if trgmii is not being used. Add a comment to explain the code. Thanks to 趙皎宏 (Landen Chao) for pointing out what the code does. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 610828b56eac..029d3129bb8b 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -404,7 +404,7 @@ static void mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) { struct mt7530_priv *priv = ds->priv; - u32 ncpo1, ssc_delta, xtal, val; + u32 ncpo1, ssc_delta, i, xtal, val; val = mt7530_read(priv, MT7530_MHWTRAP); val &= ~MHWTRAP_P6_DIS; @@ -457,6 +457,11 @@ mt7530_setup_port6(struct dsa_switch *ds, phy_interface_t interface) /* Enable the MT7530 TRGMII clocks */ core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_TRGMIICK_EN); + + /* Set the Read Data TAP value of the MT7530 TRGMII */ + for (i = 0; i < NUM_TRGMII_CTRL; i++) + mt7530_rmw(priv, MT7530_TRGMII_RD(i), + RD_TAP_MASK, RD_TAP(16)); } } @@ -2214,10 +2219,6 @@ mt7530_setup(struct dsa_switch *ds) mt7530_write(priv, MT7530_TRGMII_TD_ODT(i), TD_DM_DRVP(8) | TD_DM_DRVN(8)); - for (i = 0; i < NUM_TRGMII_CTRL; i++) - mt7530_rmw(priv, MT7530_TRGMII_RD(i), - RD_TAP_MASK, RD_TAP(16)); - /* Enable PHY access and operate in manual mode */ val = mt7530_read(priv, MT7530_MHWTRAP); val &= ~MHWTRAP_PHY_ACCESS; From patchwork Fri Apr 21 14:36:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220220 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABF5BC77B71 for ; Fri, 21 Apr 2023 14:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FZ8YgUYPk1BlgEuRR44l+Fg104ZW02BZsA3SV8H37Js=; b=K15JoEz1Fp3/aB N/UwgGcWdS88uzt8DrUEvHBvUIvwfy57azxJ0ZwQX3mIWEXsak+dwmhiMfqo5+9UqCgyBwHq274fF 2OdAiXPRQsdaqkPLb+aeAOOqxArsN2OUJSp75FIK7/1AktmjsPCcX0AQ3muKRwj+UyyVj2GcE7Wth LpiMiZmAbRsEXdbkcsBERdJZAIQxQaiTtdciFQ0VMJSqEnO4uAfNX4bCk89Y+inWcTonNFCRttkWm MoUfjQk2ju1mxwak2i1WLCEXVi/hzz0z/IfR8ITR+UFgrk5OymS5Dw3Xb8LKEZNArlFLTq1QysURt FdkFRqmyLAcp+mLC/Kkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprvD-00B9Gt-19; Fri, 21 Apr 2023 14:39:37 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprtD-00B7e2-1S; Fri, 21 Apr 2023 14:37:33 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5083bd8e226so2569699a12.3; Fri, 21 Apr 2023 07:37:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087850; x=1684679850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FZ8YgUYPk1BlgEuRR44l+Fg104ZW02BZsA3SV8H37Js=; b=U5NHcKalC4+8sMwdwp4mGjS2snuxVPW3Sugcax6GJMa+CeydeXKVqrErLFqKrDVhVN 3uNX7HHL0dyhzkWY2Y/lc80X+qcMts66PadQIDeNLn/hvpm6un2kHwLRz14Jv0JX/2Vl lNnKIvyDaIjxleo+ixSeNoxEPUcOwNvxMJ7860/DchZ/nUQnNkMNBj4dK+bD/UQvgoRN bA/IB4W/AvS7ZYwFC+JWqhbFS/zwsFQyV3REmIlx356/ZbBSRPc8QOJcIup1ZLcmxcK+ CgGqdv6/WM4RuOi1zpaFuMyrTpym1krNVMGyZl3ztXQ43Tyy6rSP1RRSOY+fVgWnP06T U5dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087850; x=1684679850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FZ8YgUYPk1BlgEuRR44l+Fg104ZW02BZsA3SV8H37Js=; b=QTn1aW/Yx7NRTtXiy9xMC4wsljKsD+dJlWp7OA9TjTBmT2eYYk+wh+sjHbyblT9Lvf WHix43BPevNoYeEhf5bj6TBWcm+hFyn/S9NY839XsY1p7zWxqvFYO6dcEx/PjJnMr3BW tEGe1YZbwRPPkBl1oHPLB8WGT0CsG/VbC58cH40VZ0ne4t/KDt6q5j6siv/bIY5ae5eQ Q0H/LnjX1/VUjS/2cts2rU4Jf4DAWDFC1M/yl4hJ8F2td74RDyr2AT8ailS3JblvDKtp G2g8DecED8fgnzAg0Lj8WG8d9jJRY4NzPNZSm1vkmL8sM9nAl3pDZZVNsPzcPt8g52t/ BQbA== X-Gm-Message-State: AAQBX9eO4bGxN2cJb5LO3Z/wrHPim7gnCWHcdslIIzbHoyMKulLDt6BM H8yOoGNWFsnJVoTUtx33z3U= X-Google-Smtp-Source: AKy350Yn9RipJy2SbwmUEVL08A6pIXKIY+5qeS1WhOyzZ8b43mMhNv+4vGwG7GeisZVmC8rSXNgzdg== X-Received: by 2002:a17:907:9603:b0:94e:6dc8:7ba7 with SMTP id gb3-20020a170907960300b0094e6dc87ba7mr2959685ejc.34.1682087850021; Fri, 21 Apr 2023 07:37:30 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:29 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 16/22] net: dsa: mt7530: move lowering port 5 RGMII driving to mt7530_setup() Date: Fri, 21 Apr 2023 17:36:42 +0300 Message-Id: <20230421143648.87889-17-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073731_755063_3E00201A X-CRM114-Status: GOOD ( 12.44 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL Move lowering Tx driving of rgmii on port 5 to right before lowering of Tx driving of trgmii on port 6 on mt7530_setup(). This way, the switch should consume less power regardless of port 5 being used. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 029d3129bb8b..5466259fd99b 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -938,10 +938,6 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) /* P5 RGMII TX Clock Control: delay x */ mt7530_write(priv, MT7530_P5RGMIITXCR, CSR_RGMII_TXC_CFG(0x10 + tx_delay)); - - /* reduce P5 RGMII Tx driving, 8mA */ - mt7530_write(priv, MT7530_IO_DRV_CR, - P5_IO_CLK_DRV(1) | P5_IO_DATA_DRV(1)); } mt7530_write(priv, MT7530_MHWTRAP, val); @@ -2214,6 +2210,10 @@ mt7530_setup(struct dsa_switch *ds) mt7530_pll_setup(priv); + /* Lower P5 RGMII Tx driving, 8mA */ + mt7530_write(priv, MT7530_IO_DRV_CR, + P5_IO_CLK_DRV(1) | P5_IO_DATA_DRV(1)); + /* Lower Tx driving for TRGMII path */ for (i = 0; i < NUM_TRGMII_CTRL; i++) mt7530_write(priv, MT7530_TRGMII_TD_ODT(i), From patchwork Fri Apr 21 14:36:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220221 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A016BC7618E for ; Fri, 21 Apr 2023 14:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QL82S92PhjBdYfMxindC7dNu43LqusGvD9gOD5L3A2g=; b=hsGLjT+3dx3AGV U1UKsRSFh4JFtsS1WZXwUDEgnGAizK86/pZCk9l6dNYww6fnhh1fmkShOvlF+RrjphslNVtaml/f5 7NktoczqOOSifb8aXJH7Uv1XrUhTUa5c7+H1KsZ25inRe2Wjp3yPn/ghTP9IkLLm9FO5ATANBCpWx 9NqmVo8CaXGzN2u2gOkVtcXTTm2BGORGEPr+bhy+kXdKf1GUvrQw3OXp+q9jOodZG3dkBXDPBq4W/ WKWssrwVhfvPWhFVPhrh6rqFhwLyfB0bvvWKRpAOe3x5jmeRdsj55XR4jL+nm8qLydz3saDDcbjJi NTgcCEI+5895ig1e92Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprvS-00B9SV-0j; Fri, 21 Apr 2023 14:39:50 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprtE-00B7Sh-2Q; Fri, 21 Apr 2023 14:37:35 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-94eee951c70so250062266b.3; Fri, 21 Apr 2023 07:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087852; x=1684679852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QL82S92PhjBdYfMxindC7dNu43LqusGvD9gOD5L3A2g=; b=bKD2PiaWlSQ8fki7UcZX0yKrc00KrG55tW4wCF3mwt+64q32ybCgNLbl1ad+5I5avz oGYmtQU12vKk7tUHMxqOgP+rPs0fOnOwCUKUlzVKB5c8FD85wUc0fLnzCwWAXEhIG8ZP USVps0ZH6DAcGtUD1LwBymYbYCWG3nriM0pcCfO2fmSOuzruQ1RaM6bUy1didxjJwPPZ sMclDWOM5wSOo6C14S5eoVBXT+JImitb+GV7pomFNjjcqT8wwH1W5GkgUi2iWgEwENq3 e7k6JritmPMtrB/wkStkMxoxklPEmfSzTmEZIFGFUPMBdzoBBJCBnxeIKmoyVpbzoLpE f2sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087852; x=1684679852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QL82S92PhjBdYfMxindC7dNu43LqusGvD9gOD5L3A2g=; b=jZB9VK9SMWItXeIs96g13qG0xhFtCAIZGCbzy5hCsACplrDDSnyp1d7jqFLG31IVOb TAXphnZU7R1Q1KTd0Ecj2EBP9Wdm1Emy2FXkIcX52T4DPUAk2QwtHpaeBhYKSu2jV4Rd i/6s3vZlLjwIdd6dv0V2e2V48j67b3zAhhmes1LJy1pXwlkAxJXGxOBX9hedbvZjYLht N+7lO0DSIxttf3giZfkw+AU7nsQWCcd0klJ+9wYcF80l5F222uCgs8+Gvke5PDFxv5VH mFH0ZfH4ItDWQ/ld8EKhMY6aC/V8z+3trEdShTRm4pkZdqX+fgUIVILBAsGftYcvj2j9 UEcw== X-Gm-Message-State: AAQBX9cI5QO7YAKdCVueheYio72JvmJM9Jw14KiVXyr7R6gHPxxFOlx7 hvZuCxCOyrOtVijdEJyrn0U= X-Google-Smtp-Source: AKy350Zz7vHaBqbcCW8whFHVzYvj2/PnK3KBZofM+qOcv70sDcdPH+IJR6ZEBIq25sled6qYWm94nA== X-Received: by 2002:a17:906:10ce:b0:94f:5242:a03a with SMTP id v14-20020a17090610ce00b0094f5242a03amr3010132ejv.63.1682087852178; Fri, 21 Apr 2023 07:37:32 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:31 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 17/22] net: dsa: mt7530: fix port capabilities for MT7988 Date: Fri, 21 Apr 2023 17:36:43 +0300 Message-Id: <20230421143648.87889-18-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073732_807010_BFC5DFBB X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL On the switch on the MT7988 SoC, there are only 4 PHYs. That's port 0 to 3. Set the internal phy cases to '0 ... 3'. There's no need to clear the config->supported_interfaces bitmap before reporting the supported interfaces as all bits in the bitmap will already be initialized to zero when the phylink_config structure is allocated. There's no code that would change the bitmap beforehand. Remove it. Fixes: 110c18bfed41 ("net: dsa: mt7530: introduce driver for MT7988 built-in switch") Signed-off-by: Arınç ÜNAL Acked-by: Daniel Golle --- drivers/net/dsa/mt7530.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 5466259fd99b..899fc52193e1 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2538,10 +2538,8 @@ static void mt7531_mac_port_get_caps(struct dsa_switch *ds, int port, static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port, struct phylink_config *config) { - phy_interface_zero(config->supported_interfaces); - switch (port) { - case 0 ... 4: /* Internal phy */ + case 0 ... 3: /* Internal phy */ __set_bit(PHY_INTERFACE_MODE_INTERNAL, config->supported_interfaces); break; From patchwork Fri Apr 21 14:36:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220224 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00E72C77B71 for ; Fri, 21 Apr 2023 14:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jH8yEvnmoXsEC6mwOHxF9ajbBlURmLh7zMT6HCy7q6s=; b=SpO2vOCTz34/1n QkkzWMcPN56dUye+VijFinCGpEJdH+T9mYTsj4yOGW8lyq6i5WQwu3/zWannKKoXbwJH1lOPLjCXd 7nssmVnlaiNLMII3SUsc3gGCU8zoX1n8iqfvfIe+QyGkym68zySX6OJ5lCVTZ+qW/zNa4E8kHZVrQ a1JYKDiK4JmzQIQUCpAhghooUI9gX5pMr1vGXou8PsM/gugvtEI1buMewZYSNMq2Kr1BTo0EXvYi7 9WkctPzUq0A16SbWH6cbQKvyV9xfgCaXuwY4lhwtAlFYhIIT8dkluVwwfjyb5j2mwjN8Uzr/TtpNw 6goaBbaXVhVhwKXr4HEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprw0-00B9tW-0O; Fri, 21 Apr 2023 14:40:24 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprtL-00B7ha-1v; Fri, 21 Apr 2023 14:37:42 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-956eacbe651so236897066b.3; Fri, 21 Apr 2023 07:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087854; x=1684679854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jH8yEvnmoXsEC6mwOHxF9ajbBlURmLh7zMT6HCy7q6s=; b=ENF4e5isJoqDkxBVkvDe8GJi2ftvSaFaD9Evi4Dpli45lx1araC/pu5qZV+/ri9OtW aLau62aVwy1AxwQ40Q861kxGjJrGhSrI1L4hqchjhCa90Ei2Ilsgnjfz9Z95jOiSfSYn f6UXow6rBZMOv2mKFxv/FKlTe6VZ2HfQHmnuKMaVE6tKv6oyVGmqx+QH2UQEDTeJSn0p ep5Ni6mPdJFC95jJgJK0wy4PHbT/ixsdvFwW7mRUDeUb7AlmtPDOmfvt236IFJLLXMeH wrDdQUbMEHPFIOhUAAz9tAIca0emd32Y/WkYY/01pNXqm+JlfHzGj/rNQmTURFQWIHMT UKDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087854; x=1684679854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jH8yEvnmoXsEC6mwOHxF9ajbBlURmLh7zMT6HCy7q6s=; b=MYUFP+gvIh0aP64lfa+AB04jdRxFp6o1Hyos7S4D5SbmYAPrfzRuLIge4eelIaidn0 aL32xWUt3R50NzvnaXNVlJzZFcOuZENFF6ZIRg2XIHjJlCmN4DuSbGrZ85TiLDPB4wxi dvLYlii0mZqE4SXtbJ+5Lkre7E7bIId+gfBAhb+JfPJliTQExn3yrCjfnjdE9uqzJq/1 rtfvGq3gnVu5Spi2h9f2Twy1aOgOLkQAmqq3lTkmlM/jjBmV1z58B0uUMwrbQR5EbM9V 1HDUkH8AxuOZ5E2omesThtSZTaoipI0fgauFSGyTTlVZaj3ErhABcWHo/9x9Ao+XeZsd tTAA== X-Gm-Message-State: AAQBX9fWd0D8MpVUAeCjUV/pfUjbM2DgSvLel2Hy3cDckWh7JUXcDmsU tXvojrZyyVyeRd2CH4voucJKsWbPGfECiv0O X-Google-Smtp-Source: AKy350b2NWrqoFCF1UDO3y+zEU6fJrF42fw4MyZhMWLq7M5pUTgsmJD+/3oPcIpL57kyJxjWUvr7Mg== X-Received: by 2002:a17:906:9b45:b0:94e:5679:d950 with SMTP id ep5-20020a1709069b4500b0094e5679d950mr2004270ejc.72.1682087854350; Fri, 21 Apr 2023 07:37:34 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:34 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 18/22] net: dsa: mt7530: remove .mac_port_config for MT7988 and make it optional Date: Fri, 21 Apr 2023 17:36:44 +0300 Message-Id: <20230421143648.87889-19-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073739_780921_9904DC21 X-CRM114-Status: GOOD ( 15.35 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL For the switch on the MT7988 SoC, the code in mac_port_config for MT7988 is not needed as the interface of the CPU port is already handled on mt7988_mac_port_get_caps(). Make .mac_port_config optional. Before calling priv->info->mac_port_config(), if there's no mac_port_config member in the priv->info table, exit mt753x_mac_config() successfully. Remove mac_port_config from the sanity check as the sanity check requires a pointer to a mac_port_config function to be non-NULL. This will fail for MT7988 as mac_port_config won't be a member of its info table. Signed-off-by: Arınç ÜNAL Co-authored-by: Daniel Golle Signed-off-by: Daniel Golle --- drivers/net/dsa/mt7530.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 899fc52193e1..a66a762cb5db 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2619,17 +2619,6 @@ static bool mt753x_is_mac_port(u32 port) return (port == 5 || port == 6); } -static int -mt7988_mac_config(struct dsa_switch *ds, int port, unsigned int mode, - phy_interface_t interface) -{ - if (dsa_is_cpu_port(ds, port) && - interface == PHY_INTERFACE_MODE_INTERNAL) - return 0; - - return -EINVAL; -} - static int mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface) @@ -2670,6 +2659,9 @@ mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode, { struct mt7530_priv *priv = ds->priv; + if (!priv->info->mac_port_config) + return 0; + return priv->info->mac_port_config(ds, port, mode, state->interface); } @@ -3113,7 +3105,6 @@ const struct mt753x_info mt753x_table[] = { .phy_write_c45 = mt7531_ind_c45_phy_write, .cpu_port_config = mt7988_cpu_port_config, .mac_port_get_caps = mt7988_mac_port_get_caps, - .mac_port_config = mt7988_mac_config, }, }; EXPORT_SYMBOL_GPL(mt753x_table); @@ -3141,8 +3132,7 @@ mt7530_probe_common(struct mt7530_priv *priv) * properly. */ if (!priv->info->sw_setup || !priv->info->phy_read_c22 || - !priv->info->phy_write_c22 || !priv->info->mac_port_get_caps || - !priv->info->mac_port_config) + !priv->info->phy_write_c22 || !priv->info->mac_port_get_caps) return -EINVAL; priv->id = priv->info->id; From patchwork Fri Apr 21 14:36:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220222 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3C9FC7618E for ; Fri, 21 Apr 2023 14:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pJixOmbyU63hr3o8Ny5bPEY6KG/MRULhsuG3NEyY2DA=; b=2fIH4BpZB+xetq RU28huIk9KGjUQ03Qev3o18nXJ6is0oVywTDKHuIvWe0xZxsaUQ7ETfDHAUBss8UCIplIfOvHSi8p 3xG+6f+h6Z8awHVyvMQIePWpNqA/ldjhwOKDujvRWih/VHV/c4MjlDf/1BF/pS3fYLE+NjDoeeNeN 3ieyRgpBawJZDhoAiXYL0C6rKNXOwNjZPdEkzQQ0lJe1M0vHMrJkLcp+FnQcVqqbSB4cgDNyvTKaO 3C1qyX+nuz+jQNKrq/H1/di7zd8yFQD2o3MyjHvx4AnK/+RHKQ0ohAXSH3+xGV5Qz+TaCiRL5DG8+ Ps88GE3GXBChtfytUP0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprva-00B9Yl-1N; Fri, 21 Apr 2023 14:39:59 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprtJ-00B7NP-0R; Fri, 21 Apr 2023 14:37:38 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-50506ac462bso2550295a12.3; Fri, 21 Apr 2023 07:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087856; x=1684679856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pJixOmbyU63hr3o8Ny5bPEY6KG/MRULhsuG3NEyY2DA=; b=Az8QzgGdCSu60O6ATgA/rltMAPtJHOIM/fNgqvUDwljrF188OKCwkUXZsu9TgceVlb XJkSkwuYk0q0LODKP0Ys/gPMEnMs9C7UjYnIRN2N2nUjxcSEfGJV5UOJaNW14e4cnTYS YYp2rdotxte5IvfGjycuGpQ4F0+Bt1P7PL7yLDSziXrWL+u+6Mhk9Y28soqpLcZy2kyl a7qeOJUJqOqXZDshLZd/zrlM0EyAayg+R+R9eZLdjHd+ki27hhuw/u3u1c3kY2DzOkpQ slACzNFllLRnXORAQTxHP8XqHNQ5mNJVS40wnXF5bfsNVrvW0XRlQPB711YFwXXbW8rJ 1lHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087856; x=1684679856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pJixOmbyU63hr3o8Ny5bPEY6KG/MRULhsuG3NEyY2DA=; b=dGWn/TeNc10l85Hk64gNiN6qwng7haKqgAJmELeU/XkfbUQ8cSpF29KkM3EG4JkCxz Gic89FYKLEj5MLm/3k5RIUF+jTCx2koLBslxMyortXX0SzxaEDXp1KcusepnUMHDj+wp W2h59d8JL7jUDpTEITiCLrchQ4sCmOK7y9Mgy/JzaEilhtY4Ddq6Q00y1BOZTmW7nfbT U+MDRjzC82AUVGHTb5LxOWWflmXpIlZiUi1AynvaH1GBbnXYbhb9JjDWNb8qgGHWZL4Z /kPQp4dqyanfio5MWMD6AQ8j2XGJ7EObxDsx8Ul8WH4P4H9bnm+j8MzbdPs9n5ZL7YN0 5JPQ== X-Gm-Message-State: AAQBX9d9Wtky08LFlb7b3z0b6GTxgjPCGfa5vtezGo4F1uG3zC7AqpUN eBStF0M5wISvApyvM7vsL2s= X-Google-Smtp-Source: AKy350Z4aXH6j521XmbeT5SJQ3g67clUrR3I/0wqCunsH6aDT41k5hSTcXbseqGcd/WUsvruZjAStw== X-Received: by 2002:a17:906:250b:b0:94f:a309:67b9 with SMTP id i11-20020a170906250b00b0094fa30967b9mr2483806ejb.6.1682087856476; Fri, 21 Apr 2023 07:37:36 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:36 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 19/22] net: dsa: mt7530: set interrupt register only for MT7530 Date: Fri, 21 Apr 2023 17:36:45 +0300 Message-Id: <20230421143648.87889-20-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073737_248312_408F2B1F X-CRM114-Status: GOOD ( 12.12 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL Setting this register related to interrupts is only needed for the MT7530 switch. Make an exclusive check to ensure this. Signed-off-by: Arınç ÜNAL Acked-by: Daniel Golle Tested-by: Daniel Golle --- drivers/net/dsa/mt7530.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index a66a762cb5db..ac1e3c58aaac 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2034,7 +2034,7 @@ mt7530_setup_irq(struct mt7530_priv *priv) } /* This register must be set for MT7530 to properly fire interrupts */ - if (priv->id != ID_MT7531) + if (priv->id == ID_MT7530 || priv->id == ID_MT7621) mt7530_set(priv, MT7530_TOP_SIG_CTRL, TOP_SIG_CTRL_NORMAL); ret = request_threaded_irq(priv->irq, NULL, mt7530_irq_thread_fn, From patchwork Fri Apr 21 14:36:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220223 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58B96C77B76 for ; Fri, 21 Apr 2023 14:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JzoT/KmMIWGXd84HSAhqqXVj6Wxc4XH+Xw/4O9lmsTc=; b=y/eoCnAaZqOpoP iWCRIhmVwfS97mTpPa/E1ZEEDHqzMhDZZsAQUiqXhQB4rGn40YallsMgsVDJoD546oMRI+IIVYmg+ i6HsoFUYlUpnMCMt14k/ESOQZ/2e/COIqMO4UaCJQWahR0cGPsjapHrRDQy5L0xxmXZLJdqIveMec vt0lr1WMOYNh7u0Cr7CXh6lP5Nk4HyAO44U+Wp2sEY8fXAfxTPGi5SyIKXWREjSwv+yfcE27i7e/P lC+GEXw/mdkjX1KFb0rTDBeFymbnoB42cAJE2AKhovncj+7Us0qBiispf8HPkPN4Lpn4jdTU/taVS CrR//QPw6GxNYBSXHIEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprvx-00B9rl-2e; Fri, 21 Apr 2023 14:40:21 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprtL-00B7lG-37; Fri, 21 Apr 2023 14:37:42 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-50506111a6eso3065275a12.1; Fri, 21 Apr 2023 07:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087858; x=1684679858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JzoT/KmMIWGXd84HSAhqqXVj6Wxc4XH+Xw/4O9lmsTc=; b=g2RMVEYoRmsDAMKPmJikqWI/qnDOB9DlBY+ZE8gvCNAJmL69pKinZmG5PGjxPlNaat FTWjOESJcCtRVa42iaqGgREtxXe/2zUwhh26Nt9+tH02uyx8hD8O190M+LojA7xrxD9y OD3L+gKvVz1qDjeAUNtKtbdHmXt10VXP+kq71avQ0r517UivyBICqRNbV03ElgqCMdjT d+1DNJdpNqtywk8N9ID7u+8gE0wt7JTY2osrVaBPH+G8uWrzChl9NB2CKIkgIi7vab4g ELXN93NH4I42ueYQhveL8CZc68I4fI96lU+FV5FMKNXb2u6ZOcEddkK8Qip8v4GEgB0Z pgcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087858; x=1684679858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JzoT/KmMIWGXd84HSAhqqXVj6Wxc4XH+Xw/4O9lmsTc=; b=Iqspl3LY0e36/jQN/YIoVKL86gTA001zV0T4CRdtzbSYy0nsT1sSf4+bzKLH2GgAsw SW70jsraapLMcrfmfVyKoQcklpl7ErjC9E6CMB9i7GdDo8ORDh87JxojSBTdjNNeMO8o oil9Dcq4dHm1AIOkFt23LA8UjKRL+yJ1d2eTvQhfjUVDuwpZdprd0SQDnxEkKvwFGcHp btb6zSJWIFFKfXnQMEvXeNOBfLdM/1BryHJ2TgmF4AT16I6w192tvmRr00yCASNLYAEU pkDHTMu1IcpkZa/qxm9UuNeZ42u5HtWWnwfRZXFBGoEAXnL17lIo8icQdN5kzMK0uVoV XBQQ== X-Gm-Message-State: AAQBX9dNi06xQhlHcQpycCbHR14OE0xLvog0SnlJ2b3SrR6R3n6zsAJS lQNfefqJ1OZt5RDRw11yIdw= X-Google-Smtp-Source: AKy350bvezXZMnE6qY8pddEadrjpfPhij7bGJMvQiC8tz2+VfLMVSEi3Ck1X+2zbazpQV9tGb8ihvQ== X-Received: by 2002:a17:906:cb94:b0:94a:826c:df57 with SMTP id mf20-20020a170906cb9400b0094a826cdf57mr2385888ejb.39.1682087858639; Fri, 21 Apr 2023 07:37:38 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:38 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 20/22] net: dsa: mt7530: force link-down on MACs before reset on MT7530 Date: Fri, 21 Apr 2023 17:36:46 +0300 Message-Id: <20230421143648.87889-21-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073740_388990_EBBE69A8 X-CRM114-Status: GOOD ( 11.13 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL Force link-down on all MACs before internal reset. Let's follow suit commit 728c2af6ad8c ("net: mt7531: ensure all MACs are powered down before reset"). Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index ac1e3c58aaac..8ece3d0d820c 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2203,6 +2203,10 @@ mt7530_setup(struct dsa_switch *ds) return -EINVAL; } + /* Force link-down on all MACs before internal reset */ + for (i = 0; i < MT7530_NUM_PORTS; i++) + mt7530_write(priv, MT7530_PMCR_P(i), PMCR_FORCE_LNK); + /* Reset the switch through internal reset */ mt7530_write(priv, MT7530_SYS_CTRL, SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST | From patchwork Fri Apr 21 14:36:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220225 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1E6B1C7618E for ; Fri, 21 Apr 2023 14:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W0SY+q/k+wS5cublkhfKHLZdZ3m6Ag++oyfwsyKHc0g=; b=jp6rV4wr/SU5Bx 41W232iU8PHYwnebWkEHbCIMmPYjLxIZ9p9X0PzyUYABszRlg3P7Q6WoYzFG7NNeoeqLZovq5M1L3 zFBczdSGriNQvM+qN01aCYozGHF2iuarcH+QbYBOlBzqY+Mkyce1Tf1+rCBZPzurBUsHrSyMBO/rl Rz0vyowMhgnBk9dFDqCKgzicB54d9btIWkvh1Tj5Im+T8K9Sb92NaBljTsFvh4vC4fcXtuxLhrmD0 VNMTYEOnxZWrPo9pq7PztbxzprySMxjSL80uzmtXFlR/8Vgp8vqUXRRFu93bsdkI5OEGcOlMkfP8P mDi6AFdDfEjBjk1NaFtw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprw3-00B9wA-1L; Fri, 21 Apr 2023 14:40:27 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprtP-00B7nE-0j; Fri, 21 Apr 2023 14:37:45 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-9536df4b907so290141466b.0; Fri, 21 Apr 2023 07:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087861; x=1684679861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W0SY+q/k+wS5cublkhfKHLZdZ3m6Ag++oyfwsyKHc0g=; b=kBf0AAsjHp4U5y3+MzkHRrO38ehIlSzJRXNBJqmpaXFoVzhpsimVNyS8UHd1xGBHr2 gTcfIZdepaVGARInpgJvzntBu+s5R3ue33aLGWNBGXiXwQDIMyPHEi9tFytdm4odsh+2 NGNw9H25bNGOIEt0UH+lA8SllwREVDIHz8TUvI8zUS54CiPm/Y4zlszpWScf+xvVSC0X tNk5LqGeb3XzyCYXiCiEhRFRxeGUTZy/wbXMxS5fgRlvtivhoRF5mygNsfzrMtv60AYK NRui5IZJG79rW+mA+C9yp7NTPcSrWKGBQ186gH4G3ishsrYbgXmlAlKp9PSx5dTEPQCt 8neQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087861; x=1684679861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W0SY+q/k+wS5cublkhfKHLZdZ3m6Ag++oyfwsyKHc0g=; b=Og42R+QfL2slksI/Z9jqVG/uuyFAmanBEi4vJDa088ilIBgHcnqVyt8Cg+UkBm9kzv F8BNlpxcc57gr3tfiZ0au4QzOoEROb6xYmTfqhw+GapRCf1sFV8kbqPML+nKnKE9TADR KINtvMOdI+A3Jv5Q7Dmjn+uuRqIJ3niJLPAorZcyUbsuxBC167FrUX+bxyy5dhpj+Q/Y F8X3Tn5Ojhk5RhrGYdJyXYpFBjk4RUUFNR/hAep9YtsmmebHKSsI+5hcvY3+yHJu+15T OzV5MYIYxUL2Oly576QZWN35UnPoGUjkLNAT7Mt8m2e6QzjA/A5hMuDpxfFj48eeiEmD YzIw== X-Gm-Message-State: AAQBX9ebp3ITCOcnGU14Zulb1/a+deU4mSUSLn+LzFAf6AP9zGLLOvvC Zd5fc4yUzQI9OM6oDdiKGc935VuIhomUaVS+ X-Google-Smtp-Source: AKy350YEJ9c4wS6IdmP5YmcPkF6gbz9rvCYvFkcpxmG8P7rEekcu6rw6pnjDiWPAczyEs8Fii33FuA== X-Received: by 2002:a17:907:70a:b0:957:2e48:5657 with SMTP id xb10-20020a170907070a00b009572e485657mr1745618ejb.68.1682087860787; Fri, 21 Apr 2023 07:37:40 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:40 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 21/22] net: dsa: mt7530: get rid of useless error returns on phylink code path Date: Fri, 21 Apr 2023 17:36:47 +0300 Message-Id: <20230421143648.87889-22-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073743_569708_BC137647 X-CRM114-Status: GOOD ( 20.59 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL Remove error returns on the cases where they are already handled with the function the mac_port_get_caps member points to. mt7531_mac_config() is also called from mt7531_cpu_port_config() outside of phylink but the port and interface modes are already handled there. Change the functions and the mac_port_config function pointer to void now that there're no error returns anymore. Remove mt753x_is_mac_port() that used to help the said error returns. On mt7531_mac_config(), switch to if statements to simplify the code. Remove internal phy cases from mt753x_phylink_mac_config() as there is no configuration to be done for them. There's also no need to check the interface mode as that's already handled with the function the mac_port_get_caps member points to. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL Acked-by: Daniel Golle Tested-by: Daniel Golle --- drivers/net/dsa/mt7530.c | 81 ++++++++-------------------------------- drivers/net/dsa/mt7530.h | 2 +- 2 files changed, 17 insertions(+), 66 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 8ece3d0d820c..3d19e06061cb 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2556,7 +2556,7 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port, } } -static int +static void mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface) { @@ -2567,22 +2567,14 @@ mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, } else if (port == 6) { mt7530_setup_port6(priv->ds, interface); } - - return 0; } -static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, - phy_interface_t interface, - struct phy_device *phydev) +static void mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, + phy_interface_t interface, + struct phy_device *phydev) { u32 val; - if (priv->p5_sgmii) { - dev_err(priv->dev, "RGMII mode is not available for port %d\n", - port); - return -EINVAL; - } - val = mt7530_read(priv, MT7531_CLKGEN_CTRL); val |= GP_CLK_EN; val &= ~GP_MODE_MASK; @@ -2610,20 +2602,14 @@ static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, case PHY_INTERFACE_MODE_RGMII_ID: break; default: - return -EINVAL; + break; } } - mt7530_write(priv, MT7531_CLKGEN_CTRL, val); - return 0; -} - -static bool mt753x_is_mac_port(u32 port) -{ - return (port == 5 || port == 6); + mt7530_write(priv, MT7531_CLKGEN_CTRL, val); } -static int +static void mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface) { @@ -2631,42 +2617,21 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, struct phy_device *phydev; struct dsa_port *dp; - if (!mt753x_is_mac_port(port)) { - dev_err(priv->dev, "port %d is not a MAC port\n", port); - return -EINVAL; - } - - switch (interface) { - case PHY_INTERFACE_MODE_RGMII: - case PHY_INTERFACE_MODE_RGMII_ID: - case PHY_INTERFACE_MODE_RGMII_RXID: - case PHY_INTERFACE_MODE_RGMII_TXID: + if (phy_interface_mode_is_rgmii(interface)) { dp = dsa_to_port(ds, port); phydev = dp->slave->phydev; - return mt7531_rgmii_setup(priv, port, interface, phydev); - case PHY_INTERFACE_MODE_SGMII: - case PHY_INTERFACE_MODE_NA: - case PHY_INTERFACE_MODE_1000BASEX: - case PHY_INTERFACE_MODE_2500BASEX: - /* handled in SGMII PCS driver */ - return 0; - default: - return -EINVAL; + mt7531_rgmii_setup(priv, port, interface, phydev); } - - return -EINVAL; } -static int +static void mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode, const struct phylink_link_state *state) { struct mt7530_priv *priv = ds->priv; - if (!priv->info->mac_port_config) - return 0; - - return priv->info->mac_port_config(ds, port, mode, state->interface); + if (priv->info->mac_port_config) + priv->info->mac_port_config(ds, port, mode, state->interface); } static struct phylink_pcs * @@ -2695,30 +2660,18 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, u32 mcr_cur, mcr_new; switch (port) { - case 0 ... 4: /* Internal phy */ - if (state->interface != PHY_INTERFACE_MODE_GMII && - state->interface != PHY_INTERFACE_MODE_INTERNAL) - goto unsupported; - break; case 5: /* Port 5, can be used as a CPU port. */ if (priv->p5_configured) break; - if (mt753x_mac_config(ds, port, mode, state) < 0) - goto unsupported; + mt753x_mac_config(ds, port, mode, state); break; case 6: /* Port 6, can be used as a CPU port. */ if (priv->p6_configured) break; - if (mt753x_mac_config(ds, port, mode, state) < 0) - goto unsupported; + mt753x_mac_config(ds, port, mode, state); break; - default: -unsupported: - dev_err(ds->dev, "%s: unsupported %s port: %i\n", - __func__, phy_modes(state->interface), port); - return; } mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port)); @@ -2811,7 +2764,6 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) struct mt7530_priv *priv = ds->priv; phy_interface_t interface; int speed; - int ret; switch (port) { case 5: @@ -2836,9 +2788,8 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) else speed = SPEED_1000; - ret = mt7531_mac_config(ds, port, MLO_AN_FIXED, interface); - if (ret) - return ret; + mt7531_mac_config(ds, port, MLO_AN_FIXED, interface); + mt7530_write(priv, MT7530_PMCR_P(port), PMCR_CPU_PORT_SETTING(priv->id)); mt753x_phylink_pcs_link_up(&priv->pcs[port].pcs, MLO_AN_FIXED, diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index cad9115de22b..ee2b3d2d6258 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -722,7 +722,7 @@ struct mt753x_info { void (*mac_port_validate)(struct dsa_switch *ds, int port, phy_interface_t interface, unsigned long *supported); - int (*mac_port_config)(struct dsa_switch *ds, int port, + void (*mac_port_config)(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface); }; From patchwork Fri Apr 21 14:36:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= X-Patchwork-Id: 13220226 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F066DC7618E for ; Fri, 21 Apr 2023 14:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZmJp66E7f+Y6znObj42iK8swVGPa549Lcio15ZPSnxQ=; b=4RhEGrt+IBWaSG Lm2Y0/2vttFFJruFOGmzbc3bA21JzBcPUnvAOqEEQPFqD/f8zLzqtOYXF9fyD8ang+7/H5BI98u3c OilaTZw/tHcYmOrfOXBC+CuLBFANqXwCT5ZJt3Zff2szIdsG4agy4evt6OWPjnVaHnsQj3l/z6N1E IFNlsEVgtKS6SLK3iuK6G/ZJT+i/3Y2ejk2gXsdKw5epEMZhdmJtb4iMzaPF8nl+xb5IgkWfgz9vI UPccfLJtBiP2HOp0arhNLmJRCEgGKvvkJtedr4H27SfCVusc3Q5RlHWnPYUkuUe66/7H/aU6kjkJZ aOAMrWy9lXBQNH6xFrkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pprwl-00BATh-03; Fri, 21 Apr 2023 14:41:11 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pprtR-00B7ot-1S; Fri, 21 Apr 2023 14:37:47 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-94f6c285d22so288950566b.2; Fri, 21 Apr 2023 07:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682087863; x=1684679863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZmJp66E7f+Y6znObj42iK8swVGPa549Lcio15ZPSnxQ=; b=XHY8SQ0nVRKoZTcLzj4l+LM5LQOi8vlGiwQ8QoZI9l9DoGKtf1oaT+Pvrqs5SYtQNC E1Cbp25l2IAMrunqWeAVFKQ58dOvSlKEhVWTr86vD8ThF+pbDbeKQa3/9YtGxVg/hgb6 CtPBuW6XBrT0g2RvqCY8NSwKoto8XFK3yjRMJBXK6vDpIHYlXXbbfjjXXsWJJMgyZpbg /6XqE566YLIzLZu50HHjScG+6S3nzGnJgL6pWYhGjhQPslMG0EkraTr+rdXUpcVyOFZA mT1AWFhTnNtL0OJ7meUXco+omY1i9zKP9MklOigmu2QjhojyT35rHQX9jMxdWOF2FoUM kuFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682087863; x=1684679863; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZmJp66E7f+Y6znObj42iK8swVGPa549Lcio15ZPSnxQ=; b=e6Qnjwd+3ADp6fdo/QfIj20XQVkC8x7pC9xoVEurU+c8lWyI7CE2+c3AYDK08sH2tu acRbhddlrRUutBlnjjvB5LRbp6NDT3Tg4eMvRNn5bRF/Oi3BsLQOK45Ptu/I2c39cwtp pqfkIUIadLRdNGA0IYhPeEYievTettW2LyKepwWsdSLjmDVlD0ZhiFIlYnO87XFr7M7v EzP6LUje2yVXAMU1Agv/Lsl6Ig42f8XZNKf/6TkXqDKM+14pKr+gaRw3iUfKGXeyR673 N38g+Fnxp6AWpkxYUMcamTb8P8wv39Jx/kGafd29Wc3S37wErmcfAfVbAzH29X7ivZAx UDTQ== X-Gm-Message-State: AAQBX9diwP9P8sVkQTogKluex1pyABuMr/y2hQgL/+BZI6R6RbecaDJ5 UwHF1p/HqdmnFLRC6YN9EY4= X-Google-Smtp-Source: AKy350awrJxVPyo3L53jJ5gYw7X144Hv7XTVmv+bBVZdnRD1U32Up7K/6/LnxfMVoGT02rrdv/xbVg== X-Received: by 2002:a17:906:63d1:b0:94f:cee:56f2 with SMTP id u17-20020a17090663d100b0094f0cee56f2mr2546057ejk.4.1682087863051; Fri, 21 Apr 2023 07:37:43 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id q27-20020a170906361b00b0094e1026bc66sm2168244ejb.140.2023.04.21.07.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 07:37:42 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Subject: [RFC PATCH net-next 22/22] net: dsa: mt7530: rename p5_intf_sel and use only for MT7530 switch Date: Fri, 21 Apr 2023 17:36:48 +0300 Message-Id: <20230421143648.87889-23-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230421143648.87889-1-arinc.unal@arinc9.com> References: <20230421143648.87889-1-arinc.unal@arinc9.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_073745_521411_37DE01F5 X-CRM114-Status: GOOD ( 20.44 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Richard van Schagen , linux-kernel@vger.kernel.org, Richard van Schagen , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , linux-mediatek@lists.infradead.org, erkin.bozoglu@xeront.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Arınç ÜNAL The p5_intf_sel pointer is used to store the information of whether PHY muxing is used or not. PHY muxing is a feature specific to port 5 of the MT7530 switch. Do not use it for other switch models. Rename the pointer to p5_mode to store the mode the port is being used in. Rename the p5_interface_select enum to mt7530_p5_mode, the string representation to mt7530_p5_mode_str, and the enum elements. If PHY muxing is not detected, the default mode, GMAC5, will be used. Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 61 ++++++++++++++++------------------------ drivers/net/dsa/mt7530.h | 15 +++++----- 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 3d19e06061cb..63b108ef5e0e 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -873,19 +873,15 @@ mt7530_set_ageing_time(struct dsa_switch *ds, unsigned int msecs) return 0; } -static const char *p5_intf_modes(unsigned int p5_interface) -{ - switch (p5_interface) { - case P5_DISABLED: - return "DISABLED"; - case P5_INTF_SEL_PHY_P0: - return "PHY P0"; - case P5_INTF_SEL_PHY_P4: - return "PHY P4"; - case P5_INTF_SEL_GMAC5: - return "GMAC5"; +static const char *mt7530_p5_mode_str(unsigned int mode) +{ + switch (mode) { + case MUX_PHY_P0: + return "MUX PHY P0"; + case MUX_PHY_P4: + return "MUX PHY P4"; default: - return "unknown"; + return "GMAC5"; } } @@ -902,23 +898,21 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) val |= MHWTRAP_MANUAL | MHWTRAP_P5_MAC_SEL | MHWTRAP_P5_DIS; val &= ~MHWTRAP_P5_RGMII_MODE & ~MHWTRAP_PHY0_SEL; - switch (priv->p5_intf_sel) { - case P5_INTF_SEL_PHY_P0: - /* MT7530_P5_MODE_GPHY_P0: 2nd GMAC -> P5 -> P0 */ + switch (priv->p5_mode) { + case MUX_PHY_P0: + /* MUX_PHY_P0: P0 -> P5 -> SoC MAC */ val |= MHWTRAP_PHY0_SEL; fallthrough; - case P5_INTF_SEL_PHY_P4: - /* MT7530_P5_MODE_GPHY_P4: 2nd GMAC -> P5 -> P4 */ + case MUX_PHY_P4: + /* MUX_PHY_P4: P4 -> P5 -> SoC MAC */ val &= ~MHWTRAP_P5_MAC_SEL & ~MHWTRAP_P5_DIS; /* Setup the MAC by default for the cpu port */ mt7530_write(priv, MT7530_PMCR_P(5), 0x56300); break; - case P5_INTF_SEL_GMAC5: - /* MT7530_P5_MODE_GMAC: P5 -> External phy or 2nd GMAC */ - val &= ~MHWTRAP_P5_DIS; - break; default: + /* GMAC5: P5 -> SoC MAC or external PHY */ + val &= ~MHWTRAP_P5_DIS; break; } @@ -942,8 +936,8 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) mt7530_write(priv, MT7530_MHWTRAP, val); - dev_dbg(ds->dev, "Setup P5, HWTRAP=0x%x, intf_sel=%s, phy-mode=%s\n", - val, p5_intf_modes(priv->p5_intf_sel), phy_modes(interface)); + dev_dbg(ds->dev, "Setup P5, HWTRAP=0x%x, mode=%s, phy-mode=%s\n", val, + mt7530_p5_mode_str(priv->p5_mode), phy_modes(interface)); mutex_unlock(&priv->reg_mutex); } @@ -2261,13 +2255,11 @@ mt7530_setup(struct dsa_switch *ds) if (ret) return ret; - /* Setup port 5 */ - if (!dsa_is_unused_port(ds, 5)) { - priv->p5_intf_sel = P5_INTF_SEL_GMAC5; - } else { + /* Check for PHY muxing on port 5 */ + if (dsa_is_unused_port(ds, 5)) { /* Scan the ethernet nodes. Look for GMAC1, lookup the used PHY. - * Set priv->p5_intf_sel to the appropriate value if PHY muxing - * is detected. + * Set priv->p5_mode to the appropriate value if PHY muxing is + * detected. */ for_each_child_of_node(dn, mac_np) { if (!of_device_is_compatible(mac_np, @@ -2291,17 +2283,17 @@ mt7530_setup(struct dsa_switch *ds) } id = of_mdio_parse_addr(ds->dev, phy_node); if (id == 0) - priv->p5_intf_sel = P5_INTF_SEL_PHY_P0; + priv->p5_mode = MUX_PHY_P0; if (id == 4) - priv->p5_intf_sel = P5_INTF_SEL_PHY_P4; + priv->p5_mode = MUX_PHY_P4; } of_node_put(mac_np); of_node_put(phy_node); break; } - if (priv->p5_intf_sel == P5_INTF_SEL_PHY_P0 || - priv->p5_intf_sel == P5_INTF_SEL_PHY_P4) + if (priv->p5_mode == MUX_PHY_P0 || + priv->p5_mode == MUX_PHY_P4) mt7530_setup_port5(ds, interface); } @@ -2444,9 +2436,6 @@ mt7531_setup(struct dsa_switch *ds) MT7531_EXT_P_MDIO_12); } - if (!dsa_is_unused_port(ds, 5)) - priv->p5_intf_sel = P5_INTF_SEL_GMAC5; - mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK, MT7531_GPIO0_INTERRUPT); diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index ee2b3d2d6258..8187d77603f8 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -673,13 +673,12 @@ struct mt7530_port { struct phylink_pcs *sgmii_pcs; }; -/* Port 5 interface select definitions */ +/* Port 5 mode definitions of the MT7530 switch */ typedef enum { - P5_DISABLED, - P5_INTF_SEL_PHY_P0, - P5_INTF_SEL_PHY_P4, - P5_INTF_SEL_GMAC5, -} p5_interface_select; + GMAC5, + MUX_PHY_P0, + MUX_PHY_P4, +} mt7530_p5_mode; struct mt7530_priv; @@ -746,7 +745,7 @@ struct mt753x_info { * is already configured * @p5_configured: Flag for distinguishing if port 5 of the MT7531 switch * is already configured - * @p5_intf_sel: Holding the current port 5 interface select + * @p5_mode: Holding the current port 5 mode of the MT7530 switch * @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch * has got SGMII * @irq: IRQ number of the switch @@ -768,7 +767,7 @@ struct mt7530_priv { bool mcm; bool p6_configured; bool p5_configured; - p5_interface_select p5_intf_sel; + mt7530_p5_mode p5_mode; bool p5_sgmii; u8 mirror_rx; u8 mirror_tx;