Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp528860ybh; Sat, 7 Mar 2020 04:12:44 -0800 (PST) X-Google-Smtp-Source: ADFU+vufsQrbdykIjaeijfZF0p29hZ4G+gmtBh1G+CxOh3zVFzp832NDZO8Fer7bucRP1lWvMcN6 X-Received: by 2002:aca:1a06:: with SMTP id a6mr5465126oia.148.1583583164262; Sat, 07 Mar 2020 04:12:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583583164; cv=none; d=google.com; s=arc-20160816; b=SKCkbL7CxJO0u8z+x2Sz1wOdvZBQHmy62+VUqb9IjQWijoPVfvAIKO8ph5dXqi76Bp +RmsPRqT/R3e37E9bxDA7wqvjqs9kJYnDZuIUPG49i8z8qIykLa/ZeOb9PJdk/aGb0oO kWfNSseE0g3iJVGp0NjmA0jUiZPfOGonpqpbKTn/v/0pD9Yi7+L7G+OT2VK8praARD0/ wuKsod0eGOiotMvHuqXoNYv3nWcBBgTKmiiJNLhZ/fRFp5dJfX2MKC+VKUVQrZx/4UiF sE/OleMPMLF+zOPd2gLc68Doc3/9ELtniSninlNr/bD8KDGtP2FojgvoeFZFh8H9LvAS ocNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=VuPF3l9ow9dZ+btSoftqgtCWKW9inIJziEc+WqduYDg=; b=PVL2xuyzUGLt4NY5w8QqaMzEGwxW/JZ01pnsww/DNgpTIGdSSi4BYnpRDNhq5ZSzOb 330InuG8xhNO8xWmYl8c9e3I21SfP+JtI9Q2+6NLcDoRqV426XVyAGjGqTwkhT2OnsSD Y1S4bCRDVEUIHQYCaSEO36a/f7wCagtIPhttQPCoaCiIKhOyl7fsz5oh6EBNJ9b1qoqx wSfrNMrQCdjQrWrpWea/2aooE0kYh04njkH2gZt3EaSk3xpkfUGHJb7zT2wgELigLABT KiPpS0KqdmV5CUY/J5XY+AXGMxBCwettKrFE/1Ymx/khPZdRUGfhWuIyG5btUYFNpUus jPgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mBerlUJI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l63si1189663oig.123.2020.03.07.04.12.32; Sat, 07 Mar 2020 04:12:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mBerlUJI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726168AbgCGMML (ORCPT + 99 others); Sat, 7 Mar 2020 07:12:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:53008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgCGMML (ORCPT ); Sat, 7 Mar 2020 07:12:11 -0500 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4E62206D5; Sat, 7 Mar 2020 12:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583583130; bh=P8N4UNcKSNSGMcRht8RlKDglPptQ3j1/8pnNFx0TVgE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mBerlUJISCnGRaiiA9XbYCDfLWqNhdnea1/0oLm4zKi6NqJK1C0jFQAywo/4CDGLp awlSHOdEcyeI1mIKgLIeXQ7ykavDyvSbGvk7O2zP8JK4mPbGqd2/dDUQj4RtqJx+SZ HpkXzKoxGK90efbbZRnl7WgDn1AuhbG3sqRJTHHs= Date: Sat, 7 Mar 2020 12:12:06 +0000 From: Jonathan Cameron To: Alexandru Tachici Cc: , Subject: Re: [PATCH v2 4/6] iio: accel: adxl372: add iio events Message-ID: <20200307121206.2d92521a@archlinux> In-Reply-To: <20200225120909.12629-5-alexandru.tachici@analog.com> References: <20200225120909.12629-1-alexandru.tachici@analog.com> <20200225120909.12629-5-alexandru.tachici@analog.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 25 Feb 2020 14:09:07 +0200 Alexandru Tachici wrote: > Set INT1 interrupts to fire when activity/inactivity > is detected by the device. On irq, push event code by calling > iio_push_event(). > > Signed-off-by: Alexandru Tachici > --- > drivers/iio/accel/adxl372.c | 37 +++++++++++++++++++++++++++++++++++-- > 1 file changed, 35 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c > index 775dc4f0aaf4..e669eaaaa07e 100644 > --- a/drivers/iio/accel/adxl372.c > +++ b/drivers/iio/accel/adxl372.c > @@ -114,6 +114,11 @@ > #define ADXL372_STATUS_1_AWAKE(x) (((x) >> 6) & 0x1) > #define ADXL372_STATUS_1_ERR_USR_REGS(x) (((x) >> 7) & 0x1) > > +/* ADXL372_STATUS_2 */ > +#define ADXL372_STATUS_2_INACT(x) (((x) >> 4) & 0x1) > +#define ADXL372_STATUS_2_ACT(x) (((x) >> 5) & 0x1) > +#define ADXL372_STATUS_2_AC2(x) (((x) >> 6) & 0x1) > + > /* ADXL372_INT1_MAP */ > #define ADXL372_INT1_MAP_DATA_RDY_MSK BIT(0) > #define ADXL372_INT1_MAP_DATA_RDY_MODE(x) (((x) & 0x1) << 0) > @@ -585,6 +590,27 @@ static int adxl372_get_status(struct adxl372_state *st, > return ret; > } > > +static void adxl372_push_event(struct iio_dev *indio_dev, s64 timestamp, > + u8 status2) > +{ > + unsigned int ev_dir; > + > + if (ADXL372_STATUS_2_ACT(status2)) > + ev_dir = IIO_EV_DIR_RISING; > + > + if (ADXL372_STATUS_2_INACT(status2)) > + ev_dir = IIO_EV_DIR_FALLING; > + > + if (ev_dir != IIO_EV_DIR_NONE) Unless I'm missing something we don't have an enable / disable control for this event. Can we add one? > + iio_push_event(indio_dev, > + IIO_MOD_EVENT_CODE(IIO_ACCEL, > + 0, > + IIO_MOD_X_OR_Y_OR_Z, > + IIO_EV_TYPE_THRESH, > + ev_dir), > + timestamp); > +} > + > static irqreturn_t adxl372_trigger_handler(int irq, void *p) > { > struct iio_poll_func *pf = p; > @@ -598,6 +624,8 @@ static irqreturn_t adxl372_trigger_handler(int irq, void *p) > if (ret < 0) > goto err; > > + adxl372_push_event(indio_dev, iio_get_time_ns(indio_dev), status2); > + > if (st->fifo_mode != ADXL372_FIFO_BYPASSED && > ADXL372_STATUS_1_FIFO_FULL(status1)) { > /* > @@ -989,7 +1017,10 @@ static int adxl372_buffer_postenable(struct iio_dev *indio_dev) > if (ret < 0) > return ret; > > - ret = adxl372_set_interrupts(st, ADXL372_INT1_MAP_FIFO_FULL_MSK, 0); > + mask = ADXL372_INT1_MAP_FIFO_FULL_MSK | > + ADXL372_INT1_MAP_ACT_MSK | > + ADXL372_INT1_MAP_INACT_MSK; > + ret = adxl372_set_interrupts(st, mask, 0); > if (ret < 0) > goto err; > > @@ -1067,7 +1098,9 @@ static int adxl372_dready_trig_set_state(struct iio_trigger *trig, > unsigned long int mask = 0; > > if (state) > - mask = ADXL372_INT1_MAP_FIFO_FULL_MSK; > + mask = ADXL372_INT1_MAP_FIFO_FULL_MSK | > + ADXL372_INT1_MAP_ACT_MSK | > + ADXL372_INT1_MAP_INACT_MSK; > > return adxl372_set_interrupts(st, mask, 0); > }