Simon Glass | 6ca4ba0 | 2014-12-10 08:55:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 Google, Inc |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #ifndef __I2C_EEPROM |
| 8 | #define __I2C_EEPROM |
| 9 | |
| 10 | struct i2c_eeprom_ops { |
| 11 | int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size); |
| 12 | int (*write)(struct udevice *dev, int offset, const uint8_t *buf, |
| 13 | int size); |
| 14 | }; |
| 15 | |
| 16 | struct i2c_eeprom { |
mario.six@gdsys.cc | 7559ac4 | 2016-06-22 15:14:16 +0200 | [diff] [blame] | 17 | /* The EEPROM's page size in byte */ |
| 18 | unsigned long pagesize; |
| 19 | /* The EEPROM's page width in bits (pagesize = 2^pagewidth) */ |
| 20 | unsigned pagewidth; |
Simon Glass | 6ca4ba0 | 2014-12-10 08:55:54 -0700 | [diff] [blame] | 21 | }; |
| 22 | |
Jonas Karlman | 8427a24 | 2017-04-22 08:57:41 +0000 | [diff] [blame] | 23 | /* |
| 24 | * i2c_eeprom_read() - read bytes from an I2C EEPROM chip |
| 25 | * |
| 26 | * @dev: Chip to read from |
| 27 | * @offset: Offset within chip to start reading |
| 28 | * @buf: Place to put data |
| 29 | * @size: Number of bytes to read |
| 30 | * |
| 31 | * @return 0 on success, -ve on failure |
| 32 | */ |
| 33 | int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf, int size); |
| 34 | |
| 35 | /* |
| 36 | * i2c_eeprom_write() - write bytes to an I2C EEPROM chip |
| 37 | * |
| 38 | * @dev: Chip to write to |
| 39 | * @offset: Offset within chip to start writing |
| 40 | * @buf: Buffer containing data to write |
| 41 | * @size: Number of bytes to write |
| 42 | * |
| 43 | * @return 0 on success, -ve on failure |
| 44 | */ |
| 45 | int i2c_eeprom_write(struct udevice *dev, int offset, uint8_t *buf, int size); |
| 46 | |
Simon Glass | 6ca4ba0 | 2014-12-10 08:55:54 -0700 | [diff] [blame] | 47 | #endif |