From patchwork Tue Apr 19 15:45:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Rokosov X-Patchwork-Id: 12818750 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 9E7B0C4167B for ; Tue, 19 Apr 2022 16:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354337AbiDSQHo (ORCPT ); Tue, 19 Apr 2022 12:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354328AbiDSQH3 (ORCPT ); Tue, 19 Apr 2022 12:07:29 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 611B235ABB; Tue, 19 Apr 2022 09:04:35 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id B48355FD06; Tue, 19 Apr 2022 18:46:43 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1650383203; bh=FgIhnfyhkzdJQqe2GL+vfkTnpbKRdN4mqOCrSqMUQG4=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=jv7Wou6+JNuIklPgKYH35wR6JLyMCCUOdLXLmkHd3WM6dLt0WOqmvlsG8u3/ZxJ6D FUBu5OaunqsvMVodcZMDiLSoNmonn2iwP321lBiTFyR/xkwJzRiR1XdMzKtuJFxQJJ bGRKlWCT9rmeVM8KJ7X6q01JIm1HzLlK2IRyByg7VwqwZBTQjZ4vDz9ZxZYepVnCNZ Qs10cmRoKpDtwx4L7rhQ16BUDfsOVLDW5yX+0EwuPV/fp9O7Zn2qIi4xM9gkrRqCPA 5j/cYtXpqPzejZp7Z3QYfzvNvkrwobL1LWHs8YPZUzl1xFYkQhnNPsR/Nu9t/gX4wx lw/Zp6EryiG1w== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Tue, 19 Apr 2022 18:46:43 +0300 (MSK) From: Rokosov Dmitry Dmitrievich To: "robh+dt@kernel.org" , "stano.jakubek@gmail.com" , "shawnguo@kernel.org" , "jic23@kernel.org" , "lars@metafoo.de" , "andy.shevchenko@gmail.com" , "stephan@gerhold.net" CC: "linux-iio@vger.kernel.org" , "devicetree@vger.kernel.org" , kernel , "linux-kernel@vger.kernel.org" , Rokosov Dmitry Dmitrievich Subject: [PATCH v1 0/3] iio: accel: add MSA311 accelerometer driver Thread-Topic: [PATCH v1 0/3] iio: accel: add MSA311 accelerometer driver Thread-Index: AQHYVASG6e/L14/R5Uev6QnUCJ5Flw== Date: Tue, 19 Apr 2022 15:45:48 +0000 Message-ID: <20220419154555.24191-1-ddrokosov@sberdevices.ru> Accept-Language: ru-RU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/04/19 10:34:00 #19304456 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org MSA311 is a tri-axial, low-g accelerometer with I2C digital output for sensitivity consumer applications. It has dynamical user selectable full scales range of +-2g/+-4g/+-8g/+-16g and allows acceleration measurements with output data rates from 1Hz to 1000Hz. Datasheet can be found at following URL: https://cdn-shop.adafruit.com/product-files/5309/MSA311-V1.1-ENG.pdf This driver supports following MSA311 features: - IIO interface - Different power modes: NORMAL, SUSPEND and LOW (using pm_runtime) - ODR (Output Data Rate) selection - Scale and samp_freq selection - IIO triggered buffer, IIO reg access - NEW_DATA interrupt + trigger Below features to be done: - Motion Events: ACTIVE, TAP, ORIENT, FREEFALL Also this patchset has new vendor prefix for MEMSensing Microsystems and MSA311 dt-binding schema. You can test msa311 driver using libiio and gnuplot following below instructions: $ # Read 4K samples using buffer with depth equals to 64 samples and $ # rotate device a little bit $ iio_readdev -u "local:" -b 64 -s 4096 msa311 > /data/local/tmp/msa311.dat $ gnuplot gnuplot> set title "MSA311 Accel Data" gnuplot> gnuplot> set key below gnuplot> gnuplot> set xdata time gnuplot> set format x "%H:%M\n%.4S" gnuplot> set xlabel "timestamp" gnuplot> gnuplot> set autoscale y gnuplot> plot 'msa311.dat' binary format='%int16%int16%int16%uint16%uint64'\ > using ($5/1000000000):1 title "acc_x" with lines,\ > 'msa311.dat' binary format='%int16%int16%int16%uint16%uint64' using\ > ($5/1000000000):2 title "acc_y" with lines,\ > 'msa311.dat' binary format='%int16%int16%int16%uint16%uint64' using\ > ($5/1000000000):3 title "acc_z" with lines Dmitry Rokosov (3): dt-bindings: vendor-prefixes: add MEMSensing Microsystems Co., Ltd. iio: add MEMSensing MSA311 3-axis accelerometer driver dt-bindings: iio: accel: add dt-binding schema for msa311 accel driver .../bindings/iio/accel/memsensing,msa311.yaml | 64 + .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 7 + drivers/iio/accel/Kconfig | 13 + drivers/iio/accel/Makefile | 2 + drivers/iio/accel/msa311.c | 2068 ++++++++++++++++++++ 6 files changed, 2156 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/accel/memsensing,msa311.yaml create mode 100644 drivers/iio/accel/msa311.c