17e4d5620SIcenowy Zheng /* 27e4d5620SIcenowy Zheng * Copyright (C) 2018 Marvell International Ltd. 37e4d5620SIcenowy Zheng * Copyright (C) 2018 Icenowy Zheng <icenowy@aosc.io> 47e4d5620SIcenowy Zheng * 57e4d5620SIcenowy Zheng * SPDX-License-Identifier: BSD-3-Clause 67e4d5620SIcenowy Zheng * https://spdx.org/licenses 77e4d5620SIcenowy Zheng */ 87e4d5620SIcenowy Zheng 97e4d5620SIcenowy Zheng /* This driver provides support for Mentor Graphics MI2CV IP core */ 107e4d5620SIcenowy Zheng 11*c3cf06f1SAntonio Nino Diaz #ifndef MI2CV_H 12*c3cf06f1SAntonio Nino Diaz #define MI2CV_H 137e4d5620SIcenowy Zheng 147e4d5620SIcenowy Zheng #include <stdint.h> 157e4d5620SIcenowy Zheng 167e4d5620SIcenowy Zheng /* 177e4d5620SIcenowy Zheng * Initialization, must be called once on start up, may be called 187e4d5620SIcenowy Zheng * repeatedly to change the speed and slave addresses. 197e4d5620SIcenowy Zheng */ 207e4d5620SIcenowy Zheng void i2c_init(void *i2c_base); 217e4d5620SIcenowy Zheng 227e4d5620SIcenowy Zheng /* 237e4d5620SIcenowy Zheng * Read/Write interface: 247e4d5620SIcenowy Zheng * chip: I2C chip address, range 0..127 257e4d5620SIcenowy Zheng * addr: Memory (register) address within the chip 267e4d5620SIcenowy Zheng * alen: Number of bytes to use for addr (typically 1, 2 for larger 277e4d5620SIcenowy Zheng * memories, 0 for register type devices with only one 287e4d5620SIcenowy Zheng * register) 297e4d5620SIcenowy Zheng * buffer: Where to read/write the data 307e4d5620SIcenowy Zheng * len: How many bytes to read/write 317e4d5620SIcenowy Zheng * 327e4d5620SIcenowy Zheng * Returns: 0 on success, not 0 on failure 337e4d5620SIcenowy Zheng */ 347e4d5620SIcenowy Zheng int i2c_read(uint8_t chip, 357e4d5620SIcenowy Zheng unsigned int addr, int alen, uint8_t *buffer, int len); 367e4d5620SIcenowy Zheng 377e4d5620SIcenowy Zheng int i2c_write(uint8_t chip, 387e4d5620SIcenowy Zheng unsigned int addr, int alen, uint8_t *buffer, int len); 39*c3cf06f1SAntonio Nino Diaz 40*c3cf06f1SAntonio Nino Diaz #endif /* MI2CV_H */ 41