i2c_eeprom.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. int (*size)(struct udevice *dev);
  12. };
  13. struct i2c_eeprom {
  14. /* The EEPROM's page size in byte */
  15. unsigned long pagesize;
  16. /* The EEPROM's capacity in bytes */
  17. unsigned long size;
  18. };
  19. /*
  20. * i2c_eeprom_read() - read bytes from an I2C EEPROM chip
  21. *
  22. * @dev: Chip to read from
  23. * @offset: Offset within chip to start reading
  24. * @buf: Place to put data
  25. * @size: Number of bytes to read
  26. *
  27. * @return 0 on success, -ve on failure
  28. */
  29. int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf, int size);
  30. /*
  31. * i2c_eeprom_write() - write bytes to an I2C EEPROM chip
  32. *
  33. * @dev: Chip to write to
  34. * @offset: Offset within chip to start writing
  35. * @buf: Buffer containing data to write
  36. * @size: Number of bytes to write
  37. *
  38. * @return 0 on success, -ve on failure
  39. */
  40. int i2c_eeprom_write(struct udevice *dev, int offset, uint8_t *buf, int size);
  41. /*
  42. * i2c_eeprom_size() - get size of I2C EEPROM chip
  43. *
  44. * @dev: Chip to query
  45. *
  46. * @return +ve size in bytes on success, -ve on failure
  47. */
  48. int i2c_eeprom_size(struct udevice *dev);
  49. #endif