From nobody Sat Feb 7 12:41:05 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 E1A1B21FF3B for ; Fri, 26 Dec 2025 20:17:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766780233; cv=none; b=UtjLt4rGbekz6oMfFLz+PajdTa+MKIhZmIwitNd2Detds2EuokQpKqWHP52XSiMvpmxsbuxydYsijFkcnjiIF5/qtTlvFaT7OBG5HBGFS0X0RRTQ94S8oBWxMy6QBrXHHS0naJXYnRH6p1goY3bIJhAS1/UgJUXFgwaXVOHnFaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766780233; c=relaxed/simple; bh=vp8Yy4uf2L8v2nN/BjXes/BY2UojDEtB2beFPE4/Dq8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cKgyQsUz+z5w/YlVYNfqm778vtdSbr4A/pP8Z+HzGGwmvSG612Oz/xhaneK1lLuw67gB/jblgVQ6AlLlcSn0GqC+knMtdI3fTJj3XSxBtZ3/ZUAA3286c2fh6M1P8aJXJxlZHwDJLv+BwQN6GsPqSgMRSXR0K1Pk/lx0do8qRVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=L9MOoQvQ; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L9MOoQvQ" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-29f1f79d6afso108740445ad.0 for ; Fri, 26 Dec 2025 12:17:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1766780231; x=1767385031; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=zz3ZyeBmKBt2y6OI3g9KdB1vakMP9sSbCkDeJ9UcYu8=; b=L9MOoQvQilogQ4GEGwioNoz7lhN68+jxOlhivstluahXBdb/LLoPM9T81guwn2Dxxt +YRqEfb+k46Zf+eNslYNgMOTv1JJvmO6bLLj8xiDA98mTajMjwvig/QxlXBFr5ebZgaE FRwzccSWkmS5f5wKZbTGo4obheGSGzy5FXDzeNxwwFBWo6/L620Ur0GfZXTTkY8tJZt+ 6cumOwKnc0FYCsaj6RXd3U61blszSb+uUOHavS6EKN6VcSVX5wdlXVd7AlGcMZVciI0h LxdyCr+OnJ3sXw7FYQ998mvrZ69IXFzFEUgWw2JSuuYN0a6LVmNPhiktj9AmTO7iP/+k 4hHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766780231; x=1767385031; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zz3ZyeBmKBt2y6OI3g9KdB1vakMP9sSbCkDeJ9UcYu8=; b=HERduF0/46DB48yw3ObaflIrdQx451xBNQ0qXIH8OVYKgVzQ+ZK7ajNVmwoTDjJCMR 5+oCm9ul8RpNQhPez3a22cuQcmpWaThcUsq0OnVNIUiSxRqGEk5vu28oWBB2r8ydECiy 1d2yMAAjEzXnsRmBXXZClNC550dh0Xwphd5VzME4Pzp9yNLWhsr4auKRVGSabaUkMJ+F D74MwOm4G/BVW5z4dySboFh2V9NAQ4cUkpRlzFdleSPD7rBpauEwHkVEWnb2VEY0ac6B NFg9Y/oENlvDJbz8qdismDeQF2eyYxcEz8ZbPCI1Tiahs0xw1NLQw8HG0cFy9abtQgb9 vPQg== X-Gm-Message-State: AOJu0YxUNaH5Gejj8OlCukAjTSMHVXXoyc1L4ojEIsLUyIbbnytzfoYw OmRk27tHIo3H2VaFggIlPXHOOunN40awvHlM/lptIoToAn8YsIG+dFYwlS/X0gKe3Sq0knGqEsG awQdzzChVwA== X-Google-Smtp-Source: AGHT+IFxfDKXFW0xczZqBz1TfOO0JXiQRbmEXCyKtHbQRkKzMctPSWfj+RUKPqvkQlC1pLlxWLJ3SN0LPX4R X-Received: from dlbpy24.prod.google.com ([2002:a05:7022:e998:b0:120:5c35:c798]) (user=mmaurer job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:2404:b0:11b:923d:773f with SMTP id a92af1059eb24-121721aae47mr17916261c88.5.1766780231141; Fri, 26 Dec 2025 12:17:11 -0800 (PST) Date: Fri, 26 Dec 2025 20:17:07 +0000 In-Reply-To: <20251226-soc-bindings-v4-0-2c2fac08f820@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251226-soc-bindings-v4-0-2c2fac08f820@google.com> X-Developer-Key: i=mmaurer@google.com; a=ed25519; pk=2Ezhl7+fEjTOMVFpplDeak2AdQ8cjJieLRVJdNzrW+E= X-Developer-Signature: v=1; a=ed25519-sha256; t=1766780228; l=7565; i=mmaurer@google.com; s=20250429; h=from:subject:message-id; bh=vp8Yy4uf2L8v2nN/BjXes/BY2UojDEtB2beFPE4/Dq8=; b=ST0hIqnSMdJv0UsgcrYBqIlKA6oWPcxHCROn0eFgpNseRUVsviiUVho7iVN1uLvAQOKsGwNeC TkuorY7m6HeDcbf+u4SHoql17GGCwNZhsgwWyM16kacGzBjNRMlPibd X-Mailer: b4 0.14.2 Message-ID: <20251226-soc-bindings-v4-1-2c2fac08f820@google.com> Subject: [PATCH v4 1/3] rust: Add soc_device support From: Matthew Maurer To: Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Matthew Maurer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Allow SoC drivers in Rust to present metadata about their devices to userspace through /sys/devices/socX and other drivers to identify their properties through `soc_device_match`. Signed-off-by: Matthew Maurer --- MAINTAINERS | 1 + rust/bindings/bindings_helper.h | 1 + rust/kernel/lib.rs | 2 + rust/kernel/soc.rs | 135 ++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 139 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index c5a7cda26c600e49c7ab0d547306d3281333f672..4ff01fb0f1bda27002094113c0b= f9d074d28fdb6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7700,6 +7700,7 @@ F: rust/kernel/devres.rs F: rust/kernel/driver.rs F: rust/kernel/faux.rs F: rust/kernel/platform.rs +F: rust/kernel/soc.rs F: samples/rust/rust_debugfs.rs F: samples/rust/rust_debugfs_scoped.rs F: samples/rust/rust_driver_platform.rs diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helpe= r.h index a067038b4b422b4256f4a2b75fe644d47e6e82c8..9fdf76ca630e00715503e2a3a80= 9bedc895697fd 100644 --- a/rust/bindings/bindings_helper.h +++ b/rust/bindings/bindings_helper.h @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index f812cf12004286962985a068665443dc22c389a2..6d637e2fed1b605e2dfc2e7b224= 7179439a90ba9 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -138,6 +138,8 @@ pub mod seq_file; pub mod sizes; pub mod slice; +#[cfg(CONFIG_SOC_BUS)] +pub mod soc; mod static_assert; #[doc(hidden)] pub mod std_vendor; diff --git a/rust/kernel/soc.rs b/rust/kernel/soc.rs new file mode 100644 index 0000000000000000000000000000000000000000..0d6a36c83cb67ef20dc1e3d3995= 752f36e25ac9f --- /dev/null +++ b/rust/kernel/soc.rs @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0 + +// Copyright (C) 2025 Google LLC. + +//! SoC Driver Abstraction. +//! +//! C header: [`include/linux/sys_soc.h`](srctree/include/linux/sys_soc.h) + +use crate::{ + bindings, + error, + prelude::*, + str::CString, + types::Opaque, // +}; +use core::ptr::NonNull; + +/// Attributes for a SoC device. +/// +/// These are both exported to userspace under /sys/devices/socX and provi= ded to other drivers to +/// match against via `soc_device_match` (not yet available in Rust) to en= able quirks or +/// device-specific support where necessary. +/// +/// All fields are freeform - they have no specific formatting, just defin= ed meanings. +/// For example, the [`machine`](`Attributes::machine`) field could be "DB= 8500" or +/// "Qualcomm Technologies, Inc. SM8560 HDK", but regardless it should ide= ntify a board or product. +pub struct Attributes { + /// Should generally be a board ID or product ID. Examples + /// include DB8500 (ST-Ericsson) or "Qualcomm Technologies, inc. SM856= 0 HDK". + /// + /// If this field is not populated, the SoC infrastructure will try to= populate it from + /// `/model` in the device tree. + pub machine: Option, + /// The broader class this SoC belongs to. Examples include ux500 + /// (for DB8500) or Snapdragon (for SM8650). + /// + /// On chips with ARM firmware supporting SMCCC v1.2+, this may be a J= EDEC JEP106 manufacturer + /// identification. + pub family: Option, + /// The manufacturing revision of the part. Frequently this is MAJOR.M= INOR, but not always. + pub revision: Option, + /// Serial Number - uniquely identifies a specific SoC. If present, sh= ould be unique (buying a + /// replacement part should change it if present). This field cannot b= e matched on and is + /// solely present to export through /sys. + pub serial_number: Option, + /// SoC ID - identifies a specific SoC kind in question, sometimes mor= e specifically than + /// `machine` if the same SoC is used in multiple products. Some devic= es use this to specify a + /// SoC name, e.g. "I.MX??", and others just print an ID number (e.g. = Tegra and Qualcomm). + /// + /// On chips with ARM firmware supporting SMCCC v1.2+, this may be a J= EDEC JEP106 manufacturer + /// identification (the family value) followed by a colon and then a 4= -digit ID value. + pub soc_id: Option, +} + +struct BuiltAttributes { + // While `inner` has pointers to `_backing`, it is to the interior of = the `CStrings`, not + // `backing` itself, so it does not need to be pinned. + _backing: Attributes, + // `Opaque` makes us `!Unpin`, as the registration holds a pointer to = `inner` when used. + inner: Opaque, +} + +fn cstring_to_c(mcs: &Option) -> *const kernel::ffi::c_char { + mcs.as_ref() + .map(|cs| cs.as_char_ptr()) + .unwrap_or(core::ptr::null()) +} + +impl BuiltAttributes { + fn as_mut_ptr(&self) -> *mut bindings::soc_device_attribute { + self.inner.get() + } +} + +impl Attributes { + fn build(self) -> BuiltAttributes { + BuiltAttributes { + inner: Opaque::new(bindings::soc_device_attribute { + machine: cstring_to_c(&self.machine), + family: cstring_to_c(&self.family), + revision: cstring_to_c(&self.revision), + serial_number: cstring_to_c(&self.serial_number), + soc_id: cstring_to_c(&self.soc_id), + data: core::ptr::null(), + custom_attr_group: core::ptr::null(), + }), + _backing: self, + } + } +} + +#[pin_data(PinnedDrop)] +/// Registration handle for your soc_dev. If you let it go out of scope, y= our soc_dev will be +/// unregistered. +pub struct Registration { + #[pin] + attr: BuiltAttributes, + soc_dev: NonNull, +} + +// SAFETY: We provide no operations through `&Registration`. +unsafe impl Sync for Registration {} + +// SAFETY: All pointers are normal allocations, not thread-specific. +unsafe impl Send for Registration {} + +#[pinned_drop] +impl PinnedDrop for Registration { + fn drop(self: Pin<&mut Self>) { + // SAFETY: Device always contains a live pointer to a soc_device t= hat can be unregistered + unsafe { bindings::soc_device_unregister(self.soc_dev.as_ptr()) } + } +} + +impl Registration { + /// Register a new SoC device + pub fn new(attr: Attributes) -> impl PinInit { + try_pin_init!(Self { + attr: attr.build(), + soc_dev: { + // SAFETY: + // * The struct provided through attr is backed by pinned = data next to it, + // so as long as attr lives, the strings pointed to by t= he struct will too. + // * `attr` is pinned, so the pinned data won't move. + // * If it returns a device, and so others may try to read= this data, by + // caller invariant, `attr` won't be released until the = device is. + let raw_soc =3D error::from_err_ptr(unsafe { + bindings::soc_device_register(attr.as_mut_ptr()) + })?; + + NonNull::new(raw_soc).ok_or(EINVAL)? + }, + }? Error) + } +} --=20 2.52.0.351.gbe84eed79e-goog From nobody Sat Feb 7 12:41:05 2026 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (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 7ED1C265632 for ; Fri, 26 Dec 2025 20:17:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766780235; cv=none; b=KVQqwx5vAzQlrMxdwrHkVhmfNUag5pjwmYPLYAhtv4BYPFaRGjyoRkseiXLOiKVILLSshPBqAUOv3ZBITdnwzwpjc+m3cVOikbCUXPeiuzPLf7Li8R2O7VHD3R8B/1ZHwVftnlKsbMyyVdxpv9WHvGRCz+sBKB7JvX9XGNBgeRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766780235; c=relaxed/simple; bh=q9ccVZ75E1t6Iz8oTFKPOXXPyovi4Nj48RYiQMWWzIs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GYl4vKQeHrj42q7hzhveC4V7oL+jxfIh5zWVBd14W7Vh9kHo6ycz6AWxlOgTBpK8qAK3pVzn4Hn1T2PybqRZrV60TzedI2OyrhQd208BxW20YyW/8psZP/MrU8XzILEh/QRuIhP2Gn19/LrP+lFtrCzXXX+7y58hrQQ/lTjHTfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=oAzVmchb; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oAzVmchb" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7b82c2c2ca2so14172660b3a.1 for ; Fri, 26 Dec 2025 12:17:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1766780233; x=1767385033; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=n5BajE6GC4alJzdat38pb+WqbRtu5IzHgH/U6QY15+M=; b=oAzVmchb/eugDTJAIgMlrwhjVMpBBWCrxLs4Sl8oSkIpaRl/5Q0fFia0Q/k0JvlcxM 6TppQU7lkHdwdtfTEeDJEsTIHda9/bzP86fsTP1FaIrhg4mHqjJogY4r8k1dROXOY1vR EFZCZ1eLZm+52tOBxLk4iNMAuZwVYRL4TXStOVy8GvJENo7X78rhLJGQCr4O9/qOzty8 tXRHJDQW7LYx9mmZNINh9z1nT2G8KHTjzSLCAiwFycdTuOTrVDfY8Sn/R5L1FXBrKASR LAV/tgmX9s+ud63gSnqcPK9EkDW2TGj/V+32UdbBIzFx4sGOMfsjcr9S3K64MoWHXNok L7ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766780233; x=1767385033; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=n5BajE6GC4alJzdat38pb+WqbRtu5IzHgH/U6QY15+M=; b=A176dMfWYxgYpwta+yJuenRR54ODeVMtV8ra1qbwx47gANcHrlGliquwxMEoUlJ0Ot DU04rIzzhJCLUlJ1U6WDs0+hUZr3dwIZ+NlskCfes9ex07bnC2k09QFsrCO6ylnS51EG 0dIpa46gqlV0XPqu4YHK8uLzdNjA/D0H8mhGyK8TN9NettCeTvhidw0vKKsHl1KZTycV scg9Zy+DYo2c8gvSj8iSJJeT+32Knd7wH+DJAJvqZHcbuUFXPQ1Ct+SgThRjbE6wh4Is iuH3Dn8JEVej2IWU0qvyVjS7VwJvt1HJ+Su/gfFlPJnLBSOkilovR7IHd6gLaoADcnxF k4Rg== X-Gm-Message-State: AOJu0YxQ3ojdV1N0UF4j+k1gAIlF4QA1DnWlZcywG9iLy9oWh43nbgj9 7PCE+Gjsy81/aami1OIZJe9rdGHm2B7PPckpzSEGMwlZE+HYut+k1axcSheLq2Ha00rQI2jEUV/ Lm7k/Xa83CQ== X-Google-Smtp-Source: AGHT+IER0cckPtj42JVaxluGja7akI8AY3kDpI6WicheC9rZMTka+YXjLsTFwNoebAWThPMSHM7AhBTaGPoQ X-Received: from dlc13.prod.google.com ([2002:a05:7022:38d:b0:11f:457b:a457]) (user=mmaurer job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:b903:b0:119:e569:f268 with SMTP id a92af1059eb24-121722ac40fmr18273733c88.17.1766780232743; Fri, 26 Dec 2025 12:17:12 -0800 (PST) Date: Fri, 26 Dec 2025 20:17:08 +0000 In-Reply-To: <20251226-soc-bindings-v4-0-2c2fac08f820@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251226-soc-bindings-v4-0-2c2fac08f820@google.com> X-Developer-Key: i=mmaurer@google.com; a=ed25519; pk=2Ezhl7+fEjTOMVFpplDeak2AdQ8cjJieLRVJdNzrW+E= X-Developer-Signature: v=1; a=ed25519-sha256; t=1766780228; l=1261; i=mmaurer@google.com; s=20250429; h=from:subject:message-id; bh=Vyc9JG5KXpS/qLvfPeVNJI9OqD8eT7wmuEDYtRN9r14=; b=7Q3suO3QK0WxCf32bMHYCBfxWPMVux9uhXiE/LL6tJS/QCHrGBUnSonnMdrUquuB3Zbb458Ia WyhPexej8DQBsMQhAIkdPzuwFXhAetq1TYgC2A6LAmXccXZ5wh0V0Tq X-Mailer: b4 0.14.2 Message-ID: <20251226-soc-bindings-v4-2-2c2fac08f820@google.com> Subject: [PATCH v4 2/3] docs: ABI: sysfs-devices-soc: Fix swapped sample values From: Matthew Maurer To: Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Matthew Maurer , Lee Jones Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The sample values for `family` and `machine` were swapped relative to what the driver actually does, and doesn't match the field description. Reviewed-by: Lee Jones Signed-off-by: Matthew Maurer --- Documentation/ABI/testing/sysfs-devices-soc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-devices-soc b/Documentation/AB= I/testing/sysfs-devices-soc index 5269808ec35f8e2b18516556f886c77f5fac9401..cb6776a4afe02a76fe27ac6fc23= 6babdc7865287 100644 --- a/Documentation/ABI/testing/sysfs-devices-soc +++ b/Documentation/ABI/testing/sysfs-devices-soc @@ -17,14 +17,14 @@ Date: January 2012 contact: Lee Jones Description: Read-only attribute common to all SoCs. Contains the SoC machine - name (e.g. Ux500). + name (e.g. DB8500). =20 What: /sys/devices/socX/family Date: January 2012 contact: Lee Jones Description: Read-only attribute common to all SoCs. Contains SoC family name - (e.g. DB8500). + (e.g. ux500). =20 On many of ARM based silicon with SMCCC v1.2+ compliant firmware this will contain the JEDEC JEP106 manufacturer=E2=80=99s identification --=20 2.52.0.351.gbe84eed79e-goog From nobody Sat Feb 7 12:41:05 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 28BA2275B18 for ; Fri, 26 Dec 2025 20:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766780236; cv=none; b=dWn/sq/D5/JjO5bIqDJaRKhwk0I5V814GN/AdKoGCwXWckw4cEeLIRQixsr+PYKMEXgQnqd1GBqt1aO3norMpRmaG//LWQC6X0lfpK9TRJ7d8jotZXY2HWSmnrGI0/i0oRPhHE+uKC71M+rAGqIRVVqOiDQjZEg8gvVR1jJHDHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766780236; c=relaxed/simple; bh=duw+JCtdCh0rRhbXurcNe0zOIZAVRIyHLJEjn/39DHQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ICXo2ITsIathCOa3UanUocYe8/mze6nB3/S78JZ7SaweUyESaNAN9CiQ3R2cam4E2Zt5r5Q3jo8OgoebhhR/XZPzrRk18oes+YksxJT8wA626Uki9Szt1P1tdo5gI+mHM7h7KLq6jZzNQmeLQcmvoMRFSGyhhn0jQHDebQZhjiU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=t6iA0jV6; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--mmaurer.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="t6iA0jV6" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-29f26fc6476so124166805ad.1 for ; Fri, 26 Dec 2025 12:17:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1766780234; x=1767385034; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QSJpfbIfAXnd+EuNkoaHygWty3plypdqNIVg+qLRiRc=; b=t6iA0jV6Op+jCvGanVKJPeCq+Hzh4JfTBX+vDKejL1sr/6rZxcWdmc9SnFDmxSmPlX PkNG87+w6jklXgCnMa+dSiRwhFA5Z03S85hAyU7VJiUS+T1wDXLK8PRhHsX+6seuyYbe RxTO3cms8WH8UD6U4cMoHlq1skfGv/uREprBL+ciAGJXhthqjEt4Tf7F66q7z9ivyfcP 9C3y967Op4oRtuJS/hDHfMGQOZ84ut9e0ABR6wF41XxfRfugicQ7swkESfmZI/oJA6Vv 3Q5H+thfiwsUJ/hjofVDfGMPDhG+4rEutLdOJu245VDAHjXLf3cueQlJuKk+TfpbEzoN e0yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766780234; x=1767385034; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QSJpfbIfAXnd+EuNkoaHygWty3plypdqNIVg+qLRiRc=; b=W6NS1V835lV55ZQzrVkWlMLCvTl7pmrLf6L+IqvDloIZ6TE48Ti5alX9if59hbNOmi aiCPMTwiqru7XZmk+xD/A5/4EFWVquZIjyRUsWZSF+XMc34RIDUyFABXdau6Nd1GluAQ TZyO+PCoM4Nr6/Jk2/YrRzEqZ/UsGO5egsulz1BmPG15ulT/6uMvU944wB2jGi7cSw0E 88GBM+qrIS38JQNz94Df9cokJPLt+HUD2/WpF8qUaqESZFO2i7o3eaCitxmTLSrssAww lzLMmlQA0JsDYr4AN0vTKCV0198IZtLvk/jY6RtohPQBtWaM/A6GhK671mwBa2QiBhNZ jdFA== X-Gm-Message-State: AOJu0Yw4vmgsLKBADkk2c+Jw74iTat4uUKo6XTIHWeW1ghm/iTO5Dezd 3ei1LNuIy/zW6xFxA6L/+vHu+Y35LG45RQkaQD8RS4t4E3NINEGcnbwEubLSlIECQCW2iAIsS+V Bjtw1Jnkncg== X-Google-Smtp-Source: AGHT+IG6WVP7Yusc+K6z2Cavb5gcTtQLqohC7qQUfIVAEJG0hg0r2tbZS+6fuyxiCb7el6POmJYz9jja3p6B X-Received: from dybsy4.prod.google.com ([2002:a05:7301:7004:b0:2ab:f916:f31f]) (user=mmaurer job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6290:b0:11a:4016:4491 with SMTP id a92af1059eb24-121722e1205mr30653400c88.24.1766780234244; Fri, 26 Dec 2025 12:17:14 -0800 (PST) Date: Fri, 26 Dec 2025 20:17:09 +0000 In-Reply-To: <20251226-soc-bindings-v4-0-2c2fac08f820@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251226-soc-bindings-v4-0-2c2fac08f820@google.com> X-Developer-Key: i=mmaurer@google.com; a=ed25519; pk=2Ezhl7+fEjTOMVFpplDeak2AdQ8cjJieLRVJdNzrW+E= X-Developer-Signature: v=1; a=ed25519-sha256; t=1766780228; l=4584; i=mmaurer@google.com; s=20250429; h=from:subject:message-id; bh=duw+JCtdCh0rRhbXurcNe0zOIZAVRIyHLJEjn/39DHQ=; b=daHoYFC7mub2v8W0QBBQW4ocK6pW/0v+xG+GzkCJKrSBeYmWGWjPvBWhBDQ9vrxC8h9BxVDXT V6UKAjoO/KvA8QlXzB0p2OVRUQ1yECa6aNQyWHMsxA+z3mBQPOkRWzL X-Mailer: b4 0.14.2 Message-ID: <20251226-soc-bindings-v4-3-2c2fac08f820@google.com> Subject: [PATCH v4 3/3] rust: Add SoC Driver Sample From: Matthew Maurer To: Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Matthew Maurer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Shows registration of a SoC device upon receipt of a probe. Signed-off-by: Matthew Maurer --- MAINTAINERS | 1 + samples/rust/Kconfig | 11 +++++++ samples/rust/Makefile | 1 + samples/rust/rust_soc.rs | 81 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 94 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 4ff01fb0f1bda27002094113c0bf9d074d28fdb6..bb2e710277cc84dd6042d4d4607= 6e665d9f68752 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7705,6 +7705,7 @@ F: samples/rust/rust_debugfs.rs F: samples/rust/rust_debugfs_scoped.rs F: samples/rust/rust_driver_platform.rs F: samples/rust/rust_driver_faux.rs +F: samples/rust/rust_soc.rs =20 DRIVERS FOR OMAP ADAPTIVE VOLTAGE SCALING (AVS) M: Nishanth Menon diff --git a/samples/rust/Kconfig b/samples/rust/Kconfig index 3efa51bfc8efccd91d9ee079ccd078ed1a6e8aa7..c49ab910634596aea4a1a73dac8= 7585e084f420a 100644 --- a/samples/rust/Kconfig +++ b/samples/rust/Kconfig @@ -161,6 +161,17 @@ config SAMPLE_RUST_DRIVER_AUXILIARY =20 If unsure, say N. =20 +config SAMPLE_RUST_SOC + tristate "SoC Driver" + select SOC_BUS + help + This option builds the Rust SoC driver sample. + + To compile this as a module, choose M here: + the module will be called rust_soc. + + If unsure, say N. + config SAMPLE_RUST_HOSTPROGS bool "Host programs" help diff --git a/samples/rust/Makefile b/samples/rust/Makefile index f65885d1d62bf406b0db13121ef3e5b09829cfbc..6c0aaa58ccccfd12ef019f68ca7= 84f6d977bc668 100644 --- a/samples/rust/Makefile +++ b/samples/rust/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_SAMPLE_RUST_DRIVER_USB) +=3D rust_driver_us= b.o obj-$(CONFIG_SAMPLE_RUST_DRIVER_FAUX) +=3D rust_driver_faux.o obj-$(CONFIG_SAMPLE_RUST_DRIVER_AUXILIARY) +=3D rust_driver_auxiliary.o obj-$(CONFIG_SAMPLE_RUST_CONFIGFS) +=3D rust_configfs.o +obj-$(CONFIG_SAMPLE_RUST_SOC) +=3D rust_soc.o =20 rust_print-y :=3D rust_print_main.o rust_print_events.o =20 diff --git a/samples/rust/rust_soc.rs b/samples/rust/rust_soc.rs new file mode 100644 index 0000000000000000000000000000000000000000..403c1137af779d3c660786959d6= f5160f934f4ae --- /dev/null +++ b/samples/rust/rust_soc.rs @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0 + +//! Rust SoC Platform driver sample. + +use kernel::{ + acpi, + device::Core, + of, + platform, + prelude::*, + soc, + str::CString, + sync::aref::ARef, // +}; +use pin_init::pin_init_scope; + +#[pin_data] +struct SampleSocDriver { + pdev: ARef, + #[pin] + _dev_reg: soc::Registration, +} + +kernel::of_device_table!( + OF_TABLE, + MODULE_OF_TABLE, + ::IdInfo, + [(of::DeviceId::new(c"test,rust-device"), ())] +); + +kernel::acpi_device_table!( + ACPI_TABLE, + MODULE_ACPI_TABLE, + ::IdInfo, + [(acpi::DeviceId::new(c"LNUXBEEF"), ())] +); + +impl platform::Driver for SampleSocDriver { + type IdInfo =3D (); + const OF_ID_TABLE: Option> =3D Some(&OF_TABL= E); + const ACPI_ID_TABLE: Option> =3D Some(&ACP= I_TABLE); + + fn probe( + pdev: &platform::Device, + _info: Option<&Self::IdInfo>, + ) -> impl PinInit { + let dev =3D pdev.as_ref(); + + dev_dbg!(dev, "Probe Rust SoC driver sample.\n"); + + let pdev =3D pdev.into(); + pin_init_scope(move || { + let machine =3D CString::try_from(c"My cool ACME15 dev board")= ?; + let family =3D CString::try_from(c"ACME")?; + let revision =3D CString::try_from(c"1.2")?; + let serial_number =3D CString::try_from(c"12345")?; + let soc_id =3D CString::try_from(c"ACME15")?; + + let attr =3D soc::Attributes { + machine: Some(machine), + family: Some(family), + revision: Some(revision), + serial_number: Some(serial_number), + soc_id: Some(soc_id), + }; + + Ok(try_pin_init!(SampleSocDriver { + pdev: pdev, + _dev_reg <- soc::Registration::new(attr), + }? Error)) + }) + } +} + +kernel::module_platform_driver! { + type: SampleSocDriver, + name: "rust_soc", + authors: ["Matthew Maurer"], + description: "Rust SoC Driver", + license: "GPL", +} --=20 2.52.0.351.gbe84eed79e-goog