blob: 0fcdf3831b3a7394c3ca330c8a5260c9245e7439 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass20142012014-12-10 08:55:54 -07002/*
3 * Copyright (c) 2014 Google, Inc
Simon Glass20142012014-12-10 08:55:54 -07004 */
5
6#ifndef __I2C_EEPROM
7#define __I2C_EEPROM
8
9struct i2c_eeprom_ops {
10 int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size);
11 int (*write)(struct udevice *dev, int offset, const uint8_t *buf,
12 int size);
13};
14
15struct i2c_eeprom {
mario.six@gdsys.ccd7e28912016-06-22 15:14:16 +020016 /* The EEPROM's page size in byte */
17 unsigned long pagesize;
18 /* The EEPROM's page width in bits (pagesize = 2^pagewidth) */
19 unsigned pagewidth;
Simon Glass20142012014-12-10 08:55:54 -070020};
21
Jonas Karlman8880efb2017-04-22 08:57:41 +000022/*
23 * i2c_eeprom_read() - read bytes from an I2C EEPROM chip
24 *
25 * @dev: Chip to read from
26 * @offset: Offset within chip to start reading
27 * @buf: Place to put data
28 * @size: Number of bytes to read
29 *
30 * @return 0 on success, -ve on failure
31 */
32int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf, int size);
33
34/*
35 * i2c_eeprom_write() - write bytes to an I2C EEPROM chip
36 *
37 * @dev: Chip to write to
38 * @offset: Offset within chip to start writing
39 * @buf: Buffer containing data to write
40 * @size: Number of bytes to write
41 *
42 * @return 0 on success, -ve on failure
43 */
44int i2c_eeprom_write(struct udevice *dev, int offset, uint8_t *buf, int size);
45
Simon Glass20142012014-12-10 08:55:54 -070046#endif