Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3036767rwd; Mon, 22 May 2023 07:51:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ44ZhVP+6//5nXW1edz7y2JUWrjDvTKqJCgOAY7AomsJk4prfKe1OcS8oW4x+Ly4iDYHfIe X-Received: by 2002:a17:90a:74cb:b0:24e:2e86:5465 with SMTP id p11-20020a17090a74cb00b0024e2e865465mr10242118pjl.31.1684767093068; Mon, 22 May 2023 07:51:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684767093; cv=none; d=google.com; s=arc-20160816; b=Pktc2sf/lDgx1pXDuQ9EFCOC4GWnDzyFC3r2cAX744wRfuor66qGORm+Ll9vZ59iLA Es4GD13Q1MHNR5yItdHUuIA59EeU2v0MIc8UM440emiSVXjvSqz3gL6u5E5gmLOtb8Qx lllZo5M30m9/fFv+qumZYWBHppiZZOff3KH43oqE/i4gsaOp3J7PU6DX4/0XG5Oa0Sba PBSMFox7rbaTUG0NDF5uJCs4KM/fRcyX+QoThvONRsbXKhIHbJDA3xxyKYa+NT3WPkXa rcQgvqtULBUdZ9MdSD298hNE4ZbZjtehge9Ghtw/MTv0zUrI9Td66hGp6XBXgkaUsHKa Lckg== 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=Zp9g6LGMcrNga0LDQCnxSABwd8l8hW09UrHEcEB+7N8=; b=t/wdvyBH3U2WowTC6rbCRHAHBkvQERY7qESlWDmNPkDe6leTicbV0JKGdEciB4Tn8X 2CIhBvokjQAGh9EC/Zu04YHEUM0rTV33qol3oa+ZnZkfqiJHImHdkUBLAhiQcMdW16Nd je2teR6q+dPvU8/ed9wcJ+y4E9VXn9RUf7EJbmwoxalFUBE6Qx6cBh2itspibCPLqUu1 EvMHQkXix+Enoy98noCdqFDX8ZzVa7Zeeoco5mKdqAuWtMSAtUweKX4BhcRwRzlkQyFB amUe2Q3GAx28FQK6ViRnQ54/+mwWgMnwcQOU1WWeJnsApAGEUknsh1ngy7B08GUcrH7/ hYlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=XoXlMLrH; 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 em9-20020a17090b014900b00252df576596si8604pjb.13.2023.05.22.07.51.19; Mon, 22 May 2023 07:51:33 -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=XoXlMLrH; 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 S233263AbjEVO0b (ORCPT + 99 others); Mon, 22 May 2023 10:26:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231695AbjEVO0a (ORCPT ); Mon, 22 May 2023 10:26:30 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A052A3; Mon, 22 May 2023 07:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1684765588; x=1716301588; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Zp9g6LGMcrNga0LDQCnxSABwd8l8hW09UrHEcEB+7N8=; b=XoXlMLrHRjm0jCyihZNJCDRGRDwDm3QuXQyO/pjTIGYuFolZSgwLjT9W BtZuHTQ31zTsNzp4vCvoP+RVVJiKqpIfUZgltv0rYdVOUhv+EYEICd/o3 9L0hhmtMIRowjlOiNzAXpK+7RldJFaTB1oxIJXhqaThUFsoqq7y3sQsCW RV+5hABc/Yyfwn9QxYLhNNql37KmW5daSEBP7t/tBvJzPGDcxl8pOpw3z yvAlura1Bkmb8231q5hjlBPSj4ieTvsGIkNbm2n6l/zK1J7HU9zKiFSJI TxrfX2YS9rLCG0Tc2Rka9SLj/DB9aCpxdgdvnwUS8RCtrAiqBV+w/Ua5S Q==; From: Astrid Rost To: Jonathan Cameron , Lars-Peter Clausen CC: , , , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Mathieu Othacehe , Astrid Rost Subject: [PATCH v4 1/7] iio: light: vcnl4000: Add proximity irq for vcnl4200 Date: Mon, 22 May 2023 16:26:15 +0200 Message-ID: <20230522142621.1680563-2-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230522142621.1680563-1-astrid.rost@axis.com> References: <20230522142621.1680563-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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 56d3963d3d66..565b9c9ea470 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 */ @@ -164,6 +165,7 @@ struct vcnl4000_chip_spec { int (*set_power_state)(struct vcnl4000_data *data, bool on); irqreturn_t (*irq_thread)(int irq, void *priv); irqreturn_t (*trig_buffer_func)(int irq, void *priv); + u8 int_reg; }; static const struct i2c_device_id vcnl4000_id[] = { @@ -1005,7 +1007,7 @@ static irqreturn_t vcnl4040_irq_thread(int irq, void *p) struct vcnl4000_data *data = iio_priv(indio_dev); int ret; - ret = i2c_smbus_read_word_data(data->client, VCNL4040_INT_FLAGS); + ret = i2c_smbus_read_word_data(data->client, data->chip_spec->int_reg); if (ret < 0) return IRQ_HANDLED; @@ -1314,6 +1316,7 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { .num_channels = ARRAY_SIZE(vcnl4040_channels), .info = &vcnl4040_info, .irq_thread = vcnl4040_irq_thread, + .int_reg = VCNL4040_INT_FLAGS, }, [VCNL4200] = { .prod = "VCNL4200", @@ -1321,9 +1324,11 @@ 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, + .int_reg = VCNL4200_INT_FLAGS, }, }; -- 2.30.2