Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3710428pxv; Mon, 26 Jul 2021 09:59:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWmvRVayWD7DVbrXB8TFpMOsDkcFTJtOJflHCW7XHtT8kFB/cwcOitVeTOCOAexjvlu3K+ X-Received: by 2002:a02:8206:: with SMTP id o6mr17216964jag.92.1627318744925; Mon, 26 Jul 2021 09:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627318744; cv=none; d=google.com; s=arc-20160816; b=CDdYVu/SEOBAjFAbahEKpnfQ2QTntHosocTqvE5pG0XK7t4GTSwglBil5lY2LZcgY8 ssngCtO6KxeFF8FtSjbdWS2htklqEPqBDQQzk2Z0Mmn74nYw5Q+rV+z2RU80qe8Iqr8/ HSetOi6TMs7i+KBSz1hKKoFnwpeZhFa7moWvE41WNRT82nStSo4/vbk/jAOu58vSKgWB rAW7odjckrXToR6Hb3Nv5PGvW1loSEi8GXFwuQCOJ1L4MKivOGW8wrmDIl9KZCrsPlyF 7OoVOOoBKX0SAIzUMvI2iH0DFeESDcxA0CTdIGQ0CtxZzEV+LYnA+YTrR2FaooIp7gYZ MyEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E5OYHN16+FBjPezm2notqMafsNQ7wep/I7W2NMLYHdI=; b=pRzawPDLqhOem0bHyRHaJ1kK6Rlh9B42JbVwedlt6oLUalHJJjkRpNEu8w6YH/ZZ5R XceKDyzpjMQ8vQjKxSEADPhxxwHuI9U6qOImf9ckeqxHhCr4C85CSm0MS/NNqjUbMnhj TonIRMA1gLtX64Zf8wPsWx1vDeiZ2bzv+6VaC6qRHeSWlNOk8bWpleXNlIGSmmoe5S/J 75qE0hxST7/8mcqo/ws6kPpukAUtKxiG/cnqStlKaXyNtjdBrsjrW0KZy8sZ3XEe5YS+ VSpcSZQGj6Cr7q4wcyrU2vmsoqdfoCGKUEoVI48qYglta3IjjSbKz96N22AShwqGwprW 6TNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zKM3fCyc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si420152ilu.53.2021.07.26.09.58.52; Mon, 26 Jul 2021 09:59:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zKM3fCyc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbhGZPe1 (ORCPT + 99 others); Mon, 26 Jul 2021 11:34:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:60900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236805AbhGZPTg (ORCPT ); Mon, 26 Jul 2021 11:19:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5906F60F6E; Mon, 26 Jul 2021 16:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315204; bh=aUtE/6ADHg/XyMNw85yAX7gi+yxiI1lRLjARRwOU204=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zKM3fCycvfTzNC6MlbBAPxAZHFbx70lG2zbEGZtU/mQAzDfpDM3rALMf0wgxsuJh2 7KXDnbNDJQav/qybZ3Gv100d3WWCtOd5Gjkgjo7rPMrjaTXuU+C5L7UHjRT6HDOWre O5LxfOyRplu+CB0bCW8LZZsCrReqrscnhPExANOo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Meerwald , Stephan Gerhold , Linus Walleij , Stable@vger.kernel.org, Jonathan Cameron , Sudip Mukherjee Subject: [PATCH 5.4 104/108] iio: accel: bma180: Fix BMA25x bandwidth register values Date: Mon, 26 Jul 2021 17:39:45 +0200 Message-Id: <20210726153835.011799269@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephan Gerhold commit 8090d67421ddab0ae932abab5a60200598bf0bbb upstream 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 Fixes: 2017cff24cc0 ("iio:bma180: Add BMA250 chip support") Signed-off-by: Stephan Gerhold Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20210526094408.34298-2-stephan@gerhold.net Cc: Signed-off-by: Jonathan Cameron [sudip: adjust context] Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/iio/accel/bma180.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -47,7 +47,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; @@ -103,6 +103,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) @@ -241,7 +242,8 @@ static int bma180_set_bw(struct bma180_d 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"); @@ -669,6 +671,7 @@ static const struct bma180_part_info bma .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,