From patchwork Wed Aug 23 21:16:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 716251 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 4BE92C3DA6F for ; Wed, 23 Aug 2023 21:18:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237276AbjHWVRb (ORCPT ); Wed, 23 Aug 2023 17:17:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237735AbjHWVRS (ORCPT ); Wed, 23 Aug 2023 17:17:18 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EF9F1702; Wed, 23 Aug 2023 14:16:58 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-31aeedbb264so4023600f8f.0; Wed, 23 Aug 2023 14:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692825417; x=1693430217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U0SXq78kITy+3F6975QNYAlOEwatlqb3yYsPUiIzHhc=; b=BqMoyWKVPmaVRnuEAnAFskDkZqw0g4JOWqkssnXg/IhvapZ8gRuMtQPII131OMw3Pb VqHkxZ/VQb1cCMoeaf9TFVLtJ5b2OGYL8P5uYYCo/nEwifFserg7H8/VqPxv0BfvELSg Wb7hG6OFl+WKJZOKPpioh9x7hbOlbN7rVpDRzG+2+iRMWzx6raKTVk9brM9W7OeM/f0K mzEhLZOcg3+oh4scFyA82j22+g1L0QuNtQctk+63HAptUz80LE/M7cDWjAUc62RpDHGv /L8tGJz9Usi+1k8GiRPlkDgdQPbW6uOPMPqVmY4wuCDxTggx/irUpXlwPMffaSmm0xmn qNvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692825417; x=1693430217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U0SXq78kITy+3F6975QNYAlOEwatlqb3yYsPUiIzHhc=; b=RITYuaojjv9QcqdVTBQaPwNLqMHlRipg5Aa9XAorDkOlom1yNkEvn8gSvR+hkOGcwz azCZ2gwM5LdAJe9+0FylobcxJNFXforA4et/txYFa9miI48mozsNrKiLRspRyKY+8vdu Li7hYAQ4eWfY8UDiN1R1Qp5q3+1nfhEiw64nk3cJyCl438x3mIX7wsZyl94+pzJzkjJK /8KepUKbFT30JJf/VTLTuIs6ZGjAay0PRQ6Xqwg2ToPHFe64QT/36chLiHkJ+phO3oVV IvY0i1nqpZ6TtJbdXxZp3QuWk07fvffgZ1G5tONGaLFZywk1uoE4SZJFZb3N2UBm/Yel lkuQ== X-Gm-Message-State: AOJu0YwRJ+psEP2fhhMaGpZBqI8Y3F8LcjmLoFK/3pmmMFkJU+zRS/5W vMA5nq8HwnKQW3I9bgbyC0VsovzUh07hAA== X-Google-Smtp-Source: AGHT+IEVIgvede2H6lzCsw9URrQcv9ofjSzlZO2INQ515SlTKlOLmVCesgJYDK4nGVfg6RqZieS4IA== X-Received: by 2002:adf:e5cf:0:b0:314:2132:a277 with SMTP id a15-20020adfe5cf000000b003142132a277mr11043759wrn.9.1692825416657; Wed, 23 Aug 2023 14:16:56 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id p11-20020adfe60b000000b003176c6e87b1sm20193399wrm.81.2023.08.23.14.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 14:16:54 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait , Krzysztof Kozlowski Subject: [PATCH v8 1/7] dt-bindings: iio: Add KX132-1211 accelerometer Date: Wed, 23 Aug 2023 23:16:35 +0200 Message-Id: <0d6051ad217f91c7de0883c4ca1516bdacc343ce.1692824815.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Extend the kionix,kx022a.yaml file to support the kx132-1211 device Acked-by: Krzysztof Kozlowski Acked-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- v8: v7: v6: v5: v4: v3: - no changes .../devicetree/bindings/iio/accel/kionix,kx022a.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml b/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml index 986df1a6ff0a..034b69614416 100644 --- a/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml +++ b/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml @@ -4,19 +4,21 @@ $id: http://devicetree.org/schemas/iio/accel/kionix,kx022a.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM/Kionix KX022A Accelerometer +title: ROHM/Kionix KX022A and KX132-1211 Accelerometers maintainers: - Matti Vaittinen description: | - KX022A is a 3-axis accelerometer supporting +/- 2G, 4G, 8G and 16G ranges, - output data-rates from 0.78Hz to 1600Hz and a hardware-fifo buffering. - KX022A can be accessed either via I2C or SPI. + 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. properties: compatible: - const: kionix,kx022a + enum: + - kionix,kx022a + - kionix,kx132-1211 reg: maxItems: 1 From patchwork Wed Aug 23 21:16:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 716250 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 2E6DCC88CB2 for ; Wed, 23 Aug 2023 21:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237373AbjHWVRb (ORCPT ); Wed, 23 Aug 2023 17:17:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237741AbjHWVRS (ORCPT ); Wed, 23 Aug 2023 17:17:18 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6366410DA; Wed, 23 Aug 2023 14:17:01 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fef3c3277bso30120425e9.1; Wed, 23 Aug 2023 14:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692825420; x=1693430220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qk+27VqlRqrj/ivAPFtnt5mYhJJ8mv21V/tphnroa0c=; b=eT+uzmtzQo167/cZpSk4pujI3G3HgH/Uw6ruSLWNGgV6wxndBv+DT1eiXjy6zp10in 7/x8g1UqAgIJuR9ftUEubvcc9QRNWukOKHGvht89eySQwWfA4nj39zpaWfNzRDvWSfEI LBTIo2tRXdQ60cyqboRb5VlP6AJKUqhur/EMjW32lgTZyxIxSQoyMECO7Rcdsw+l8PHl vr6lLfkQ4IK33JZ0sE4roHUPxodf2SB5hQN/dSl6AFJM11N6Ybdv8bDzqP6wgRa0YlUM AjuPzJ7dD8kn5Yx6+q0eOkyPwyh0spiSfnco6FkWph1yWBdDK+MpqXDxDgxlUVdR9Qcm 4FtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692825420; x=1693430220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qk+27VqlRqrj/ivAPFtnt5mYhJJ8mv21V/tphnroa0c=; b=gRlqa1BfKHnU5c9LdiuNrnlXFcMGmIp8dn1wEqobIzR5l6ifvYqJTBSyXhLZmBoTII KLSof/7VVK2ORKHmaDWF3EVys/oCmkazeXGiAGYLgvam2lPGJviGKcbafXZH2XDQzMzv c6+9+F1Sn7xGCAFelwdPLn/TUE1bnorwu1JyWXH2wMP70mZGoGF+XPZ9AJZgfIZBbue7 LOMljYiY22v/q4rl++SGiRd7oi1G8TKmHR/lJ0n/QJ81TpX9ba5YGdtyCO1xug309Pwo vCUAYo/j1hHOfzEa9hZWr9JGXSB0bBltL+KlKKT27P5J/OjtvO7dSFW2XuvLkLxMt9t/ cI7w== X-Gm-Message-State: AOJu0YyU2pYG6BOr7AaJY1rXypppqCCb0XrjlQAyLW7lTtwaL+XWcZWl wKZm/fFzIbcCHLhMJ+g3Y2k= X-Google-Smtp-Source: AGHT+IGeZLQumrD19cF7aY8h4mtOeYJZR/V6aKbSBafS7YbxJJODXiWob0SDFrvis9E8NMwIS//bbw== X-Received: by 2002:a1c:6a16:0:b0:3fb:ff57:1750 with SMTP id f22-20020a1c6a16000000b003fbff571750mr10763840wmc.32.1692825419785; Wed, 23 Aug 2023 14:16:59 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id p11-20020adfe60b000000b003176c6e87b1sm20193399wrm.81.2023.08.23.14.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 14:16:58 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait Subject: [PATCH v8 2/7] iio: accel: kionix-kx022a: Remove blank lines Date: Wed, 23 Aug 2023 23:16:36 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Remove blank lines pointed out by the checkpatch script Reviewed-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- v8: v7: v6: v5: v4: - no changes v3: - no changes, this patch is introduced in the v2 drivers/iio/accel/kionix-kx022a.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index f98393d74666..ff8aa7b9568e 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -341,7 +341,6 @@ static int kx022a_turn_on_off_unlocked(struct kx022a_data *data, bool on) dev_err(data->dev, "Turn %s fail %d\n", str_on_off(on), ret); return ret; - } static int kx022a_turn_off_lock(struct kx022a_data *data) @@ -1121,7 +1120,6 @@ int kx022a_probe_internal(struct device *dev) if (ret) return dev_err_probe(data->dev, ret, "Could not request IRQ\n"); - ret = devm_iio_trigger_register(dev, indio_trig); if (ret) return dev_err_probe(data->dev, ret, From patchwork Wed Aug 23 21:16:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 716249 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 6E2CBEE49A0 for ; Wed, 23 Aug 2023 21:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237410AbjHWVRc (ORCPT ); Wed, 23 Aug 2023 17:17:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237798AbjHWVRU (ORCPT ); Wed, 23 Aug 2023 17:17:20 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31C9F10DD; Wed, 23 Aug 2023 14:17:12 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-319e93a1594so5439313f8f.1; Wed, 23 Aug 2023 14:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692825430; x=1693430230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HqvTXQQxpEFsJU9721Xhtm+H9CSOKKaBAgAHD9Eag4c=; b=GDNZg2IdF2a1yMe3yxFxrH/93twg2DTUC6uif9LXW8axkuWGrCBmJJnMfl4w1yq1ZX rVDHizZzvVTpnmCo8LeGDESDUJq0F48DhIyev417cF4uw7A9+IUbzphfeVa6E4+t5nBM S9KdoW8OQ+fMQgeawXElp2K1IqvBlPB94x/91UfOILRiGAYeI4/r8Uu/lv/06O1cL6Uu 8nfQx/iN+JkKr1jpAem6Z1gSpD/NgXeS6E+xTtWYbfShr7nNmMaqc8OXtzKZsiuL56zw jvEon//BVXMXcLoYoW68mE0UY/EmpMGExpCg22cnCwwNgVxuja6mCZMonkDoC7RwU92t 0pmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692825430; x=1693430230; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HqvTXQQxpEFsJU9721Xhtm+H9CSOKKaBAgAHD9Eag4c=; b=ZrvJGsWCIjND0QdLJu67wwdZ+105BsCGD/aJPanvw7bFLJm8ZylY4LvBWfv2RZonBl x7apQLTuxq6ZcjM8KoFeXMQVmKLBiu93Gd+C1M7DVCIofCQWQjRknEsURg5+fvS8VXkM KLoir84B4cuFIv8X5tjWtVYPStgslDD+I/hW9Tk1xoFMZZ5PE9tEufWCLHtO4lWdeudH oqwYeL9ITXwajmodDDbZT916G9PEgMBFx1GSrnlj+PA3tP9jRvaSrlBtmJVf47Wyz14p AHYYMoSo/59Akb658Su9szxtCSXWEVTCWp/cTr4rHiskSf2cIwVrdnNaLs3pjBZcPID8 ZOCg== X-Gm-Message-State: AOJu0YyjMA6YG8Y2ESi+OcQoICypbwawt2dd1DvqPUW3ME0dO7J5z/Rb 8RnwpaOP2UpwSEKAXH+xF4k= X-Google-Smtp-Source: AGHT+IEddox/bkLvjz6heBTwdc99NNkJXFUpbFi4S2sAhzJJ0YW7W/qMMzBf29U4tQbEzzWF329SCg== X-Received: by 2002:adf:dc86:0:b0:317:3d6c:5b27 with SMTP id r6-20020adfdc86000000b003173d6c5b27mr10133611wrj.46.1692825430431; Wed, 23 Aug 2023 14:17:10 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id p11-20020adfe60b000000b003176c6e87b1sm20193399wrm.81.2023.08.23.14.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 14:17:09 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait Subject: [PATCH v8 4/7] iio: accel: kionix-kx022a: Add an i2c_device_id table Date: Wed, 23 Aug 2023 23:16:38 +0200 Message-Id: <9950e3963600465e1177a20ad8a93a3927c026ef.1692824815.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add the missing i2c device id. Acked-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- v8: v7: v6: v5: v4: - no changes v3: - no changes, this patch is introduced in the v2 drivers/iio/accel/kionix-kx022a-i2c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/accel/kionix-kx022a-i2c.c b/drivers/iio/accel/kionix-kx022a-i2c.c index e6fd02d931b6..b5a85ce3a891 100644 --- a/drivers/iio/accel/kionix-kx022a-i2c.c +++ b/drivers/iio/accel/kionix-kx022a-i2c.c @@ -30,6 +30,12 @@ static int kx022a_i2c_probe(struct i2c_client *i2c) return kx022a_probe_internal(dev); } +static const struct i2c_device_id kx022a_i2c_id[] = { + { .name = "kx022a" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, kx022a_i2c_id); + static const struct of_device_id kx022a_of_match[] = { { .compatible = "kionix,kx022a", }, { } @@ -42,6 +48,7 @@ static struct i2c_driver kx022a_i2c_driver = { .of_match_table = kx022a_of_match, }, .probe_new = kx022a_i2c_probe, + .id_table = kx022a_i2c_id, }; module_i2c_driver(kx022a_i2c_driver); From patchwork Wed Aug 23 21:16:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 716248 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 B15CCEE49AB for ; Wed, 23 Aug 2023 21:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237482AbjHWVRd (ORCPT ); Wed, 23 Aug 2023 17:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237851AbjHWVR0 (ORCPT ); Wed, 23 Aug 2023 17:17:26 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B8E510D9; Wed, 23 Aug 2023 14:17:24 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31781e15a0cso5320621f8f.3; Wed, 23 Aug 2023 14:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692825442; x=1693430242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WlUmPFC2XOjRsuc0M7D78GV/T6f00xWXWar2gA2I7w4=; b=FUfQvHPtpFpI0oZGE8JT+jc9npTK/I5T4y/HXQRT7WivCH91VSkETUgM28Ood0pU7S joI1SsOuwqJXK0DB49LfV+l1WcBm+WokIA0zO+H9LHwyXWb3omo+Jb4+SZlSLBGY5GbF RWfW2YqZeLO6qBnqjyy9mrlVV9D9J96WlsKQ4Vy0t4CgOaasgoA81T3QsjZWbhVY8XDA KIQIBdHm487WnQ1I3J11LObaXMcl2lEo5sk06tDL6CEksfHm/L2Rz/3sE9v/2LNkFcPw 3V2gIbTRIzvUi50gzl5yqIuK0qp1j+f5Vn+hyUAGsQLYZRoCk6EI4UJn/ko/zL3Kr6zw TMYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692825442; x=1693430242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WlUmPFC2XOjRsuc0M7D78GV/T6f00xWXWar2gA2I7w4=; b=Fb1ntWLOj/ZxzeI5wTdGWbirJETTUb3udY/vP0/3jmOpSAFPOUKAebd/RCpT42l7J8 OIYDVst7ne56bebA4rrv6bACLhsPoG0O1aqVvnaXW/pBiI+Lrp3grauEp55yxx36J80P rw9dwO3N25lOOjzBbRLXeW9VAM0IECiUwnN3aI27ofpZPiZN0VSgLoZXp/cES+/+7tm4 UgwDCWwkNIT/3P50gQAv61FwXBifVjlbkDAJYLTjALODKAbq1kstCXwiVX9aL0oFSiK9 DdMNekewDO4ryC6RjsT/98y3JbWtXghrRoaOZSwbjLY4gZg8MsBtLg9dPanUNNjyujMc cQ0w== X-Gm-Message-State: AOJu0YyBed4QnwfD77X+zNpjSZ2EgiWuLPQFzs7wQ6vUURpRcHdiTMiB Pn0RdX1qAgk4cAn7LG+6UqU= X-Google-Smtp-Source: AGHT+IEvbQCt5cER6S2Zqx7jah4+K2NLTAuuNVA3u3m07vyFjaGGWnGGOkJVOaKgyQEipvNjrlDfxg== X-Received: by 2002:adf:d08c:0:b0:31c:71fc:7bd6 with SMTP id y12-20020adfd08c000000b0031c71fc7bd6mr854748wrh.46.1692825442464; Wed, 23 Aug 2023 14:17:22 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id p11-20020adfe60b000000b003176c6e87b1sm20193399wrm.81.2023.08.23.14.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 14:17:21 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait Subject: [PATCH v8 7/7] iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer Date: Wed, 23 Aug 2023 23:16:41 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Kionix KX132-1211 is a tri-axis 16-bit accelerometer that can support ranges from ±2G to ±16G, digital output through I²C/SPI. Add support for basic accelerometer features such as reading acceleration via IIO using raw reads, triggered buffer (data-ready), or the WMI IRQ. Datasheet: https://kionixfs.azureedge.net/en/document/KX132-1211-Technical-Reference-Manual-Rev-5.0.pdf Acked-by: Matti Vaittinen Reviewed-by: Andy Shevchenko Signed-off-by: Mehdi Djait --- v8: - replaced min_t() by min() v7: - added a min_t in kx132_get_fifo_bytes to ensure that that the fifo_bytes is never bigger than the fifo_length * KX022A_FIFO_SAMPLES_SIZE_BYTES no matter what we read from I2C as suggested by Matti v6: - no changes v5: - moved the position of u16 buf_smp_lvl_mask as suggested by Andy - introduced buf_smp_lvl_mask in Patch 7 as suggested by Jonathan v4: - added KX132_REG_CNTL5 to the volatile ranges - added the kionix reserved regs to the read_only ranges - removed KX132_REG_MAN_WAKEUP from the write_only ranges v3: - fixed the warning of the kernel test robot in kx132_get_fifo_bytes (invalid assignment: &=, left side has type restricted __le16 right side has type unsigned short) v2: - mentioned the kx132-1211 in the Kconfig - added a kx132-specific get_fifo_bytes function - changed the device name from "kx132" to "kx132-1211 drivers/iio/accel/Kconfig | 8 +- drivers/iio/accel/kionix-kx022a-i2c.c | 2 + drivers/iio/accel/kionix-kx022a-spi.c | 2 + drivers/iio/accel/kionix-kx022a.c | 164 ++++++++++++++++++++++++++ drivers/iio/accel/kionix-kx022a.h | 54 +++++++++ 5 files changed, 226 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index b6b45d359f28..d8cc6e6f2bb9 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -418,8 +418,8 @@ config IIO_KX022A_SPI select IIO_KX022A select REGMAP_SPI help - Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to SPI interface. config IIO_KX022A_I2C tristate "Kionix KX022A tri-axis digital accelerometer I2C interface" @@ -427,8 +427,8 @@ config IIO_KX022A_I2C select IIO_KX022A select REGMAP_I2C help - Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to I2C interface. config KXSD9 tristate "Kionix KXSD9 Accelerometer Driver" diff --git a/drivers/iio/accel/kionix-kx022a-i2c.c b/drivers/iio/accel/kionix-kx022a-i2c.c index 006ffb51d3e6..286754dc5e97 100644 --- a/drivers/iio/accel/kionix-kx022a-i2c.c +++ b/drivers/iio/accel/kionix-kx022a-i2c.c @@ -42,12 +42,14 @@ 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 }, { } }; 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 }, { } }; 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 896b57866fc9..c7766492bcd9 100644 --- a/drivers/iio/accel/kionix-kx022a-spi.c +++ b/drivers/iio/accel/kionix-kx022a-spi.c @@ -37,12 +37,14 @@ 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 }, { } }; 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 }, { } }; MODULE_DEVICE_TABLE(of, kx022a_of_match); diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index 458859ebc645..b61a97325052 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -150,6 +150,117 @@ static const struct regmap_config kx022a_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +/* Regmap configs kx132 */ +static const struct regmap_range kx132_volatile_ranges[] = { + { + .range_min = KX132_REG_XADP_L, + .range_max = KX132_REG_COTR, + }, { + .range_min = KX132_REG_TSCP, + .range_max = KX132_REG_INT_REL, + }, { + /* The reset bit will be cleared by sensor */ + .range_min = KX132_REG_CNTL2, + .range_max = KX132_REG_CNTL2, + }, { + .range_min = KX132_REG_CNTL5, + .range_max = KX132_REG_CNTL5, + }, { + .range_min = KX132_REG_BUF_STATUS_1, + .range_max = KX132_REG_BUF_READ, + }, +}; + +static const struct regmap_access_table kx132_volatile_regs = { + .yes_ranges = &kx132_volatile_ranges[0], + .n_yes_ranges = ARRAY_SIZE(kx132_volatile_ranges), +}; + +static const struct regmap_range kx132_precious_ranges[] = { + { + .range_min = KX132_REG_INT_REL, + .range_max = KX132_REG_INT_REL, + }, +}; + +static const struct regmap_access_table kx132_precious_regs = { + .yes_ranges = &kx132_precious_ranges[0], + .n_yes_ranges = ARRAY_SIZE(kx132_precious_ranges), +}; + +static const struct regmap_range kx132_read_only_ranges[] = { + { + .range_min = KX132_REG_XADP_L, + .range_max = KX132_REG_INT_REL, + }, { + .range_min = KX132_REG_BUF_STATUS_1, + .range_max = KX132_REG_BUF_STATUS_2, + }, { + .range_min = KX132_REG_BUF_READ, + .range_max = KX132_REG_BUF_READ, + }, { + /* Kionix reserved registers: should not be written */ + .range_min = 0x28, + .range_max = 0x28, + }, { + .range_min = 0x35, + .range_max = 0x36, + }, { + .range_min = 0x3c, + .range_max = 0x48, + }, { + .range_min = 0x4e, + .range_max = 0x5c, + }, { + .range_min = 0x77, + .range_max = 0x7f, + }, +}; + +static const struct regmap_access_table kx132_ro_regs = { + .no_ranges = &kx132_read_only_ranges[0], + .n_no_ranges = ARRAY_SIZE(kx132_read_only_ranges), +}; + +static const struct regmap_range kx132_write_only_ranges[] = { + { + .range_min = KX132_REG_SELF_TEST, + .range_max = KX132_REG_SELF_TEST, + }, { + .range_min = KX132_REG_BUF_CLEAR, + .range_max = KX132_REG_BUF_CLEAR, + }, +}; + +static const struct regmap_access_table kx132_wo_regs = { + .no_ranges = &kx132_write_only_ranges[0], + .n_no_ranges = ARRAY_SIZE(kx132_write_only_ranges), +}; + +static const struct regmap_range kx132_noinc_read_ranges[] = { + { + .range_min = KX132_REG_BUF_READ, + .range_max = KX132_REG_BUF_READ, + }, +}; + +static const struct regmap_access_table kx132_nir_regs = { + .yes_ranges = &kx132_noinc_read_ranges[0], + .n_yes_ranges = ARRAY_SIZE(kx132_noinc_read_ranges), +}; + +static const struct regmap_config kx132_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .volatile_table = &kx132_volatile_regs, + .rd_table = &kx132_wo_regs, + .wr_table = &kx132_ro_regs, + .rd_noinc_table = &kx132_nir_regs, + .precious_table = &kx132_precious_regs, + .max_register = KX132_MAX_REGISTER, + .cache_type = REGCACHE_RBTREE, +}; + struct kx022a_data { struct regmap *regmap; const struct kx022a_chip_info *chip_info; @@ -239,6 +350,13 @@ static const struct iio_chan_spec kx022a_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3), }; +static const struct iio_chan_spec kx132_channels[] = { + KX022A_ACCEL_CHAN(X, KX132_REG_XOUT_L, 0), + KX022A_ACCEL_CHAN(Y, KX132_REG_YOUT_L, 1), + KX022A_ACCEL_CHAN(Z, KX132_REG_ZOUT_L, 2), + IIO_CHAN_SOFT_TIMESTAMP(3), +}; + /* * The sensor HW can support ODR up to 1600 Hz, which is beyond what most of the * Linux CPUs can handle without dropping samples. Also, the low power mode is @@ -612,6 +730,26 @@ static int kx022a_get_fifo_bytes(struct kx022a_data *data) return fifo_bytes; } +static int kx132_get_fifo_bytes(struct kx022a_data *data) +{ + __le16 buf_status; + int ret, fifo_bytes; + + ret = regmap_bulk_read(data->regmap, data->chip_info->buf_status1, + &buf_status, sizeof(buf_status)); + if (ret) { + dev_err(data->dev, "Error reading buffer status\n"); + return ret; + } + + fifo_bytes = le16_to_cpu(buf_status); + fifo_bytes &= data->chip_info->buf_smp_lvl_mask; + fifo_bytes = min((unsigned int)fifo_bytes, data->chip_info->fifo_length * + KX022A_FIFO_SAMPLES_SIZE_BYTES); + + return fifo_bytes; +} + static int __kx022a_fifo_flush(struct iio_dev *idev, unsigned int samples, bool irq) { @@ -1035,6 +1173,32 @@ const struct kx022a_chip_info kx022a_chip_info = { }; EXPORT_SYMBOL_NS_GPL(kx022a_chip_info, IIO_KX022A); +const struct kx022a_chip_info kx132_chip_info = { + .name = "kx132-1211", + .regmap_config = &kx132_regmap_config, + .channels = kx132_channels, + .num_channels = ARRAY_SIZE(kx132_channels), + .fifo_length = KX132_FIFO_LENGTH, + .who = KX132_REG_WHO, + .id = KX132_ID, + .cntl = KX132_REG_CNTL, + .cntl2 = KX132_REG_CNTL2, + .odcntl = KX132_REG_ODCNTL, + .buf_cntl1 = KX132_REG_BUF_CNTL1, + .buf_cntl2 = KX132_REG_BUF_CNTL2, + .buf_clear = KX132_REG_BUF_CLEAR, + .buf_status1 = KX132_REG_BUF_STATUS_1, + .buf_smp_lvl_mask = KX132_MASK_BUF_SMP_LVL, + .buf_read = KX132_REG_BUF_READ, + .inc1 = KX132_REG_INC1, + .inc4 = KX132_REG_INC4, + .inc5 = KX132_REG_INC5, + .inc6 = KX132_REG_INC6, + .xout_l = KX132_REG_XOUT_L, + .get_fifo_bytes = kx132_get_fifo_bytes, +}; +EXPORT_SYMBOL_NS_GPL(kx132_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 c9f9aee7e597..ea6202d29303 100644 --- a/drivers/iio/accel/kionix-kx022a.h +++ b/drivers/iio/accel/kionix-kx022a.h @@ -74,6 +74,57 @@ #define KX022A_REG_SELF_TEST 0x60 #define KX022A_MAX_REGISTER 0x60 +#define KX132_REG_WHO 0x13 +#define KX132_ID 0x3d + +#define KX132_FIFO_LENGTH 86 + +#define KX132_REG_CNTL 0x1b +#define KX132_REG_CNTL2 0x1c +#define KX132_REG_CNTL5 0x1f +#define KX132_MASK_RES BIT(6) +#define KX132_GSEL_2 0x0 +#define KX132_GSEL_4 BIT(3) +#define KX132_GSEL_8 BIT(4) +#define KX132_GSEL_16 GENMASK(4, 3) + +#define KX132_REG_INS2 0x17 +#define KX132_MASK_INS2_WMI BIT(5) + +#define KX132_REG_XADP_L 0x02 +#define KX132_REG_XOUT_L 0x08 +#define KX132_REG_YOUT_L 0x0a +#define KX132_REG_ZOUT_L 0x0c +#define KX132_REG_COTR 0x12 +#define KX132_REG_TSCP 0x14 +#define KX132_REG_INT_REL 0x1a + +#define KX132_REG_ODCNTL 0x21 + +#define KX132_REG_BTS_WUF_TH 0x4a + +#define KX132_REG_BUF_CNTL1 0x5e +#define KX132_REG_BUF_CNTL2 0x5f +#define KX132_REG_BUF_STATUS_1 0x60 +#define KX132_REG_BUF_STATUS_2 0x61 +#define KX132_MASK_BUF_SMP_LVL GENMASK(9, 0) +#define KX132_REG_BUF_CLEAR 0x62 +#define KX132_REG_BUF_READ 0x63 +#define KX132_ODR_SHIFT 3 +#define KX132_FIFO_MAX_WMI_TH 86 + +#define KX132_REG_INC1 0x22 +#define KX132_REG_INC5 0x26 +#define KX132_REG_INC6 0x27 +#define KX132_IPOL_LOW 0 +#define KX132_IPOL_HIGH KX022A_MASK_IPOL +#define KX132_ITYP_PULSE KX022A_MASK_ITYP + +#define KX132_REG_INC4 0x25 + +#define KX132_REG_SELF_TEST 0x5d +#define KX132_MAX_REGISTER 0x76 + struct device; struct kx022a_data; @@ -86,6 +137,7 @@ struct kx022a_data; * @channels: pointer to iio_chan_spec array * @num_channels: number of iio_chan_spec channels * @fifo_length: number of 16-bit samples in a full buffer + * @buf_smp_lvl_mask: buffer sample level mask * @who: WHO_AM_I register * @id: WHO_AM_I register value * @cntl: control register 1 @@ -109,6 +161,7 @@ struct kx022a_chip_info { const struct iio_chan_spec *channels; unsigned int num_channels; unsigned int fifo_length; + u16 buf_smp_lvl_mask; u8 who; u8 id; u8 cntl; @@ -130,5 +183,6 @@ struct kx022a_chip_info { int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chip_info); extern const struct kx022a_chip_info kx022a_chip_info; +extern const struct kx022a_chip_info kx132_chip_info; #endif