From patchwork Sun Jan 12 12:25:35 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: 13936344 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 BAE881B0F30; Sun, 12 Jan 2025 12:26:20 +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=1736684780; cv=none; b=tA6+FlbiUmodNqLH6mvKeHh/AS9ko1bT/337EAasplAI/TmzM/aqMpp/Nn5DKxXL3/mrFI6ud0BTCu1WbGGg5v/lR/aOBzyLfKjnp131YbsiLs0O+nB6LIsIWsm8lZzpBa9k8F7hPVvS5ff+0yoLKa/amQENNrkDMmwEeplAzTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736684780; c=relaxed/simple; bh=/2wNdRw+WQbyfxQS3NklGacoKVAmlCPk/EFYLbVlOVE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HgpGk5eIaO2K+rvyTVxWY+IhE+HvcxR9sTGFS5vWqSKlpncPBwjFJ42+SkJAznZp5cra6GSZQn73dmnQ2mLjJpius9+kPyigkVnB6nOMhUp0P8bDUjBVDWM8RBU/RXMXYaDUnlkssQDvxUocfJFccsfmLfi8sLMqp8S4GMh9EPQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kh5xem92; 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="kh5xem92" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3A3BEC4CEE3; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736684780; bh=/2wNdRw+WQbyfxQS3NklGacoKVAmlCPk/EFYLbVlOVE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=kh5xem92FDcmq7kICF7WqrQ9rEmuCmK9noJiunomPZ3av9ddmVrjkJnPdkxkv3EUe oygxmuOrumcamMKC6UllCAwqaRcVY9TVcrM8KE34HDH/U9u0tn41h7JLNaukhRPyyz YwhD/Sa5NjsT6ZisxfXKKPrCzk2gSFPBuv+QOBb0pcXkCZULxVsm9Ny3FIXzAQsI9R mYJ7mpf3kkQvw40cGbIV5aRUI7hW2LYqs6J9M2GcKUZTYp+eVlEs1i0G5OuXm0CYbm ETYA3G406XGIUhNBvnLoCkBcNvnlQhrMUnpfH6YfoR0Hmdk5KktHBnxZIYC1e2ntbG aPk9Fg/c0LkOg== 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 2B326E7719C; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:25:35 +0300 Subject: [PATCH v3 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-v3-1-9ee6520ab69d@gmail.com> References: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@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/SFZeSpU2Mp9WSGNKbt7yat2zhtSW6ZzhPTFqv13/kRM2uR0bM7aU7eKbyL 1l8LshftKOUhUGMi0FWTJHFZqPHbLH8cMlJ054qwMxhZQIZwsDFKQATaQhm+MPLf3HCrxiHJVyO DRP+FYvr573ezf/qOkuHI1+NxMJNJ+UY/nDN22lzw3sPx4dJ7hOFDktEuno85PTdv2h94XmfWR/ UzBgB 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 Acked-by: Krzysztof Kozlowski --- 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:25:36 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: 13936345 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 C09511B0F36; Sun, 12 Jan 2025 12:26:20 +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=1736684780; cv=none; b=TcgySCUEg+1zYvsmNogAs1VpfhxAbUykXBzxJ9ARIW1gBPdr4WBhlc6gEPsyJqnVXJTYqYrNxFwbQ+aNrTeZ8R7tZVCgs5/i2YFEynzZwAjEPrktHWtfCX7vc96SCf6ap/kKNjwkXBt+4W8wrJajDMqT9hlBmOY/nPYeetATNho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736684780; 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=GcIRn7Mjotkds7EUA2KvqmqUhGaJKcKEwZeuhyb3EpSfl3k4JlJOtiZYT2KSPKS8rcSDBtJSoA9tNd+/uqQxCry751FWzInBDnTF8NGwK2MHkv2v1k9Hgzio+OdNTCIAvz/i+DaJHWTa08k+SYFhCJihHCMOjuszSDquU9VUvpo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qWC1Ok2C; 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="qWC1Ok2C" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4A3D5C4CEE2; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736684780; bh=kvKC97JeAx/m1MCydo6d/Py+eTfMKM+AcUKKqHF3zc0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qWC1Ok2C6XbzrgJu1iJfPlWTOYob9LOZ0ajgyTfox/t7EoWPRCp2N9Z8ux6XBgHMj NNoqJl/TRqQJgujxdrVitl0WAEGyzXibDqt7Njd/S3NNIjZRCXQUDosSqY587wYORX sqnKLn7Ye2+638Ny+r/zinosc516Pyh3ysp6kikwmDfH1EOHR8uDFLFFuOrP64B6Y5 HZxZcOdx5a86oJC0LofnbqqSJO1iGrTlwekp8HwdKKtEO/cbx/SuQv1DimXuy7Kp7K V7i/+aUqAUpmyArPyNin7LBZ3P4mvBzfWCasol7Clxpz6uXMUhIzNhOIqL9YzTzGVv QgdLDxd7IS1IQ== 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 3A093E7719E; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:25:36 +0300 Subject: [PATCH v3 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-v3-2-9ee6520ab69d@gmail.com> References: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@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/SFZeSpU2Mp9WSGNKbt7w6ye9ad372xnshd61MT3N8v77Zfw8fT+F3iZfBx x+s/i4+t6OUhUGMi0FWTJHFZqPHbLH8cMlJ054qwMxhZQIZwsDFKQATEdjJyHB323ybSuYFhg5N GZzrmfnOr3rC3SxeM+GG/e6a9ayn9oUx/HcKm9H37cKfe5p8AcGWs/X2sr1wOq+6Te/IFOPvD3+ ckmQEAA== 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:25:37 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: 13936346 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 C09AA1B0F3C; Sun, 12 Jan 2025 12:26:20 +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=1736684780; cv=none; b=fTLdyDsLfdHJkjMVqjKnp4bFzOQMISaDflvPhTjCPYrDC3TADipuE0NDIiUsMRYKGSKJr5qj8mfwcexIJo9N12Dre323MXBAj5mXfUupSexiYqH3ypLT8UXGiZgCCqdX24TaVkHPqHCaIK3eL5R3wEhBooT8LcDMgl60n7OgmNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736684780; c=relaxed/simple; bh=HRChpib1kiNQdmhKWJNL1bCldJ1FJminyluLN/esqpM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K56KK+KoGItZqTW/C+6HRlJxj8wjcXPYCtapyLg5SJdYsa6Dx14m0THdPLVZyKInGp900QVYHYLDPBwmfLiR175hOSOE02QnlYCVXidVRddZkuLSCIlap5wScpo2lezT9h655qanR/FF7RWKr9zLpT2IrAc65dLgdnYX6j0kTN0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YJVPgy29; 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="YJVPgy29" Received: by smtp.kernel.org (Postfix) with ESMTPS id 568FDC4CEE4; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736684780; bh=HRChpib1kiNQdmhKWJNL1bCldJ1FJminyluLN/esqpM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YJVPgy29QPcTKqxGnj4mfdBs4jfhZLc3/JYLeVVAtTfGjnNKPfPXrM7x858p4QdMI 9IettcqqE6km3Xpqu+AqSoJ5mJawqJli5Fv3utCC6JS4WbzJO8DRmOGgtlyKW3ltmm RsBJ6sYWtOG8Rxprs/Wc1Qt53bQDkZss1fGsJBMl7/53/29pjYx15NfG6y0VAmuMR6 IcB9i6kI8lvL64kGFX6roc0KSoubyzCOYSyb1yW8YPsTFue1XJjGj5EXMgaVuQNZ+/ 3iUEwQFJIoxEqJqSEnoCNlTZftFMF1DY47+V8L1xQrMovgFhjUvmm+H6Og/wBiBk9a 3YhmPZVt+jRMg== 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 48CD9E7719F; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:25:37 +0300 Subject: [PATCH v3 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-v3-3-9ee6520ab69d@gmail.com> References: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@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/SFZeSpU2Mp9WSGNKbt7y6x7/qffH/JYs9JHu/B3S5CZk2Pzf8uMrvC1s49 0Gn8y89OkpZGMS4GGTFFFlsNnrMFssPl5w07akCzBxWJpAhDFycAjCRS/8YGTozdjL070rM1Vba NXtOxewrPh6bYm0fbbw3TybTbP9CaTVGhj1Ht2TeemwR+Njw6LPqIy/TJ0bfKvBdsnG7tteW3c+ 61nADAA== 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:25:38 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: 13936347 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 D93F01B2196; Sun, 12 Jan 2025 12:26:20 +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=1736684781; cv=none; b=ts6E9N3ERVh9tUSdw1eLCaiaLcRk+cxAXZMhH8gHkKxVYv3RaUs48o4mxlmdsBVp30+qM6MmcP/wKElRAUnGbyA/HFwJDIj+36ZQfHIxS3XiW39g6B9j3Y9kxzmonCKoBauxOdspMs6hLGBHggTGRuwNOma89yI6uGTgBHwBQbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736684781; c=relaxed/simple; bh=1BtfBU+VFpnpmflSFDCHod/dke+yeYEpABp6H5TAfhg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qi5qwi2yUififwaHx8B1k/82REn7i3usu/9E7tZIt0StLI7bjkdUWzW29UoTnA0MOWweabuzzdtqT33G/LiGsoNs7EDyMaRN8EQ6HiZeOvS7Fm1ZFRu3oZc9mlrXFAnyZdRvMPdo8sUDkRzYsMZ/XBqfedCer16Qs5cWzgT1Rqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ogsPzAhE; 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="ogsPzAhE" Received: by smtp.kernel.org (Postfix) with ESMTPS id 60E1EC4CEE6; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736684780; bh=1BtfBU+VFpnpmflSFDCHod/dke+yeYEpABp6H5TAfhg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ogsPzAhERDjuPIXsNMc4YvUcD2R2b+JSipAOFLiUpmWd9+Ob51Qwq5frkcSVpDAda fnspzMnwGL8Q2eGoeEIQv8fmFwMSmgMJ0Y1sNRk4spKmpTMXzRdNJ65vcFtdtOTbZ7 KdGwAKNNIbrc2cY+mvqGTaKr0KrzYXL0qq/4rnYDFLH7Kiad3uWN5aym0zSMOBAyW4 3X3BYxdGHfy9njAiV3Of/TJSDoVRcR0zPr3htAwPoU3q+hTX1Vr6TYnRAbQTf5xGRq i61TLFhuaPgbOKKEjinwVprx3gkc440TjJltDXOqbMV8AH1kFYaldOR8l2FRXLSl57 uJDNUlb8wFp4g== 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 58EB2C02181; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:25:38 +0300 Subject: [PATCH v3 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-v3-4-9ee6520ab69d@gmail.com> References: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@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=3869; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=YcfiMUnze8tmhEPaR9oGF3t6Cjv+BkLj5cOU6InNf2c=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbt7yycpC+v7Xr6cdHrae/l09fu/HE6ili/lG/uRNmf NN/NEHasaOUhUGMi0FWTJHFZqPHbLH8cMlJ054qwMxhZQIZwsDFKQATmfmC4RezfEjRtaVXnpir Rn+vd5I2LjPrMLhk+uvmefP165ca7ZvCyHDjnv/jM9dy/r+fdlmvYjvHpp8P3tr/nni7Mt3q0G9 buT4GAA== 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..1b58f3ea50655b6563a78a2531b16a8088e8f8d5 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 mc3230_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 mc3230_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", &mc3230_chip_info }, {} }; MODULE_DEVICE_TABLE(of, mc3230_of_match); From patchwork Sun Jan 12 12:25:39 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: 13936348 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 072ED1B2EFB; Sun, 12 Jan 2025 12:26:20 +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=1736684781; cv=none; b=rUHCC8gHvNdsvO5h9dYzcajNYKdeoDFi9pNLWolfASWiI9xTKsjcjZwvq4TqWjR3l7pJaOv5CzNIIS3cwX/9J3G/lCTf6GUZHbrM8Ni0gcDCOwHLa1HGGJSpLjj+Qm+p1LwcDLSzZOtcB/neFhEfXYjSIl4XxsEHwITIZ+KJkwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736684781; c=relaxed/simple; bh=54TbCEVIqaLsT6+mK26KHcEnUNW3F9y6yj+SI4+oyn4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u6CGpBLEYcIIACNo/SCPqoI8fpdJeYhn2K4eFQ2IlzdgYDrrOki1TLoKR7ErhMn9IxrZApg16qCVDLYaMoXbZCekWHJ+NZa5apjucCMkyPW0gy3AFiZPAF7SVlv17dkvogkuZ8CNwjfpu1YCrRL8a9BRmYHDvXiKLHb0MC/qsbo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O6E8YAwI; 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="O6E8YAwI" Received: by smtp.kernel.org (Postfix) with ESMTPS id 70186C4CEED; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736684780; bh=54TbCEVIqaLsT6+mK26KHcEnUNW3F9y6yj+SI4+oyn4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=O6E8YAwIxCYJuLyKUt6xhHVsxJvl8qvxn9Bso2PZ19sp4xPXtq5/KniyPSpm+S6VZ PnSYxktiHRAMDpOdAZr5d0ddOWUcO2OZXIV/JeDdouBgEdxSOkQT2A7EQbsGsujRz0 4djdQTH33MZl0oNld3mR3UpCbt7nUzFdmq16iSqdhIS3y6CyXaUF2XGEoscBo0ztzh hMp4sKCAGQLd8pNrsBupROFDK/TOjWJN7v9cQxXV5e5fI+DTxghaaTWgjwea8R9V/2 xgH6J6WQ72+FyHcuW/f3N2PQ0w87kSqhvDCoSXQCCgJMBozNUkCopVkg6O5o2CnAvY AzaCCfb+ce3qA== 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 670B4E77188; Sun, 12 Jan 2025 12:26:20 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sun, 12 Jan 2025 15:25:39 +0300 Subject: [PATCH v3 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-v3-5-9ee6520ab69d@gmail.com> References: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@gmail.com> In-Reply-To: <20250112-mainlining-mc3510c-v3-0-9ee6520ab69d@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=1445; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=8NnUIWTvd4feGzNACN4tIbU/CIslPoRvUoNTUHEipMg=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbt7yyUji+dZfq45fBdxmu7yhbtZv3poPu457vmyZo3 JwTa3ltd0cpC4MYF4OsmCKLzUaP2WL54ZKTpj1VgJnDygQyhIGLUwAmsqqKkWFrmQrTofY9AXtl dGtmLmV10j0W1FSVsDhFtYCP+cmLE5MYGS7qntzKMV90ywX3W+8X9KwQUYisFNzyV++h05OlN6c 02TADAA== 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 1b58f3ea50655b6563a78a2531b16a8088e8f8d5..92934975edc77b11ed6dc3da077a28d317314fab 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", &mc3230_chip_info }, + { .compatible = "mcube,mc3510c", &mc3510c_chip_info }, {} }; MODULE_DEVICE_TABLE(of, mc3230_of_match);