From: Jonathan Cameron <jic23@kernel.org>
To: "Nuno Sá" <noname.nuno@gmail.com>
Cc: David Lechner <dlechner@baylibre.com>,
Jonathan Cameron <Jonathan.Cameron@Huawei.com>,
"Tinaco, Mariel" <Mariel.Tinaco@analog.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
Marcelo Schmitt <marcelo.schmitt1@gmail.com>,
Dimitri Fedrau <dima.fedrau@gmail.com>,
Guenter Roeck <linux@roeck-us.net>, Nuno Sa <nuno.sa@analog.com>
Subject: Re: [PATCH 2/2] iio: dac: support the ad8460 Waveform DAC
Date: Sat, 13 Jul 2024 10:57:19 +0100 [thread overview]
Message-ID: <20240713105719.0f9847c9@jic23-huawei> (raw)
In-Reply-To: <468b5725d0f191c20ada9524ecb7da8a48d56d97.camel@gmail.com>
On Fri, 12 Jul 2024 08:57:00 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Thu, 2024-07-11 at 16:31 -0500, David Lechner wrote:
> > On 7/11/24 4:20 AM, Nuno Sá wrote:
> > > On Mon, 2024-07-08 at 17:05 +0100, Jonathan Cameron wrote:
> > > > On Mon, 8 Jul 2024 05:17:55 +0000
> > > > "Tinaco, Mariel" <Mariel.Tinaco@analog.com> wrote:
> > > >
> > > > > > -----Original Message-----
> > > > > > From: Jonathan Cameron <jic23@kernel.org>
> > > > > > Sent: Saturday, June 29, 2024 2:46 AM
> > > > > > To: Tinaco, Mariel <Mariel.Tinaco@analog.com>
> > > > > > Cc: linux-iio@vger.kernel.org; devicetree@vger.kernel.org; linux-
> > > > > > kernel@vger.kernel.org; Lars-Peter Clausen <lars@metafoo.de>; Rob
> > > > > > Herring
> > > > > > <robh@kernel.org>; Krzysztof Kozlowski <krzk+dt@kernel.org>; Conor
> > > > > > Dooley
> > > > > > <conor+dt@kernel.org>; Liam Girdwood <lgirdwood@gmail.com>; Mark Brown
> > > > > > <broonie@kernel.org>; Hennerich, Michael
> > > > > > <Michael.Hennerich@analog.com>;
> > > > > > Marcelo Schmitt <marcelo.schmitt1@gmail.com>; Dimitri Fedrau
> > > > > > <dima.fedrau@gmail.com>; Guenter Roeck <linux@roeck-us.net>
> > > > > > Subject: Re: [PATCH 2/2] iio: dac: support the ad8460 Waveform DAC
> > > > > >
> > > > > > [External]
> > > > > >
> > > > > > > > > +};
> > > > > > > > > +
> > > > > > > > > +static int ad8460_get_powerdown_mode(struct iio_dev *indio_dev,
> > > > > > > > > + const struct iio_chan_spec
> > > > > > > > > *chan) {
> > > > > > > > > + return 0;
> > > > > > > >
> > > > > > > > Why have the stubs in here?
> > > > > > >
> > > > > > > Should I move the stubs to a different place in the code or remove
> > > > > > > them altogether since there is only a single powerdown mode
> > > > > > > available
> > > > > > Ah. I'd not really understood what was going on here. This is fine as
> > > > > > is.
> > > > > >
> > > > > > > > AD8460_HVDAC_DATA_WORD_HIGH(index),
> > > > > > > > > + ((val >> 8) & 0xFF));
> > > > > > > >
> > > > > > > > bulk write? or do these need to be ordered?
> > > > > > >
> > > > > > > For this I used bulk read/write this way.
> > > > > > >
> > > > > > > static int ad8460_set_hvdac_word(struct ad8460_state *state,
> > > > > > > int index,
> > > > > > > int val)
> > > > > > > {
> > > > > > > u8 regvals[AD8460_DATA_BYTE_WORD_LENGTH];
> > > > > > regmap bulk accesses (when spi anyway) should be provided with DMA
> > > > > > safe
> > > > > > buffers.
> > > > > > Easiest way to do that is add one with __aligned(IIO_DMA_MINALIGN) to
> > > > > > the
> > > > > > end of the ad8460_state structure. Possibly you'll need a lock to
> > > > > > protect it -
> > > > > > I
> > > > > > haven't checked.
> > > > > > >
> > > > > > > regvals[0] = val & 0xFF;
> > > > > > > regvals[1] = (val >> 8) & 0xFF;
> > > > > >
> > > > > > That is an endian conversion so use appropriate endian function to
> > > > > > fill it
> > > > > > efficiently and document clearly what is going on.
> > > > > >
> > > > > >
> > > > > > put_unaligned_le16()
> > > > > >
> > > > > > >
> > > > > > > return regmap_bulk_write(state->regmap,
> > > > > > AD8460_HVDAC_DATA_WORD_LOW(index),
> > > > > > > regvals,
> > > > > > AD8460_DATA_BYTE_WORD_LENGTH); }
> > > > > > >
> > > > > > >
> > > > > > > > > +}
> > > > > >
> > > > > > > > > + state->regmap = devm_regmap_init_spi(spi,
> > > > > > > > > &ad8460_regmap_config);
> > > > > > > > > + if (IS_ERR(state->regmap))
> > > > > > > > > + return dev_err_probe(&spi->dev, PTR_ERR(state-
> > > > > > > > > >regmap),
> > > > > > > > > + "Failed to initialize
> > > > > > > > > regmap");
> > > > > > > > > +
> > > > > > > > > + ret = devm_iio_dmaengine_buffer_setup_ext(&spi->dev,
> > > > > > > > > indio_dev,
> > > > > > > > > +"tx",
> > > > > > > > > +
> > > > > > > > IIO_BUFFER_DIRECTION_OUT);
> > > > > > > >
> > > > > > > > Ah. I take back my binding comment. I assume this is mapping some
> > > > > > > > non standard interface for the parallel data flow?
> > > > > > >
> > > > > > > Yes, the HDL side doesn't follow yet the standard IIO backend from
> > > > > > > which this driver was tested
> > > > > >
> > > > > > Hmm. I'd like to see this brought inline with the other iio backend
> > > > > > drivers if
> > > > > > possible.
> > > > >
> > > > > Does this mean that we would need to implement an AXI IP core on the
> > > > > FPGA side to be able to test this?
> > > >
> > > > Don't think so. That framework is meant to support any equivalent IP.
> > > > So whatever you have should be supportable. Maybe it's somewhat of a stub
> > > > driver though if there isn't anything controllable.
> > > >
> > > > It's Nuno's area of expertise though +CC.
> > > >
> > >
> > > Hi Jonathan,
> > >
> > > Yeah, I did reply David (IIRC) about the very same question. In the
> > > design/HW Mariel
> > > is working on the DAC is directly connected to the DMA core which is handled
> > > already
> > > by a proper dma controller driver. So in this case I'm really not seeing the
> > > backend
> > > need right now (maybe in the future we may have another design for this
> > > device that
> > > could justify for a backend device but no idea on that).
> > >
> > > As you mention, we could very well do a stub platform driver so we can use
> > > the
> > > backend framework (like dma-backend or something) that could pretty much be
> > > a stub
> > > for the DMA controller. But is it worth it though? We'd actually be "lying"
> > > in terms
> > > of HW description as the DMA is a property of the actual converter.
> > >
> > > - Nuno Sá
> > >
> > >
> >
> > I'm a bit inclined to agree with Jonathan here. I could see someone in the
> > future,
> > wanting to, e.g., use DMA + a GPIO controller for the parallel interface if
> > they
> > didn't have an FPGA. So it seems a bit more future-proof to just always use
> > the
> > IIO backend framework for the parallel interface.
>
> I do agree it's more future but guessing usecases is not something I tend to
> like much (often just results in code that never gets __really__ used). We can
> very well take care of it when a usecase pops up and we have an actual device
> that can be represented by a backend :).
>
> >
> > FWIW, I don't think it would be "lying" since the io-backend DT node would be
> > representing physical parallel bus between the DMA controller and the ADC
> > chip.
>
> To me, it's really a stretch having a backend with the only reason (op) of
> requesting the DMA channel. I still think you're pushing to much and going
> around with wording to justify for the DMA property :). The parallel bus is part
> of the DAC and directly connects to the DMA data lines so it really looks to me
> the dma is a property of the actual DAC.
>
> That said and Mariel can help here, I did not really looked into the design
> myself and I'm just stating (or what I understood) what Mariel told me. But if
> there's some other piece of HW sitting between the DMA and the bus then it would
> be easier for me to agree even if we don't have any real control over that
> device.
>
> > But if DT maintainers are OK with the idea that a DMA channel can be directly
> > wired to an external chip, I guess I won't complain. :-)
>
> That's the case in here so I don't see why it should be a problem :). It's the
> same with the axi-dac/adc. It's all inside the FPGA but different cores/IPS.
>
> FWIW, I'm ok if we go the backend direction even if I don't fully agree with it
> (at least with the understanding I have so far about the design). I definitely
> want to see more users of it but I also don't think it should be a rule for any
> fairly high speed converter to have a backend associated.
ok. So short term, DT bindings that document the dma-channel
and see what the DT maintainers think. Longer term, if things get more
complex, that can become optional and a backend added.
Jonathan
>
> - Nuno Sá
>
next prev parent reply other threads:[~2024-07-13 9:57 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-10 6:40 [PATCH 0/2] add AD8460 DAC driver Mariel Tinaco
2024-05-10 6:40 ` [PATCH 1/2] dt-bindings: iio: dac: add docs for ad8460 Mariel Tinaco
2024-05-10 7:21 ` Rob Herring (Arm)
2024-05-10 17:28 ` David Lechner
2024-05-11 16:25 ` Jonathan Cameron
2024-05-11 18:47 ` David Lechner
2024-05-21 7:07 ` Nuno Sá
2024-06-24 4:20 ` Tinaco, Mariel
2024-05-10 6:40 ` [PATCH 2/2] iio: dac: support the ad8460 Waveform DAC Mariel Tinaco
2024-05-10 17:30 ` David Lechner
2024-05-11 16:44 ` Jonathan Cameron
2024-06-24 4:19 ` Tinaco, Mariel
2024-06-28 18:45 ` Jonathan Cameron
2024-07-08 5:17 ` Tinaco, Mariel
2024-07-08 16:05 ` Jonathan Cameron
2024-07-11 9:20 ` Nuno Sá
2024-07-11 21:31 ` David Lechner
2024-07-12 6:57 ` Nuno Sá
2024-07-13 9:57 ` Jonathan Cameron [this message]
2024-07-14 6:17 ` Nuno Sá
2024-06-24 4:56 ` Tinaco, Mariel
2024-06-28 18:51 ` Jonathan Cameron
2024-07-07 23:32 ` Tinaco, Mariel
2024-07-07 23:37 ` Tinaco, Mariel
2024-05-10 17:30 ` [PATCH 0/2] add AD8460 DAC driver David Lechner
2024-05-11 16:21 ` Jonathan Cameron
2024-06-24 4:38 ` Tinaco, Mariel
2024-06-28 18:39 ` Jonathan Cameron
2024-07-07 23:29 ` Tinaco, Mariel
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=20240713105719.0f9847c9@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@Huawei.com \
--cc=Mariel.Tinaco@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dima.fedrau@gmail.com \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=marcelo.schmitt1@gmail.com \
--cc=noname.nuno@gmail.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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).