Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 2014201 | 2014-12-10 08:55:54 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014 Google, Inc |
Simon Glass | 2014201 | 2014-12-10 08:55:54 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef __I2C_EEPROM |
| 7 | #define __I2C_EEPROM |
| 8 | |
| 9 | struct i2c_eeprom_ops { |
| 10 | int (*read)(struct udevice *dev, int offset, uint8_t *buf, int size); |
| 11 | int (*write)(struct udevice *dev, int offset, const uint8_t *buf, |
| 12 | int size); |
Robert Beckett | 033e18b | 2019-10-28 18:29:06 +0000 | [diff] [blame] | 13 | int (*size)(struct udevice *dev); |
Simon Glass | 2014201 | 2014-12-10 08:55:54 -0700 | [diff] [blame] | 14 | }; |
| 15 | |
| 16 | struct i2c_eeprom { |
mario.six@gdsys.cc | d7e2891 | 2016-06-22 15:14:16 +0200 | [diff] [blame] | 17 | /* The EEPROM's page size in byte */ |
| 18 | unsigned long pagesize; |
Robert Beckett | 033e18b | 2019-10-28 18:29:06 +0000 | [diff] [blame] | 19 | /* The EEPROM's capacity in bytes */ |
| 20 | unsigned long size; |
Simon Glass | 2014201 | 2014-12-10 08:55:54 -0700 | [diff] [blame] | 21 | }; |
| 22 | |
Jonas Karlman | 8880efb | 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 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 31 | * Return: 0 on success, -ve on failure |
Jonas Karlman | 8880efb | 2017-04-22 08:57:41 +0000 | [diff] [blame] | 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 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 43 | * Return: 0 on success, -ve on failure |
Jonas Karlman | 8880efb | 2017-04-22 08:57:41 +0000 | [diff] [blame] | 44 | */ |
| 45 | int i2c_eeprom_write(struct udevice *dev, int offset, uint8_t *buf, int size); |
| 46 | |
Robert Beckett | 033e18b | 2019-10-28 18:29:06 +0000 | [diff] [blame] | 47 | /* |
| 48 | * i2c_eeprom_size() - get size of I2C EEPROM chip |
| 49 | * |
| 50 | * @dev: Chip to query |
| 51 | * |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 52 | * Return: +ve size in bytes on success, -ve on failure |
Robert Beckett | 033e18b | 2019-10-28 18:29:06 +0000 | [diff] [blame] | 53 | */ |
| 54 | int i2c_eeprom_size(struct udevice *dev); |
| 55 | |
Simon Glass | 2014201 | 2014-12-10 08:55:54 -0700 | [diff] [blame] | 56 | #endif |