1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2019 Intel Corporation
5 #include "opae_osdep.h"
7 #include "opae_at24_eeprom.h"
9 #define AT24_READ_RETRY 10
11 static int at24_eeprom_read_and_try(struct altera_i2c_dev *dev,
12 unsigned int slave_addr,
13 u32 offset, u8 *buf, u32 len)
18 for (i = 0; i < AT24_READ_RETRY; i++) {
19 ret = i2c_read16(dev, slave_addr, offset,
30 int at24_eeprom_read(struct altera_i2c_dev *dev, unsigned int slave_addr,
31 u32 offset, u8 *buf, int count)
40 if (count > AT24C512_IO_LIMIT)
41 len = AT24C512_IO_LIMIT;
46 status = at24_eeprom_read_and_try(dev, slave_addr, offset,
60 int at24_eeprom_write(struct altera_i2c_dev *dev, unsigned int slave_addr,
61 u32 offset, u8 *buf, int count)
70 if (count > AT24C512_PAGE_SIZE)
71 len = AT24C512_PAGE_SIZE;
76 status = i2c_write16(dev, slave_addr, offset, buf, len);