From patchwork Sun Mar 28 03:36:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwendal Grignou X-Patchwork-Id: 12168803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AC40C433E1 for ; Sun, 28 Mar 2021 03:38:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37B5A6197E for ; Sun, 28 Mar 2021 03:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230451AbhC1DhY (ORCPT ); Sat, 27 Mar 2021 23:37:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230470AbhC1Dgs (ORCPT ); Sat, 27 Mar 2021 23:36:48 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53493C0613B1 for ; Sat, 27 Mar 2021 20:36:48 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id m7so7215149pgj.8 for ; Sat, 27 Mar 2021 20:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YLO2XQIJs0BFINTqxacgVlSm3fGm5XvtqH/HUSlWzB8=; b=AznN/mLi9KYh42xAbSKgETGsGDLN14ZRd8rByffzefFb2TLbVn4WSB9yAwzL6Aip3n EuJzLpL+ZXTwyPV78Y74AHaxfNy81eDPJwJLAqr2BiZEAZ3u11n1jNgS37fNb70ERGg5 +fYnx5rVEqVpMf5HQDkWw0nWDoqZPYI6r12A4= 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:mime-version:content-transfer-encoding; bh=YLO2XQIJs0BFINTqxacgVlSm3fGm5XvtqH/HUSlWzB8=; b=f/wV0zvEI4fMM2f+x83Va9F2n7NTayHIjZtZZTtQ7FSmmQf2oPQoAbuwuaP7B8/vfn eiytvp6DZXe9mLnuShsEHN9yvtHx3L6eWS+oR8gznPytv+QVhhqYXYwn58V8zBvmOKVH M7VIDV09ON2K409K9J+n/mX1fm79T+Hd+CiAkAULyUIkLen6icUJecKO9AzGvZwAP8+S RYtqfoqIb+BBOGJdo3ewi0cNlXOdeR1zYO6I6pYt+AETonuGMGiH/GcQfAVXMKVNp51W SquOEpppcn/gphCi0Mmml4p/B5K+5PzcEPaQlzUr05Y0n9W9Zuz86nQ5JZbKCcg77ooJ Ss+Q== X-Gm-Message-State: AOAM531tczg/s8Pm1Q+cP8HBbJOTOuHzBSBRpod/c3Nd3knKUeJIUopl /CTNipAoUoCuELXYoC89eXjv4A== X-Google-Smtp-Source: ABdhPJyrZaFQPv51zD6UQhboi/sZZtgxy6MgA/kxKO0gUws0npIT84CLCO/o+HV/WMlkKX/BuHikrQ== X-Received: by 2002:a63:f212:: with SMTP id v18mr16605363pgh.343.1616902607910; Sat, 27 Mar 2021 20:36:47 -0700 (PDT) Received: from localhost ([2620:15c:202:201:5993:d227:a897:4c2a]) by smtp.gmail.com with UTF8SMTPSA id g10sm12573048pgh.36.2021.03.27.20.36.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Mar 2021 20:36:47 -0700 (PDT) From: Gwendal Grignou To: jic23@kernel.org, lars@metafoo.de, swboyd@chromium.org, campello@chromium.org, andy.shevchenko@gmail.com, ardeleanalex@gmail.com Cc: linux-iio@vger.kernel.org, Gwendal Grignou Subject: [PATCH 1/2] dt-bindings: iio: sx9310: Add close/far debouncer strength Date: Sat, 27 Mar 2021 20:36:38 -0700 Message-Id: <20210328033639.1021599-2-gwendal@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210328033639.1021599-1-gwendal@chromium.org> References: <20210328033639.1021599-1-gwendal@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Debouncer are used to prevent false positive: only when N measurement are above/below the far/close threshold an event is sent to the host. Define 2 new entries: a close and far debouncer. Signed-off-by: Gwendal Grignou --- .../bindings/iio/proximity/semtech,sx9310.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml index ccfb163f3d341..f2656f87e2c44 100644 --- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml @@ -97,6 +97,24 @@ properties: UINT_MAX (4294967295) represents infinite. Other values represent 1-1/N. + semtech,close-debouncer-depth: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 2, 4, 8] + default: 0 + description: + Number of samples need to trigger a transition from far to close event. + 0 disables the debouncer, N is the number of samples needed under the + proximity threshold to trigger an event. + + semtech,far-debouncer-depth: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 2, 4, 8] + default: 0 + description: + Number of samples need to trigger a transition from close to far event. + 0 disables the debouncer, N is the number of samples needed above the + proximity threshold to trigger an event. + required: - compatible - reg From patchwork Sun Mar 28 03:36:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwendal Grignou X-Patchwork-Id: 12168801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57EE3C433E0 for ; Sun, 28 Mar 2021 03:38:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 269EC619A0 for ; Sun, 28 Mar 2021 03:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230470AbhC1DhZ (ORCPT ); Sat, 27 Mar 2021 23:37:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230512AbhC1Dgu (ORCPT ); Sat, 27 Mar 2021 23:36:50 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06D7FC0613B1 for ; Sat, 27 Mar 2021 20:36:50 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id r17so7263381pgi.0 for ; Sat, 27 Mar 2021 20:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j9qFxmM7PC3HjqXfTJfN+OFOhIINqBJVEYzQMAqXcGA=; b=M8EhQfC4W6FHV3cDWap/DkH8n5aAmlpmNhyYhEzvvYfkdO5nEhZclvVTKiuveLvw9I cbL9bK0zAvsuu//aTsisUri1xAMSr3pVO1hWTbzeHjZNYlKM0ZpJ08/h5DeFepnZbmfs Of6huu2I/NV+k0Cczzp5vdOXqpejA65rq+T/o= 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:mime-version:content-transfer-encoding; bh=j9qFxmM7PC3HjqXfTJfN+OFOhIINqBJVEYzQMAqXcGA=; b=VuWnGAUEm638Hcl2pz8QCgBPO0Cfkj6FjGtza/6dV1AEPZkAZLT8J4jpxCJa1Ur3U2 FmAkIfcdZvZoD0D9+AWGNf3CxlZIdwxDEEEZgReWxNICuIzNIF1yGfWHADcoJvFKQ3tr u2ys7rJsG5GVu6fN1yPr5hETmJFCHTWQJyYeYc8R8+mWZJzfhbBEJmNGAGlwTI+ol7ad xmCINItft7alXWHVlu+DtfOiYS7MhFsn4v8o2ko1t/I2KiDgEJ6ggDS8+7hZKHFfecqP QKSVbYx1yDHTYQxxaIHhw86NlaULUb9BzYPTpkG4kY12CpP9Wf6buLyXY/LabrF2EcAY xF4Q== X-Gm-Message-State: AOAM533RW4Uqvve8Bgnx02nSEG+EzvIrBb5Ezb+yRo+jckVYsoQPxKFC TqPn5c4yY6MfSOkJdk9RgYF11Q== X-Google-Smtp-Source: ABdhPJxIkOWp9AM1cU0EfkTNpxya9df7+547JU6zFQwHIByCqf4G4WHXu0LnEVyuNvOCOHBp2PaAOQ== X-Received: by 2002:aa7:980a:0:b029:20c:5402:5de9 with SMTP id e10-20020aa7980a0000b029020c54025de9mr19769635pfl.18.1616902609590; Sat, 27 Mar 2021 20:36:49 -0700 (PDT) Received: from localhost ([2620:15c:202:201:5993:d227:a897:4c2a]) by smtp.gmail.com with UTF8SMTPSA id u9sm13075121pgc.59.2021.03.27.20.36.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Mar 2021 20:36:49 -0700 (PDT) From: Gwendal Grignou To: jic23@kernel.org, lars@metafoo.de, swboyd@chromium.org, campello@chromium.org, andy.shevchenko@gmail.com, ardeleanalex@gmail.com Cc: linux-iio@vger.kernel.org, Gwendal Grignou Subject: [PATCH 2/2] iio: sx9310: Add debouncer-depth parameters Date: Sat, 27 Mar 2021 20:36:39 -0700 Message-Id: <20210328033639.1021599-3-gwendal@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210328033639.1021599-1-gwendal@chromium.org> References: <20210328033639.1021599-1-gwendal@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Semtech SX9310 SAR sensor has a debouncer filter: only when N measurements are above/below the far/close threshold an event is sent to the host. By default the debouncer is set to 2 events for the close to far transition and 1 event (no debounce) for far to close. It is a balance speed of detection and false positive avoidance. On some chromebooks, the debouncer is set to a larger number. Signed-off-by: Gwendal Grignou --- drivers/iio/proximity/sx9310.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 1ed749190bff9..6f92cf18fac31 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -1219,8 +1219,8 @@ static const struct sx9310_reg_default * sx9310_get_default_reg(struct device *dev, int idx, struct sx9310_reg_default *reg_def) { + u32 start = 0, raw = 0, pos = 0, depth = 0; u32 combined[SX9310_NUM_CHANNELS]; - u32 start = 0, raw = 0, pos = 0; unsigned long comb_mask = 0; int ret, i, count; const char *res; @@ -1325,6 +1325,25 @@ sx9310_get_default_reg(struct device *dev, int idx, reg_def->def |= FIELD_PREP(SX9310_REG_PROX_CTRL7_AVGPOSFILT_MASK, pos); break; + case SX9310_REG_PROX_CTRL10: + ret = device_property_read_u32(dev, "semtech,close-debouncer-depth", &depth); + if (ret) + raw = FIELD_GET(SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK, + reg_def->def); + else + raw = ilog2(depth); + reg_def->def &= ~SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK; + reg_def->def |= FIELD_PREP(SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK, raw); + + ret = device_property_read_u32(dev, "semtech,far-debouncer-depth", &depth); + if (ret) + raw = FIELD_GET(SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK, + reg_def->def); + else + raw = ilog2(depth); + reg_def->def &= ~SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK; + reg_def->def |= FIELD_PREP(SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK, raw); + break; } return reg_def;