xref: /arm-trusted-firmware/include/drivers/mentor/mi2cv.h (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (C) 2018 Marvell International Ltd.
3*91f16700Schasinglulu  * Copyright (C) 2018 Icenowy Zheng <icenowy@aosc.io>
4*91f16700Schasinglulu  *
5*91f16700Schasinglulu  * SPDX-License-Identifier:     BSD-3-Clause
6*91f16700Schasinglulu  * https://spdx.org/licenses
7*91f16700Schasinglulu  */
8*91f16700Schasinglulu 
9*91f16700Schasinglulu /* This driver provides support for Mentor Graphics MI2CV IP core */
10*91f16700Schasinglulu 
11*91f16700Schasinglulu #ifndef MI2CV_H
12*91f16700Schasinglulu #define MI2CV_H
13*91f16700Schasinglulu 
14*91f16700Schasinglulu #include <stdint.h>
15*91f16700Schasinglulu 
16*91f16700Schasinglulu /*
17*91f16700Schasinglulu  * Initialization, must be called once on start up, may be called
18*91f16700Schasinglulu  * repeatedly to change the speed and slave addresses.
19*91f16700Schasinglulu  */
20*91f16700Schasinglulu void i2c_init(void *i2c_base);
21*91f16700Schasinglulu 
22*91f16700Schasinglulu /*
23*91f16700Schasinglulu  * Read/Write interface:
24*91f16700Schasinglulu  *   chip:    I2C chip address, range 0..127
25*91f16700Schasinglulu  *   addr:    Memory (register) address within the chip
26*91f16700Schasinglulu  *   alen:    Number of bytes to use for addr (typically 1, 2 for larger
27*91f16700Schasinglulu  *              memories, 0 for register type devices with only one
28*91f16700Schasinglulu  *              register)
29*91f16700Schasinglulu  *   buffer:  Where to read/write the data
30*91f16700Schasinglulu  *   len:     How many bytes to read/write
31*91f16700Schasinglulu  *
32*91f16700Schasinglulu  *   Returns: 0 on success, not 0 on failure
33*91f16700Schasinglulu  */
34*91f16700Schasinglulu int i2c_read(uint8_t chip,
35*91f16700Schasinglulu 	     unsigned int addr, int alen, uint8_t *buffer, int len);
36*91f16700Schasinglulu 
37*91f16700Schasinglulu int i2c_write(uint8_t chip,
38*91f16700Schasinglulu 	      unsigned int addr, int alen, uint8_t *buffer, int len);
39*91f16700Schasinglulu 
40*91f16700Schasinglulu #endif /* MI2CV_H */
41