Konstantin Porotchkin | 73cd881 | 2018-02-26 16:06:35 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 Marvell International Ltd. |
Icenowy Zheng | d9cb895 | 2018-07-21 19:06:46 +0800 | [diff] [blame] | 3 | * Copyright (C) 2018 Icenowy Zheng <icenowy@aosc.io> |
Konstantin Porotchkin | 73cd881 | 2018-02-26 16:06:35 +0200 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | * https://spdx.org/licenses |
| 7 | */ |
| 8 | |
Icenowy Zheng | d9cb895 | 2018-07-21 19:06:46 +0800 | [diff] [blame] | 9 | /* This driver provides support for Mentor Graphics MI2CV IP core */ |
Konstantin Porotchkin | 73cd881 | 2018-02-26 16:06:35 +0200 | [diff] [blame] | 10 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 11 | #ifndef MI2CV_H |
| 12 | #define MI2CV_H |
Konstantin Porotchkin | 73cd881 | 2018-02-26 16:06:35 +0200 | [diff] [blame] | 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); |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 39 | |
| 40 | #endif /* MI2CV_H */ |