blob: 90fdb25232e9a32165f1a458a99a769ab6fef8f1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass6ca4ba02014-12-10 08:55:54 -07002/*
3 * Copyright (c) 2014 Google, Inc
Simon Glass6ca4ba02014-12-10 08:55:54 -07004 */
5
6#ifndef __I2C_EEPROM
7#define __I2C_EEPROM
8
9struct 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 Beckett069ddc72019-10-28 18:29:06 +000013 int (*size)(struct udevice *dev);
Simon Glass6ca4ba02014-12-10 08:55:54 -070014};
15
16struct i2c_eeprom {
mario.six@gdsys.cc7559ac42016-06-22 15:14:16 +020017 /* The EEPROM's page size in byte */
18 unsigned long pagesize;
Robert Beckett069ddc72019-10-28 18:29:06 +000019 /* The EEPROM's capacity in bytes */
20 unsigned long size;
Simon Glass6ca4ba02014-12-10 08:55:54 -070021};
22
Jonas Karlman8427a242017-04-22 08:57:41 +000023/*
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 Schuchardt47b4c022022-01-19 18:05:50 +010031 * Return: 0 on success, -ve on failure
Jonas Karlman8427a242017-04-22 08:57:41 +000032 */
33int 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 Schuchardt47b4c022022-01-19 18:05:50 +010043 * Return: 0 on success, -ve on failure
Jonas Karlman8427a242017-04-22 08:57:41 +000044 */
Sean Anderson4a55f9d2022-05-05 13:11:37 -040045int i2c_eeprom_write(struct udevice *dev, int offset, const uint8_t *buf,
46 int size);
Jonas Karlman8427a242017-04-22 08:57:41 +000047
Robert Beckett069ddc72019-10-28 18:29:06 +000048/*
49 * i2c_eeprom_size() - get size of I2C EEPROM chip
50 *
51 * @dev: Chip to query
52 *
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010053 * Return: +ve size in bytes on success, -ve on failure
Robert Beckett069ddc72019-10-28 18:29:06 +000054 */
55int i2c_eeprom_size(struct udevice *dev);
56
Simon Glass6ca4ba02014-12-10 08:55:54 -070057#endif