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