36 #ifndef __MHAL_I2C__H__
37 #define __MHAL_I2C__H__
39 #include "mhal_osai.h"
120 #define I2C_EINVAL 22
122 #define I2C_ETIMEDOUT 110
125 #define I2C_TRANS_DONE 0
129 #define I2C_WAIT_DMA 1
Transmit data with 1000 kbps.
Definition: mhal_i2c.h:156
int mtk_mhal_i2c_disable_clk(struct mtk_i2c_controller *i2c)
This function is used to disable I2C clock after transfer.
int mtk_mhal_i2c_dump_register(struct mtk_i2c_controller *i2c)
This function is used to dump I2C register value for debugging.
u8 msg_num
The number of message.
Definition: mhal_i2c.h:294
i2c_speed_kHz
I2C master's clock frequency definition.
Definition: mhal_i2c.h:146
int mtk_mhal_i2c_irq_handle(struct mtk_i2c_controller *i2c)
Get I2C irq status and clear irq status reg.
Set I2C controller to master role.
Definition: mhal_i2c.h:181
void __iomem * base
I2C controller base address.
Definition: mhal_i2c.h:280
u32 rx_len
Temp transfer length to DMA.
Definition: mhal_i2c.h:262
Transmit data with 100 kbps.
Definition: mhal_i2c.h:150
I2C master reads data from slave.
Definition: mhal_i2c.h:168
void __iomem * cg_base
Clock gate base address of I2C controller.
Definition: mhal_i2c.h:283
u32 irq_stat
Interrupt flag, this parameter will be set in mtk_mhal_i2c_irq_handle().
Definition: mhal_i2c.h:303
int mtk_mhal_i2c_trigger_transfer(struct mtk_i2c_controller *i2c)
This function is used to trigger I2C controller transfer.
Interface to messages.
Definition: mhal_i2c.h:228
u32 tx_len
Temp transfer length to DMA.
Definition: mhal_i2c.h:260
u8 * buf
Pointer to read or write data buffer.
Definition: mhal_i2c.h:243
bool dma_en
I2C supports FIFO mode and DMA mode, 0: FIFO mode, 1: DMA mode.
Definition: mhal_i2c.h:297
int mtk_mhal_i2c_enable_clk(struct mtk_i2c_controller *i2c)
Enable I2C clock before transfer.
enum i2c_trans_op flags
I2C transfer operation mode.
Definition: mhal_i2c.h:239
int(* i2c_dma_done_callback)(void *user_data)
This defines the callback function prototype.
Definition: mhal_i2c.h:211
struct mtk_i2c_private * mdata
M-HAL private structure is used by M-HAL only.
Definition: mhal_i2c.h:321
u16 len
Read or write data length, unit: byte.
Definition: mhal_i2c.h:241
u32 timeout
Set the transmission timeout period.
Definition: mhal_i2c.h:306
enum i2c_trans_mode i2c_mode
0: Set I2C controller as a master or slave role
Definition: mhal_i2c.h:312
u8 addr
The address of slave device which the master access.
Definition: mhal_i2c.h:232
u8 * tx_buff
used for tx temp buf
Definition: mhal_i2c.h:252
Transmit data with 200 kbps.
Definition: mhal_i2c.h:152
int mtk_mhal_i2c_init_slv_addr(struct mtk_i2c_controller *i2c, u8 slv_addr)
This function is used to set I2C salve address.
M-HAL private structure.
Definition: mhal_i2c.h:250
i2c_dma_done_callback dma_done_callback
This function is used to register user's DMA done callback to OS-HAL layer.
Definition: mhal_i2c.h:271
int mtk_mhal_i2c_result_handle(struct mtk_i2c_controller *i2c)
This fuction is used to analyze the type of i2c interrupt.
void * user_data
User_data is an OS-HAL defined parameter provided by mtk_mhal_i2c_dma_done_callback_register().
Definition: mhal_i2c.h:266
int mtk_mhal_i2c_init_hw(struct mtk_i2c_controller *i2c)
This function is used to initialize I2C and DMA hardware.
u8 slave_addr
Set i2c slave address, default by 0x20.
Definition: mhal_i2c.h:318
i2c_trans_mode
Definition: mhal_i2c.h:179
dma_addr_t rx_dma_addr
temp rx DMA physical addr
Definition: mhal_i2c.h:258
The mtk_i2c_controller contains hardware information( such as base address) of i2c controller...
Definition: mhal_i2c.h:278
int mtk_mhal_i2c_release_dma(struct mtk_i2c_controller *i2c)
This function is used to release I2C DMA channel.
enum i2c_speed_kHz i2c_speed
I2C master transfer speed.
Definition: mhal_i2c.h:309
u8 op
I2C master transfer mode, it is used to HDL driver.
Definition: mhal_i2c.h:315
struct i2c_msg * msg
Configure I2C transfer message.
Definition: mhal_i2c.h:291
I2C slave sends data to master.
Definition: mhal_i2c.h:172
Transmit data with 50 kbps.
Definition: mhal_i2c.h:148
I2C slave receives data from master.
Definition: mhal_i2c.h:170
i2c_trans_op
I2C controller operation mode definition.
Definition: mhal_i2c.h:164
I2C master writes data to slave.
Definition: mhal_i2c.h:166
u8 * rx_buff
used for rx temp buf
Definition: mhal_i2c.h:254
int mtk_mhal_i2c_dma_done_callback_register(struct mtk_i2c_controller *i2c, i2c_dma_done_callback callback, void *user_data)
This defines the callback function prototype.
int dma_rx_chan
RX DMA channel.
Definition: mhal_i2c.h:288
Transmit data with 400 kbps.
Definition: mhal_i2c.h:154
int dma_tx_chan
TX DMA channel.
Definition: mhal_i2c.h:286
int mtk_mhal_i2c_init_speed(struct mtk_i2c_controller *i2c, enum i2c_speed_kHz)
This function is used to initialize transfer speed.
Set I2C controller to slave role.
Definition: mhal_i2c.h:183
dma_addr_t tx_dma_addr
temp tx DMA physical addr
Definition: mhal_i2c.h:256
int mtk_mhal_i2c_request_dma(struct mtk_i2c_controller *i2c)
This function is used to allocate I2C DMA channel.