1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2014 Google, Inc
11 struct i2c_eeprom_ops {
12 int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size);
13 int (*write)(struct udevice *dev, int offset, const uint8_t *buf,
15 int (*size)(struct udevice *dev);
19 /* The EEPROM's page size in byte */
20 unsigned long pagesize;
21 /* The EEPROM's capacity in bytes */
25 #if CONFIG_IS_ENABLED(I2C_EEPROM)
27 * i2c_eeprom_read() - read bytes from an I2C EEPROM chip
29 * @dev: Chip to read from
30 * @offset: Offset within chip to start reading
31 * @buf: Place to put data
32 * @size: Number of bytes to read
34 * Return: 0 on success, -ve on failure
36 int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf, int size);
39 * i2c_eeprom_write() - write bytes to an I2C EEPROM chip
41 * @dev: Chip to write to
42 * @offset: Offset within chip to start writing
43 * @buf: Buffer containing data to write
44 * @size: Number of bytes to write
46 * Return: 0 on success, -ve on failure
48 int i2c_eeprom_write(struct udevice *dev, int offset, const uint8_t *buf,
52 * i2c_eeprom_size() - get size of I2C EEPROM chip
56 * Return: +ve size in bytes on success, -ve on failure
58 int i2c_eeprom_size(struct udevice *dev);
60 #else /* !I2C_EEPROM */
62 static inline int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf,
68 static inline int i2c_eeprom_write(struct udevice *dev, int offset,
69 const uint8_t *buf, int size)
74 static inline int i2c_eeprom_size(struct udevice *dev)
79 #endif /* I2C_EEPROM */