From patchwork Thu Feb 17 06:27:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12749459 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 27A2DC43217 for ; Thu, 17 Feb 2022 06:27:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235553AbiBQG1d (ORCPT ); Thu, 17 Feb 2022 01:27:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235427AbiBQG1a (ORCPT ); Thu, 17 Feb 2022 01:27:30 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2107.outbound.protection.outlook.com [40.107.21.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B63BA2804F0; Wed, 16 Feb 2022 22:27:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HvTvCyVy/VpoLu1cGfCz3ayXYNEkKvzqll+y5Y3HEfoIRnxof9ifyhQ1/J4kDm02AckbiZBsMdwk87zxwsXlr6PqQ7N08gTMzgsAkPK+ShJvL1kTQd3T05tWIx6CfxbTmQ21GTwI6kDH0bTDXaRBRNjNc3a+HmGJlIQDdiHO8DkwtqCOcE1Z1M2XUgH33IPw+B6scMSUfsWpQuH7ZYXrysaiJ9wWz0wTsTDrDQ9AHXRtafLyQ4r6Lqw70obWtMfEjBGeXWlwdD3hGdHvDag8+r7+cJPWBIrq4E8k7iFKkJ3XtgyGN1jfDaULFDb50LtKAZY0229c0rtICNvN1sybrw== 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=r8pF8QoyeW8SoNhfIv4dgfaNxj6MxM2G5WRPmaYL3rM=; b=IyVFm6O3L6tl3fxv6AZ+sAjEsvSV0vFnPaDQGzX5H5SIfaPJKtEL82db0/ZQ4W8tjpSQw2VwftSsxZwQSh97gn28om2FA7HBmVgq1tpJoAbEU+sM155DfHL/iZweVIc7ddZ3m0lHTBCpPXqLFQTfv90dxrIWRt3EofbFiGVDcLxXeLc6XPNRc7ZrAlxEwmCkxb9yX3Xgr145dyBExXoHVyvzokArYFbrWUpjBeOtdWZnRnT1i8k61xEibCgePhBXAWXANvrhoguwBBxVDwCm43oN9PP8KpHR/ezm3St5iyojiJn67VR239LI91RF1q/+TIEX8kRJzdfZBvV3Z/8Vww== 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=r8pF8QoyeW8SoNhfIv4dgfaNxj6MxM2G5WRPmaYL3rM=; b=quuqjDUSWGFhHjpswXRSr4ohFLThDaSC3smBIFRy8JucpDRDBsWuDa6eQwRCW8c95RfBWAUDCDsejTg/jDBbBwSbMpK2kWr1NYXLRv92q9BS4pVJuH+6RbnvmeUC44k3hiDechG+kfYu86jqv9vC4tJXsehHUsOPakwIwvQWgW4= Received: from AM6P192CA0107.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::48) by AS8PR06MB8244.eurprd06.prod.outlook.com (2603:10a6:20b:349::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.15; Thu, 17 Feb 2022 06:27:09 +0000 Received: from AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com (2603:10a6:209:8d:cafe::bc) by AM6P192CA0107.outlook.office365.com (2603:10a6:209:8d::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Thu, 17 Feb 2022 06:27:09 +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 AM5EUR02FT043.mail.protection.outlook.com (10.152.9.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Thu, 17 Feb 2022 06:27:09 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, robh+dt@kernel.org, tomas.melin@vaisala.com, andy.shevchenko@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Cc: linux-iio@vger.kernel.org, bsp-development.geo@leica-geosystems.com Subject: [PATCH V2 1/5] dt-bindings: iio: accel: sca3300: Document murata,scl3300 Date: Thu, 17 Feb 2022 06:27:01 +0000 Message-Id: <20220217062705.2867149-2-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217062705.2867149-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220217062705.2867149-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: b81072c9-e360-42b1-ca01-08d9f1de86dc X-MS-TrafficTypeDiagnostic: AS8PR06MB8244:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1079; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7aTl8bP1hZ39D0RNdIOoWJY/O0MQ6zaD3nPKKwdzadAG/veQ16LQL7PHCCBOo6Pw1cAnujYWnheeCZ5asCS+oXNOQ/3LIdSv3GbDHFwP8RyQyrs3Mxc4T6TB6U3rPLp27waIgT0p2Vdhc1X2T11PGVy4vWobCLv9H+hw6R+Sn9QJ+4EEBtsOxNuvocWUtTu/0fNfNE4U+rflbJ4/ra2/O3+wCrr+9VKQYGaemPb3ONn/iRKzCxu8eun1Qui4iosN7ZkBpgNsdddRlsa1lZtlmQCcI4aUVQwhyuu4kn42cPTGHxR0D+mDwgK+bDkeKqTW/fvDLoflnKsQ44PRRfM6GSfeyM05wJJf3cC0Hfw2vz5vXg1vEsE89C+dRKG5xJgUUlPiuIB0UPm2zMOnBlB+7xPBFo6GSjp60GUsuh8I1Tp7IOsRkIZmJCwQQ7OXgjxgsShC7gxLI/nsx14JjawRD5y5u3BE9DmWM2RGbVFS5oifb8aS0QjFBMcktGnQiw/cfM30IRMx04eN+4jvNzt59L/N5MqX0NZRBhk7KsAvrsQ3iESn7E0cFle4pk9fG5vJtFsVMavb3dGlBKcAnWgCmnzvBHKu+Mgta265VXgDo/aL5fEzMTWFIHVogtaeapW2PdOGUyLA9SatPBD7GmpwM2yCR6KgVqwtr3iTvwYqHDtuduj7l4tLdyICNDZPWTmx 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)(6512007)(86362001)(6506007)(36756003)(47076005)(36736006)(6666004)(186003)(316002)(107886003)(8676002)(4326008)(82310400004)(70586007)(70206006)(40460700003)(118246002)(4744005)(26005)(8936002)(336012)(1076003)(956004)(36860700001)(81166007)(508600001)(6486002)(2616005)(356005)(2906002)(5660300002);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 06:27:09.4735 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b81072c9-e360-42b1-ca01-08d9f1de86dc 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: AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR06MB8244 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add DT bindings for Murata scl3300 inclinometer. Signed-off-by: LI Qingwu --- Documentation/devicetree/bindings/iio/accel/murata,sca3300.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/accel/murata,sca3300.yaml b/Documentation/devicetree/bindings/iio/accel/murata,sca3300.yaml index 55fd3548e3b6..f6e2a16a710b 100644 --- a/Documentation/devicetree/bindings/iio/accel/murata,sca3300.yaml +++ b/Documentation/devicetree/bindings/iio/accel/murata,sca3300.yaml @@ -17,6 +17,7 @@ properties: compatible: enum: - murata,sca3300 + - murata,scl3300 reg: maxItems: 1 From patchwork Thu Feb 17 06:27:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12749457 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 6ECBBC4167B for ; Thu, 17 Feb 2022 06:27:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235572AbiBQG1e (ORCPT ); Thu, 17 Feb 2022 01:27:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235426AbiBQG1a (ORCPT ); Thu, 17 Feb 2022 01:27:30 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2091.outbound.protection.outlook.com [40.107.22.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F7B31FFCA7; Wed, 16 Feb 2022 22:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ChmCUhF5sjvqlirtQwRtyq4EhDX5dzDUQeW8wJiVhd0WrzxKJERVuTOm1PqyorB6DsRylZL0ZITGeayFmMJ9Wa1vbwnju73ek+AL42t7x59xS9tw6qXfhJ8AtZ6LHHW+EZ56IK2g800PI9mZrNS3FbpaFCNSRREucO/+6VSa1YceQocC/XMmFCtyYl2Ui/J8iM7jFnaL3AAslco9jsgPETLhxkLndnNsouguhQrIeRVkrRrBbd5OXeBLwe9gwUFJfQbch9kBdVTfzU9o0ElhEshr80RLxdfWaMOf6loNaSkj0dtav/serRLYeolNhsfTk9WnkCKlkkRjV/40ZKP+3g== 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=GLDuV2KrgenZkIPe4JZZX6YDLV+Fb0+07JQWbhDnbSY=; b=N1oggykPGhqRoNc4RVwLsZY5cWFz+UH8MWgsuKKPz93Jlm1FiD1XT6VtP3jaUGfi3x91A6AomJBNLXGFofCy5vxhOVN99LCkj/YzFnRsqJZKUUY8QTafMk1TY+8o/PGfWwxpg+Ksqii21x6H3Ic+gwtRJ7ROiTOBwYNPjGeAsYHNcb35pK5RvV/5TvxWc7C12EtdwlInSo2jp+J3z8qVYCqdXOy78K5LXzJOtkWrxS7ec8mLCXzm0CAt9lwts1C0NDZJqMXYZ1v/nBvtI8OpKfnAR8SppuHD8rQJJNihjW09v+EKHMC2z2WUvBhkVE0JeU8pWsGbMqMRG8f3FJpMpA== 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=GLDuV2KrgenZkIPe4JZZX6YDLV+Fb0+07JQWbhDnbSY=; b=cU7RRm75TbsigVDyoISfMBaQCGYtlwo7+8iurMwxkYwbgWoCd2Q36onbXYtpEUDj6FCFxfQSa48oW/6lLhhv9DXXim1TCA1wXo9jcjaaKWwtPN+1ETXUU73nu3fFRYjABe8/dZKB5F6TsMmlpJbA3Xn/chXl0nl8LHudKw8b6RI= Received: from AM6P192CA0078.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::19) by AM7PR06MB6487.eurprd06.prod.outlook.com (2603:10a6:20b:111::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.17; Thu, 17 Feb 2022 06:27:10 +0000 Received: from AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com (2603:10a6:209:8d:cafe::5d) by AM6P192CA0078.outlook.office365.com (2603:10a6:209:8d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Thu, 17 Feb 2022 06:27:10 +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 AM5EUR02FT043.mail.protection.outlook.com (10.152.9.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Thu, 17 Feb 2022 06:27:09 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, robh+dt@kernel.org, tomas.melin@vaisala.com, andy.shevchenko@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Cc: linux-iio@vger.kernel.org, bsp-development.geo@leica-geosystems.com Subject: [PATCH V2 2/5] iio: accel: sca3300: add define for temp channel for reuse. Date: Thu, 17 Feb 2022 06:27:02 +0000 Message-Id: <20220217062705.2867149-3-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217062705.2867149-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220217062705.2867149-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: c11ffb48-f080-4be0-91d4-08d9f1de8720 X-MS-TrafficTypeDiagnostic: AM7PR06MB6487:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 21dKtA1wlLitvsb+Bbp6/RpteOUBINTtwH0nvp3JMarNgxE3QfPtdD65V2SoAm3HqR5nk8VQLPrftfMiiHFwcjnE8NOpRoadpjs/M2ATFUxPrPU152pnBcAGzNqlwK+sbcg5e9QqEGJ7Jzr0HRYAOs3qnRWnW5bRBDi1MSkoN5phnGAbzsYj5dX12aHSL6168KExxZamn/E12qw2QMD17rNrQtdG5Ff6fsrQx/E8HgA+NNY+0d/gyb5C8tIPtHR/w4byfLVUhW+sQh2oXOS7VBQ0pq3A6+sI/63aLDhSmwuB3NYe+p4W1uHThVEjqn87BZJOKahPMriW7bvGXi9Bcda7QRl3JpS0rnywFeqqiv27ch8Ga7163vUJysPCNqR2u7oOYvgc+qkcaRt8d7fn9SX9RaApq4tiSEdLYTxiMmS1HQ1ekkRi4wDIZI8KvJQL2FgY0qsTYmzzAd5hKFadxgcgglZX5kZHmqwzdI3RrsiE2KijtVb6UcuZK3au9XMcpDxdh+tJh9Gn4jZs5UH4Z+BtbNKs1eAPWgGeaukHUCyTFzf712kIoHPE/yrmh+JOBo7oI4CpWrae50HDxMxPlbJI0JDoOn7yWG5bOhtS6dQI/GBIVMvUHPy+KpGAcf7GT7m7yL8FoYa9OWbk893kj/yKiQXAjJzFQydpSAxPzWAGiT+fBKlEXBrgFl+Qt9BW 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)(4326008)(70586007)(107886003)(6506007)(36736006)(6666004)(186003)(86362001)(2906002)(6486002)(508600001)(5660300002)(8936002)(2616005)(956004)(36756003)(26005)(8676002)(316002)(336012)(70206006)(1076003)(82310400004)(40460700003)(356005)(47076005)(83380400001)(6512007)(36860700001)(118246002)(81166007);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 06:27:09.9187 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c11ffb48-f080-4be0-91d4-08d9f1de8720 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: AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR06MB6487 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add define of SCA3300_TEMP_CHANNEL for reuse. Signed-off-by: LI Qingwu --- drivers/iio/accel/sca3300.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index f7ef8ecfd34a..ff16d2cc8c70 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -72,22 +72,24 @@ enum sca3300_scan_indexes { }, \ } +#define SCA3300_TEMP_CHANNEL(index, reg) { \ + .type = IIO_TEMP, \ + .address = reg, \ + .scan_index = index, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .scan_type = { \ + .sign = 's', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_CPU, \ + }, \ +} + static const struct iio_chan_spec sca3300_channels[] = { SCA3300_ACCEL_CHANNEL(SCA3300_ACC_X, 0x1, X), SCA3300_ACCEL_CHANNEL(SCA3300_ACC_Y, 0x2, Y), SCA3300_ACCEL_CHANNEL(SCA3300_ACC_Z, 0x3, Z), - { - .type = IIO_TEMP, - .address = 0x5, - .scan_index = SCA3300_TEMP, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_type = { - .sign = 's', - .realbits = 16, - .storagebits = 16, - .endianness = IIO_CPU, - }, - }, + SCA3300_TEMP_CHANNEL(SCA3300_TEMP, 0x05), IIO_CHAN_SOFT_TIMESTAMP(4), }; From patchwork Thu Feb 17 06:27:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12749460 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 ABF60C41535 for ; Thu, 17 Feb 2022 06:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235577AbiBQG1f (ORCPT ); Thu, 17 Feb 2022 01:27:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235425AbiBQG1a (ORCPT ); Thu, 17 Feb 2022 01:27:30 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2120.outbound.protection.outlook.com [40.107.22.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65E59201901; Wed, 16 Feb 2022 22:27:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GG4rAzVKC/yzwx8Q11+l/070aUxTJJQTlF7uZvlfBMP35ETUvyyIwoTFf1Q3h3akCm9xP9rrKkjV1/Crr49dqQ5+5qchZOJDRzlcw3pCpZBhdBpkW3/13T/4PKu3UmNZJKtfeEFQKoEABDl7RiV3MXAt9Cn2G5uLV5zleXl75GUmd9nTiVQiH48rvNMne0meH35irWjr2oYJEykmNyU9dftjKdUV12u7+KdYPtWKNZAyhfbHiOTXhul6+1e2uYKisD+cFpBXHj0lAMdoU8KE1EuYQaQAyY80PpUa6bXLxsHKHSQl4jbi0/xIzzyDWhL/vmsyEVevPYWGGmU0njLstw== 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=eeo3P6bcWH+w7eQPcd7Ts/60gi4ZllQduypxLPWV6N4=; b=I5a2Qp14ZRG7edScp/ccLxlABA9ClcvYIVJOhT7uWjSyAf+H8xJ1X9C+nrvbi0ie8HoTOXJkfGjoLfFdeS0xrtO2B5lugERxRiqp5o3ftBM6XRhGlgwVNLR9fZVS6HXXB04d0pzZHEX0Mw/LNCBMsPB+/MTywWG2HYkFlVe7yCYetb78xfq8/jJbQguy5QD019Id1lWfcls8zo+NdR/E4NqeNN2lJBdhgYYQHRrC/+1RVx4ypa4cgXCq0DxAZRwhTMeFA/4QeEfX67Oom6r73wu7fsZCuHk4IRyWte5U8FzumVbtd/rknkRwnmgt/mJqhaJJZu80Vo6NcpSbzjqwAw== 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=eeo3P6bcWH+w7eQPcd7Ts/60gi4ZllQduypxLPWV6N4=; b=ghRZ5lRW8SgWevi3ER9NXX+Rme2R5oQI2Jey7mE4JFTh/yILFHL5+2/oVwUe1Wo96K5IlSRQIKssf9fAUP0ZazMX52eT+2dmVktVGmEBD3fvhA9c+KmalulYZnWsmJU2g/e3F5Sa5/A17Vm5pD15CdirN7gaWKgeDqTAy7aXcs0= Received: from AM6P192CA0077.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::18) by DB3PR0602MB3739.eurprd06.prod.outlook.com (2603:10a6:8:e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Thu, 17 Feb 2022 06:27:10 +0000 Received: from AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com (2603:10a6:209:8d:cafe::22) by AM6P192CA0077.outlook.office365.com (2603:10a6:209:8d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Thu, 17 Feb 2022 06:27:10 +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 AM5EUR02FT043.mail.protection.outlook.com (10.152.9.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Thu, 17 Feb 2022 06:27:10 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, robh+dt@kernel.org, tomas.melin@vaisala.com, andy.shevchenko@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Cc: linux-iio@vger.kernel.org, bsp-development.geo@leica-geosystems.com, kernel test robot Subject: [PATCH V2 3/5] iio: accel: sca3300: modified to support multi chips Date: Thu, 17 Feb 2022 06:27:03 +0000 Message-Id: <20220217062705.2867149-4-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217062705.2867149-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220217062705.2867149-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: 6500703b-87c3-4430-977e-08d9f1de876a X-MS-TrafficTypeDiagnostic: DB3PR0602MB3739:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n4+shCNl7cRuYQM5OuV3k0gJwQp5sJB7Z0q04q+H/SVo8AfNZbVFL/pMt2hizJv35vRxQVWelkQ77YmRG6YhpixeWZVuYu2etJjnjeoD650Gajgy+U1h6yOHlxQIkwuC8v/9Nik/eYJhR58mkVlg+q/R46OKJZoJkx1AEqS6Z9UDQTDATobQI8iEr23VyrLap2DYjCzMhS+eZ34w4hvhdiv2Sx6R/gUkqNSyjqMIIebgZJ2KpYNUtHj00ga3ERt6OmK/DgSICEm/nd6zbhxeOTnkJsqXe9dG4qMR+RbxsI9og4t6p99V1zQVmvlui39GGW/1+gl2I3J+Y5Y9hSf0InahpUObt2JYTMFLQneANvQ1U5qZxvnMRoKD+UDN4T8S3exy2bOdCoezgE9wXQYA9UfskDnsQftTxW8tEdjYZ4+xmsoU2dg0A3AJ1nC1fC2cQutM7HD8U6r7DODs39owtD+2Opmf2aJXByY7cVQoOg+5SQu1xjGH5cSz7SBuYSXN7/0VCo7WHtFUIZWWy+QnV5v3NZT6shQ8mYpLHvkADAgul4fg0KU9XCUhKxehxoGx0yiqf9XkqEZTrPeZE4c7O/IVDxvCLdsli3ntdMR9zmUN+Xt6X5L5z3It6Qe0ADQRkW0n4W7uVLUU1Lr1GRnyeUrqcngUq50tzR48zuicWQgDf8gXVspbZMFxUgDae8ra 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)(40470700004)(46966006)(82310400004)(26005)(186003)(8936002)(118246002)(6506007)(6666004)(956004)(40460700003)(1076003)(6512007)(508600001)(6486002)(2616005)(70586007)(83380400001)(2906002)(36860700001)(36736006)(86362001)(47076005)(70206006)(8676002)(356005)(336012)(5660300002)(316002)(36756003)(4326008)(81166007);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 06:27:10.3819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6500703b-87c3-4430-977e-08d9f1de876a 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: AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0602MB3739 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The drive support sca3300 only,there are some other similar chips, for instance, SCL3300. modified the driver to read the device id, add the tables for the corresponding id to support multiple chips. Reported-by: kernel test robot Signed-off-by: LI Qingwu --- drivers/iio/accel/sca3300.c | 156 +++++++++++++++++++++++++++--------- 1 file changed, 118 insertions(+), 38 deletions(-) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index ff16d2cc8c70..b1748874c02d 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -37,12 +37,24 @@ /* Device ID */ #define SCA3300_REG_WHOAMI 0x10 -#define SCA3300_WHOAMI_ID 0x51 /* Device return status and mask */ #define SCA3300_VALUE_RS_ERROR 0x3 #define SCA3300_MASK_RS_STATUS GENMASK(1, 0) +enum sca3300_op_mode_indexes { + OP_MOD_1 = 0, + OP_MOD_2, + OP_MOD_3, + OP_MOD_4, + OP_MOD_CNT, +}; + +enum sca3300_chip_type { + CHIP_SCA3300 = 0, + CHIP_CNT +}; + enum sca3300_scan_indexes { SCA3300_ACC_X = 0, SCA3300_ACC_Y, @@ -91,15 +103,29 @@ static const struct iio_chan_spec sca3300_channels[] = { SCA3300_ACCEL_CHANNEL(SCA3300_ACC_Z, 0x3, Z), SCA3300_TEMP_CHANNEL(SCA3300_TEMP, 0x05), IIO_CHAN_SOFT_TIMESTAMP(4), + IIO_CHAN_SOFT_TIMESTAMP(SCA3300_TIMESTAMP), }; -static const int sca3300_lp_freq[] = {70, 70, 70, 10}; -static const int sca3300_accel_scale[][2] = {{0, 370}, {0, 741}, {0, 185}, {0, 185}}; +static const int sca3300_lp_freq_table[] = {70, 70, 70, 10}; +static const int sca3300_accel_scale_table[][2] = {{0, 370}, {0, 741}, {0, 185}, {0, 185}}; static const unsigned long sca3300_scan_masks[] = { BIT(SCA3300_ACC_X) | BIT(SCA3300_ACC_Y) | BIT(SCA3300_ACC_Z) | BIT(SCA3300_TEMP), - 0 + 0, +}; + +struct sca3300_chip_info { + const struct iio_chan_spec *channels; + enum sca3300_chip_type chip_type; + const int (*accel_scale_table)[2]; + unsigned int num_accel_scales; + unsigned long scan_masks; + unsigned int num_freqs; + const int *freq_table; + const char *name; + int num_channels; + u8 chip_id; }; /** @@ -114,13 +140,29 @@ struct sca3300_data { struct spi_device *spi; struct mutex lock; struct { - s16 channels[4]; + s16 channels[SCA3300_TIMESTAMP - 1]; s64 ts __aligned(sizeof(s64)); } scan; + const struct sca3300_chip_info *chip_info; u8 txbuf[4] ____cacheline_aligned; u8 rxbuf[4]; }; +static const struct sca3300_chip_info sca3300_chip_info_tbl[] = { + [CHIP_SCA3300] = { + .num_accel_scales = ARRAY_SIZE(sca3300_accel_scale_table)*2-1, + .accel_scale_table = sca3300_accel_scale_table, + .num_channels = ARRAY_SIZE(sca3300_channels), + .freq_table = &sca3300_lp_freq_table[2], + .scan_masks = sca3300_scan_masks, + .channels = sca3300_channels, + .chip_type = CHIP_SCA3300, + .name = "sca3300", + .chip_id = 0x51, + .num_freqs = 2, + }, +}; + DECLARE_CRC8_TABLE(sca3300_crc_table); static int sca3300_transfer(struct sca3300_data *sca_data, int *val) @@ -227,36 +269,57 @@ static int sca3300_write_reg(struct sca3300_data *sca_data, u8 reg, int val) return sca3300_error_handler(sca_data); } +static int sca3300_set_op_mode(struct sca3300_data *sca_data, unsigned int mode) +{ + if ((mode < OP_MOD_1) || (mode >= OP_MOD_CNT)) + return -EINVAL; + + return sca3300_write_reg(sca_data, SCA3300_REG_MODE, mode); +} + static int sca3300_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) { struct sca3300_data *data = iio_priv(indio_dev); + int mode = -1; int reg_val; int ret; int i; switch (mask) { case IIO_CHAN_INFO_SCALE: - if (val) + if (chan->type != IIO_ACCEL) return -EINVAL; - - for (i = 0; i < ARRAY_SIZE(sca3300_accel_scale); i++) { - if (val2 == sca3300_accel_scale[i][1]) - return sca3300_write_reg(data, SCA3300_REG_MODE, i); + for (i = 0; i < OP_MOD_CNT; i++) { + if ((val == data->chip_info->accel_scale_table[i][0]) && + (val2 == data->chip_info->accel_scale_table[i][1])) { + mode = i; + break; + } } - return -EINVAL; - + return sca3300_set_op_mode(data, mode); case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: ret = sca3300_read_reg(data, SCA3300_REG_MODE, ®_val); if (ret) return ret; - /* freq. change is possible only for mode 3 and 4 */ - if (reg_val == 2 && val == sca3300_lp_freq[3]) - return sca3300_write_reg(data, SCA3300_REG_MODE, 3); - if (reg_val == 3 && val == sca3300_lp_freq[2]) - return sca3300_write_reg(data, SCA3300_REG_MODE, 2); - return -EINVAL; + for (i = 0; i < OP_MOD_CNT; i++) { + if (val == data->chip_info->freq_table[i]) { + mode = i; + break; + } + } + switch (data->chip_info->chip_type) { + case CHIP_SCA3300: + /* SCA330 freq. change is possible only for mode 3 and 4 */ + if (reg_val == OP_MOD_3 && mode == OP_MOD_4) + return sca3300_set_op_mode(data, mode); + if (reg_val == OP_MOD_4 && mode == OP_MOD_3) + return sca3300_set_op_mode(data, mode); + return -EINVAL; + default: + return -EINVAL; + } default: return -EINVAL; } @@ -267,8 +330,8 @@ static int sca3300_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct sca3300_data *data = iio_priv(indio_dev); - int ret; int reg_val; + int ret; switch (mask) { case IIO_CHAN_INFO_RAW: @@ -280,14 +343,18 @@ static int sca3300_read_raw(struct iio_dev *indio_dev, ret = sca3300_read_reg(data, SCA3300_REG_MODE, ®_val); if (ret) return ret; - *val = 0; - *val2 = sca3300_accel_scale[reg_val][1]; - return IIO_VAL_INT_PLUS_MICRO; + switch (chan->type) { + case IIO_ACCEL: + *val = data->chip_info->accel_scale_table[reg_val][0]; + *val2 = data->chip_info->accel_scale_table[reg_val][1]; + return IIO_VAL_INT_PLUS_MICRO; + } + return -EINVAL; case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: ret = sca3300_read_reg(data, SCA3300_REG_MODE, ®_val); if (ret) return ret; - *val = sca3300_lp_freq[reg_val]; + *val = data->chip_info->freq_table[reg_val]; return IIO_VAL_INT; default: return -EINVAL; @@ -330,6 +397,7 @@ static int sca3300_init(struct sca3300_data *sca_data, struct iio_dev *indio_dev) { int value = 0; + int i = 0; int ret; ret = sca3300_write_reg(sca_data, SCA3300_REG_MODE, @@ -347,12 +415,22 @@ static int sca3300_init(struct sca3300_data *sca_data, if (ret) return ret; - if (value != SCA3300_WHOAMI_ID) { - dev_err(&sca_data->spi->dev, - "device id not expected value, %d != %u\n", - value, SCA3300_WHOAMI_ID); + for (i = 0; i < ARRAY_SIZE(sca3300_chip_info_tbl); i++) { + if (sca3300_chip_info_tbl[i].chip_id == value) + break; + } + if (i == ARRAY_SIZE(sca3300_chip_info_tbl)) { + dev_err(&sca_data->spi->dev, "Invalid chip %x\n", value); return -ENODEV; } + + indio_dev->available_scan_masks = sca3300_chip_info_tbl[i].scan_masks; + indio_dev->num_channels = sca3300_chip_info_tbl[i].num_channels; + indio_dev->channels = sca3300_chip_info_tbl[i].channels; + sca_data->chip_info = &sca3300_chip_info_tbl[i]; + indio_dev->name = sca3300_chip_info_tbl[i].name; + indio_dev->modes = INDIO_DIRECT_MODE; + return 0; } @@ -384,15 +462,22 @@ static int sca3300_read_avail(struct iio_dev *indio_dev, const int **vals, int *type, int *length, long mask) { + struct sca3300_data *data = iio_priv(indio_dev); switch (mask) { case IIO_CHAN_INFO_SCALE: - *vals = (const int *)sca3300_accel_scale; - *length = ARRAY_SIZE(sca3300_accel_scale) * 2 - 2; - *type = IIO_VAL_INT_PLUS_MICRO; - return IIO_AVAIL_LIST; + switch (chan->type) { + case IIO_ACCEL: + *vals = (const int *)data->chip_info->accel_scale_table; + *length = data->chip_info->num_accel_scales; + *type = IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } + return -EINVAL; case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: - *vals = &sca3300_lp_freq[2]; - *length = 2; + *vals = (const int *)data->chip_info->freq_table; + *length = data->chip_info->num_freqs; *type = IIO_VAL_INT; return IIO_AVAIL_LIST; default: @@ -424,11 +509,6 @@ static int sca3300_probe(struct spi_device *spi) crc8_populate_msb(sca3300_crc_table, SCA3300_CRC8_POLYNOMIAL); indio_dev->info = &sca3300_info; - indio_dev->name = SCA3300_ALIAS; - indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = sca3300_channels; - indio_dev->num_channels = ARRAY_SIZE(sca3300_channels); - indio_dev->available_scan_masks = sca3300_scan_masks; ret = sca3300_init(sca_data, indio_dev); if (ret) { From patchwork Thu Feb 17 06:27:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12749461 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 81C7BC35273 for ; Thu, 17 Feb 2022 06:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235291AbiBQG1f (ORCPT ); Thu, 17 Feb 2022 01:27:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235428AbiBQG1c (ORCPT ); Thu, 17 Feb 2022 01:27:32 -0500 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30127.outbound.protection.outlook.com [40.107.3.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E7132A22BC; Wed, 16 Feb 2022 22:27:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aav9X8ydRkUtXUGQ5o5V//SdGXEOQsOtJL7rnpPMOKUhNNpIPCU7C1enFSb6UdkDAvQECsVlNBhoQ2vo6itr0eIFgl04XwZBiOsSX/+zKjFUBZ+FdIMzRG9T2AB18tzJms+6WFcugFHYOImBHXOatYVcUg4eanIWqnUT6gB2FjN4PCKbl7iWIPQy5KVVEePLolXzVFfLzVuAu532ljd/agW6Da1KQMmMH0BdLORrmD3pevhuZn/5CdlkVyxPpModLvZ5mv3KI5gueqTDVrfFcAxuNO8vs7nQ2L+rMGqvUKYRynNJKnvfr6LuR7Msd6eJCgff/wXIhXRdJAY2xBr3SQ== 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=weo//E55ssFdOI1hxfBcmxIjPtQPGzmp2vMRR46A0WI=; b=Ru5DjtgdZIwK2zvftvB23vChQzUxWA62303lcpTh/yKkd2TT3Of6jcwKwk4khAeC7k2kybica7WSVaZZOpRhEG/hNx4zmpPD469gLpk/VKGps8CpTr3flI+lnvaC3WWcBAHpIcd1sc5QmgXi3ZL8v4y8SLd8bKmeIhJli59RdqwOTOzGkh1/OCBt+hcBMw8K0BfJvc6u1sHuqbRrdZWSbZDIEjhmZq6ldqQhP8rUQk+UrTRaeTUusJjgcGqFuRZlhw83vuWe1QRaDY9pTfndXRlWk4ualH5SEk9XoNOpa09iG6ij3Fga2nJ57cFUZQeOYAF+W6Ep+GCcQaLlzKlXvQ== 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=weo//E55ssFdOI1hxfBcmxIjPtQPGzmp2vMRR46A0WI=; b=NdyXlD7KclwjDnh7BRnRhNWvrtPBJu9qLtcmFgBM1ABIlLa2RHp6gmiLlYgriGpDvTZ22IYoSuNd4SLfG2g3IelqMkkOB8jX0E8qrFJ4hccu+B6XFuSXmaMJp7DhPalDZVqma88qjImFNIBYKfkXU1hJnsA8LZDo4ItRq0VjtfY= Received: from AM6P192CA0083.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::24) by DB6PR0601MB2213.eurprd06.prod.outlook.com (2603:10a6:4:4f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.18; Thu, 17 Feb 2022 06:27:11 +0000 Received: from AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com (2603:10a6:209:8d:cafe::1a) by AM6P192CA0083.outlook.office365.com (2603:10a6:209:8d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Thu, 17 Feb 2022 06:27:11 +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 AM5EUR02FT043.mail.protection.outlook.com (10.152.9.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Thu, 17 Feb 2022 06:27:11 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, robh+dt@kernel.org, tomas.melin@vaisala.com, andy.shevchenko@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Cc: linux-iio@vger.kernel.org, bsp-development.geo@leica-geosystems.com Subject: [PATCH V2 4/5] iio: accel: sca3300: Add support for SCL3300 Date: Thu, 17 Feb 2022 06:27:04 +0000 Message-Id: <20220217062705.2867149-5-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217062705.2867149-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220217062705.2867149-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: 46d58a8c-63f7-4857-d982-08d9f1de87d2 X-MS-TrafficTypeDiagnostic: DB6PR0601MB2213:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C0mkJJKDbp1O2GGoD296eGpr9gyMM9Qsb3reUaQBgk+4gqAwG0hbsF+as/rdbF/3TmV3cwugMLZm1wjspgItpRb2MaL7CIPGaD+HgscG9452XoeHp0tiWts2+1gQyUmGuqpCjrnTSIHQSgkY4sg1uLys5JiC1Dsp9sdrDJsH6SeO6auPQlQ0iW0y3nn5M2C04bcbCdmqVh+k6IT9uI+P4QTwVgtn8Ep+ULGC/FuN1KzNWZJR9g4qCsZfOm+3ydrrEy9tDaR/Di9+ukOf9Vt71OBdCL9q0NrUx7mUL10JAd7Ie1EibjXDUPTcRpIyEbNEX/6Lz6pYpgZ5uWl19SOkEPMaJQ3gCIZuSoFOiGBrtF+1brCtt/Cf4eWoX2NDFKLx+NGbPuZTrdb1wwZ5R9epkEjJBhN5NzZvGkgDHCsD51zORzrsG/PAnYrLdqDX0oJQUGQ8d/BOJ8/nzs15MXpIKAhG873Mu2KvLp42HMEzhnXaq3Cw3VIZv8KtN9gQ7Z+vnQBLK+QqBHXgE48/MZrRxT60XdYuu9zUmITVZ5fpldxWPp73qadtOApilTepP0JvY08UaltCgDznkAsRrHXD4vo95BFTGvTFX9ibuEw6wOpH3Nyf0opjhm1aad7l8Xz7m6EEkWFZj4ui+jieQ6hMFQdjLrHIrsNUqaHfYWjC7YKSStCMMDZAQt5s37ImOczG1SEAu/xFbJIal+c+oIAbOQos1hzlDXbt0UtJHjp0DpOXxxyUKFkEERcefWMThdTQrHXtEOg6J5Om4AXUleUu0A== 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)(6506007)(8936002)(86362001)(118246002)(82310400004)(83380400001)(36860700001)(336012)(2616005)(1076003)(956004)(107886003)(6666004)(26005)(186003)(47076005)(2906002)(6512007)(5660300002)(4326008)(508600001)(36736006)(70586007)(316002)(81166007)(356005)(36756003)(70206006)(15974865002)(6486002)(40460700003)(8676002);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 06:27:11.0871 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46d58a8c-63f7-4857-d982-08d9f1de87d2 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: AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0601MB2213 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add support for Murata SCL3300, a 3-axis MEMS accelerometer. Same as SCA3300, it has accelerometer and temperature output. Datasheet: www.murata.com/en-us/products/sensor/inclinometer/overview/lineup/scl3300 Signed-off-by: LI Qingwu --- drivers/iio/accel/sca3300.c | 45 +++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index b1748874c02d..123ab9a784d2 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -42,6 +42,9 @@ #define SCA3300_VALUE_RS_ERROR 0x3 #define SCA3300_MASK_RS_STATUS GENMASK(1, 0) +#define SCA3300_REG_ANG_CTRL 0x0C +#define SCA3300_ANG_ENABLE 0x1F + enum sca3300_op_mode_indexes { OP_MOD_1 = 0, OP_MOD_2, @@ -52,6 +55,7 @@ enum sca3300_op_mode_indexes { enum sca3300_chip_type { CHIP_SCA3300 = 0, + CHIP_SCL3300, CHIP_CNT }; @@ -106,8 +110,19 @@ static const struct iio_chan_spec sca3300_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(SCA3300_TIMESTAMP), }; +static const struct iio_chan_spec scl3300_channels[] = { + SCA3300_ACCEL_CHANNEL(SCA3300_ACC_X, 0x1, X), + SCA3300_ACCEL_CHANNEL(SCA3300_ACC_Y, 0x2, Y), + SCA3300_ACCEL_CHANNEL(SCA3300_ACC_Z, 0x3, Z), + SCA3300_TEMP_CHANNEL(SCA3300_TEMP, 0x05), + IIO_CHAN_SOFT_TIMESTAMP(SCA3300_TIMESTAMP), +}; + static const int sca3300_lp_freq_table[] = {70, 70, 70, 10}; +static const int scl3300_lp_freq_table[] = {40, 70, 10, 10}; + static const int sca3300_accel_scale_table[][2] = {{0, 370}, {0, 741}, {0, 185}, {0, 185}}; +static const int scl3300_accel_scale_table[][2] = {{0, 167}, {0, 333}, {0, 83}, {0, 83}}; static const unsigned long sca3300_scan_masks[] = { BIT(SCA3300_ACC_X) | BIT(SCA3300_ACC_Y) | BIT(SCA3300_ACC_Z) | @@ -161,6 +176,18 @@ static const struct sca3300_chip_info sca3300_chip_info_tbl[] = { .chip_id = 0x51, .num_freqs = 2, }, + [CHIP_SCL3300] = { + .num_accel_scales = ARRAY_SIZE(scl3300_accel_scale_table)*2-1, + .num_channels = ARRAY_SIZE(scl3300_channels), + .accel_scale_table = scl3300_accel_scale_table, + .freq_table = scl3300_lp_freq_table, + .scan_masks = sca3300_scan_masks, + .channels = scl3300_channels, + .chip_type = CHIP_SCL3300, + .name = "scl3300", + .chip_id = 0xC1, + .num_freqs = 3, + }, }; DECLARE_CRC8_TABLE(sca3300_crc_table); @@ -274,6 +301,11 @@ static int sca3300_set_op_mode(struct sca3300_data *sca_data, unsigned int mode) if ((mode < OP_MOD_1) || (mode >= OP_MOD_CNT)) return -EINVAL; + /* SCL3300, mode 3 and 4 are same, use mode 4 only*/ + if (sca_data->chip_info->chip_type == CHIP_SCL3300) { + if (mode == OP_MOD_3) + mode = OP_MOD_4; + } return sca3300_write_reg(sca_data, SCA3300_REG_MODE, mode); } @@ -317,6 +349,8 @@ static int sca3300_write_raw(struct iio_dev *indio_dev, if (reg_val == OP_MOD_4 && mode == OP_MOD_3) return sca3300_set_op_mode(data, mode); return -EINVAL; + case CHIP_SCL3300: + return sca3300_set_op_mode(data, mode); default: return -EINVAL; } @@ -348,8 +382,9 @@ static int sca3300_read_raw(struct iio_dev *indio_dev, *val = data->chip_info->accel_scale_table[reg_val][0]; *val2 = data->chip_info->accel_scale_table[reg_val][1]; return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; } - return -EINVAL; case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: ret = sca3300_read_reg(data, SCA3300_REG_MODE, ®_val); if (ret) @@ -431,6 +466,12 @@ static int sca3300_init(struct sca3300_data *sca_data, indio_dev->name = sca3300_chip_info_tbl[i].name; indio_dev->modes = INDIO_DIRECT_MODE; + if (sca_data->chip_info->chip_type == CHIP_SCL3300) { + ret = sca3300_write_reg(sca_data, SCA3300_REG_ANG_CTRL, SCA3300_ANG_ENABLE); + if (ret) + return ret; + } + return 0; } @@ -474,7 +515,6 @@ static int sca3300_read_avail(struct iio_dev *indio_dev, default: return -EINVAL; } - return -EINVAL; case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: *vals = (const int *)data->chip_info->freq_table; *length = data->chip_info->num_freqs; @@ -536,6 +576,7 @@ static int sca3300_probe(struct spi_device *spi) static const struct of_device_id sca3300_dt_ids[] = { { .compatible = "murata,sca3300"}, + { .compatible = "murata,scl3300"}, {} }; MODULE_DEVICE_TABLE(of, sca3300_dt_ids); From patchwork Thu Feb 17 06:27:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12749456 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 A4F6AC433FE for ; Thu, 17 Feb 2022 06:27:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235433AbiBQG1c (ORCPT ); Thu, 17 Feb 2022 01:27:32 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbiBQG1a (ORCPT ); Thu, 17 Feb 2022 01:27:30 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2133.outbound.protection.outlook.com [40.107.20.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B145021FC7C; Wed, 16 Feb 2022 22:27:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mER4DnPgdLfJsMTCC3ZybvF3dkkXuLslaSJpHuvuiBXt+2yirToGxuyjLxHdPz26T0AHVEu+Qnbcq94xZUuBP3rc7WIXnJc2Oq/r0D1a4WR0Aw3u1GYNe43ZO1iVb4irAbVzaWLls13M6ddI1F9gP8JmIpKA1k8G1cphA4ngQfRocqOS/Ui9v567u1Vj2BGRY/hsMf9nWKWOuxJmCQiO5W9Bz6jaZUnIDuKRD2JoCWd7S0y0H0UpdHJtzIT3RA+XJiZHvedsGfCWCK00by+vCv5rlVj2sSMTurcnwrjM15lUWeQDLDpLDM67fk5LoH1zhgkdKI4k5cNBx7c0PyX95g== 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=9ijaw5tV938xk33WOJJS+JUKjmLcWtbs1VPS+aMEqCU=; b=TU5qjJ2hFB7ob8vdvGeNMM8/FpSOPPBpRWb5+e6AsyjXZ2Pw/Q4OEQ84El0npddtFSVkT8yKrMRpTJkdSR7mxvS8ZxQAZGNXozWvMkAQQymGQjferIUkszUVqagXSZXfa1lurzJHJRvp9s8kQzfTBUb57v2ckpIW68RdeqWX1PNvlmayiLdY7vMQ3EFHI8EZkjFrRl8zCchpPFCCtSUIZdr/kDJSNPs2onkMPEykut3QoAgWbBtOonFs4B6RMOSud6hII0C3XbpLfVIJCc9cax44ujm/UiGo5ST3Bfr1kbvuY+Q4BVNsr+uKJk8Mil0QSh+qpJ4a4CcH+9hGPPSaUA== 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=9ijaw5tV938xk33WOJJS+JUKjmLcWtbs1VPS+aMEqCU=; b=l5E9co6WttKRCTZhGyaJXxuyJkzXH4jxt99WfzMKMILzaojSR48V1NkwcxWKJ0g5U3K8Vj/NGkqwo3c0VTHZvW/+jf1DuUEZHbS7ij1jZW/2mguW35gLpA4yDPJwTLp2ht1b7FYOpj3YdME3rB8OrBNA8eQhno3xarbJ3nulRcI= Received: from AM6P192CA0092.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::33) by AS4PR06MB8565.eurprd06.prod.outlook.com (2603:10a6:20b:4e8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Thu, 17 Feb 2022 06:27:12 +0000 Received: from AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com (2603:10a6:209:8d:cafe::d7) by AM6P192CA0092.outlook.office365.com (2603:10a6:209:8d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14 via Frontend Transport; Thu, 17 Feb 2022 06:27:12 +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 AM5EUR02FT043.mail.protection.outlook.com (10.152.9.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Thu, 17 Feb 2022 06:27:11 +0000 From: LI Qingwu To: jic23@kernel.org, lars@metafoo.de, robh+dt@kernel.org, tomas.melin@vaisala.com, andy.shevchenko@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Qing-wu.Li@leica-geosystems.com.cn Cc: linux-iio@vger.kernel.org, bsp-development.geo@leica-geosystems.com Subject: [PATCH V2 5/5] iio: accel: sca3300: Add inclination channels. Date: Thu, 17 Feb 2022 06:27:05 +0000 Message-Id: <20220217062705.2867149-6-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217062705.2867149-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220217062705.2867149-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: 3c46dc0a-69b6-4393-936a-08d9f1de883a X-MS-TrafficTypeDiagnostic: AS4PR06MB8565:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /C7+WLJFXVDfQW+1ViBWoFpaDBNbuR4biLBX2byoREbVqirQwodhefJlrRzf62T9w9wNhk4FJnReqeXuoQcbNxASkOS/rZWqXDls/54XwwJ0cmIVgf6JOcL1Ir2LpIvSOVF+3xIOBfW8NajDwg5yrzhjYUOuVrP4NcigZxuKdJ9+6nRlySAOIx1JQqfLtu/vCh+8oCBAuLTHO8FzqYwP5A9Q5nHEvpPbfudQZeo5lw1IDD3ASn4b6n6IJXY9pgtE7e1T8ST9TYbJ/tpehrFfQPt6zJCgVyNVGYfmw4CHTtWhZe+xK/7VAnX3xnLNcPgnuCUuoELg4W2mIzR1TPvSBfAdv9RyAmQ9bhnNkmMrIxERb3j+K2QykVUacWLgWaEYG9PC6IskADXxPK/UZvkTVTp9yyhJIipiibClOQ3IumY3iPqbXqbPUVPZIU5e/9DiIY+Y+tIIzC2r2VOGuZzpurYP1oleSCjgnoV5yjXKQJc57GokS+lOmPR6sCxjwVSaWeWX0psuqP1LxlzJgR+rcsXaLQlqvuLvfqzAmkx/W7oCLkvwxH/yfMfZ9y5IiQPp751Doqq5oxnjAAB35p9ChqleMla0TjI9MhZVaN1oLcQHjVKR+o+I5SL+SECAsoFlRgV8p6QdShfdsSq7CUCo6idEmFjQDVrbxL33dh4WmbQiHRzyFNqbKRJ7so/Iorj+ 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)(8936002)(956004)(2616005)(5660300002)(8676002)(36860700001)(70586007)(86362001)(6666004)(107886003)(6512007)(6486002)(26005)(186003)(6506007)(36756003)(1076003)(336012)(118246002)(508600001)(40460700003)(2906002)(4326008)(36736006)(356005)(47076005)(82310400004)(70206006)(316002)(81166007);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2022 06:27:11.7674 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c46dc0a-69b6-4393-936a-08d9f1de883a 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: AM5EUR02FT043.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR06MB8565 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Different with SCA3300, SCL3300 can output inclination angles. Angles are formed from acceleration with following equations: ANG_X = atan2(accx / √(accy^2 + accz^2)), ANG_Y = atan2(accy / √(accx^2 + accz^2)), ANG_Z = atan2(accz / √(accx^2 + accy^2)), The commit add output of the raw value,scale and scale_available of angles. New interfaces: in_incli_scale in_incli_scale_available in_incli_x_raw in_incli_y_raw in_incli_z_raw Signed-off-by: LI Qingwu --- drivers/iio/accel/sca3300.c | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index 123ab9a784d2..5c86b143d17a 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -64,6 +64,9 @@ enum sca3300_scan_indexes { SCA3300_ACC_Y, SCA3300_ACC_Z, SCA3300_TEMP, + SCA3300_INCLI_X, + SCA3300_INCLI_Y, + SCA3300_INCLI_Z, SCA3300_TIMESTAMP, }; @@ -88,6 +91,24 @@ enum sca3300_scan_indexes { }, \ } +#define SCA3300_INCLI_CHANNEL(index, reg, axis) { \ + .type = IIO_INCLI, \ + .address = reg, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type_available = \ + BIT(IIO_CHAN_INFO_SCALE), \ + .scan_index = index, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_CPU, \ + }, \ +} + #define SCA3300_TEMP_CHANNEL(index, reg) { \ .type = IIO_TEMP, \ .address = reg, \ @@ -115,6 +136,9 @@ static const struct iio_chan_spec scl3300_channels[] = { SCA3300_ACCEL_CHANNEL(SCA3300_ACC_Y, 0x2, Y), SCA3300_ACCEL_CHANNEL(SCA3300_ACC_Z, 0x3, Z), SCA3300_TEMP_CHANNEL(SCA3300_TEMP, 0x05), + SCA3300_INCLI_CHANNEL(SCA3300_INCLI_X, 0x09, X), + SCA3300_INCLI_CHANNEL(SCA3300_INCLI_Y, 0x0A, Y), + SCA3300_INCLI_CHANNEL(SCA3300_INCLI_Z, 0x0B, Z), IIO_CHAN_SOFT_TIMESTAMP(SCA3300_TIMESTAMP), }; @@ -124,17 +148,28 @@ static const int scl3300_lp_freq_table[] = {40, 70, 10, 10}; static const int sca3300_accel_scale_table[][2] = {{0, 370}, {0, 741}, {0, 185}, {0, 185}}; static const int scl3300_accel_scale_table[][2] = {{0, 167}, {0, 333}, {0, 83}, {0, 83}}; +static const int scl3300_incli_scale_table[][2] = {{0, 5495}, {0, 5495}, {0, 5495}, {0, 5495}}; + static const unsigned long sca3300_scan_masks[] = { BIT(SCA3300_ACC_X) | BIT(SCA3300_ACC_Y) | BIT(SCA3300_ACC_Z) | BIT(SCA3300_TEMP), 0, }; +static const unsigned long scl3300_scan_masks[] = { + BIT(SCA3300_ACC_X) | BIT(SCA3300_ACC_Y) | BIT(SCA3300_ACC_Z) | + BIT(SCA3300_TEMP) | + BIT(SCA3300_INCLI_X) | BIT(SCA3300_INCLI_Y) | BIT(SCA3300_INCLI_Z), + 0, +}; + struct sca3300_chip_info { const struct iio_chan_spec *channels; enum sca3300_chip_type chip_type; const int (*accel_scale_table)[2]; + const int (*incli_scale_table)[2]; unsigned int num_accel_scales; + unsigned int num_incli_scales; unsigned long scan_masks; unsigned int num_freqs; const int *freq_table; @@ -172,14 +207,18 @@ static const struct sca3300_chip_info sca3300_chip_info_tbl[] = { .scan_masks = sca3300_scan_masks, .channels = sca3300_channels, .chip_type = CHIP_SCA3300, + .incli_scale_table = NULL, + .num_incli_scales = 0, .name = "sca3300", .chip_id = 0x51, .num_freqs = 2, }, [CHIP_SCL3300] = { .num_accel_scales = ARRAY_SIZE(scl3300_accel_scale_table)*2-1, + .num_incli_scales = ARRAY_SIZE(scl3300_lp_freq_table)-1, .num_channels = ARRAY_SIZE(scl3300_channels), .accel_scale_table = scl3300_accel_scale_table, + .incli_scale_table = scl3300_incli_scale_table, .freq_table = scl3300_lp_freq_table, .scan_masks = sca3300_scan_masks, .channels = scl3300_channels, @@ -378,6 +417,10 @@ static int sca3300_read_raw(struct iio_dev *indio_dev, if (ret) return ret; switch (chan->type) { + case IIO_INCLI: + *val = data->chip_info->incli_scale_table[reg_val][0]; + *val2 = data->chip_info->incli_scale_table[reg_val][1]; + return IIO_VAL_INT_PLUS_MICRO; case IIO_ACCEL: *val = data->chip_info->accel_scale_table[reg_val][0]; *val2 = data->chip_info->accel_scale_table[reg_val][1]; @@ -507,6 +550,11 @@ static int sca3300_read_avail(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_SCALE: switch (chan->type) { + case IIO_INCLI: + *vals = (const int *)data->chip_info->incli_scale_table; + *length = data->chip_info->num_incli_scales; + *type = IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; case IIO_ACCEL: *vals = (const int *)data->chip_info->accel_scale_table; *length = data->chip_info->num_accel_scales;