Devicetree
 help / color / mirror / Atom feed
From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: David Lechner <dlechner@baylibre.com>
Cc: "Nuno Sá" <noname.nuno@gmail.com>,
	"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	broonie@kernel.org, lars@metafoo.de,
	Michael.Hennerich@analog.com, jic23@kernel.org,
	robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	conor+dt@kernel.org, nuno.sa@analog.com,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/6] spi: spi-axi-spi-engine: Add support for MOSI idle configuration
Date: Thu, 6 Jun 2024 18:31:49 -0300	[thread overview]
Message-ID: <ZmIqxS-xUVMNH_lJ@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <f8ce5dc8-ed68-4f04-af3a-187bf0e4a3b3@baylibre.com>

On 06/06, David Lechner wrote:
> On 6/6/24 1:51 AM, Nuno Sá wrote:
> > On Wed, 2024-06-05 at 12:03 -0500, David Lechner wrote:
> >> On 6/4/24 5:43 PM, Marcelo Schmitt wrote:
> >>> Implement MOSI idle low and MOSI idle high to better support peripherals
> >>> that request specific MOSI behavior.
> >>>
> >>> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
> >>> ---
> >>>  drivers/spi/spi-axi-spi-engine.c | 8 +++++++-
> >>>  1 file changed, 7 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-
> >>> engine.c
> >>> index 0aa31d745734..549f03069d0e 100644
> >>> --- a/drivers/spi/spi-axi-spi-engine.c
> >>> +++ b/drivers/spi/spi-axi-spi-engine.c
> >>> @@ -41,6 +41,7 @@
> >>>  #define SPI_ENGINE_CONFIG_CPHA			BIT(0)
> >>>  #define SPI_ENGINE_CONFIG_CPOL			BIT(1)
> >>>  #define SPI_ENGINE_CONFIG_3WIRE			BIT(2)
> >>> +#define SPI_ENGINE_CONFIG_SDO_IDLE		BIT(3)
> >>>  
> >>>  #define SPI_ENGINE_INST_TRANSFER		0x0
> >>>  #define SPI_ENGINE_INST_ASSERT			0x1
> >>> @@ -132,6 +133,10 @@ static unsigned int spi_engine_get_config(struct
> >>> spi_device *spi)
> >>>  		config |= SPI_ENGINE_CONFIG_CPHA;
> >>>  	if (spi->mode & SPI_3WIRE)
> >>>  		config |= SPI_ENGINE_CONFIG_3WIRE;
> >>> +	if (spi->mode & SPI_MOSI_IDLE_HIGH)
> >>> +		config |= SPI_ENGINE_CONFIG_SDO_IDLE;
> >>> +	if (spi->mode & SPI_MOSI_IDLE_LOW)
> >>> +		config &= ~SPI_ENGINE_CONFIG_SDO_IDLE;
> >>>  
> >>>  	return config;
> >>>  }
> >>> @@ -645,7 +650,8 @@ static int spi_engine_probe(struct platform_device
> >>> *pdev)
> >>>  		return ret;
> >>>  
> >>>  	host->dev.of_node = pdev->dev.of_node;
> >>> -	host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE;
> >>> +	host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE |
> >>> SPI_MOSI_IDLE_LOW
> >>> +			  | SPI_MOSI_IDLE_HIGH;
> >>>  	host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
> >>>  	host->max_speed_hz = clk_get_rate(spi_engine->ref_clk) / 2;
> >>>  	host->transfer_one_message = spi_engine_transfer_one_message;
> >>
> >> I think we need a version check instead of setting the flags unconditionally
> >> here since older versions of the AXI SPI Engine won't support this feature.
> > 
> > Oh, was not aware of that... Then, we definitely need to do that. Marcelo, only
> > add my r-b tag with the version change in place.
> > 
> > - Nuno Sá

Nuno,

I think there will be more disscussion about this series.
Maybe better I not add the tag at all so you may check to agree with the next
patch version.

> 
> Actually, looking at [1], it looks like this could be a compile-time
> flag when the HDL is built. If it stays that way, then we would need
> a way to read that flag from a register instead of using the version.
> 
> 
> [1]: https://github.com/analogdevicesinc/hdl/pull/1320#issuecomment-2145744521

When is a driver version check needed?
Yes, older versions of SPI-Engine won't support this, but the patch set should
cause no regression. Even if loading the current ad4000 driver with
older SPI-Engine HDL and driver, the ADC driver would get a warn (or error?)
and do what's possible without MOSI idle feature (probably only be able to do
reg access) or fail probing.

We decided to have the MOSI idle state feature for SPI-Engine configured by
writing to a dedicated bit [1] in the SPI Configuration Register [2].
Does this looks good?

[1]: https://github.com/analogdevicesinc/hdl/pull/1320/commits/941937eedae6701d253b4930d8f279c21ef3f807#diff-dc9213744b55493ca9430cd02cd62212436c2379ca121d1a2681356e6a37e22dR257
[2]: https://analogdevicesinc.github.io/hdl/library/spi_engine/instruction-format.html#spi-configuration-register

Thanks,
Marcelo

  reply	other threads:[~2024-06-06 21:30 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 22:40 [PATCH v3 0/6] Add support for AD4000 series of ADCs Marcelo Schmitt
2024-06-04 22:41 ` [PATCH v3 1/6] spi: Add SPI mode bit for MOSI idle state configuration Marcelo Schmitt
2024-06-05  9:14   ` Nuno Sá
2024-06-05 12:02     ` Mark Brown
2024-06-06 20:10       ` Marcelo Schmitt
2024-06-07 13:52         ` Mark Brown
2024-06-05 12:24   ` Mark Brown
2024-06-05 16:37     ` David Lechner
2024-06-05 17:04       ` Mark Brown
2024-06-06 22:08         ` Marcelo Schmitt
2024-06-07 13:51           ` Mark Brown
2024-06-06 19:57     ` Marcelo Schmitt
2024-06-07 13:50       ` Mark Brown
2024-06-07 14:55         ` Marcelo Schmitt
2024-06-04 22:42 ` [PATCH v3 2/6] spi: bitbang: Implement support " Marcelo Schmitt
2024-06-05  9:30   ` Nuno Sá
2024-06-04 22:42 ` [PATCH v3 3/6] spi: spi-gpio: Add " Marcelo Schmitt
2024-06-05  9:26   ` Nuno Sá
2024-06-04 22:43 ` [PATCH v3 4/6] spi: spi-axi-spi-engine: Add support for MOSI idle configuration Marcelo Schmitt
2024-06-05  9:25   ` Nuno Sá
2024-06-05 17:03   ` David Lechner
2024-06-06  6:51     ` Nuno Sá
2024-06-06 13:21       ` David Lechner
2024-06-06 21:31         ` Marcelo Schmitt [this message]
2024-06-07  7:15           ` Nuno Sá
2024-06-07 14:40             ` Marcelo Schmitt
2024-06-09  9:11               ` Jonathan Cameron
2024-06-04 22:43 ` [PATCH v3 5/6] dt-bindings: iio: adc: Add AD4000 Marcelo Schmitt
2024-06-05 17:14   ` Conor Dooley
2024-06-07 14:35     ` Marcelo Schmitt
2024-06-07 14:49       ` Conor Dooley
2024-06-05  9:31 ` [PATCH v3 0/6] Add support for AD4000 series of ADCs Nuno Sá
2024-06-05 11:19   ` Marcelo Schmitt
2024-06-05 11:14 ` [PATCH v3 6/6] iio: adc: Add support for AD4000 Marcelo Schmitt
2024-06-05 13:03   ` Nuno Sá
2024-06-09  9:23     ` Jonathan Cameron
2024-06-11 10:34       ` Andy Shevchenko
2024-06-11 17:05         ` Jonathan Cameron
2024-06-05 20:50   ` kernel test robot
2024-06-05 21:32   ` kernel test robot

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=ZmIqxS-xUVMNH_lJ@debian-BULLSEYE-live-builder-AMD64 \
    --to=marcelo.schmitt1@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=noname.nuno@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=robh+dt@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