36 #ifndef __MHAL_SPI_MASTER__H__
37 #define __MHAL_SPI_MASTER__H__
39 #include "mhal_osai.h"
145 #define SPIM_ELENGTH 2
147 #define SPIM_ENOMEM 3
152 #define MTK_SPIM_DMA_BUFFER_BYTES (48 + 4)
enum spi_cpha cpha
clock phase
Definition: mhal_spim.h:265
int mtk_mhal_spim_prepare_transfer(struct mtk_spi_controller *ctlr, struct mtk_spi_transfer *xfer)
This function is used to initialize SPIM based on mtk_spi_transfer setting.
Clock format is 0.
Definition: mhal_spim.h:183
u32 opcode_len
size of opcode length (in bytes) Note on MT3620: half duplex: TX only: it should be 1~4...
Definition: mhal_spim.h:299
I/O INTERFACE between SPI OS-HAL and M-HAL.
Definition: mhal_spim.h:281
int mtk_mhal_spim_disable_clk(struct mtk_spi_controller *ctlr)
This function is used to disable SPIM clock before transfer.
void * user_data
user_data is a OS-HAL defined parameter provided by mtk_mhal_spim_dma_done_callback_register().
Definition: mhal_spim.h:336
select device 1
Definition: mhal_spim.h:209
int mtk_mhal_spim_enable_clk(struct mtk_spi_controller *ctlr)
This function is used to enable SPIM clock before transfer.
The common configuration can be set for the SPIM HW.
Definition: mhal_spim.h:261
u32 speed_khz
config SPIM HW SCK speed that talk with device for this transfer.
Definition: mhal_spim.h:310
u8 * dma_tmp_tx_buf
used for DMA tx temp buf, the size of tx buffer should be MTK_SPIM_DMA_BUFFER_BYTES ...
Definition: mhal_spim.h:355
int mtk_mhal_spim_prepare_hw(struct mtk_spi_controller *ctlr, struct mtk_spi_config *config)
This function is used to initialize SPIM HW based on *config settings.
int(* spi_dma_done_callback)(void *user_data)
This defines the callback function prototype.
Definition: mhal_spim.h:249
int dma_rx_chan
RX DMA channel.
Definition: mhal_spim.h:360
spi_mlsb
SPI master's transaction bit order definition.
Definition: mhal_spim.h:194
Send/Receive data transfer MSB first.
Definition: mhal_spim.h:198
int mtk_mhal_spim_release_dma_chan(struct mtk_spi_controller *ctlr)
This function is used to release SPIM DMA channel.
void __iomem * base
spi controller base address
Definition: mhal_spim.h:348
int mtk_mhal_spim_dump_reg(struct mtk_spi_controller *ctlr)
This function is used to dump spi register for debugging.
int mtk_mhal_spim_fifo_handle_rx(struct mtk_spi_controller *ctlr, struct mtk_spi_transfer *xfer)
This function is used to read FIFO data from SPIM HW.
enum spi_cs_polarity cs_polar
cs polarity for slave device
Definition: mhal_spim.h:273
Send/Receive data transfer LSB first.
Definition: mhal_spim.h:196
struct mtk_spi_transfer * current_xfer
the temp variable of current mtk_spi_transfer
Definition: mhal_spim.h:363
int mtk_mhal_spim_allocate_dma_chan(struct mtk_spi_controller *ctlr)
This function is used to allocate SPIM DMA channel.
enum spi_mlsb rx_mlsb
rx per-word bits-on-wire
Definition: mhal_spim.h:269
u32 xfer_len
temp transfer len to DMA
Definition: mhal_spim.h:331
Clock polarity is 1.
Definition: mhal_spim.h:173
int mtk_mhal_spim_dma_transfer_one(struct mtk_spi_controller *ctlr, struct mtk_spi_transfer *xfer)
This function is used to perform a single mtk_spi_transfer by DMA mode.
enum spi_cpol cpol
clock polarity
Definition: mhal_spim.h:263
dma_addr_t rx_dma
temp rx DMA physical addr, it's the PA of mtk_spi_transfer->rx_buf
Definition: mhal_spim.h:328
u32 opcode
opcode data to be written (on MOSI pin)
Definition: mhal_spim.h:290
int dma_tx_chan
TX DMA channel.
Definition: mhal_spim.h:358
Interface to SPI master, it's used to pass arguments between OS-HAL/M-HAL/HDL.
Definition: mhal_spim.h:346
M-HAL privite structure.
Definition: mhal_spim.h:317
int mtk_mhal_spim_clear_irq_status(struct mtk_spi_controller *ctlr)
This function is used to clear SPIM HW status.
spi_cpol
SPI master's clock polarity definition.
Definition: mhal_spim.h:169
cs operate high active
Definition: mhal_spim.h:220
cs operate low active
Definition: mhal_spim.h:218
struct mtk_spi_private * mdata
M-HAL privite structure, used by M-HAL only.
Definition: mhal_spim.h:366
enum spi_slave_sel slave_sel
define select which spi slave device
Definition: mhal_spim.h:271
spi_cpha
SPI master's clock format definition.
Definition: mhal_spim.h:181
const void * tx_buf
data to be written (DMA-safe memory), or NULL
Definition: mhal_spim.h:283
u32 len
size of rx and tx buffers (in bytes)
Definition: mhal_spim.h:287
int mtk_mhal_spim_fifo_transfer_one(struct mtk_spi_controller *ctlr, struct mtk_spi_transfer *xfer)
This function is used to perform a single mtk_spi_transfer by FIFO mode.
enum spi_mlsb tx_mlsb
tx per-word bits-on-wire
Definition: mhal_spim.h:267
spi_cs_polarity
SPI master's CS polarity definition.
Definition: mhal_spim.h:216
Clock polarity is 0.
Definition: mhal_spim.h:171
u32 use_dma
spi support FIFO & DMA mode, 0:FIFO, 1: DMA
Definition: mhal_spim.h:302
int mtk_mhal_spim_dma_done_callback_register(struct mtk_spi_controller *ctlr, spi_dma_done_callback callback, void *user_data)
This function is used to register user's DMA callback to M-HAL.
void * rx_buf
data to be read (DMA-safe memory), or NULL
Definition: mhal_spim.h:285
dma_addr_t tx_dma
temp tx DMA physical addr, it's the PA of mtk_spi_transfer->tx_buf
Definition: mhal_spim.h:324
u8 * tx_buf
used for tx temp buf
Definition: mhal_spim.h:319
void __iomem * cg_base
CG base address of this spi controller.
Definition: mhal_spim.h:350
Clock format is 1.
Definition: mhal_spim.h:185
spi_slave_sel
SPI master's slave device select definition.
Definition: mhal_spim.h:205
select device 0
Definition: mhal_spim.h:207
spi_dma_done_callback dma_done_callback
This function is used to register user's DMA done callback to OS-HAL layer.
Definition: mhal_spim.h:340