X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=include%2Fi2c_eeprom.h;h=b96254ae79f5bb7cc071e005efd41934f92e5d56;hb=80e99adbe47d1c8590f9b971ac52257fdc51a5ec;hp=ea6c962a3932f3bc7a28276a93e2bc9c45f2a2cf;hpb=e3bf81b1e841ecabe7c8b3d48621256db8b8623e;p=oweals%2Fu-boot.git diff --git a/include/i2c_eeprom.h b/include/i2c_eeprom.h index ea6c962a39..b96254ae79 100644 --- a/include/i2c_eeprom.h +++ b/include/i2c_eeprom.h @@ -1,7 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (c) 2014 Google, Inc - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef __I2C_EEPROM @@ -11,9 +10,49 @@ struct i2c_eeprom_ops { int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size); int (*write)(struct udevice *dev, int offset, const uint8_t *buf, int size); + int (*size)(struct udevice *dev); }; struct i2c_eeprom { + /* The EEPROM's page size in byte */ + unsigned long pagesize; + /* The EEPROM's page width in bits (pagesize = 2^pagewidth) */ + unsigned pagewidth; + /* The EEPROM's capacity in bytes */ + unsigned long size; }; +/* + * i2c_eeprom_read() - read bytes from an I2C EEPROM chip + * + * @dev: Chip to read from + * @offset: Offset within chip to start reading + * @buf: Place to put data + * @size: Number of bytes to read + * + * @return 0 on success, -ve on failure + */ +int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf, int size); + +/* + * i2c_eeprom_write() - write bytes to an I2C EEPROM chip + * + * @dev: Chip to write to + * @offset: Offset within chip to start writing + * @buf: Buffer containing data to write + * @size: Number of bytes to write + * + * @return 0 on success, -ve on failure + */ +int i2c_eeprom_write(struct udevice *dev, int offset, uint8_t *buf, int size); + +/* + * i2c_eeprom_size() - get size of I2C EEPROM chip + * + * @dev: Chip to query + * + * @return +ve size in bytes on success, -ve on failure + */ +int i2c_eeprom_size(struct udevice *dev); + #endif