i2c_eeprom.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2014 Google, Inc
  4. */
  5. #ifndef __I2C_EEPROM
  6. #define __I2C_EEPROM
  7. struct i2c_eeprom_ops {
  8. int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size);
  9. int (*write)(struct udevice *dev, int offset, const uint8_t *buf,
  10. int size);
  11. };
  12. struct i2c_eeprom {
  13. /* The EEPROM's page size in byte */
  14. unsigned long pagesize;
  15. /* The EEPROM's page width in bits (pagesize = 2^pagewidth) */
  16. unsigned pagewidth;
  17. };
  18. /*
  19. * i2c_eeprom_read() - read bytes from an I2C EEPROM chip
  20. *
  21. * @dev: Chip to read from
  22. * @offset: Offset within chip to start reading
  23. * @buf: Place to put data
  24. * @size: Number of bytes to read
  25. *
  26. * @return 0 on success, -ve on failure
  27. */
  28. int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf, int size);
  29. /*
  30. * i2c_eeprom_write() - write bytes to an I2C EEPROM chip
  31. *
  32. * @dev: Chip to write to
  33. * @offset: Offset within chip to start writing
  34. * @buf: Buffer containing data to write
  35. * @size: Number of bytes to write
  36. *
  37. * @return 0 on success, -ve on failure
  38. */
  39. int i2c_eeprom_write(struct udevice *dev, int offset, uint8_t *buf, int size);
  40. #endif