From patchwork Mon May 9 13:46:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12843619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 091BAC433EF for ; Mon, 9 May 2022 13:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236290AbiEINue (ORCPT ); Mon, 9 May 2022 09:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236193AbiEINuc (ORCPT ); Mon, 9 May 2022 09:50:32 -0400 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140138.outbound.protection.outlook.com [40.107.14.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7073E164CB4; Mon, 9 May 2022 06:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mXQEHR1m/kkmW0qrIkGOMnyoY7+bDc9ojkdxlvsjC5NUh7Ja41gOcmumSbWCdqjjC8lQW5hO1DVjN1zsncZjOh5ZtD2+tQwBW4CL3pI4XKDWDnS1NARbfPZLpZHMQP3ftxJ23TzdhcavEuCNgEKKEYVJfHHjA4/cy/S2gTUAtlVlBXPy+797ofY7U75lky/yC6/9mCUV3fxIfpZsz7j5H5JM0iVWDANSLkZHaSK40gGrf/cUpBxhfUQONyLEIthIafFdxXQ4BTPUIWn+G5BHc3wOeOHsT7mIHWHDHvwPdLeiMkfL7GwhJlUmCypoxY4+k7oHTj1UYt3LUDr4ymDi0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZLJg/fGggZqqZKRQIsgHFd7ZgVxK8VPebIBuSxIlG1c=; b=YOJXyeoCpbf5P6DQu5pEk35SInqqdDJERyv0lIFDvNYm6SkHXYPD4v2lMR2DQ4AsUiDupDthl8wBMGoitYiGh3h/dE/DFIsyB7JIyUSJz8DVwuUPAT1trGv7aexPKDE+d18txkwb/911GujIHoKnmhvqyOtaxcCPulJhtUgHyqJx2kPzRQ5MXlfrGscRAU150/7Aexy2qxGQ+SP6rbnSsRJiO6Kmc1cVg+uNrLQbbwPeTvw99rFNJaKNvHqBn75i3MnbgsPWISyKwk96jugTrDIm4BhztbhlqTB85siz3oWyzHIdwiUHz+JL4KPj+Zaqa9dhF+kFuxeCScoh4NJpGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 193.8.40.94) smtp.rcpttodomain=kernel.org smtp.mailfrom=leica-geosystems.com.cn; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=leica-geosystems.com.cn; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leica-geosystems.com.cn; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZLJg/fGggZqqZKRQIsgHFd7ZgVxK8VPebIBuSxIlG1c=; b=aCOiuMMmh7F9uToGbrnO9I1fw0eZWloNoqHBuZgvRmdUxdCVDUSx/V64uGyxjN8GAXHkxz9eBQpTDHbA/8qCc1hX3WEe3JrOlTjHHRboKHoUmcX25v0G0mYFHJP2reLXUldwsaxrxuPubu6nwTRvd0RjkrSrTAYXt9CtWH+VZAw= Received: from AS9PR04CA0083.eurprd04.prod.outlook.com (2603:10a6:20b:48b::29) by PAXPR06MB7552.eurprd06.prod.outlook.com (2603:10a6:102:157::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.18; Mon, 9 May 2022 13:46:34 +0000 Received: from VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:48b:cafe::cd) by AS9PR04CA0083.outlook.office365.com (2603:10a6:20b:48b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 13:46:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 193.8.40.94) smtp.mailfrom=leica-geosystems.com.cn; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=leica-geosystems.com.cn; Received-SPF: Pass (protection.outlook.com: domain of leica-geosystems.com.cn designates 193.8.40.94 as permitted sender) receiver=protection.outlook.com; client-ip=193.8.40.94; helo=aherlnxbspsrv01.lgs-net.com; Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by VE1EUR02FT056.mail.protection.outlook.com (10.152.13.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 13:46:33 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, mchehab+huawei@kernel.org, ardeleanalex@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Subject: [PATCH V1 1/5] iio: accel: bmi088: Modified the scale calculate Date: Mon, 9 May 2022 13:46:25 +0000 Message-Id: <20220509134629.440965-2-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8647cb0f-6a4d-48c5-0fb0-08da31c254a4 X-MS-TrafficTypeDiagnostic: PAXPR06MB7552:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kEgUwS3ftV90oC4JY1xv06ts/ckFd4Qx7ZVOpT8sTdbQjh0DOlEyGOzMKbDFlH/8yZ9bI2PnDUIPIeuoKavUfIjFXWrUdV+V+xMYEhEULxoLovzJsYxKVXahoowfusyUN0AC2Matq+ld5tZEaJX7kJn/3PLoyvGPZknxI36u0kYO/RSh/j07T6D35xNAbHq6JVpam7kh5MxZmKx+Zrf2pF3A5T3g/x9fy1HwGLHjUcbaoJVMdEysFA8GWuwmJ/UJ7giw7cODR1avT0iTld+zZKqle2q/1Dyr0i+CnUyEfKkMcrdNVjqeG0zLTwB2a00CqUoz/DpDc2VfYX9ZzEAPu/GWmJ9N78cPnww+hgce/o5asZAxj13uat6q16iCsA8qqPyanM86Xta3p45p+XdyMAXrWL+iijbbfr74XguSb6B9jXbf5R5rqPBmrqODJ9QAXnS1XevCtlpcq1dl4VPCEe2VKMs/iFVk9RmIPVg2y+mqXTCZZcXUf2YCeFI4GQOmaVo4JJgoYa4uUOsIFbyAVRISClA4zRNxXY/o2hciA0o1kvCh5JP/O99Uhdk7PIG40DJ7F6orFBtmIQsBMPA74AKDRQqeH/9xeu7c8inQc4ByAkpQGHcy0vbAEMGSQ8cSoXMzBJFKqqUwDCFKJXye6nA/asIflExYKi8Km64IxYWMExB5A0klohXU1FbmAIIm X-Forefront-Antispam-Report: CIP:193.8.40.94;CTRY:CH;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:aherlnxbspsrv01.lgs-net.com;PTR:ahersrvdom50.leica-geosystems.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(36860700001)(6512007)(2616005)(956004)(118246002)(40460700003)(26005)(8676002)(82310400005)(36756003)(47076005)(186003)(316002)(336012)(1076003)(70586007)(70206006)(36736006)(2906002)(6666004)(5660300002)(6506007)(86362001)(6486002)(8936002)(508600001)(81166007)(83380400001)(356005);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 13:46:33.8082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8647cb0f-6a4d-48c5-0fb0-08da31c254a4 X-MS-Exchange-CrossTenant-Id: 1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a;Ip=[193.8.40.94];Helo=[aherlnxbspsrv01.lgs-net.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR06MB7552 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The units after application of scale are 100*m/s^2, The scale calculation is only for the device with the range of 3, 6, 12, and 24g, but some other chips have a range of 2, 4, 6, and 8g. Modified the formula to a scale list. The scales in the list are calculated by 1/sensitivity*9.8. The new units after the application of scale are m/s^2. Signed-off-by: LI Qingwu --- drivers/iio/accel/bmi088-accel-core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index a06dae5c971d..0c58ffdd00e3 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -119,6 +119,7 @@ struct bmi088_accel_chip_info { u8 chip_id; const struct iio_chan_spec *channels; int num_channels; + const int scale_table[4][2]; }; struct bmi088_accel_data { @@ -280,6 +281,7 @@ static int bmi088_accel_read_raw(struct iio_dev *indio_dev, struct bmi088_accel_data *data = iio_priv(indio_dev); struct device *dev = regmap_get_device(data->regmap); int ret; + int reg; switch (mask) { case IIO_CHAN_INFO_RAW: @@ -330,13 +332,12 @@ static int bmi088_accel_read_raw(struct iio_dev *indio_dev, return ret; ret = regmap_read(data->regmap, - BMI088_ACCEL_REG_ACC_RANGE, val); + BMI088_ACCEL_REG_ACC_RANGE, ®); if (ret) goto out_read_raw_pm_put; - - *val2 = 15 - (*val & 0x3); - *val = 3 * 980; - ret = IIO_VAL_FRACTIONAL_LOG2; + *val = data->chip_info->scale_table[reg][0]; + *val2 = data->chip_info->scale_table[reg][1]; + ret = IIO_VAL_INT_PLUS_MICRO; goto out_read_raw_pm_put; default: @@ -432,6 +433,7 @@ static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = { .chip_id = 0x1E, .channels = bmi088_accel_channels, .num_channels = ARRAY_SIZE(bmi088_accel_channels), + .scale_table = {{0, 897}, {0, 1795}, {0, 3590}, {0, 7179}}, }, }; From patchwork Mon May 9 13:46:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12843620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A07D5C4332F for ; Mon, 9 May 2022 13:46:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236347AbiEINug (ORCPT ); Mon, 9 May 2022 09:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236320AbiEINuf (ORCPT ); Mon, 9 May 2022 09:50:35 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2122.outbound.protection.outlook.com [40.107.22.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F031164CB4; Mon, 9 May 2022 06:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IzPVUewWclPksBmqFHuTG8o4F1GX1mWKGORxtx7cqRQOBFE43duWtdy7u8jAcJLGWoLTQ8mIFjGbhIr2x/VRxROKcGxZM/t/mJFb2eaREKv0Jf7F/svfgGLBCrfmTkn+JCjp3QuVZUPA5ALT3q/GelMUrDq4uRFCf/k03BCfqMiGuHRkXhXjwZpnIdIFrO92N2aIt9/GW6fpHPzLy8IZ+l4bNCjZK8soyFeBTpd3z5huf+4C26iudoMD/NUfKFQqkm6m82CGUMQFJqhknwV2ee8Iwz1UdpXESUvxmCaNEPS6KEpzbbfMiMdoF+lPrxHvUsAtkiuFPVFHwR2BXVcS7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Irwy0KKOuYF/RdVeH4BkcdceXbkpF69gBW87N0K6pCo=; b=U15LlopzwPMpE1eHCFRtiZd7FK6ENxaFOvUdWQ/bZxb0t8cqapAN6w1tEkEGYrGVn9kdw7iSZn2oJakaEep7KX26keon7PpABI9cpG9IJHDO8a9ZCgYTsZRubrSaTqpNsqD90higSkyRcEnonTAkQq/6gltEq1Xy+VhkAFgZ+Cfc696DXtZXOLb8L5entzUkWAvnt1TsGN1wCUaGG5F+3ZjXA9BmuM1UqtEHFnax8f6WEFn217jLmBKofzzEiaDtB3nqKkxfgxzqmIP0qHujNABcif5sbglEfLvDmQMPMpwX8aWfMw5y8MVG/uTCXuEj8raIq1ngzA5QZujtY7x+cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 193.8.40.94) smtp.rcpttodomain=kernel.org smtp.mailfrom=leica-geosystems.com.cn; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=leica-geosystems.com.cn; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leica-geosystems.com.cn; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Irwy0KKOuYF/RdVeH4BkcdceXbkpF69gBW87N0K6pCo=; b=m3upb7js2h7kixL7H47mr3pbBcy4LcE4H00DkaCEQ3nOJG12cricMVnZI9GovfUJDHJ/At2WMvSs5P0nCT9KLL64aNyI5E73M67Uts8ca3/PXAvnqiSEDu1RT6VFXsiCwNTPuM0UaIZ8olOyqkt92w9FNGVFmlruzDOb6KHnooE= Received: from AS9PR04CA0067.eurprd04.prod.outlook.com (2603:10a6:20b:48b::14) by AM6PR06MB4963.eurprd06.prod.outlook.com (2603:10a6:20b:34::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.14; Mon, 9 May 2022 13:46:34 +0000 Received: from VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:48b:cafe::1e) by AS9PR04CA0067.outlook.office365.com (2603:10a6:20b:48b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 13:46:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 193.8.40.94) smtp.mailfrom=leica-geosystems.com.cn; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=leica-geosystems.com.cn; Received-SPF: Pass (protection.outlook.com: domain of leica-geosystems.com.cn designates 193.8.40.94 as permitted sender) receiver=protection.outlook.com; client-ip=193.8.40.94; helo=aherlnxbspsrv01.lgs-net.com; Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by VE1EUR02FT056.mail.protection.outlook.com (10.152.13.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 13:46:34 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, mchehab+huawei@kernel.org, ardeleanalex@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Subject: [PATCH V1 2/5] iio: accel: bmi088: Add support for bmi085 accel. Date: Mon, 9 May 2022 13:46:26 +0000 Message-Id: <20220509134629.440965-3-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 833871ad-d871-4f9c-6c0f-08da31c25503 X-MS-TrafficTypeDiagnostic: AM6PR06MB4963:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5yIvmSlkjqKGEmvscCmRDntjE0bV2mQ/RUbM16RzAd4T2rPXLxGTSteK7T3edkufSvlCtckbDeP4hpCsKXlBQ2kH/51v6bytOL7qX88Ptm5/S4XcvR4/5zTFVA0EDk9DA9Rm+9hhoiOySkf2DHM8dbsekRY7A/JUwkur8AcNd4Qh07oYO8AGuQ/CoHW0DJMVncQSLUjvrPoQaGH/WJ1yIe5Eh0xKNWmHe/3J0HDYnFYaKNX7WJV5Ixk5RQT2ayLTfaPHVsTJX5+HLwha4j0AUYuOcQrXjvYO4vHsVDol1rJ0bpCruUEPkpFFN00TdIjIKZj16Mv1R1cMgN6vz6YjSnySbLYkoUxfGj8t6FeWxnlvEmnFFTSa7ij9nxTNAAdg4/XxuIoqGchh6Lm4z6k4TJDqLxLbwQ9jPLpNRRAsX+b9KaTC2UKyxcWy2MofaIIlgm10ZssBkzGz4yrK15O3VtOKnFslZAclL/MLI4+d47LpPcv7Vn1ECoaGaSw/tNP9TY2Du1MUG69j+eBQFFoYkMPaAH9oiw0zF0QYwHs+DUjSUnbSNLGE/r/KVyYRlfhnzJX9Jn1QaDw6RkXHS4RB8XGasDSAwoH9VenDtrWYXkrxi09OPmqIQ2mGvnNYEqRaoDqnQXxe5NIf/93wauaBIqHsta8ontpv75PIqxUDq4sxNPlxl+IX70avC/OqOS1y X-Forefront-Antispam-Report: CIP:193.8.40.94;CTRY:CH;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:aherlnxbspsrv01.lgs-net.com;PTR:ahersrvdom50.leica-geosystems.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(47076005)(70206006)(70586007)(316002)(1076003)(2616005)(36860700001)(186003)(336012)(956004)(82310400005)(356005)(8676002)(36756003)(5660300002)(2906002)(81166007)(8936002)(6486002)(26005)(118246002)(40460700003)(6666004)(6506007)(6512007)(36736006)(508600001)(86362001);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 13:46:34.4331 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 833871ad-d871-4f9c-6c0f-08da31c25503 X-MS-Exchange-CrossTenant-Id: 1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a;Ip=[193.8.40.94];Helo=[aherlnxbspsrv01.lgs-net.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR06MB4963 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add supports for BMI085, an Inertial Measurement Unit, with an accelerometer and gyroscope. The commit adds the accelerometer driver for the SPI interface. The gyroscope part is already supported by the BMG160 driver. Different from BMI088, the BMI085 accelerometer has the range of +/-2, 4, 6, and 8g. Signed-off-by: LI Qingwu Reviewed-by: Alexandru Ardelean --- drivers/iio/accel/bmi088-accel-core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index 0c58ffdd00e3..ac8acf6e2ff0 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -435,6 +435,13 @@ static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = { .num_channels = ARRAY_SIZE(bmi088_accel_channels), .scale_table = {{0, 897}, {0, 1795}, {0, 3590}, {0, 7179}}, }, + [1] = { + .name = "bmi085-accel", + .chip_id = 0x1F, + .channels = bmi088_accel_channels, + .num_channels = ARRAY_SIZE(bmi088_accel_channels), + .scale_table = {{0, 598}, {0, 1196}, {0, 2393}, {0, 4785}}, + }, }; static const struct iio_info bmi088_accel_info = { From patchwork Mon May 9 13:46:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12843621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA0ECC433F5 for ; Mon, 9 May 2022 13:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236362AbiEINuh (ORCPT ); Mon, 9 May 2022 09:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236348AbiEINug (ORCPT ); Mon, 9 May 2022 09:50:36 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2090.outbound.protection.outlook.com [40.107.20.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D54F616ABE1; Mon, 9 May 2022 06:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UPisYVYOHuSOjkcEVDYGtFJI2N0LCfP+Ap8x6ylOCSdDeZglXKtVTNULKEhHyYdMYs9RsfghDCD3xrDcV++PwjrKjYNG6cl+mVxOc6wsgO+9wilkraD7DMU0olPPSPlrli6zZrtHW23L2Zd3aKcT8Sgj6o0/yny/f99fOYAPKkrOkF6rp7cPx/CuEkmDSO1ubt2RiK/PORbGBB8sROBjaf5iKuRC4JdN252xhnLYVvJPVOxN3H45WFAViaX+8f/JvUot5g7FwQkESZkhPn7n7dW1ryMqK/CGmzReRj6S1/fT363JwkwSn3K8TKrwZ13xVFtQm7uPUhBinIXjfhUvlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XlEkrwvPmPLUEGkqiOTJfvym2l2BHiouj60mFnWg1LU=; b=NceNn7Zs17eXUkkEe1OZupKLgFDon6c76R2zcW1j7g+EuonMPfuF1z0o89MGEeQY5V5kLWHWiy5sWjxC//Fz90hmu3jrAaDR84do7KOp/bsAFKD/mtuhdGMi+UEzH8kEMvhLB+oAFg5T/smarDRGp+BKhqN/qdSmxjRPtpmUDOvGZIVj2THyEW7dB8k1gazBv7oHfYXUNO4dP3LapI+3hgEycDwt8fe/IoJoEgAj4NqkpOBf9+Bd+g/viO7+T2X2EHjIc2uh9RCebBEZM4bhOAaU1PViMiaS13jeYIAUq/OuZh8ieeZ4ElEQnek7Oyt4f9bZkxZqhidUqwdz9Rr9Lw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 193.8.40.94) smtp.rcpttodomain=kernel.org smtp.mailfrom=leica-geosystems.com.cn; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=leica-geosystems.com.cn; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leica-geosystems.com.cn; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XlEkrwvPmPLUEGkqiOTJfvym2l2BHiouj60mFnWg1LU=; b=Y8zHMbztS1AKB5eM34dxC7N43kiBLzSZYEajOM8LSPegeEIE0SKlOh/betF6OWqhmM+GTe8KI56P9ANvqIeoU8VO3QTxeQ+1rZCp39QH/hKfy9/A73t9qlKn5bRPqmFJDGzXhDQEpsPqXOFlqYfDLSi5ht2nz2ecbUuDtfZZX4o= Received: from AS9PR04CA0061.eurprd04.prod.outlook.com (2603:10a6:20b:48b::15) by DB8PR06MB6137.eurprd06.prod.outlook.com (2603:10a6:10:3e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Mon, 9 May 2022 13:46:39 +0000 Received: from VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:48b:cafe::63) by AS9PR04CA0061.outlook.office365.com (2603:10a6:20b:48b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 13:46:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 193.8.40.94) smtp.mailfrom=leica-geosystems.com.cn; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=leica-geosystems.com.cn; Received-SPF: Pass (protection.outlook.com: domain of leica-geosystems.com.cn designates 193.8.40.94 as permitted sender) receiver=protection.outlook.com; client-ip=193.8.40.94; helo=aherlnxbspsrv01.lgs-net.com; Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by VE1EUR02FT056.mail.protection.outlook.com (10.152.13.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 13:46:38 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, mchehab+huawei@kernel.org, ardeleanalex@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Subject: [PATCH V1 3/5] iio: accel: bmi088: Add support for bmi090l accel Date: Mon, 9 May 2022 13:46:27 +0000 Message-Id: <20220509134629.440965-4-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40616598-fa07-428f-a4e7-08da31c25790 X-MS-TrafficTypeDiagnostic: DB8PR06MB6137:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yR7qZ2BY39oI51m6iumEvdcqpOUky0cGw5fX0ezyhrYarfooBX7m2K1Ak9eeyrG2pgyISvEcomGgJNl8YEgDOB0gGqh1aG6w51DFyOY9O0tY38yrc/6zTy7KzRNs/zLlM/dfbAmQDfFUGFn12XWI8YtBUgLmwdRyWdR0XwJFGEuMwTvLgTlHQBcN8ZIt8aGlXctJWOkyExC41anL1kMkLKw3J69wLeb23Qq4QyfPN3HXSXgqoIMTsVsU9sDOB3YsRHRnNh6k05HiH80d33w+VF21S9eIvECMmNnFDSGTTqTpL7+wrCR5t5KcPuYVlTk9PTwBM4f5UQSKdAlCSB+VPwl2hcQ2ydiDMetga3IFJp4kmjlRqr63F0+DJ436nSxmAdlExOQ7Abo0TCcbpDAZh2N7BqPoai7id5hXnlDEUnmDOgKLFsso6Oo5U31AGi0vLfEeYCaorB/d/jZfpmmiP/caWu3B5xzuHtikNL667En2r8Q8oSdWNdWlSswvGTr9/WaVCchj6y61jQb81GDdrCjO0iRk66oNoMlyxV1r1xSAnkFt3AyV1gEPJNL+b8ClVGePXQgag4111o1OEy6v36n3dJ5BtrdH6+X4Z21bnqVIzRcvagPTWJE6M5s7YVFLiJAXBXSgWe6sfX1qBTfEfuwxFFqKmzVI0/Se5oV5ZmJKYG0f5wSHWTvZLNkDtvEV X-Forefront-Antispam-Report: CIP:193.8.40.94;CTRY:CH;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:aherlnxbspsrv01.lgs-net.com;PTR:ahersrvdom50.leica-geosystems.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(36756003)(8936002)(36860700001)(356005)(8676002)(81166007)(40460700003)(508600001)(2906002)(70586007)(70206006)(6666004)(26005)(118246002)(6506007)(186003)(2616005)(6512007)(956004)(36736006)(1076003)(5660300002)(6486002)(82310400005)(316002)(47076005)(86362001)(336012);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 13:46:38.7141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40616598-fa07-428f-a4e7-08da31c25790 X-MS-Exchange-CrossTenant-Id: 1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a;Ip=[193.8.40.94];Helo=[aherlnxbspsrv01.lgs-net.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR06MB6137 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add supports for BMI090L, it's a high-performance Inertial Measurement Unit, with an accelerometer and gyroscope. The commit adds the accelerometer driver for the SPI interface. The gyroscope part is already supported by the BMG160 driver. Same as BMI088, BMI090L have the range of +/-3, 6, 12, and 24g. Signed-off-by: LI Qingwu Reviewed-by: Alexandru Ardelean --- drivers/iio/accel/bmi088-accel-core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index ac8acf6e2ff0..44cbe098c093 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -442,6 +442,13 @@ static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = { .num_channels = ARRAY_SIZE(bmi088_accel_channels), .scale_table = {{0, 598}, {0, 1196}, {0, 2393}, {0, 4785}}, }, + [2] = { + .name = "bmi090l-accel", + .chip_id = 0x1A, + .channels = bmi088_accel_channels, + .num_channels = ARRAY_SIZE(bmi088_accel_channels), + .scale_table = {{0, 897}, {0, 1795}, {0, 3590}, {0, 7179}}, + }, }; static const struct iio_info bmi088_accel_info = { From patchwork Mon May 9 13:46:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12843623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFF95C433F5 for ; Mon, 9 May 2022 13:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236348AbiEINvP (ORCPT ); Mon, 9 May 2022 09:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236430AbiEINuu (ORCPT ); Mon, 9 May 2022 09:50:50 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2111.outbound.protection.outlook.com [40.107.22.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1097916F92C; Mon, 9 May 2022 06:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P4hTWKt+Iv3sfe7CdYhQTv42ld2PFlWxNt40lRJjMW8A8GDzu474dj//uihWr7fK7D0i+4abTHD3+tpzT31QkX4hohymg7TiyJgdpJVGAmraXxxITrfCYETSxAM1pZ2nCkMcP4aHIXEFWww3DUdMPki0f1AO1/9dsejFPK0YL0QBhneEavs/Zcj5UqEbi15fCpfc9Y6JjVssZPFNpt+nlpFX/KH4U0RZP2ljbPXutga6vdFmN3TXCMSxUFR2cvKMWEvXZcak2lVHoRLIG3KTxaBsDwiDP4++zqR5qj6SAqZVMY1b2i7fHcsK0UT8zsdICevWki4UqLsEDK+7Vcy49Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wCiOJgBV1dOsX6E05lMH+yxQnQgXKL6VmsudgsMvsb4=; b=hXNhNE3iqKGlyV3glqyi1PrV6VGsMMgic6aVJrfxa+lCLJ02fElYLhjHkOtBUadfklBTNMfDEt3un1WbmRou+Bc6qE8dI2xHvQ5GhYCBuWrDmFU+J3qJuokJqf+S6KwlQyK85pNx+eB/CEli0VHQsJbh9uf8AOGg94aHIBLH/Z+oTMiqKI47k5BIDPUlWqomHuoQ7CjrRUmCiqFPb8JdXGrHuDFOUKPVRp3C3WTOX8d3DkltWy4sEoPZTUaJkqB2SyeAFnUkm68GbUHIEO1e421Ct6+UHPad/mwx8olOBG8NWEEpE0D+qClNh9cI73qCguGqrtWhQc5IW2u+1/zueA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 193.8.40.94) smtp.rcpttodomain=kernel.org smtp.mailfrom=leica-geosystems.com.cn; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=leica-geosystems.com.cn; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leica-geosystems.com.cn; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wCiOJgBV1dOsX6E05lMH+yxQnQgXKL6VmsudgsMvsb4=; b=ATqlLHC9A5Sg+L39pXdu1JpSOmw/OCkMZWlEbd8W2QhdUdaCjADCSJizb2jvMubH8sXSayTRbIpsGNgOVfUGornk1s6S3NbTPCbglcDsupjvj+31+i8VH8zRq0S5XQiiTTxTxh2cwtwURYJZTFx5Tywjh2uCju+xst+U2vurheA= Received: from AS9PR04CA0061.eurprd04.prod.outlook.com (2603:10a6:20b:48b::15) by DB7PR06MB5723.eurprd06.prod.outlook.com (2603:10a6:10:86::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.18; Mon, 9 May 2022 13:46:42 +0000 Received: from VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:48b:cafe::23) by AS9PR04CA0061.outlook.office365.com (2603:10a6:20b:48b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 13:46:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 193.8.40.94) smtp.mailfrom=leica-geosystems.com.cn; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=leica-geosystems.com.cn; Received-SPF: Pass (protection.outlook.com: domain of leica-geosystems.com.cn designates 193.8.40.94 as permitted sender) receiver=protection.outlook.com; client-ip=193.8.40.94; helo=aherlnxbspsrv01.lgs-net.com; Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by VE1EUR02FT056.mail.protection.outlook.com (10.152.13.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 13:46:39 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, mchehab+huawei@kernel.org, ardeleanalex@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Subject: [PATCH V1 4/5] iio: accel: bmi088: Make it possible to config scales. Date: Mon, 9 May 2022 13:46:28 +0000 Message-Id: <20220509134629.440965-5-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 332a6a5d-4111-4cdf-4b2c-08da31c2583c X-MS-TrafficTypeDiagnostic: DB7PR06MB5723:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jo51wj8V2aHGzAtpGqaVnyc5DiQBHZ46j1EnfJlm2qt4EB+QQ6O7poOUJ0C80DebeJP40VH7PRLexTTHog99heh5iAvl0nP1EnUKmXwr/jHOKu5mu1NK8dPQxHbg+Uu5C/1/qjCPk2znBUxH8VHVI1Hc/GfEM1YIhVMH1H7Larj3JADCFZuAn/EUQTMUsjJmHqsQ8f3hICNcdP6FJ/hjAJCSIR4maW37VrXBaK8k3Qin1ynJuJOvQvYt/Gnquf3fRdGc2ollyJ+XhNiKcbtYx7/wHuLuDeaUX/RrN0tvdx4Ph1uKiEs5cfA0p8JLsQsZOdP751xfrmiIepij2GzF6dPv0V5mzLuuNLUnHbXXwMV40OHy+d2QAI9vMuFYgCWJ4/0seoy6NWDttR8w916nqQu67dT2g7rL2AOwA0+kzZmQkg9p4nAAbUDBuAcFxRbHfLTjGJoumngFvMqJnUb44kb9H+TsS/9p4X3ozIwKgdgw64lKKMb2EDMYR193ADgER/IIFpSM1UjoH/R3ppmwMFQH9sWs4KLLMW7ofjlj2KtXuBmYiF69YlXnJHw+xqQyzKxSjPN6Yat2vEhFM/Tvk7ypeypoDU7hPu21+LLRKlxjKL3Nob1EiIcAAnCplyH6in3dr4CZTf1gl+g4l7lhenZFuW8n+Sj1HwpfrEgvGHitk8LUY6DzKBzkChTvBAxH X-Forefront-Antispam-Report: CIP:193.8.40.94;CTRY:CH;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:aherlnxbspsrv01.lgs-net.com;PTR:ahersrvdom50.leica-geosystems.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(356005)(6512007)(6506007)(6666004)(508600001)(26005)(40460700003)(6486002)(86362001)(81166007)(8676002)(36860700001)(82310400005)(336012)(47076005)(186003)(83380400001)(1076003)(2616005)(956004)(5660300002)(8936002)(36756003)(70206006)(36736006)(118246002)(70586007)(316002)(2906002);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 13:46:39.7922 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 332a6a5d-4111-4cdf-4b2c-08da31c2583c X-MS-Exchange-CrossTenant-Id: 1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a;Ip=[193.8.40.94];Helo=[aherlnxbspsrv01.lgs-net.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR06MB5723 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org All the sensors can set the scales by writing the range register 0x41, The current driver has no interface to configure it. The commit adds the interface for config the scales. Signed-off-by: LI Qingwu Reported-by: kernel test robot Reported-by: kernel test robot Reviewed-by: Alexandru Ardelean --- drivers/iio/accel/bmi088-accel-core.c | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index 44cbe098c093..7c78cfb321ee 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -237,6 +237,23 @@ static int bmi088_accel_set_sample_freq(struct bmi088_accel_data *data, int val) BMI088_ACCEL_MODE_ODR_MASK, regval); } +static int bmi088_accel_set_scale(struct bmi088_accel_data *data, int val, int val2) +{ + unsigned int i; + int ret; + int reg; + + for (i = 0; i < 4; i++) + if (val == data->chip_info->scale_table[i][0] && + val2 == data->chip_info->scale_table[i][1]) + break; + + if (i >= 4) + return -EINVAL; + + return regmap_write(data->regmap, BMI088_ACCEL_REG_ACC_RANGE, i); +} + static int bmi088_accel_get_temp(struct bmi088_accel_data *data, int *val) { int ret; @@ -368,7 +385,13 @@ static int bmi088_accel_read_avail(struct iio_dev *indio_dev, const int **vals, int *type, int *length, long mask) { + struct bmi088_accel_data *data = iio_priv(indio_dev); switch (mask) { + case IIO_CHAN_INFO_SCALE: + *vals = (const int *)data->chip_info->scale_table; + *length = 8; + *type = IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; case IIO_CHAN_INFO_SAMP_FREQ: *type = IIO_VAL_INT_PLUS_MICRO; *vals = bmi088_sample_freqs; @@ -388,6 +411,14 @@ static int bmi088_accel_write_raw(struct iio_dev *indio_dev, int ret; switch (mask) { + case IIO_CHAN_INFO_SCALE: + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + ret = bmi088_accel_set_scale(data, val, val2); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return ret; case IIO_CHAN_INFO_SAMP_FREQ: ret = pm_runtime_resume_and_get(dev); if (ret) @@ -410,6 +441,7 @@ static int bmi088_accel_write_raw(struct iio_dev *indio_dev, .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ BIT(IIO_CHAN_INFO_SAMP_FREQ), \ .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + BIT(IIO_CHAN_INFO_SCALE ), \ .scan_index = AXIS_##_axis, \ } From patchwork Mon May 9 13:46:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12843622 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36B08C433F5 for ; Mon, 9 May 2022 13:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236419AbiEINuw (ORCPT ); Mon, 9 May 2022 09:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236415AbiEINuu (ORCPT ); Mon, 9 May 2022 09:50:50 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70125.outbound.protection.outlook.com [40.107.7.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BF9816D5CE; Mon, 9 May 2022 06:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=haSL6AtJKmb2rcod6/Bx5+zlx9JSjTYJGTu3DQPgMcL91IO4/uGiykHcMOkzU0tjZqbrbrzdlDEGwH+sJjr4T+BiAw00mEfRWfV8sQwFpR6cu71AFPiVjb5XmWaBLFrxFhLBrqnUWETVCGl0m1YZyOfBWFXXi1Y6tQyylfDEavPWn/6lEs2W6MWaKJ8wb7mxvx9y1PgECqZANqhWmypbGivBQBPNjRouqgSB5owIZspDYzlGJNH5KDfvvoe+GoD+CKIzXTG3RGpE/+pOgHlywCwBDYdpMuoTe65ZLzJKwL7z2qBU/Ruu+bwED6qOMiduhM3v1vUv7R9CY7z6ZqadIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FHYXk3E8HIAjGeCZQVdDr941iUJX3u0mPSa0nBZ8EOU=; b=gOxwN2mFfHPiDCqyEKPkq2UJPoNnIK6N+EKI8UiS/iaNK+Bx/U2M51/V1uKK0lFsHnq3xwifUd/3PY0POT5iU0pkMemmkWkkDalToihmaOknbwkgShigNlCwuUz1sN4Os1IXOVJmZVMWBbKVGX2Vc45UiyD0VZ8+x2W1l/4gocvCwMIokb61U8Ca+umy7vHF1XDll3eMbbjorlEywltYDn5hH4uLoz8NIGyfNK4Zu1xLayqn/AeVRH7ivuXuy+811HWvcKGa64tFSPei6ZAzc2j9z1UsKsgBXNRPl7JulVO8WqbOLJkWGkiIDdeoG7Gtmea+u1wfntb8Bat2Q3b93g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 193.8.40.94) smtp.rcpttodomain=kernel.org smtp.mailfrom=leica-geosystems.com.cn; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=leica-geosystems.com.cn; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leica-geosystems.com.cn; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FHYXk3E8HIAjGeCZQVdDr941iUJX3u0mPSa0nBZ8EOU=; b=aJzCqSaFaAJ6v9s7Wp+1t4vMmVESlcl14ujkLy0usMj2UnzIRp+8WiKqIve+lbBg1VNUnycdokCAemcYG3IoWA0i2s2XMFHG1jw6cqRiDKz8yqp+62rt8FDthJs0FWmQP5A3N6rILczovNmuiom3nXhdQc7+IMK07hZJnBNhLKQ= Received: from AS9PR04CA0072.eurprd04.prod.outlook.com (2603:10a6:20b:48b::7) by AS8PR06MB8181.eurprd06.prod.outlook.com (2603:10a6:20b:3d0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.20; Mon, 9 May 2022 13:46:42 +0000 Received: from VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:48b:cafe::ef) by AS9PR04CA0072.outlook.office365.com (2603:10a6:20b:48b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 13:46:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 193.8.40.94) smtp.mailfrom=leica-geosystems.com.cn; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=leica-geosystems.com.cn; Received-SPF: Pass (protection.outlook.com: domain of leica-geosystems.com.cn designates 193.8.40.94 as permitted sender) receiver=protection.outlook.com; client-ip=193.8.40.94; helo=aherlnxbspsrv01.lgs-net.com; Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by VE1EUR02FT056.mail.protection.outlook.com (10.152.13.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 13:46:42 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, mchehab+huawei@kernel.org, ardeleanalex@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Subject: [PATCH V1 5/5] iio: accel: bmi088: modifed the device name. Date: Mon, 9 May 2022 13:46:29 +0000 Message-Id: <20220509134629.440965-6-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220509134629.440965-1-Qing-wu.Li@leica-geosystems.com.cn> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d591f17d-2f21-4c7c-0a94-08da31c259c8 X-MS-TrafficTypeDiagnostic: AS8PR06MB8181:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kBW5qaqJYhhbFg+xlg5uPSeapNobJnsVfgGOVflYWcUwWkxxvyckmTrNPHVeymOOMJMLtl3p8HVbcD8yoBXx6MyfUPCr9Mcn1p1jz9JBr5Fv0c9dRWlBX9HEBwbGX+qZAKb1O7L6vbkngLhCiBrzS7wbKgOzN2ffR+DVEl80AhtoLcbXG+atxr4HoWQ/p2f7O7Lc0qLkvcO2lT9tjqMFUFIbx06YzM/3prMv30CJEoIhPBXSBzIDim8NBQdh8e4Sp1PDHVIwjvfNr1fDfbYFn6A+VgjWTlDvFCzYeJqgDKLBqq0+xLguXQjjvc7lqhanGvh9jDoDChjmH42ppseNmWbQrN0Ls2+nXxTJEBVht1T/WpjetbnbeB86NJ/4vjOE1tLjZsb158CygWxpAmokza/wKFm5dy1mIYldrvvCMlAEEjvABmVzjo+gK1MfoIvPxJtF9fjApNSag2WxfIHLfFeN0yQ6ucZDcc4XclaEYuDkIkROtAoqyz9KaLmOfbgOjbSoXBze7O1WG8oHNwiIpmO1Hk9B8yV/wKCFmG/3t7wOdXRlCT0gh5fS5s4nyw7McqxIBZET+7mC3GDWU4nOXgFUiY89ea16QvlHxpceTmVZ0QVwyLg4jj+Gqb8Yktg+Mykz2Q33043D44WwVJ1r5fb07V7xhsXTPs9eM8mVCWgqpj+n6d1Cl3E41yj3XFnZ X-Forefront-Antispam-Report: CIP:193.8.40.94;CTRY:CH;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:aherlnxbspsrv01.lgs-net.com;PTR:ahersrvdom50.leica-geosystems.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(356005)(6512007)(6506007)(6666004)(508600001)(26005)(186003)(6486002)(40460700003)(82310400005)(36860700001)(81166007)(86362001)(83380400001)(336012)(47076005)(1076003)(2616005)(956004)(5660300002)(8936002)(36756003)(70206006)(2906002)(36736006)(118246002)(70586007)(316002)(8676002);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 13:46:42.4326 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d591f17d-2f21-4c7c-0a94-08da31c259c8 X-MS-Exchange-CrossTenant-Id: 1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a;Ip=[193.8.40.94];Helo=[aherlnxbspsrv01.lgs-net.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT056.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR06MB8181 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org It is possible to have multiple sensors connected on the same platform, The commit makes it possible to obtain the device name for the different chips according to the connected chip ID. To be compatible with previous versions, renambmi088a to bmi088-accel. Signed-off-by: LI Qingwu --- drivers/iio/accel/bmi088-accel-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index 7c78cfb321ee..8f6920dc2ad9 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -461,7 +461,7 @@ static const struct iio_chan_spec bmi088_accel_channels[] = { static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = { [0] = { - .name = "bmi088a", + .name = "bmi088-accel", .chip_id = 0x1E, .channels = bmi088_accel_channels, .num_channels = ARRAY_SIZE(bmi088_accel_channels), @@ -561,7 +561,7 @@ int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap, indio_dev->channels = data->chip_info->channels; indio_dev->num_channels = data->chip_info->num_channels; - indio_dev->name = name ? name : data->chip_info->name; + indio_dev->name = data->chip_info->name; indio_dev->available_scan_masks = bmi088_accel_scan_masks; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &bmi088_accel_info;