From patchwork Sun Jan 12 12:06:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasiliy Doylov via B4 Relay X-Patchwork-Id: 13936339 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF0B4139B; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; cv=none; b=iYFYoXU0LRNjA+EL1kKB8cA4acV9h2MxoL+25+xJmLau0uixAWmCg/qN6Ba9T0swKe2rgTWUY7wGzCE6zyWYfV195AZeLqWGRV0f2zRPc005s5aImDs5VYEazbynUmnySK3jK1s6/j2vNzDybkxN3ekGiR9PIgL1AFPRKqis1WA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; c=relaxed/simple; bh=/2wNdRw+WQbyfxQS3NklGacoKVAmlCPk/EFYLbVlOVE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h37+tDsDlyDqbui3keS5xfq8wfcWirLE4GdKtwmJzgVSrcdHyg9TCDu9no/R582Yql5CAW3AAr6dKDVUVJxysJGKQeojvfy8MPD6WFS3AZI6r04ctHa6cMFl7K7mYpgCrLxrg04Upy3oZwvQB0eIfYL2Xi2YRgScXeTz/hdOS5I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J/c4evub; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J/c4evub" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8BEBFC4CEE3; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736683564; bh=/2wNdRw+WQbyfxQS3NklGacoKVAmlCPk/EFYLbVlOVE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=J/c4evub0hg5Apb+TGG3JOtwFz89BsFZYZ0oldJG85vVgfsIExaQemjUafzMbyyc8 CWq1YEpovcBeYCd8aSylkCf/aTmnba4m/3PJIU7DcuYLqwFfCpE3l8Wmhxf/AT4Mww SvpSOCHuB0/IC7v78oznzbqknna6QMWfM2TBoB5ApHzRLm0NVIhI4IE/xEngUJbZPl JibycTECtzXWiIJPTDlhYCA2JhAX/bUEnmhSTNcGuXMXl4+SJhYg63gQbG5xtmJ4Fw HIh4jelpi6xfY0CGXiLbMXWTMUg7J/hNJqoylK1zn4CxB4ikjphI1LlHBNBadWbpn9 UkvNWn6Ad7WEw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AE9DE7719D; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:06:02 +0300 Subject: [PATCH v2 1/5] dt-bindings: iio: accel: mc3230: document mc3510c Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250112-mainlining-mc3510c-v2-1-322804a545cf@gmail.com> References: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Vasiliy Doylov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1060; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=kKqPGqcAMrV8Q/3yZlxILQP7a1DF7juDcij9I0w4AmM=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbN2jxT9hxW2Q3S+P0vDNTAoSmscfsvfgq3Mp9UsHV/ bHiUjO7O0pZGMS4GGTFFFlsNnrMFssPl5w07akCzBxWJpAhDFycAjCR2CWMDGdZtxpInSyyZ/s/ d2v4Bpf81z2PV1+L4tOSO5wf4PasI4bhf+6CmzxLvVssmj/NDVZqajAubV9z+szFj5nTXNPV2X+ y8AIA X-Developer-Key: i=nekodevelopper@gmail.com; a=openpgp; fpr=3CB1489B166F57199296E520B7BE22D44474A582 X-Endpoint-Received: by B4 Relay for nekodevelopper@gmail.com/default with auth_id=314 X-Original-From: Vasiliy Doylov Reply-To: nekodevelopper@gmail.com From: Vasiliy Doylov The MC3510C is a 3 asix digital accelerometer. It handled by the same driver as MC3230. Document it as a trivial device. Signed-off-by: Vasiliy Doylov --- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index fadbd3c041c8c39faedfe62874d4eba25a0bf30e..6c34e4c0dcc6df5a4d8edc5effb80980de820db9 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -187,6 +187,8 @@ properties: - maxim,max6621 # mCube 3-axis 8-bit digital accelerometer - mcube,mc3230 + # mCube 3-axis 8-bit digital accelerometer + - mcube,mc3510c # Measurement Specialities I2C temperature and humidity sensor - meas,htu21 # Measurement Specialities I2C pressure and temperature sensor From patchwork Sun Jan 12 12:06:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasiliy Doylov via B4 Relay X-Patchwork-Id: 13936337 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF16A1AB530; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; cv=none; b=SBvnLHLdwI9CzPB09T9Y/wjcDYlr8YSzBxtG4UUfmOe0nE51e7O4zRGTS9brJOSUuK0eDpj38fp7zkmzqPa9J3ux1q3vp5SgbykG6aE/BizMoDi2YRizkWzWJ2RKZDq4bbgUIRMykSFY1wC8Ycm3KP/htJ+HPOVQ0Rz0dvUbmgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; c=relaxed/simple; bh=kvKC97JeAx/m1MCydo6d/Py+eTfMKM+AcUKKqHF3zc0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P/qTT+HpMP9D+k+rrU0I7I4Wgs1tvI7q9DXFrtKMmFO1lUmCC522ErFzWD5DaKXdTk3zrpXdOIo15RGi1haKjTfDfbqnDpgVciywDr+feBpD1KRYYlt7w6c8dsmoZVZFN+N1E1w5QA3dUK0x0NoKGi6m6hsOlyI0/xGnl7psZsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hPZuiBfh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hPZuiBfh" Received: by smtp.kernel.org (Postfix) with ESMTPS id 96A2BC4CEE2; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736683564; bh=kvKC97JeAx/m1MCydo6d/Py+eTfMKM+AcUKKqHF3zc0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=hPZuiBfh9VUEar9jC2Ek5V3eUMAc+0gc0vCnG63BEJKXWvGGCtykeVcZk9a+0Tp5S DjI3//0eMJ7D/d9lwNhVaHXHUBJEqWjr8oRhDRZIu10qYwBs+64GjK4DPrYXXoohve yp9F9898Qvy4Q9EP+cDMG9kJUAQ9ZX9Tln6Do15lRy+Hrxppdy8GffUql61VZMZe3r titOu8lxPWA7jYOuVFdNOXt/xWvkPpDNNs/bE6JdMXOcTJoVy/kwDpgmKFuSbh8X7j BtoP8izSOYQ2LVNhfWP9nNfbOieFHIHptAWW94iLsxMaaBrrVGLCk3cjfnvDG89Rxx BKtbXGIArsyRQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C0D8E77188; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:06:03 +0300 Subject: [PATCH v2 2/5] iio: accel: mc3230: add mount matrix support Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250112-mainlining-mc3510c-v2-2-322804a545cf@gmail.com> References: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Vasiliy Doylov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1922; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=tt9zbmLm9qM5VxkCOcKg8jECB+aJJH6bwFRVLsKm6MY=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbN2j9cn+97c+ShWV+Pyp2hQexZmxhjbsRfejkbT6xO ddza/SkOkpZGMS4GGTFFFlsNnrMFssPl5w07akCzBxWJpAhDFycAjCRs06MDEeu5aazrdMS/Vqg rjx7XSOTqoOAJWOtX9eX4rYFoqsr3zP8r7Sc9yP+xGyNPW/PnVetifZ90hL+Jyo1rnR306wbHNf aWQE= X-Developer-Key: i=nekodevelopper@gmail.com; a=openpgp; fpr=3CB1489B166F57199296E520B7BE22D44474A582 X-Endpoint-Received: by B4 Relay for nekodevelopper@gmail.com/default with auth_id=314 X-Original-From: Vasiliy Doylov Reply-To: nekodevelopper@gmail.com From: Vasiliy Doylov This patch allows to read a mount-matrix device tree property and report to user-space or in-kernel iio clients. Signed-off-by: Vasiliy Doylov --- drivers/iio/accel/mc3230.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c index caa40a14a6316acae3a972f0ebe0b325db96eb44..a153a3f715ed7f2f1417618715767f265b49191d 100644 --- a/drivers/iio/accel/mc3230.c +++ b/drivers/iio/accel/mc3230.c @@ -44,18 +44,34 @@ static const int mc3230_nscale = 115411765; .channel2 = IIO_MOD_##axis, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .ext_info = mc3230_ext_info, \ } +struct mc3230_data { + struct i2c_client *client; + struct iio_mount_matrix orientation; +}; + +static const struct iio_mount_matrix * +mc3230_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct mc3230_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info mc3230_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, mc3230_get_mount_matrix), + {} +}; + static const struct iio_chan_spec mc3230_channels[] = { MC3230_CHANNEL(MC3230_REG_XOUT, X), MC3230_CHANNEL(MC3230_REG_YOUT, Y), MC3230_CHANNEL(MC3230_REG_ZOUT, Z), }; -struct mc3230_data { - struct i2c_client *client; -}; - static int mc3230_set_opcon(struct mc3230_data *data, int opcon) { int ret; @@ -141,6 +157,10 @@ static int mc3230_probe(struct i2c_client *client) if (ret < 0) return ret; + ret = iio_read_mount_matrix(&client->dev, &data->orientation); + if (ret) + return ret; + ret = iio_device_register(indio_dev); if (ret < 0) { dev_err(&client->dev, "device_register failed\n"); From patchwork Sun Jan 12 12:06:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasiliy Doylov via B4 Relay X-Patchwork-Id: 13936341 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13F6D1ACEAC; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; cv=none; b=fzXhbLnTIoIqTBQC85peCNZvWxDaDvjc18UK0IeUT8LIWtqiw80TFUAOCB4te9XOiO0BVCZu/HH+CZF8YGY60SlM4JXmAwTkq7W8Kc8XDxKRZtao8MZ+n408Y59yDrGz69yZA3c1fsxXNSPImCTJ1Dct9nU1ajT3GhkUY7/bMDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; c=relaxed/simple; bh=HRChpib1kiNQdmhKWJNL1bCldJ1FJminyluLN/esqpM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZasRlpZaVkHwHandi+R+WUA7A2E86COl/tQVVkxyNi+ftq9KHahrRUmfTIsstmnAGpd0xRcSSCE8npb78k/Nb938Tsns+Za7Hdz8Iq9FGZGkfhkOHdJGpf2WyeUVC8+glk7q8+NxClzOl7MdsqxnaozxBCbM/cbOzQM+LDsOypA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p0xIPcgT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p0xIPcgT" Received: by smtp.kernel.org (Postfix) with ESMTPS id A4AF5C4CEE7; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736683564; bh=HRChpib1kiNQdmhKWJNL1bCldJ1FJminyluLN/esqpM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=p0xIPcgTW1uS6ioXxaRb2rV9Fck4hDH7lbWxjtEcpQbk59QXeVVo3aOxOeakCakaQ isI2gSX4tI8RmmCOcZLVPi6J6uJdfKpEXTyOY6+GG0OmPlcdPceoDg+5H0Q+e2mNH3 fVM2w4VpsB0ZmmR/C6r2orMuOlyWoXTS5oM2Mop2zNlWhVjz2mAttp+BJ3SEFOk0kA vIXdtnZJVWNE9kJirzS3ZV7GUAZlqeLTlYCGK2HYXWSweljKKNCLmOqFsBSKzRMBwt KsJ8btltfVQv0Vd8fu/MxQHJQi3APovxqnJnTo71f+iFOCRlTXa4qRbYtKoyrN3LeK 92tkYBeKuG+6A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A53BE7719E; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:06:04 +0300 Subject: [PATCH v2 3/5] iio: accel: mc3230: add OF match table Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250112-mainlining-mc3510c-v2-3-322804a545cf@gmail.com> References: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Vasiliy Doylov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=921; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=CXzfdvJmi3hz61iMY9QNCk/KSoxBmTl8+cAWMbpfFFg=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbN2gdmbirteXk30JTrounr71kmb+i+NyFeeaNxYrCb 4z3BvRad5SyMIhxMciKKbLYbPSYLZYfLjlp2lMFmDmsTCBDGLg4BWAiC3IZ/lewszl6str/e2uh zXlMJGJDNMedSe4a/ff2xHV8c134U5CR4WBF01OPT0lbDT29Qg7uMlax0hQ4XpR//Jx02pkV/ZN 38AMA X-Developer-Key: i=nekodevelopper@gmail.com; a=openpgp; fpr=3CB1489B166F57199296E520B7BE22D44474A582 X-Endpoint-Received: by B4 Relay for nekodevelopper@gmail.com/default with auth_id=314 X-Original-From: Vasiliy Doylov Reply-To: nekodevelopper@gmail.com From: Vasiliy Doylov This will make the driver auto loaded via device-tree. Signed-off-by: Vasiliy Doylov --- drivers/iio/accel/mc3230.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c index a153a3f715ed7f2f1417618715767f265b49191d..ba30c904d3f67002deeb3ca5a7e12bfae312e05f 100644 --- a/drivers/iio/accel/mc3230.c +++ b/drivers/iio/accel/mc3230.c @@ -205,9 +205,16 @@ static const struct i2c_device_id mc3230_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, mc3230_i2c_id); +static const struct of_device_id mc3230_of_match[] = { + { .compatible = "mcube,mc3230" }, + {} +}; +MODULE_DEVICE_TABLE(of, mc3230_of_match); + static struct i2c_driver mc3230_driver = { .driver = { .name = "mc3230", + .of_match_table = mc3230_of_match, .pm = pm_sleep_ptr(&mc3230_pm_ops), }, .probe = mc3230_probe, From patchwork Sun Jan 12 12:06:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasiliy Doylov via B4 Relay X-Patchwork-Id: 13936340 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13FBD1AF0C0; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; cv=none; b=ba3RUbwmbsjtZZnmxRtI8GvhMliWlcx4q7hjwazmjDZ4Y7Mb3gbXSLDDMKL1od9SysleWj2RR6OeFXOnbqcT8jgx0hJMOLmrW4swATePKHTkNcDb5KKB9hTo23vSQjFem9Wk8y/SJxTWFWPeYTh4ZRqFaWlP8N2l0wiv5dDNj+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; c=relaxed/simple; bh=Se0XQboJyjtbGzscr24wmSD4SF40fS4151iliKnRSms=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LphP8HZn1EX1yPQ+JI+yarFv5FTfWXaZObofGck8pXsNxrdfNWAulNWDmuV+7npgGUlEYjVPHiCaa3xUlaXZUO2Rb1TxvV7uz3YkNtg3OZYiYglMw5QGmt17EYryBfdMUjI33S/O4dOrpyyYTsYATGhboSTUgIIPqK1oM+HzLvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=As8FQZIt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="As8FQZIt" Received: by smtp.kernel.org (Postfix) with ESMTPS id BA576C4CEE9; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736683564; bh=Se0XQboJyjtbGzscr24wmSD4SF40fS4151iliKnRSms=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=As8FQZItL/BnzHw/7uKn65d+3WdxoCwiWrV2guMIUOjVcXb4pZnrgVwS8Hn/b9uU0 tWUl/w7vjNca5op4fTlVmZTC7DD6ozPNv3HXNQB1nbKZpkM44ilNgw3TSgYRePMZsG Uo6yxWmZsfUjUv+FXHeTZvhWyR3+JlSWBnMHerLpE9bT1ZoId8KrwOG38konfBiED2 kZT/PtM8qjZsCSXFtHl20FC8rsHvZwPQOm7GuSqOhgQ8KsbE2JXMZOiBDYFVfpc84S wvUMKD4ryh6C3ZbTgMPml3fvyw99n92SzCVzfIw6/7Af7GUoWd9qBRJ6+6pItrNlm6 cTNrzL7pQGNEA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEB74E7719C; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:06:05 +0300 Subject: [PATCH v2 4/5] iio: accel: mc3230: add multiple devices support Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250112-mainlining-mc3510c-v2-4-322804a545cf@gmail.com> References: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Vasiliy Doylov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3868; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=3IVy/NyWvdKKaQp0EMfhTlEK8Ob/tkCbzYjX6DAoo5c=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbN2gprFV2Tfh9/sXuWz3P71hy9Kiztt2K/LFm1Z9zS VZfplcVdJSyMIhxMciKKbLYbPSYLZYfLjlp2lMFmDmsTCBDGLg4BeAm5zL8d06w8JPeyzcv/9/r JtVe8zNrlgY6zxdMuV6VwXT4U9r2Ewz/jB8kvPgoe2XWq+9zDy/ZfPTk2mUnNnHM8k08ZLzXZMW OlTwA X-Developer-Key: i=nekodevelopper@gmail.com; a=openpgp; fpr=3CB1489B166F57199296E520B7BE22D44474A582 X-Endpoint-Received: by B4 Relay for nekodevelopper@gmail.com/default with auth_id=314 X-Original-From: Vasiliy Doylov Reply-To: nekodevelopper@gmail.com From: Vasiliy Doylov This patch allows to add new devices to this driver. Signed-off-by: Vasiliy Doylov --- drivers/iio/accel/mc3230.c | 50 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c index ba30c904d3f67002deeb3ca5a7e12bfae312e05f..ef9c4bcabb0b77518fe2a124e31ec5e7ca66816f 100644 --- a/drivers/iio/accel/mc3230.c +++ b/drivers/iio/accel/mc3230.c @@ -22,20 +22,29 @@ #define MC3230_MODE_OPCON_STANDBY 0x03 #define MC3230_REG_CHIP_ID 0x18 -#define MC3230_CHIP_ID 0x01 - #define MC3230_REG_PRODUCT_CODE 0x3b -#define MC3230_PRODUCT_CODE 0x19 /* * The accelerometer has one measurement range: * * -1.5g - +1.5g (8-bit, signed) * - * scale = (1.5 + 1.5) * 9.81 / (2^8 - 1) = 0.115411765 */ -static const int mc3230_nscale = 115411765; +struct mc3230_chip_info { + const u8 chip_id; + const char *name; + const u8 product_code; + const int scale; +}; + +static struct mc3230_chip_info mc3230_chip_info = { + .chip_id = 0x01, + .name = "mc3230", + .product_code = 0x19, + /* (1.5 + 1.5) * 9.81 / (2^8 - 1) = 0.115411765 */ + .scale = 115411765, +}; #define MC3230_CHANNEL(reg, axis) { \ .type = IIO_ACCEL, \ @@ -48,6 +57,7 @@ static const int mc3230_nscale = 115411765; } struct mc3230_data { + const struct mc3xxx_chip_info *chip_info; struct i2c_client *client; struct iio_mount_matrix orientation; }; @@ -111,7 +121,7 @@ static int mc3230_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; - *val2 = mc3230_nscale; + *val2 = data->chip_info->scale; return IIO_VAL_INT_PLUS_NANO; default: return -EINVAL; @@ -127,15 +137,28 @@ static int mc3230_probe(struct i2c_client *client) int ret; struct iio_dev *indio_dev; struct mc3230_data *data; + const struct mc3xxx_chip_info *chip_info; + + chip_info = i2c_get_match_data(client); + if (chip_info == NULL) { + dev_err(&client->dev, "failed to get match data"); + return -ENODATA; + } /* First check chip-id and product-id */ ret = i2c_smbus_read_byte_data(client, MC3230_REG_CHIP_ID); - if (ret != MC3230_CHIP_ID) - return (ret < 0) ? ret : -ENODEV; + if (ret != chip_info->chip_id) { + dev_info(&client->dev, + "chip id check fail: 0x%x != 0x%x !\n", + ret, chip_info->chip_id); + } ret = i2c_smbus_read_byte_data(client, MC3230_REG_PRODUCT_CODE); - if (ret != MC3230_PRODUCT_CODE) - return (ret < 0) ? ret : -ENODEV; + if (ret != chip_info->product_code) { + dev_info(&client->dev, + "product code check fail: 0x%x != 0x%x !\n", + ret, chip_info->product_code); + } indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) { @@ -144,11 +167,12 @@ static int mc3230_probe(struct i2c_client *client) } data = iio_priv(indio_dev); + data->chip_info = chip_info; data->client = client; i2c_set_clientdata(client, indio_dev); indio_dev->info = &mc3230_info; - indio_dev->name = "mc3230"; + indio_dev->name = chip_info->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = mc3230_channels; indio_dev->num_channels = ARRAY_SIZE(mc3230_channels); @@ -200,13 +224,13 @@ static int mc3230_resume(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(mc3230_pm_ops, mc3230_suspend, mc3230_resume); static const struct i2c_device_id mc3230_i2c_id[] = { - { "mc3230" }, + { "mc3230", (kernel_ulong_t)&mc3230_chip_info }, {} }; MODULE_DEVICE_TABLE(i2c, mc3230_i2c_id); static const struct of_device_id mc3230_of_match[] = { - { .compatible = "mcube,mc3230" }, + { .compatible = "mcube,mc3230", &c3230_chip_info }, {} }; MODULE_DEVICE_TABLE(of, mc3230_of_match); From patchwork Sun Jan 12 12:06:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasiliy Doylov via B4 Relay X-Patchwork-Id: 13936342 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B2FC1B0F35; Sun, 12 Jan 2025 12:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; cv=none; b=W77Ngv98sB55IRGHjjpiwLBo93DBvaK/5Rk/bnp/mxP3haxKcemrilwCyBUJvdcBmkfvX+xMiG8fY3VSe0gpLeAVBLDUNIHR6WbRn8GLRY7pnEZ3/1fDI2idQod3wgXjHk2PfEQ8uudu9k9ckUDxRNxb9TrVM6fbWqhFBSCoeLw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736683565; c=relaxed/simple; bh=HdC3tnypYV9krIVMUb6n9Me4suQ/79fxzfa7NWhVtHk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iCabwG1hsQTwZaZV9ScmUJLqk2IMm9M8EjCrUzFReT42I8uiOToR1lrGiAOFIz1ZqNb2sQ8Z6vXuhFe7vkdtKpe+qHr6Y04zvu1TiNFrI+jW3aF2bsb19wbw9MXOh+oCLybH7B4Lwvo6ObgSnL/PsOk96RYtico9o79YX+HGceE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z557wR1/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z557wR1/" Received: by smtp.kernel.org (Postfix) with ESMTPS id C6959C4CEED; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736683564; bh=HdC3tnypYV9krIVMUb6n9Me4suQ/79fxzfa7NWhVtHk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Z557wR1/Ri0x/v7HLBEpXPfBpA0C2BU93R118SDYq2yKED0gSPRbVTLs7ra7SiXQd Qu5OtGDh7pY/1I7O1udDSmt0ZqQcPVWzVdMpHnEAg13zxl8EWBY9rX6uO9S0+koVd0 /Ene9dN4km0xbvoex96Qi3iAUF6VJ1wuS7Z+VyR4tkXRSK88mwfFaoHEMv1PofRDci LKGywhN8Itmaqnf6motxzvDN7PKvmsdGT7Mb3qiyTjGhxObJhGTRRMoRBs4s1bgLQT fc4H0rkjOGhi1Hqb2A0YWvP2iJRoMoB2tP1od3/SkqrZpKf+PHfsFcPTAOKtjpn5BX MvW9FyBAIN1DQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0002E7719D; Sun, 12 Jan 2025 12:06:04 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:06:06 +0300 Subject: [PATCH v2 5/5] iio: accel: mc3230: add mc3510c support Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250112-mainlining-mc3510c-v2-5-322804a545cf@gmail.com> References: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v2-0-322804a545cf@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Vasiliy Doylov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1444; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=RJjlWfFqRxjL45OPhdWltdOqM38Z7glviIeJAsj3UeE=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbN2gtEXm7IWXPvY7/qkmfr7n2iUWYHl2s92Z2IaNxw 9LqAMu2jlIWBjEuBlkxRRabjR6zxfLDJSdNe6oAM4eVCWQIAxenAEzE8i8jw1b/c+4NbSWPLPjk vBJKuFd8TOdPXmp7qr32z8JlQexrShn+p7De0P98+0J9sr7ud4NzW7OSI1kcwjWEk6XrWMpsHGf wAAA= X-Developer-Key: i=nekodevelopper@gmail.com; a=openpgp; fpr=3CB1489B166F57199296E520B7BE22D44474A582 X-Endpoint-Received: by B4 Relay for nekodevelopper@gmail.com/default with auth_id=314 X-Original-From: Vasiliy Doylov Reply-To: nekodevelopper@gmail.com From: Vasiliy Doylov This commit integrates support for the mc3510c into the mc3230 driver. Tested on Huawei MediaPad T3 10 (huawei-agassi) Signed-off-by: Vasiliy Doylov --- drivers/iio/accel/mc3230.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c index ef9c4bcabb0b77518fe2a124e31ec5e7ca66816f..ca6f87d27b0f179ca33528b7e82471f1d13ebd5b 100644 --- a/drivers/iio/accel/mc3230.c +++ b/drivers/iio/accel/mc3230.c @@ -46,6 +46,14 @@ static struct mc3230_chip_info mc3230_chip_info = { .scale = 115411765, }; +static struct mc3230_chip_info mc3510c_chip_info = { + .chip_id = 0x23, + .name = "mc3510c", + .product_code = 0x10, + /* Was obtained empirically */ + .scale = 625000000, +}; + #define MC3230_CHANNEL(reg, axis) { \ .type = IIO_ACCEL, \ .address = reg, \ @@ -225,12 +233,14 @@ static DEFINE_SIMPLE_DEV_PM_OPS(mc3230_pm_ops, mc3230_suspend, mc3230_resume); static const struct i2c_device_id mc3230_i2c_id[] = { { "mc3230", (kernel_ulong_t)&mc3230_chip_info }, + { "mc3510c", (kernel_ulong_t)&mc3510c_chip_info }, {} }; MODULE_DEVICE_TABLE(i2c, mc3230_i2c_id); static const struct of_device_id mc3230_of_match[] = { { .compatible = "mcube,mc3230", &c3230_chip_info }, + { .compatible = "mcube,mc3510c", &mc3510c_chip_info }, {} }; MODULE_DEVICE_TABLE(of, mc3230_of_match);