Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4232906imu; Mon, 14 Jan 2019 18:11:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN5R2AVvJyDeomTsTvrLkrhT70I+gCfDRCk4f8Fgs4quhVv99UMSUjvpO3ulakWNBKNi/7Uu X-Received: by 2002:a63:df13:: with SMTP id u19mr1539829pgg.294.1547518273031; Mon, 14 Jan 2019 18:11:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547518273; cv=none; d=google.com; s=arc-20160816; b=a2ORzxe21PB4z4Z/nsJLZW8n5oXbRkaQApDokSDX+XTEVSnCp7Ebsv1BQHiAXADUY6 1o03HskGpnzv9SqB40c5v+Z+5smoQekazA5/bZ2JbyMPmwYxtpb7CsGlreY7RZ59VPf+ MrmTrHvJR2ikvc+SLtaQfapoDyGGUQuGVctQjpTMBfWfCL02S+B7rLD+PEUfT8r2NJtx tBKZox7U5eCaW7lt6KAY6w1SvClxVyIjntHN6hxslJgAHbH3xPSk41A4TNxkXnRps3bl PC80DVWw+T2HrBmSjcQROFWnhQEScKeh1lOIH77ie+LT+TYR5Y2lKk3MFZDvRIi4VZIU 1H6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=UsaM3ooIJFH2oh3kVkcSozBXEBUObUQAs61tgQwiydg=; b=EyeXdGomd3SyyvlE179qAITKD/UlrV5zxL1fWsTXVhWnXA5TdfALdsanvQHcYkrOcE ti/nq9H7Tam1mBRMUacAMXa8ZSBVcDj0kqShkCJSo+7K6C+ioG1V9mDxDS4TlLb51IJP DWivWIPiywMX6hHcXIFpgu6PRk9/bmH9jk6+o9rc3n0WdKtkaXqtEd8DvXX4TI2e0x/K lpVgdAz8C5SgDu9Zvch86MOv21PbS29U8nnrAOJf7isIOkcbHaxqfiXqvBdQqJ+lD0+5 Z4QeMe4a3KRPJnhjA1zrM9CHIX1K4G4YzD/N5gsDo8IXNZ7tikyiHz79y5TeVxLn4o4D uUDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m14si1941419pgd.326.2019.01.14.18.10.44; Mon, 14 Jan 2019 18:11:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727330AbfAOATF convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 Jan 2019 19:19:05 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:37360 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbfAOATF (ORCPT ); Mon, 14 Jan 2019 19:19:05 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0F0GFX0025501; Tue, 15 Jan 2019 01:19:00 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2pyc012h1g-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 15 Jan 2019 01:19:00 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 94C2F31; Tue, 15 Jan 2019 00:18:59 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag4node1.st.com [10.75.127.10]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6D4C81130; Tue, 15 Jan 2019 00:18:59 +0000 (GMT) Received: from SFHDAG2NODE1.st.com (10.75.127.4) by SFHDAG4NODE1.st.com (10.75.127.10) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 15 Jan 2019 01:18:59 +0100 Received: from SFHDAG2NODE1.st.com ([fe80::4413:c8c:992b:bb90]) by SFHDAG2NODE1.st.com ([fe80::4413:c8c:992b:bb90%20]) with mapi id 15.00.1347.000; Tue, 15 Jan 2019 01:18:58 +0100 From: Denis CIOCCA To: Mario Tesi , "jic23@kernel.org" CC: "linux-iio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Mario TESI Subject: RE: [PATCH] iio:st_pressure:initial lps22hh sensor support Thread-Topic: [PATCH] iio:st_pressure:initial lps22hh sensor support Thread-Index: AQHUrC4eDiZaIhqSo064Gq5PC9PrK6Wvd1Ew Date: Tue, 15 Jan 2019 00:18:58 +0000 Message-ID: <2844d78742404a0ebea470fa5e0ec722@SFHDAG2NODE1.st.com> References: <1547486660-15359-1-git-send-email-mario.tesi@st.com> In-Reply-To: <1547486660-15359-1-git-send-email-mario.tesi@st.com> Accept-Language: it-IT, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.51] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-14_13:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Acked-by: Denis Ciocca -----Original Message----- From: linux-iio-owner@vger.kernel.org On Behalf Of Mario Tesi Sent: Monday, January 14, 2019 9:24 AM To: jic23@kernel.org Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; Mario TESI Subject: [PATCH] iio:st_pressure:initial lps22hh sensor support From: mario tesi Initial support for ST LPS22HH pressure sensor. Datasheet: http://www2.st.com/resource/en/datasheet/lps22hh.pdf Features: * pressure, temperature data and timestamping channels * sampling frequency selection [1..200] Hz * interrupt based trigger * over I2C or SPI interface Signed-off-by: mario tesi --- drivers/iio/pressure/Kconfig | 2 +- drivers/iio/pressure/st_pressure.h | 2 + drivers/iio/pressure/st_pressure_core.c | 69 +++++++++++++++++++++++++++++++++ drivers/iio/pressure/st_pressure_i2c.c | 5 +++ drivers/iio/pressure/st_pressure_spi.c | 5 +++ 5 files changed, 82 insertions(+), 1 deletion(-) diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index eaa7cfc..efeb89f 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -165,7 +165,7 @@ config IIO_ST_PRESS select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) help Say yes here to build support for STMicroelectronics pressure - sensors: LPS001WP, LPS25H, LPS331AP, LPS22HB. + sensors: LPS001WP, LPS25H, LPS331AP, LPS22HB, LPS22HH. This driver can also be built as a module. If so, these modules will be created: diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h index e67eb0d..5794660 100644 --- a/drivers/iio/pressure/st_pressure.h +++ b/drivers/iio/pressure/st_pressure.h @@ -21,6 +21,7 @@ enum st_press_type { LPS22HB, LPS33HW, LPS35HW, + LPS22HH, ST_PRESS_MAX, }; @@ -30,6 +31,7 @@ enum st_press_type { #define LPS22HB_PRESS_DEV_NAME "lps22hb" #define LPS33HW_PRESS_DEV_NAME "lps33hw" #define LPS35HW_PRESS_DEV_NAME "lps35hw" +#define LPS22HH_PRESS_DEV_NAME "lps22hh" /** * struct st_sensors_platform_data - default press platform data diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 4ddb6cf..38dcdb7 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -492,6 +492,75 @@ .multi_read_bit = false, .bootime = 2, }, + { + /* + * CUSTOM VALUES FOR LPS22HH SENSOR + * See LPS22HH datasheet: + * http://www2.st.com/resource/en/datasheet/lps22hh.pdf + */ + .wai = 0xb3, + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, + .sensors_supported = { + [0] = LPS22HH_PRESS_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_press_lps22hb_channels, + .num_ch = ARRAY_SIZE(st_press_lps22hb_channels), + .odr = { + .addr = 0x10, + .mask = 0x70, + .odr_avl = { + { .hz = 1, .value = 0x01 }, + { .hz = 10, .value = 0x02 }, + { .hz = 25, .value = 0x03 }, + { .hz = 50, .value = 0x04 }, + { .hz = 75, .value = 0x05 }, + { .hz = 100, .value = 0x06 }, + { .hz = 200, .value = 0x07 }, + }, + }, + .pw = { + .addr = 0x10, + .mask = 0x70, + .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, + }, + .fs = { + .fs_avl = { + /* + * Pressure and temperature sensitivity values + * as defined in table 3 of LPS22HH datasheet. + */ + [0] = { + .num = ST_PRESS_FS_AVL_1260MB, + .gain = ST_PRESS_KPASCAL_NANO_SCALE, + .gain2 = ST_PRESS_LPS22HB_LSB_PER_CELSIUS, + }, + }, + }, + .bdu = { + .addr = 0x10, + .mask = BIT(1), + }, + .drdy_irq = { + .int1 = { + .addr = 0x12, + .mask = BIT(2), + .addr_od = 0x11, + .mask_od = BIT(5), + }, + .addr_ihl = 0x11, + .mask_ihl = BIT(6), + .stat_drdy = { + .addr = ST_SENSORS_DEFAULT_STAT_ADDR, + .mask = 0x03, + }, + }, + .sim = { + .addr = 0x10, + .value = BIT(0), + }, + .multi_read_bit = false, + .bootime = 2, + }, }; static int st_press_write_raw(struct iio_dev *indio_dev, diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index 2026a10..a60849d 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -45,6 +45,10 @@ .compatible = "st,lps35hw", .data = LPS35HW_PRESS_DEV_NAME, }, + { + .compatible = "st,lps22hh", + .data = LPS22HH_PRESS_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_press_of_match); @@ -69,6 +73,7 @@ { LPS22HB_PRESS_DEV_NAME, LPS22HB }, { LPS33HW_PRESS_DEV_NAME, LPS33HW }, { LPS35HW_PRESS_DEV_NAME, LPS35HW }, + { LPS22HH_PRESS_DEV_NAME, LPS22HH }, {}, }; MODULE_DEVICE_TABLE(i2c, st_press_id_table); diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index 9a3441b..79a12ed 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -49,6 +49,10 @@ .compatible = "st,lps35hw", .data = LPS35HW_PRESS_DEV_NAME, }, + { + .compatible = "st,lps22hh", + .data = LPS22HH_PRESS_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_press_of_match); @@ -93,6 +97,7 @@ static int st_press_spi_remove(struct spi_device *spi) { LPS22HB_PRESS_DEV_NAME }, { LPS33HW_PRESS_DEV_NAME }, { LPS35HW_PRESS_DEV_NAME }, + { LPS22HH_PRESS_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(spi, st_press_id_table); -- 1.9.1