Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3970841rwr; Mon, 8 May 2023 00:23:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ59x3N+wBBeuvd/s4SadYBmol1GGxENcObb0jx4/DgKQtmriRgZoYSiKz6vu5FHysKlDW1p X-Received: by 2002:a17:90a:9483:b0:24d:f3f5:4d2e with SMTP id s3-20020a17090a948300b0024df3f54d2emr9690520pjo.10.1683530620982; Mon, 08 May 2023 00:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683530620; cv=none; d=google.com; s=arc-20160816; b=tEfgABj1XiFHx5qHGS96vyI791lw6znqQmO88RQJb0CmEHJh9b3MCEVs3Sh84A990k xevXUUpfb/sl1op2l1pztGm62C2fXyO4aVf+Kr95Fg/fsojGpyWuH8eUAxYMc56AfhUT LInnQTwWyDi7rdC2RlPY42E5AWiuCuqg30Y6uWIeUoHw6Okg1PAQjQjqexxQcxxJLj85 tVL6vA2GMoF2UagPmBVT4BBHjZvxpgKVriUk6LOvUEtwjgfR5MCiSeoVMnevRpM1rItY XZX8VQLMokCotiLXGzp+yDHskb7eeBFVWIQid1GSTTHetAYyVXIAlvwooGFk5uhUlfkE BAjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2V+NUhnYRzHcs/qPV372ooVdqlg/MRqyc6ldidCg9bY=; b=jOlS9IzDSsqcuiafqgmXDgpsEoNuDxQA7xfReRpIESThgERDTsdFmFSvErRiewe74F /Y62pMrEQyMpaEdqZyV7qzN50C3ml/CarUnPfSS0QMtYw0mq5JafNjxLdDYrH+m35rmi c4byyufppaQ0n+g8tlP3Srxsnz4msEJDmJA4pwldM8WaqFb8ls3oS2Ta9ITva3tmIrw6 fmeeCzfz0LZRX+BNGvj1CMYjRtnj+WTHxxMit1yuZZj8M1ssUaovHGmbxB6YjXaDaEAm 3u9Y/AuXc7yOaY5mq2V6SZFdxlFuW7rXXMWjy/7hOeQ8N/tgfV/t76kBSKoIsm2uf1Wk 7Pgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=DIZct6nc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a17090ad25300b0023d22d0f0fdsi12326098pjw.19.2023.05.08.00.23.29; Mon, 08 May 2023 00:23:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=DIZct6nc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233300AbjEHHKR (ORCPT + 99 others); Mon, 8 May 2023 03:10:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233428AbjEHHJ5 (ORCPT ); Mon, 8 May 2023 03:09:57 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 262601AEF4; Mon, 8 May 2023 00:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1683529781; x=1715065781; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2V+NUhnYRzHcs/qPV372ooVdqlg/MRqyc6ldidCg9bY=; b=DIZct6ncsTbjR4096+pVaYccmSB9epzRem86o3mB2lJTEHhNWiK4dJQL r42DLb/tRgRntj/24e/cR8/gP95JuKyzZWW4Y0HmiriAwkjX27iX+IFvd WnLe9nCeGrWLuhZbJFN2whTcj3yIDDdK5jQbH7X9cdMIWZcIgG3rpw+aJ eyNa2HH00SN9yQ73z6bbnWwRHiy7Ei5asQcpMX1753qbkvbCAaVDKh/JJ jU0XV54SdkVo4hH5BfN2bpZYIcXPb/vfIoCeyt/ONx5uETqZSmCcUAEpy +FeVA8OUSavXWtz22oEChsrns8yFFNShsGk0sTmcVi9SC4FQg9yAvZsqb g==; From: Astrid Rost To: Jonathan Cameron CC: , Astrid Rost , Astrid Rost , Lars-Peter Clausen , , Subject: [PATCH v1 1/7] iio: light: vcnl4000: Add proximity irq for vcnl4200 Date: Mon, 8 May 2023 09:09:19 +0200 Message-ID: <20230508070925.2123265-2-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230508070925.2123265-1-astrid.rost@axis.com> References: <20230508070925.2123265-1-astrid.rost@axis.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add proximity interrupt support for vcnl4200 (similar to vcnl4040). Add support to configure proximity sensor interrupts and threshold limits. If an interrupt is detected an event will be pushed to the event interface. Signed-off-by: Astrid Rost --- drivers/iio/light/vcnl4000.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 56d3963d3d66..13568454baff 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -65,6 +65,7 @@ #define VCNL4200_PS_DATA 0x08 /* Proximity data */ #define VCNL4200_AL_DATA 0x09 /* Ambient light data */ #define VCNL4040_INT_FLAGS 0x0b /* Interrupt register */ +#define VCNL4200_INT_FLAGS 0x0d /* Interrupt register */ #define VCNL4200_DEV_ID 0x0e /* Device ID, slave address and version */ #define VCNL4040_DEV_ID 0x0c /* Device ID and version */ @@ -1004,8 +1005,14 @@ static irqreturn_t vcnl4040_irq_thread(int irq, void *p) struct iio_dev *indio_dev = p; struct vcnl4000_data *data = iio_priv(indio_dev); int ret; + int reg; - ret = i2c_smbus_read_word_data(data->client, VCNL4040_INT_FLAGS); + if (data->id == VCNL4200) + reg = VCNL4200_INT_FLAGS; + else + reg = VCNL4040_INT_FLAGS; + + ret = i2c_smbus_read_word_data(data->client, reg); if (ret < 0) return IRQ_HANDLED; @@ -1321,9 +1328,10 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .measure_light = vcnl4200_measure_light, .measure_proximity = vcnl4200_measure_proximity, .set_power_state = vcnl4200_set_power_state, - .channels = vcnl4000_channels, + .channels = vcnl4040_channels, .num_channels = ARRAY_SIZE(vcnl4000_channels), - .info = &vcnl4000_info, + .info = &vcnl4040_info, + .irq_thread = vcnl4040_irq_thread, }, }; -- 2.30.2