Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5841062rwr; Tue, 9 May 2023 07:03:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7p5WvNFJHE7XNbSIGq0hWzdEbTxJ0vD8jMOoQW2i/My/CyHXH5QPGmJVIt1xadSOviB+qa X-Received: by 2002:a92:cc4c:0:b0:335:4c33:dd25 with SMTP id t12-20020a92cc4c000000b003354c33dd25mr5433186ilq.23.1683641001574; Tue, 09 May 2023 07:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683641001; cv=none; d=google.com; s=arc-20160816; b=n4vNlGkKGKMWs8b2VLv0h90vYnLrNWSOYAcbwdGYH/N2hwC6lLTFjNj1uNiL/AiQD/ ZypZpX2ggRCqRsxnS4gl159mZMx+o6r+TyrhgHTTtbMbqKNFOETjpKbVc5Yl4H5/kK84 VhcQ5Z0vfkwYWHaSkLp2qYXJMbHej2FeQSoS41uKdtFX4si8Qzyk1LyoPQOjXecTVp+5 DWZFRIMi6gq6H2eDV5cJJ3uTHLIY3YaBdPDR91pS6aPS/gyHV6lsZTezsUX2W1asbzv9 N2gLh1XQI6oIgY4lJx0qvYIK81MkuoC0Vfo2f6tDom5i3i9burNZXSYF0QF/MwPMqssF IyNA== 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=yaf0YJqWFoOVvklPuwa7Iqo8kFo4TON25B32QtfDPAxywEz6iT4Zedwm2BjfHXoQf3 ePrHclWobRx0p9pVxY+qq446IcP/X6BC9XnfAVhFt7cZ2xOHfSsR1IdnJA6Epab1mZWx Vy3xSZvnLSkLzime0uilfK1H7bwHcbKG29SYRjJSs8Gok9zyNYCkD1+w4NdnMZ4gsElV Ir6A8kovXNk0xIm3KOr12DmEk2R0H8tiGdwfSs2OEsKc/1YZDRMxSQG7O+KTrd6xGdlz egIUxzMIvxRHC7ZQ42WQuAUfxxxJoDBdFqNt2lxNnMFMgxxtBrQnjPJN5DcR6cX0i/mN B8Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=cnx4hZNk; 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 p16-20020a92c110000000b0032cc38e1512si6343134ile.132.2023.05.09.07.03.06; Tue, 09 May 2023 07:03:21 -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=cnx4hZNk; 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 S235686AbjEIOCL (ORCPT + 99 others); Tue, 9 May 2023 10:02:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbjEIOCJ (ORCPT ); Tue, 9 May 2023 10:02:09 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50CDA30E8; Tue, 9 May 2023 07:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1683640919; x=1715176919; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2V+NUhnYRzHcs/qPV372ooVdqlg/MRqyc6ldidCg9bY=; b=cnx4hZNk3RLw+BNyLhSOE8tqUSVh/j/WkCDZdqZjsxr3rmbCGd+cXg4W iDvgZFZJX5K8bIAFniiwUX9Tf+bQhLpMgHVZxB+DAzCGi41tntoFgWtrc KH23HCEF3pIJRNoEHNk7uTrwpCKxYuwx3zE0QfeL3yq5n9/VMp62nYL5q hABKss+YF2eXu3NXfy4i37MlHx/NU7ul3j3ZNrM6K6H6FDZ7JxCoHBfvW YzfUOT6R87I67L2glh5DWMh/hfYFuZUdbRU8qHUuIeXL97+hcYbMLq8xu y0NJ7lUJytIi3Sx9l0vQrn+3VGuPz4CO91QqARa+4CT8w05PlHkEhVCef Q==; From: Astrid Rost To: Jonathan Cameron , Lars-Peter Clausen CC: , , , Astrid Rost Subject: [PATCH v2 1/7] iio: light: vcnl4000: Add proximity irq for vcnl4200 Date: Tue, 9 May 2023 16:01:47 +0200 Message-ID: <20230509140153.3279288-2-astrid.rost@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230509140153.3279288-1-astrid.rost@axis.com> References: <20230509140153.3279288-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 | 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