From nobody Sun Apr 5 21:35:14 2026 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A48A29D28F for ; Tue, 24 Feb 2026 04:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771907539; cv=none; b=tI/jPULjIrF+AwiOZs61gFZnL2plpK5xLIxjMZBK+YCt38DSA78rLdqhNs2gNGE6CzokVXzpNNsCKZCkBaHAK5a7eVLh+9qlUUm+fKr7kCZnruVklpuutzkggxR5QxchqUFmXPKNeshJ2TuumMkjI0T/ianG1VPhV/iMTdIDcWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771907539; c=relaxed/simple; bh=N7MWqqsHu380Gb5Rc2gHv1QWehPH/HCcbhJPVIYlH10=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hIzuEV0/9v0nPobv4b/2VjGjcI8e6aRwBaMtbvqhlOJBXW1xwJfqguH0HGmnUN8FGcuNueqOEFZTBS+lP9klCBq+li32cnhPfGKkaNdmPdJM6yD2rHseN5+h/Ka0/PogwYtuIxUWK5lkkWhNipor5gn3FZ/QVa0gnBuj+URFQiI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Bs/RvXXG; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bs/RvXXG" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-65c0e2cbde1so8722989a12.0 for ; Mon, 23 Feb 2026 20:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771907535; x=1772512335; 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=cuF+2ZeNg9MZpifVmvjXA4TLhrwpvQWcio7F8T9WLuI=; b=Bs/RvXXGz9U82DjHrLFLC15NX/WSXX0MnohT3EfibFpWWrHFP33WcEdZy1q8CAFiX/ RpzMweMIyxHVag81blg0rAWaA9DNsnHqkxBPKI7P/1WblNEtr1nQj/ykF49digucILxD eWKYSjidUO/KLx8FtNGjodipQAWBkLwK4aDjXudCxgmoJ6NAQHzJxXticcOixFtS3g4C D+ZGz5HdCOMI6DOV2XCbHuEA6GhqxCqAfcnC31lWo4clwSxF9vpB1cr5dgSyxJuVe/x6 j9n343T9RI/oMm02UPE/OqzNV6lNtklWQ+xd9+Y2YaRIRYzsG6H6MG9v96nKUV9AtfV/ 0SbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771907535; x=1772512335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cuF+2ZeNg9MZpifVmvjXA4TLhrwpvQWcio7F8T9WLuI=; b=IOoMgmWpu+TdRmWlv5pAy3jNx2sQQnAWiAa/Mvr4bKQWGRfaQTp2+dfObgD+umhi3R 06k5CGBcHCvTzP8luSnrO3oy7ro3K81qKIsiEJIkZNBBfMkUMU0L5wCwxP3gDCfn8qr2 RyEZPzRttNM/IqCBLtbdBz3AyTF8PcS102vpyWGYHV3yUGZBxte+dW35yOOIP98PXlb/ zah1VoMqCQxoFgowhReJXaAGjUxPNCBO61QH5e69Rk+WddgFNMAiHpBbi3imvu23GNmk 78jHZ84P2nIxVz05+XI9CqasVJz99RHvoS2m9zL1uGqKvvqV2sDA5RheJiGQ7AVBSzAb QZdQ== X-Forwarded-Encrypted: i=1; AJvYcCXA/pqnXDnLqx7ElbIC2fz3UkTdE/n6AsBHwUSJ3yrSivjcr1oA5o9NxijtrLVR1p1WGmVF1GLUKTYjjmw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5t15BE4U2ozBrI+H2KhzU4UOCcc9Of2TKASPKTCYk1ahbTUx1 zfwFXZhBkBjHnVw13CBBrHdJKEE6SMiuL+Qrfu3aEbFjyf9qHyVjH5VN X-Gm-Gg: AZuq6aKQHm0TEIJDoFiVdgMdN+NPiLeOfSuir/qwQ74kN7UzS9qEYMjPrqlDRSYHtzS AoUUntsi3mgIsLmarEl33/d7chHynK/sYJ09FBooSEKCoeQCAYKwE3L+Ix6hYAdA7GHGYCawrou QtditWeyjQ+IbTeVmpCDxezsS4Pfw85x/kb+hoQRW/satvSirLlTRehM7Pz73eVEDqoJPFg2VOO U1nNrtTyT2Lb3Uw1zPa23CK+wst2FhHk7hRK+J7msG2/S27One8ym7xYNO1hnm4rF4f5nARibHK MHWO0BnT9Be2DEgHUmup+JERrD5aN6Lj5KkgkyXKJyn030LPaSK2Q0abdv1U+qk0b8fFOImYDLi pF1j87Fc5P3TiN1ak965DV5LmGePr8lDU89cMQryHGNyxV5iaFr6ShkiqD4phiFKeo505L6B5tg AgvHUCMVXkdbV1+zVQooiSEZPnkjSMGnXCEhtwN9afn9s/u5igWbC3rHBDgG1XllKXYeYHpvPqN FLtY7Uk6wZnsGXnFVOJ/HKgYh5I7qt7yJALpoy/HwxZaj0vh/WKual0buyWuoBfIAGh4bmszIqM UVnZlZe1 X-Received: by 2002:a17:907:fdcb:b0:b8f:a03c:ac22 with SMTP id a640c23a62f3a-b9081b77ae4mr722929966b.42.1771907535344; Mon, 23 Feb 2026 20:32:15 -0800 (PST) Received: from cs-874966990260-default.europe-west4-b.c.i2f7e30109524dc12-tp.internal (206.242.32.34.bc.googleusercontent.com. [34.32.242.206]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b9088c8fc30sm371284466b.63.2026.02.23.20.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 20:32:14 -0800 (PST) From: Artem Lytkin To: FUJITA Tomonori , Andrew Lunn , Heiner Kallweit Cc: Trevor Gross , Russell King , Miguel Ojeda , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Lytkin Subject: [PATCH net-next v2 3/3] net: phy: add Rust reference driver for ET1011C Date: Tue, 24 Feb 2026 04:32:11 +0000 Message-ID: <20260224043211.1747-4-iprintercanon@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260224043211.1747-1-iprintercanon@gmail.com> References: <20260223220504.2102-1-iprintercanon@gmail.com> <20260224043211.1747-1-iprintercanon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a Rust implementation of the LSI ET1011C PHY driver, equivalent to the existing C driver in drivers/net/phy/et1011c.c. The driver implements config_aneg and read_status callbacks using the Rust PHY abstraction. The Rust driver uses the new speed() getter to detect speed changes, only reconfiguring the TX FIFO depth and GMII interface when the negotiated speed actually changes. This matches the C driver behavior. The Rust driver can be selected via the ET1011C_RUST_PHY Kconfig option, following the same pattern as AX88796B_RUST_PHY. Signed-off-by: Artem Lytkin --- drivers/net/phy/Kconfig | 9 ++++ drivers/net/phy/Makefile | 6 ++- drivers/net/phy/et1011c_rust.rs | 75 +++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 drivers/net/phy/et1011c_rust.rs diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 7b73332a13d9..5271898a38f7 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -254,6 +254,15 @@ config LSI_ET1011C_PHY help Supports the LSI ET1011C PHY. =20 +config ET1011C_RUST_PHY + bool "Rust reference driver for LSI ET1011C PHY" + depends on RUST_PHYLIB_ABSTRACTIONS && LSI_ET1011C_PHY + help + Uses the Rust reference driver for LSI ET1011C PHY + (et1011c_rust.ko). The features and behavior are + equivalent to the C driver. Selecting this option builds + the Rust version instead of the C version. + config MARVELL_PHY tristate "Marvell Alaska PHYs" help diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 3a34917adea7..491469457a67 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -62,7 +62,11 @@ obj-$(CONFIG_DP83TG720_PHY) +=3D dp83tg720.o obj-$(CONFIG_FIXED_PHY) +=3D fixed_phy.o obj-$(CONFIG_ICPLUS_PHY) +=3D icplus.o obj-$(CONFIG_INTEL_XWAY_PHY) +=3D intel-xway.o -obj-$(CONFIG_LSI_ET1011C_PHY) +=3D et1011c.o +ifdef CONFIG_ET1011C_RUST_PHY + obj-$(CONFIG_LSI_ET1011C_PHY) +=3D et1011c_rust.o +else + obj-$(CONFIG_LSI_ET1011C_PHY) +=3D et1011c.o +endif obj-$(CONFIG_LXT_PHY) +=3D lxt.o obj-$(CONFIG_MARVELL_10G_PHY) +=3D marvell10g.o obj-$(CONFIG_MARVELL_PHY) +=3D marvell.o diff --git a/drivers/net/phy/et1011c_rust.rs b/drivers/net/phy/et1011c_rust= .rs new file mode 100644 index 000000000000..7b8ae3bf492c --- /dev/null +++ b/drivers/net/phy/et1011c_rust.rs @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0+ +// Copyright (C) 2026 Artem Lytkin + +//! Rust LSI ET1011C PHY driver +//! +//! C version of this driver: [`drivers/net/phy/et1011c.c`](./et1011c.c) + +use kernel::{ + net::phy::{self, reg::C22, DeviceId, Driver}, + prelude::*, + uapi, +}; + +kernel::module_phy_driver! { + drivers: [PhyET1011C], + device_table: [ + DeviceId::new_with_driver::() + ], + name: "rust_et1011c_phy", + authors: ["Artem Lytkin "], + description: "Rust LSI ET1011C PHY driver", + license: "GPL", +} + +const ET1011C_STATUS_REG: C22 =3D C22::vendor_specific::<0x1A>(); +const ET1011C_CONFIG_REG: C22 =3D C22::vendor_specific::<0x16>(); + +const ET1011C_SPEED_MASK: u16 =3D 0x0300; +const ET1011C_GIGABIT_SPEED: u16 =3D 0x0200; +const ET1011C_TX_FIFO_MASK: u16 =3D 0x3000; +const ET1011C_TX_FIFO_DEPTH_16: u16 =3D 0x1000; +const ET1011C_GMII_INTERFACE: u16 =3D 0x0002; +const ET1011C_SYS_CLK_EN: u16 =3D 0x0010; + +const BMCR_FULLDPLX: u16 =3D uapi::BMCR_FULLDPLX as u16; +const BMCR_SPEED100: u16 =3D uapi::BMCR_SPEED100 as u16; +const BMCR_SPEED1000: u16 =3D uapi::BMCR_SPEED1000 as u16; +const BMCR_ANENABLE: u16 =3D uapi::BMCR_ANENABLE as u16; +const BMCR_RESET: u16 =3D uapi::BMCR_RESET as u16; + +struct PhyET1011C; + +#[vtable] +impl Driver for PhyET1011C { + const NAME: &'static CStr =3D c"ET1011C"; + const PHY_DEVICE_ID: DeviceId =3D DeviceId::new_with_model_mask(0x0282= f014); + + fn config_aneg(dev: &mut phy::Device) -> Result { + let ctl =3D dev.read(C22::BMCR)?; + let ctl =3D ctl & !(BMCR_FULLDPLX | BMCR_SPEED100 | BMCR_SPEED1000= | BMCR_ANENABLE); + dev.write(C22::BMCR, ctl | BMCR_RESET)?; + dev.genphy_config_aneg() + } + + fn read_status(dev: &mut phy::Device) -> Result { + let old_speed =3D dev.speed(); + dev.genphy_read_status::()?; + + if old_speed !=3D dev.speed() { + let val =3D dev.read(ET1011C_STATUS_REG)?; + if (val & ET1011C_SPEED_MASK) =3D=3D ET1011C_GIGABIT_SPEED { + let cfg =3D dev.read(ET1011C_CONFIG_REG)?; + let cfg =3D cfg & !ET1011C_TX_FIFO_MASK; + dev.write( + ET1011C_CONFIG_REG, + cfg | ET1011C_GMII_INTERFACE + | ET1011C_SYS_CLK_EN + | ET1011C_TX_FIFO_DEPTH_16, + )?; + } + } + + Ok(0) + } +} --=20 2.43.0