From patchwork Mon Nov 27 10:40:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ram=C3=B3n_Nordin_Rodriguez?= X-Patchwork-Id: 13469355 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ferroamp-se.20230601.gappssmtp.com header.i=@ferroamp-se.20230601.gappssmtp.com header.b="R9lHQTMi" Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 004DF10F for ; Mon, 27 Nov 2023 02:41:35 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50baa3e5c00so2301175e87.1 for ; Mon, 27 Nov 2023 02:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ferroamp-se.20230601.gappssmtp.com; s=20230601; t=1701081694; x=1701686494; darn=vger.kernel.org; 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=YKjdRgLrUCqiZ/8TfWkcZK9DEDOrOby/F2DvMdG0zJo=; b=R9lHQTMi4ZgR+K9FugU2LsSbOl/GWgS1qUowGRx2RQkxwidbUCjgxLQbqWH5jhaYPh MDjCZZN7xMoSKTpnBkoDFycsxJQ3w3omnbsBf1PowZ4qRi8rJK4c3CqsU2O58A1/DDLC 3LRovJGZUYcnJCW4vjAd6qOZQIhVkAOCno9v6BSqWfZ9FpHukpJER0DgTiWALbUdWZDU VEnYS9kRsb4VS/+LHsickC9oyzgewv772dqGOzsl0uPZUjHpd01jhCX5Vndex7pz8QT0 KubNSSXWEzHZT4BJdrkdtIE2uXnKmqWc+p16fcg926ilxkCuH2ZeaOVB6HCsQxy7uhUk S5Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701081694; x=1701686494; 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=YKjdRgLrUCqiZ/8TfWkcZK9DEDOrOby/F2DvMdG0zJo=; b=hoGPJSEUriV7B1mPX/Brqeg2XEA+9HB7mGaYoRNOvnKN45LD3aA0PbJuckOkZNDR6o 4YU78te03uZdSlT4fZ2qk86JcNLoFE23n7nUHXbjyqfCJBBl+akf3Ym7wMCQe4xcqY5A WPQYEzcf0+UskC1imom7MPBxsCd7lmVoJjk/Wd2wJh7jn3Gql8nuhlyz8Ll0+50SkIZI FtooJz8Bob7gSM2UQ1gJ+rjLKBBbKJ3JOmb4Obc8xSfGbAg7AnZz4UF3pgnRjkGrz0BB YeXhiuExaEvjiXxSiw2XHfLhbdgzxqV9d/YI5t15y7iMSA9HRL5+3QDod/FB73vGibuE Aipg== X-Gm-Message-State: AOJu0Yz1Yo4Rc3F7X4cQOHabQxJMAytYAVD4dHVnoc0smKwP9T8cG+0l yQziPA8LXc2ieVKt5EarGQBbcQ== X-Google-Smtp-Source: AGHT+IGpNy1Ibi0FzBM2TdCbpskcep8VoY2/zMQZle6Qf1fQQIRpXPQUsG+Ui6vhUO22lNXw/l/Duw== X-Received: by 2002:ac2:4c4b:0:b0:507:a9e1:5a3b with SMTP id o11-20020ac24c4b000000b00507a9e15a3bmr5493090lfk.0.1701081694278; Mon, 27 Nov 2023 02:41:34 -0800 (PST) Received: from localhost.localdomain ([185.117.107.42]) by smtp.gmail.com with ESMTPSA id l6-20020a19c206000000b004fe1f1c0ee4sm1432070lfc.82.2023.11.27.02.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 02:41:33 -0800 (PST) From: =?utf-8?q?Ram=C3=B3n_N=2ERodriguez?= To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ram=C3=B3n_N=2ERodriguez?= Subject: [PATCH 1/3] net: microchip_t1s: refactor reset functionality Date: Mon, 27 Nov 2023 11:40:43 +0100 Message-ID: <20231127104045.96722-2-ramon.nordin.rodriguez@ferroamp.se> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231127104045.96722-1-ramon.nordin.rodriguez@ferroamp.se> References: <20231127104045.96722-1-ramon.nordin.rodriguez@ferroamp.se> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Ramón Nordin Rodriguez This commit moves the reset functionality for lan867x from the revb1 init function to a separate function. The intention with this minor refactor is to prepare for adding support for lan867x rev C1. Signed-off-by: Ramón Nordin Rodriguez Reviewed-by: Andrew Lunn --- drivers/net/phy/microchip_t1s.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/microchip_t1s.c b/drivers/net/phy/microchip_t1s.c index 534ca7d1b061..ace2bf35a18a 100644 --- a/drivers/net/phy/microchip_t1s.c +++ b/drivers/net/phy/microchip_t1s.c @@ -213,7 +213,7 @@ static int lan865x_revb0_config_init(struct phy_device *phydev) return lan865x_setup_cfgparam(phydev); } -static int lan867x_revb1_config_init(struct phy_device *phydev) +static int lan867x_wait_for_reset_complete(struct phy_device *phydev) { int err; @@ -234,6 +234,16 @@ static int lan867x_revb1_config_init(struct phy_device *phydev) return -ENODEV; } } + return 0; +} + +static int lan867x_revb1_config_init(struct phy_device *phydev) +{ + int err; + + err = lan867x_wait_for_reset_complete(phydev); + if (err) + return err; /* Reference to AN1699 * https://ww1.microchip.com/downloads/aemDocuments/documents/AIS/ProductDocuments/SupportingCollateral/AN-LAN8670-1-2-config-60001699.pdf From patchwork Mon Nov 27 10:40:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ram=C3=B3n_Nordin_Rodriguez?= X-Patchwork-Id: 13469356 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ferroamp-se.20230601.gappssmtp.com header.i=@ferroamp-se.20230601.gappssmtp.com header.b="usgzsHoI" Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B9FF13E for ; Mon, 27 Nov 2023 02:41:37 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507962561adso6155586e87.0 for ; Mon, 27 Nov 2023 02:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ferroamp-se.20230601.gappssmtp.com; s=20230601; t=1701081695; x=1701686495; darn=vger.kernel.org; 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=ywOmUh3+E3BrPrVrzGPyOnQBIBtadDkzgT4Gfly9luU=; b=usgzsHoI3U6TkoYITS5G/id7DF71mcUwqy60tdenlD5fijl3cTV1lXtml0CVuhU3Jm 8/kM/uLx/1noQZlE7kspFrsSyi8Tmp7SFAPJq2prstC0x6Lrfm6DjSFkuMobzg9gBQwK LN9J9ycQSbROpAd19NLzOp8YoirK3TGsaHMqPv6uv1Bu8HJGCGB0GUnaXijYLi2XXMup E5yzTHK2mNLnuXhj6r3VLAK7JqdhipYZz7QW1grG6VOEDBdVmvwZgEcGZ3ZzatwFfZAR Tz+uQ2gpdxEWJ/NiF9jX9I4If9xUUAFnBvBr0BzaXFW4FqFSnBTaEeWImc80M8dt11TX j9wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701081695; x=1701686495; 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=ywOmUh3+E3BrPrVrzGPyOnQBIBtadDkzgT4Gfly9luU=; b=Raf1rLZfborNWGLusDB311SwAZ8UT8bDXt33GuwI5C9H7M+D9OMvkdq2gLU+FcLkgW qxBinHK6qAsMPg9EsGSPewDmDJC4HmF+LsaA6jCEptcTWczlk/ii1gLoZZwoWMcufrak k+qs+jpZ7/Ya9i8ydXjUvCtJr+pZ1bWAhj87XPmGpTUQXbvBt/n5X+IIAFfhafJxP7cY M9FTjYDPqzZxNa13NPNYYluNxtxh8vyBAT7HTEYA1Yduv6fWcNvIJr8ZxSGdolQ4RSR+ tkcAaVLrbECc0ZFH3Gu3o8RPqO9nTQICpCwpUKzHzcL/GHXAPTbqcaaRKOXIvw62NIVX spWw== X-Gm-Message-State: AOJu0YwSFY+SMPyYxwTsNbm6CLREbtf2eWGO6SBPjDs1kpzvoX+cdIW8 Rh0Rb8oCYx3tkEHKn5Z4r43rWg== X-Google-Smtp-Source: AGHT+IFnNWMBpcw27UBqGAplcSub4tfqzr/5uFem0JSEXjZ+D63ENv+dHHYwT+N5O3+TSDiDa44iGw== X-Received: by 2002:a05:6512:2101:b0:50b:aa7e:c350 with SMTP id q1-20020a056512210100b0050baa7ec350mr3988251lfr.36.1701081695415; Mon, 27 Nov 2023 02:41:35 -0800 (PST) Received: from localhost.localdomain ([185.117.107.42]) by smtp.gmail.com with ESMTPSA id l6-20020a19c206000000b004fe1f1c0ee4sm1432070lfc.82.2023.11.27.02.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 02:41:34 -0800 (PST) From: =?utf-8?q?Ram=C3=B3n_N=2ERodriguez?= To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ram=C3=B3n_N=2ERodriguez?= Subject: [PATCH 2/3] net: microchip_t1s: add support for LAN867x Rev.C1 Date: Mon, 27 Nov 2023 11:40:44 +0100 Message-ID: <20231127104045.96722-3-ramon.nordin.rodriguez@ferroamp.se> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231127104045.96722-1-ramon.nordin.rodriguez@ferroamp.se> References: <20231127104045.96722-1-ramon.nordin.rodriguez@ferroamp.se> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Ramón Nordin Rodriguez This commit adds support for yet another Microchip T1S lan867x phy revision. The only meaningful difference between Rev.B that already is supported and Rev.C is the init change where other undocumented regs needs writes with unexplained values. The changes introduced here attempts to follow the manufacturer recommendations in AN1699. Signed-off-by: Ramón Nordin Rodriguez --- drivers/net/phy/microchip_t1s.c | 96 +++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/drivers/net/phy/microchip_t1s.c b/drivers/net/phy/microchip_t1s.c index ace2bf35a18a..db84d850b165 100644 --- a/drivers/net/phy/microchip_t1s.c +++ b/drivers/net/phy/microchip_t1s.c @@ -12,6 +12,7 @@ #include #define PHY_ID_LAN867X_REVB1 0x0007C162 +#define PHY_ID_LAN867X_REVC1 0x0007C164 #define PHY_ID_LAN865X_REVB0 0x0007C1B3 #define LAN867X_REG_STS2 0x0019 @@ -59,6 +60,22 @@ static const u16 lan867x_revb1_fixup_masks[12] = { 0x0600, 0x7F00, 0x2000, 0xFFFF, }; +static const u16 lan867x_revc1_fixup_registers[12] = { + 0x00D0, 0x00E0, 0x0084, 0x008A, + 0x00E9, 0x00F5, 0x00F4, 0x00F8, + 0x00F9, 0x0081, 0x0091, 0x0093, +}; + +/* Index 2 & 3 will not be used, these are runtime populated/calculated. + * It makes the code a lot easier to read having this arr the same len + * as the _fixup_registers arr though + */ +static const u16 lan867x_revc1_fixup_values[12] = { + 0x3F31, 0xC000, 0xFFFF, 0xFFFF, + 0x9E50, 0x1CF8, 0xC020, 0x9B00, + 0x4E53, 0x0080, 0x9660, 0x06E9, +}; + /* LAN865x Rev.B0 configuration parameters from AN1760 */ static const u32 lan865x_revb0_fixup_registers[28] = { 0x0091, 0x0081, 0x0043, 0x0044, @@ -263,6 +280,74 @@ static int lan867x_revb1_config_init(struct phy_device *phydev) return 0; } +static int lan867x_revc1_read_fixup_value(struct phy_device *phydev, u16 addr) +{ + int regval; + /* The AN pretty much just states 'trust us' regarding these magic vals */ + const u16 magic_or = 0xE0; + const u16 magic_reg_mask = 0x1F; + const u16 magic_check_mask = 0x10; + + regval = lan865x_revb0_indirect_read(phydev, addr); + if (regval < 0) + return regval; + + regval &= magic_reg_mask; + + return (regval & magic_check_mask) ? regval | magic_or : regval; +} + +static int lan867x_revc1_config_init(struct phy_device *phydev) +{ + int err; + int regval; + u16 override0; + u16 override1; + const u16 override_addr0 = 0x4; + const u16 override_addr1 = 0x8; + const u8 index_to_override0 = 2; + const u8 index_to_override1 = 3; + + err = lan867x_wait_for_reset_complete(phydev); + if (err) + return err; + + /* The application note specifies a super convenient process + * where 2 of the fixup regs needs a write with a value that is + * a modified result of another reg read. + * Enjoy the magic show. + */ + regval = lan867x_revc1_read_fixup_value(phydev, override_addr0); + if (regval < 0) + return regval; + override0 = ((regval + 9) << 10) | ((regval + 14) << 4) | 0x3; + + regval = lan867x_revc1_read_fixup_value(phydev, override_addr1); + if (regval < 0) + return regval; + override1 = (regval + 40) << 10; + + for (int i = 0; i < ARRAY_SIZE(lan867x_revc1_fixup_registers); i++) { + /* The hardcoded */ + if (i == index_to_override0) + err = phy_write_mmd(phydev, MDIO_MMD_VEND2, + lan867x_revc1_fixup_registers[i], + override0); + else if (i == index_to_override1) + err = phy_write_mmd(phydev, MDIO_MMD_VEND2, + lan867x_revc1_fixup_registers[i], + override1); + else + err = phy_write_mmd(phydev, MDIO_MMD_VEND2, + lan867x_revc1_fixup_registers[i], + lan867x_revc1_fixup_values[i]); + if (err) + return err; + } + + return 0; +} + static int lan86xx_read_status(struct phy_device *phydev) { /* The phy has some limitations, namely: @@ -289,6 +374,16 @@ static struct phy_driver microchip_t1s_driver[] = { .set_plca_cfg = genphy_c45_plca_set_cfg, .get_plca_status = genphy_c45_plca_get_status, }, + { + PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVC1), + .name = "LAN867X Rev.C1", + .features = PHY_BASIC_T1S_P2MP_FEATURES, + .config_init = lan867x_revc1_config_init, + .read_status = lan86xx_read_status, + .get_plca_cfg = genphy_c45_plca_get_cfg, + .set_plca_cfg = genphy_c45_plca_set_cfg, + .get_plca_status = genphy_c45_plca_get_status, + }, { PHY_ID_MATCH_EXACT(PHY_ID_LAN865X_REVB0), .name = "LAN865X Rev.B0 Internal Phy", @@ -305,6 +400,7 @@ module_phy_driver(microchip_t1s_driver); static struct mdio_device_id __maybe_unused tbl[] = { { PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVB1) }, + { PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVC1) }, { PHY_ID_MATCH_EXACT(PHY_ID_LAN865X_REVB0) }, { } }; From patchwork Mon Nov 27 10:40:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ram=C3=B3n_Nordin_Rodriguez?= X-Patchwork-Id: 13469357 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ferroamp-se.20230601.gappssmtp.com header.i=@ferroamp-se.20230601.gappssmtp.com header.b="y5FSJzHk" Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D04E1 for ; Mon, 27 Nov 2023 02:41:38 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-50baa1ca01cso2338758e87.2 for ; Mon, 27 Nov 2023 02:41:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ferroamp-se.20230601.gappssmtp.com; s=20230601; t=1701081696; x=1701686496; darn=vger.kernel.org; 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=qVSAHbxZoohnOH7jImii/DY4owc5b3zp1Hwe6YQy5wU=; b=y5FSJzHksCLkhTeR1wb6xnBEsXuTttvnk3Gj3TnEo+Jimgymwoinr8YvYDEixbFHok mtjDX1aum1F5NULvOVTnJvuDlDoXuhWUYvlwjSQeOksHzL+l/fXX0ialZaqgc+RE4XCD OQhvVPacTfKF4sFgpHr6Ct+kvnulc58WqhWhNku13yFNO/ru16wRITEc5RM7QlK7pVJv Dgw7HP7Dhili2GaA4KOeMIBnqb64Nv3unhmG4F7Dy+97R3R05puXxLhculxUiQ2ueZC6 fo1o1p9tMCLIsbMh8czU5sWTpXDNDUeI9dXaG0EG9/a0cr6jiJudG+4qIVBjlB7Qjver 3JvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701081696; x=1701686496; 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=qVSAHbxZoohnOH7jImii/DY4owc5b3zp1Hwe6YQy5wU=; b=V8yLLEaTOlpgopQ2bBdDTkaSOR75mhybwisEAqUt7Q3/3Ktt93w+am+1udaGIe4BTF oekMvqP07r4CMJxR9tO4vOiGFr3HSSHPEWRspgFfeSi9tA2ASigoOMInFHzRD7B+vzyl wlxKYB42YFOo8jxS4RePJNivykAxy6TAnjShmXq9FaqhYIODr6Grg2mZr0mm1D1wSSwM 2aNiEfPMjLWJRiDUHvLszrO0JzKfYHqvopiehzWPTiG1SlNU6eS8sj2Z6VQ5KbtSD4eT xJ6+QJFkrugdslh2ANQnhCGKEgbh1H2R2Q+5Ba8YudyMW1Iym8fn6Lqn3Li1xaIX2VBZ ql5g== X-Gm-Message-State: AOJu0YwzXm0M3qK4QqRq4mZmeClMWZRY5W5wGTTWJ9K/R4gdcRz9o4+D wiA5dVWcOhOZ1vN429yQm9yy+Q== X-Google-Smtp-Source: AGHT+IFX7bNX12KRNlnqIDKFrEARfjiZuo+r+3ozDbjLMUk02p73hgrg4SGWJZUpk3cWJXj78xYChw== X-Received: by 2002:a05:6512:1105:b0:50b:a69d:b8bb with SMTP id l5-20020a056512110500b0050ba69db8bbmr5175114lfg.49.1701081696442; Mon, 27 Nov 2023 02:41:36 -0800 (PST) Received: from localhost.localdomain ([185.117.107.42]) by smtp.gmail.com with ESMTPSA id l6-20020a19c206000000b004fe1f1c0ee4sm1432070lfc.82.2023.11.27.02.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 02:41:35 -0800 (PST) From: =?utf-8?q?Ram=C3=B3n_N=2ERodriguez?= To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ram=C3=B3n_N=2ERodriguez?= Subject: [PATCH 3/3] net: microchip_t1s: conditional collision detection Date: Mon, 27 Nov 2023 11:40:45 +0100 Message-ID: <20231127104045.96722-4-ramon.nordin.rodriguez@ferroamp.se> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231127104045.96722-1-ramon.nordin.rodriguez@ferroamp.se> References: <20231127104045.96722-1-ramon.nordin.rodriguez@ferroamp.se> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Ramón Nordin Rodriguez This commit conditionally sets the collision detection bit on lan867x and lan865x phys on changing PLCA enabled on/off. The intended realworld scenario is that all nodes on the network run the same settings with regards to plca, and when plca is enabled the physical layer guarantees that no collisions should occur. In a practical setting where it was tested running one node with collision detection on and other off, the node with collision detection on dropped a lot of packets, leading to a poor performing link. Worth noting here is that the phys default/reset to plca disabled and collision detection enabled. Thus this change would only have an effect when changing settings via ethtool. Signed-off-by: Ramón Nordin Rodriguez --- drivers/net/phy/microchip_t1s.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/microchip_t1s.c b/drivers/net/phy/microchip_t1s.c index db84d850b165..3b1e82ecdf69 100644 --- a/drivers/net/phy/microchip_t1s.c +++ b/drivers/net/phy/microchip_t1s.c @@ -23,8 +23,10 @@ #define LAN865X_REG_CFGPARAM_DATA 0x00D9 #define LAN865X_REG_CFGPARAM_CTRL 0x00DA #define LAN865X_REG_STS2 0x0019 +#define LAN86XX_REG_COLLISION_DETECT 0x0087 #define LAN865X_CFGPARAM_READ_ENABLE BIT(1) +#define LAN86XX_COLLISION_DETECT_ENABLE BIT(15) /* The arrays below are pulled from the following table from AN1699 * Access MMD Address Value Mask @@ -363,6 +365,27 @@ static int lan86xx_read_status(struct phy_device *phydev) return 0; } +static int lan86xx_plca_set_cfg(struct phy_device *phydev, + const struct phy_plca_cfg *plca_cfg) +{ + int err; + + err = genphy_c45_plca_set_cfg(phydev, plca_cfg); + if (err) + return err; + + /* Disable collision detect on the phy when PLCA is enabled. + * Noise can be picked up as a false positive for collisions + * leading to the phy dropping legitimate packets. + * No collisions should be possible when all nodes are setup + * for running PLCA. + */ + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, + LAN86XX_REG_COLLISION_DETECT, + LAN86XX_COLLISION_DETECT_ENABLE, + plca_cfg->enabled ? 0 : LAN86XX_COLLISION_DETECT_ENABLE); +} + static struct phy_driver microchip_t1s_driver[] = { { PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVB1), @@ -371,7 +394,7 @@ static struct phy_driver microchip_t1s_driver[] = { .config_init = lan867x_revb1_config_init, .read_status = lan86xx_read_status, .get_plca_cfg = genphy_c45_plca_get_cfg, - .set_plca_cfg = genphy_c45_plca_set_cfg, + .set_plca_cfg = lan86xx_plca_set_cfg, .get_plca_status = genphy_c45_plca_get_status, }, { @@ -381,7 +404,7 @@ static struct phy_driver microchip_t1s_driver[] = { .config_init = lan867x_revc1_config_init, .read_status = lan86xx_read_status, .get_plca_cfg = genphy_c45_plca_get_cfg, - .set_plca_cfg = genphy_c45_plca_set_cfg, + .set_plca_cfg = lan86xx_plca_set_cfg, .get_plca_status = genphy_c45_plca_get_status, }, { @@ -391,7 +414,7 @@ static struct phy_driver microchip_t1s_driver[] = { .config_init = lan865x_revb0_config_init, .read_status = lan86xx_read_status, .get_plca_cfg = genphy_c45_plca_get_cfg, - .set_plca_cfg = genphy_c45_plca_set_cfg, + .set_plca_cfg = lan86xx_plca_set_cfg, .get_plca_status = genphy_c45_plca_get_status, }, };