From patchwork Wed Sep 27 12:56:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13400764 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 56E62E810DD for ; Wed, 27 Sep 2023 12:56:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231773AbjI0M43 (ORCPT ); Wed, 27 Sep 2023 08:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231749AbjI0M4Y (ORCPT ); Wed, 27 Sep 2023 08:56:24 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD6D194; Wed, 27 Sep 2023 05:56:22 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-50482ba2b20so1067158e87.1; Wed, 27 Sep 2023 05:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695819380; x=1696424180; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=0DE0mLNtJsF5eQFGXeJoUeYHt3jhgAAPiZzB3iqa8Xc=; b=jXbZOMGnfxsvHaX4PASafK/KkaE21INIUlIr3XlDPulB0FGPF90TNFp902WqieFXSq qpxPJ7uOKzhUVr7GdczoR33USwKn+uOHZ2eE+wTogJIYzpCkillAUBcfZX/3SOKoRx1s lH/FVbGg3B1Qd0rIETA9/UY1BBBEynT4cmC4piJkHoe/gs5j/PPWfDT+xIZ9yST5hasD KkDzRX/ORj5FQGs1yVaJ4D11HSe6D5lw4uQK9kx2WiMXiSJe2r4Fh2Xbr3K24X7Y0wRB EyRrQvFZfARjen4p7AavVLE/moIZXgHbtihklBqHsQc2L5UUS7ISF3o7xkMTK2M6IX25 Gg3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695819380; x=1696424180; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0DE0mLNtJsF5eQFGXeJoUeYHt3jhgAAPiZzB3iqa8Xc=; b=jvJ4a3qpg1c5j0mfYQZYf0jWq282SOAMDuKV/kVl4YT+oJkmJOiV3gThQBJ7WYPRn2 7xN4oxWQz2ixu2J82Y0aqmf5E0sxbNsg6qRAfUZ+3R7JZ2mm/Hzv+arej2S/aa0MrLQr IyvtQja/v7nZXb0KxWkxsjb44cBeCtbKwbViY6OJjOGQ1SFVKZVf/Vauu4ViHzgQhJHo lfP2ulkjo9RFb52BUj3meLOFIVCKXXJ/av8DMBLPpIxbzO3z6VuZ1dPbrrhwSpKNK6qM jbH8uadW/66qyNXGFdI1TC/AdvwaKpenb/F9l6MZaTII/kuncJh5LqlKllIF2cvpzrce rDeQ== X-Gm-Message-State: AOJu0YzCSzmpoznQaA0CUh/zbKOLB8b038dajKxLDCnUoa6OMeenNkXS TuvPdSV7yIKenBj1RRVaKvA= X-Google-Smtp-Source: AGHT+IHLF/ceQR2phD4Q7ymVsxwHgQ+3Arg2p4oysiQlBVXiVH7QYDHUVepdBU9075xxznJcYJJmQg== X-Received: by 2002:a05:6512:31c8:b0:502:df19:83b3 with SMTP id j8-20020a05651231c800b00502df1983b3mr2265767lfe.10.1695819380151; Wed, 27 Sep 2023 05:56:20 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id x20-20020a05651c105400b002c02b36d381sm3169889ljm.88.2023.09.27.05.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 05:56:19 -0700 (PDT) Date: Wed, 27 Sep 2023 15:56:14 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , Mehdi Djait , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] dt-bindings: iio: Add KX132ACR-LBZ accelerometer Message-ID: <5c9e03ffad5e6e5970d6e71fb02eab4b652e109f.1695819243.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org ROHM KX132ACR-LBZ is an accelerometer for industrial applications. It has a subset of KX022A functionalities, dropping support for tap, free fall and tilt detection engines. Also, the register interface is an exact subset of what is found on KX022A. Extend the kionix,kx022a.yaml file to support the KX132ACR-LBZ device Signed-off-by: Matti Vaittinen --- .../devicetree/bindings/iio/accel/kionix,kx022a.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml b/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml index 034b69614416..66ea894dbe55 100644 --- a/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml +++ b/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml @@ -4,21 +4,23 @@ $id: http://devicetree.org/schemas/iio/accel/kionix,kx022a.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM/Kionix KX022A and KX132-1211 Accelerometers +title: ROHM/Kionix KX022A, KX132-1211 and KX132ACR-LBZ Accelerometers maintainers: - Matti Vaittinen description: | - KX022A and KX132-1211 are 3-axis accelerometers supporting +/- 2G, 4G, 8G and - 16G ranges, variable output data-rates and a hardware-fifo buffering. - KX022A and KX132-1211 can be accessed either via I2C or SPI. + KX022A, KX132ACR-LBZ and KX132-1211 are 3-axis accelerometers supporting + +/- 2G, 4G, 8G and 16G ranges, variable output data-rates and a + hardware-fifo buffering. These accelerometers can be accessed either + via I2C or SPI. properties: compatible: enum: - kionix,kx022a - kionix,kx132-1211 + - rohm,kx132acr-lbz reg: maxItems: 1 From patchwork Wed Sep 27 12:56:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13400765 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 E657BE810DE for ; Wed, 27 Sep 2023 12:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbjI0M4l (ORCPT ); Wed, 27 Sep 2023 08:56:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231794AbjI0M4k (ORCPT ); Wed, 27 Sep 2023 08:56:40 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0640B19A; Wed, 27 Sep 2023 05:56:38 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c012232792so187939881fa.0; Wed, 27 Sep 2023 05:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695819396; x=1696424196; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/STRLEXwyIt6rSvyA0lWIiep8SC45mkNHds5YDZ1SYA=; b=Rn9QyNlrhrWkLB7jAM6jmRsXmlbQ5/ak0KBrg7argOsKOAvPlkKnBPWJnY7Uo8udTy Wkb7YuwY68ryHlPynVg/eMBFc9Nm8IuG0VHwebtuj9TgN7eXbvf/X/eeH0YjoudCTBHY 2LGIz9V6KTA7AwhZclirOVZTOJ61UvA+XsjQcs4Zwwq927GzIRzNJafgCmAviEZ/wmGi Cg7nbgyFiKujUjK9uYvWE4o1CsYxmSjN/0nsmYWkw/QWvhRXIbKel5v3/krfXIqEUBeo LiPFxF8EpAEYqoPfqHxDNnAq8+PzGGdwKnk25swVPruWrbqMO9pF93oVYibz9AiKcfvK X9Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695819396; x=1696424196; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/STRLEXwyIt6rSvyA0lWIiep8SC45mkNHds5YDZ1SYA=; b=SOQv5QiKziKvpjRvZZjXsl3sAQ1EMSRZX2EAn6hgLm/vl13GGIVgzwxsxBJ2sy4XPV g3WngOgj1QiuFBe20hk1rQy9GxmQgNizNDuuG+dNVbSvf4n42397Ppc1Hs0KfLqy4tbQ Y+7WwZo6Bq00lFAZc9c650Ay2URJq2s6t0MPTUED/uobcnAZB7nCOZdoJttoDzyCj490 Xh/B8UnRYvjVdKPnrPy6yOPrRiOkODR0yXJzYAgdp7711vS9PakWYqrkiMYZaIDL80kp CB7cnDJPNKE6nsR6fnWx4EEzOadXHuZP78W2rWXvmUT/tGqQD00mQUrpUOftq0BI2CBp O3WA== X-Gm-Message-State: AOJu0YzlB4zGXv70FcCo13/Pt0p3oz3vUeMNPMq0O8P7cYCVldRgRZ2L 22ncltSXe00y/Hewrm5oTAA= X-Google-Smtp-Source: AGHT+IH67VMmt4/1etE9oRhfSXdZIyp8eZNkM9j2AckPHC6ADGBkMV/PB8fvl8SPGrKChjuY3bux9g== X-Received: by 2002:a2e:be2c:0:b0:2b9:ed84:b2bf with SMTP id z44-20020a2ebe2c000000b002b9ed84b2bfmr2313467ljq.33.1695819396388; Wed, 27 Sep 2023 05:56:36 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id x6-20020a2e9c86000000b002ba045496d0sm3124231lji.125.2023.09.27.05.56.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 05:56:35 -0700 (PDT) Date: Wed, 27 Sep 2023 15:56:31 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , Mehdi Djait , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] iio: kx022a: Support ROHM KX132ACR-LBZ Message-ID: <3bc7431c7899b166d26b1c8d8f85914a5727b16a.1695819243.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org dt-bindings: iio: Add KX132ACR-LBZ accelerometer ROHM KX132ACR-LBZ is an accelerometer for industrial applications. It has a subset of KX022A functionalities, dropping support for tap, free fall and tilt detection engines. Also, the register interface is an exact subset of what is found on KX022A (except the WHO_AM_I register value). Add support for KX132ACR-LBZ. Signed-off-by: Matti Vaittinen --- drivers/iio/accel/kionix-kx022a-i2c.c | 4 +++- drivers/iio/accel/kionix-kx022a-spi.c | 4 +++- drivers/iio/accel/kionix-kx022a.c | 34 ++++++++++++++++++++++++++- drivers/iio/accel/kionix-kx022a.h | 2 ++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/kionix-kx022a-i2c.c b/drivers/iio/accel/kionix-kx022a-i2c.c index fc53e527cae0..8a1d4fc28ddd 100644 --- a/drivers/iio/accel/kionix-kx022a-i2c.c +++ b/drivers/iio/accel/kionix-kx022a-i2c.c @@ -2,7 +2,7 @@ /* * Copyright (C) 2022 ROHM Semiconductors * - * ROHM/KIONIX KX022A accelerometer driver + * ROHM/KIONIX accelerometer driver */ #include @@ -38,6 +38,7 @@ static int kx022a_i2c_probe(struct i2c_client *i2c) static const struct i2c_device_id kx022a_i2c_id[] = { { .name = "kx022a", .driver_data = (kernel_ulong_t)&kx022a_chip_info }, { .name = "kx132-1211", .driver_data = (kernel_ulong_t)&kx132_chip_info }, + { .name = "kx132acr-lbz", .driver_data = (kernel_ulong_t)&kx132acr_chip_info }, { } }; MODULE_DEVICE_TABLE(i2c, kx022a_i2c_id); @@ -45,6 +46,7 @@ MODULE_DEVICE_TABLE(i2c, kx022a_i2c_id); static const struct of_device_id kx022a_of_match[] = { { .compatible = "kionix,kx022a", .data = &kx022a_chip_info }, { .compatible = "kionix,kx132-1211", .data = &kx132_chip_info }, + { .compatible = "rohm,kx132acr-lbz", .data = &kx132acr_chip_info }, { } }; MODULE_DEVICE_TABLE(of, kx022a_of_match); diff --git a/drivers/iio/accel/kionix-kx022a-spi.c b/drivers/iio/accel/kionix-kx022a-spi.c index e7878ba67827..f798b964d0b5 100644 --- a/drivers/iio/accel/kionix-kx022a-spi.c +++ b/drivers/iio/accel/kionix-kx022a-spi.c @@ -2,7 +2,7 @@ /* * Copyright (C) 2022 ROHM Semiconductors * - * ROHM/KIONIX KX022A accelerometer driver + * ROHM/KIONIX accelerometer driver */ #include @@ -38,6 +38,7 @@ static int kx022a_spi_probe(struct spi_device *spi) static const struct spi_device_id kx022a_id[] = { { .name = "kx022a", .driver_data = (kernel_ulong_t)&kx022a_chip_info }, { .name = "kx132-1211", .driver_data = (kernel_ulong_t)&kx132_chip_info }, + { .name = "kx132acr-lbz", .driver_data = (kernel_ulong_t)&kx132acr_chip_info }, { } }; MODULE_DEVICE_TABLE(spi, kx022a_id); @@ -45,6 +46,7 @@ MODULE_DEVICE_TABLE(spi, kx022a_id); static const struct of_device_id kx022a_of_match[] = { { .compatible = "kionix,kx022a", .data = &kx022a_chip_info }, { .compatible = "kionix,kx132-1211", .data = &kx132_chip_info }, + { .compatible = "rohm,kx132acr-lbz", .data = &kx132acr_chip_info }, { } }; MODULE_DEVICE_TABLE(of, kx022a_of_match); diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index c5b555094e60..60864be3a667 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -2,7 +2,7 @@ /* * Copyright (C) 2022 ROHM Semiconductors * - * ROHM/KIONIX KX022A accelerometer driver + * ROHM/KIONIX accelerometer driver */ #include @@ -1188,6 +1188,38 @@ const struct kx022a_chip_info kx132_chip_info = { }; EXPORT_SYMBOL_NS_GPL(kx132_chip_info, IIO_KX022A); +/* + * Despite the naming, KX132ACR-LBZ is not similar to KX132-1211 but it is + * exact subset of KX022A. KX132ACR-LBZ is meant to be used for industrial + * applications and the tap/double tap, free fall and tilt engines were + * removed. Rest of the registers and functionalities (excluding the ID + * register) are exact match to what is found in KX022. + */ +const struct kx022a_chip_info kx132acr_chip_info = { + .name = "kx132acr-lbz", + .regmap_config = &kx022a_regmap_config, + .channels = kx022a_channels, + .num_channels = ARRAY_SIZE(kx022a_channels), + .fifo_length = KX022A_FIFO_LENGTH, + .who = KX022A_REG_WHO, + .id = KX132ACR_LBZ_ID, + .cntl = KX022A_REG_CNTL, + .cntl2 = KX022A_REG_CNTL2, + .odcntl = KX022A_REG_ODCNTL, + .buf_cntl1 = KX022A_REG_BUF_CNTL1, + .buf_cntl2 = KX022A_REG_BUF_CNTL2, + .buf_clear = KX022A_REG_BUF_CLEAR, + .buf_status1 = KX022A_REG_BUF_STATUS_1, + .buf_read = KX022A_REG_BUF_READ, + .inc1 = KX022A_REG_INC1, + .inc4 = KX022A_REG_INC4, + .inc5 = KX022A_REG_INC5, + .inc6 = KX022A_REG_INC6, + .xout_l = KX022A_REG_XOUT_L, + .get_fifo_bytes_available = kx022a_get_fifo_bytes_available, +}; +EXPORT_SYMBOL_NS_GPL(kx132acr_chip_info, IIO_KX022A); + int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chip_info) { static const char * const regulator_names[] = {"io-vdd", "vdd"}; diff --git a/drivers/iio/accel/kionix-kx022a.h b/drivers/iio/accel/kionix-kx022a.h index 35c548ae7eff..7060438ad88c 100644 --- a/drivers/iio/accel/kionix-kx022a.h +++ b/drivers/iio/accel/kionix-kx022a.h @@ -13,6 +13,7 @@ #define KX022A_REG_WHO 0x0f #define KX022A_ID 0xc8 +#define KX132ACR_LBZ_ID 0xd8 #define KX022A_REG_CNTL2 0x19 #define KX022A_MASK_SRST BIT(7) @@ -186,5 +187,6 @@ int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chi extern const struct kx022a_chip_info kx022a_chip_info; extern const struct kx022a_chip_info kx132_chip_info; +extern const struct kx022a_chip_info kx132acr_chip_info; #endif