From nobody Thu Dec 18 08:29:12 2025 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 264A8324B1E for ; Tue, 16 Dec 2025 19:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765913078; cv=none; b=tNznedUka7fxuEwMFbL2OZeYzWeTuYtOrnbN4Rx6z8PrU8Qs+v1VjY3ZPmyyk3+MajrDyvCeAzVWFnJN/ttA8BPkmUkl7gsKMjPeKQ8kocGQQISsD9l7QNQntr2LT9pd8wwW/cUK/rBJ41nTjmlMi/i64tWzVwqty9zwN+boksU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765913078; c=relaxed/simple; bh=God7snImE/2RjSSFJGBdoE/GLr+qwzbcgfa5v+DUTBM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lK9R/aa13tDB0C4sk81dNxvt4MtM1AWSlyfe2o/ZJTzSBM9ou4lK0h9VVWuZP4e3PaBWdNi0tkifZZ8rjHuanSablnO1S5E6USXTU+Dw1Ty02qm/uTcyLY9MR5uOX69nytbWpLVpdg0Z6L28XhG/7YmD+E4fnMWpnQvMSNY2Igs= 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=PQ4PXVHA; arc=none smtp.client-ip=209.85.215.201 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="PQ4PXVHA" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b9b9e8b0812so8299877a12.0 for ; Tue, 16 Dec 2025 11:24:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765913075; x=1766517875; 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=gYNzeEWkQrNZCPjMaj2SJhUyBdynXwycEj28gkBG7Us=; b=PQ4PXVHAOlMDOt6WXIb2lq8LIY23tdSjs9/zGWUZrLlJLxfhlF8kcm0pc5+KZ0havd 2ZMWzx1UCoNzeXhgKnqi762cu/OnKxZpBzPWjqoebHFvQZqWQ39s4pQ4doZm94fbt5gm Q05snUrkHPlEhqqLboO+5IjfOMu83olK9fAsxAD4tVAacGWf62tpoz8VtI/0EyKpswJQ DXhL0oCzbaO2lEbpNoRzURC5ip3EAba4+QC9wl1SqiDfUS/aMsRElxPdzht2YyDaCwcg uircWZx3VDRTnIp3zBlhu+OAj2bb+XtDVO5/3KySUzzbGlOdqgFDWAGJ1WLpqsmtz5wx MZIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765913075; x=1766517875; 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=gYNzeEWkQrNZCPjMaj2SJhUyBdynXwycEj28gkBG7Us=; b=hyHnQJSnAYpbritg8hU9FVPbvWsT0LUG+0Oqp8e/dnKHEy2i2MHMtrGtcCYD6qGaLm IvxybwSTWxRdI0gzoyyQXj5TuXTO/vaZCxvCUKPr//ETbhOwYpgJU8c2k0hTg0WS1Ikt R9PSvvPicce0uKX+Ba2/EDTmZcF7R1DaRpCe/1J+JW8/K95GMRCSAJ448gSvH7cwuAyT GTYoCwwMuJIXsyLx53Ahbk+QJTrIHouXOEkZyfxVH0FQECdveqoAZz023lky16LkzvH3 DuA8P8FI0wHqinQtAuNknIqONMGVyhi3dtb0bcbFTPqGVMo5ez8jeuqNmZfx4UfZb8l3 roIw== X-Gm-Message-State: AOJu0YxcF1OLURnwqfKKChTBeCOjWCArylLwor0flLL7gzrkaEBAiJtN U57pgKJJlTO/HSAxrbdOuVgVCdmbcn4AMfzCqlEzZ86/XhxVWg4mk/G+wwLzb41SWPFoj2A9GcJ TjEOMisz2iw== X-Google-Smtp-Source: AGHT+IEqa4HSnXwXmznEGtV0MuVS4XT84S48mFC2iVd2WV41B6M+Ui3Mh1qclHH3haOf4kxh7G7hqkG0K4Mv X-Received: from dycmf11.prod.google.com ([2002:a05:693c:248b:b0:2ae:3278:d74f]) (user=mmaurer job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:425:b0:2ab:9b40:fc78 with SMTP id 5a478bee46e88-2ac300fd0a3mr7584436eec.20.1765913075320; Tue, 16 Dec 2025 11:24:35 -0800 (PST) Date: Tue, 16 Dec 2025 19:24:29 +0000 In-Reply-To: <20251216-soc-bindings-v3-0-42ecdc8c117e@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251216-soc-bindings-v3-0-42ecdc8c117e@google.com> X-Developer-Key: i=mmaurer@google.com; a=ed25519; pk=2Ezhl7+fEjTOMVFpplDeak2AdQ8cjJieLRVJdNzrW+E= X-Developer-Signature: v=1; a=ed25519-sha256; t=1765913070; l=7565; i=mmaurer@google.com; s=20250429; h=from:subject:message-id; bh=God7snImE/2RjSSFJGBdoE/GLr+qwzbcgfa5v+DUTBM=; b=gYixZ9A3KPhDzvm3fxdpfDdtABHWEFy3q6CPr1/fsZfpCw6Tahwp0DLhRPqGrlreI62oI92Oq w4q79snJtdzAb+2HNw+yL20dU3SdfamJCM+J+JEESg1gHY5qGE2XxSI X-Mailer: b4 0.14.2 Message-ID: <20251216-soc-bindings-v3-1-42ecdc8c117e@google.com> Subject: [PATCH v3 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.305.g3fc767764a-goog From nobody Thu Dec 18 08:29:12 2025 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 593A732572F for ; Tue, 16 Dec 2025 19:24:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765913081; cv=none; b=DmT8PjqRQA53TMqEcjtwfkLns8EcFH5YhDbX49vTOmWCdUaeBBkEy69F27YDs1+H576DtzGljGlH9ugjvIxlw7iwULuOydPPm/A6ezR3vjaFKUqb5Uvk3wvGPHj0N/AYG0diB/e7SGvLQO5gBXLgI5pNIcfIzNfukca59XEsSe8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765913081; c=relaxed/simple; bh=LqxxlS4/i6gwgoiVzwffeQkmGGsXyfqyFWcsijZbA9s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=n+Ax5RBiGrrAaWkZSVqSUEoDONe8Vnb9W62pankp09xXltSe8HvtG4JOseQI3KsDR4vHTD+90u0D2+X1xFUKEN7vOqjyRwlKhYMfNBILpj+9B46zzA3R+Fy2TWQOTjDfVpo10lC4hcopQbck5EBym56R5NnN2GnFOX97U5hRfWM= 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=l/IlgWRv; arc=none smtp.client-ip=209.85.215.201 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="l/IlgWRv" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b471737e673so6151138a12.1 for ; Tue, 16 Dec 2025 11:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765913077; x=1766517877; 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=PCT8CzXnMjLHmplwTh0qF+iMeCCzn47uGLMQ1Y0SyoE=; b=l/IlgWRvHseBsVZ3p1ZPtNHQpX/RuqvcKUn/Nqu4Fn4iJr4xl9K0H9HeyUy/62UJCm MrSaDPtbu/i4R1VI03eIyqelEIjBYDwQ+kn1qun9ZvZ/jf06pF0I+SRtfwJbDuN4TzRf ruMoYjhmmgm3GHPIWueJcykQp20pjiuMvStw9QXFRqYx5uvKKPL7MGt8YaqGszYFtkLf hIpVIP/ulYe3AtsO4FosafiMUKeNrr1Jz9a730wSM0EfCS04GiQplioScHPusjQQ5r/+ tGO2koPd3DlY2waHPAbQxTF6Wrz3m7kyZncwM58dj2AhLJbsex/MhxS2FdKUgoCbY8Ba bP3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765913077; x=1766517877; 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=PCT8CzXnMjLHmplwTh0qF+iMeCCzn47uGLMQ1Y0SyoE=; b=P6pOFHcIQFPRl458S6lTAmZ3id4LKxrlw1TE6E5EssQwCk4hmo2UA5nupBJq8635w3 H0Uyutd6keZcHgGcl1k00DujiNYf4ucBaU5ybf5AByrwmz2jLWcxZoyqBb5ngTFVtC4b CIAqMUcs/KN+yWi2iBrzkmlRxXmTAmKsHUFt9a7aHrBT+qA/7gK1KMAUYUNsTOeZX9U4 mGJ1InaqDfMwXqk/H3FVNyhHfyUqhl4CS+pxEs2J8WOmNWpUor7NudnCdupIB9auAi1O aCy9d2VsYlsyaUQxM5wGIzHBfPIK8QAP6xCQTAaOKyvVK+m04S3NESZ7HsvgG9ElVqlw CeKg== X-Gm-Message-State: AOJu0YzrBIquplchtgaCfC+nJFypmO2Zz/H+ovKFwoWjeMmeHrtJs2uM 5K9M8imLBbqrLpaLkgNcszLtkJy81nqgBPPLnBBXAi9mp39VuBGLmZDZynT9mdoRxNLOhbefJ01 a5N3ORhfXKQ== X-Google-Smtp-Source: AGHT+IEZ56QmOBawruH657K/DMJRgdLujdgWu4Kgy0A+2J7/sLSPvuD1WA8L51E9ZzFyYKVAHTLSSu8/ry+j X-Received: from dybmk41.prod.google.com ([2002:a05:7301:ea9:b0:2a4:733c:4a27]) (user=mmaurer job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:800f:b0:2ab:ca55:89b6 with SMTP id 5a478bee46e88-2ac30154a97mr11459558eec.41.1765913077347; Tue, 16 Dec 2025 11:24:37 -0800 (PST) Date: Tue, 16 Dec 2025 19:24:30 +0000 In-Reply-To: <20251216-soc-bindings-v3-0-42ecdc8c117e@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251216-soc-bindings-v3-0-42ecdc8c117e@google.com> X-Developer-Key: i=mmaurer@google.com; a=ed25519; pk=2Ezhl7+fEjTOMVFpplDeak2AdQ8cjJieLRVJdNzrW+E= X-Developer-Signature: v=1; a=ed25519-sha256; t=1765913070; l=1261; i=mmaurer@google.com; s=20250429; h=from:subject:message-id; bh=uW1WwinLWyYqTbUHU0Eo2e0sUZIdoSKVPOwpgjV/qUA=; b=h3e5Ae95fZbP4g67AnzxyJkPNgBZEPztDXN+WoNpffNh89NQBRgHMNr/dpn8SepcaIdPAHXJs 4d9A1xQz9CkAhmcYVRwkEEVdrVYF7FLp/oQSb4l/kqEtQhSmnbk+s+G X-Mailer: b4 0.14.2 Message-ID: <20251216-soc-bindings-v3-2-42ecdc8c117e@google.com> Subject: [PATCH v3 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.305.g3fc767764a-goog From nobody Thu Dec 18 08:29:12 2025 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 D05A23242D8 for ; Tue, 16 Dec 2025 19:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765913083; cv=none; b=Z8gxmIzRnhjKu/3BhJgulL7nXHAPRZAnARZVowcW/OlmSS7XQ8luGfhFt5wy4vHbwmy1ltcgU7tCWGqir5OMP8dNaERWRYeKcffEDesW6syP023yUJdkICTk/DKbpCr8qln2Jo6w5MNVXESbQmpXJDLDoP5DwD40IQ+NTu3YsmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765913083; c=relaxed/simple; bh=/0kPZnK0q0pVyibhVyD4nZIlS2J5epiHCu2rpf5FvVI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XaC9XCCmI9+j96ORvNv8K5vrWdlqDqDncQ0IJ0FkvmLYOJwDd/W2PcFHGrJW0lWWDpa/wAWPyYNIfhz7C5PxA6lOmyepeOBxpI6vJA9IXcnfMJkDtbXjVgTKqldo8et7wy6ocjrmUQa777pm8WHUrsJDrNifiTTsVhO2gi/DCF0= 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=hxPqYQ76; arc=none smtp.client-ip=209.85.215.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="hxPqYQ76" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-bc09a8454b9so11571646a12.1 for ; Tue, 16 Dec 2025 11:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765913080; x=1766517880; 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=caqD8hxyMyGOF0U4L0dCaQCZmRG662msU+mDI24JSo8=; b=hxPqYQ76uNoQwRmkztqL4FcJPBUnADdr2mkYNKdgGuM08YigGzb3VyM/5mGwa7QUUN yB3iARV2fYuEEcOckpiK+YN6bw2mia1drBPJUcP7GdwBbS2BeSL9HCOXkylnM1SAdzNA ds5gfzJxN/IT8ZdEV0zMuG9LtHkTOFCd7or/hjWUdX8MkVptgaYpm2yg0WnAImFG/reJ 31KpmIFP9wLS/37DjFCjxBNmLOxqZi3KvYlUu0cqHc4R9mqHPMYddE/1f6ttqCkenbBh RxSZFR0XBgRZvdEOoo1goVfsy3TeTNkHAUmolFe5+uEeOyxoMWlSIAo0BlsdnavmQ310 KCpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765913080; x=1766517880; 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=caqD8hxyMyGOF0U4L0dCaQCZmRG662msU+mDI24JSo8=; b=B/Z3KZY8jsho+WutCgQRrbKVA+OFhU3VlLglIassGg9vt40gCxJV26JCVLJthsZnVU yl/8zi2Yz6EC14yUA/vZZmZtQUnFa6aJ+I45MlCZhOCR+dtsrDbfS54vWKCKV2Oo2GXi GEqePLwXny7hO3tcF/rVsTk06PYcMJnBqSkv/g0ddcgaPQFufl6nN5Tm87yrdEWLTjxm GpJGr+5kHeXJwpuMRsZ2qbvfWFZ01jVpbzVZTx6ztR7Cr0fgAS86ViP4HkVVCumCnDPG G5RETmZoC++hM9h4Erty/uD1jtwZnotRO+c4xRdr/2LsWBdGk7y0xGLdcfzLCkJQ/cKa qYaA== X-Gm-Message-State: AOJu0YyJsRhQu4mCQl1fmx5HU7F+ymMM+Vit3MQIeAxiMgOloCExcY8C w8tmtfFWTc7SZCduHXMWTIxlJnJ2n2gl0UEDfJ8r/DpPKG2CCwlI6hI9IrP5cEHgDLqnl++QsRT NPPYKRkASgA== X-Google-Smtp-Source: AGHT+IF8TY4ZLjIfQafruKxa7X/TC7lnilPDPi7zM3OchSNolmv+IxSySGMUVXDUR1dZzciWx9Cyp9XQs6dM X-Received: from dybun12.prod.google.com ([2002:a05:7300:f3cc:b0:2ac:5d1f:eb20]) (user=mmaurer job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:1a2:b0:2ab:9f55:d158 with SMTP id 5a478bee46e88-2ac30384fc7mr7707217eec.37.1765913079982; Tue, 16 Dec 2025 11:24:39 -0800 (PST) Date: Tue, 16 Dec 2025 19:24:31 +0000 In-Reply-To: <20251216-soc-bindings-v3-0-42ecdc8c117e@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251216-soc-bindings-v3-0-42ecdc8c117e@google.com> X-Developer-Key: i=mmaurer@google.com; a=ed25519; pk=2Ezhl7+fEjTOMVFpplDeak2AdQ8cjJieLRVJdNzrW+E= X-Developer-Signature: v=1; a=ed25519-sha256; t=1765913070; l=4646; i=mmaurer@google.com; s=20250429; h=from:subject:message-id; bh=/0kPZnK0q0pVyibhVyD4nZIlS2J5epiHCu2rpf5FvVI=; b=12i2ttbSYrSgli205SA8tbyLjtEUs+rX+OjsMQXcrdZbLiqZ82bHHnHEx0IfjYv1w0zXOLs2G vrUePS72nDLCtBkwbA6c+vjL+LuuN/eRJ+K2m+TprmSbe4RNBimCLtY X-Mailer: b4 0.14.2 Message-ID: <20251216-soc-bindings-v3-3-42ecdc8c117e@google.com> Subject: [PATCH v3 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 | 82 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 95 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..33043b0ac8dadec36aebf369f0f= b68dbb3b118ed --- /dev/null +++ b/samples/rust/rust_soc.rs @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0 + +//! Rust SoC Platform driver sample. + +use kernel::{ + acpi, + c_str, + 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_str!("test,rust-device")), ())] +); + +kernel::acpi_device_table!( + ACPI_TABLE, + MODULE_ACPI_TABLE, + ::IdInfo, + [(acpi::DeviceId::new(c_str!("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_str!("My cool ACME15 dev b= oard"))?; + let family =3D CString::try_from(c_str!("ACME"))?; + let revision =3D CString::try_from(c_str!("1.2"))?; + let serial_number =3D CString::try_from(c_str!("12345"))?; + let soc_id =3D CString::try_from(c_str!("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.305.g3fc767764a-goog