mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-11-29 22:51:49 +01:00
misc: i2c_eeprom: add eeprom write support
Write up to page size in each i2c transfer. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Reviewed-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
a29034d1e6
commit
84c80c63d5
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <i2c_eeprom.h>
|
#include <i2c_eeprom.h>
|
||||||
@ -38,7 +39,24 @@ static int i2c_eeprom_std_read(struct udevice *dev, int offset, uint8_t *buf,
|
|||||||
static int i2c_eeprom_std_write(struct udevice *dev, int offset,
|
static int i2c_eeprom_std_write(struct udevice *dev, int offset,
|
||||||
const uint8_t *buf, int size)
|
const uint8_t *buf, int size)
|
||||||
{
|
{
|
||||||
return -ENODEV;
|
struct i2c_eeprom *priv = dev_get_priv(dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
while (size > 0) {
|
||||||
|
int write_size = min_t(int, size, priv->pagesize);
|
||||||
|
|
||||||
|
ret = dm_i2c_write(dev, offset, buf, write_size);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
offset += write_size;
|
||||||
|
buf += write_size;
|
||||||
|
size -= write_size;
|
||||||
|
|
||||||
|
udelay(10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct i2c_eeprom_ops i2c_eeprom_std_ops = {
|
static const struct i2c_eeprom_ops i2c_eeprom_std_ops = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user