From: David Lechner <dlechner@baylibre.com>
To: Angelo Dureghello <adureghello@baylibre.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
Mihail Chindris <mihail.chindris@analog.com>,
Nuno Sa <nuno.sa@analog.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/9] iio: dac: adi-axi-dac: add bus mode setup
Date: Wed, 8 Jan 2025 15:06:19 -0600 [thread overview]
Message-ID: <50488ccd-8106-4048-9be7-06b2da854f3a@baylibre.com> (raw)
In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-4-2dac02f04638@baylibre.com>
On 1/8/25 11:29 AM, Angelo Dureghello wrote:
> From: Angelo Dureghello <adureghello@baylibre.com>
>
> The ad354xr requires DSPI mode (2 data lanes) to work in buffering
> mode, so backend needs to allow a mode selection between:
> SPI (entire ad35xxr family),
> DSPI (ad354xr),
> QSPI (ad355xr).
>
It wouldn't hurt to mention here why AXI_DAC_CUSTOM_CTRL_SYNCED_TRANSFER is
removed. It looks like it was just added by mistake in the original code and
isn't used anywhere.
> Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> ---
> drivers/iio/dac/ad3552r-hs.h | 8 ++++++++
> drivers/iio/dac/adi-axi-dac.c | 26 +++++++++++++++++++++++++-
> 2 files changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/dac/ad3552r-hs.h b/drivers/iio/dac/ad3552r-hs.h
> index 724261d38dea..4a9e35234124 100644
> --- a/drivers/iio/dac/ad3552r-hs.h
> +++ b/drivers/iio/dac/ad3552r-hs.h
> @@ -8,11 +8,19 @@
>
> struct iio_backend;
>
> +enum ad3552r_io_mode {
> + AD3552R_IO_MODE_SPI,
> + AD3552R_IO_MODE_DSPI,
> + AD3552R_IO_MODE_QSPI,
> +};
> +
> struct ad3552r_hs_platform_data {
> int (*bus_reg_read)(struct iio_backend *back, u32 reg, u32 *val,
> size_t data_size);
> int (*bus_reg_write)(struct iio_backend *back, u32 reg, u32 val,
> size_t data_size);
> + int (*bus_set_io_mode)(struct iio_backend *back,
> + enum ad3552r_io_mode mode);
> u32 bus_sample_data_clock_hz;
> };
>
> diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
> index d02eb535b648..79ca158c1ad9 100644
> --- a/drivers/iio/dac/adi-axi-dac.c
> +++ b/drivers/iio/dac/adi-axi-dac.c
> @@ -64,7 +64,7 @@
> #define AXI_DAC_UI_STATUS_IF_BUSY BIT(4)
> #define AXI_DAC_CUSTOM_CTRL_REG 0x008C
> #define AXI_DAC_CUSTOM_CTRL_ADDRESS GENMASK(31, 24)
> -#define AXI_DAC_CUSTOM_CTRL_SYNCED_TRANSFER BIT(2)
> +#define AXI_DAC_CUSTOM_CTRL_MULTI_IO_MODE GENMASK(3, 2)
> #define AXI_DAC_CUSTOM_CTRL_STREAM BIT(1)
> #define AXI_DAC_CUSTOM_CTRL_TRANSFER_DATA BIT(0)
>
> @@ -725,6 +725,29 @@ static int axi_dac_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val,
> return regmap_read(st->regmap, AXI_DAC_CUSTOM_RD_REG, val);
> }
>
> +static int axi_dac_bus_set_io_mode(struct iio_backend *back,
> + enum ad3552r_io_mode mode)
> +{
> + struct axi_dac_state *st = iio_backend_get_priv(back);
> + int ival, ret;
Don't we need to protect against concurrent register access?
guard(mutex)(&st->lock);
> +
> + ret = regmap_update_bits(st->regmap, AXI_DAC_CUSTOM_CTRL_REG,
> + AXI_DAC_CUSTOM_CTRL_MULTI_IO_MODE,
> + FIELD_PREP(AXI_DAC_CUSTOM_CTRL_MULTI_IO_MODE, mode));
> + if (ret)
> + return ret;
> +
> + ret = regmap_read_poll_timeout(st->regmap,
> + AXI_DAC_UI_STATUS_REG, ival,
> + FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0,
> + 10, 100 * KILO);
> +
> + if (ret == -ETIMEDOUT)
> + dev_err(st->dev, "AXI read timeout\n");
Same comment here as previous patch, is `dev_err()` really that helpful?
> +
> + return ret;
> +}
> +
> static void axi_dac_child_remove(void *data)
> {
> platform_device_unregister(data);
> @@ -736,6 +759,7 @@ static int axi_dac_create_platform_device(struct axi_dac_state *st,
> struct ad3552r_hs_platform_data pdata = {
> .bus_reg_read = axi_dac_bus_reg_read,
> .bus_reg_write = axi_dac_bus_reg_write,
> + .bus_set_io_mode = axi_dac_bus_set_io_mode,
> .bus_sample_data_clock_hz = st->dac_clk_rate,
> };
> struct platform_device_info pi = {
>
next prev parent reply other threads:[~2025-01-08 21:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 17:29 [PATCH v2 0/9] iio: ad3552r-hs: add support for ad3541/42r Angelo Dureghello
2025-01-08 17:29 ` [PATCH v2 1/9] iio: dac: ad3552r-common: fix ad3541/2r ranges Angelo Dureghello
2025-01-08 20:43 ` David Lechner
2025-01-12 13:35 ` Jonathan Cameron
2025-01-08 17:29 ` [PATCH v2 2/9] iio: dac: ad3552r-hs: clear reset status flag Angelo Dureghello
2025-01-08 20:51 ` David Lechner
2025-01-12 13:36 ` Jonathan Cameron
2025-01-08 17:29 ` [PATCH v2 3/9] iio: dac: adi-axi-dac: modify stream enable Angelo Dureghello
2025-01-08 21:00 ` David Lechner
2025-01-08 17:29 ` [PATCH v2 4/9] iio: dac: adi-axi-dac: add bus mode setup Angelo Dureghello
2025-01-08 21:06 ` David Lechner [this message]
2025-01-08 17:29 ` [PATCH v2 5/9] iio: dac: ad3552r-hs: fix message on wrong chip id Angelo Dureghello
2025-01-12 14:20 ` Jonathan Cameron
2025-01-08 17:29 ` [PATCH v2 6/9] iio: dac: ad3552r-hs: use instruction mode for configuration Angelo Dureghello
2025-01-08 21:16 ` David Lechner
2025-01-09 17:25 ` Angelo Dureghello
2025-01-09 18:04 ` David Lechner
2025-01-08 17:29 ` [PATCH v2 7/9] iio: dac: ad3552r: share model data structures Angelo Dureghello
2025-01-08 21:19 ` David Lechner
2025-01-08 17:29 ` [PATCH v2 8/9] iio: dac: ad3552r-hs: add ad3541/2r support Angelo Dureghello
2025-01-08 21:37 ` David Lechner
2025-01-12 14:36 ` Jonathan Cameron
2025-01-14 9:18 ` Angelo Dureghello
2025-01-08 17:29 ` [PATCH v2 9/9] iio: dac: ad3552r-hs: update function name (non functional) Angelo Dureghello
2025-01-08 21:39 ` 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=50488ccd-8106-4048-9be7-06b2da854f3a@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=adureghello@baylibre.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mihail.chindris@analog.com \
--cc=nuno.sa@analog.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®