From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: David Lechner <dlechner@baylibre.com>
Cc: "Mark Brown" <broonie@kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Michael Hennerich" <michael.hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Frank Rowand" <frowand.list@gmail.com>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Jonathan Corbet" <corbet@lwn.net>,
linux-spi@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 12/13] iio: offload: add new PWM triggered DMA buffer driver
Date: Fri, 12 Jan 2024 12:45:09 +0000 [thread overview]
Message-ID: <20240112124509.000001b8@Huawei.com> (raw)
In-Reply-To: <20240109-axi-spi-engine-series-3-v1-12-e42c6a986580@baylibre.com>
On Wed, 10 Jan 2024 13:49:53 -0600
David Lechner <dlechner@baylibre.com> wrote:
> This adds a new driver for handling SPI offloading using a PWM as the
> trigger and DMA for the received data. This will be used by ADCs in
> conjunction with SPI controllers with offloading support to be able
> to sample at high rates without CPU intervention.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Ah. So if I read this right, the trigger only exists to provide somewhere
to hang the frequency control? Not sure it's worth the complexity for that.
Do we expect a given offload engine to allow a bunch of 'standard' triggers?
If that's the case then I don't mind them being exposed as triggers. We do
that for a few other devices where we need to pick between a bunch of
different internal signals and it works fine.
> +
> +static int iio_pwm_triggered_dma_buffer_probe(struct platform_device *pdev)
> +{
> + struct iio_pwm_triggered_dma_buffer *st;
> + struct auxiliary_device *adev;
> + int ret;
> +
> + st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL);
> + if (!st)
> + return -ENOMEM;
> +
> + st->pwm = devm_pwm_get(&pdev->dev, NULL);
> + if (IS_ERR(st->pwm))
> + return dev_err_probe(&pdev->dev, PTR_ERR(st->pwm),
> + "failed to get PWM\n");
> +
> + st->hw.buffer = devm_iio_dmaengine_buffer_alloc(&pdev->dev, "rx");
> + if (IS_ERR(st->hw.buffer))
> + return dev_err_probe(&pdev->dev, PTR_ERR(st->hw.buffer),
> + "failed to allocate buffer\n");
> +
> + st->hw.trig = devm_iio_trigger_alloc(&pdev->dev, "%s-%s-pwm-trigger",
> + dev_name(pdev->dev.parent),
> + dev_name(&pdev->dev));
> + if (!st->hw.trig)
> + return -ENOMEM;
> +
> + st->hw.trig->ops = &iio_pwm_triggered_dma_buffer_ops;
> + st->hw.trig->dev.parent = &pdev->dev;
> + st->hw.trig->dev.groups = iio_pwm_triggered_dma_buffer_groups;
> + iio_trigger_set_drvdata(st->hw.trig, st);
> +
> + /* start with a reasonable default value */
> + ret = axi_spi_engine_offload_set_samp_freq(st, 1000);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "failed to set sampling frequency\n");
> +
> + ret = devm_iio_trigger_register(&pdev->dev, st->hw.trig);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "failed to register trigger\n");
> +
> + adev = &st->hw.adev;
> + adev->name = "triggered-buffer";
> + adev->dev.parent = &pdev->dev;
> + adev->dev.release = iio_pwm_triggered_dma_buffer_adev_release;
> + adev->id = 0;
> +
> + ret = auxiliary_device_init(adev);
> + if (ret)
> + return ret;
> +
> + ret = auxiliary_device_add(adev);
> + if (ret) {
> + auxiliary_device_uninit(adev);
> + return ret;
> + }
> +
> + return devm_add_action_or_reset(&pdev->dev,
> + iio_pwm_triggered_dma_buffer_unregister_adev, adev);
Split this an register the uninit and delete as separate callbacks to so we
can clearly see what each is doing.
> +}
next prev parent reply other threads:[~2024-01-12 12:45 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 19:49 [PATCH 00/13] spi: axi-spi-engine: add offload support David Lechner
2024-01-10 19:49 ` [PATCH 01/13] spi: add core support for controllers with offload capabilities David Lechner
2024-01-10 21:36 ` Mark Brown
2024-01-11 20:54 ` David Lechner
2024-01-11 21:32 ` David Lechner
2024-01-11 21:49 ` Mark Brown
2024-01-12 9:03 ` David Jander
2024-01-12 20:09 ` David Lechner
2024-03-04 23:21 ` David Lechner
2024-03-05 18:50 ` Mark Brown
2024-03-09 17:54 ` Jonathan Cameron
2024-01-11 8:49 ` Nuno Sá
2024-01-11 13:33 ` Mark Brown
2024-01-11 14:11 ` Nuno Sá
2024-01-11 15:41 ` Mark Brown
2024-01-12 7:26 ` Nuno Sá
2024-01-10 19:49 ` [PATCH 02/13] scripts: dtc: checks: don't warn on SPI non-peripheral child nodes David Lechner
2024-01-11 22:03 ` Rob Herring
2024-01-10 19:49 ` [PATCH 03/13] spi: do not attempt to register DT nodes without @ in name David Lechner
2024-01-10 21:37 ` Mark Brown
2024-01-10 19:49 ` [PATCH 04/13] spi: dt-bindings: adi,axi-spi-engine: add offload bindings David Lechner
2024-01-10 23:14 ` Rob Herring
2024-01-11 0:06 ` David Lechner
2024-01-11 9:14 ` Nuno Sá
2024-01-11 9:07 ` Nuno Sá
2024-01-10 19:49 ` [PATCH 05/13] spi: axi-spi-engine: add SPI offload support David Lechner
2024-01-10 21:39 ` Mark Brown
2024-01-10 22:31 ` David Lechner
2024-01-11 13:00 ` Mark Brown
2024-01-11 17:57 ` David Lechner
2024-01-10 19:49 ` [PATCH 06/13] iio: buffer: add hardware triggered buffer support David Lechner
2024-01-12 12:37 ` Jonathan Cameron
2024-01-12 15:42 ` David Lechner
2024-01-12 16:50 ` Nuno Sá
2024-01-10 19:49 ` [PATCH 07/13] iio: buffer: dmaengine: add INDIO_HW_BUFFER_TRIGGERED flag David Lechner
2024-01-10 19:49 ` [PATCH 08/13] iio: buffer: add new hardware triggered buffer driver David Lechner
2024-01-11 9:24 ` Nuno Sá
2024-01-10 19:49 ` [PATCH 09/13] bus: auxiliary: increase AUXILIARY_NAME_SIZE David Lechner
2024-01-10 19:49 ` [PATCH 10/13] iio: buffer: dmaengine: export devm_iio_dmaengine_buffer_alloc() David Lechner
2024-01-12 12:37 ` Jonathan Cameron
2024-01-12 14:55 ` David Lechner
2024-01-10 19:49 ` [PATCH 11/13] dt-bindings: iio: offload: add binding for PWM/DMA triggered buffer David Lechner
2024-01-10 21:25 ` Rob Herring
2024-01-10 22:56 ` Rob Herring
2024-01-10 19:49 ` [PATCH 12/13] iio: offload: add new PWM triggered DMA buffer driver David Lechner
2024-01-11 9:31 ` Nuno Sá
2024-01-11 14:59 ` Nuno Sá
2024-01-12 12:51 ` Jonathan Cameron
2024-01-12 13:19 ` Nuno Sá
2024-01-12 12:45 ` Jonathan Cameron [this message]
2024-01-10 19:49 ` [PATCH 13/13] iio: adc: ad7380: add SPI offload support David Lechner
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=20240112124509.000001b8@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=frowand.list@gmail.com \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=nuno.sa@analog.com \
--cc=robh+dt@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).