Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
mhal_spis.h
1 /*
2  * (C) 2005-2020 MediaTek Inc. All rights reserved.
3  *
4  * Copyright Statement:
5  *
6  * This MT3620 driver software/firmware and related documentation
7  * ("MediaTek Software") are protected under relevant copyright laws.
8  * The information contained herein is confidential and proprietary to
9  * MediaTek Inc. ("MediaTek"). You may only use, reproduce, modify, or
10  * distribute (as applicable) MediaTek Software if you have agreed to and been
11  * bound by this Statement and the applicable license agreement with MediaTek
12  * ("License Agreement") and been granted explicit permission to do so within
13  * the License Agreement ("Permitted User"). If you are not a Permitted User,
14  * please cease any access or use of MediaTek Software immediately.
15  *
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
18  * PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS
19  * ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
21  * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
22  * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
23  * INCORPORATED IN, OR SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO
24  * LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
25  * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
26  * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
27  * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
28  * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
29  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
30  * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED
31  * HEREUNDER WILL BE ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
32  * RECEIVER TO MEDIATEK DURING THE PRECEDING TWELVE (12) MONTHS FOR SUCH
33  * MEDIATEK SOFTWARE AT ISSUE.
34  */
35 
36 #ifndef __MHAL_SPI_SLAVE__H__
37 #define __MHAL_SPI_SLAVE__H__
38 
39 #include "mhal_osai.h"
40 
596 #define SET_TRANSFER_H2DMB(x, y, z) \
597  ((0x1 << 6) | (x << 5) | (y << 4) | ((z) & 0xf))
598 
600 #define SPIS_EPTR 1
601 
602 #define SPIS_ELENGTH 2
603 
604 #define SPIS_EMEM 3
605 
606 #define SPIS_EBUSY 4
607 
608 #define SPIS_EDMA 5
609 
610 #define SPIS_EH2DMB 6
611 
627 enum spis_cpol {
632 };
633 
639 enum spis_cpha {
644 };
645 
663 };
664 
679 };
680 
688  SPIS_IDLE = 0x0,
690  SPIS_READY = 0x1,
692  SPIS_DONE = 0x2,
694  SPIS_ERR = 0x4,
695 };
696 
707 };
708 
734 typedef int (*spis_dma_done_callback) (void *user_data);
735 
736 
752 };
753 
761  void *tx_buf;
763  void *rx_buf;
765  unsigned int len;
769  int use_dma;
770 };
771 
781  dma_addr_t tx_dma;
785  dma_addr_t rx_dma;
788  void *user_data;
793 };
794 
800  void __iomem *base;
802  void __iomem *cg_base;
808  void *spis_tx_buf;
810  void *spis_rx_buf;
815 };
816 
827 #ifdef __cplusplus
828 extern "C" {
829 #endif
830 
841 
852 
853 
864 
896 
927 
960 
989 
990 
1014  struct mtk_spis_config *config);
1015 
1026 
1043  struct mtk_spis_transfer *xfer);
1044 
1045 
1063  struct mtk_spis_controller *ctlr,
1064  spis_dma_done_callback callback);
1065 
1084  struct mtk_spis_transfer *xfer);
1085 
1086 
1099 
1111 
1123 
1134 
1135 #ifdef __cplusplus
1136 }
1137 #endif
1138 
1139 
1149 #endif
spis_dma_done_callback dma_done_callback
This function is used to register user's DMA done callback to OS-HAL layer.
Definition: mhal_spis.h:792
dma_addr_t tx_dma
TX DMA physical addr, it's the PA of mtk_spis_transfer->tx_buf.
Definition: mhal_spis.h:781
int mtk_mhal_spis_handle_tx(struct mtk_spis_controller *ctlr)
This function is used to update spis TX transmisson status to d2hmb_state(defined in mtk_spis_private...
void * tx_buf
Data to be written (DMA-safe memory), or NULL.
Definition: mhal_spis.h:761
int mtk_mhal_spis_send_d2hmb(struct mtk_spis_controller *ctlr)
This function is used to update spis transmisson status.
int mtk_mhal_spis_fifo_transfer_one(struct mtk_spis_controller *ctlr, struct mtk_spis_transfer *xfer)
This function is used to perform a single mtk_spi_transfer by FIFO mode.
spis_tx_rx_flag
SPI slave's transmisson type.
Definition: mhal_spis.h:670
SPIM write data to SPIS(SPIS RX)
Definition: mhal_spis.h:674
spis_opcode
SPI slave's supported opcode.
Definition: mhal_spis.h:650
Used to record spis status and required resources during transmisson.
Definition: mhal_spis.h:775
void __iomem * base
spis controller base address
Definition: mhal_spis.h:800
Clock format is 0.
Definition: mhal_spis.h:641
void __iomem * cg_base
CG base address of this spis controller.
Definition: mhal_spis.h:802
enum spis_d2hmb_state d2hmb_state
D2HMB state, defined in spis_d2hmb_state.
Definition: mhal_spis.h:777
int mtk_mhal_spis_release_dma_chan(struct mtk_spis_controller *ctlr)
This function is used to release SPIS DMA channel.
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
int mtk_mhal_spis_get_irq_status(struct mtk_spis_controller *ctlr)
This function is used to get SPIS HW status.
Interface to SPI slave, it's used to pass arguments among OS-HAL/M-HAL/HDL.
Definition: mhal_spis.h:798
spim writes data to spis
Definition: mhal_spis.h:652
int mtk_mhal_spis_dump_reg(struct mtk_spis_controller *ctlr)
This function is used to dump spis register for debugging.
int mtk_mhal_spis_enable_irq(struct mtk_spis_controller *ctlr)
This function is used to enable SPIS HW interrupt.
struct mtk_spis_transfer * xfer
the mtk_spis_transfer
Definition: mhal_spis.h:812
int(* spis_dma_done_callback)(void *user_data)
This defines the callback function prototype.
Definition: mhal_spis.h:734
spim wants to write data
Definition: mhal_spis.h:706
spis_cpol
SPI slave's clock polarity definition.
Definition: mhal_spis.h:627
Clock format is 1.
Definition: mhal_spis.h:643
void * user_data
user_data is used to store spis hw setting.
Definition: mhal_spis.h:788
struct mtk_spis_private * mdata
M-HAL private structure, used by M-HAL only.
Definition: mhal_spis.h:814
int mtk_mhal_spis_allocate_dma_chan(struct mtk_spis_controller *ctlr)
This function is used to allocate SPIS DMA channel.
int mtk_mhal_spis_handle_rx(struct mtk_spis_controller *ctlr)
This function is used to update spis RX transmisson status to d2hmb_state(defined in mtk_spis_private...
The common configuration can be set for the SPIS HW.
Definition: mhal_spis.h:747
spis idle
Definition: mhal_spis.h:688
int mtk_mhal_spis_setup_hw(struct mtk_spis_controller *ctlr, struct mtk_spis_config *config)
This function is used to initialize SPIS HW based on *config settings.
spis_cpha
SPI slave's clock format definition.
Definition: mhal_spis.h:639
spim reads spis status
Definition: mhal_spis.h:656
spim sends H2DMB to spis
Definition: mhal_spis.h:662
spim wants to read data
Definition: mhal_spis.h:704
dma_addr_t rx_dma
RX DMA physical addr, it's the PA of mtk_spis_transfer->rx_buf.
Definition: mhal_spis.h:785
spis_direction_cmd
SPI transmission direction cmd definition.
Definition: mhal_spis.h:702
int mtk_mhal_spis_dma_transfer_one(struct mtk_spis_controller *ctlr, struct mtk_spis_transfer *xfer)
This function is used to perform a single mtk_spis_transfer by DMA mode.
int mtk_mhal_spis_enable_clk(struct mtk_spis_controller *ctlr)
This function is used to enable SPIS clock before transfer.
Clock polarity is 1.
Definition: mhal_spis.h:631
spis_d2hmb_state
SPI slave's supported transaction status.
Definition: mhal_spis.h:686
void * spis_tx_buf
Data to be written (DMA-safe memory), or NULL.
Definition: mhal_spis.h:808
int direction
Spim read or write data, 0: Read(spis TX), 1: Write(spis RX)
Definition: mhal_spis.h:767
SPIM write IRQ/MB to SPIS(SPIS RX)
Definition: mhal_spis.h:678
Clock polarity is 0.
Definition: mhal_spis.h:629
SPIM read data from SPIS(SPIS TX)
Definition: mhal_spis.h:672
void * spis_rx_buf
Data to be read (DMA-safe memory), or NULL.
Definition: mhal_spis.h:810
spis transfer error
Definition: mhal_spis.h:694
enum spis_cpol cpol
clock polarity
Definition: mhal_spis.h:749
I/O INTERFACE between SPI OS-HAL and M-HAL.
Definition: mhal_spis.h:759
int mtk_mhal_spis_clear_irq_status(struct mtk_spis_controller *ctlr)
This function is used to clear SPIS HW status.
spis preparation transfer ready
Definition: mhal_spis.h:690
int dma_rx_chan
RX DMA channel.
Definition: mhal_spis.h:806
spim sets spis irq
Definition: mhal_spis.h:658
void * rx_buf
Data to be read (DMA-safe memory), or NULL.
Definition: mhal_spis.h:763
spis transfer done
Definition: mhal_spis.h:692
int mtk_mhal_spis_disable_clk(struct mtk_spis_controller *ctlr)
This function is used to disable SPIS clock before transfer.
SPIM read SPIS_STATUS from SPIS(SPIS TX)
Definition: mhal_spis.h:676
unsigned int len
Size of rx and tx buffers (in bytes)
Definition: mhal_spis.h:765
int mtk_mhal_spis_handle_h2dmb(struct mtk_spis_controller *ctlr)
This function is used to handle H2DMB which is sent from spi master.
int use_dma
Spis support FIFO and DMA mode, 0:FIFO, 1: DMA.
Definition: mhal_spis.h:769
spim reads data from spis
Definition: mhal_spis.h:654
enum spis_cpha cpha
clock phase
Definition: mhal_spis.h:751
int mtk_mhal_spis_dma_done_callback_register(struct mtk_spis_controller *ctlr, spis_dma_done_callback callback)
This function is used to register user's DMA callback to M-HAL.
int dma_tx_chan
TX DMA channel.
Definition: mhal_spis.h:804
spim clears spis D2HMB
Definition: mhal_spis.h:660