STRUCT STM32_SPI(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’– struct stm32_spi(9) ๐Ÿ’–

okay so bestie, welcome to the Kernel API Manual โ€” this is the page for struct stm32_spi, aka the private data of the SPI controller. it's giving "backstage pass to the SPI vibe" and honestly? iconic. ๐ŸŽ€


โœจ NAME โœจ

struct stm32_spi โ€” the private data of the SPI controller. no cap, this is where all the controller's personal business lives. ๐Ÿ™ˆ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

here's the whole squad, laid out exactly how the kernel declares them:

       struct stm32_spi {
           struct device *dev;
           struct spi_controller *ctrl;
           const struct stm32_spi_cfg *cfg;
           void __iomem *base;
           struct clk *clk;
           u32 clk_rate;
           spinlock_t lock;
           int irq;
           unsigned int fifo_size;
           unsigned int t_size_max;
           unsigned int feature_set;
         #define STM32_SPI_FEATURE_LIMITED
       STM32MP25_SPI_HWCFGR1_FULLCFG_LIMITED   ;
         #define STM32_SPI_FEATURE_FULL
       STM32MP25_SPI_HWCFGR1_FULLCFG_FULL      ;
           unsigned int cur_midi;
           unsigned int cur_speed;
           unsigned int cur_half_period;
           unsigned int cur_bpw;
           unsigned int cur_fthlv;
           unsigned int cur_comm;
           unsigned int cur_xferlen;
           bool cur_usedma;
           const void *tx_buf;
           void *rx_buf;
           int tx_len;
           int rx_len;
           struct dma_chan *dma_tx;
           struct dma_chan *dma_rx;
           dma_addr_t phys_addr;
           bool device_mode;
           struct gen_pool *sram_pool;
           size_t sram_rx_buf_size;
           void *sram_rx_buf;
           dma_addr_t sram_dma_rx_buf;
           struct dma_chan *mdma_rx;
        };
fr fr, copy that block character for character โ€” the #defines sitting inside there are STM32_SPI_FEATURE_LIMITED and STM32_SPI_FEATURE_FULL, and they're part of feature_set's whole situation. ๐Ÿซถ

๐Ÿฆ‹ Members ๐Ÿฆ‹

time for the member-by-member vibe check, bestie. every single one, no skipping. ๐Ÿ’…

  • dev โ€” the driver model representation of the controller. it's the controller's official ID photo. ๐Ÿ“ธ
  • ctrl โ€” the controller interface. the actual SPI controller hookup. ๐Ÿ”Œ
  • cfg โ€” compatible configuration data. every compatible gets its own little outfit. ๐Ÿ‘—
  • base โ€” the virtual memory area. where the registers hang out in memory. ๐Ÿ—บ๏ธ
  • clk โ€” the hw kernel clock feeding the SPI clock generator. the clock's clock, yes really. โฐ
  • clk_rate โ€” the rate of the hw kernel clock feeding the SPI clock generator. same clock, but now with a number attached. ๐Ÿ”ข
  • lock โ€” prevents I/O concurrent access. one at a time, bestie, we're not doing chaos here. ๐Ÿ”’
  • irq โ€” the SPI controller interrupt line. the "hey bestie, something happened" phone line. โ˜Ž๏ธ
  • fifo_size โ€” size of the embedded fifo, in bytes. ๐ŸŒŠ
  • t_size_max โ€” the maximum number of data of one transfer. the ceiling, the limit, the "know your bounds". ๐Ÿ“
  • feature_set โ€” SPI full or limited feature set. full feature set vs. limited feature set, and this field tells you which one you got. ๐ŸŽš๏ธ
  • cur_midi โ€” host inter-data idleness in ns. yes, ns. nanoseconds of doing nothing, on purpose. ๐Ÿ˜ด
  • cur_speed โ€” speed configured in Hz. ๐ŸŽ๏ธ
  • cur_half_period โ€” time of a half bit in us. half a bit! in microseconds! the precision of it all. โฑ๏ธ
  • cur_bpw โ€” number of bits in a single SPI data frame. ๐Ÿงฎ
  • cur_fthlv โ€” fifo threshold level (data frames in a single data packet). ๐Ÿšฆ
  • cur_comm โ€” SPI communication mode. ๐Ÿ—ฃ๏ธ
  • cur_xferlen โ€” current transfer length in bytes. ๐Ÿ“ฆ
  • cur_usedma โ€” boolean to know if dma is used in current transfer. true/false, dma or no dma. โœ…
  • tx_buf โ€” data to be written, or NULL. ๐Ÿ“ค
  • rx_buf โ€” data to be read, or NULL. ๐Ÿ“ฅ
  • tx_len โ€” number of data to be written, in bytes. ๐Ÿ“คโžก๏ธ๐Ÿ”ข
  • rx_len โ€” number of data to be read, in bytes. ๐Ÿ”ขโฌ…๏ธ๐Ÿ“ฅ
  • dma_tx โ€” dma channel for TX transfer. ๐Ÿšš
  • dma_rx โ€” dma channel for RX transfer. ๐Ÿš›
  • phys_addr โ€” SPI registers physical base address. the physical one, not the virtual one up in base. respect the distinction, bestie. ๐Ÿ 
  • device_mode โ€” the controller is configured as SPI device. plot twist: it's the device now. ๐ŸŽญ
  • sram_pool โ€” SRAM pool for DMA transfers. ๐ŸŠ
  • sram_rx_buf_size โ€” size of SRAM buffer for RX transfer. ๐Ÿ“
  • sram_rx_buf โ€” SRAM buffer for RX transfer. the buffer itself. ๐Ÿงบ
  • sram_dma_rx_buf โ€” SRAM buffer physical address for RX transfer. again: the physical address. ๐ŸŒ
  • mdma_rx โ€” MDMA channel for RX transfer. not dma_rx โ€” MDMA. different little guy entirely. ๐Ÿ’€

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

everything below lives in the kernel file ./drivers/spi/spi-stm32.c โ€” go say hi to the whole extended fam: ๐ŸŒˆ


and that's the page, bestie ๐Ÿซถ this lil masterpiece comes to you from ./drivers/spi, dated October 2026 โ€” go forth and read your registers responsibly. periodt. ๐Ÿ’œโœจ

๐Ÿ“ฆ where this page comes from