From patchwork Wed Oct 24 01:39:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kelly X-Patchwork-Id: 10654111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E0F514BD for ; Wed, 24 Oct 2018 03:15:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 227E229F77 for ; Wed, 24 Oct 2018 03:15:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1653E2A209; Wed, 24 Oct 2018 03:15:22 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A42D329F77 for ; Wed, 24 Oct 2018 03:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726301AbeJXLl0 (ORCPT ); Wed, 24 Oct 2018 07:41:26 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39461 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725952AbeJXLl0 (ORCPT ); Wed, 24 Oct 2018 07:41:26 -0400 Received: by mail-pl1-f196.google.com with SMTP id e67-v6so1567406plb.6 for ; Tue, 23 Oct 2018 20:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martingkelly-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=0C/jgL0qR5hjEgdfyqIDTpOWwLl3IM7ncgI4KZ5XNuM=; b=qY8rn7VQbQ8ZEjhGywcPpIAKMPPrt/nyY6yo7qhD2ksXKudJz+BYTxoPTh9P+thcsI yGoEL1ucDGN1Wkc+kUCIbrO9P0hLpX7tS1lj/SZfvmH5EpO9Tct33gfob9tXlkXv+yEz wRd07sv00C76BqVNiCa6njsMpV3kXC2RUgjoKxXoE2pa2/i6UkYlpsjQQ35NBF3ZOGq2 yaeTQszxCDS/uTXCUPr8RbZm3jlb2rB4DYmzW5/BdnqQAPMoPbAi733RkaLR1WDPUNs4 YlMHsu3a9GeHu1RA5fcrtGXnUYDo06dSODiBGGMy0vABvRR8GGsp4/GBKYbtWi1Gp6l9 9kVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0C/jgL0qR5hjEgdfyqIDTpOWwLl3IM7ncgI4KZ5XNuM=; b=ctm5GizSJWscZ8lgHKn2ZnJiA0gaouYIji/PB0tbb7bdFA4I8+i0bmdAgTM6gsylXZ ZDYpoWf9BnA2lLs0sxS8+36Z1RC4u+a1NMcFLccIM8kpAOtn5DEoa4328+joCWUH5iuD BVXS+Yl1hQgFWp0ElM2n/RCkFFix3RLZ+khV9Aa+eoGHIPUAH99uje7s8bMMA4NZwJ35 iCtQgoDsvLPqQsBeQihyUmuvC/eZz/zNaYTSsZg6fS0EqaENTVWRciHTLvjM2Ok7p+9Q S7H16D55I/+LoJ/X23vZNdl01FtdMXHkiv4CyCTqkbHGir80L6mzNVM/7m6Cj9bhndXz Sqcg== X-Gm-Message-State: AGRZ1gLb452Ec/mgUqCAElFVc3QlVuEqAWlJV4wn71xwUVuiy2M/y9ye jBrRVYgYCEvgMMTDMjXHZa587qtd1cB8ag== X-Google-Smtp-Source: AJdET5fdoGEWGJfhJeDNFsaNt9fSU4Uy+U9Py34KeYrZyW4DlRZthSz30BUBaOwjgKiA4CAY0zcVIA== X-Received: by 2002:a17:902:aa84:: with SMTP id d4-v6mr638997plr.25.1540345201176; Tue, 23 Oct 2018 18:40:01 -0700 (PDT) Received: from cascade.Home (71-212-17-184.tukw.qwest.net. [71.212.17.184]) by smtp.gmail.com with ESMTPSA id x23-v6sm3221043pfh.56.2018.10.23.18.40.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 18:40:00 -0700 (PDT) From: Martin Kelly X-Google-Original-From: Martin Kelly , Denis Ciocca , Jonathan Cameron , Rob Herring , Mark Rutland , Martin Kelly Subject: [PATCH 1/2] iio:magnetometer: st_magn: add LSM9DS1 support Date: Tue, 23 Oct 2018 18:39:47 -0700 Message-Id: <20181024013948.16326-1-martin@martingkelly.com> X-Mailer: git-send-email 2.11.0 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 From: Martin Kelly Update the sensor settings to support the LSM9DS1 sensor. Although the LSM9DS1 accelerometer and gyroscope are coupled together to use the same FIFO, the magnetometer is separate and can be cleanly supported without refactoring the existing driver. Signed-off-by: Martin Kelly --- drivers/iio/magnetometer/st_magn.h | 1 + drivers/iio/magnetometer/st_magn_core.c | 68 +++++++++++++++++++++++++++++++++ drivers/iio/magnetometer/st_magn_spi.c | 5 +++ 3 files changed, 74 insertions(+) diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h index 8fe51ce427bd..3a4abcd1f106 100644 --- a/drivers/iio/magnetometer/st_magn.h +++ b/drivers/iio/magnetometer/st_magn.h @@ -20,6 +20,7 @@ #define LIS3MDL_MAGN_DEV_NAME "lis3mdl" #define LSM303AGR_MAGN_DEV_NAME "lsm303agr_magn" #define LIS2MDL_MAGN_DEV_NAME "lis2mdl" +#define LSM9DS1_MAGN_DEV_NAME "lsm9ds1" int st_magn_common_probe(struct iio_dev *indio_dev); void st_magn_common_remove(struct iio_dev *indio_dev); diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 72f6d1335a04..dfbdeb428467 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -378,6 +378,74 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { .multi_read_bit = false, .bootime = 2, }, + { + .wai = 0x3d, + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, + .sensors_supported = { + [0] = LSM9DS1_MAGN_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_magn_2_16bit_channels, + .odr = { + /* Fast ODR mode currently not supported. */ + .addr = 0x20, + .mask = 0x1c, + .odr_avl = { + { .hz = 5, .value = 0x03 }, + { .hz = 10, .value = 0x04 }, + { .hz = 20, .value = 0x05 }, + { .hz = 40, .value = 0x06 }, + { .hz = 80, .value = 0x07 }, + }, + }, + .pw = { + .addr = 0x22, + .mask = 0x03, + .value_on = 0x00, + .value_off = 0x03, + }, + .fs = { + .addr = 0x21, + .mask = 0x60, + .fs_avl = { + [0] = { + .num = ST_MAGN_FS_AVL_4000MG, + .value = 0x00, + .gain = 140, + }, + [1] = { + .num = ST_MAGN_FS_AVL_8000MG, + .value = 0x01, + .gain = 290, + }, + [2] = { + .num = ST_MAGN_FS_AVL_12000MG, + .value = 0x02, + .gain = 430, + }, + [3] = { + .num = ST_MAGN_FS_AVL_16000MG, + .value = 0x03, + .gain = 580, + }, + }, + }, + .bdu = { + .addr = 0x24, + .mask = 0x40, + }, + .drdy_irq = { + .stat_drdy = { + .addr = ST_SENSORS_DEFAULT_STAT_ADDR, + .mask = 0x07, + }, + }, + .sim = { + .addr = 0x22, + .value = BIT(2), + }, + .multi_read_bit = true, + .bootime = 2, + }, }; static int st_magn_read_raw(struct iio_dev *indio_dev, diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index 7b7cd08fcc32..433456920673 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -37,6 +37,10 @@ static const struct of_device_id st_magn_of_match[] = { .compatible = "st,lis2mdl", .data = LIS2MDL_MAGN_DEV_NAME, }, + { + .compatible = "st,lsm9ds1", + .data = LSM9DS1_MAGN_DEV_NAME, + }, {} }; MODULE_DEVICE_TABLE(of, st_magn_of_match); @@ -79,6 +83,7 @@ static const struct spi_device_id st_magn_id_table[] = { { LIS3MDL_MAGN_DEV_NAME }, { LSM303AGR_MAGN_DEV_NAME }, { LIS2MDL_MAGN_DEV_NAME }, + { LSM9DS1_MAGN_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(spi, st_magn_id_table); From patchwork Wed Oct 24 01:39:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kelly X-Patchwork-Id: 10654109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3738514BD for ; Wed, 24 Oct 2018 03:15:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CA622A187 for ; Wed, 24 Oct 2018 03:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 107492A20E; Wed, 24 Oct 2018 03:15:06 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A11902A303 for ; Wed, 24 Oct 2018 03:15:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725979AbeJXLlK (ORCPT ); Wed, 24 Oct 2018 07:41:10 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44171 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725952AbeJXLlK (ORCPT ); Wed, 24 Oct 2018 07:41:10 -0400 Received: by mail-pf1-f196.google.com with SMTP id r9-v6so1679517pff.11 for ; Tue, 23 Oct 2018 20:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martingkelly-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HAJE7mJTelPHE+zjDKLmhGpM0oUjF82TduOUVxs8K6E=; b=s+pz9U/4oqliXNP+EKYnSieAV8/BSJV92BuIF/VXm9yR8GtsvjQCBtVePbB0Xl5W/q mXVXvEF2E/nRLL5MwxCbiJ5t3YFQUbTH5wP7+32FF/XBbKL5u0t1BQmfFlM5t7wZjqx4 y0mgXmYELfYbwrEtKg0xWFnkcr+Dv470oxhAl/xltc1nKDGZHq94snMEpVtBMrOWDQQL 8iGOdFcLzhirB2H+UZPq8B5YRlUow0hqRpfGrOXB6WTKr72yVDxYsiGOfS4qxo6b6Fyb oIzl7skLqmvQrqi44rhBqkzWgpHSuVJl37yuyngqq07/OXog5iEACeiPs8HwuZi/H/7e zi2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HAJE7mJTelPHE+zjDKLmhGpM0oUjF82TduOUVxs8K6E=; b=mH4AuVVtmC00wiYIsWdEBpQRbgNu7+gzLmAA+EwGwKcjia0lH6sUp9597eZ46877ve Pt0GeQM84Ch0Kii4FIKQQJ0kQZOGd7bG1+L3zrXpYImZfqhFQPJNDToBWWHtM6Lzfkhb Zeae7SpIiVzO4/8ECEYVQPdZdtZ748+kx0Vrw1t2Smf1KIODqQn+StcwOfMf7GLPxRsQ d3QddCZcuK5T1cVhuy+Bht1NDYLAL+p7AkHpLFlqvRmFno/r1KN3Q+BVr/cGLKoXSSHF 8JydBjDJqo18jbQYDxAUOM6gPO51UkieSkoHEh2bPTsppzUm3r7sOYWwQPu2ThgZ+6PK chUw== X-Gm-Message-State: AGRZ1gKMnxV8wJYTyyS3V94wWyPCb2YRxaofNMvrYinRCcRDN8IKrCCR QBaMEE4MzLM4pM72uyNLl05E7Zybt6qUDg== X-Google-Smtp-Source: AJdET5cHS0etjfBTOBkyWkpTymNuhW0bgh1H5SeWxo3bwvIUsbAn+L49cedoDEGH82KkP2za7L84hQ== X-Received: by 2002:a63:6445:: with SMTP id y66mr676914pgb.250.1540345202588; Tue, 23 Oct 2018 18:40:02 -0700 (PDT) Received: from cascade.Home (71-212-17-184.tukw.qwest.net. [71.212.17.184]) by smtp.gmail.com with ESMTPSA id x23-v6sm3221043pfh.56.2018.10.23.18.40.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 18:40:02 -0700 (PDT) From: Martin Kelly X-Google-Original-From: Martin Kelly , Denis Ciocca , Jonathan Cameron , Rob Herring , Mark Rutland , Martin Kelly Subject: [PATCH 2/2] dt-bindings: iio: magn: add LSM9DS1 bindings Date: Tue, 23 Oct 2018 18:39:48 -0700 Message-Id: <20181024013948.16326-2-martin@martingkelly.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181024013948.16326-1-martin@martingkelly.com> References: <20181024013948.16326-1-martin@martingkelly.com> 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 From: Martin Kelly Add DT binding documentation for the LSM9DS1 magnetometer driver. Signed-off-by: Martin Kelly Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/iio/st-sensors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt index 6f626f73417e..284e86dcbd69 100644 --- a/Documentation/devicetree/bindings/iio/st-sensors.txt +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt @@ -67,6 +67,7 @@ Magnetometers: - st,lsm303dlm-magn - st,lis3mdl-magn - st,lis2mdl +- st,lsm9ds1 Pressure sensors: - st,lps001wp-press