From patchwork Wed May 25 13:08:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12861138 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 AF492C433EF for ; Wed, 25 May 2022 13:08:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243842AbiEYNIq (ORCPT ); Wed, 25 May 2022 09:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbiEYNIp (ORCPT ); Wed, 25 May 2022 09:08:45 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70098.outbound.protection.outlook.com [40.107.7.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 718C9A2062; Wed, 25 May 2022 06:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m0S+Oa6KVetd7DRLa+vMfI5AZrnZHcSg4cQGlMllcjuEizUMIpDyejn+7fgMZyR/Y2xbfbTB1K9iuS30V9y91S7Hzr9ONM9wShMxV+vmSqNEtdfsftWj1ROmirKJgL9Fxz/tf3frHim4fKsERnIpNdD5AgkzJX4285IRwN4HQq4V06p8Kf5sZSgZ01okMpP1rxHtcuAGExDh2kmSnYeDOBVqBT3ZNGu7TuTKuiry1WD7zWkfjFi8A/9OZUMqp5+5Tn4A1HAQ5yTkfPmtkXrTnqCm6mjGuUKGVUFVbVEjevULpAtOqIc9vg+KF+SRWuqar6rzUCXaI7T8CWm7dadHDQ== 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=y9YoyUl4Jwgq9M/1fNZmhEW5S01RQSaiaLfksrOzzJo=; b=MJTW1GnkDfj8vh/ggySOW/NadOWy6gtGB5y05nG6bMTCUp/818BpeRf+H8TsyyLUQ9MFtRxGa8uAwbfrKUR9TT5JpbvTcBkmnzgubGW/H4L8sZvJMwUlndL3JvqrmvjOVFpYw13THj50uk8zdmHivRtJUfm+pAACfPI2bydOhlnW7QZoVeqfWTdPqUzlTX9HS1v/qqMmnHFGxHa1fWRi1SFvZx7Wqpeps3hcpknU3dBa22TnwoNXjK4N8+35tgtx+ihcVd34rwQwdBakoPuiTdvVusZhbmrOZSbPfnmqDWUH5BcBxvl3iSkZqFzG5cXHCVp6qrjPln3uEHSWj56dRw== 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=y9YoyUl4Jwgq9M/1fNZmhEW5S01RQSaiaLfksrOzzJo=; b=KwE+BzCQtbVmY5ei48E3392Sk89IfXI2D7SX+9CnrQ7nqwLVjlxYmOssVa4wpQb3Pq6bkRvVKcMrx2YkF1jvcZAlFynSRflUdk+5SS0H0RjEda9gnFnppm5/4JwTz9sqWgt4Xw+TpjFue+0AqqWxB+8/rrmHJZ7PXiBhUsIE97Y= Received: from AS9PR07CA0017.eurprd07.prod.outlook.com (2603:10a6:20b:46c::13) by AM9PR06MB8052.eurprd06.prod.outlook.com (2603:10a6:20b:3a0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.17; Wed, 25 May 2022 13:08:40 +0000 Received: from HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::38) by AS9PR07CA0017.outlook.office365.com (2603:10a6:20b:46c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.5 via Frontend Transport; Wed, 25 May 2022 13:08:39 +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; pr=C Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by HE1EUR02FT051.mail.protection.outlook.com (10.152.11.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08: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, robh+dt@kernel.org, mike.looijmans@topic.nl, devicetree@vger.kernel.org Cc: thomas.haemmerle@leica-geosystems.com Subject: [PATCH V4 1/6] iio: accel: bmi088: Modified the scale calculate Date: Wed, 25 May 2022 13:08:23 +0000 Message-Id: <20220525130828.2394919-2-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525130828.2394919-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220525130828.2394919-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: 0c4aaac0-2aaf-47a9-4181-08da3e4fafb8 X-MS-TrafficTypeDiagnostic: AM9PR06MB8052: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: 870euEi/ecb5RwL52R/o2k5cxIfySJESZa5uGH3KTW8aATKfulDmv/B5vIuuKsZzb1WqkrGlLPGs5ftaRo6TVvVagiJsrCELfC2pf1xFjMONHiblEgQtXkaZCxykoyTXC03IKDJ836tR3jAnabeKzDsX2haN94yFIH6kPEo0QCYnQI+EmVH3NIqRlxFflqhAK27PVkhmPchDt9WRJP6fuPbIyt79xGSjHHaa39lw3EjhAvWwIsKHHkMn8eulZVNjDi9r9eWWNYWvGlpl2XR6dNssmmSb02kdlzYHVZ43KFm8SwYDRm5XhKzQyNHKA0VJlXFADffPAT0Jx//I/+L/piB2Yb2nBUhyIb+dZ/WAaKFrpNNvjg9HxO2ZhZcBXE+UbMyeOl5LdYiJFF/lgjVn9+1YEDUCHyfSbbzI7us23Krh2UvlJKQcRlt0bMDCuxINIAKnkUPSubnOxbx0QGqw2OAlKsmAvKoZsgdkT8TMiGojKpsDEP7K5CcRt7AND0P0Pbz5ApGqfpo8uGuAhb3Mrph0Zmnc0S4FyfyLVp7CIHJCk5gNKKdo3V2Ax+DS0673oKJev5S01GHpamfwPtRJHuDulfoc4/GVTKmEVwlgGKamou+EqcqtwLZoiF8ubyqOQYEv9SnnCah1DdxZ6Qch4svNv/yNucLnXlSD8dXzuLN36vOMAIMJzU0lJk59L+lwtYkbQbkOW1H+WxagetThhQ== 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)(956004)(107886003)(2616005)(316002)(36736006)(356005)(921005)(86362001)(81166007)(6666004)(1076003)(8676002)(70586007)(4326008)(6506007)(70206006)(6512007)(508600001)(26005)(2906002)(36756003)(36860700001)(40460700003)(6486002)(186003)(118246002)(8936002)(82310400005)(83380400001)(336012)(47076005)(5660300002);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2022 13:08:39.2617 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c4aaac0-2aaf-47a9-4181-08da3e4fafb8 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: HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR06MB8052 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 scales from formula to a list, the scales in the list are calculated as 9.8/32768*pow(2,reg41+1)*1.5, refer to datasheet 5.3.4. The new units after the application of scale are m/s^2. Reviewed-by: Alexandru Ardelean Signed-off-by: LI Qingwu Reported-by: kernel test robot --- drivers/iio/accel/bmi088-accel-core.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index d74465214feb..3f38967c5a0a 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -73,6 +73,8 @@ #define BMI088_ACCEL_FIFO_MODE_FIFO 0x40 #define BMI088_ACCEL_FIFO_MODE_STREAM 0x80 +#define BMIO088_ACCEL_ACC_RANGE_MSK GENMASK(1, 0) + enum bmi088_accel_axis { AXIS_X, AXIS_Y, @@ -119,6 +121,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 +283,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 +334,14 @@ 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; + reg = FIELD_GET(BMIO088_ACCEL_ACC_RANGE_MSK, reg); + *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 +437,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, 1794}, {0, 3589}, {0, 7178}}, }, }; From patchwork Wed May 25 13:08:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12861139 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 3E0E2C43217 for ; Wed, 25 May 2022 13:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243846AbiEYNIr (ORCPT ); Wed, 25 May 2022 09:08:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243831AbiEYNIp (ORCPT ); Wed, 25 May 2022 09:08:45 -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 AC2C9A0051; Wed, 25 May 2022 06:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BBrpTXqB2gyCEtkXAVnTsbjt3fAWli89E66ehT2WW372B4xp5nrPV9OlU1xiTF+JFsMapP9RcELGufzkPKKuiHVZHnxtch1gfvjKHy7NF5WKN7bndAQw5Ljm05b/kSW1slyso/IrZjk/w9o+sCLsZJBZw5TIavuGaC4JGYuiLkOTBRqOdPhWWluOBychNDCCIVo8PPset13QfsQzlgzpQx6YMA2eUOJ3XZ6dh1neXdBZZylMo+ZyVoco6DldzqDskks/8q8+xbRiHpfJC+hz+0iXJsl2ZLL4xbUP5WdYyfoTJEiFQhoq1lwcAf5P8uyGWkfcT18vt6G/YS3L/9sU8g== 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=oPNV8OcUZQZwvA1Ho/8hfSfgM+Q1/QC75fmVd0hzYFc=; b=e1ogvbvpom5VaKa1nbQCJeGTUjDDgdyAdgG6rDoOI8D6B7UaKDIq3vS+lw2Rpt/ay7xKn6OjsvQOfHP8K+lPy9piJpk97y4iQGYN4grpXfkr49JttefwL9/IWQWnVt/QTonjOoWpOTd4KHjL6pKxC5VkgAyNYmjN8BVQDBHod6mvDyifA3islhxihTCupfrGN9XHdbOGpm/EOAIlw3diuCwXFO+BMeBw7w73ra6hNzCYqXVRl+1Dqgjtn2FokV21MMWRk8G8R/UVGs6eJ4HS0bZZEGYmelfgEPi142C4HxGzkYiDtUKa7N6/Is/JW60EYtQhvHXdF4BRfF3moGFSOg== 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=oPNV8OcUZQZwvA1Ho/8hfSfgM+Q1/QC75fmVd0hzYFc=; b=eK6NnZH5MSk+9By3F3f8Tym0Sk9pR106W+1Kq1g9GsLzsAxxaoN3JgHTCMTXoo1JWY4VWeVmKDi76IeZJwYc650vBg+s8LH9IOYGys44WUuXQ0hWrzmsF6xbtB6LgFAjFQjsNi9k5DaefIgjuw85uMI/+y3Pg9f86Fm7GwWIACA= Received: from AS9PR07CA0016.eurprd07.prod.outlook.com (2603:10a6:20b:46c::27) by AM0PR06MB5252.eurprd06.prod.outlook.com (2603:10a6:208:fe::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.14; Wed, 25 May 2022 13:08:40 +0000 Received: from HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::6d) by AS9PR07CA0016.outlook.office365.com (2603:10a6:20b:46c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.5 via Frontend Transport; Wed, 25 May 2022 13:08: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; pr=C Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by HE1EUR02FT051.mail.protection.outlook.com (10.152.11.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08:40 +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, robh+dt@kernel.org, mike.looijmans@topic.nl, devicetree@vger.kernel.org Cc: thomas.haemmerle@leica-geosystems.com Subject: [PATCH V4 2/6] iio: accel: bmi088: Make it possible to config scales Date: Wed, 25 May 2022 13:08:24 +0000 Message-Id: <20220525130828.2394919-3-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525130828.2394919-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220525130828.2394919-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: 13032b85-9a90-4b7b-c45d-08da3e4fb03d X-MS-TrafficTypeDiagnostic: AM0PR06MB5252: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: n9LYALvPs2UolsKFmOTAbu2pGl41qeb3+V4dTmA07BkHZr0lOWFQfnxXOqaEuqUijSLqfLjyBusOhLnTW4uNUigxHLtjYEMbDmXmDXBCd5AtQQPHJxxGAMczwHNv/x+EH9g86mdgxqCa10eXDLrDIljTTC2j0g6IfUfbqR99jITRVl/P6V8LkCbK0Mf7wJBCQydZ35v7AjAZw764+el+k7d+MBE6PlNlPgL4pgYbUTbajJK/JP2MEsL3TuC+1zgWbIJXhLhk61PbQZad4Vlw5x8yW/9hV45rONdVYW3HbM+jiMoFyUX3MidZgIB/PqE0+4K7+1CfdciUeKREypLH2OLK7B8iTMOksnb6o3/exEQnsl9OrsKiVsM9UUHBqqIrsGaNVDQrUme0lFWBJ6qfVDhwOfDlmSbSb58W710p+mVRSgJQf4iIBuAvBQ3j0pubOby5Leh7sNdwD1xfn+MArXVvzev5On+T5l4kvilVLH6NrCsbjFjHXQtmiqHBVe5I4VMaXo+xgnPKzZKf5iZrRAFGFKfYJFLmow01TNXdRmUdt5NnAFnNR+kg8pX3uDh1WJfrFYVqi+sms0wQTsuOadCDj8KhclO5nVVRWD+toX/WqVImvFuhcCvliy0wLtGkZGvXwj6RisQuJ2WH2P1PJoH6yEdqpexg4XnAyk0k5tVp3Udf7smoObTZN4HTib4j 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)(36840700001)(40470700004)(336012)(956004)(36736006)(107886003)(6512007)(2616005)(356005)(2906002)(47076005)(36756003)(26005)(316002)(82310400005)(81166007)(6486002)(5660300002)(8936002)(4326008)(6506007)(83380400001)(118246002)(508600001)(36860700001)(40460700003)(86362001)(70586007)(6666004)(70206006)(1076003)(921005)(186003)(8676002);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2022 13:08:40.1523 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13032b85-9a90-4b7b-c45d-08da3e4fb03d 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: HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR06MB5252 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The sensor 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. Reviewed-by: Alexandru Ardelean Signed-off-by: LI Qingwu --- drivers/iio/accel/bmi088-accel-core.c | 33 ++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index 3f38967c5a0a..16c95d90f829 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -239,6 +239,21 @@ 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; + + 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; @@ -372,7 +387,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; @@ -392,6 +413,15 @@ 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) @@ -413,7 +443,8 @@ static int bmi088_accel_write_raw(struct iio_dev *indio_dev, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .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), \ + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ + BIT(IIO_CHAN_INFO_SCALE), \ .scan_index = AXIS_##_axis, \ } From patchwork Wed May 25 13:08: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: 12861140 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 67609C4332F for ; Wed, 25 May 2022 13:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243855AbiEYNIr (ORCPT ); Wed, 25 May 2022 09:08:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243832AbiEYNIq (ORCPT ); Wed, 25 May 2022 09:08:46 -0400 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140102.outbound.protection.outlook.com [40.107.14.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C10DD4BB97; Wed, 25 May 2022 06:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g5bHPaxoqlXZUVelWHJOQKCKSQfVhDZ2QCzmJ3Vce/jMxUxRdgfbNE2Dk6zhed6td0i1lrI4YvV+coPOoZvYZ0WZ8TK3clopZA5uX4MBhjkbFzbOvXyw/+H3ut9jxEI+1TCnLUO39plBg92RZ6uC79ZIkiI1mE73Hk63gZyb/hGcbJgkzqZQTXfbjzDGwtFN5ShHqf6SqklbQ4g21ArvacTnd2Qfvqk0WEK7yRFOPY5bcdWZMS8AciDKoBGPVvDaMjBh84GYrj7tm+WOsnf72GdwudWAgZOXmSsjT0cS6/n6D845HFeaggikWXNSgUS1vJLv6twPSORAIi45LtpFgg== 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=6XFlk5WFuK2cIX5Ys1DBdTbS/G49IjssPCzOyKESzWE=; b=A+txutBfLC1Z6SrbbHFhuCr/cosbX2IgQxDzAkTFFOqnzTSObkLWPCDzUv0tS1rE83Clo/45qQJRxpL9mUaWIJ4Pj86YDcR+YCKyZN1t/t2pQQbbFSzougS80zj8HRR/jo4j1sCtTTnaLJ0mHGXgQgNNFSl/UgW3x0TW/vIgm97GBIZSHOOlEXizihAvPTzPEBG8+SqbIxjGvVLNUKRAbJyWJJirvyTO45nNbVzleFRGPslC3o6qMrNI+AjzW53Syqowja5pPrFxwtrWJhtL8AQEgBMm7CzTDnR3FBHB5CIrXhAOaiyaeNd0JrXOhgluiFLeiv7uNMep58xyqrHVDg== 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=6XFlk5WFuK2cIX5Ys1DBdTbS/G49IjssPCzOyKESzWE=; b=dSYGEEwY65nvrlf6CmSLd+YqTIOD9j1nxopwJqpbcYf8vsurEAhasCXKmiG9+BT50kZVC4nJzdDIv0L/+JPwPuufc19N4qvq2XzmK+cgr5gXLz9mS31U/NG6KFRxxCsc98Z2xQ7XhSDWfVYZcdLJeRcsUXqFMfV4xH9uTUMExH8= Received: from AS9PR07CA0008.eurprd07.prod.outlook.com (2603:10a6:20b:46c::6) by AM6PR06MB4785.eurprd06.prod.outlook.com (2603:10a6:20b:5b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.14; Wed, 25 May 2022 13:08:42 +0000 Received: from HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::84) by AS9PR07CA0008.outlook.office365.com (2603:10a6:20b:46c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08:41 +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; pr=C Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by HE1EUR02FT051.mail.protection.outlook.com (10.152.11.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08:41 +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, robh+dt@kernel.org, mike.looijmans@topic.nl, devicetree@vger.kernel.org Cc: thomas.haemmerle@leica-geosystems.com Subject: [PATCH V4 3/6] iio: accel: bmi088: modified the device name Date: Wed, 25 May 2022 13:08:25 +0000 Message-Id: <20220525130828.2394919-4-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525130828.2394919-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220525130828.2394919-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: 8bc52cca-fc9a-4257-baad-08da3e4fb0f7 X-MS-TrafficTypeDiagnostic: AM6PR06MB4785: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: fRESdfyt6eV85kIAIV+L1SlpOiAS7aUHepSrRQ33N7qVNNCG6PkOarJbMDKDw1w1I8X7THlpJ1l9LTE3NIPE2twu1JWrUW3xYxVc1Z42HQlF+o2vdVwChKJANKpoBWkMlh054GNStBnbqlbza68FfG4kZF7qKJWOvlNzX0vfjJNvlzdykB2GF0zjz5OVya3GO05OA3nVBYJT1cROjjhJIO+GEolNpCJJbfchdHdPSnLjnFd665ue4lg7nY5UzcBulOtqmZT7eWOuKkn2vJSTfgpoZW4C0+PmG4LiXGurnO3fHeVjSuaw2NAvSKBIXxzJaT/xwZwypL93VtVblqHIxT8i3ZXCy8CvKe0JaQKucJvBAgt7R+3P0vPOkQAtA4vfj13NaoPx7dg8rATmLDHL8eX8RNon/flRHn6Kb1+MBCVSb2jSYw1D10TzKI3unwlVxnsva7Did487WgAWVPnCFz5LZtQsrmM9xJsGsZTOmXbPxSUJGn/VsCf3caKgHFEkRMU4oGXuyI2uO146B8WGZj3O6bSGbVlW1jptXODkQKUalBdNT/ccb2jqW6awk/Stwx95qEmKn42McAKUllQQQqT/EEl7Ab+WxP2SN6WZpZs6NwFfArU67nvy3cSzeJZXmwa1SmNN5U0dlVadcfH/ZaOw4iYkeXBizTilQI98zJ4lsFOqc3sh27AtWixbtxcxApLdm9plUwJTeKOYHsLBmA== 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)(70586007)(70206006)(6666004)(6512007)(36860700001)(36756003)(118246002)(336012)(6506007)(8936002)(86362001)(82310400005)(508600001)(186003)(83380400001)(6486002)(2616005)(107886003)(81166007)(1076003)(956004)(5660300002)(2906002)(8676002)(4326008)(26005)(921005)(316002)(356005)(36736006)(40460700003)(47076005);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2022 13:08:41.3554 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8bc52cca-fc9a-4257-baad-08da3e4fb0f7 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: HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR06MB4785 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org iio: accel: bmi088: modified the device name It is possible to have multiple sensors connected on the same platform. For support of different sensors, making it possible to obtain the device name by reading the chip id. If the device was found in the table but the device tree binding is different, the driver will carry on with a warning. If no matching device was found, the driver load the binding chip info. Tested case, test with bmi085 and bmi090 patches applied: connect 3 bmi090l to the system, and set device tree compatible: spi2.0: compatible = "bosch,bmi090l-accel"; spi2.2: compatible = "bosch,bmi088-accel"; spi2.4: compatible = "bosch,bmi085-accel"; Get a warning for the mismatched devices: bmi088_accel_spi spi2.2: unexpected chip id 0x1A bmi088_accel_spi spi2.4: unexpected chip id 0x1A Get the real present device name: /sys/bus/iio/devices/iio:device1/name:bmi090l-accel /sys/bus/iio/devices/iio:device3/name:bmi090l-accel /sys/bus/iio/devices/iio:device5/name:bmi090l-accel Signed-off-by: LI Qingwu --- drivers/iio/accel/bmi088-accel-core.c | 35 +++++++++++++++------------ drivers/iio/accel/bmi088-accel-spi.c | 13 +++++++--- drivers/iio/accel/bmi088-accel.h | 7 +++++- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index 16c95d90f829..fe8db9615d69 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -388,6 +388,7 @@ static int bmi088_accel_read_avail(struct iio_dev *indio_dev, 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; @@ -463,8 +464,8 @@ static const struct iio_chan_spec bmi088_accel_channels[] = { }; static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = { - [0] = { - .name = "bmi088a", + [BOSCH_BMI088] = { + .name = "bmi088-accel", .chip_id = 0x1E, .channels = bmi088_accel_channels, .num_channels = ARRAY_SIZE(bmi088_accel_channels), @@ -483,12 +484,15 @@ static const unsigned long bmi088_accel_scan_masks[] = { 0 }; -static int bmi088_accel_chip_init(struct bmi088_accel_data *data) +static int bmi088_accel_chip_init(struct bmi088_accel_data *data, enum bmi_device_type type) { struct device *dev = regmap_get_device(data->regmap); int ret, i; unsigned int val; + if (type >= BOSCH_UNKNOWN) + return -ENODEV; + /* Do a dummy read to enable SPI interface, won't harm I2C */ regmap_read(data->regmap, BMI088_ACCEL_REG_INT_STATUS, &val); @@ -514,22 +518,23 @@ static int bmi088_accel_chip_init(struct bmi088_accel_data *data) } /* Validate chip ID */ - for (i = 0; i < ARRAY_SIZE(bmi088_accel_chip_info_tbl); i++) { - if (bmi088_accel_chip_info_tbl[i].chip_id == val) { - data->chip_info = &bmi088_accel_chip_info_tbl[i]; + for (i = 0; i < ARRAY_SIZE(bmi088_accel_chip_info_tbl); i++) + if (bmi088_accel_chip_info_tbl[i].chip_id == val) break; - } - } - if (i == ARRAY_SIZE(bmi088_accel_chip_info_tbl)) { - dev_err(dev, "Invalid chip %x\n", val); - return -ENODEV; - } + + if (i == ARRAY_SIZE(bmi088_accel_chip_info_tbl)) + data->chip_info = &bmi088_accel_chip_info_tbl[type]; + else + data->chip_info = &bmi088_accel_chip_info_tbl[i]; + + if (i != type) + dev_warn(dev, "unexpected chip id 0x%X\n", val); return 0; } int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap, - int irq, const char *name, bool block_supported) + int irq, enum bmi_device_type type) { struct bmi088_accel_data *data; struct iio_dev *indio_dev; @@ -544,13 +549,13 @@ int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap, data->regmap = regmap; - ret = bmi088_accel_chip_init(data); + ret = bmi088_accel_chip_init(data, type); if (ret) return ret; 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; diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c index 06d99d9949f3..c77aec01bc67 100644 --- a/drivers/iio/accel/bmi088-accel-spi.c +++ b/drivers/iio/accel/bmi088-accel-spi.c @@ -52,8 +52,8 @@ static int bmi088_accel_probe(struct spi_device *spi) return PTR_ERR(regmap); } - return bmi088_accel_core_probe(&spi->dev, regmap, spi->irq, id->name, - true); + return bmi088_accel_core_probe(&spi->dev, regmap, spi->irq, + id->driver_data); } static void bmi088_accel_remove(struct spi_device *spi) @@ -61,8 +61,14 @@ static void bmi088_accel_remove(struct spi_device *spi) bmi088_accel_core_remove(&spi->dev); } +static const struct of_device_id bmi088_of_match[] = { + { .compatible = "bosch,bmi088-accel" }, + {} +}; +MODULE_DEVICE_TABLE(of, bmi088_of_match); + static const struct spi_device_id bmi088_accel_id[] = { - {"bmi088-accel", }, + {"bmi088-accel", BOSCH_BMI088}, {} }; MODULE_DEVICE_TABLE(spi, bmi088_accel_id); @@ -71,6 +77,7 @@ static struct spi_driver bmi088_accel_driver = { .driver = { .name = "bmi088_accel_spi", .pm = &bmi088_accel_pm_ops, + .of_match_table = bmi088_of_match, }, .probe = bmi088_accel_probe, .remove = bmi088_accel_remove, diff --git a/drivers/iio/accel/bmi088-accel.h b/drivers/iio/accel/bmi088-accel.h index 5d40c7cf1cbc..65338a1bf97d 100644 --- a/drivers/iio/accel/bmi088-accel.h +++ b/drivers/iio/accel/bmi088-accel.h @@ -8,11 +8,16 @@ struct device; +enum bmi_device_type { + BOSCH_BMI088, + BOSCH_UNKNOWN, +}; + extern const struct regmap_config bmi088_regmap_conf; extern const struct dev_pm_ops bmi088_accel_pm_ops; int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, - const char *name, bool block_supported); + enum bmi_device_type type); void bmi088_accel_core_remove(struct device *dev); #endif /* BMI088_ACCEL_H */ From patchwork Wed May 25 13:08: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: 12861142 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 2645BC4332F for ; Wed, 25 May 2022 13:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244053AbiEYNJA (ORCPT ); Wed, 25 May 2022 09:09:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242528AbiEYNIt (ORCPT ); Wed, 25 May 2022 09:08:49 -0400 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20110.outbound.protection.outlook.com [40.107.2.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FF72A2062; Wed, 25 May 2022 06:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W7VdczsEBB3vJrvtLfnxUENSZNaqooaXxzD7RQAV/m+rvi67iUiOjIIu/7E4UCUM5/MtP3R4BqMQHZAaaSv9S3uaFR73c9OBSV91qy39iHAkG2uGdeh2+Z7gKblGjlrTBlS4kQB4JVvCmP41olMJ18UaRnZqwMlQF9FSVmWXU2VCjkk0unvLtIZ6J2+DCI4O3B1nghgsWH5/Txtv0yiUYUnJRfH7sZ9KmyREJrkN78YAlAPc9QqEYcp1mnQa00bvjnwaBSx/tbN/VJzOwEoo5G0AUTMk6bC7CsAkr3ONMc73FDDEv3k1N95p+gWvrjCbhPo5SDCRRgLF074Linx9IA== 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=l3jdhWbWEgCxDYxcMZ3yohV5I+65uu+4kU3aTO5Y0s0=; b=VuKwhtyBSqXaDGU6BeTcN72qY3rmV+8+FNy+9mmgU9JX4mbpCNm3a648fhggAjvJFJdEyUj+c5QN+J46AK8Od1JYCgvYeLt/ZnqpbR7CvNGgOgxMtdecVhzUwtGvCUkCjTH6RpSnwLGWbWnhfQVy/pL5GyQ1YXKxlzryHFXRN8NUA94SdGxwxR0FWlO6VLqmhFaevLlvwXVXkMSRqPTu09NRwVx6nQUDCTa3ZO8NxD7LZYd2bodsT6GVKCNFWn2eUYEyXOwLiXaxAvxmCYNTzbQHpHHHYdVaVwdktsTSWvb/hPNUDHH1AXAyES59YFZx9yJX9XxDUrcBIgJs28lYHg== 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=l3jdhWbWEgCxDYxcMZ3yohV5I+65uu+4kU3aTO5Y0s0=; b=bVaVCMrj5rlam9hAZP9BBLydTTUCAI29VmugWMLJlfvMrueJ871pwwnlx/o1zrtWr4GrYVmyqTHUcZ2r98tVM3fb+NqWWk4jKDs7ab0etMc9Nwp375vg+GpKIfkauU2Ci0uwONrh0crSvIP4l0gse+gGZGs43TcbbhAHV3hcd6Y= Received: from AS9PR07CA0002.eurprd07.prod.outlook.com (2603:10a6:20b:46c::20) by VI1PR06MB4014.eurprd06.prod.outlook.com (2603:10a6:802:62::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.16; Wed, 25 May 2022 13:08:43 +0000 Received: from HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::b5) by AS9PR07CA0002.outlook.office365.com (2603:10a6:20b:46c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08:43 +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; pr=C Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by HE1EUR02FT051.mail.protection.outlook.com (10.152.11.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08: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, robh+dt@kernel.org, mike.looijmans@topic.nl, devicetree@vger.kernel.org Cc: thomas.haemmerle@leica-geosystems.com Subject: [PATCH V4 4/6] iio: accel: bmi088: Add support for bmi085 accel Date: Wed, 25 May 2022 13:08:26 +0000 Message-Id: <20220525130828.2394919-5-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525130828.2394919-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220525130828.2394919-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: 62ee2fd3-af79-4ef2-c53e-08da3e4fb1a5 X-MS-TrafficTypeDiagnostic: VI1PR06MB4014: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: uA4X5kuy+sVVLG5IUWk8C+bu6/i7vfXNJA2tR5nZSRHwsQ5hcaJFDZEY/e4dGyNXv5TV0b45QL2baiW9N69wPYVUNUPQD0/Q7p174chhE9ViMxnBMzLIaMNlBLXsqo5pNYebmJvkiy9lA/iNfNt+h9A49H68vtc/cKYhrZaFU6zrXDyho1BOStmzVKzeq8vz7unbg9GfhIRKiBI5y97Y4O8jYmFqCTBCoE6mSeRMLY/KEjI385Bt4/WhiuouC9LmlipQZbXe0uJsriMQdCySBEWutaHdkVSceTTkZF2iLHukEI4F//tjoOBBx2D2lInOq+UhuBQME0qNc/QMoCMLB7+VoY5Z2nkYnb+dnulEypOHpiDo30SF6Rx3544b36T416ZGZO+bX0eTr8iRMC3+hRxySf0Hb0eaeWj+98vQRTvAdXnGoWSdwb1+V9XakwD6LvKKaLXE1t/1ivNCVmcbPyrjrp/3Swk7l1qQN+LZZiO0ZAG/ADsI23wuPjcohVos5Gfe+Drr2f7y8McwGWANGrc1ofitl9pmYgfBkkqflMUcU8mjr3s8ewLB+l2rslnFDLfKarWz1qpZfMeHuDNZ9tkJupXeoWf94BYIbp+k/ea5VM+IFXaoKfJV1LeWQpBWXf4zwAX3lHaBakDlvRY4tIi94cpHb6G3xZ7LP07gBdMzhl11PqwGTwZWSXToAyCw 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)(46966006)(36840700001)(6666004)(2616005)(47076005)(81166007)(82310400005)(118246002)(356005)(956004)(921005)(107886003)(186003)(70206006)(36736006)(336012)(70586007)(8936002)(4326008)(8676002)(1076003)(36756003)(316002)(36860700001)(86362001)(26005)(6506007)(508600001)(5660300002)(6486002)(6512007)(2906002)(40460700003);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2022 13:08:42.4960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62ee2fd3-af79-4ef2-c53e-08da3e4fb1a5 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: HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR06MB4014 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. Unlike BMI088, the BMI085 accelerometer ranges are +/-2, 4, 6, and 8g, the scales are calculated as 9.8/32768*pow(2,reg41+1). Reviewed-by: Alexandru Ardelean Signed-off-by: LI Qingwu --- drivers/iio/accel/bmi088-accel-core.c | 7 +++++++ drivers/iio/accel/bmi088-accel-spi.c | 2 ++ drivers/iio/accel/bmi088-accel.h | 1 + 3 files changed, 10 insertions(+) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index fe8db9615d69..18becc857d49 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -464,6 +464,13 @@ static const struct iio_chan_spec bmi088_accel_channels[] = { }; static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = { + [BOSCH_BMI085] = { + .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}}, + }, [BOSCH_BMI088] = { .name = "bmi088-accel", .chip_id = 0x1E, diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c index c77aec01bc67..b14a1e5b986a 100644 --- a/drivers/iio/accel/bmi088-accel-spi.c +++ b/drivers/iio/accel/bmi088-accel-spi.c @@ -62,12 +62,14 @@ static void bmi088_accel_remove(struct spi_device *spi) } static const struct of_device_id bmi088_of_match[] = { + { .compatible = "bosch,bmi085-accel" }, { .compatible = "bosch,bmi088-accel" }, {} }; MODULE_DEVICE_TABLE(of, bmi088_of_match); static const struct spi_device_id bmi088_accel_id[] = { + {"bmi085-accel", BOSCH_BMI085}, {"bmi088-accel", BOSCH_BMI088}, {} }; diff --git a/drivers/iio/accel/bmi088-accel.h b/drivers/iio/accel/bmi088-accel.h index 65338a1bf97d..044999eb4fd6 100644 --- a/drivers/iio/accel/bmi088-accel.h +++ b/drivers/iio/accel/bmi088-accel.h @@ -9,6 +9,7 @@ struct device; enum bmi_device_type { + BOSCH_BMI085, BOSCH_BMI088, BOSCH_UNKNOWN, }; From patchwork Wed May 25 13:08: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: 12861141 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 C1327C433FE for ; Wed, 25 May 2022 13:08:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243862AbiEYNIt (ORCPT ); Wed, 25 May 2022 09:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbiEYNIs (ORCPT ); Wed, 25 May 2022 09:08:48 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70137.outbound.protection.outlook.com [40.107.7.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34C1CA3085; Wed, 25 May 2022 06:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jBvDrgSFIQUdftEFTEbbbm0hNenCIEgF3XSpGTk9Rg3Ove6IIUIdRdF0M/AHxn5s7I6bwZ1seuJS6dwXZOC8xohEYabRXfbaX2xDQsZvkYAke/dPAGzPOgzYqAUczDfoQH1a6xmloMxVVBRkauhgPB/I4xCqB3qgLgVPvuFBp6vO9wf2jyxSQk5jS8w1cTqeNbl6w/FuADk4OSu/v1/iRMU64TwLeIqMsGHNYNnuOmtOqGamWS38eX8zirTb0Z19Y2lF3y3QvrNyiRv9uHwDZGF8S0EbGykPenALXWSwvJ/v3bpBiElluRfDvaUFQdrcurdSN0CCL8XotU0MMNu/jQ== 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=yN1aFnLydPoTPm2oaAwRP1LHFnQEE/CLOPfQrCgL0oA=; b=NjRn3r0UvA5cL+P4o9JlXQTu8zIjQHgRuxz5y9o1OyKsWWTLpSlNSgqvLQKuFKDY7YtuCKjfxlvOU5+ua7Dfw3soGZS5+SiEA2RPNZjyfWOOFMwm5sZO3hgEQ/jneEzuf+Spb/iX3suvfwcmihjLNf1SnyKwVFnzGrjQiK5kvxjzhXw9tlOdZCL+xzOLWSeNvdUpcy+a7SX06nS8TBerGQMGgSqMg73JOD8jUgJvF8DqWENlEyiNGeqYL/ApQZPzdOAyzB5UFYqVaeVjVnE89QhokIM0l+GCuegPqaU9CsNVyL+dZ8iIuJtnBmxf0tWGR7CZxvUZ+vYJA0lPaqK8yA== 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=yN1aFnLydPoTPm2oaAwRP1LHFnQEE/CLOPfQrCgL0oA=; b=LdthVRAIB8634Yy7MC0QuqHauWT/tV9TVjJClAWTf1M91UplpmvBS/Em1+gi9oRge/q5qg0YTigjmmf64khBgOPpfDg0sM5Db6ag3jSefsWNPPsVyu08UMXRgeox07xgsLObcVmpyt15uR+Btexk0ZeHgUMxbQ9i/hXpeVkLtQI= Received: from AS9PR07CA0019.eurprd07.prod.outlook.com (2603:10a6:20b:46c::23) by AM6PR06MB5747.eurprd06.prod.outlook.com (2603:10a6:20b:57::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 25 May 2022 13:08:44 +0000 Received: from HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::52) by AS9PR07CA0019.outlook.office365.com (2603:10a6:20b:46c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08:44 +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; pr=C Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by HE1EUR02FT051.mail.protection.outlook.com (10.152.11.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08:43 +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, robh+dt@kernel.org, mike.looijmans@topic.nl, devicetree@vger.kernel.org Cc: thomas.haemmerle@leica-geosystems.com Subject: [PATCH V4 5/6] iio: accel: bmi088: Add support for bmi090l accel Date: Wed, 25 May 2022 13:08:27 +0000 Message-Id: <20220525130828.2394919-6-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525130828.2394919-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220525130828.2394919-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: 73a4bde2-487a-41bc-0984-08da3e4fb26e X-MS-TrafficTypeDiagnostic: AM6PR06MB5747: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: QBkJ9VTDoln8Nqo6UbZOV8BiN6DpnXTmdgXCoyvtfqO6M4rc8yZYHvhmAYNwaV1e460RLfk+hmgapU7bLFkTqJ1PqIj+iLJxlE3F16Ym1Z2NnKiANkE1eBp3x1WOSrNiFJNhcwqb3dj0aGIdgr93Txf2QxSSmCwypt7S9QsooWOUU8GXTDKNbPBPJxx/PptRvKOqKQThbQ5EtclR4nu5esDwfGvMNLxyumGp0pa22VbQEEnPsiHn5uZv654YsbzSC4cDssH+TtHSYYNVTEM5C65mVRkYNMqbxscjuvoZsoS6n6wqQy4/7jBVrguY1hFwuyKSsdT0urYZbSLbY6f5n6gBR8AC/xGgkHnBVB340dVeLK8242zrMWsV/mtuOtIC15/ubg5mtoomudG8dyKHZpl09RBbGdFoGByZatwh7y2T9Giwix/I8rWA4Ct4Ofb11aDUpu5KSQ2XfMC8ODN42TaubPuSWTDzW50aKa1c/yrcjm+o37wVam0GzSGtJwynpyHCc4l2rali8AFy+5rF9kzftaGtVDUwckDwSFeymUtgYUGe5t+YUakSVPU7GMP/etB3EMo/uoBITAINPCCHj189gkUjtiaAmMF1UYwVr87txiXANWceWa0FhIX0n1g7OAyJI4nODlTGtqh4MXChfa0/I+1O9MaQsRoIJhoKW17p+6JFQPVlHpk7IEmHjWjm3xVKJIBj47b0HW5OU3EV2w== 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)(36840700001)(40470700004)(921005)(6506007)(6512007)(26005)(6666004)(81166007)(356005)(86362001)(107886003)(1076003)(336012)(2616005)(956004)(47076005)(36860700001)(118246002)(5660300002)(186003)(316002)(36736006)(40460700003)(4326008)(70586007)(8676002)(8936002)(70206006)(508600001)(36756003)(2906002)(6486002)(82310400005);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2022 13:08:43.8084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73a4bde2-487a-41bc-0984-08da3e4fb26e 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: HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR06MB5747 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. Reviewed-by: Alexandru Ardelean Signed-off-by: LI Qingwu --- drivers/iio/accel/bmi088-accel-core.c | 7 +++++++ drivers/iio/accel/bmi088-accel-spi.c | 2 ++ drivers/iio/accel/bmi088-accel.h | 1 + 3 files changed, 10 insertions(+) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index 18becc857d49..631cd66476ce 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -478,6 +478,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, 1794}, {0, 3589}, {0, 7178}}, }, + [BOSCH_BMI090L] = { + .name = "bmi090l-accel", + .chip_id = 0x1A, + .channels = bmi088_accel_channels, + .num_channels = ARRAY_SIZE(bmi088_accel_channels), + .scale_table = {{0, 897}, {0, 1794}, {0, 3589}, {0, 7178}}, + }, }; static const struct iio_info bmi088_accel_info = { diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c index b14a1e5b986a..8aa25138f098 100644 --- a/drivers/iio/accel/bmi088-accel-spi.c +++ b/drivers/iio/accel/bmi088-accel-spi.c @@ -64,6 +64,7 @@ static void bmi088_accel_remove(struct spi_device *spi) static const struct of_device_id bmi088_of_match[] = { { .compatible = "bosch,bmi085-accel" }, { .compatible = "bosch,bmi088-accel" }, + { .compatible = "bosch,bmi090l-accel" }, {} }; MODULE_DEVICE_TABLE(of, bmi088_of_match); @@ -71,6 +72,7 @@ MODULE_DEVICE_TABLE(of, bmi088_of_match); static const struct spi_device_id bmi088_accel_id[] = { {"bmi085-accel", BOSCH_BMI085}, {"bmi088-accel", BOSCH_BMI088}, + {"bmi090l-accel", BOSCH_BMI090L}, {} }; MODULE_DEVICE_TABLE(spi, bmi088_accel_id); diff --git a/drivers/iio/accel/bmi088-accel.h b/drivers/iio/accel/bmi088-accel.h index 044999eb4fd6..80cd396a3141 100644 --- a/drivers/iio/accel/bmi088-accel.h +++ b/drivers/iio/accel/bmi088-accel.h @@ -11,6 +11,7 @@ struct device; enum bmi_device_type { BOSCH_BMI085, BOSCH_BMI088, + BOSCH_BMI090L, BOSCH_UNKNOWN, }; From patchwork Wed May 25 13:08: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: 12861143 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 76664C43217 for ; Wed, 25 May 2022 13:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244152AbiEYNJB (ORCPT ); Wed, 25 May 2022 09:09:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243872AbiEYNIu (ORCPT ); Wed, 25 May 2022 09:08:50 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70137.outbound.protection.outlook.com [40.107.7.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33210A3091; Wed, 25 May 2022 06:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cawh2N15Mzvsewy7BmA/xRwfQBJHblNxazBs79MswGBmWf5femq5SEimVgPt9lxMUfgTbJ0fxrk1bpEEOnOv+riWSLFDndp14PXduGh7j/qlCwzKkDQ+NjwcMI6elkrCRpvv807AaVF9ajQCASQEB9PbcppJJWpK6siyqxpvYHJlcsz2NKoX9vWmEktIaWsJJv5mqIEiZroovM/dbyqiteT67UrXxBd83E8l/IoYJrulIjcMSsYEoj2F3aGlm6KgRsmG2+pkmyoiJIZ48e76UVMnn4chb08e5SrStD5Kljgxyjkgx/eF3li3yrzLuX5lWf8RyhGNI7BqrIWjwyzagQ== 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=MgOWtc0h84OfR0/XgjFODhvBKtLJ+qAcjYntEln1lJc=; b=iGXlYcc8fXtmEovrHe+FRp2NvZFsEPFG2MABUcAxziY9l411b7y5uyNnQEw5vAAZSwwYNVeSd3gERsedm0hdCQuBy6qI1M+pFJ+1tDp7O/GEiJ6zLjdNqs7aJo+PIpY5WfRHLX3YqVbnAwOiUGcrICRuERqB0EGLzuWnO3+NlBpg/TNL88QjkxCa/4r/mykAK7z98HzWTmDkDx4ni+9a0iJ49I2e/Lp5rz1HBlQqDkUma7KGLvNwHcrSgduuktWLEjSKFwIFSx7s7rxY9koyu78TRTS1pQEHXYVPgjVVPh7y17utPE3nmzLn91oTXyKxgm+9IHRRmPT+VBr6hkW8VA== 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=MgOWtc0h84OfR0/XgjFODhvBKtLJ+qAcjYntEln1lJc=; b=QCpj73FtbHOP2RM/fspaPo0eFfmwGBtWuvTnINdzM1CQ6OjCcnvr/LVd5DCFkplPM8s2tdxr4lSrEKgtD4AcpFkWRMNNG7ZJAHP4fiJ8NzpC1eTdQdymm2w5eYsuuvot4J2+2JkxPzNnk8f488FjZnECp9QwtVV9VJDlUXd2gfo= Received: from AS9PR07CA0019.eurprd07.prod.outlook.com (2603:10a6:20b:46c::23) by AM6PR06MB5747.eurprd06.prod.outlook.com (2603:10a6:20b:57::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 25 May 2022 13:08:45 +0000 Received: from HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com (2603:10a6:20b:46c:cafe::52) by AS9PR07CA0019.outlook.office365.com (2603:10a6:20b:46c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08:45 +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; pr=C Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.94) by HE1EUR02FT051.mail.protection.outlook.com (10.152.11.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 13:08:44 +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, robh+dt@kernel.org, mike.looijmans@topic.nl, devicetree@vger.kernel.org Cc: thomas.haemmerle@leica-geosystems.com Subject: [PATCH V4 6/6] dt-bindings: iio: accel: Add bmi085 and bmi090l bindings Date: Wed, 25 May 2022 13:08:28 +0000 Message-Id: <20220525130828.2394919-7-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525130828.2394919-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220525130828.2394919-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: 58716185-c888-424f-2865-08da3e4fb310 X-MS-TrafficTypeDiagnostic: AM6PR06MB5747: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: FwrvwURUf5gfv72+Uq99SOeOOsr0ddMzn4FYSvqLfNAftVMazKfFTUko/CNXxW110iVNk0ShI6SYiinW5JJt4fkKR9c+xe9+cN920N3vD06jnZCgpHeotce9n6rtjAJ8W2WNB0XyscOrLCV7jO7xU2Rr2iCblugC3fdQnmU+pE6O+ZZJZmu2xvZ2Kdb7oY1rUVc8UGpsewCuo0nOIYfM3b9IJOgEnW2XsHLVD69ZInGzHQB6743wP1LD/6dIMO7M3u4qjMLBL3l+FmGOsfmqrPJVQ98ei/Z5yatt61aCeGkRUf33QAFrUcxpPWH6pj3qjNd0lEt6h1uBPnNMs8wKl9dB+0RICDGDyJnlyIbtH5LQKJ+UivxHZzzsW8dkt8xxC0gGvueSPxROebFVeizekRyLyHg1aUtXB1OMcq9SuQ0SZSWaE2KiJCvVXsUeSD2etWl2xGK2m+aYpsYzyvd4TCoGOFZ7ymRLMVH9ndGaF11O0dl6AwhY6TYbCj9oi9XolBlReVJ3ee0uRxTStE6221LbsfeuAL4o1dxjeAcq8eYPO5TNdIHP+ikZVnrLsL8DJ63/AlAtW/yPegeywUl7dPtXYDHUxen0MPotHUbx4kTAjckKB1Z7O5e02LSuSC5FNbZDrPOjDzK2p/CJ8QjiGeKol7xQ+uHYrk4JEruVz5n56vuhvEDQIzlKkrZiZkq24jnv5tch0e1kyUhJ4C2gP5mnnqIpI+2x+OV2krRsK5HCvpSpjrsBG30emPJU0YGoepPbfeDqnpi8U6w89XbaVp4/h3PZX4U59jgiZfg+JgI= 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)(36840700001)(40470700004)(921005)(6506007)(6512007)(26005)(6666004)(81166007)(356005)(4744005)(83380400001)(86362001)(107886003)(1076003)(336012)(2616005)(956004)(47076005)(36860700001)(118246002)(5660300002)(186003)(316002)(36736006)(40460700003)(4326008)(70586007)(8676002)(8936002)(70206006)(508600001)(36756003)(2906002)(966005)(6486002)(82310400005);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2022 13:08:44.8865 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58716185-c888-424f-2865-08da3e4fb310 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: HE1EUR02FT051.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR06MB5747 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Adds the device-tree bindings for the Bosch BMI085 and BMI090L IMU, the accelerometer part. Datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmi085-ds001.pdf Datasheet: https://media.digikey.com/pdf/Data%20Sheets/Bosch/BST-BMI090L-DS000-00.pdf Signed-off-by: LI Qingwu --- Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml b/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml index 911a1ae9c83f..272eb48eef5a 100644 --- a/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml +++ b/Documentation/devicetree/bindings/iio/accel/bosch,bmi088.yaml @@ -17,7 +17,9 @@ description: | properties: compatible: enum: + - bosch,bmi085-accel - bosch,bmi088-accel + - bosch,bmi090l-accel reg: maxItems: 1