From patchwork Wed Dec 9 23:48:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 11962867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E215EC4361B for ; Wed, 9 Dec 2020 23:50:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A855A23B51 for ; Wed, 9 Dec 2020 23:50:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A855A23B51 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WR9u/32rNzLwSIZr2jaHcaLuBIjgrwYVNhyE7+BQBMU=; b=Tb3zWsJLIOJ23e/Ni+IIPxuyN Ey3oKmTpc43SLk5lF303wJgUt5EPuu5SOQaVTTONmnRWc/gqdmppuY2/9u3cxx95Au3gO+kCdRnlk VeBvA3i14PrOvh7GJ9AAlziiFiCoVUOK08P1pIVP1IjzSANgF6cDltRYgYg3XWHXxW3jGdGMZOLL2 H375YsSBnzhR3nk2J0XAXSM+gcgzp4T6NHHjpN73NQc42j3tVu/Hf32eVBoawc/kze0+Ot7frrFne YG5IVF0UcqYsyBWzOILfxj2YLeYjyPdY2LnEB4uHIrCjg3Tu4+188TMR5jYANEV3cB7d5ARWTuiLZ aDV6AWP6w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9Cu-0000NU-OL; Wed, 09 Dec 2020 23:49:16 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9Cm-0000Kx-OF for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 23:49:10 +0000 X-Originating-IP: 86.194.74.19 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 96AC5240006; Wed, 9 Dec 2020 23:49:04 +0000 (UTC) From: Alexandre Belloni To: Jonathan Cameron Subject: [PATCH 1/6] iio:pressure:ms5637: switch to probe_new Date: Thu, 10 Dec 2020 00:48:52 +0100 Message-Id: <20201209234857.1521453-2-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> References: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_184908_922422_414EA8ED X-CRM114-Status: GOOD ( 11.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Alexandre Belloni , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Meerwald-Stadler , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch to the modern i2c probe_new callback and drop the i2c_device_id array. Signed-off-by: Alexandre Belloni --- drivers/iio/pressure/ms5637.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c index 5b59a4137d32..7c3f0ccd917c 100644 --- a/drivers/iio/pressure/ms5637.c +++ b/drivers/iio/pressure/ms5637.c @@ -126,8 +126,7 @@ static const struct iio_info ms5637_info = { .attrs = &ms5637_attribute_group, }; -static int ms5637_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int ms5637_probe(struct i2c_client *client) { struct ms_tp_dev *dev_data; struct iio_dev *indio_dev; @@ -152,7 +151,7 @@ static int ms5637_probe(struct i2c_client *client, mutex_init(&dev_data->lock); indio_dev->info = &ms5637_info; - indio_dev->name = id->name; + indio_dev->name = device_get_match_data(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ms5637_channels; indio_dev->num_channels = ARRAY_SIZE(ms5637_channels); @@ -170,27 +169,17 @@ static int ms5637_probe(struct i2c_client *client, return devm_iio_device_register(&client->dev, indio_dev); } -static const struct i2c_device_id ms5637_id[] = { - {"ms5637", 0}, - {"ms5805", 0}, - {"ms5837", 0}, - {"ms8607-temppressure", 0}, - {} -}; -MODULE_DEVICE_TABLE(i2c, ms5637_id); - static const struct of_device_id ms5637_of_match[] = { - { .compatible = "meas,ms5637", }, - { .compatible = "meas,ms5805", }, - { .compatible = "meas,ms5837", }, - { .compatible = "meas,ms8607-temppressure", }, + { .compatible = "meas,ms5637", .data = "ms5637" }, + { .compatible = "meas,ms5805", .data = "ms5805" }, + { .compatible = "meas,ms5837", .data = "ms5837" }, + { .compatible = "meas,ms8607-temppressure", .data = "ms8607-temppressure" }, { }, }; MODULE_DEVICE_TABLE(of, ms5637_of_match); static struct i2c_driver ms5637_driver = { - .probe = ms5637_probe, - .id_table = ms5637_id, + .probe_new = ms5637_probe, .driver = { .name = "ms5637", .of_match_table = ms5637_of_match, From patchwork Wed Dec 9 23:48:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 11962869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AC03C4167B for ; Wed, 9 Dec 2020 23:50:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0313D23B51 for ; Wed, 9 Dec 2020 23:50:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0313D23B51 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SdTEDe56GaInhl4iQ2vgmg4t0it4Bj8pxx6tF4rmtDM=; b=sgwMD9NTD3/Vx6r4CmZ/6y3xt 7l26TVoDjeKkITC2rkvkxR6vUW9eswphOEAePu/DmxNrSREZWNLV+SVCPK6FVzFcfcuRTj5s65tO8 M/nUxrBUDfIgq1T2bOSaZXWXYvp/C5t/thntH0oIXKYCSJvaCPtaoj77Al/YfPAvpBj88bVtkaqg0 JEiawemp5bJ6HhZ8sMU0+ctJJx+Ov3R4rUjol1q4hTtQqrQLaCcebcGpsFJLyQzwSSvICDkBx2Fl5 lnnKvoffg0oUcpBrjHY9HbRiZY59Vrh1BmwhcfPFap9DFvlNWhLLJBw206+qhZsw9q/dF2oDiA3rZ PiiuWqPwg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9D3-0000ON-AL; Wed, 09 Dec 2020 23:49:25 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9Cn-0000Kw-U0 for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 23:49:11 +0000 X-Originating-IP: 86.194.74.19 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id A7E5D240005; Wed, 9 Dec 2020 23:49:05 +0000 (UTC) From: Alexandre Belloni To: Jonathan Cameron Subject: [PATCH 2/6] iio:pressure:ms5637: introduce hardware differentiation Date: Thu, 10 Dec 2020 00:48:53 +0100 Message-Id: <20201209234857.1521453-3-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> References: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_184910_166760_25ECF907 X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Alexandre Belloni , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Meerwald-Stadler , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some sensors in the ms58xx family have a different PROM length and a different number of available resolution. introduce struct ms_tp_hw_data to handle those differences. Signed-off-by: Alexandre Belloni --- .../iio/common/ms_sensors/ms_sensors_i2c.h | 11 ++++++ drivers/iio/pressure/ms5637.c | 35 +++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/drivers/iio/common/ms_sensors/ms_sensors_i2c.h b/drivers/iio/common/ms_sensors/ms_sensors_i2c.h index bad09c80e47a..f4a88148c113 100644 --- a/drivers/iio/common/ms_sensors/ms_sensors_i2c.h +++ b/drivers/iio/common/ms_sensors/ms_sensors_i2c.h @@ -25,6 +25,16 @@ struct ms_ht_dev { u8 res_index; }; +/** + * struct ms_hw_data - Temperature/Pressure sensor hardware data + * @prom_len: number of words in the PROM + * @max_res_index: maximum sensor resolution index + */ +struct ms_tp_hw_data { + u8 prom_len; + u8 max_res_index; +}; + /** * struct ms_tp_dev - Temperature/Pressure sensor device structure * @client: i2c client @@ -36,6 +46,7 @@ struct ms_ht_dev { struct ms_tp_dev { struct i2c_client *client; struct mutex lock; + const struct ms_tp_hw_data *hw; u16 prom[MS_SENSORS_TP_PROM_WORDS_NB + 1]; u8 res_index; }; diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c index 7c3f0ccd917c..351bfdb24fb4 100644 --- a/drivers/iio/pressure/ms5637.c +++ b/drivers/iio/pressure/ms5637.c @@ -30,6 +30,11 @@ #include "../common/ms_sensors/ms_sensors_i2c.h" +struct ms_tp_data { + const char *name; + const struct ms_tp_hw_data *hw; +}; + static const int ms5637_samp_freq[6] = { 960, 480, 240, 120, 60, 30 }; /* String copy of the above const for readability purpose */ static const char ms5637_show_samp_freq[] = "960 480 240 120 60 30"; @@ -128,6 +133,7 @@ static const struct iio_info ms5637_info = { static int ms5637_probe(struct i2c_client *client) { + const struct ms_tp_data *data = device_get_match_data(&client->dev); struct ms_tp_dev *dev_data; struct iio_dev *indio_dev; int ret; @@ -147,11 +153,12 @@ static int ms5637_probe(struct i2c_client *client) dev_data = iio_priv(indio_dev); dev_data->client = client; - dev_data->res_index = 5; + dev_data->res_index = data->hw->max_res_index; + dev_data->hw = data->hw; mutex_init(&dev_data->lock); indio_dev->info = &ms5637_info; - indio_dev->name = device_get_match_data(&client->dev); + indio_dev->name = data->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ms5637_channels; indio_dev->num_channels = ARRAY_SIZE(ms5637_channels); @@ -169,11 +176,27 @@ static int ms5637_probe(struct i2c_client *client) return devm_iio_device_register(&client->dev, indio_dev); } +static const struct ms_tp_hw_data ms5637_hw_data = { + .prom_len = 7, + .max_res_index = 5 +}; + +static const struct ms_tp_data ms5637_data = { .name = "ms5637", .hw = &ms5637_hw_data }; + +static const struct ms_tp_data ms5805_data = { .name = "ms5805", .hw = &ms5637_hw_data }; + +static const struct ms_tp_data ms5837_data = { .name = "ms5837", .hw = &ms5637_hw_data }; + +static const struct ms_tp_data ms8607_data = { + .name = "ms8607-temppressure", + .hw = &ms5637_hw_data, +}; + static const struct of_device_id ms5637_of_match[] = { - { .compatible = "meas,ms5637", .data = "ms5637" }, - { .compatible = "meas,ms5805", .data = "ms5805" }, - { .compatible = "meas,ms5837", .data = "ms5837" }, - { .compatible = "meas,ms8607-temppressure", .data = "ms8607-temppressure" }, + { .compatible = "meas,ms5637", .data = &ms5637_data }, + { .compatible = "meas,ms5805", .data = &ms5805_data }, + { .compatible = "meas,ms5837", .data = &ms5837_data }, + { .compatible = "meas,ms8607-temppressure", .data = &ms8607_data }, { }, }; MODULE_DEVICE_TABLE(of, ms5637_of_match); From patchwork Wed Dec 9 23:48:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 11962861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 370BAC4167B for ; Wed, 9 Dec 2020 23:50:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F180523B77 for ; Wed, 9 Dec 2020 23:50:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F180523B77 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FZX5TO+zQLQJmqTyleFd+nAzjp8SzJZvrTHTPgz3tqk=; b=1RJzYnzTHgonjRUq8WfBZb7dG J341QdVkb1FVhF5hcH+VE4rgxPPwvljRNlAx+4bjux5guq6wFmqLFU4NcTrNN/DV+3cZPlm3KsqCb gK/MdYDyflHRtnj+42UMb2jqWI3G45hs05Xhno9m6talKtk3MG4OFEmryFfj61TPXz9tCB0+Q9eo4 +Zyji5hrQwtQm4AxvcZVTOvRcKNFsZOiqF5pMzAUjNCikiF+Nk16+02ZUUJZfntdKGXWiaBFwSEXT 94oPvuNxVZ72PqGQe4f7W+4e/zCDDgtgQtxojXUnKPBpVnQ8Re4MDYVOwku4g1lxE+c9bWAsQKTnE iIbnrhCKA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9Cz-0000Nt-86; Wed, 09 Dec 2020 23:49:21 +0000 Received: from relay10.mail.gandi.net ([217.70.178.230]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9Cn-0000Kz-32 for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 23:49:10 +0000 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 6B15C240003; Wed, 9 Dec 2020 23:49:06 +0000 (UTC) From: Alexandre Belloni To: Jonathan Cameron Subject: [PATCH 3/6] iio:pressure:ms5637: limit available sample frequencies Date: Thu, 10 Dec 2020 00:48:54 +0100 Message-Id: <20201209234857.1521453-4-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> References: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_184909_294086_10AA1FD2 X-CRM114-Status: GOOD ( 12.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Alexandre Belloni , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Meerwald-Stadler , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Avoid exposing all the sampling frequencies for chip that only support a subset. Signed-off-by: Alexandre Belloni --- drivers/iio/pressure/ms5637.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c index 351bfdb24fb4..2943b88734b3 100644 --- a/drivers/iio/pressure/ms5637.c +++ b/drivers/iio/pressure/ms5637.c @@ -36,8 +36,19 @@ struct ms_tp_data { }; static const int ms5637_samp_freq[6] = { 960, 480, 240, 120, 60, 30 }; -/* String copy of the above const for readability purpose */ -static const char ms5637_show_samp_freq[] = "960 480 240 120 60 30"; + +static ssize_t ms5637_show_samp_freq(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ms_tp_dev *dev_data = iio_priv(indio_dev); + int i, len = 0; + + for (i = 0; i <= dev_data->hw->max_res_index; i++) + len += scnprintf(buf + len, PAGE_SIZE - len, "%u ", ms5637_samp_freq[i]); + buf[len - 1] = '\n'; + + return len; +} static int ms5637_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *channel, int *val, @@ -114,10 +125,10 @@ static const struct iio_chan_spec ms5637_channels[] = { } }; -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(ms5637_show_samp_freq); +static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(ms5637_show_samp_freq); static struct attribute *ms5637_attributes[] = { - &iio_const_attr_sampling_frequency_available.dev_attr.attr, + &iio_dev_attr_sampling_frequency_available.dev_attr.attr, NULL, }; From patchwork Wed Dec 9 23:48:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 11962859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBBD3C433FE for ; Wed, 9 Dec 2020 23:50:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A095A23B51 for ; Wed, 9 Dec 2020 23:50:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A095A23B51 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MWTPmgyEbWUFT6XZN7Wh1evV/1KSSVPaGCJaRwxvRyM=; b=ON5J6ZuiQmMn8VRenva9Qd4vC bm18GM+7QfQaqUB06igyN9eXKoYg9zsLpfm1uqFwgcdi3AYbJBAgqhqx8fwl/oKEtzd8sjLUNJPgo FlPqOgB52vIArjoqYfgW0CCgafpt3cfjceHe5Nu3DPYNgZGCqArkM6JMC8R8DrLq25b2ruEEVu8Br Kfz9fm/OHzcSk9Qnele3kBuplp7QYIg0DzLbJWVKCvWn9mBFe0Hcm+s/WFL2nZaeMrTcBaz2CXsO0 oCEziLn6nifC9O5NQ6E9BYE9HpW26nPkp3y/+TeFbnHMJOcs8N2I7hEBJ35YnZjgc7O7s4uw18Evz g2tSl0G7Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9Cw-0000Nf-Cl; Wed, 09 Dec 2020 23:49:18 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9Cm-0000LA-RY for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 23:49:10 +0000 X-Originating-IP: 86.194.74.19 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 797F3240007; Wed, 9 Dec 2020 23:49:07 +0000 (UTC) From: Alexandre Belloni To: Jonathan Cameron Subject: [PATCH 4/6] iio:common:ms_sensors:ms_sensors_i2c: rework CRC calculation helper Date: Thu, 10 Dec 2020 00:48:55 +0100 Message-Id: <20201209234857.1521453-5-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> References: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_184909_130620_5095C34D X-CRM114-Status: GOOD ( 15.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Alexandre Belloni , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Meerwald-Stadler , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The CRC calculation always happens on 8 words which is why there is an extra element in the prom array of struct ms_tp_dev. However, on ms5637 and similar, only 7 words are readable. Then, set MS_SENSORS_TP_PROM_WORDS_NB to 8 and stop passing a len parameter to ms_sensors_tp_crc_valid as this simply hide the fact that it is hardcoded. Finally, use the newly introduced hw->prom_len to know how many words can be read. Signed-off-by: Alexandre Belloni --- drivers/iio/common/ms_sensors/ms_sensors_i2c.c | 12 +++++------- drivers/iio/common/ms_sensors/ms_sensors_i2c.h | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/iio/common/ms_sensors/ms_sensors_i2c.c b/drivers/iio/common/ms_sensors/ms_sensors_i2c.c index b9e2038d05ef..872f90459e2e 100644 --- a/drivers/iio/common/ms_sensors/ms_sensors_i2c.c +++ b/drivers/iio/common/ms_sensors/ms_sensors_i2c.c @@ -493,19 +493,18 @@ EXPORT_SYMBOL(ms_sensors_ht_read_humidity); * This function is only used when reading PROM coefficients * * @prom: pointer to PROM coefficients array - * @len: length of PROM coefficients array * * Return: True if CRC is ok. */ -static bool ms_sensors_tp_crc_valid(u16 *prom, u8 len) +static bool ms_sensors_tp_crc_valid(u16 *prom) { unsigned int cnt, n_bit; u16 n_rem = 0x0000, crc_read = prom[0], crc = (*prom & 0xF000) >> 12; - prom[len - 1] = 0; + prom[MS_SENSORS_TP_PROM_WORDS_NB - 1] = 0; prom[0] &= 0x0FFF; /* Clear the CRC computation part */ - for (cnt = 0; cnt < len * 2; cnt++) { + for (cnt = 0; cnt < MS_SENSORS_TP_PROM_WORDS_NB * 2; cnt++) { if (cnt % 2 == 1) n_rem ^= prom[cnt >> 1] & 0x00FF; else @@ -537,7 +536,7 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data) { int i, ret; - for (i = 0; i < MS_SENSORS_TP_PROM_WORDS_NB; i++) { + for (i = 0; i < dev_data->hw->prom_len; i++) { ret = ms_sensors_read_prom_word( dev_data->client, MS_SENSORS_TP_PROM_READ + (i << 1), @@ -547,8 +546,7 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data) return ret; } - if (!ms_sensors_tp_crc_valid(dev_data->prom, - MS_SENSORS_TP_PROM_WORDS_NB + 1)) { + if (!ms_sensors_tp_crc_valid(dev_data->prom)) { dev_err(&dev_data->client->dev, "Calibration coefficients crc check error\n"); return -ENODEV; diff --git a/drivers/iio/common/ms_sensors/ms_sensors_i2c.h b/drivers/iio/common/ms_sensors/ms_sensors_i2c.h index f4a88148c113..f15b973f27c6 100644 --- a/drivers/iio/common/ms_sensors/ms_sensors_i2c.h +++ b/drivers/iio/common/ms_sensors/ms_sensors_i2c.h @@ -11,7 +11,7 @@ #include #include -#define MS_SENSORS_TP_PROM_WORDS_NB 7 +#define MS_SENSORS_TP_PROM_WORDS_NB 8 /** * struct ms_ht_dev - Humidity/Temperature sensor device structure @@ -47,7 +47,7 @@ struct ms_tp_dev { struct i2c_client *client; struct mutex lock; const struct ms_tp_hw_data *hw; - u16 prom[MS_SENSORS_TP_PROM_WORDS_NB + 1]; + u16 prom[MS_SENSORS_TP_PROM_WORDS_NB]; u8 res_index; }; From patchwork Wed Dec 9 23:48:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 11962865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 885A9C433FE for ; Wed, 9 Dec 2020 23:50:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52B9623B53 for ; Wed, 9 Dec 2020 23:50:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52B9623B53 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vp+VuaEiCORm+wrbaF2N1f8hp76Yubm2LDK4OyXyGTg=; b=IQp7xRNYN8Xuza9cyDQiHRiJJ N874BB1MBClaP7mu5gI6/gGH1enXAkf4Q33PEi9OqWL5M3dIvL+zCm3L7lzAMX/Nh0xzBQ7IB2Tvn r5MAuJk2Hqv+6bGCOX+whSO4gpNXThdYmynMXgDTOt2aPQNIAD731AyUb86beszHTbBGNEFFE/P50 VvQEve4TFkjGGckxZkFye6GuIxc2RCg3VXWZI4ECtuIht/NYpVylv1p3umYjxXzQWVhDLemGhtzGO xzn+B0uGZv7RppjxypslLjCPi98D7H9fLqX9gNgwE25WkOS6AG9xStOXYxdPGe802Q83jbQg0VVqi dYPV1+z5A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9D1-0000O9-I1; Wed, 09 Dec 2020 23:49:23 +0000 Received: from relay10.mail.gandi.net ([217.70.178.230]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9Cn-0000LE-IF for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 23:49:11 +0000 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 33C72240004; Wed, 9 Dec 2020 23:49:08 +0000 (UTC) From: Alexandre Belloni To: Jonathan Cameron Subject: [PATCH 5/6] iio:common:ms_sensors:ms_sensors_i2c: add support for alternative PROM layout Date: Thu, 10 Dec 2020 00:48:56 +0100 Message-Id: <20201209234857.1521453-6-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> References: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_184909_834325_A3EC34F9 X-CRM114-Status: GOOD ( 16.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Alexandre Belloni , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Meerwald-Stadler , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, only the 112bit PROM on 7 words is supported. However the ms58xx family also have devices with a 128bit PROM on 8 words. See AN520: C-CODE EXAMPLE FOR MS56XX, MS57XX (EXCEPT ANALOG SENSOR), AND MS58XX SERIES PRESSURE SENSORS and the various device datasheets. The difference is that the CRC is the 4 LSBs of word7 instead of being the 4 MSBs of word0. Signed-off-by: Alexandre Belloni --- .../iio/common/ms_sensors/ms_sensors_i2c.c | 70 ++++++++++++++++--- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/drivers/iio/common/ms_sensors/ms_sensors_i2c.c b/drivers/iio/common/ms_sensors/ms_sensors_i2c.c index 872f90459e2e..d97ca3e1b1d7 100644 --- a/drivers/iio/common/ms_sensors/ms_sensors_i2c.c +++ b/drivers/iio/common/ms_sensors/ms_sensors_i2c.c @@ -488,21 +488,18 @@ int ms_sensors_ht_read_humidity(struct ms_ht_dev *dev_data, EXPORT_SYMBOL(ms_sensors_ht_read_humidity); /** - * ms_sensors_tp_crc_valid() - CRC check function for + * ms_sensors_tp_crc4() - Calculate PROM CRC for * Temperature and pressure devices. * This function is only used when reading PROM coefficients * * @prom: pointer to PROM coefficients array * - * Return: True if CRC is ok. + * Return: CRC. */ -static bool ms_sensors_tp_crc_valid(u16 *prom) +static u8 ms_sensors_tp_crc4(u16 *prom) { unsigned int cnt, n_bit; - u16 n_rem = 0x0000, crc_read = prom[0], crc = (*prom & 0xF000) >> 12; - - prom[MS_SENSORS_TP_PROM_WORDS_NB - 1] = 0; - prom[0] &= 0x0FFF; /* Clear the CRC computation part */ + u16 n_rem = 0x0000; for (cnt = 0; cnt < MS_SENSORS_TP_PROM_WORDS_NB * 2; cnt++) { if (cnt % 2 == 1) @@ -517,10 +514,55 @@ static bool ms_sensors_tp_crc_valid(u16 *prom) n_rem <<= 1; } } - n_rem >>= 12; - prom[0] = crc_read; - return n_rem == crc; + return n_rem >> 12; +} + +/** + * ms_sensors_tp_crc_valid_112() - CRC check function for + * Temperature and pressure devices for 112bit PROM. + * This function is only used when reading PROM coefficients + * + * @prom: pointer to PROM coefficients array + * + * Return: CRC. + */ +static bool ms_sensors_tp_crc_valid_112(u16 *prom) +{ + u16 w0 = prom[0], crc_read = (w0 & 0xF000) >> 12; + u8 crc; + + prom[0] &= 0x0FFF; /* Clear the CRC computation part */ + prom[MS_SENSORS_TP_PROM_WORDS_NB - 1] = 0; + + crc = ms_sensors_tp_crc4(prom); + + prom[0] = w0; + + return crc == crc_read; +} + +/** + * ms_sensors_tp_crc_valid_128() - CRC check function for + * Temperature and pressure devices for 128bit PROM. + * This function is only used when reading PROM coefficients + * + * @prom: pointer to PROM coefficients array + * + * Return: CRC. + */ +static bool ms_sensors_tp_crc_valid_128(u16 *prom) +{ + u16 w7 = prom[7], crc_read = w7 & 0x000F; + u8 crc; + + prom[7] &= 0xFF00; /* Clear the CRC and LSB part */ + + crc = ms_sensors_tp_crc4(prom); + + prom[7] = w7; + + return crc == crc_read; } /** @@ -535,6 +577,7 @@ static bool ms_sensors_tp_crc_valid(u16 *prom) int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data) { int i, ret; + bool valid; for (i = 0; i < dev_data->hw->prom_len; i++) { ret = ms_sensors_read_prom_word( @@ -546,7 +589,12 @@ int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data) return ret; } - if (!ms_sensors_tp_crc_valid(dev_data->prom)) { + if (dev_data->hw->prom_len == 8) + valid = ms_sensors_tp_crc_valid_128(dev_data->prom); + else + valid = ms_sensors_tp_crc_valid_112(dev_data->prom); + + if (!valid) { dev_err(&dev_data->client->dev, "Calibration coefficients crc check error\n"); return -ENODEV; From patchwork Wed Dec 9 23:48:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 11962857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E291C4361B for ; Wed, 9 Dec 2020 23:50:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD70D23B51 for ; Wed, 9 Dec 2020 23:50:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD70D23B51 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wTkke53AUUo8FFOiLgwJbnJSHTVkGZnpLkEH7RGoVds=; b=TYxgDLTBl6HOc+TveQIC46RBx w8o/d5oY24D7UVTUdWRpyD5soFfgZqnAQYkDCXPGFibJWwNgr4fOolUxY+jV8d1tWu5kokDQ8vVEv mF4Un0m+nJ+TSBb72UgL1ag3yRe2FdqlGH59OpK3wHuU3osTJ6DDwfmY4U1qUl/UTd0Y+rL4C+yvD rymEpqTKLjbesvezMIkT4Pg+J5RbzTb321Owwpy4uxxqOpsinI5Luv5/+1RhyVJqMxWqOdlecl3fF 0RHrE/iX+qnDx4tMx9zAcWflB50iYymqvnD3Vhr9+t1tOaBL2M4wMRV7WZnl4KSPBsCnSFA4j/X5m k4ZhW8dzA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9D7-0000Of-AB; Wed, 09 Dec 2020 23:49:29 +0000 Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn9Cq-0000Mj-Jn for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 23:49:13 +0000 X-Originating-IP: 86.194.74.19 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 122A2C0008; Wed, 9 Dec 2020 23:49:08 +0000 (UTC) From: Alexandre Belloni To: Jonathan Cameron Subject: [PATCH 6/6] iio:pressure:ms5637: add ms5803 support Date: Thu, 10 Dec 2020 00:48:57 +0100 Message-Id: <20201209234857.1521453-7-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> References: <20201209234857.1521453-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_184912_798570_FC699737 X-CRM114-Status: GOOD ( 12.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Alexandre Belloni , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Peter Meerwald-Stadler , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The ms5803 is very similar to the ms5805 but has less resolution options and has the 128bit PROM layout. Cc: Rob Herring Signed-off-by: Alexandre Belloni --- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ drivers/iio/pressure/ms5637.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index ab623ba930d5..84b0e44235c1 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -132,6 +132,8 @@ properties: - mcube,mc3230 # MEMSIC 2-axis 8-bit digital accelerometer - memsic,mxc6225 + # Measurement Specialities I2C pressure and temperature sensor + - meas,ms5803 # Microchip differential I2C ADC, 1 Channel, 18 bit - microchip,mcp3421 # Microchip differential I2C ADC, 2 Channel, 18 bit diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c index 2943b88734b3..39830a51ca78 100644 --- a/drivers/iio/pressure/ms5637.c +++ b/drivers/iio/pressure/ms5637.c @@ -192,8 +192,15 @@ static const struct ms_tp_hw_data ms5637_hw_data = { .max_res_index = 5 }; +static const struct ms_tp_hw_data ms5803_hw_data = { + .prom_len = 8, + .max_res_index = 4 +}; + static const struct ms_tp_data ms5637_data = { .name = "ms5637", .hw = &ms5637_hw_data }; +static const struct ms_tp_data ms5803_data = { .name = "ms5803", .hw = &ms5803_hw_data }; + static const struct ms_tp_data ms5805_data = { .name = "ms5805", .hw = &ms5637_hw_data }; static const struct ms_tp_data ms5837_data = { .name = "ms5837", .hw = &ms5637_hw_data }; @@ -205,6 +212,7 @@ static const struct ms_tp_data ms8607_data = { static const struct of_device_id ms5637_of_match[] = { { .compatible = "meas,ms5637", .data = &ms5637_data }, + { .compatible = "meas,ms5803", .data = &ms5803_data }, { .compatible = "meas,ms5805", .data = &ms5805_data }, { .compatible = "meas,ms5837", .data = &ms5837_data }, { .compatible = "meas,ms8607-temppressure", .data = &ms8607_data },