From patchwork Sun Sep 17 16:17:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 9954915 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 0E1D260352 for ; Sun, 17 Sep 2017 16:17:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0097828385 for ; Sun, 17 Sep 2017 16:17:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9993286F8; Sun, 17 Sep 2017 16:17:50 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 455FC28703 for ; Sun, 17 Sep 2017 16:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751671AbdIQQRW (ORCPT ); Sun, 17 Sep 2017 12:17:22 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35875 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651AbdIQQRU (ORCPT ); Sun, 17 Sep 2017 12:17:20 -0400 Received: by mail-wm0-f67.google.com with SMTP id r136so6710360wmf.3; Sun, 17 Sep 2017 09:17:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MsVLrzn5PqfP2Sye3Kk+vlcM1JjOpexHlL+W+wXGh2A=; b=Aa56wMEhHxCZbNAw66VPDS6p9X6vU0TUxIUY16k+054okGndH1XZEBpzloOOsexubh xAciYW+1G1ayAAEj+ffdpHhAKi+ghn4gLNrmwyosSj9y+GMIMXuGvhIp44d4xh/B7pmb /tbSGfIm8paWHtnRUTHsoJcYeGCGS6BeCW3YF/2qzlfJIWBfjW5LsWTOe30YWKDKInya +uAnOZqjvRKVYXwNumONZFTaVOYVjoLPcTQhsLzdMiZvPrQ8IgaBj7T7BqxsOghvse+T Mzz2otzQe1ArzHWpUF1zoA/RqRAYbPO59/7F93IsBbPrcClPbxJacfl+vMHlMfgjaTzd UUCw== 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=MsVLrzn5PqfP2Sye3Kk+vlcM1JjOpexHlL+W+wXGh2A=; b=G7WOJ4tUYelIn1w1SqNqrj5E/rIvjyO3EuI6k3xRsHJJgWvd96Kz6ate5p3SVcn49p PAqdqO9OnDEwaYv+oVrNFzlk6Vn3Ti7oP2K2ucMbblSatBEOlX7ePLVxTh6niVm6UEKG Zhc/l4UQyU4Aqk2d28GHXUFHSO4Adszh3EDQPqk1alH++ba50G9kvZFOonv/k0HxZMOy M1VjbsnxRJR/7SXZCIDFak/LXXOjf36yfGlzlkmb0XptHkBAo7uJc8MI0KhMiflFawAL ryk9ghCm3GOFHE0lRRo6kCmOGW31yLxsAyv157wxjE2KT0eu6A3j8oXw1rgSCyucNSwP snZA== X-Gm-Message-State: AHPjjUg47fKuSDViO4ns0NB/5eNtnAtsOlxdXevGbJhFhZTOwqpFpQdh 1wc4kX1TFxXiSGWR9T1uph8= X-Google-Smtp-Source: AOwi7QDV6WCVC0TZ5qywEfEEIFng5JM0pvFwKbkJbCxeNxmBFjg7+zKNCm1s5RsoTb0hEIbAGuMjwg== X-Received: by 10.28.179.9 with SMTP id c9mr6966479wmf.57.1505665038886; Sun, 17 Sep 2017 09:17:18 -0700 (PDT) Received: from localhost.localdomain ([151.66.56.134]) by smtp.gmail.com with ESMTPSA id 56sm5299468wrx.2.2017.09.17.09.17.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Sep 2017 09:17:18 -0700 (PDT) From: Lorenzo Bianconi X-Google-Original-From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, lorenzo.bianconi@st.com, devicetree@vger.kernel.org Subject: [PATCH 3/4] iio: accel: add support to LIS3DHH Date: Sun, 17 Sep 2017 18:17:11 +0200 Message-Id: <20170917161712.14645-4-lorenzo.bianconi@st.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170917161712.14645-1-lorenzo.bianconi@st.com> References: <20170917161712.14645-1-lorenzo.bianconi@st.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 add support to STMicroelectronics LIS3DHH accel sensor http://www.st.com/resource/en/datasheet/lis3dhh.pdf Signed-off-by: Lorenzo Bianconi --- drivers/iio/accel/st_accel.h | 2 ++ drivers/iio/accel/st_accel_core.c | 52 +++++++++++++++++++++++++++++++++++++++ drivers/iio/accel/st_accel_spi.c | 5 ++++ 3 files changed, 59 insertions(+) diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h index 2ed0f60418c0..2f931e4837e5 100644 --- a/drivers/iio/accel/st_accel.h +++ b/drivers/iio/accel/st_accel.h @@ -33,6 +33,7 @@ enum st_accel_type { LIS331DL, LIS3LV02DL, LIS2DW12, + LIS3DHH, ST_ACCEL_MAX, }; @@ -54,6 +55,7 @@ enum st_accel_type { #define LIS3L02DQ_ACCEL_DEV_NAME "lis3l02dq" #define LNG2DM_ACCEL_DEV_NAME "lng2dm" #define LIS2DW12_ACCEL_DEV_NAME "lis2dw12" +#define LIS3DHH_ACCEL_DEV_NAME "lis3dhh" /** * struct st_sensors_platform_data - default accel platform data diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index c88db25a1aff..460aa58e0159 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -777,6 +777,58 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { .multi_read_bit = false, .bootime = 2, }, + { + .wai = 0x11, + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, + .sensors_supported = { + [0] = LIS3DHH_ACCEL_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_accel_16bit_channels, + .odr = { + /* just ODR = 1100Hz available */ + .odr_avl = { + { .hz = 1100, .value = 0x00, }, + }, + }, + .pw = { + .addr = 0x20, + .mask = 0x80, + .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE, + .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, + }, + .fs = { + .fs_avl = { + [0] = { + .num = ST_ACCEL_FS_AVL_2G, + .gain = IIO_G_TO_M_S_2(76), + }, + }, + }, + .bdu = { + .addr = 0x20, + .mask = 0x01, + }, + .drdy_irq = { + .int1 = { + .addr = 0x21, + .mask = 0x80, + .addr_od = 0x23, + .mask_od = 0x04, + }, + .int2 = { + .addr = 0x22, + .mask = 0x80, + .addr_od = 0x23, + .mask_od = 0x08, + }, + .stat_drdy = { + .addr = ST_SENSORS_DEFAULT_STAT_ADDR, + .mask = 0x07, + }, + }, + .multi_read_bit = false, + .bootime = 2, + }, }; static int st_accel_read_raw(struct iio_dev *indio_dev, diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index 7692da49e59f..dcc9bd243a52 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -86,6 +86,10 @@ static const struct of_device_id st_accel_of_match[] = { .compatible = "st,lis2dw12", .data = LIS2DW12_ACCEL_DEV_NAME, }, + { + .compatible = "st,lis3dhh", + .data = LIS3DHH_ACCEL_DEV_NAME, + }, {} }; MODULE_DEVICE_TABLE(of, st_accel_of_match); @@ -138,6 +142,7 @@ static const struct spi_device_id st_accel_id_table[] = { { LIS331DL_ACCEL_DEV_NAME }, { LIS3LV02DL_ACCEL_DEV_NAME }, { LIS2DW12_ACCEL_DEV_NAME }, + { LIS3DHH_ACCEL_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(spi, st_accel_id_table);