mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Rupesh Majhi <zoone.rupert@gmail.com>
Cc: "Andy Shevchenko" <andy@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Eddie James" <eajames@linux.ibm.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Nuno Sá" <nuno.sa@analog.com>, "Rob Herring" <robh@kernel.org>,
	devicetree@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Paulius Zaleckas" <paulius.zaleckas@gmail.com>
Subject: Re: [PATCH 2/2] iio: pressure: dps310: add a data-ready trigger
Date: Tue, 10 Nov 2026 18:48:16 +0200	[thread overview]
Message-ID: <avNK0EldiZVxrhE8@ashevche-desk.local> (raw)
In-Reply-To: <20261110154254.39092-3-zoone.rupert@gmail.com>

On Tue, Nov 10, 2026 at 05:42:54PM +0200, Rupesh Majhi wrote:
> With an interrupt wired to SDO, the chip can signal each new pressure
> result. Expose it as a trigger, so captures follow the measurements and
> scans carry the time the result was ready, not when the handler ran.
> 
> Polarity follows the interrupt type. Status latches while the interrupt
> is disabled, so it is cleared before enabling. The trigger is not the
> default, so FIFO mode without a trigger is unchanged.

...

> +static int dps310_trigger_set_state(struct iio_trigger *trig, bool state)
> +{
> +	struct dps310_data *data = iio_trigger_get_drvdata(trig);

	struct regmap *map = data->regmap;

> +	unsigned int status;
> +	int rc;
> +
> +	guard(mutex)(&data->lock);
> +
> +	/* Status latched while disabled would fire a stale interrupt */
> +	if (state) {
> +		rc = regmap_read(data->regmap, DPS310_INT_STS, &status);

(as per below)

> +		if (rc)
> +			return rc;
> +	}
> +
> +	return regmap_assign_bits(data->regmap, DPS310_CFG_REG, DPS310_INT_PRS,
> +				  state);

	return regmap_assign_bits(map, DPS310_CFG_REG, DPS310_INT_PRS, state);

> +}

...

> +static int dps310_trigger_probe(struct dps310_data *data)
> +{
> +	struct device *dev = &data->client->dev;

	struct regmap *map = data->regmap;

> +	struct iio_dev *iio = data->iio;
> +	int irq = data->client->irq;
> +	bool active_high;
> +	int rc;
> +
> +	switch (irq_get_trigger_type(irq)) {
> +	case IRQ_TYPE_LEVEL_HIGH:
> +	case IRQ_TYPE_EDGE_RISING:
> +		active_high = true;
> +		break;
> +	case IRQ_TYPE_LEVEL_LOW:
> +	case IRQ_TYPE_EDGE_FALLING:
> +		active_high = false;
> +		break;
> +	default:
> +		return dev_err_probe(dev, -EINVAL, "Unsupported interrupt type\n");
> +	}

> +	rc = regmap_assign_bits(data->regmap, DPS310_CFG_REG, DPS310_INT_HL,
> +				active_high);

	rc = regmap_assign_bits(map, DPS310_CFG_REG, DPS310_INT_HL, active_high);

> +	if (rc)
> +		return rc;
> +
> +	data->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", iio->name,
> +					    iio_device_id(iio));
> +	if (!data->trig)
> +		return -ENOMEM;
> +
> +	data->trig->ops = &dps310_trigger_ops;
> +	iio_trigger_set_drvdata(data->trig, data);
> +
> +	rc = devm_request_threaded_irq(dev, irq, dps310_irq_handler,
> +				       dps310_irq_thread, IRQF_ONESHOT,
> +				       iio->name, data);
> +	if (rc)
> +		return rc;
> +
> +	return devm_iio_trigger_register(dev, data->trig);
> +}

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2026-11-10 16:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 15:42 [PATCH 0/2] iio: pressure: dps310: " Rupesh Majhi
2026-11-10 15:42 ` [PATCH 1/2] dt-bindings: iio: pressure: infineon,dps310: Add interrupts Rupesh Majhi
2026-11-10 15:42 ` [PATCH 2/2] iio: pressure: dps310: add a data-ready trigger Rupesh Majhi
2026-11-10 16:48   ` Andy Shevchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avNK0EldiZVxrhE8@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=eajames@linux.ibm.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=paulius.zaleckas@gmail.com \
    --cc=robh@kernel.org \
    --cc=zoone.rupert@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®