linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Serge Semin <fancer.lancer@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
	Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] spi: dw: Add a number of native CS auto-detection
Date: Thu, 15 Feb 2024 21:31:52 +0200	[thread overview]
Message-ID: <Zc5mqLS34XIEo36F@smile.fi.intel.com> (raw)
In-Reply-To: <20240215180102.13887-3-fancer.lancer@gmail.com>

On Thu, Feb 15, 2024 at 09:00:47PM +0300, Serge Semin wrote:
> Aside with the FIFO depth and DFS field size it's possible to auto-detect
> a number of native chip-select synthesized in the DW APB/AHB SSI IP-core.
> It can be done just by writing ones to the SER register. The number of
> writable flags in the register is limited by the SSI_NUM_SLAVES IP-core
> synthesize parameter. All the upper flags are read-only and wired to zero.
> Based on that let's add the number of native CS auto-detection procedure
> so the low-level platform drivers wouldn't need to manually set it up
> unless it's required to set a constraint due to platform-specific reasons
> (for instance, due to a hardware bug).

...

> +	/*
> +	 * Try to detect the number of native chip-selects if the platform
> +	 * driver didn't set it up. There can be up to 16 lines configured.
> +	 */
> +	if (!dws->num_cs) {
> +		u32 ser;
> +
> +		dw_writel(dws, DW_SPI_SER, 0xffff);

GENMASK() ?

> +		ser = dw_readl(dws, DW_SPI_SER);
> +		dw_writel(dws, DW_SPI_SER, 0);

Would it actually change the physical line state? If so, we may not do this.

> +		dws->num_cs = hweight16(ser);

Why 16 and not u16 & dw_writew()/readw()?

> +	}

I'm wondering why this can't be the default

	num_cs = ...autodetected...
	device_property_read(..., &num_cs);

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-02-15 19:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 18:00 [PATCH 0/3] spi: dw: Auto-detect number of native CS Serge Semin
2024-02-15 18:00 ` [PATCH 1/3] spi: dw: Convert to using BITS_TO_BYTES() macro Serge Semin
2024-02-15 19:28   ` Andy Shevchenko
2024-02-15 18:00 ` [PATCH 2/3] spi: dw: Add a number of native CS auto-detection Serge Semin
2024-02-15 19:31   ` Andy Shevchenko [this message]
2024-02-15 18:00 ` [PATCH 3/3] spi: dw: Drop default number of CS setting Serge Semin
2024-02-15 19:32   ` Andy Shevchenko
2024-02-16 15:36     ` Serge Semin
2024-02-16 17:00       ` Andy Shevchenko
2024-02-16 18:03         ` Serge Semin

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=Zc5mqLS34XIEo36F@smile.fi.intel.com \
    --to=andy.shevchenko@gmail.com \
    --cc=Alexey.Malahov@baikalelectronics.ru \
    --cc=broonie@kernel.org \
    --cc=fancer.lancer@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.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).