From patchwork Tue May 22 14:18:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 10418727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A3F9600CC for ; Tue, 22 May 2018 14:19:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49EE528C78 for ; Tue, 22 May 2018 14:19:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E03D28C7A; Tue, 22 May 2018 14:19:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C54F28C79 for ; Tue, 22 May 2018 14:19:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751561AbeEVOTD (ORCPT ); Tue, 22 May 2018 10:19:03 -0400 Received: from mail-by2nam03on0049.outbound.protection.outlook.com ([104.47.42.49]:59361 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751411AbeEVOTB (ORCPT ); Tue, 22 May 2018 10:19:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jr8GaB7Ptp7wAPsQsLnSNZWfEC0aivQlHVnNpLiWlTE=; b=k8FwvpUbC4EefMJ7+7H2aLEEFVUkNFEPSmR2aa0c5ygPRINI74KcZJ5VTmG29BKtI39KPteOzhMw9unh/zqFqGK9dx4xwFTEQxtbZGhyD4M2TRVx8y9tHJmfTjNwIi2XgrSMelNempGdFc2mspSF6riIFaqvg2GjJ7j3HmHfQwQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=JManeyrol@invensense.com; Received: from frgnb-12nlpn2.invcorp.invensense.com (2a01:e35:87fd:c140:d9b1:749c:d974:2408) by DM5PR1201MB0187.namprd12.prod.outlook.com (2603:10b6:4:56::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.11; Tue, 22 May 2018 14:18:58 +0000 From: Jean-Baptiste Maneyrol To: linux-iio@vger.kernel.org Cc: Jean-Baptiste Maneyrol Subject: [PATCH v2 5/5] iio: imu: inv_mpu6050: new timestamp mechanism Date: Tue, 22 May 2018 16:18:22 +0200 Message-Id: <20180522141822.11598-5-jmaneyrol@invensense.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180522141822.11598-1-jmaneyrol@invensense.com> References: <20180522141822.11598-1-jmaneyrol@invensense.com> MIME-Version: 1.0 X-Originating-IP: [2a01:e35:87fd:c140:d9b1:749c:d974:2408] X-ClientProxiedBy: LNXP265CA0069.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::33) To DM5PR1201MB0187.namprd12.prod.outlook.com (2603:10b6:4:56::11) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM5PR1201MB0187; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0187; 3:PVpkzZqe0Slscu9l1yfC6cSihSob1nGyc1ifIfSSepa+1pGdRlPZ8HGvQqTxu6Sb2E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ycwsYJGbvJVK5IH/mOqUu8FxAUNUu0HvteBkGcXHo2EcnvGJWpbJ/aBjt0sXKI2eJiLkX8ueIvPjl5Bif/8X7BACYPKWOrHWSkEzUzff8BgGlT1upqQ2m6RUknBYN4FeW+7D8IGoXa1sVjQc+MdjN/ntoam5H3iOUv7XlhF5um706Gob4x2Uz8dc0EYsYzhsFNGOAgxSuaOWwKRPqQ1sxc7a8v6emoJbcvTcp6CXjSKT3uHIXq6KianjSbN88b5YEMQx+r1W+jltM4jylCAlD35dFXu9eTV; 4:Phw57yxRozh1joebeLWB5eHTf29zUVvGBfjISHmF0ptNeKA9a8EAExHRXgHp5IHkEltiCVf/SnyUwFEVYj5siMwqt2KVdxFUk73SnRNWW7Nok1mQRhkA0nqyGsuaaZkVu40nC0CQLJsrjC5Ikx7NVnSSkjppdazFUXsxlP154AAOY/Rz1yq3L9WoH8ph9dMYpYMa3YkXxC+C5aOH/DVgmBZlFU0HKo9C0bUfXJnU8iobKdsSjlxNItGHbOOnnpzDXnUCH5NYnTcXltgBwt06Mm/lCRL2xxl8ZEFl/tYl8eO1/xnO4TzNVPrTM43Amags X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(257004950022427); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:DM5PR1201MB0187; BCL:0; PCL:0; RULEID:; SRVR:DM5PR1201MB0187; X-Forefront-PRVS: 0680FADD48 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(396003)(376002)(366004)(39850400004)(346002)(199004)(189003)(50226002)(8676002)(52396003)(81156014)(6116002)(5660300001)(107886003)(36756003)(316002)(80792005)(97736004)(7736002)(4326008)(52116002)(1076002)(8936002)(305945005)(81166006)(7696005)(6486002)(53936002)(51416003)(186003)(476003)(2616005)(59450400001)(50466002)(11346002)(48376002)(2361001)(16526019)(46003)(478600001)(106356001)(16586007)(386003)(68736007)(446003)(86362001)(2351001)(486006)(76176011)(6666003)(6916009)(72206003)(105586002)(2906002)(25786009)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0187; H:frgnb-12nlpn2.invcorp.invensense.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR1201MB0187; 23:TaGf0hEbokHtrNndxEMnehuvF0T8ddCzOtdjG7X?= =?us-ascii?Q?nGVsgZXRS42QIvVerCYlyL6KebIqgI9NoKxaftkimAlJzbBtQqiIfRmIXYW4?= =?us-ascii?Q?DE9GykYlM3X/Kvn3/H7eUsCRRSQ+XxOS7hszJyAH4BnG0jTPIrm8uRAayVRA?= =?us-ascii?Q?zP5laNSd8lAZkbNf8SMv21IZ5zyF/PZnaRJ9EE1BdWRJTnJmpjaNomDX41Vi?= =?us-ascii?Q?SqoPIA+SXX5FPngRRN2NiZnXSIkgiC+xKa3/Y+caCF11ayDPcnkfr+UrFAxc?= =?us-ascii?Q?bW092ymRaxPMDl98+77jMq2QoUwYc+ljzWkBB7o83F4JDFD1gWEDsZch+xCz?= =?us-ascii?Q?1Rw8i2H1H8zYzP3luYM2BXN0Bac4E73LIFu73tBx2tlXQFCfOyTMU+3RZLWe?= =?us-ascii?Q?ANQkVqPqcHV4C/fV8RiIoI83Usu5RTCFACiHqohlFSe3UX6siLuyVU+0b3TY?= =?us-ascii?Q?2mtldd1nwuXg+GmdQFmYWVPsPQ1+qMpNI0WXRiwFU+OxTBe2Dz3l0DnYhQGl?= =?us-ascii?Q?gAoFOFH3AQ9mhlYxxnT4LQ+4wdyU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w2exwvjQm4vYQO02u8u4QgkYOkN43KHnyUoLF5JvX2TAaJNf X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0187; 6:aC5iYtFueaLDpVlpfERYosTk/K3uUeHdzLGe8mU3j9til1qCMACCEJOerpSG8nxAWd7iLpn+hMyf/BxbFNcmbMNENU0wM4X3ThAAL4/STOrwh4RcRR79lhALJWbgwe9/GRTgpPWdw/e6laPT8ANTJL9y85k7uXajOTva8H0hD4+lNiqs3lvwhw2pxTuW1U6pScXerS6jBDGnSuUcxa0b/NMufAKxbR+//KS2EgLUstnj/gagZh7UTKH9cI+ulWzBaDL7jfmt+cG3m91R+SlpuOSQBMDW1NOuk6Un/rUJqPchqm3r6kd6KtP/J1gkZ5qvJr/6qeIjKGu3gPAbXmyDclljP/RsJlyPsEyGEHrTYMilRbg8Biimfy3457OYIvqMqg8c3mXH5PcY/UOsiX6nfXz5k1oGU11RvpOEpcUJNLwfuu/TFxkkkPhcfRRZ4OHzlvlDUnxGvjvwcjhOYlyc9w==; 5:ogfLvELUwC+faF3zWdPGII1SX3FFbmGP1xfYdlMqh4R2YFqUKt7i5/E0Y0gMuzB+pM/KhVNdJ8TyCLzgqMoXdSp/wyW8KL83YNY5Y6IPWLl93njaOcugWokVvS2jW1DjvRKpi03H8Ta/Dn1X2nx01k9zH9XbAueQ3KugHiT4oFw=; 24:uHlQ58mthCxQMNRU0Nf9W4EoSs6ly881zcVyqcUl5GzoR02L4KZxfgJo4UUJqu4unayjqA1Xk5niRdkJLE3Jy7wrnaLKoZz7tbMYD9j/XyI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0187; 7:qv8hgrNFY2qONSybuiOQb1axa7DT0bzbQmgDJkpm805GkHAol2fQXrPLHOiNDPBc+b0XMn5H0zdOw+sndT8OyxjhEE1y7ijgEhULcYFolPnbZ8tdCqFJbQRLtRd61WFi5DDqLSlr9fwf8pXpSNsFtjLVKy6MDfTT0rZdZ+HHmi1C1SJZC8EEDaBtjGYdaMEfUcmI4c+nxX5opTHwI876YDqZ6n99Zn5EOJIfk25mPQYLxjpBFZvx+xKYcjqfVGDu; 20:zHPWO9Y5ISWsCGW7XtoMCqVdgLRtpyGNHAqDAWrYpD7l3r7l0zV8tCUGCaF1mYvNyqHyyxIENbOJhO6WOevt/gbhRZ5NaTWWf2YCCcyts9rVCWDGh3HwHmocckbBpEar5rY7MIpB6mBeYf5D7Nk8BKR37pFp1z804XVpibtoSko= X-MS-Office365-Filtering-Correlation-Id: 719dbcc8-f27b-49fc-a9e4-08d5bfeef5de X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2018 14:18:58.4987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 719dbcc8-f27b-49fc-a9e4-08d5bfeef5de X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0187 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Check validity of interrupt timestamps by computing time between 2 interrupts. If it matches the chip frequency modulo 4%, it is used as the data timestamp and also for estimating the chip frequency measured from the system. Otherwise timestamp is computed using the estimated chip frequency. Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 ++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 8 +++ drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 81 +++++++++++++++++++++- 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 2c3e666aa970..93c64f30b615 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -295,6 +295,13 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev) memcpy(&st->chip_config, hw_info[st->chip_type].config, sizeof(struct inv_mpu6050_chip_config)); + /* + * Internal chip period is 1ms (1kHz). + * Let's use at the beginning the theorical value before measuring + * with interrupt timestamps. + */ + st->chip_period = NSEC_PER_MSEC; + return inv_mpu6050_set_power_itg(st, false); error_power_off: diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index 6bc80ac9d120..de8391693e17 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -125,6 +125,9 @@ struct inv_mpu6050_hw { * @map regmap pointer. * @irq interrupt number. * @irq_mask the int_pin_cfg mask to configure interrupt type. + * @chip_period: chip internal period estimation (~1kHz). + * @it_timestamp: timestamp from previous interrupt. + * @data_timestamp: timestamp for next data sample. */ struct inv_mpu6050_state { struct mutex lock; @@ -142,6 +145,9 @@ struct inv_mpu6050_state { int irq; u8 irq_mask; unsigned skip_samples; + s64 chip_period; + s64 it_timestamp; + s64 data_timestamp; }; /*register and associated bit definition*/ @@ -223,6 +229,8 @@ struct inv_mpu6050_state { #define INV_MPU6050_LATCH_INT_EN 0x20 #define INV_MPU6050_BIT_BYPASS_EN 0x2 +/* Allowed timestamp period jitter in percent */ +#define INV_MPU6050_TS_PERIOD_JITTER 4 /* init parameters */ #define INV_MPU6050_INIT_FIFO_RATE 50 diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index 7a4aaed83044..6930af413397 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -23,12 +23,89 @@ #include #include "inv_mpu_iio.h" +/** + * inv_mpu6050_update_period() - Update chip internal period estimation + * + * @st: driver state + * @timestamp: the interrupt timestamp + * @nb: number of data set in the fifo + * + * This function uses interrupt timestamps to estimate the chip period and + * to choose the data timestamp to come. + */ +static void inv_mpu6050_update_period(struct inv_mpu6050_state *st, + s64 timestamp, size_t nb) +{ + /* Period boundaries for accepting timestamp */ + const s64 period_min = + (NSEC_PER_MSEC * (100 - INV_MPU6050_TS_PERIOD_JITTER)) / 100; + const s64 period_max = + (NSEC_PER_MSEC * (100 + INV_MPU6050_TS_PERIOD_JITTER)) / 100; + const unsigned divider = INV_MPU6050_FREQ_DIVIDER(st); + s64 delta, interval; + bool use_it_timestamp = false; + + if (st->it_timestamp == 0) { + /* not initialized, forced to use it_timestamp */ + use_it_timestamp = true; + } else if (nb == 1) { + /* + * Validate the use of it timestamp by checking if interrupt + * has been delayed. + * nb > 1 means interrupt was delayed for more than 1 sample, + * so it's obviously not good. + * Compute the chip period between 2 interrupts for validating. + */ + delta = (timestamp - st->it_timestamp) / divider; + if (delta > period_min && delta < period_max) { + /* update chip period and use it timestamp */ + st->chip_period = (st->chip_period + delta) / 2; + use_it_timestamp = true; + } + } + + if (use_it_timestamp) { + /* + * Manage case of multiple samples in the fifo (nb > 1): + * compute timestamp corresponding to the first sample using + * estimated chip period. + */ + interval = (nb - 1) * st->chip_period * divider; + st->data_timestamp = timestamp - interval; + } + + /* save it timestamp */ + st->it_timestamp = timestamp; +} + +/** + * inv_mpu6050_get_timestamp() - Return the current data timestamp + * + * @st: driver state + * @return: current data timestamp + * + * This function returns the current data timestamp and prepares for next one. + */ +static s64 inv_mpu6050_get_timestamp(struct inv_mpu6050_state *st) +{ + s64 ts; + + /* return current data timestamp and increment */ + ts = st->data_timestamp; + st->data_timestamp += st->chip_period * INV_MPU6050_FREQ_DIVIDER(st); + + return ts; +} + int inv_reset_fifo(struct iio_dev *indio_dev) { int result; u8 d; struct inv_mpu6050_state *st = iio_priv(indio_dev); + /* reset it timestamp validation */ + st->it_timestamp = 0; + /* disable interrupt */ result = regmap_write(st->map, st->reg->int_enable, 0); if (result) { @@ -97,7 +174,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) int result; u8 data[INV_MPU6050_OUTPUT_DATA_SIZE]; u16 fifo_count; - s64 timestamp = pf->timestamp; + s64 timestamp; int int_status; size_t i, nb; @@ -140,6 +217,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) fifo_count = get_unaligned_be16(&data[0]); /* compute and process all complete datum */ nb = fifo_count / bytes_per_datum; + inv_mpu6050_update_period(st, pf->timestamp, nb); for (i = 0; i < nb; ++i) { result = regmap_bulk_read(st->map, st->reg->fifo_r_w, data, bytes_per_datum); @@ -150,6 +228,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) st->skip_samples--; continue; } + timestamp = inv_mpu6050_get_timestamp(st); iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp); }