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