blob: 6b03ed7f6ad79ce53a955cf5e4d06ebe3fbcfb0e [file] [log] [blame]
Konstantin Porotchkin73cd8812018-02-26 16:06:35 +02001/*
2 * Copyright (C) 2018 Marvell International Ltd.
Icenowy Zhengd9cb8952018-07-21 19:06:46 +08003 * Copyright (C) 2018 Icenowy Zheng <icenowy@aosc.io>
Konstantin Porotchkin73cd8812018-02-26 16:06:35 +02004 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 * https://spdx.org/licenses
7 */
8
Icenowy Zhengd9cb8952018-07-21 19:06:46 +08009/* This driver provides support for Mentor Graphics MI2CV IP core */
Konstantin Porotchkin73cd8812018-02-26 16:06:35 +020010
Icenowy Zhengd9cb8952018-07-21 19:06:46 +080011#ifndef _MI2CV_H_
12#define _MI2CV_H_
Konstantin Porotchkin73cd8812018-02-26 16:06:35 +020013
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 */
20void 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 */
34int i2c_read(uint8_t chip,
35 unsigned int addr, int alen, uint8_t *buffer, int len);
36
37int i2c_write(uint8_t chip,
38 unsigned int addr, int alen, uint8_t *buffer, int len);
39#endif