Skip to contentSkip to conversation

fpga: Add flag to indicate SPI bitstream is bit-reversed

PATCH In review Anatolij Gustschin 2 participants 4 messages Apr 20, 2017 – May 18, 2017 FPGA manager framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fpga: Add flag to indicate SPI bitstream is bit-reversed

Add a flag that is passed to the write_init() callback, indicating that the SPI bitstream starts with LSB first. SPI controllers usually send data with MSB first. If an FPGA expects bitstream data as LSB first, the data must be reversed either by the SPI controller or by the driver.

Alternatively the bitstream could be prepared as bit-reversed to avoid the bit-swapping while sending. This flag indicates such bit-reversed SPI bitstream. The low-level driver will deal with the flag and perform bit-reversing if needed.

---
 include/linux/fpga/fpga-mgr.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/fpga/fpga-mgr.h +3 -0
index b4ac24c..5a055a0 100644
@@ -67,10 +67,13 @@ enum fpga_mgr_states {
  * FPGA Manager flags
  * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported
  * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting
+ * FPGA_MGR_SPI_BITSTREAM_LSB_FIRST: SPI bitstream bit order is reversed to
+ *				     start with LSB first
  */
 #define FPGA_MGR_PARTIAL_RECONFIG	BIT(0)
 #define FPGA_MGR_EXTERNAL_CONFIG	BIT(1)
 #define FPGA_MGR_ENCRYPTED_BITSTREAM	BIT(2)
+#define FPGA_MGR_SPI_BITSTREAM_LSB_FIRST	BIT(3)
 
 /**
  * struct fpga_image_info - information specific to a FPGA image
Signature · 1 line
2.7.4
#1 lore raw

Hi Alanatolij,
I was just finally able to test this and your other change yesterday

Quoted 24 lines · PDT Anatolij Gustschin

Add a flag that is passed to the write_init() callback, indicating that the SPI bitstream starts with LSB first. SPI controllers usually send data with MSB first. If an FPGA expects bitstream data as LSB first, the data must be reversed either by the SPI controller or by the driver.

Alternatively the bitstream could be prepared as bit-reversed to avoid the bit-swapping while sending. This flag indicates such bit-reversed SPI bitstream. The low-level driver will deal with the flag and perform bit-reversing if needed.

---
 include/linux/fpga/fpga-mgr.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/fpga/fpga-mgr.h +0 -0
index b4ac24c..5a055a0 100644
@@ -67,10 +67,13 @@ enum fpga_mgr_states {
  * FPGA Manager flags
  * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported
  * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux
Quoted 7 lines

booting + * FPGA_MGR_SPI_BITSTREAM_LSB_FIRST: SPI bitstream bit order is
reversed to + * start with LSB first
*/
#define FPGA_MGR_PARTIAL_RECONFIG BIT(0)
#define FPGA_MGR_EXTERNAL_CONFIG BIT(1)
#define FPGA_MGR_ENCRYPTED_BITSTREAM BIT(2)
+#define FPGA_MGR_SPI_BITSTREAM_LSB_FIRST BIT(3)

My thought here is that FPGA_MGR_BITSTREAM_LSB_FIRST is a bit shorter, adequate, and could do if another upload method happened to use LSB first organized data.

Quoted 3 lines

/**
* struct fpga_image_info - information specific to a FPGA image

I'll preparing an updated patch series including a version of your patches

Signature · 1 line
~Joshua A Clayton
#2 lore raw

Hi Joshua,

On Wed, 17 May 2017 07:47:42 -0700 [email protected] [email protected] wrote:
...

Quoted 4 lines
Quoted 2 lines

/**
* struct fpga_image_info - information specific to a FPGA image

I'll preparing an updated patch series including a version of your patches

please wait a bit. I'll send updated version with Arria 10 support merged.

Thanks,

Anatolij

#3 lore raw
In reply to [email protected]

Hi Joshua,

On Wed, 17 May 2017 07:47:42 -0700 [email protected] [email protected] wrote:
...

Quoted 5 lines
Quoted 2 lines

#define FPGA_MGR_ENCRYPTED_BITSTREAM BIT(2)
+#define FPGA_MGR_SPI_BITSTREAM_LSB_FIRST BIT(3)

My thought here is that FPGA_MGR_BITSTREAM_LSB_FIRST is a bit shorter, adequate, and could do if another upload method happened to use LSB first organized data.

OK, I'll change and resubmit.

Thanks,

Anatolij