Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1280049rwd; Tue, 13 Jun 2023 07:13:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4TwQlx3CND2ikyaioc8kfy7b4X7XPX5sC4LO2LnP18+tGfJsytDpUt/Wn0EtcP9Cn8SnHW X-Received: by 2002:a17:907:948e:b0:982:416f:1963 with SMTP id dm14-20020a170907948e00b00982416f1963mr1148290ejc.39.1686665622307; Tue, 13 Jun 2023 07:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686665622; cv=none; d=google.com; s=arc-20160816; b=iQUwRc1PmYu696QTuPIUvOm3dU1k0BTKplRW7grozISCJPCLYEufNBn7cZoapUPwOj AeH6qxxZOaikR/dsQ9sCSXP/LlesbSxbSDyaTCx3JpQfkrVwIyM4PMd1HODNNDtwM3RF uIDbOWyujQEKz9uyy33jszQ+Cj+7xJiKu2EeuyTRqfGvLyjLKxnEhxKURH9bAbEHje2f AJVLe5S4PUZ1nZyJ5uh+r9lG0cBlp+aeOfglxWOawZr6jnA3WFej9e8khiYnq2OkuyOP REYx5ZzOjclbkOhOmhKsMWyTTNMbhaV45eUJNdYmoquB13TE0Jg32oEEJIt7s+adShcH r60g== 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=jHoqqmlDAGebBQdgXBrwxAnMk3s8uTXBmUHeS8OYD+8=; b=dBnbsc4/fTONu3inOBaJ32liYuXvtrF21hBTSLgcstOxUVwcBrbKSup5exDgOUAtvp H1nYqvJuSG5+2o70ahGiWIRaFy4taFfF7ekiJujUsYqwqv2jcogx3dOK6rlSGT9p4M/0 B/UY6lPWL8LP82pXhL7MdBwkPWtTForjtD7/oiFMc1En2tUs3Rc17aniNp8VNPdn7lc9 lKpNuSRjbDtiapAikfwonid3NPp6XBJ/xFuiRscKj7D0og2pCcWZHAw5M5DfTQ4AHDKo C9exf3qRQrRGg/0dLN/GNq0Gx9Z80pN5IOszUApzZN86/9sxggY0d5nW39ye9mGcXYj/ hvfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=hlzEi7s0; 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 fi9-20020a170906da0900b00977e93c57bbsi6925432ejb.1017.2023.06.13.07.13.10; Tue, 13 Jun 2023 07:13:42 -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=hlzEi7s0; 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 S242614AbjFMNuj (ORCPT + 99 others); Tue, 13 Jun 2023 09:50:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240515AbjFMNuc (ORCPT ); Tue, 13 Jun 2023 09:50:32 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C33DCD2; Tue, 13 Jun 2023 06:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1686664231; x=1718200231; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jHoqqmlDAGebBQdgXBrwxAnMk3s8uTXBmUHeS8OYD+8=; b=hlzEi7s0KaAZ1aU0lkTifwQ64n6LD3AxwcplCd0sSTVg1rhOOH3qqUqJ PN0k7Rv/ALawalRglBBZ4FG2kyH10GKzVerYFedZkt9mrdsajS9BJIUnC qRtnoFMKaYva/6TWU+VZYKvCWxBU/mIKyvnOZVyJr0RxyYUsnlLEyN7rh WsGGLg/D2wzlKurLJ59+yP3xinr+eGYu5C0OFgClk/Y4S5jH4ib6N5zAJ cihYjmcw7uRwiAZAEPaEACJjrfkCzvnxF+EaUBUR2gHlSvvRNCIn/Nojf SXEFh3/pWHZZuKiz9V0EWB62SbLHETRRzohfMuFCYAPMXhiMmlDk0rFQi A==; From: Astrid Rost To: Jonathan Cameron , Lars-Peter Clausen CC: , , , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Mathieu Othacehe , Astrid Rost Subject: [PATCH v6 1/8] iio: light: vcnl4000: Add proximity irq for vcnl4200 Date: Tue, 13 Jun 2023 15:50:17 +0200 Message-ID: <20230613135025.2596641-2-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230613135025.2596641-1-astrid.rost@axis.com> References: <20230613135025.2596641-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 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 56d3963d3d66..55a1952672a4 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,8 @@ 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 +1008,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 +1317,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 +1325,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