From patchwork Thu May 12 16:03:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12847862 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 59974C433F5 for ; Thu, 12 May 2022 16:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356159AbiELQDZ (ORCPT ); Thu, 12 May 2022 12:03:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356155AbiELQDV (ORCPT ); Thu, 12 May 2022 12:03:21 -0400 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20105.outbound.protection.outlook.com [40.107.2.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C2B36223B; Thu, 12 May 2022 09:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kYtbg641bVCQ77qbxgt1x8RL2MTovv31fypR8fsrF69ILwZ0OFUvv+RJrOZ7FgBYr2v1XrYwqPm33wFF2CaafaxtoumT+0RK+HAPdsqtrPulUWN2kMMlytE1fadmmQTI0J3z3EbCPB2mCsyS50QaUyNwxZoR+YWdhdjUWkHFDAbtcNsIgdnoydL3LlAqXZ45nDMi5C7sUTkiu6LxrWYDrQeynRtz9J3o9qAFmOppdrYfOsQMTzbY0577sQ5bltpVzpKb99nLbdBzpJc9ZEWKVwq01WlZsYk0mHpJNdS5udVfBBnRIq6+lkXw4K4eZ7f2jioUaPabbYoW/YVTpiqPow== 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=7ekwVoXx/+aYjX3KlJSJLf75Avjb5+QFhAMoKN3Z/Tw=; b=e0+P5zp6uwUbQ+1fjtOOcTuxGUyESkCF8wN9+F7eIVYs6OKw1ttXrxGJTxS1YKxpDTs6sRqW8mDWzudEq6zYECigGY/AEZ+YZ6oFzdGQzoynh7RIGwZMhXS7naN9Za15GEAXkzQZacLTuAGIJPoV3Voo3GfO+6iFtPALGK/ukmDQLYqETWvnyiE2gqu92VC4yTrK57wtkaysGQv1vnKENzRy0p0tYTL4Ilcm3V7CKqtQbwktRroE5nLl9OhwozjeOl9VttSARM9Quo+DndiIr7fDElp7K0bZjDSShmyUtnlclyPk/PHtsrDRxmlmqPiIPioFpE5A8HrAGl1GC1VDzg== 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=7ekwVoXx/+aYjX3KlJSJLf75Avjb5+QFhAMoKN3Z/Tw=; b=cAjK0Z36lq7lMGuH7hwOncQ3Wn8MOI7HVtK5SM0C2yiRzQ47eJXqJOblXWEWYV6X2hdTK/lgqxGT1bbCUJj/rI/jNDGNBiZ6HUI/KGAnNBesFQ8fCuviRdEhSdciDs7tBRrPN3YuWFqfJ1rzMGICIe8cO0N85Ne89b82ievPAPQ= Received: from OL1P279CA0043.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:14::12) by DB7PR06MB4506.eurprd06.prod.outlook.com (2603:10a6:10:21::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13; Thu, 12 May 2022 16:03:17 +0000 Received: from HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com (2603:10a6:e10:14:cafe::74) by OL1P279CA0043.outlook.office365.com (2603:10a6:e10:14::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:17 +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 HE1EUR02FT005.mail.protection.outlook.com (10.152.10.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:16 +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, Rob Herring Subject: [PATCH V5 1/5] dt-bindings: iio: accel: sca3300: Document murata,scl3300 Date: Thu, 12 May 2022 16:03:08 +0000 Message-Id: <20220512160312.3880433-2-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220512160312.3880433-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220512160312.3880433-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: 89ca4b6a-f9e2-4299-6612-08da3430ed38 X-MS-TrafficTypeDiagnostic: DB7PR06MB4506: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: XEiz/UYllkVuuzGhird8JfZr36NbJFTsqYsYMTl6BgTNBVVtQ2SdzATKGj+f0EoUoAxpUXpuI7l3HPY2ZKACxpW0ohA/mSXg2rAMzanG7o2kObhLHD3g4aJe25m++epE4bRFTPFqy+aLl5/FTCw480aa3E0FQp1j6BsxiTitFli4RW5eH1vu4YVYzXjfrxoV5si6lFUNdWGcSl0QVTZnxQkE4a1B87hAxGmlQuj3swyir9ZOd3LAle4AiOxL03q5MVRpUqBuMPjJs5B47qyKE/2ZuOQwX6m0A0JA0H9Dv3Qraey7DiRSDS1KhU5bSabbpKZjXEew+fJBtHozPfScrhPD4igsloqQIi0kxOHRwrwg+s7aK0dwiLOlHv3Nunhp7V0Dt2j/jSobJZpzuVXtTuBhPNLFlKJTffjoR1vpfblYobaIGlFy5K6z8wJZa+3zF4II1ek3sd3ZaGtclwFS+MDS5fEmh9rSGER8ew/I1PCRIJ5PxXc61Wc74Vm8CtJcmLqqkYpK8RH7xhEFnX83YcjNKb8dwvVq5lnUfPkkPL9Fe+/xCPoolHw1AZbZnQm0mThzFJufzF1JUX+4p1rGi7FfG/pOj3Yc6eeAz+yrr8li30IBeQOAI6qsVE9oQyRKZ40EI8Qs3NkzSLdEwVcJdCEYSjCNbhnu1s/8GCdD7tNNVnp657PbLK9dTE18fDGv X-Forefront-Antispam-Report: CIP:193.8.40.94;CTRY:CH;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:aherlnxbspsrv01.lgs-net.com;PTR:ahersrvdom50.leica-geosystems.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(36736006)(316002)(86362001)(6506007)(508600001)(6486002)(6666004)(81166007)(2906002)(356005)(1076003)(5660300002)(26005)(70586007)(70206006)(336012)(47076005)(8676002)(4744005)(6512007)(956004)(186003)(4326008)(2616005)(82310400005)(8936002)(40460700003)(36860700001)(36756003)(118246002);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2022 16:03:16.4630 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89ca4b6a-f9e2-4299-6612-08da3430ed38 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: HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR06MB4506 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add DT bindings for Murata scl3300 inclinometer. Reviewed-by: Rob Herring 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 May 12 16:03:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12847861 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 CC2FEC433FE for ; Thu, 12 May 2022 16:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356162AbiELQDY (ORCPT ); Thu, 12 May 2022 12:03:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356153AbiELQDV (ORCPT ); Thu, 12 May 2022 12:03:21 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2126.outbound.protection.outlook.com [40.107.22.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A8515F26F; Thu, 12 May 2022 09:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEtfRoFcIt5+3SN+1qXvla5h2se4XppMj7LUOBNKG9tTzJyxpFhj3SsarC5VVX6f/dwiNaCTPIuRpYrhvDkKm5jB4wqdeYLt27ZIAW77FNAmIOTy91fFl7pmmkMs1DrJXDlpzyhaqoXmAUR0O20DYXmaor9HD4AjhjiFZ9pDqwneOTYa/W2tQ6JW66PFW/Z8j6mOLeumDvHnO3PHYuD3nTUNB4DlEegFVNlFyE48aYJm3Aw3hAKhaJBgo8CMyjQHWJeGbL5OgKe3jwa8f2PNEGcS9Y74+12QHPXGkVeNXA1HI7/anoiOj6ywp5wh5XFuW75DWuKi3zJgoN+c4bVC1w== 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=CkMDr98K5aiwzx9LPKvHPcyGWVZAYo6N9o4PNmTKra+DO76vH1/6sR06BUvtl0ItVVDDKjqzdKzQo7ax+yJRJJ2HYHTRBPc+8EAYJvHgC6KetYof2fJYwujajrQzWDnl5iXxTXIUCnXNqvY3oZ2bo600BexzWkeUJgq4FbUg0PxwwN0RzM1bG4T43qZAphaw3uzCxyAQqEhIn+zGD6c2TAIciESzUPszVY+8ZReJp/Mvtb7MCwnkjfSmFA4+SxffVlESsP+Imflpu6NliU5/v5jzicpXf4TrepLZZuxREC+4bJGBCscr7gXmckKqUJ9FFOzH7kEEmKyz7rLJ913kYw== 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=kBynsgwhShzZREiytvqVdPLfwjrmbrl1Ud1of2BCuT3iFNgeJ/DC1j99xBRIKCZoPCxjp/qWg5A4QVHbJAN8iIqGBR3XYtMBj5taL2qNPkxLnPZT1Kw0TXoYiKax0YJl5IuyXqSduKnvMtgWVu1hcdaKfZo1yB5fzysi+1jhxBY= Received: from OL1P279CA0051.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:14::20) by PA4PR06MB7357.eurprd06.prod.outlook.com (2603:10a6:102:d6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Thu, 12 May 2022 16:03:18 +0000 Received: from HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com (2603:10a6:e10:14:cafe::be) by OL1P279CA0051.outlook.office365.com (2603:10a6:e10:14::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:18 +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 HE1EUR02FT005.mail.protection.outlook.com (10.152.10.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:17 +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 Subject: [PATCH V5 2/5] iio: accel: sca3300: add define for temp channel for reuse. Date: Thu, 12 May 2022 16:03:09 +0000 Message-Id: <20220512160312.3880433-3-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220512160312.3880433-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220512160312.3880433-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: 8014b091-9c19-4d23-aa11-08da3430ede1 X-MS-TrafficTypeDiagnostic: PA4PR06MB7357: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: Gkv0U6V/DrV59mwsRB0xXHE38IRhFDk+vhuK84o/ImVyU2uLoqaMpvt/AEoWbLTv7Krqp8Fu4YtRP12BhuqhZ2IxDUrvx81ncQSNj57TQyu08bSH4qDCZb5CbFiLB0V0esWOyxUmsC1g01PXbm+gU56vJqWXdSrFBJYtWit/jAdj1KpsfvehEBIbZEulO1E7Ez7RK/pUumRHjjHGIdD9KtdZjB+RSSNsdidxV0HRRRZ3/12JnM95lN8bJBoylNLDf5Q9yTcIWvdZVYtesrPfhjhx9LFLMAARH+GOPOJuDtE01/MuM5+w1SJQko3v2d7NLJeiT+WC4YNltfKEC+HX82wAJzjZlJGMyb2nsB3EuCrqu4Ij20pSQWF9paGbsMJriuCOxgefgyZxp701VogXpWH5wYP5EeJ3sJ8UNVzagbpRAAbdlPkM8SLIVPzBm2cy8Hv40YMcScAgh0wDYGarwu/+GgdCN/rGEn5L6SShSx6NR36mAZ84vDoWMdYRn9YFaOFgFjY60XJoTbnGI4H0W/VolYF4VKCKcU3QDeP2RthcgpYfpeDcd4+lHvMcMFFsqmSnbkuIx2swgCFsQcSrKRD/spFGGNPikLCsksFtZ5aeOSM5fSIKiWyCrzWoCwBDFvMeQfppEZ3+KnJvZ4yR5WUt9qNYvj6iBi5U2pn9amoIl58mpVD/obUb+0KM5Thp 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)(40460700003)(316002)(1076003)(2906002)(186003)(36756003)(956004)(8936002)(356005)(81166007)(5660300002)(2616005)(83380400001)(36736006)(8676002)(508600001)(6506007)(36860700001)(6486002)(4326008)(70206006)(70586007)(118246002)(6512007)(6666004)(26005)(336012)(47076005)(86362001)(82310400005);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2022 16:03:17.6035 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8014b091-9c19-4d23-aa11-08da3430ede1 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: HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR06MB7357 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 May 12 16:03:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12847863 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 16D55C4321E for ; Thu, 12 May 2022 16:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356166AbiELQD0 (ORCPT ); Thu, 12 May 2022 12:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356165AbiELQDY (ORCPT ); Thu, 12 May 2022 12:03:24 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2094.outbound.protection.outlook.com [40.107.21.94]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FC1B62205; Thu, 12 May 2022 09:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i1u+7Vy8TTstIrRu2i1NZbH2jAsruMzE75LtUaGibs/L2BN20j8pVSZPn0LUzlhPEFjcIYB1ZKB9dJM0jcqqGnNr2+fobK9W2oxS3zew745vl4A/7H284ITl0gN3s3qCvdL54OZ/2CvcliUMDduPa1KPBns8evQr4GIu8vlIU34F39AVGJqYA+IR6uVdVheripNK5dOdHr6JzEZLwD/af167SkF6MDWAPCRm6qO+hpgkdpMWNXaxlElvYQDDvYiFSG9XXhfwCef6von5gHimuoP5prtAA6aVFA4JT+aoIfy6kDQgTnRtOW9MDIxQ+KhNZGsJTsg49sYqnpkz3KucKg== 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=fMssC8u6DNzhzOrLeXF9jkYO7TZ0xF8MfgyIjvvJsTY=; b=V3BLlCOyUQMoNPMhxnttuI9jCy3dm+SdZBqSPPRN1Dtbtcmnji5J60hQzcGiLiXjpg3/9+O12153PZeemAxxZy1RPv8sbJ0suhgJSLNpICGcTvt3ZW+C+35XTM+PTr82mSCC+gvFO7sgSQOVqJEN/W/81pdmSs5ejm1FFpL/zo7asKy77Oc+kRmtanX5ZShYVxV9ctqRdVacmgaJWgntpnxMN6qVNVP4yuZcIAfY7x+PW8veDuU7+yrTOd0pnMqGuWzyzpL/HAMPzdUReqqE2H6g081SY7nhCvkfANJkEvrW5wFCpuQ2so8ZFKWZaXxRw8TVM+AKHB4/b+TgPs7M+Q== 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=fMssC8u6DNzhzOrLeXF9jkYO7TZ0xF8MfgyIjvvJsTY=; b=mQ6hNfoanNI0Yin47bMH/rdW1Yk/AVGfr7UlqgxxBMln2rbrYvxrEdIy/xGTMICqf/ByF7LbaiGXa4ZDd9vl6NFj+1m+JHAcCbCEqV3Fg0BoVb0hYfz8roaL5LBtQOfPlJX3viz5M+B93k7pmIuU90LCOCfVLblZeMq93ikelzc= Received: from OL1P279CA0049.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:14::18) by HE1PR06MB3995.eurprd06.prod.outlook.com (2603:10a6:7:9f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Thu, 12 May 2022 16:03:19 +0000 Received: from HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com (2603:10a6:e10:14:cafe::a3) by OL1P279CA0049.outlook.office365.com (2603:10a6:e10:14::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:19 +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 HE1EUR02FT005.mail.protection.outlook.com (10.152.10.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:18 +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 Subject: [PATCH V5 3/5] iio: accel: sca3300: modified to support multi chips Date: Thu, 12 May 2022 16:03:10 +0000 Message-Id: <20220512160312.3880433-4-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220512160312.3880433-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220512160312.3880433-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: 1217c7b3-731f-4792-a035-08da3430ee7c X-MS-TrafficTypeDiagnostic: HE1PR06MB3995: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: Gn6IkFO0IE5easGcOWL4N2asyVB6zYG9wx4kqTaE5vPo459mRcD7nVcPOyJeurLuL9WlinPlFWSvkhBL9JgRcDH2XeVRbsLxgG8uOwUGm/5AP8mTw9wSfIc2/yG9ef1Jqu2brTpjiTiU25Z+2exz2IkbgE2adZ0I6V1tJSxBpuKuD4dfATgCEYd7uIS+0aiaNN4tESA0ZMkvjkYnS6lOjhkOTdDH3fWQex++Ox62STM31iyu8+0JSOf7elyPJm3Rv1zQfmiQFcvhAez6wQq1E2CCf8w1n07sm+bUo0z4wkvQeF+6o1wiWrXV0VlrsBz0BX0lPJkGiZSzcZaRbMbOqfHXm4OrgEq6TBv25kCifr/RRps6yS97Fcm1CKkLCeRE8GW6YPvmtR3Sf3rySJv4j1mLLSWAkId86opFHHvNuFpWxixRRBK5Zom6ut0m4vjozCAcRGgRoFiwIZwGZszLGze6AnEGM+epYPlw2x+RHAk+sJsJ2zQNLUPxRU+Ht6x0IBZjRfm3pxjOoyE029iuDgq1ZqcGSH5RIFuq1o8t80TM9kfam6/ohCfqnfTFBMaxoUfihiJ/pggaK//tENgB4nH9YcPqzcKdxlShS7Bl+cO+mZlYf6K/5EVFGEjOkPPv+vxSic/e4yqyxpg7T9NxG6fYcn+PL7JfYa/egNfRu2PJNufXTIh/K8PGKR8hWpAx 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)(40460700003)(6666004)(6486002)(956004)(2906002)(81166007)(118246002)(2616005)(1076003)(356005)(86362001)(508600001)(6506007)(186003)(5660300002)(36860700001)(8936002)(336012)(316002)(36756003)(82310400005)(6512007)(26005)(83380400001)(4326008)(8676002)(70586007)(70206006)(36736006)(47076005);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2022 16:03:18.6191 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1217c7b3-731f-4792-a035-08da3430ee7c 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: HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR06MB3995 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The driver supports sca3300 only, there are some other similar chips, for instance, SCL3300. This commit prepares the way for multiple chips and additional channels. Modify the driver to read the device ID and load the corresponding sensor information from the table to support multiple chips. add prepares for the addition of extra channels. Add prepares for handling the operation modes for multiple chips. Signed-off-by: LI Qingwu Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/iio/accel/sca3300.c | 186 ++++++++++++++++++++++++++++-------- 1 file changed, 145 insertions(+), 41 deletions(-) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index ff16d2cc8c70..80168f926b9d 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -93,15 +93,35 @@ static const struct iio_chan_spec sca3300_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(4), }; -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[] = {70, 10}; +static const int sca3300_lp_freq_map[] = {0, 0, 0, 1}; +static const int sca3300_accel_scale[][2] = {{0, 370}, {0, 741}, {0, 185}}; +static const int sca3300_accel_scale_map[] = {0, 1, 2, 2}; + +static const int sca3300_avail_modes_map[] = {0, 1, 2, 3}; static const unsigned long sca3300_scan_masks[] = { BIT(SCA3300_ACC_X) | BIT(SCA3300_ACC_Y) | BIT(SCA3300_ACC_Z) | BIT(SCA3300_TEMP), 0 }; +struct sca3300_chip_info { + const unsigned long *scan_masks; + const struct iio_chan_spec *channels; + u8 num_channels; + u8 num_accel_scales; + const int (*accel_scale)[2]; + const int *accel_scale_map; + u8 num_freqs; + const int *freq_table; + const int *freq_map; + const char *name; + const int *avail_modes_table; + u8 num_avail_modes; + u8 chip_id; +}; + /** * struct sca3300_data - device data * @spi: SPI device structure @@ -117,10 +137,28 @@ struct sca3300_data { s16 channels[4]; s64 ts __aligned(sizeof(s64)); } scan; + const struct sca3300_chip_info *chip; u8 txbuf[4] ____cacheline_aligned; u8 rxbuf[4]; }; +static const struct sca3300_chip_info sca3300_chip_tbl[] = { + { .scan_masks = sca3300_scan_masks, + .channels = sca3300_channels, + .num_channels = ARRAY_SIZE(sca3300_channels), + .num_accel_scales = ARRAY_SIZE(sca3300_accel_scale)*2, + .accel_scale = sca3300_accel_scale, + .accel_scale_map = sca3300_accel_scale_map, + .num_freqs = ARRAY_SIZE(sca3300_lp_freq), + .freq_table = sca3300_lp_freq, + .freq_map = sca3300_lp_freq_map, + .name = "sca3300", + .avail_modes_table = sca3300_avail_modes_map, + .num_avail_modes = 4, + .chip_id = SCA3300_WHOAMI_ID, + }, +}; + DECLARE_CRC8_TABLE(sca3300_crc_table); static int sca3300_transfer(struct sca3300_data *sca_data, int *val) @@ -227,36 +265,81 @@ 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, int index) +{ + if ((index < 0) || (index >= sca_data->chip->num_avail_modes)) + return -EINVAL; + + return sca3300_write_reg(sca_data, SCA3300_REG_MODE, + sca_data->chip->avail_modes_table[index]); +} + +static int sca3300_get_op_mode(struct sca3300_data *sca_data, int *index) +{ + int reg_val; + int ret; + int i; + + ret = sca3300_read_reg(sca_data, SCA3300_REG_MODE, ®_val); + if (ret) + return ret; + + for (i = 0; i < sca_data->chip->num_avail_modes; i++) { + if (sca_data->chip->avail_modes_table[i] == reg_val&0x03) + break; + } + + if (i >= sca_data->chip->num_avail_modes) + return -EINVAL; + + *index = i; + return 0; +} + +static int sca3300_set_frequency(struct sca3300_data *data, int val) +{ + const struct sca3300_chip_info *chip = data->chip; + int index; + int i; + + if (sca3300_get_op_mode(data, &index)) + return -EINVAL; + + for (i = 0; i < chip->num_avail_modes; i++) { + if ((val == chip->freq_table[chip->freq_map[i]]) && + (chip->accel_scale[chip->accel_scale_map[index]] == + chip->accel_scale[chip->accel_scale_map[i]])) + break; + } + + if (i >= chip->num_avail_modes) + return -EINVAL; + + return sca3300_set_op_mode(data, i); +} + 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 reg_val; - int ret; + int index; 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 < data->chip->num_avail_modes; i++) { + index = data->chip->accel_scale_map[i]; + if ((val == data->chip->accel_scale[index][0]) && + (val2 == data->chip->accel_scale[index][1])) { + return sca3300_set_op_mode(data, i); + } } return -EINVAL; - 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; + return sca3300_set_frequency(data, val); default: return -EINVAL; } @@ -267,8 +350,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 index; int ret; - int reg_val; switch (mask) { case IIO_CHAN_INFO_RAW: @@ -277,17 +360,25 @@ static int sca3300_read_raw(struct iio_dev *indio_dev, return ret; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - ret = sca3300_read_reg(data, SCA3300_REG_MODE, ®_val); + ret = sca3300_get_op_mode(data, &index); 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: + index = data->chip->accel_scale_map[index]; + *val = data->chip->accel_scale[index][0]; + *val2 = data->chip->accel_scale[index][1]; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: - ret = sca3300_read_reg(data, SCA3300_REG_MODE, ®_val); + + ret = sca3300_get_op_mode(data, &index); if (ret) return ret; - *val = sca3300_lp_freq[reg_val]; + index = data->chip->freq_map[index]; + *val = data->chip->freq_table[index]; return IIO_VAL_INT; default: return -EINVAL; @@ -331,6 +422,7 @@ static int sca3300_init(struct sca3300_data *sca_data, { int value = 0; int ret; + int i; ret = sca3300_write_reg(sca_data, SCA3300_REG_MODE, SCA3300_MODE_SW_RESET); @@ -347,12 +439,17 @@ 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_tbl); i++) { + if (sca3300_chip_tbl[i].chip_id == value) + break; + } + if (i == ARRAY_SIZE(sca3300_chip_tbl)) { + dev_err(&sca_data->spi->dev, "unknown chip id %x\n", value); return -ENODEV; } + + sca_data->chip = &sca3300_chip_tbl[i]; + return 0; } @@ -384,15 +481,21 @@ 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->accel_scale; + *length = data->chip->num_accel_scales; + *type = IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: - *vals = &sca3300_lp_freq[2]; - *length = 2; + *vals = (const int *)data->chip->freq_table; + *length = data->chip->num_freqs; *type = IIO_VAL_INT; return IIO_AVAIL_LIST; default: @@ -424,11 +527,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) { @@ -436,6 +534,12 @@ static int sca3300_probe(struct spi_device *spi) return ret; } + indio_dev->name = sca_data->chip->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = sca_data->chip->channels; + indio_dev->num_channels = sca_data->chip->num_channels; + indio_dev->available_scan_masks = sca_data->chip->scan_masks; + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, iio_pollfunc_store_time, sca3300_trigger_handler, NULL); From patchwork Thu May 12 16:03:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12847864 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 B7AA4C433F5 for ; Thu, 12 May 2022 16:03:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356161AbiELQD1 (ORCPT ); Thu, 12 May 2022 12:03:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356167AbiELQDY (ORCPT ); Thu, 12 May 2022 12:03:24 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2118.outbound.protection.outlook.com [40.107.104.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7031C6223B; Thu, 12 May 2022 09:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JE/RkP6fWmKiiFbOSIhIv9qCoFnfTg6dCCclnWzEK9CosyPc8orCk1vTjNKc8bIieh+onfrQQ9F60hWhM8nFXbuctAHPnkzB/Mr1d+h08HCikh+1zMgtfiwpDtzhZnZLBaCHSkENjQQWgxmd34WqzAWCmihnQJH3cZ3UhBDpBG7vxEKhrSetaPcX4VEZXGAJQeSCjVk7alGDgTG16D6YWzv2fmZBYLkhiPolCkPnoLoAojLqip5xiBgL8K57OqYXWKu3q0qc7YROB+ozJnFBHOO/5OOAx2UpZilEhzGrRR3TLq2pP46lqoMWHaZMIrL2ZdTTsyc2Mb+J2Ul9XZgMPw== 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=M84jlitE2mSHMNc2Q5CJija/Bbj2HJbzZlocwylgPIU=; b=ekOp16KS6IbHpiWMPSsCUczU5JWS8sITCDPBi6kqSw1VdXhDnl35p2jIOFWe+mm4Y4MU/T/zB8rt648hlV31vAaDPwF2gNTz4GhIwzYGLfVfYh9g45+EVkVMKMo65IRx+0X0kX8gtE0j0bOTbwp5BkZmzbJ1OtseHAOrnFq0DM2Qrk1ovhmIy5FGnE4W+r3QUMW7ul4YRI1Hv+glJ6B4ExOmIstjBN0YOKs7RF6CgSU25DVpBiM9a+etu8D9qGdNBG51x06b2ZGmqwKTscuLB+A19sIR5ZTxCgi7hJeG2ZSvKqgz3zLd01aKEhjJQ6WhTteehtVca1rMN9wsoaxJoQ== 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=M84jlitE2mSHMNc2Q5CJija/Bbj2HJbzZlocwylgPIU=; b=djJJZVbAYGUu7d8Il0+phWE3tnbuKP4y1zSlnL2YLXkUQ8xUu7+tcExDBCM2xuH28ygRCHDe7dzK/t1ygr27+NitmHOcDwzTZFh7zLlu21apFxzN2OVEI2KB6hsPxZbQUJeZhJgpsbX0p1DY/NpAb4E23b3dKFlCyYIHzzNjRf4= Received: from OL1P279CA0047.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:14::16) by AM6PR06MB4181.eurprd06.prod.outlook.com (2603:10a6:20b:1c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Thu, 12 May 2022 16:03:20 +0000 Received: from HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com (2603:10a6:e10:14:cafe::d3) by OL1P279CA0047.outlook.office365.com (2603:10a6:e10:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:20 +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 HE1EUR02FT005.mail.protection.outlook.com (10.152.10.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:19 +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 Subject: [PATCH V5 4/5] iio: accel: sca3300: Add support for SCL3300 Date: Thu, 12 May 2022 16:03:11 +0000 Message-Id: <20220512160312.3880433-5-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220512160312.3880433-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220512160312.3880433-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: 27c9d0ba-4f4d-4112-1f98-08da3430ef21 X-MS-TrafficTypeDiagnostic: AM6PR06MB4181: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: r+CdO8+FFduCF9AwS6wuvjp3xluIOKOzsjOJ3x/0BQQcPxzjsPsqOJnxSc9QAd3tT8AGp8qeCvwmfjhPTi6PtHCxUUma6EOE9KkC7jObsotIfsPe7j5wVEK8mbXzx/IGA3h3E4U9o8N+XAIdILD4MnpRs8jSkVFNx9nVIhD95Ql/zS3iUJA7x/Oai2+ONxA6wN2d8hYtWi/uVyukT6jjQp57mb3BZSitw2kjFfn7OMFcyBA51NW0sQZJ6kPfvHHYbffuXTpnEeV9NGojPIyVjvwL1QhgUsYz1tN7X7AdMrsP2DCrxIYq8a1Pd9ZuKcFRLWhYx1nIh8xM8eStR/zb4dh4kGr2EceE+kGMUpCGss7mbR2AUFAMUvHCNdih5l3UnzuJESjVCOYKHrCKZcYs64o5goy1KkvKINjTII0VzUCBxy79ThMzwHebxvYni/US58pbzcWiYl2UZIhRIpUX93pVJSk/AkL2kjjuF4vyWXJzQjubDOznyXA98Iq+hsd5mbAu8XFdtfd6JWR9SSIpdrqFjSfBF+3KG49WZMF5C01OBYhtkxsdaC76+Fo7DkyNsgc8vn1d/Pu7HZY/SPUg8/aVZRujXocUukIEMzKnuDrKJS3kb6wq7NypmKgqkbDeVRru8t4inLrSBrGT1xO7L/+88VfKPPoaKrohUoYXazc75CydDWB43tNOilSzFkpK/fUre0Ty/0gIpmK8wWrmpA0KrkQpwoRRvNwS8Jj7Q5aGuKb8JLsiafQcDqOXpd/J1jhxWfQo0NOXUHyO+3kLbQ== X-Forefront-Antispam-Report: CIP:193.8.40.94;CTRY:CH;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:aherlnxbspsrv01.lgs-net.com;PTR:ahersrvdom50.leica-geosystems.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(956004)(1076003)(86362001)(8936002)(15974865002)(36756003)(2616005)(6506007)(6666004)(81166007)(70206006)(36736006)(70586007)(316002)(4326008)(8676002)(82310400005)(2906002)(508600001)(356005)(6486002)(336012)(36860700001)(47076005)(5660300002)(118246002)(6512007)(26005)(40460700003)(186003);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2022 16:03:19.6971 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27c9d0ba-4f4d-4112-1f98-08da3430ef21 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: HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR06MB4181 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 the 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index 80168f926b9d..dc53e7ed3925 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -38,6 +38,7 @@ /* Device ID */ #define SCA3300_REG_WHOAMI 0x10 #define SCA3300_WHOAMI_ID 0x51 +#define SCL3300_WHOAMI_ID 0xC1 /* Device return status and mask */ #define SCA3300_VALUE_RS_ERROR 0x3 @@ -96,10 +97,18 @@ static const struct iio_chan_spec sca3300_channels[] = { static const int sca3300_lp_freq[] = {70, 10}; static const int sca3300_lp_freq_map[] = {0, 0, 0, 1}; +static const int scl3300_lp_freq[] = {40, 70, 10}; +static const int scl3300_lp_freq_map[] = {0, 1, 2}; + static const int sca3300_accel_scale[][2] = {{0, 370}, {0, 741}, {0, 185}}; static const int sca3300_accel_scale_map[] = {0, 1, 2, 2}; +static const int scl3300_accel_scale[][2] = {{0, 167}, {0, 333}, {0, 83}}; +static const int scl3300_accel_scale_map[] = {0, 1, 2}; + static const int sca3300_avail_modes_map[] = {0, 1, 2, 3}; +static const int scl3300_avail_modes_map[] = {0, 1, 3}; + static const unsigned long sca3300_scan_masks[] = { BIT(SCA3300_ACC_X) | BIT(SCA3300_ACC_Y) | BIT(SCA3300_ACC_Z) | BIT(SCA3300_TEMP), @@ -157,6 +166,20 @@ static const struct sca3300_chip_info sca3300_chip_tbl[] = { .num_avail_modes = 4, .chip_id = SCA3300_WHOAMI_ID, }, + { .scan_masks = sca3300_scan_masks, + .channels = sca3300_channels, + .num_channels = ARRAY_SIZE(sca3300_channels), + .num_accel_scales = ARRAY_SIZE(scl3300_accel_scale)*2, + .accel_scale = scl3300_accel_scale, + .accel_scale_map = scl3300_accel_scale_map, + .num_freqs = ARRAY_SIZE(scl3300_lp_freq), + .freq_table = scl3300_lp_freq, + .freq_map = scl3300_lp_freq_map, + .name = "scl3300", + .avail_modes_table = scl3300_avail_modes_map, + .num_avail_modes = 3, + .chip_id = SCL3300_WHOAMI_ID, + }, }; DECLARE_CRC8_TABLE(sca3300_crc_table); @@ -560,6 +583,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 May 12 16:03:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LI Qingwu X-Patchwork-Id: 12847865 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 847C6C433F5 for ; Thu, 12 May 2022 16:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356173AbiELQD3 (ORCPT ); Thu, 12 May 2022 12:03:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356176AbiELQD0 (ORCPT ); Thu, 12 May 2022 12:03:26 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2122.outbound.protection.outlook.com [40.107.21.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D8135F26F; Thu, 12 May 2022 09:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Teg0XyJrIARNzFcCHAaR70y5J4OVghOFdywrXxDRJmSswFLVfebU3rbNTVEYJQfU1E3TZ35oBcrnxbeMBTNmTpPTxtf0VQvW3B6rkR6zkeIX1IafB80tb3cEO4sd6Q6BxKrAWIezNtULfOTN0E1n04Qdu9LEsLAAmIvMmEoaEOHA7UPElSOYHs2o8hUqUIjlOol3RFM5xdYoBug0VQjPT2wanas2GOk5ahIjK8Xl+KbHizQkRNXZamIuLWVC6nNMi6blopK/VIJkVbUWRu7ZQERg+nXxNeLZGMmVlGThhc5p+hg0/IGSiK7bMLn+iWjftD9XRHVj1Yet/Ffm671TTQ== 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=g0ZEwcN33gvwMvi/n4QyU8Zd9aOU4b0tWYXCjjWPkU4=; b=fxhOP7OCuZlzLR2v37pz+9QbrpHS03Hab9fIcVeaf5tbx+Js+KOm4HICxaii/tbrnLxyWVIA3dFoLF6mQ1f6S5qMiJnHSL9Xlzc+aH1VqdqruVygdXFQpNAQZjza3s4dJVk9w9eWyp8zis8RYaBSoG81bkxhA9nrXD8owXQaBdi7PctkrFx6UthxF0hffXPrcil80F2Mzbd9eEJ19kBNlzpXioma5RVMLgHOTccqduCbobj2HpAMlZn8PamwzUbGX4y5OZ3zbwuQfZ9wS6Yszbk5iWUwKXLGHfoJygzH65NlfTLbGKPzbzIJwe55tTFVkEN52KWF998Bn5TYqBQkPg== 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=g0ZEwcN33gvwMvi/n4QyU8Zd9aOU4b0tWYXCjjWPkU4=; b=zcxWoAIRDj+ADdAtiWQeYR1og7CfIcZ0yucX1WqbTPVi8zp3LQzQ+ZmsCGQvS+w/CJajMMMWs9HenTDvjv/XBas+/FbzCsByDwSsTkBfZCfiCre+1iLnMgsNHVdK34JjH5jSiDQwyd3o1dlMWdjiH0+awcC5x4Jt2BcPLO3zqec= Received: from OL1P279CA0040.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:14::9) by AM0PR06MB6419.eurprd06.prod.outlook.com (2603:10a6:208:19b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13; Thu, 12 May 2022 16:03:21 +0000 Received: from HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com (2603:10a6:e10:14:cafe::11) by OL1P279CA0040.outlook.office365.com (2603:10a6:e10:14::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:21 +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 HE1EUR02FT005.mail.protection.outlook.com (10.152.10.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Thu, 12 May 2022 16:03:20 +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 Subject: [PATCH V5 5/5] iio: accel: sca3300: Add inclination channels Date: Thu, 12 May 2022 16:03:12 +0000 Message-Id: <20220512160312.3880433-6-Qing-wu.Li@leica-geosystems.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220512160312.3880433-1-Qing-wu.Li@leica-geosystems.com.cn> References: <20220512160312.3880433-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: 3b909f1e-3954-496b-963d-08da3430efb2 X-MS-TrafficTypeDiagnostic: AM0PR06MB6419: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: +25vFYhVscarVjA3qeHFq5yLMCTDbnlUYpKTcdliXRR7ckZfS2qAErjl10JvfDkCs/FTdBMJmXfJ7CBb6uvpItHHoieZdI8SYZerfpAaRqDyZMERqEOMvl/9P+gQ2cjj35PWQxGUDvYokHK3S0dSjdJNu9Ts/1Tkqh1QDUHW6TD36TeppME7F4R7lGveDD/qPdZ2+xlWu7H73Ck9Kzb8NIMYzbhqmDt5gFQvvh1ftUv0koYTWIYYeKktvauHRsZbfk+lazxGLRFEvKyYHpbvh8PhNA4rB0SGsMYbnBE4VJxxFoEICvh5vwgGuKMqWLsf2uZIVRk30OSJXilxeca8wrj+UvTtjNUmJDuUO0AWxdJqCfjo4BtdNOAtp6AtI/HW9hyRItdKHsk7UBFl7YFqvOuo040YIbVQohwjUPpUM6QsfbkUh/lE/jeAJoEElRu95DzLMvZUq3JVXiTvXBCSSWcq7RWmGDTX3CxIc7E2hIj7OX3dPv/b1BHOkq9jyOOwjEWhPn3SnN/1sXfjBMrbhPgoAKE9Rsa1J3oz8nHXsQW/m48NX6IM2NZkAOKWPtJhxrjKW3VazW3bGm79Tv8fwlznalT0re42JLNBSfpp3oWZccQROdLZjNebJsC5X9V8H5x34CRJZlonTCFTThlVJjzSR0R1Nda+nEIuLI5ini0DJIad9k1j9fANaS4SdMBv 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)(6486002)(8936002)(40460700003)(70586007)(36860700001)(508600001)(8676002)(5660300002)(336012)(186003)(83380400001)(1076003)(47076005)(118246002)(36756003)(86362001)(2616005)(2906002)(6666004)(81166007)(356005)(316002)(36736006)(4326008)(6512007)(6506007)(82310400005)(956004)(26005)(70206006);DIR:OUT;SFP:1102; X-OriginatorOrg: leica-geosystems.com.cn X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2022 16:03:20.6502 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b909f1e-3954-496b-963d-08da3430efb2 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: HE1EUR02FT005.eop-EUR02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR06MB6419 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Different from SCA3300, SCL3300 can output inclination angles. Angles are formed from acceleration with following equations: ANG_X = atan2(accx , sqrt(pow(accy , 2) + pow(accz , 2))) ANG_Y = atan2(accy , sqrt(pow(accx , 2) + pow(accz , 2))) ANG_Z = atan2(accz , sqrt(pow(accx , 2) + pow(accy , 2))) The commit adds the 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 Data converted by application of scale to degrees. Signed-off-by: LI Qingwu --- drivers/iio/accel/sca3300.c | 82 +++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index dc53e7ed3925..8057133c97e6 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -44,12 +44,18 @@ #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_scan_indexes { SCA3300_ACC_X = 0, SCA3300_ACC_Y, SCA3300_ACC_Z, SCA3300_TEMP, SCA3300_TIMESTAMP, + SCA3300_INCLI_X, + SCA3300_INCLI_Y, + SCA3300_INCLI_Z, }; #define SCA3300_ACCEL_CHANNEL(index, reg, axis) { \ @@ -73,6 +79,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, \ @@ -106,15 +130,36 @@ static const int sca3300_accel_scale_map[] = {0, 1, 2, 2}; static const int scl3300_accel_scale[][2] = {{0, 167}, {0, 333}, {0, 83}}; static const int scl3300_accel_scale_map[] = {0, 1, 2}; +static const int scl3300_incli_scale[][2] = {{0, 5495}}; +static const int scl3300_incli_scale_map[] = {0, 0, 0}; + static const int sca3300_avail_modes_map[] = {0, 1, 2, 3}; static const int scl3300_avail_modes_map[] = {0, 1, 3}; +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), + SCA3300_INCLI_CHANNEL(SCA3300_INCLI_X, 0x09, X), + SCA3300_INCLI_CHANNEL(SCA3300_INCLI_Y, 0x0A, Y), + SCA3300_INCLI_CHANNEL(SCA3300_INCLI_Z, 0x0B, Z), +}; + 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 unsigned long *scan_masks; const struct iio_chan_spec *channels; @@ -122,6 +167,9 @@ struct sca3300_chip_info { u8 num_accel_scales; const int (*accel_scale)[2]; const int *accel_scale_map; + const int (*incli_scale)[2]; + const int *incli_scale_map; + u8 num_incli_scales; u8 num_freqs; const int *freq_table; const int *freq_map; @@ -129,8 +177,10 @@ struct sca3300_chip_info { const int *avail_modes_table; u8 num_avail_modes; u8 chip_id; + bool angle; }; + /** * struct sca3300_data - device data * @spi: SPI device structure @@ -158,6 +208,9 @@ static const struct sca3300_chip_info sca3300_chip_tbl[] = { .num_accel_scales = ARRAY_SIZE(sca3300_accel_scale)*2, .accel_scale = sca3300_accel_scale, .accel_scale_map = sca3300_accel_scale_map, + .incli_scale = NULL, + .incli_scale_map = NULL, + .num_incli_scales = 0, .num_freqs = ARRAY_SIZE(sca3300_lp_freq), .freq_table = sca3300_lp_freq, .freq_map = sca3300_lp_freq_map, @@ -165,13 +218,18 @@ static const struct sca3300_chip_info sca3300_chip_tbl[] = { .avail_modes_table = sca3300_avail_modes_map, .num_avail_modes = 4, .chip_id = SCA3300_WHOAMI_ID, + .angle = false, }, - { .scan_masks = sca3300_scan_masks, - .channels = sca3300_channels, - .num_channels = ARRAY_SIZE(sca3300_channels), + { + .scan_masks = scl3300_scan_masks, + .channels = scl3300_channels, + .num_channels = ARRAY_SIZE(scl3300_channels), .num_accel_scales = ARRAY_SIZE(scl3300_accel_scale)*2, .accel_scale = scl3300_accel_scale, .accel_scale_map = scl3300_accel_scale_map, + .incli_scale = scl3300_incli_scale, + .incli_scale_map = scl3300_incli_scale_map, + .num_incli_scales = ARRAY_SIZE(scl3300_incli_scale)*2, .num_freqs = ARRAY_SIZE(scl3300_lp_freq), .freq_table = scl3300_lp_freq, .freq_map = scl3300_lp_freq_map, @@ -179,6 +237,7 @@ static const struct sca3300_chip_info sca3300_chip_tbl[] = { .avail_modes_table = scl3300_avail_modes_map, .num_avail_modes = 3, .chip_id = SCL3300_WHOAMI_ID, + .angle = true, }, }; @@ -387,6 +446,11 @@ static int sca3300_read_raw(struct iio_dev *indio_dev, if (ret) return ret; switch (chan->type) { + case IIO_INCLI: + index = data->chip->incli_scale_map[index]; + *val = data->chip->incli_scale[index][0]; + *val2 = data->chip->incli_scale[index][1]; + return IIO_VAL_INT_PLUS_MICRO; case IIO_ACCEL: index = data->chip->accel_scale_map[index]; *val = data->chip->accel_scale[index][0]; @@ -473,6 +537,13 @@ static int sca3300_init(struct sca3300_data *sca_data, sca_data->chip = &sca3300_chip_tbl[i]; + if (sca_data->chip->angle) { + ret = sca3300_write_reg(sca_data, SCA3300_REG_ANG_CTRL, + SCA3300_ANG_ENABLE); + if (ret) + return ret; + } + return 0; } @@ -508,6 +579,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->incli_scale; + *length = data->chip->num_incli_scales; + *type = IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; case IIO_ACCEL: *vals = (const int *)data->chip->accel_scale; *length = data->chip->num_accel_scales;