public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v1] spi: designware: add support for bits-per-word DT binding
@ 2026-02-27 11:04 Boon Khai Ng
  2026-02-27 14:07 ` Tom Rini
  0 siblings, 1 reply; 12+ messages in thread
From: Boon Khai Ng @ 2026-02-27 11:04 UTC (permalink / raw)
  To: U-boot Openlist
  Cc: Boon Khai Ng, Tom Rini, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

Add support for the bits-per-word device tree binding.

Signed-off-by: Boon Khai Ng <boon.khai.ng@altera.com>
---
 drivers/spi/designware_spi.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index b520c727900..c41436a1dfb 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -359,6 +359,7 @@ static int dw_spi_probe(struct udevice *bus)
 	dw_spi_init_t init = (dw_spi_init_t)dev_get_driver_data(bus);
 	struct dw_spi_plat *plat = dev_get_plat(bus);
 	struct dw_spi_priv *priv = dev_get_priv(bus);
+	u32 bits_per_word = 8;
 	int ret;
 	u32 version;
 
@@ -384,8 +385,19 @@ static int dw_spi_probe(struct udevice *bus)
 		version >> 24, version >> 16, version >> 8, version,
 		priv->max_xfer);
 
-	/* Currently only bits_per_word == 8 supported */
-	priv->bits_per_word = 8;
+	ret = ofnode_read_u32(dev_ofnode(bus), "bits-per-word", &bits_per_word);
+	if (ret) {
+		debug("%s no bits-per-word not found\n", __func__);
+	} else {
+		if (bits_per_word >= 4 && bits_per_word <= priv->max_xfer) {
+			debug("%s %d bits-per-word found\n", __func__, bits_per_word);
+		} else {
+			printf("ignoring invalid bits-per-word %d\n", bits_per_word);
+			bits_per_word = 8;
+		}
+	}
+
+	priv->bits_per_word = bits_per_word;
 
 	priv->tmode = 0; /* Tx & Rx */
 
-- 
2.43.7


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-02-27 11:04 [PATCH v1] spi: designware: add support for bits-per-word DT binding Boon Khai Ng
@ 2026-02-27 14:07 ` Tom Rini
  2026-03-03  7:59   ` Ng, Boon Khai
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Rini @ 2026-02-27 14:07 UTC (permalink / raw)
  To: Boon Khai Ng
  Cc: U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

[-- Attachment #1: Type: text/plain, Size: 1636 bytes --]

On Fri, Feb 27, 2026 at 07:04:34PM +0800, Boon Khai Ng wrote:

> Add support for the bits-per-word device tree binding.
> 
> Signed-off-by: Boon Khai Ng <boon.khai.ng@altera.com>
> ---
>  drivers/spi/designware_spi.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
> index b520c727900..c41436a1dfb 100644
> --- a/drivers/spi/designware_spi.c
> +++ b/drivers/spi/designware_spi.c
> @@ -359,6 +359,7 @@ static int dw_spi_probe(struct udevice *bus)
>  	dw_spi_init_t init = (dw_spi_init_t)dev_get_driver_data(bus);
>  	struct dw_spi_plat *plat = dev_get_plat(bus);
>  	struct dw_spi_priv *priv = dev_get_priv(bus);
> +	u32 bits_per_word = 8;
>  	int ret;
>  	u32 version;
>  
> @@ -384,8 +385,19 @@ static int dw_spi_probe(struct udevice *bus)
>  		version >> 24, version >> 16, version >> 8, version,
>  		priv->max_xfer);
>  
> -	/* Currently only bits_per_word == 8 supported */
> -	priv->bits_per_word = 8;
> +	ret = ofnode_read_u32(dev_ofnode(bus), "bits-per-word", &bits_per_word);
> +	if (ret) {
> +		debug("%s no bits-per-word not found\n", __func__);
> +	} else {
> +		if (bits_per_word >= 4 && bits_per_word <= priv->max_xfer) {
> +			debug("%s %d bits-per-word found\n", __func__, bits_per_word);
> +		} else {
> +			printf("ignoring invalid bits-per-word %d\n", bits_per_word);
> +			bits_per_word = 8;
> +		}
> +	}
> +
> +	priv->bits_per_word = bits_per_word;
>  
>  	priv->tmode = 0; /* Tx & Rx */
>  

I don't see this binding in v7.0-rc1, did I miss it? Thanks.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-02-27 14:07 ` Tom Rini
@ 2026-03-03  7:59   ` Ng, Boon Khai
  2026-03-03 14:37     ` Tom Rini
  0 siblings, 1 reply; 12+ messages in thread
From: Ng, Boon Khai @ 2026-03-03  7:59 UTC (permalink / raw)
  To: Tom Rini
  Cc: U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

Hi Tom,

> I don't see this binding in v7.0-rc1, did I miss it? Thanks.
> 

This binding was not introduce in Linux. This is a per-requisite commit
to support the Agilex Smart NIC 60xx board 
https://www.silicom-usa.com/wp-content/uploads/2024/02/FPGA-SmartNIC-N6010-AgileX-Based.pdf

During the initialization stage, this board require a spi communication 
to configure the chip's PLL and also to check the chip's status.

and it require the specific spi bits-per-word=16 setting.

Can i add the binding at U-Boot?
https://github.com/u-boot/u-boot/blob/master/doc/device-tree-bindings/spi/snps%2Cdw-apb-ssi.txt

Regards
Boon Khai.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-03-03  7:59   ` Ng, Boon Khai
@ 2026-03-03 14:37     ` Tom Rini
  2026-03-03 16:01       ` Conor Dooley
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Rini @ 2026-03-03 14:37 UTC (permalink / raw)
  To: Ng, Boon Khai
  Cc: U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

[-- Attachment #1: Type: text/plain, Size: 874 bytes --]

On Tue, Mar 03, 2026 at 03:59:35PM +0800, Ng, Boon Khai wrote:
> Hi Tom,
> 
> > I don't see this binding in v7.0-rc1, did I miss it? Thanks.
> > 
> 
> This binding was not introduce in Linux. This is a per-requisite commit
> to support the Agilex Smart NIC 60xx board https://www.silicom-usa.com/wp-content/uploads/2024/02/FPGA-SmartNIC-N6010-AgileX-Based.pdf
> 
> During the initialization stage, this board require a spi communication to
> configure the chip's PLL and also to check the chip's status.
> 
> and it require the specific spi bits-per-word=16 setting.
> 
> Can i add the binding at U-Boot?
> https://github.com/u-boot/u-boot/blob/master/doc/device-tree-bindings/spi/snps%2Cdw-apb-ssi.txt

Why would this be inappropraite for the Linux kernel, once the system is
fully supported in Linux is the first question to answer. Thanks.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-03-03 14:37     ` Tom Rini
@ 2026-03-03 16:01       ` Conor Dooley
  2026-03-03 17:00         ` Ng, Boon Khai
  0 siblings, 1 reply; 12+ messages in thread
From: Conor Dooley @ 2026-03-03 16:01 UTC (permalink / raw)
  To: Tom Rini
  Cc: Ng, Boon Khai, U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

[-- Attachment #1: Type: text/plain, Size: 2567 bytes --]

On Tue, Mar 03, 2026 at 08:37:21AM -0600, Tom Rini wrote:
> On Tue, Mar 03, 2026 at 03:59:35PM +0800, Ng, Boon Khai wrote:
> > Hi Tom,
> > 
> > > I don't see this binding in v7.0-rc1, did I miss it? Thanks.
> > > 
> > 
> > This binding was not introduce in Linux. This is a per-requisite commit
> > to support the Agilex Smart NIC 60xx board https://www.silicom-usa.com/wp-content/uploads/2024/02/FPGA-SmartNIC-N6010-AgileX-Based.pdf
> > 
> > During the initialization stage, this board require a spi communication to
> > configure the chip's PLL and also to check the chip's status.
> > 
> > and it require the specific spi bits-per-word=16 setting.
> > 
> > Can i add the binding at U-Boot?
> > https://github.com/u-boot/u-boot/blob/master/doc/device-tree-bindings/spi/snps%2Cdw-apb-ssi.txt
> 
> Why would this be inappropraite for the Linux kernel, once the system is

Did you mean "inappropraite", or actually appropriate? Guess it
doesn't really matter to me, since the former would be asking "why would
linux not want this" and the latter would be "why would linux want
this". And I guess, as U-Boot maintainer the former is more important so
inappropriate is actually what you meant. I, of course, always approach
things with the latter mindset ;)

> fully supported in Linux is the first question to answer. Thanks.

The property doesn't make sense to me in a linux context. bits_per_word
as explained here is a device setting should be set in the device driver,
and is almost always per-compatible so doesn't even need to come from dt
at all. What a controller can support is also effectively always
determinable from the compatible of the controller, and is often a range.

Looking at the linux driver, all dw spi controllers appear to be able to
support 4-16 bits per word with select devices also supporting 32. The
check is done at runtime, it has no need for a property at all. The
device driver effectively decides what is done for the transfer, within
the range of supported values by the controller, based on what it sets
in its spi_device struct. I don't know if u-boot has similar
functionality in its code, but looking at dm_spi_slave_plat which I
think is your version of spi_device, that information is not there.

Were this submitted to linux with the current explanation, the feedback
would be to set bits_per_word in the driver for whatever this "chip"
that's being talked about is, presumably that means setting it in some
sort of clock driver given that it controls a PLL?

Cheers,
Conor.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-03-03 16:01       ` Conor Dooley
@ 2026-03-03 17:00         ` Ng, Boon Khai
  2026-03-03 17:05           ` Tom Rini
  0 siblings, 1 reply; 12+ messages in thread
From: Ng, Boon Khai @ 2026-03-03 17:00 UTC (permalink / raw)
  To: Conor Dooley, Tom Rini
  Cc: U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

Hi Conor, Tom,

>> Why would this be inappropraite for the Linux kernel, once the system is
>> fully supported in Linux is the first question to answer. Thanks.

As Conor mentioned, the bits_per_word setting is obtained from the 
controller and validated at runtime.

Additionally, bits_per_word can also be sourced from ACPI, as shown in 
the Linux SPI driver code

https://github.com/torvalds/linux/blob/af4e9ef3d78420feb8fe58cd9a1ab80c501b3c08/drivers/spi/spi.c#L2739C7-L2739C20

> in its spi_device struct. I don't know if u-boot has similar
> functionality in its code, but looking at dm_spi_slave_plat which I
> think is your version of spi_device, that information is not there.
> 
Currently, U-Boot only supports an hardcoded 8-bit bits_per_word 
configuration.

> Were this submitted to linux with the current explanation, the feedback
> would be to set bits_per_word in the driver for whatever this "chip"
> that's being talked about is, presumably that means setting it in some
> sort of clock driver given that it controls a PLL?
> 
No, this isn't required by Linux, as the PLL only needs to be configured 
during the initial stage. This commit is specifically necessary for 
supporting the Agilex Smart NIC board, and I'm currently preparing 
patches for upstream submission. More details on the chip can be found, 
https://www.microchip.com/en-us/product/zl30793

Below is the link to the Smart NIC board:
https://www.silicom-usa.com/pr/4g-5g-products/4g-5g-adapters/fpga-smartnic-n6010-intel-based/

Below is the link to the patches I am preparing for upstream submission:
https://github.com/altera-fpga/u-boot-socfpga/blob/socfpga_v2025.10/board/intel/agilex-n6010/plldata.c

-- 
 >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-03-03 17:00         ` Ng, Boon Khai
@ 2026-03-03 17:05           ` Tom Rini
  2026-03-04  2:41             ` Ng, Boon Khai
  2026-03-10 10:55             ` Ng, Boon Khai
  0 siblings, 2 replies; 12+ messages in thread
From: Tom Rini @ 2026-03-03 17:05 UTC (permalink / raw)
  To: Ng, Boon Khai
  Cc: Conor Dooley, U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

[-- Attachment #1: Type: text/plain, Size: 972 bytes --]

On Wed, Mar 04, 2026 at 01:00:13AM +0800, Ng, Boon Khai wrote:
> Hi Conor, Tom,
> 
> > > Why would this be inappropraite for the Linux kernel, once the system is
> > > fully supported in Linux is the first question to answer. Thanks.
> 
> As Conor mentioned, the bits_per_word setting is obtained from the
> controller and validated at runtime.
> 
> Additionally, bits_per_word can also be sourced from ACPI, as shown in the
> Linux SPI driver code
> 
> https://github.com/torvalds/linux/blob/af4e9ef3d78420feb8fe58cd9a1ab80c501b3c08/drivers/spi/spi.c#L2739C7-L2739C20
> 
> > in its spi_device struct. I don't know if u-boot has similar
> > functionality in its code, but looking at dm_spi_slave_plat which I
> > think is your version of spi_device, that information is not there.
> > 
> Currently, U-Boot only supports an hardcoded 8-bit bits_per_word
> configuration.

Thanks. And can we reasonably follow what Linux does here instead?

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-03-03 17:05           ` Tom Rini
@ 2026-03-04  2:41             ` Ng, Boon Khai
  2026-03-04 14:38               ` Tom Rini
  2026-03-10 10:55             ` Ng, Boon Khai
  1 sibling, 1 reply; 12+ messages in thread
From: Ng, Boon Khai @ 2026-03-04  2:41 UTC (permalink / raw)
  To: Tom Rini
  Cc: Conor Dooley, U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea


> 
> Thanks. And can we reasonably follow what Linux does here instead?
> 

We don't have ACPI in our devices, instead, i think that can be replaced 
with DTS.

-- 
 >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-03-04  2:41             ` Ng, Boon Khai
@ 2026-03-04 14:38               ` Tom Rini
  2026-03-04 14:58                 ` Conor Dooley
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Rini @ 2026-03-04 14:38 UTC (permalink / raw)
  To: Ng, Boon Khai
  Cc: Conor Dooley, U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

On Wed, Mar 04, 2026 at 10:41:57AM +0800, Ng, Boon Khai wrote:
> 
> > 
> > Thanks. And can we reasonably follow what Linux does here instead?
> > 
> 
> We don't have ACPI in our devices, instead, i think that can be replaced
> with DTS.

I thought Conor said it could be auto-detected still, without ACPI, in
Linux?

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-03-04 14:38               ` Tom Rini
@ 2026-03-04 14:58                 ` Conor Dooley
  0 siblings, 0 replies; 12+ messages in thread
From: Conor Dooley @ 2026-03-04 14:58 UTC (permalink / raw)
  To: Tom Rini
  Cc: Ng, Boon Khai, U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

[-- Attachment #1: Type: text/plain, Size: 1201 bytes --]

On Wed, Mar 04, 2026 at 08:38:17AM -0600, Tom Rini wrote:
> On Wed, Mar 04, 2026 at 10:41:57AM +0800, Ng, Boon Khai wrote:
> > 
> > > 
> > > Thanks. And can we reasonably follow what Linux does here instead?
> > > 
> > 
> > We don't have ACPI in our devices, instead, i think that can be replaced
> > with DTS.
> 
> I thought Conor said it could be auto-detected still, without ACPI, in
> Linux?

The controller capabilities are auto-detected. This has nothing to do
with ACPI AFAICT, I don't know why that was brought up. What it detects
is not an exact value though, the detected capability is the max of a
range. On Linux, the spi controller driver advertises the range it
supports. The spi device struct carries the bits_per_word that it wants
to use, and the controller driver looks into that struct to figure out
what supported bits_per_word setting to use in the transfer function.
It's not as simple as just reading the register in the controller and
setting the U-Boot drivers bits_per_word to the value, but I don't see
why U-Boot couldn't do what Linux does here.

If you search in spi-dw-core for bits_per_word, you should be able to
get a grasp of how it works.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-03-03 17:05           ` Tom Rini
  2026-03-04  2:41             ` Ng, Boon Khai
@ 2026-03-10 10:55             ` Ng, Boon Khai
  2026-03-13  1:43               ` Ng, Boon Khai
  1 sibling, 1 reply; 12+ messages in thread
From: Ng, Boon Khai @ 2026-03-10 10:55 UTC (permalink / raw)
  To: Tom Rini
  Cc: Conor Dooley, U-boot Openlist, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea

Hi, Tom, Conor,
>> configuration.
> 
> Thanks. And can we reasonably follow what Linux does here instead?
> 

After study the linux code, the bits_per_word value can be set at the 
higher level stack for example the touch screen driver ad7877.c at line 
https://github.com/torvalds/linux/blob/1f318b96cc84d7c2ab792fcc0bfd42a7ca890681/drivers/input/touchscreen/ad7877.c#L694

will implement something like that in U-Boot too as follow:
1) Add the bits_per_word in the spi_slave struct
2) at the dw_spi_xfer function to resolve for the slave->bits_per_word 
value and store into the priv->bits_per_word, default to 8 otherwise

Regards,
Boon Khai

-- 
 >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1] spi: designware: add support for bits-per-word DT binding
  2026-03-10 10:55             ` Ng, Boon Khai
@ 2026-03-13  1:43               ` Ng, Boon Khai
  0 siblings, 0 replies; 12+ messages in thread
From: Ng, Boon Khai @ 2026-03-13  1:43 UTC (permalink / raw)
  To: U-boot Openlist
  Cc: Conor Dooley, Tien Fong Chee, Dinesh Maniyam,
	Alif Zakuan Yuslaimi, Chen Huei Lok, Kok Kiang Hea, Tom Rini

> will implement something like that in U-Boot too as follow:
> 1) Add the bits_per_word in the spi_slave struct
> 2) at the dw_spi_xfer function to resolve for the slave->bits_per_word 
> value and store into the priv->bits_per_word, default to 8 otherwise
> 

Submitted the change at:
https://patchwork.ozlabs.org/project/uboot/patch/20260312044633.29242-1-boon.khai.ng@altera.com/

-- 
 >

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-13  5:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 11:04 [PATCH v1] spi: designware: add support for bits-per-word DT binding Boon Khai Ng
2026-02-27 14:07 ` Tom Rini
2026-03-03  7:59   ` Ng, Boon Khai
2026-03-03 14:37     ` Tom Rini
2026-03-03 16:01       ` Conor Dooley
2026-03-03 17:00         ` Ng, Boon Khai
2026-03-03 17:05           ` Tom Rini
2026-03-04  2:41             ` Ng, Boon Khai
2026-03-04 14:38               ` Tom Rini
2026-03-04 14:58                 ` Conor Dooley
2026-03-10 10:55             ` Ng, Boon Khai
2026-03-13  1:43               ` Ng, Boon Khai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox