From patchwork Sat Jan 11 20:11: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: 13936170 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 F20091917EE; Sat, 11 Jan 2025 20:11:09 +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=1736626270; cv=none; b=johFIzbb0KHE55uTBKoPlcUq/SGVFRiwshv5EsKdbeO/GXH12QQ5KJzecTZLADDMTiNaXdhMCOkjDCYA7AUM0i4ayXQEGdb9soxHUjNMRX0S4svhQg4X3Fu+cPwXUh/D2j462K217p8Wa/Ns7Hn++FdfaCh6DRcQ8czNaXATbrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736626270; c=relaxed/simple; bh=2oDcjsM+xls74geaRGU02rSgJmLqWyUNLZxVDoUzLvM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DUuZFLt+6H6Q3QSQjLzOVl1IUNJcvwZtfIkms+1MCzX/2FG6UD9/8ym0WsWiPcy/SsMzKEsuSq808kj0mzR6RsiXH0itNQmtddUGZWTSOysruPDTem1vudW1PPWqOOz4w8bZI4UTPXOCAlTuLmqiGqRqCLuXHOlA/w+0OmBYZ5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WGLaycdl; 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="WGLaycdl" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8CBBBC4CEDD; Sat, 11 Jan 2025 20:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736626269; bh=2oDcjsM+xls74geaRGU02rSgJmLqWyUNLZxVDoUzLvM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=WGLaycdlqyagkfWUliXhmo3tkLPKeI5Ub5nvxTSFpobG7bLLyhgA76aTuoF44+Ig4 akUZKP5vEn2o6mG/83OTVwoCsTwBW9fNiv2abc/kQHMuQ7+DO1vpqXUDsJTos7tvmm rW82dh9VHPmcYuQ6l26xyJM48HEVgiRyOVs2DS7HQUmiw5LUNVh9PdeAyFVUyxmR6c 5h3riuNq5GP1Q2C1djO8agwzSNYakkmSGuTBIe02rXgug/GxZHmGJ9ZIOTIrMXKgtj WdvvaaNRSKn+mtKdOLq1go8D0uJV7wksVYNcmCjtOZoIo1vppYwvRMMFBhXlGkYSEF 3HV2wiKI0e7YA== 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 85E81E7719D; Sat, 11 Jan 2025 20:11:09 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sat, 11 Jan 2025 23:11:06 +0300 Subject: [PATCH 1/4] 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: <20250111-mainlining-mc3510c-v1-1-57be503addf8@gmail.com> References: <20250111-mainlining-mc3510c-v1-0-57be503addf8@gmail.com> In-Reply-To: <20250111-mainlining-mc3510c-v1-0-57be503addf8@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=1924; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=SGUB0nJOPTqbOxbqJuC0hqRrN0BrPCLKg3CTaKtvEKI=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbLkQvLdgbGqH+9fl9rY+7ph9zeG60gzcj4l1454sze /84mMmxdZSyMIhxMciKKbLYbPSYLZYfLjlp2lMFmDmsTCBDGLg4BWAi+xkZGf4HnbWQn+UlWXgg 7ZO5/NuWf0e9T4mf63SR1rvI+WnpyuOMDN2Zx99ofFyts2T9Nb51Apr+Tb/XBQav327bL6m96Gj /dnYA 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..48787c0494ae6f0ef1d4d22bc5a4608035cbe123 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 Sat Jan 11 20:11:07 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: 13936169 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 D25FC17C68; Sat, 11 Jan 2025 20:11:09 +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=1736626269; cv=none; b=eFpfyUeyhFCpmze+qvtiGgdlmfO7gC+EDx6VXtFaCohDQsk9eVmKlmKaguCi9XmN6G7r8YIa7kmKI3RHsJT4caGHGwxOQgHByqmnRVEQol0tR8qfndfPkXsUPSnyzSA5cuyEeYrwyJv3cu1tJNAaAKRKgmTHgJPqOc7gLdi6WHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736626269; c=relaxed/simple; bh=5ckJwbgDkVzT0dqCQsFQCmmS29DfhOI72BOq4ZYsdFI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qoGcUCwIyUdUQ6yQej8uQd165hOSP4TnCUNAMtwNdUD8EwSBSBM4ZX4+bxQCr/AXFvni0KS8NZWZJYTs2JZfzE4VrxfmFoJa82uyiRyb76x9KS08qlizuU+kPyzuPEafTftMXcJ7ftS1jMCcxtPOoPhilgzhrzO9WnHC7RqZsuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WxZ+DqVO; 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="WxZ+DqVO" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9DF2FC4CEE2; Sat, 11 Jan 2025 20:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736626269; bh=5ckJwbgDkVzT0dqCQsFQCmmS29DfhOI72BOq4ZYsdFI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=WxZ+DqVOkdn0NNomRCrUyRQ1TgVJ2m/YwmKyzNJNuBnB51XC01/B966jTqBh/FMO/ ZphAuN6MJ9dMRdchUOV3qVP5O8tgaYVWEqDbyT5uNWhcPTLPbsvMQOUAPVwQi26Kdq cdGGfZUAaBtMsl/+42TK95yVPEKqv0mqmBwsXcts2/o9aQzMLjArUcdm4TSxs29IDK x8kgJph0g2TJ8g+FardVeQTc+qriY5paSmUale6Y8D19oH3aIzPtIFSh+4e62MqcWs VIVIVu82ACWTtbnIkWsinpWUYV4XnWTlcLILL5T32B9X3pUrFMIFBl4WtxX8vMheJt YJgi/aowc0eoQ== 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 975FFE7719E; Sat, 11 Jan 2025 20:11:09 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sat, 11 Jan 2025 23:11:07 +0300 Subject: [PATCH 2/4] 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: <20250111-mainlining-mc3510c-v1-2-57be503addf8@gmail.com> References: <20250111-mainlining-mc3510c-v1-0-57be503addf8@gmail.com> In-Reply-To: <20250111-mainlining-mc3510c-v1-0-57be503addf8@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=1074; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=7FltGDA7Coxid4ukNBq4MOgPx0ilGEOInxc3SWRtDZo=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbLkQXqk604ZqZ3uD3w+n9O5OpE+e7r5Y7UG8U2vfKb NGhgqRVHaUsDGJcDLJiiiw2Gz1mi+WHS06a9lQBZg4rE8gQBi5OAZgI7wFGhs+ZeXaLuH+/9zb+ 9jhy6Y16dv6WzU6hE/at1V/V+uX5Q19Ghovsls9ktq6dIb/xb/R2jfRGqxlSwpN0GF1Pybbe3r+ PnxEA 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 probe-able via device-tree. While the I2C match table may be sufficient, this should extend the cover of this driver being probed by other methods. 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 48787c0494ae6f0ef1d4d22bc5a4608035cbe123..3cad6f2d7a2a79df38f90e5656763f6ed019a920 100644 --- a/drivers/iio/accel/mc3230.c +++ b/drivers/iio/accel/mc3230.c @@ -205,10 +205,17 @@ 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", .pm = pm_sleep_ptr(&mc3230_pm_ops), + .of_match_table = mc3230_of_match, }, .probe = mc3230_probe, .remove = mc3230_remove, From patchwork Sat Jan 11 20:11:08 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: 13936173 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 149931B85CC; Sat, 11 Jan 2025 20:11:09 +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=1736626270; cv=none; b=iV9nE9LWUsank2UXISvj7+gjjpEWTKOvBXmOKNeYuik+xXl1l1JyD5jl8TqeFYsvU1avnEgAj1fOmHwcnb2jc36FGqtWTzR74Jsfu3eAroko6jSsYD/LVEROq1pZt4gLryngX0NjSU5Y7oUwb0aBnObORLXio6KCeatkGY3DhZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736626270; c=relaxed/simple; bh=zHENJgA45YYkFLL0ldE4wCLz8XeAFTgRqKHUY79HGiw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=emxPSUvEnMI7TX3zFIfFl0pZLLpShr1MtpPuehPYTd4nMO9dwm55ZxKdlA3MslnvioKh5lflaGuINETZy9vH5R6+05jdNXbzIGqql2JkFCFK4xQHSgX99k6yX7Dobc671UEm0x/4UjXhurO5o5TgezXwgWj6KTKGqUdXxIQfzCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DeGOLksy; 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="DeGOLksy" Received: by smtp.kernel.org (Postfix) with ESMTPS id AF269C4CEE3; Sat, 11 Jan 2025 20:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736626269; bh=zHENJgA45YYkFLL0ldE4wCLz8XeAFTgRqKHUY79HGiw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=DeGOLksy0TY24bt+xBPEz/Lk5QF2zS4NnDvTlxmjANlRShk/tbQs9FOhpKlycG9ev 1FpECt5Act7q2nve7S8bj9tHKZNGgnlRuV+nRl8I2XzWjXZpXmu281foF9Iup2eCIp NbuXL8h36ic1pZT7j+80ZBcsr4JqKO8rPpR28OdxkpjonioaEI3dgm1wcEkGVPgUcI nG2cyNBatTTTfaN4aZzMP21tfFvjukyWhc8DxWwNg5RVozA/k+7VhZmMuIrvXnzXSl 84wiAENNYHd3RCfCbJSVr53ylV4GoCcIIMfembbyALFgBRMMbKQkeDSxKv3GyxandZ mG6blifU/eQEQ== 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 A3D84E7719C; Sat, 11 Jan 2025 20:11:09 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sat, 11 Jan 2025 23:11:08 +0300 Subject: [PATCH 3/4] 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: <20250111-mainlining-mc3510c-v1-3-57be503addf8@gmail.com> References: <20250111-mainlining-mc3510c-v1-0-57be503addf8@gmail.com> In-Reply-To: <20250111-mainlining-mc3510c-v1-0-57be503addf8@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=4230; i=nekodevelopper@gmail.com; h=from:subject:message-id; bh=ydt9wEg9ZXDn59JTji5alQyxsHpWkyrwV3RCLRJDzSw=; b=owGbwMvMwCW2fZ/SFZeSpU2Mp9WSGNKbLkSv8WDsmtnCctluzwWfmPsNlj43JBmLuS68dWgNO ZHL9pm3o5SFQYyLQVZMkcVmo8dssfxwyUnTnirAzGFlAhnCwMUpABNRcmJkmNe8NarpU7i1z5lT yUaMH55EirO+1jQ8aHPHItstXUZRh5FhZxyzWfO602aPr0zsko3V5Z13pGD5c6/dMxnfsi18yzO JAwA= 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 | 55 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c index 3cad6f2d7a2a79df38f90e5656763f6ed019a920..ebbb96c658d87a83007c7c3c7212ce9ebf039963 100644 --- a/drivers/iio/accel/mc3230.c +++ b/drivers/iio/accel/mc3230.c @@ -22,20 +22,41 @@ #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; +enum mc3xxx_chips { + MC3230, + MC3510C, +}; + +struct mc3xxx_chip_info { + const char *name; + const u8 chip_id; + const u8 product_code; + const int scale; +}; + +static struct mc3xxx_chip_info mc3xxx_chip_info_tbl[] = { + [MC3230] = { + .name = "mc3230", + .chip_id = 0x01, + .product_code = 0x19, + .scale = 115411765, // (1.5 + 1.5) * 9.81 / (2^8 - 1) = 0.115411765 + }, + [MC3510C] = { + .name = "mc3510c", + .chip_id = 0x23, + .product_code = 0x10, + .scale = 625000000, // Was obtained empirically + }, +}; #define MC3230_CHANNEL(reg, axis) { \ .type = IIO_ACCEL, \ @@ -50,6 +71,7 @@ static const int mc3230_nscale = 115411765; struct mc3230_data { struct i2c_client *client; struct iio_mount_matrix orientation; + const struct mc3xxx_chip_info *chip_info; }; static const struct iio_mount_matrix * @@ -111,7 +133,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 +149,23 @@ 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); /* First check chip-id and product-id */ ret = i2c_smbus_read_byte_data(client, MC3230_REG_CHIP_ID); - if (ret != MC3230_CHIP_ID) + if (ret != chip_info->chip_id) { + dev_err(&client->dev, + "chip id check fail: 0x%x != 0x%x !\n", ret, chip_info->chip_id); return (ret < 0) ? ret : -ENODEV; + } ret = i2c_smbus_read_byte_data(client, MC3230_REG_PRODUCT_CODE); - if (ret != MC3230_PRODUCT_CODE) + if (ret != chip_info->product_code) { + dev_err(&client->dev, + "product code check fail: 0x%x != 0x%x !\n", ret, chip_info->product_code); return (ret < 0) ? ret : -ENODEV; + } indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) { @@ -145,10 +175,11 @@ static int mc3230_probe(struct i2c_client *client) data = iio_priv(indio_dev); data->client = client; + data->chip_info = chip_info; 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 +231,15 @@ 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)&mc3xxx_chip_info_tbl[MC3230] }, + { "mc3510c", (kernel_ulong_t)&mc3xxx_chip_info_tbl[MC3510C] }, {} }; MODULE_DEVICE_TABLE(i2c, mc3230_i2c_id); static const struct of_device_id mc3230_of_match[] = { - { .compatible = "mcube,mc3230" }, + { .compatible = "mcube,mc3230", &mc3xxx_chip_info_tbl[MC3230] }, + { .compatible = "mcube,mc3510c", &mc3xxx_chip_info_tbl[MC3510C] }, { }, }; MODULE_DEVICE_TABLE(of, mc3230_of_match); From patchwork Sat Jan 11 20:11:09 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: 13936172 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 149121B85CB; Sat, 11 Jan 2025 20:11:09 +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=1736626270; cv=none; b=YT86GSPyzPBUWh0HDtrjU3Y+0RQ8QtBtOrsdI8uAp4ImakrUZQCngvXJwHeKhrzuW5miRFI+3eLzaeMYPDbqn0mOoWSVHye4kudkYiNngD2i60a6/FWX6Ndgz84H4S3ROvYbqe5t5SH2PES163oWCFOrk5e/maJaEjLi6tS8b3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736626270; c=relaxed/simple; bh=/2wNdRw+WQbyfxQS3NklGacoKVAmlCPk/EFYLbVlOVE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i2m0EYHqrNhD2GajTg4rktAvM6b/ZhZj+fMTqAxdIi1DI8EAtkTRPu1FARC9nUWOAj2/N6Z3PvUrRubRSZaHJyb9wqUi2dAfaX9VPb/93dk1I1dtksm6HUBTBFYRPE6ua0xE3+Ddf5t7VGmyXqLZWu+4pjVSqcHP5bE/6C9BzbI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=quhuDFdX; 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="quhuDFdX" Received: by smtp.kernel.org (Postfix) with ESMTPS id BA90CC4CEE7; Sat, 11 Jan 2025 20:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736626269; bh=/2wNdRw+WQbyfxQS3NklGacoKVAmlCPk/EFYLbVlOVE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=quhuDFdXm935tAIfZUbbP1pHprbefv8JwvifUY/5dwV35T6MjGTPq1byVml5GaPGv TvTRLyODaLKqLfBiUJ5nwkITscfQB4L1ApjDEbuV/JrBmkzlFysOrCTgHYoml+SqF/ ttyN09S8GN3GCDsR4jsxX9AORLNSCZwku7Jnl7az2xh5Ee+ubgvKQ+wyNhONfOJ+pE IF+biYeyDC3FCMVKsC3hvCxHBp8xL9RCbgLf3fUAQi3TlBfR+kc9LE3S1/5dyTUV5E AvialTwMJ5+Q1Hs7bH1YQYDMaBZqT6FarWcvEcQclIf17HoKBsSEKE53MNDmggv+6Y lCBz8sN1lxqIA== 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 B2C03E7719A; Sat, 11 Jan 2025 20:11:09 +0000 (UTC) From: Vasiliy Doylov via B4 Relay Date: Sat, 11 Jan 2025 23:11:09 +0300 Subject: [PATCH 4/4] 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: <20250111-mainlining-mc3510c-v1-4-57be503addf8@gmail.com> References: <20250111-mainlining-mc3510c-v1-0-57be503addf8@gmail.com> In-Reply-To: <20250111-mainlining-mc3510c-v1-0-57be503addf8@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/SFZeSpU2Mp9WSGNKbLsRsbOf57LUpY1Gc8NOvEnNuVggs/qV4PsKL5f6mi bJqZisPdpSyMIhxMciKKbLYbPSYLZYfLjlp2lMFmDmsTCBDGLg4BWAiEQyMDC8Z1PhlP+yUbotb ZJYgo3bTQ3CiooDiZnc/211fAuXEtBgZ5gkvzPVpmpmaxx9378CsxprO5XYrJtXcUbP9OOt9h0I WGwA= 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