From patchwork Tue Jan 17 20:56:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 44858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2039925wrn; Tue, 17 Jan 2023 15:36:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXjx0xvQmqNLHEH2wjhhLh7q3DCWGB+Jehx+20TFhx9P49Zza4Slrm4gOrp3KVEp1Jo7Vl X-Received: by 2002:a17:907:d401:b0:872:1b27:1a43 with SMTP id vi1-20020a170907d40100b008721b271a43mr4889323ejc.31.1673998561532; Tue, 17 Jan 2023 15:36:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673998561; cv=none; d=google.com; s=arc-20160816; b=CuJYPXgYdHOrnPk16KI0sbIB2UQJGn0aJ53T07M6HIEsi37hHVleCR4klWEXb/Rl3V M/vPjjFBNqrEnW3Hkk/HciLmrbqW9luC/lLu5pbJr8Slrun/fXK/OdoxRWpzt/geeOO0 v1ydbhSN7n6jGqipltgRxZPC7ye3gvVS/28WBD+UcDn/e49Cx3ZtezZrE8sUQsLvvE0/ X/j5MMgHG/2LoTDr2cFkwLp5+nxU645TMJsGF1GjKoF3ZaLyFJilVAOBw3t3n9fOcaCn wnsyrCtz8pmpfgXEHKyZ6szCSx/Br0B8fy6BdGN1GGjMs7J9DIzW7ZoN++9ICr13Ii4h gzEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=Y6+gaEYAQ5NB24/o3HcC/CehF9QwGW6qh+NkIWxpAzo=; b=VESXAt7pvkUriYyaLxCrhMrM/Nwb9Soan/eIYoq/tHdwL60IbLe7Br7C/kOcj18dn0 ncVWkGjDP2Ee7pd4FCLbofSbHRMm+BEpm63pMDkVn5hmsnAO7Wz9fIyUK6nnr60dds0p Pe5br/kL+l7ZQD4/nn3XoHAWkoR0UCxRiEWqRT3w/0D0FQTw4nYLv64nTFlxtGT3DZ14 rBILHioNC9pyiv4x7ToWT6GFp08jRBfwLcUeALq9xhFFnEKKD4TcvkB+h5aaOjvA7Hdx bzHJiEt09Uuezoiyf3GnAFzwDzE4zQqYTwzs5GnCh2rCx0xd26zloMm/94TJUoQk0wjL RDcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=yXCbJKHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt7-20020a170907728700b0083e0ec05041si36539306ejc.541.2023.01.17.15.35.38; Tue, 17 Jan 2023 15:36:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=yXCbJKHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbjAQXcu (ORCPT + 99 others); Tue, 17 Jan 2023 18:32:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjAQXbd (ORCPT ); Tue, 17 Jan 2023 18:31:33 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF04D8C92E; Tue, 17 Jan 2023 12:57:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989036; x=1705525036; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=4MVjklp+WInBd0klfJLhEVo/AmyM+BveJwsJuTHar2g=; b=yXCbJKHNl0Q//BJshBsSc1Ah0dxISwVTKIh2sW94fIwOw5y5KN0QkLTI 3iVdgtd8z3hWrIQqLeHJcIwwiyxX9BKYmtQqlh5v8bXXbInny+dFIXOxD nEI9y9kEdSTbYXFMKsHLMvaCPLUWRdIrmtxJ+CODhgUIUgbnDk4Wwm7Pb tVev4QGvxT3UnnGaTPKVcDT9OJ01YGYv6l/i3/fsQHxoBZG4DWrNGD+bt R6yXNewM7+EDSOhbthR0dTBn2JHAAyIeTJmyvmjdIpKQSfjjmXeVT9QHJ aVmzXX6TDnD9dm4z6rkojihztE4cYP16xl9bekn/djE7uIA2cEQApARTm Q==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="208210722" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:08 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:08 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:06 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 1/7] dsa: lan9303: align dsa_switch_ops members Date: Tue, 17 Jan 2023 14:56:57 -0600 Message-ID: <20230117205703.25960-2-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755314715892418630?= X-GMAIL-MSGID: =?utf-8?q?1755314715892418630?= Whitespace preparatory patch, making the dsa_switch_ops table consistent. No code is added or removed. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 2e270b479143..f8f6f79052e3 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1282,25 +1282,25 @@ static int lan9303_port_mdb_del(struct dsa_switch *ds, int port, } static const struct dsa_switch_ops lan9303_switch_ops = { - .get_tag_protocol = lan9303_get_tag_protocol, - .setup = lan9303_setup, - .get_strings = lan9303_get_strings, - .phy_read = lan9303_phy_read, - .phy_write = lan9303_phy_write, - .adjust_link = lan9303_adjust_link, - .get_ethtool_stats = lan9303_get_ethtool_stats, - .get_sset_count = lan9303_get_sset_count, - .port_enable = lan9303_port_enable, - .port_disable = lan9303_port_disable, - .port_bridge_join = lan9303_port_bridge_join, - .port_bridge_leave = lan9303_port_bridge_leave, - .port_stp_state_set = lan9303_port_stp_state_set, - .port_fast_age = lan9303_port_fast_age, - .port_fdb_add = lan9303_port_fdb_add, - .port_fdb_del = lan9303_port_fdb_del, - .port_fdb_dump = lan9303_port_fdb_dump, - .port_mdb_add = lan9303_port_mdb_add, - .port_mdb_del = lan9303_port_mdb_del, + .get_tag_protocol = lan9303_get_tag_protocol, + .setup = lan9303_setup, + .get_strings = lan9303_get_strings, + .phy_read = lan9303_phy_read, + .phy_write = lan9303_phy_write, + .adjust_link = lan9303_adjust_link, + .get_ethtool_stats = lan9303_get_ethtool_stats, + .get_sset_count = lan9303_get_sset_count, + .port_enable = lan9303_port_enable, + .port_disable = lan9303_port_disable, + .port_bridge_join = lan9303_port_bridge_join, + .port_bridge_leave = lan9303_port_bridge_leave, + .port_stp_state_set = lan9303_port_stp_state_set, + .port_fast_age = lan9303_port_fast_age, + .port_fdb_add = lan9303_port_fdb_add, + .port_fdb_del = lan9303_port_fdb_del, + .port_fdb_dump = lan9303_port_fdb_dump, + .port_mdb_add = lan9303_port_mdb_add, + .port_mdb_del = lan9303_port_mdb_del, }; static int lan9303_register_switch(struct lan9303 *chip) From patchwork Tue Jan 17 20:56:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 44843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2033703wrn; Tue, 17 Jan 2023 15:17:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXssRHvgjGKma8kFbRvCiAgQMmYoM7b2B26h+IDE9jB0dbMstnuOIKBY7u1wJfZrNUuJBIxz X-Received: by 2002:a17:906:68d6:b0:7ff:7876:9c60 with SMTP id y22-20020a17090668d600b007ff78769c60mr4339168ejr.15.1673997473449; Tue, 17 Jan 2023 15:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673997473; cv=none; d=google.com; s=arc-20160816; b=iM9MIARayZGsbXuHd4VG7FrmrEqGhvuYOpF9IxbSq2oUKUaEkz697+XEmBdppXvoVs fAGb8idyvCmfgN0VTU34pKcvBMUUwyiwKVMtsLzNc178H8GdGKAFgW8iZUqbeSaXsW1q 5AIzetyOy0xBqA9DbaW3wr6GZ0NHKYuLj74sRhxMpWIMblAZXv/WpU61aSKaWXKDk5e5 I2CxA+nKZSpcL8gp4Flr7tPHLvq+CWLsR+0a+rgMuDDxRok8gTsZkr+y5QfEL1qJhETr cJJR+Wbz2TTUBZzd7GqW3KIhNtg4F1s2ObwTm8xT6jYuzu0S5Dvra801KGys+wJLw4NL lF8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=ncPSrOVcXE9qToDUaQ1zEZg4YP0CQlQ/6+Pg+seMZDU=; b=dpKOkI4fGROzwaf0B9ve7wEmpMKXR0mKfYAMYkPKjejXNqoOucg8V+HZBoJsqpzMTn /4EeJhqXrYG3TPBjU+QRoXWHhQnXwqJ9LYflfbBaviMorsWemwGoflTgvfZZ8BZlCZf9 ojiVAD1Fy7Zb5nw5UjR4G/liDHjj/xszztCT4CTTXKxkdh9htNnHk2t5tEZ9CX4TtbU5 t9Kov5Zt64dOcgc+bEo5ubwP8OpmZcm9j8EpbFe9nU2/B6bTmh9JBvzS5eGRXkTQwVj4 2B/xyMw8MrAEDTXkHE6k+YtuCeE+qAGkx+IA/saeURKd08zWTKp64BeuM3dobIdzKD0U zzNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ExtUB0+u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg40-20020a170907972800b00872733f3b9esi3575643ejc.855.2023.01.17.15.17.29; Tue, 17 Jan 2023 15:17:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ExtUB0+u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229541AbjAQXPR (ORCPT + 99 others); Tue, 17 Jan 2023 18:15:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjAQXNc (ORCPT ); Tue, 17 Jan 2023 18:13:32 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8FF38CE72; Tue, 17 Jan 2023 12:57:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989040; x=1705525040; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=l//9fOjFa2fPgl+Ydqe3nVGAlwfQjBnfvOtLXzxETz0=; b=ExtUB0+u2vyBYtLzZaRYG+kOq2ANdc1Bxhlwnr025aQioMHQgkMNV7Oo 1w4kyw/Db5q2CzC8Htpecw74vHjofb7NWR4FyNHSSuD4zol3wRw1LqQ3j 214kQ/s+KojdVL0j7zRcC8hZgKuv5K4kg487nJO609PSbAvQWfZ31MmKx 1fuMn3/l8knVDQa+d1t/wll0UyffO/UUk3Td7e/WMX7ViTetfvhw5efGo Hkmwv+AM+1i5MKlyorFay8uTArAiraVljv/cdzP2YU5ctK0IylvBEy88c m2YiNCh67iBltKUYWXz6iyP42ZSL26Vplz8XN7wHLqfgUPlz90xJsMOWf A==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="197058703" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:11 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:10 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:08 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 2/7] dsa: lan9303: move Turbo Mode bit init Date: Tue, 17 Jan 2023 14:56:58 -0600 Message-ID: <20230117205703.25960-3-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755313574584903053?= X-GMAIL-MSGID: =?utf-8?q?1755313574584903053?= In preparing to remove the .adjust_link api, I am moving the one-time initialization of the device's Turbo Mode bit into a different execution path. This code clears (disables) the Turbo Mode bit which is never used by this driver. Turbo Mode is a non-standard mode that would allow the 100Mbps RMII interface to run at 200Mbps. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index f8f6f79052e3..63f5c1ef65e2 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -902,6 +902,7 @@ static int lan9303_setup(struct dsa_switch *ds) { struct lan9303 *chip = ds->priv; int ret; + u32 reg; /* Make sure that port 0 is the cpu port */ if (!dsa_is_cpu_port(ds, 0)) { @@ -909,6 +910,12 @@ static int lan9303_setup(struct dsa_switch *ds) return -EINVAL; } + /* Virtual Phy: Remove Turbo 200Mbit mode */ + lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ®); + + reg &= ~LAN9303_VIRT_SPECIAL_TURBO; + regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg); + ret = lan9303_setup_tagging(chip); if (ret) dev_err(chip->dev, "failed to setup port tagging %d\n", ret); @@ -1052,7 +1059,6 @@ static int lan9303_phy_write(struct dsa_switch *ds, int phy, int regnum, static void lan9303_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phydev) { - struct lan9303 *chip = ds->priv; int ctl; if (!phy_is_pseudo_fixed_link(phydev)) @@ -1075,14 +1081,6 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port, ctl &= ~BMCR_FULLDPLX; lan9303_phy_write(ds, port, MII_BMCR, ctl); - - if (port == chip->phy_addr_base) { - /* Virtual Phy: Remove Turbo 200Mbit mode */ - lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl); - - ctl &= ~LAN9303_VIRT_SPECIAL_TURBO; - regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl); - } } static int lan9303_port_enable(struct dsa_switch *ds, int port, From patchwork Tue Jan 17 20:56:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 44841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2033267wrn; Tue, 17 Jan 2023 15:16:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXsPnIviSzKu6DzPp9f/0Qh3wo4Az0tJMS8m07El+N67vxz1ZrucOquBFPYO7XWSynZGMvYe X-Received: by 2002:a05:6402:360d:b0:46c:2c94:d30b with SMTP id el13-20020a056402360d00b0046c2c94d30bmr5467285edb.33.1673997406606; Tue, 17 Jan 2023 15:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673997406; cv=none; d=google.com; s=arc-20160816; b=s0SbSjmyICwyv5/lha3uXClqg7VHydOK+Ocs987oaAQc987+mPinHzpCMWd2ZuTjI+ 4JobrL8bg2b9MqhoTlKv1ipLSIx8TVJxBPNDXjYUREnbSbZ1A0ihpwaieUvWMX37CeYn Qlkvg67b3APp1OsBRgdMASHAiseLZaa+DcrdaW/Tx4IDCdFQcPxhrqj3G30tMJQUeTTD pk7tRTZVMhljlGEig7/FQR9wHzQMooK2ePktDBEyNvkUy/aK83Cv4ROrcJxuStWiY+c4 Nu0J7xTYARv1IB6VoPKhVvjm7gNEqXdbSKAlAvd3TU9tkx7I5sgpZQxKCKm9nlFjtFhk o7Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=OMfSSIzPMfz2kmVAxU8owoMF1ejMQVLyY9i+I2rBUZ0=; b=aiXM40SUPrKDBlhop7Bui1XP8QDsVjO+DLcRLCMGaknmfsmsTF9B8kCEg/k/He30Y1 gGRn98XKXKxEajmPjzsAQno3lQCtFjNqyDRnT+mMdoOt5X3PfxyZyF0ZExHdWDEgDoF8 69eEkifa7v6+7smQnDxAlhlbLaaDxi+CoHul0nTCytweAqyy5xX6ettX1wpuRT3as1Hv 2noBTRem1b7SUmmJRHSjTC4SXDK7G3JbH7jnjkPKWLpH49kJ2PwcvgE+t0vVt2ynwmVQ mDtuMQvOcfsgDKUYekJBpeKVfsbSLzj7QuZ/KD8y1JA7DBZwCEsDRlEJk4XNK5Z8hdUy 438A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=j3Z9lxUt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id en23-20020a056402529700b0049dcfc7afe2si5056545edb.437.2023.01.17.15.16.21; Tue, 17 Jan 2023 15:16:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=j3Z9lxUt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229516AbjAQXOK (ORCPT + 99 others); Tue, 17 Jan 2023 18:14:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbjAQXNQ (ORCPT ); Tue, 17 Jan 2023 18:13:16 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 681D78CE48; Tue, 17 Jan 2023 12:57:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989037; x=1705525037; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=7EEKO+T/AsKAYllVpBR1IF6jmvpXWkUA9M7SqcfZgMk=; b=j3Z9lxUt3D5xAl2yOg+W+QgzMrNkZQkUXPKpx7ZGvkdIbxsxKx9W2lsz mY30T89yRWtvSC504RE2eORO8KI09le9wTVeQNeeyINWL2URVL1+P134F Fzu2E6dj7YJaoBRp/+9NWXq75zGjWA0KN7BS+E2aj4IDCKjTskFT53O22 W1S2qTGn9pEyp9aYGUN4rDNTgKc0423+PNtYK4v9WQ/Tlu4+ygCejsnvi P8e1nqEHkIo4M7wVEBoAnLi4tDSFOErXUKVz7DL04yL4s/Q2a9ZT/iS96 zZIQggoNjo30QipykZS9tKVd1ipk6ElMY4WDhFcvDr/DM7B7ny99Bcdft A==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="197211172" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:14 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:13 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:11 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 3/7] dsa: lan9303: Add exception logic for read failure Date: Tue, 17 Jan 2023 14:56:59 -0600 Message-ID: <20230117205703.25960-4-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755313504366491370?= X-GMAIL-MSGID: =?utf-8?q?1755313504366491370?= While it is highly unlikely a read will ever fail, This code fragment is now in a function that allows us to return an error code. A read failure here will cause the lan9303_probe to fail. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 63f5c1ef65e2..66466d50d015 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -911,7 +911,9 @@ static int lan9303_setup(struct dsa_switch *ds) } /* Virtual Phy: Remove Turbo 200Mbit mode */ - lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ®); + ret = lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ®); + if (ret) + return (ret); reg &= ~LAN9303_VIRT_SPECIAL_TURBO; regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg); From patchwork Tue Jan 17 20:57:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 44856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2039846wrn; Tue, 17 Jan 2023 15:35:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXuC3hVMw6PK3Fp0Y9B+btxQJ6ix/PmJDDrFysxZ9A3YSGndCzY19sHxmfi2n14ixWTxBBFF X-Received: by 2002:a17:907:9623:b0:869:236c:ac40 with SMTP id gb35-20020a170907962300b00869236cac40mr5823323ejc.31.1673998544329; Tue, 17 Jan 2023 15:35:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673998544; cv=none; d=google.com; s=arc-20160816; b=od+zGxExIxT9hufCXRUtX90xpG7hSwm8aqbLSS0KxFMp5690CLO59n4Q49JRq7wrsu bRPl2y31rbckUs7bYwouGlZDzwx6eJ4VHOYPitimxgSFNcOTUGWAPLOCLi0R2lN5gLmc 1NrC5fZyF7DGn+Vnz+jpUZRtXu16lkmLE+MOc3GXTnYORJLshG9LX07hB6BUmA4ZnvVl Zonvb6SR1onnH/1dysZ2SdKmGkm9691SdrZBEbbfTN/4aPkoAHWmipD9EroqNvX7/LJk 1Cmm8cWmyhX3361tPeDdmCJiiujPES5fqItyjD6QZgNoTdgAUKXzVWYeuheQIMFPNetE 5W7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=ZbZFfnVZoDArTdNBMfEHNKiUXb8slOc5q1XCsYzXwU4=; b=zIybldnszBAtFQhRab22EPLKcuOSSMn/SbZPpCk4hXuPF1DtJnKKI6t04bEIUv3Iz6 PRFqoohJkatFhYX1kEveWxEYkJUp67dqF1GIq1ZkEgmnvPCyHiAFI93/7EExBRk9h9uM wEDu9fLP/2Fwuv7r71uyyE89pAK3BSdYNsx1GMgCHI9LjZ7pt5yEKb6X4B7LxJXgyNzN YfANNY2SbB47sJCzlhMof7G302E872wZTpXA77ZJHhG/1c7LXA1AhnKtmqD/9gVAnsk1 z4iJ9JeVmqxwDdUeMq9QON5B5cSYtslYYUBNZMVcZII5FFOg2zizjrrlm2V3M3ys+mi8 TVAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="u/cPn3TB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd21-20020a170907629500b0084d0ebd704bsi36893078ejc.71.2023.01.17.15.35.20; Tue, 17 Jan 2023 15:35:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="u/cPn3TB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230100AbjAQXcX (ORCPT + 99 others); Tue, 17 Jan 2023 18:32:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230039AbjAQXbf (ORCPT ); Tue, 17 Jan 2023 18:31:35 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E94FF8CE79; Tue, 17 Jan 2023 12:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989040; x=1705525040; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=zwa4GW5jWlP5YXzoa6EZS1ONEyHsZM9zF0qwfkL82oY=; b=u/cPn3TBeaR7EUtcKm9aOx3pra/8vg/XJL8x7k6vollR0PPHlZabuPmD VUDMITc39AlgMjmA6KUcI3SPEuHrQeIKdmAtCwtC4JkAXAr7bdk+1YzHi wLm2+RExXuGDcIls924eXxfHlg/oVwaIEDdF/2Y6SpD4yHkAcowdxEIuq Vsk6B1AdrHaDAd3GqYeJx1rKTeZVjHkvI3bb5OVZUgEQKnZT3n2hKEBAO EESgYc+pnOdQTWKYstzYSZhB5y2guR8D9UTXP/nAvWEq0e5SkkxgXvVbQ 5bIFgbRFSkTL0HV69rlSgmn7cCGb5NyMwwCsYTYTKeuaJxFr4QzOlELzR w==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="132797655" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:15 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:15 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:13 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 4/7] dsa: lan9303: write reg only if necessary Date: Tue, 17 Jan 2023 14:57:00 -0600 Message-ID: <20230117205703.25960-5-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755314697353742503?= X-GMAIL-MSGID: =?utf-8?q?1755314697353742503?= As the regmap_write() is over a slow bus that will sleep, we can speed up the boot-up time a bit by not bothering to clear a bit that is already clear. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 66466d50d015..a4decf42a002 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -915,8 +915,11 @@ static int lan9303_setup(struct dsa_switch *ds) if (ret) return (ret); - reg &= ~LAN9303_VIRT_SPECIAL_TURBO; - regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg); + /* Clear the TURBO Mode bit if it was set. */ + if (reg & LAN9303_VIRT_SPECIAL_TURBO) { + reg &= ~LAN9303_VIRT_SPECIAL_TURBO; + regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg); + } ret = lan9303_setup_tagging(chip); if (ret) From patchwork Tue Jan 17 20:57:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 44840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2033194wrn; Tue, 17 Jan 2023 15:16:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJ54pqE2DXqcrkDcHsV84LBut8w2G42SMjiz+wxir9GzBR6vp+RQXoenxsTewdy4agdJEA X-Received: by 2002:a17:902:c408:b0:194:6afa:ca with SMTP id k8-20020a170902c40800b001946afa00camr7495183plk.56.1673997396873; Tue, 17 Jan 2023 15:16:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673997396; cv=none; d=google.com; s=arc-20160816; b=U9r8ZI38vGnfBYhwovgDlkCuJL3kCztUZ+S4mQoRaXU/rmbcKe2MV6D6iJTMfg3emc MG7RR21rE5UkSrlQULsgkcYYisO426YDBz32pntJ5r7H0/uF51qYLxtiTXvq9br7Be0n GcWVm/2PO6DwXbC6j4KGWIpwqz0xq/q2dKmNgB78ZbozPFZWVw5VzY8xLqLU6oHme73Y gilZHquULabOq7VRPDu2/HlVbisVzdSGTNxuKISZatSHtxWxOLkKTL2IXNMw9W56PZTx L939UXemI82woSGUpGYL4cKoIWM9RFvAcp3rarf1pQM6wDcgmtn4qSQMHG3BHTF/ZF5i bnbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=sRuIQdCEBuhnYh7JthiW1xhxRbkLtnN3mblgl85ran8=; b=SYKMhccnXQg9n3H8UkxczXqUftoTyxH1bkNxr+6CqP7BNS5Qa+hQEfX7VlzAQdmP5L yRZOPOiaM8rk2Y46rBq8Y7ZOItQ8ayy/HeNIhE6OSnuvopayToQ6Pz0JLW+S05LwQM6B wjPBxXQr1v6CLfeS563xy+uZtng5gsGeunmNHK484eEczuXMCHQq3IODi/D10JTyctEB KSx9CYwU9EAgQwyLmYWZkLZDRkJvST8oGKPKyw2l71PvhOvGuPCQmsJ9uPBJrlZB6jMV iKLkbtpiqaoRcpZfc1khJ+hvGygviYhlKdABuaOaDdzWB2udiEHtjFQL/CwAr8ZUmFLN s5Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ZeHAp0yG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a17090332c400b00179f8a3f838si11359583plr.593.2023.01.17.15.16.24; Tue, 17 Jan 2023 15:16:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ZeHAp0yG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbjAQXOW (ORCPT + 99 others); Tue, 17 Jan 2023 18:14:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbjAQXNQ (ORCPT ); Tue, 17 Jan 2023 18:13:16 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9FD58C929; Tue, 17 Jan 2023 12:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989041; x=1705525041; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=1dySa7UmdtWanwrXlbKGP1PlLBaLqOsIW6dN4IkvW+c=; b=ZeHAp0yG1xcZoVuel4+QlpbmX3Ke80Y53snRSSKx0XWCHhRslUIyHjg1 pGvQl4jSdBEGsk1m/i9//agYLLCmImQxuD3h+iKQKcfLFLao18vTjez+e W8Sx6GvtINHMMp/sAgdExVI+PLoSb+JaBMoauvAcYhH93hwkpqJPcHIKf VvnaEQ8BpTzhqNqIJXBzolm7oYoBCgniZ6bGQBZ7KKiEDzr1eguCwacOx XJGBkByS68yDKRgcujB8TLOi9/Oi2Nonrz5UpBOgJLfNpqEEElNLr0a4F wC/+/RPxWdBgjtMqmi52ef07wMn1LNuCqn4Em4eMtHrZMR7K6iT7nNbjx w==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="132797669" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:18 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:17 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:15 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 5/7] dsa: lan9303: Port 0 is xMII port Date: Tue, 17 Jan 2023 14:57:01 -0600 Message-ID: <20230117205703.25960-6-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755313494457427743?= X-GMAIL-MSGID: =?utf-8?q?1755313494457427743?= In preparing to move the adjust_link logic into the phylink_mac_link_up api, change the macro used to check for the cpu port. In phylink_mac_link_up, the phydev pointer passed in for the CPU port is NULL, so we can't keep using phy_is_pseudo_fixed_link(phydev). Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index a4decf42a002..a4cc76423d4b 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -15,6 +15,9 @@ #include "lan9303.h" +/* For the LAN9303 and LAN9354, only port 0 is an XMII port. */ +#define IS_PORT_XMII(port) ((port) == 0) + #define LAN9303_NUM_PORTS 3 /* 13.2 System Control and Status Registers @@ -1066,7 +1069,11 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port, { int ctl; - if (!phy_is_pseudo_fixed_link(phydev)) + /* On this device, we are only interested in doing something here if + * this is an xMII port. All other ports are 10/100 phys using MDIO + * to control there link settings. + */ + if (!IS_PORT_XMII(port)) return; ctl = lan9303_phy_read(ds, port, MII_BMCR); From patchwork Tue Jan 17 20:57:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 44857 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2039904wrn; Tue, 17 Jan 2023 15:35:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXtcPrexwI6eJY5CCAGa1pBaI8f1hw9OxW3wkP6OHdOFmWTARuoYlW/GAS9ibR2srSg+OQAp X-Received: by 2002:a05:6402:28c6:b0:498:f2d:f52e with SMTP id ef6-20020a05640228c600b004980f2df52emr5072460edb.21.1673998556132; Tue, 17 Jan 2023 15:35:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673998556; cv=none; d=google.com; s=arc-20160816; b=C1z2NI6OJIP8uRumesSd8AtTCIkNuFt7gyBDqshuMHbZgfgDXSzn2pX33Gd/yVZPJX S2CYsbGB3XeDUOqLs8IYbHyZOmfrYCqRRlpc3XcKgcyQd6si9XkG43N+7xzqQ9X95HgT MqwuVvk3ZaqBl0iPSLD1k1o+h7iW0ewrnSu8K+Ju3WSf3xvwjmYS8b91q1zt0tp/QN4I UcJt8AX4aD5FPpLutuQxThfqYcLKZ1PzRX/y748UVKFFuZ7bvqpW3Q910zo8ZnfjH25b xXO6Fm/BNbP1WCTG1qiYZ+epPr6dQdpraROR+FT7vYMHmlMiv4x73poEfB15T4u7PTzA CUwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=bzdtr9Sk3NLQxeMZvt01GCrXky8uKhj1P8mUBQ2MmxY=; b=W547sbDTemuwFoCqhv7kuCn2eUMznajNDezteBl4Df0cjuIK89UfbNRurx/VgXb7x8 Ywqeu39TOJOArW4nnKcLpjc3aZHsumnGjiFsB0XjI3Qh4YyJJ0UvxvPtCiW4pvRU31H/ 4cZQdi9bKBgA6u9S+BRKclisPVFpp05kVqC11RVO8Es+TPcx2bHfni3EGojU3bnQfQiK c5wP06f3/8ga9hCAZ56wUY9idGEBd5ZRHRZxepbQdNoYRdcq9BLQ2h8VPGueXYrM86sB JqIL1+1Ijf6BcNDNowKa2D7slB7a45JT42pBaWqWUXfsRarFhhNCsjxWLsQk6H0gvi9I MkWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=1UdTBsHm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020aa7c68f000000b0048e8c54f6e9si31375614edq.384.2023.01.17.15.35.32; Tue, 17 Jan 2023 15:35:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=1UdTBsHm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbjAQXcn (ORCPT + 99 others); Tue, 17 Jan 2023 18:32:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbjAQXbg (ORCPT ); Tue, 17 Jan 2023 18:31:36 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7718CE7F; Tue, 17 Jan 2023 12:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989041; x=1705525041; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=IW/243XeP8m7HEGadBjno8Oc4TYmpSpNcrwQQRkLL+o=; b=1UdTBsHmE6YxLjEAbwqIKbGT73DHeS1d8HRF1RQcpxK/bbXmOXe+zT9e xsEN9GhRFj2FzhdjPU3YSBGIZE/kYPX0+Hx/VSAdyPs0pXSFCjt5HUA5F uZNgaQUEit4gvAVSTH6BC+nGwZpqOFVYfLnXbiKvgNbK9dLwKHjcGlOQw 0+5Uqju+I8FbQlorSDUHFBDLHT57PRaBDiBwfiVOAz8AdRmiC1GsrSaY4 jQE+yUzJ/hVNKYC/M+b94YJwLwJ9aJonyntxW8OPGcuUN4xvEZ57Wha6s lX5gcQXXT+nTED4pixa1VXBCdfZNkKTN+GaWFXbc+ddD3pLslMXWle4WG w==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="196226785" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:21 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:19 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:17 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 6/7] dsa: lan9303: Migrate to PHYLINK Date: Tue, 17 Jan 2023 14:57:02 -0600 Message-ID: <20230117205703.25960-7-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755314709538306854?= X-GMAIL-MSGID: =?utf-8?q?1755314709538306854?= This patch replaces the adjust_link api with the phylink apis that provide equivalent functionality. The remaining functionality from the adjust_link is now covered in the phylink_mac_link_up api. Removes: .adjust_link Adds: .phylink_get_caps .phylink_mac_link_up Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 101 ++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 32 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index a4cc76423d4b..93ece212cac8 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1064,37 +1064,6 @@ static int lan9303_phy_write(struct dsa_switch *ds, int phy, int regnum, return chip->ops->phy_write(chip, phy, regnum, val); } -static void lan9303_adjust_link(struct dsa_switch *ds, int port, - struct phy_device *phydev) -{ - int ctl; - - /* On this device, we are only interested in doing something here if - * this is an xMII port. All other ports are 10/100 phys using MDIO - * to control there link settings. - */ - if (!IS_PORT_XMII(port)) - return; - - ctl = lan9303_phy_read(ds, port, MII_BMCR); - - ctl &= ~BMCR_ANENABLE; - - if (phydev->speed == SPEED_100) - ctl |= BMCR_SPEED100; - else if (phydev->speed == SPEED_10) - ctl &= ~BMCR_SPEED100; - else - dev_err(ds->dev, "unsupported speed: %d\n", phydev->speed); - - if (phydev->duplex == DUPLEX_FULL) - ctl |= BMCR_FULLDPLX; - else - ctl &= ~BMCR_FULLDPLX; - - lan9303_phy_write(ds, port, MII_BMCR, ctl); -} - static int lan9303_port_enable(struct dsa_switch *ds, int port, struct phy_device *phy) { @@ -1291,13 +1260,81 @@ static int lan9303_port_mdb_del(struct dsa_switch *ds, int port, return 0; } +static void lan9303_phylink_get_caps(struct dsa_switch *ds, int port, + struct phylink_config *config) +{ + struct lan9303 *chip = ds->priv; + + dev_dbg(chip->dev, "%s(%d) entered.", __func__, port); + + config->mac_capabilities = MAC_10 | MAC_100 | MAC_ASYM_PAUSE | + MAC_SYM_PAUSE; + + if (port == 0) { + __set_bit(PHY_INTERFACE_MODE_RMII, + config->supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_MII, + config->supported_interfaces); + } else { + __set_bit(PHY_INTERFACE_MODE_INTERNAL, + config->supported_interfaces); + /* Compatibility for phylib's default interface type when the + * phy-mode property is absent + */ + __set_bit(PHY_INTERFACE_MODE_GMII, + config->supported_interfaces); + } + + /* This driver does not make use of the speed, duplex, pause or the + * advertisement in its mac_config, so it is safe to mark this driver + * as non-legacy. + */ + config->legacy_pre_march2020 = false; +} + +static void lan9303_phylink_mac_link_up(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface, + struct phy_device *phydev, int speed, + int duplex, bool tx_pause, + bool rx_pause) +{ + u32 ctl; + + /* On this device, we are only interested in doing something here if + * this is the xMII port. All other ports are 10/100 phys using MDIO + * to control there link settings. + */ + if (!IS_PORT_XMII(port)) + return; + + ctl = lan9303_phy_read(ds, port, MII_BMCR); + + ctl &= ~BMCR_ANENABLE; + + if (speed == SPEED_100) + ctl |= BMCR_SPEED100; + else if (speed == SPEED_10) + ctl &= ~BMCR_SPEED100; + else + dev_err(ds->dev, "unsupported speed: %d\n", speed); + + if (duplex == DUPLEX_FULL) + ctl |= BMCR_FULLDPLX; + else + ctl &= ~BMCR_FULLDPLX; + + lan9303_phy_write(ds, port, MII_BMCR, ctl); +} + static const struct dsa_switch_ops lan9303_switch_ops = { .get_tag_protocol = lan9303_get_tag_protocol, .setup = lan9303_setup, .get_strings = lan9303_get_strings, .phy_read = lan9303_phy_read, .phy_write = lan9303_phy_write, - .adjust_link = lan9303_adjust_link, + .phylink_get_caps = lan9303_phylink_get_caps, + .phylink_mac_link_up = lan9303_phylink_mac_link_up, .get_ethtool_stats = lan9303_get_ethtool_stats, .get_sset_count = lan9303_get_sset_count, .port_enable = lan9303_port_enable, From patchwork Tue Jan 17 20:57:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 44842 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2033669wrn; Tue, 17 Jan 2023 15:17:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXu61k4j5JCiQv7Ce5FjPj+OHLG0DE4KqOIXZS4CVQWYNpoYXg7jmtBQHGew9S6BHEcajfEe X-Received: by 2002:a17:90a:4302:b0:219:9da5:40d3 with SMTP id q2-20020a17090a430200b002199da540d3mr5091184pjg.1.1673997466597; Tue, 17 Jan 2023 15:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673997466; cv=none; d=google.com; s=arc-20160816; b=hD6CoczDqVfCZenLeECRTzgmik2bJuXXvpJpC/Bf/8nLyxHRxlaQwwIaSg7S7/9f6j 9OpuEdvnPXo535g/jwfGb8WTdZpmiwTQ8BlzwGcN8rUaAl3/btZWYaLt/C0oFw3WcEvD 4NrP2BgjXCcSP83BVkJwpGD9hm91CUAQCZ1ru0G2bMTx6KoMZfxY9IyOVY4xxF7rs8Bx rkf8sgppBQel7SRYf5RqNhPBofLrx0ubUjuJX0P3X3jFtPJr4q2ZQrWrMYLmptVt8Sn2 FbU0qzkR7YKLIwfFq78ER9gtroObJ1O7m7TzjHVaOTSwgTloB6lopc4ZCgqfbUY578Bi FQUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=4jci+LjMKCoGt4DrZ5Zi4iCTJ/6SU0OkOb+igoBU4z8=; b=QwNRJv3WOlh0Av71cHt7F9unEYZFx99EL2w3WfhtX00W3PDiqLjA1vcQFlsLWJ2tMZ q2zG91IKbuCM2sITMwKNHSm8Ey11RFV0Y/EbFpDeAqKLq4zbNufNi4H5Iti7xnh1HYKR ZDpu3e8cOWi7Uhf9y0+j51WuaWbX4pNvtIFXE7RDein/ENxxRt1P60KuxkhbBbO0DDQG KdWRePEU/MsG8jfTNM0mA6PxgkUgXWXXAjE1iJwnbYAzWtwdukL6EVbs8k9qDiV97/hp vtZlBq1XouRJRzXK23G06GPPZLnAiwed2pmvRGK3e1v93jhRUnSUINJLGqITbNCJcGHD BHkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="v/LjfrMx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a17090a4c8500b00229454a4a5fsi175178pjh.143.2023.01.17.15.17.33; Tue, 17 Jan 2023 15:17:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="v/LjfrMx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229588AbjAQXPZ (ORCPT + 99 others); Tue, 17 Jan 2023 18:15:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbjAQXNc (ORCPT ); Tue, 17 Jan 2023 18:13:32 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBD239AA8B; Tue, 17 Jan 2023 12:57:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673989044; x=1705525044; h=from:to:subject:date:message-id:in-reply-to:references: mime-version; bh=C5fCOlZ75pNlYBnCtI5JbqlChvo+KMflLyhKJDLKe4o=; b=v/LjfrMxThpW+NkUmEcSMLl1bpKgxyFav9UPZ2xWIaDTAlY0DFTlaKhd EfTi5eMqhNjCDfOj+QOTaLx5debiYqVs7MLKXZ5sin+df6hl+mgcIvqxH R7oP5wQzJ6EoZFWKh8YYdRZI7j3xwX1iP7iaqLQybrLZ4kwKeDftTBPxG KU4/8BkWoQ1SrUhCENFGoCMNIiEgO4ydgeX62Ytgi0OIfGVJ/fKVzXrtI 7e+8oMbIpc/F51JXKOzuHZ6mIk4Ka/UfeyiphCrPlueYLJBND+kJrJOuv qKdHJ+Kh1/0dsXIhS/oWxLrqgXN16CsVgAEIf0kiIarXrgIjMFT2yVYsB g==; X-IronPort-AV: E=Sophos;i="5.97,224,1669100400"; d="scan'208";a="196226791" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Jan 2023 13:57:23 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 13:57:21 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 13:57:19 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Russell King , , , , Jerry Ray Subject: [net-next: PATCH v7 7/7] dsa: lan9303: Add flow ctrl in link_up Date: Tue, 17 Jan 2023 14:57:03 -0600 Message-ID: <20230117205703.25960-8-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230117205703.25960-1-jerry.ray@microchip.com> References: <20230117205703.25960-1-jerry.ray@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755313567385553174?= X-GMAIL-MSGID: =?utf-8?q?1755313567385553174?= While the prior patch moved the adjust_link code into the phylink_mac_link_up api, this patch cleans it up and adds the setting the port's flow control based on the phylink_mac_link_up input parameters. Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 93ece212cac8..fe8bf0faf6b7 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -53,6 +53,9 @@ #define LAN9303_MANUAL_FC_1 0x68 #define LAN9303_MANUAL_FC_2 0x69 #define LAN9303_MANUAL_FC_0 0x6a +# define LAN9303_BP_EN BIT(6) +# define LAN9303_RX_FC_EN BIT(2) +# define LAN9303_TX_FC_EN BIT(1) #define LAN9303_SWITCH_CSR_DATA 0x6b #define LAN9303_SWITCH_CSR_CMD 0x6c #define LAN9303_SWITCH_CSR_CMD_BUSY BIT(31) @@ -228,6 +231,13 @@ const struct regmap_access_table lan9303_register_set = { }; EXPORT_SYMBOL(lan9303_register_set); +/* Flow Control registers indexed by port number */ +static unsigned int flow_ctl_reg[] = { + LAN9303_MANUAL_FC_0, + LAN9303_MANUAL_FC_1, + LAN9303_MANUAL_FC_2 +}; + static int lan9303_read(struct regmap *regmap, unsigned int offset, u32 *reg) { int ret, i; @@ -1299,7 +1309,9 @@ static void lan9303_phylink_mac_link_up(struct dsa_switch *ds, int port, int duplex, bool tx_pause, bool rx_pause) { + struct lan9303 *chip = ds->priv; u32 ctl; + u32 reg; /* On this device, we are only interested in doing something here if * this is the xMII port. All other ports are 10/100 phys using MDIO @@ -1308,23 +1320,23 @@ static void lan9303_phylink_mac_link_up(struct dsa_switch *ds, int port, if (!IS_PORT_XMII(port)) return; + /* Disable auto-negotiation and force the speed/duplex settings. */ ctl = lan9303_phy_read(ds, port, MII_BMCR); - - ctl &= ~BMCR_ANENABLE; - + ctl &= ~(BMCR_ANENABLE | BMCR_SPEED100 | BMCR_FULLDPLX); if (speed == SPEED_100) ctl |= BMCR_SPEED100; - else if (speed == SPEED_10) - ctl &= ~BMCR_SPEED100; - else - dev_err(ds->dev, "unsupported speed: %d\n", speed); - if (duplex == DUPLEX_FULL) ctl |= BMCR_FULLDPLX; - else - ctl &= ~BMCR_FULLDPLX; - lan9303_phy_write(ds, port, MII_BMCR, ctl); + + /* Force the flow control settings. */ + lan9303_read(chip->regmap, flow_ctl_reg[port], ®); + reg &= ~(LAN9303_BP_EN | LAN9303_RX_FC_EN | LAN9303_TX_FC_EN); + if (rx_pause) + reg |= (LAN9303_RX_FC_EN | LAN9303_BP_EN); + if (tx_pause) + reg |= LAN9303_TX_FC_EN; + regmap_write(chip->regmap, flow_ctl_reg[port], reg); } static const struct dsa_switch_ops lan9303_switch_ops = {