From nobody Tue Feb 10 04:23:46 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 15CD135DCEC for ; Sun, 8 Feb 2026 15:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770563140; cv=none; b=KDIpJdPJhUqDROJWavmUl/TkjGAiiJoZtiMDH9HI/16Uct94VTqVFrOA/OaJtSXHTKJU2vruVb41Hrd5+UDJ0ro7fQDPqR527jwJRWjgHuRvIfUkqOoyrJdXkfRp8rQJqfDvgR4jDIG7CIfcgiWxSYTg3+smdHPtjPrQPfzDVkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770563140; c=relaxed/simple; bh=U0yREyMuA9zF5E01tEeHmGWl8udIXIY+aolKf/33vzg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i54zyJwYCnvYEo8gbFATUrrZoG1nionsjf7+/9u2gq+xQjvwRFCglmUsFxz8D+tftkNm6xPCfM+Kp02LD2HkKIeebv4O/mPaKLp8lBoX4qdLFzrfMIB6zA7CG2eXQHf63bMAlzEW6WxldZJYb5MwGygbe0M4XbK3DZR4zHTINQg= 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=lPUq4mkG; arc=none smtp.client-ip=209.85.128.41 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="lPUq4mkG" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4833115090dso9035865e9.3 for ; Sun, 08 Feb 2026 07:05:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770563136; x=1771167936; 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=d13IbX+Pqr5mAXxfWBXXantCifGt3HSpLvwuk8HyZUQ=; b=lPUq4mkGcr/7J0GR91QQiJZaymr0jwOb4S27tBhjuNy/yl7ht0LJt1akYK8mcTSaH1 SD98gJ858oXXo4cxQDZ0T1elWELnm0dkM7v1vou//gC3YtwyjkmxRr+4oY8l8HC+ksjN dkXoJbrIqbXA1ZiHU/UyUgo4Z0eiBhKbSp41JZV5wY3YnDuSEC1lqHyw8m+xct0ESg1d 9qiR16m1nmxqGvCAQ0bILcZfycM5/qVxE6gn1H8YE3EAy1RiE8RrghplZbw4psyDDqqD iPK40nYdRvB3ps9LRAA8fgrTja5dB9ywxUFDf8nCI5l3z3vO0Ko9/WCp0qMQTjGqmNq+ 1B5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770563136; x=1771167936; 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=d13IbX+Pqr5mAXxfWBXXantCifGt3HSpLvwuk8HyZUQ=; b=sqroj29qUn9MXKrwMGgO2tQXvxaYj2tBNbmpVCMrS4KZcop+dLofshElT1WxrLPYbV XZag8bik12OlMwT/5uWfrzyOBj5DKg4WdAoghw2kTpG2MiKCpQDA7nCVjHd2ILJCBP/4 79mYJ+MzKJdk0uomZknB3Y/YliczieYHXadtErCBjQjxxqK/exC573CPGJa6BagDXQdP oPwkmChMqEcF6O76U1tye5+RlgVV35yBqMsxCdVJM+kX8j3UOvZqVxkCKYHhRI+6MQlV g+k2UDuhM1zE3hsG6WVK6W+XCeWDAmiU9Pay3GMAiVjC9IPfKFYir/ckYYjca9SR5Ep4 RUTQ== X-Forwarded-Encrypted: i=1; AJvYcCWegTnUPp5oRZ+iG2wmd9kOV+U0Mdfb5BbMJNmapc2+Xlc4g1eTTSQhaTeTeA8A8tVK4d1aOrebYPvgNAw=@vger.kernel.org X-Gm-Message-State: AOJu0YwThLkzUCZtow+02xLaxZ3HxIx55+mYylYDaOrOKErVqvlivJI9 As5Nz0D7hUv0j0QMcmqAeBHxyN5roF3DIa6djrxS2RFo1leDoFVvsiA6 X-Gm-Gg: AZuq6aLH3QjpjvwKEKQDvIr5GGxMgPWPmrnCOAulmp5wtJYqxbso7qc+cOe9PheouFk Hyy5UdU31z/+JTyKYCO3bQaz0cmZLHgcluglHclXsuIw7aFfUv4XdyToy02e5mDGKLePTP9Qwpc aA6/+WMmpVdiQRATIRat+tEltbxodJwiX4XtFuByqURx5FwrXaM6tD12oI8wcblvPKnmAgGwAX4 aWzPpYRkC+H+HMstvmTF0rt0DF+/4F7ZQG1vXPwZa9x7DobXomssZY7GCMjC9fZtsP+Vew9o3JJ bEyNlXrkE/fwtitAxZmvIrt/BqkefUZxQdyP9RZYNOxwXww5rSfPE8vDSiLJtt9efgB1oFs7Dcn BFgUzOAL8KEUcVfQQblDkiyw538DF7xTlzDkJvP9+75s2IhFxKyCEp/1USYNpJ16tbEy2AEY2Hh RjzJEXOeBbSIX70H+yP7z2JqnEsXaW9emTBw+/SduK9JNzUYGNZQ== X-Received: by 2002:a05:600c:a10b:b0:483:361b:deff with SMTP id 5b1f17b1804b1-483361be0aemr32845895e9.14.1770563136324; Sun, 08 Feb 2026 07:05:36 -0800 (PST) Received: from DB-VM.1337.ma ([197.230.240.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483206cc7d3sm179326255e9.5.2026.02.08.07.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Feb 2026 07:05:35 -0800 (PST) From: Taha Ed-Dafili <0rayn.dev@gmail.com> To: jic23@kernel.org Cc: dlechner@baylibre.com, rdunlap@infradead.org, skhan@linuxfoundation.org, linux-kernel-mentees-archive@lists.linuxfoundation.org, nuno.sa@analog.com, andy@kernel.org, corbet@lwn.net, lars@metafoo.de, Michael.Hennerich@analog.com, linux-iio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Taha Ed-Dafili <0rayn.dev@gmail.com> Subject: [PATCH v3 4/4] docs: iio: adxl345: update math and examples for scaling Date: Sun, 8 Feb 2026 10:05:05 -0500 Message-ID: <20260208150515.14798-5-0rayn.dev@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260208150515.14798-1-0rayn.dev@gmail.com> References: <20260208150515.14798-1-0rayn.dev@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Update the documentation to reflect the addition of event scaling and correct existing technical errors in scale values. key changes: - Fix the 62.5 g/LSB typo to 62.5 mg/LSB and add SI unit conversion. - Correct decimal precision of in_accel_scale and in_accel_scale_available to match actual SI unit (m/s^2) values reported by the driver. - Add sysfs example showing how to read and interpret the newly implemented event scale factor. Suggested-by: Jonathan Cameron Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com> --- Documentation/iio/adxl345.rst | 41 +++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/Documentation/iio/adxl345.rst b/Documentation/iio/adxl345.rst index 3ca6a78feb5b..321565699817 100644 --- a/Documentation/iio/adxl345.rst +++ b/Documentation/iio/adxl345.rst @@ -13,7 +13,12 @@ This driver supports Analog Device's ADXL345/375 on SPI/= I2C bus. * `ADXL375 `_ =20 The ADXL345 is a general-purpose, low-power, 3-axis accelerometer with sel= ectable -measurement ranges. The ADXL345 supports the =C2=B12 g, =C2=B14 g, =C2=B18= g, and =C2=B116 g ranges. +measurement ranges. The ADXL345 supports the following ranges: + +- =C2=B12g (approx. =C2=B119.61 m/s^2) +- =C2=B14g (approx. =C2=B139.23 m/s^2) +- =C2=B18g (approx. =C2=B178.45 m/s^2) +- =C2=B116g (approx. =C2=B1156.91 m/s^2) =20 2. Device Attributes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @@ -98,23 +103,23 @@ listed. +---------------------------------------------+---------------------------= ------------------+ | in_accel_gesture_singletap_timeout | Single tap duration in [us= ] | +---------------------------------------------+---------------------------= ------------------+ -| in_accel_gesture_singletap_value | Single tap threshold value= in 62.5/LSB | +| in_accel_gesture_singletap_value | Single tap threshold value= | +---------------------------------------------+---------------------------= ------------------+ | in_accel_mag_falling_period | Inactivity time in seconds= | +---------------------------------------------+---------------------------= ------------------+ -| in_accel_mag_falling_value | Inactivity threshold value= in 62.5/LSB | +| in_accel_mag_falling_value | Inactivity threshold value= | +---------------------------------------------+---------------------------= ------------------+ | in_accel_mag_adaptive_rising_en | Enable AC coupled activity= on X axis | +---------------------------------------------+---------------------------= ------------------+ | in_accel_mag_adaptive_falling_period | AC coupled inactivity time= in seconds | +---------------------------------------------+---------------------------= ------------------+ -| in_accel_mag_adaptive_falling_value | AC coupled inactivity thre= shold in 62.5/LSB | +| in_accel_mag_adaptive_falling_value | AC coupled inactivity thre= shold | +---------------------------------------------+---------------------------= ------------------+ -| in_accel_mag_adaptive_rising_value | AC coupled activity thresh= old in 62.5/LSB | +| in_accel_mag_adaptive_rising_value | AC coupled activity thresh= old | +---------------------------------------------+---------------------------= ------------------+ | in_accel_mag_rising_en | Enable activity detection = on X axis | +---------------------------------------------+---------------------------= ------------------+ -| in_accel_mag_rising_value | Activity threshold value i= n 62.5/LSB | +| in_accel_mag_rising_value | Activity threshold value = | +---------------------------------------------+---------------------------= ------------------+ | in_accel_x_gesture_singletap_en | Enable single tap detectio= n on X axis | +---------------------------------------------+---------------------------= ------------------+ @@ -126,6 +131,10 @@ listed. +---------------------------------------------+---------------------------= ------------------+ | in_accel_z_gesture_singletap_en | Enable single tap detectio= n on Z axis | +---------------------------------------------+---------------------------= ------------------+ +| in_accel_gesture_scale | Tap threshold scale (0.612= 915 m/s^2). | ++---------------------------------------------+---------------------------= ------------------+ +| in_accel_mag_scale | Activity threshold scale (= 0.612915 m/s^2). | ++---------------------------------------------+---------------------------= ------------------+ =20 Please refer to the sensor's datasheet for a detailed description of this functionality. @@ -140,8 +149,8 @@ When changing the **g range** configuration, the driver= attempts to estimate appropriate activity and inactivity thresholds by scaling the default valu= es based on the ratio of the previous range to the new one. The resulting thr= eshold will never be zero and will always fall between 1 and 255, corresponding t= o up -to 62.5=E2=80=AFg/LSB as specified in the datasheet. However, you can over= ride these -estimated thresholds by setting explicit values. +to 62.5=E2=80=AFmg/LSB (0.612915 m/s^2/LSB) as specified in the datasheet.= However, +you can override these estimated thresholds by setting explicit values. =20 When **activity** and **inactivity** events are enabled, the driver automatically manages hysteresis behavior by setting the **link** and @@ -270,13 +279,13 @@ Scale range configuration: .. code-block:: bash =20 root:/sys/bus/iio/devices/iio:device0> cat ./in_accel_scale - 0.478899 + 0.004789 root:/sys/bus/iio/devices/iio:device0> cat ./in_accel_scale_availa= ble - 0.478899 0.957798 1.915595 3.831190 + 0.004789 0.009578 0.019156 0.038312 =20 - root:/sys/bus/iio/devices/iio:device0> echo 1.915595 > ./in_accel_= scale + root:/sys/bus/iio/devices/iio:device0> echo 0.019156 > ./in_accel_= scale root:/sys/bus/iio/devices/iio:device0> cat ./in_accel_scale - 1.915595 + 0.019156 =20 Set output data rate (ODR): =20 @@ -312,10 +321,14 @@ Configure one or several events: =20 root:/sys/bus/iio/devices/iio:device0> echo 24 > ./buffer0/length =20 - ## AC coupled activity, threshold [62.5/LSB] + ## Check the event scale factor (0.0625 * 9.80665) + root:/sys/bus/iio/devices/iio:device0> cat ./events/in_accel_gestu= re_scale + 0.612915 + + ## AC coupled activity, threshold [0.612915 m/s^2/LSB] root:/sys/bus/iio/devices/iio:device0> echo 6 > ./events/in_accel_= mag_adaptive_rising_value =20 - ## AC coupled inactivity, threshold, [62.5/LSB] + ## AC coupled inactivity, threshold, [0.612915 m/s^2/LSB] root:/sys/bus/iio/devices/iio:device0> echo 4 > ./events/in_accel_= mag_adaptive_falling_value =20 ## AC coupled inactivity, time [s] --=20 2.47.3