From patchwork Wed May 26 09:44:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 12281123 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 E0E06C47088 for ; Wed, 26 May 2021 09:44:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFCFA61432 for ; Wed, 26 May 2021 09:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233490AbhEZJp6 (ORCPT ); Wed, 26 May 2021 05:45:58 -0400 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.54]:33196 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233459AbhEZJp5 (ORCPT ); Wed, 26 May 2021 05:45:57 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1622022265; cv=none; d=strato.com; s=strato-dkim-0002; b=dJaORiynPBuvkjAWsqcMzg6v86lDxZ7MA5lLqZSlAf9GDRCfB8BkPd2Cdlc8g0cXe0 9OoDJNeYChpjowAbohHhx0xItnjNhzhXXCUkhyWMM/NlRYKZXB/qW5Uq4wwRutt06Ux7 gnYVJTd96DgkAWmtjt04a9V9it47gasb1U/8SliFHQ4N6qGvhnjI/Ghq14hEUb/tuRLW HUSd+jRp39l2VUWg51/QOv58eMKcAUksKdtnkl57E+NygCgJ0LA15kI0U3trhmyWrZht AO+NyoMLhNYqQgU8lyfYNmQS1/qJf5rbuPbbnHBSkXdTB3u0ihbqeMOic6XX/SpWvGAJ EEyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1622022265; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=H9Fct0num8/7BbmsVgTLiFgWIuT2Rte5NxqkRkhm974=; b=GBuZ+MmrYvpoX+poCek6m93ufIWF4nWmGCKn+2LUzD1XuABl08RS/8kwvQPNlo537p 9SO3M88nQpGpOPX3rDuqyuG6Q0o+Ymz/yv929ijWP7b298uFiZRJQAwF6tcAJkqTGEOC G32mQeBL/77KR1mi9TVm7N165kTum3u2m/OCl0Owa3XerBjwtKxMiUMbzPe9XQJ5aBW4 KjtCg/4H9mvdfXYLZnMjvh3T370RP9d/rbEXnNk5SwTnbrzKqS1Q0xuzTBmtnwnmN7SB BPvOW87pqA5DfHzcIThCoiUyymqRKqAx9le369QY8DRcarIIW2plt8GVoZ+5eoeHxNEj MW/g== ARC-Authentication-Results: i=1; strato.com; dkim=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1622022265; s=strato-dkim-0002; d=gerhold.net; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=H9Fct0num8/7BbmsVgTLiFgWIuT2Rte5NxqkRkhm974=; b=fnBbfxUIH7CSQZt9IPSKbs+qmkFcERQqrufqfUFVJRji9AYXnwLBFgIrcfD10fO/8e euL3uw4av5jQ+E3sKSUwfjGFbXlAC4vDdCT0Yo5m3GIw+iyxOTrXOnEskaBrvVrtHTvn aH9JHKLgPr14js0aG9LHVvBxoivwS+OgrdeWbTIJO92JhGaNSjl2dulh9kaRHz8vrcqX JMupuOaB44+gmdfts5+T3id36/c2BG99KKZgPjJPUzHW2Dqp14P4/ov1VDlVXmH4tYbh pwK/RD9iuSudBNwvIYNWQg+h9UKtHABzUEgXIANI4xvVUgPzzmhSyzQemxXK6BCoFNOd JXRw== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXS7IYBkLahKxB4W6JG0s=" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.26.2 DYNA|AUTH) with ESMTPSA id w02ed1x4Q9iO6KA (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 26 May 2021 11:44:24 +0200 (CEST) From: Stephan Gerhold To: Jonathan Cameron Cc: Lars-Peter Clausen , Linus Walleij , Peter Meerwald , linux-iio@vger.kernel.org, Stephan Gerhold Subject: [PATCH 1/2] iio: accel: bma180: Fix BMA25x bandwidth register values Date: Wed, 26 May 2021 11:44:07 +0200 Message-Id: <20210526094408.34298-2-stephan@gerhold.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526094408.34298-1-stephan@gerhold.net> References: <20210526094408.34298-1-stephan@gerhold.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org According to the BMA253 datasheet [1] and BMA250 datasheet [2] the bandwidth value for BMA25x should be set as 01xxx: "Settings 00xxx result in a bandwidth of 7.81 Hz; [...] It is recommended [...] to use the range from ´01000b´ to ´01111b´ only in order to be compatible with future products." However, at the moment the drivers sets bandwidth values from 0 to 6, which is not recommended and always results into 7.81 Hz bandwidth according to the datasheet. Fix this by introducing a bw_offset = 8 = 01000b for BMA25x, so the additional bit is always set for BMA25x. [1]: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bma253-ds000.pdf [2]: https://datasheet.octopart.com/BMA250-Bosch-datasheet-15540103.pdf Cc: Peter Meerwald Cc: Linus Walleij Fixes: 2017cff24cc0 ("iio:bma180: Add BMA250 chip support") Signed-off-by: Stephan Gerhold Reviewed-by: Linus Walleij --- After spending some more time with the driver I noticed that BMA253/BMA254 would actually be better supported by the bmc150-accel driver (which doesn't have this problem and also supports the motion trigger/interrupt). I'm preparing a separate patch set to move BMA254 to bmc150-accel at least, but I'm not sure about BMA250 so this patch is relevant anyway. And I had it almost done already, so I thought it's better to send it. :) --- drivers/iio/accel/bma180.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 97e991581960..81d1e070a2ee 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -55,7 +55,7 @@ struct bma180_part_info { u8 int_reset_reg, int_reset_mask; u8 sleep_reg, sleep_mask; - u8 bw_reg, bw_mask; + u8 bw_reg, bw_mask, bw_offset; u8 scale_reg, scale_mask; u8 power_reg, power_mask, lowpower_val; u8 int_enable_reg, int_enable_mask; @@ -127,6 +127,7 @@ struct bma180_part_info { #define BMA250_RANGE_MASK GENMASK(3, 0) /* Range of accel values */ #define BMA250_BW_MASK GENMASK(4, 0) /* Accel bandwidth */ +#define BMA250_BW_OFFSET 8 #define BMA250_SUSPEND_MASK BIT(7) /* chip will sleep */ #define BMA250_LOWPOWER_MASK BIT(6) #define BMA250_DATA_INTEN_MASK BIT(4) @@ -143,6 +144,7 @@ struct bma180_part_info { #define BMA254_RANGE_MASK GENMASK(3, 0) /* Range of accel values */ #define BMA254_BW_MASK GENMASK(4, 0) /* Accel bandwidth */ +#define BMA254_BW_OFFSET 8 #define BMA254_SUSPEND_MASK BIT(7) /* chip will sleep */ #define BMA254_LOWPOWER_MASK BIT(6) #define BMA254_DATA_INTEN_MASK BIT(4) @@ -287,7 +289,8 @@ static int bma180_set_bw(struct bma180_data *data, int val) for (i = 0; i < data->part_info->num_bw; ++i) { if (data->part_info->bw_table[i] == val) { ret = bma180_set_bits(data, data->part_info->bw_reg, - data->part_info->bw_mask, i); + data->part_info->bw_mask, + i + data->part_info->bw_offset); if (ret) { dev_err(&data->client->dev, "failed to set bandwidth\n"); @@ -880,6 +883,7 @@ static const struct bma180_part_info bma180_part_info[] = { .sleep_mask = BMA250_SUSPEND_MASK, .bw_reg = BMA250_BW_REG, .bw_mask = BMA250_BW_MASK, + .bw_offset = BMA250_BW_OFFSET, .scale_reg = BMA250_RANGE_REG, .scale_mask = BMA250_RANGE_MASK, .power_reg = BMA250_POWER_REG, @@ -909,6 +913,7 @@ static const struct bma180_part_info bma180_part_info[] = { .sleep_mask = BMA254_SUSPEND_MASK, .bw_reg = BMA254_BW_REG, .bw_mask = BMA254_BW_MASK, + .bw_offset = BMA254_BW_OFFSET, .scale_reg = BMA254_RANGE_REG, .scale_mask = BMA254_RANGE_MASK, .power_reg = BMA254_POWER_REG, From patchwork Wed May 26 09:44:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 12281125 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 D0736C2B9F7 for ; Wed, 26 May 2021 09:44:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A960361417 for ; Wed, 26 May 2021 09:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233491AbhEZJp6 (ORCPT ); Wed, 26 May 2021 05:45:58 -0400 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.50]:19383 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233490AbhEZJp5 (ORCPT ); Wed, 26 May 2021 05:45:57 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1622022265; cv=none; d=strato.com; s=strato-dkim-0002; b=fXar1epYPpne9MpJy++t97IHoBGkHrdG8TlVT2DAvmzg/7CsWbegqk2joM5NzbySQ1 +CPJL09KfcBVQvlHmFsFwVdNEc05evF194Ykh5OJc82ShOqfIyvd74Wtv7vocX0OK5yX U0ty62SaXxI/mL+IXWBOFVXzhP2bL4HrFsLi0M7CsGZqwuo/XlAyRdwo+WARQn5mTjEB Xx8iCstRN+6eflOLM5p8ZhHo7KY1cOpjpIuJjQz1fhsjnCkcNZ7sA3+AzKIrN4gIQv0u LgT1okTtm4gI5DsRitJd0dH4+DbK6nLZFZa1FjDemqNL2DX2kKgvMXOAoQWqZHTwbGi3 ecoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1622022265; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=xWSdbjBNuaVmrQKNfCq8Fq65NZR6YxUG1Z2YWWiyaa0=; b=rvOadQuSFmHq7tlsmyQm5O4PDpV/pnhU6xOiTbMphYArw8p20DWL7ocyNPp+lzw1IX Zy2EO7a0/WrERNK+DiDw9SsKs8sAYAoU2Us2YVINI5DW0w/5Q0cIJLr/Zixn8a+9kclj hUo3o6Zfb97xj3qVddVP//HNuM1Ag+RPHDY/P4bZUSNriQiTbdsvDOuvUDJtIgHuT4GP vnwufHM0yhMOYG5GPPCVr4miE6clHiRP72jZDKebZtYJ5KQfUZleC/c5z/80iEozFWO8 keu5RgUk9Ssp4VNjVbqJMdalhJ4TTvytx0inwvOYql0LhmrHNW9dBDYBaZGEf3e81yyh iqlA== ARC-Authentication-Results: i=1; strato.com; dkim=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1622022265; s=strato-dkim-0002; d=gerhold.net; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=xWSdbjBNuaVmrQKNfCq8Fq65NZR6YxUG1Z2YWWiyaa0=; b=Ter1yHUlH4UO5nMlGFu+scEIb9v+Aj7v0HwiUDhRK5R0GY/gLebiqvdfAnz7wBIL7y /87PPHV07s71sThIVVilgV0zU48O7H9ACmuU3qojx7c4WXPWo2jlNAqAiE2c4OpriT94 KmbfnL3LnnQ3Ni2ELCz8TtwDMoVy/3vufXh1aFDRfOVKkGUCk4QEBF1znsiL7COZA3hL QIUAOgc0pO+wU76pEqe5pQLGYc3SCNVcFx1Ql3O+sN/d+NaaCo/I+Kox9bdWK/aemrNd ggQgl58UN/vT02J0ZPdXrw8GZjRodCszud+/CpomiPTzIs/gJsoqZOyThykldDWLsmeR yl4Q== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXS7IYBkLahKxB4W6JG0s=" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.26.2 DYNA|AUTH) with ESMTPSA id w02ed1x4Q9iP6KB (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 26 May 2021 11:44:25 +0200 (CEST) From: Stephan Gerhold To: Jonathan Cameron Cc: Lars-Peter Clausen , Linus Walleij , Peter Meerwald , linux-iio@vger.kernel.org, Stephan Gerhold Subject: [PATCH 2/2] iio: accel: bma180: Add missing 500 Hz / 1000 Hz bandwidth Date: Wed, 26 May 2021 11:44:08 +0200 Message-Id: <20210526094408.34298-3-stephan@gerhold.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526094408.34298-1-stephan@gerhold.net> References: <20210526094408.34298-1-stephan@gerhold.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org According to the BMA253 datasheet [1] and BMA250 datasheet [2] BMA25x also supports a bandwidth of 500 Hz and 1000 Hz but this was not listed in the driver for some reason. Add it to the bw_table to make the driver match the datasheet. [1]: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bma253-ds000.pdf [2]: https://datasheet.octopart.com/BMA250-Bosch-datasheet-15540103.pdf Cc: Peter Meerwald Cc: Linus Walleij Signed-off-by: Stephan Gerhold Reviewed-by: Linus Walleij --- drivers/iio/accel/bma180.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 81d1e070a2ee..e7c6b3096cb7 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -184,7 +184,7 @@ static int bma023_scale_table[] = { 2452, 4903, 9709, }; static int bma180_bw_table[] = { 10, 20, 40, 75, 150, 300 }; /* Hz */ static int bma180_scale_table[] = { 1275, 1863, 2452, 3727, 4903, 9709, 19417 }; -static int bma25x_bw_table[] = { 8, 16, 31, 63, 125, 250 }; /* Hz */ +static int bma25x_bw_table[] = { 8, 16, 31, 63, 125, 250, 500, 1000 }; /* Hz */ static int bma25x_scale_table[] = { 0, 0, 0, 38344, 0, 76590, 0, 0, 153180, 0, 0, 0, 306458 };