Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4595682rwd; Tue, 30 May 2023 07:30:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74eXG6Hixr4UG7nvbm/yJiP5QNPULW5br603DzY2oFejZmUjGW9EeU8OhK624OIprQJ+Bz X-Received: by 2002:a17:90a:15c2:b0:253:572f:79ae with SMTP id w2-20020a17090a15c200b00253572f79aemr2791224pjd.46.1685457002115; Tue, 30 May 2023 07:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685457002; cv=none; d=google.com; s=arc-20160816; b=DlCAQ2YJFtBqnV8QlMTKCUPRofMpJMvMkCWmkPwJAdEAjO5hTI1WV8O9Q9TjygyymJ sayU82DofD22ZNSN4kbqB0EflSU5ndjOY2S0rlcnVUbx6Inzdd0wZWqqcLiwwxWWGTvG vKChpa4HEWOKpm7Fz0p52SlbLlbVUzMfRYuVt8p9N89Er+qTwSUT+GP1OmxzPpK1MeB+ K7GRouW4B1kBVocNe3UgHB0hyVqXfo7yOm2MOH9pjtggzXTk+DmZus7st/4bule0oW7v cvCJ1K5CsXzg5sulrcYhbwXcacTZgFcO3wB/33XUNv4FnXNWyCDg7+c1y2kE/EbCd/0n 7PjQ== 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=c2EQctN7PDcEypwIqEfihbUvLwreorvHr6Wq3BYJmbr9SluO/uCzw+ihJIt9aSLSkX tXFUTfC6B2EIhA9/7tp6Et2y/a3Gt/VI1y5pzGqF1OYtpwFUSj1Er8Xia6a7YMkIpFMG ylQEleBaBtUhPzLIiv4lTYutMD4HjRH1IrRPOCoAkJJNV/FNC6DUNhXNV7c/ubIZ9+c0 8fokC6kj8X8As+nAZ2MrDATTht4JwI3nVKkoPKiRMJJjPGEqASiESkuLjKfnQpSoIJcX ZVKm7Z5JxtV8Vu/GU8/FeL2bAiWk8nHIPoHjRIYc/T+LeblVN5shV/EzWmCTgjt/PeF+ QxbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=E95LMJ9t; 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 h25-20020a633859000000b0053b88e08e85si11047161pgn.242.2023.05.30.07.29.46; Tue, 30 May 2023 07:30:02 -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=E95LMJ9t; 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 S232176AbjE3O0J (ORCPT + 99 others); Tue, 30 May 2023 10:26:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232134AbjE3OZk (ORCPT ); Tue, 30 May 2023 10:25:40 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F2F410D2; Tue, 30 May 2023 07:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1685456686; x=1716992686; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Zp9g6LGMcrNga0LDQCnxSABwd8l8hW09UrHEcEB+7N8=; b=E95LMJ9tVkjQKRrN3edu1tOQs2C11JGynPv2yN7RgKkeBqapSesL7Sab K0fAozlGupN7S2Kxf9UlHxqIXSqJe2bre7CzUoZJvEp2Mpx1nAu9KZTJZ WU2PfNdSi6e7rTM2WVk4s13KyKp/8bPsy8g9lwCrMTIskMzs8aGbC6ad4 tCpCY8ejRGfP4G44EX6Ua2aLZ6kXBiQ09FhzZzDllBpKDgnGW+X1rBtb6 3SQdP4Sns/Ipw8PH7tRjBkNpoE17GOmTug3Gp6NXh+E4tHd8x6sswhGli SNcs9H8iDpmAsStayubjLWNhCO+Hh0FukxnhH0xOF7vMjjG5Io0TBoOO2 w==; From: Astrid Rost To: Jonathan Cameron , Lars-Peter Clausen CC: , , , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Mathieu Othacehe , Astrid Rost Subject: [PATCH v5 1/7] iio: light: vcnl4000: Add proximity irq for vcnl4200 Date: Tue, 30 May 2023 16:23:59 +0200 Message-ID: <20230530142405.1679146-2-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230530142405.1679146-1-astrid.rost@axis.com> References: <20230530142405.1679146-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,URIBL_BLOCKED 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