2 * Copyright (c) 2014 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
11 #include <i2c_eeprom.h>
13 static int i2c_eeprom_read(struct udevice
*dev
, int offset
, uint8_t *buf
,
16 return dm_i2c_read(dev
, offset
, buf
, size
);
19 static int i2c_eeprom_write(struct udevice
*dev
, int offset
,
20 const uint8_t *buf
, int size
)
25 struct i2c_eeprom_ops i2c_eeprom_std_ops
= {
26 .read
= i2c_eeprom_read
,
27 .write
= i2c_eeprom_write
,
30 static int i2c_eeprom_std_ofdata_to_platdata(struct udevice
*dev
)
32 struct i2c_eeprom
*priv
= dev_get_priv(dev
);
33 u64 data
= dev_get_driver_data(dev
);
35 /* 6 bit -> page size of up to 2^63 (should be sufficient) */
36 priv
->pagewidth
= data
& 0x3F;
37 priv
->pagesize
= (1 << priv
->pagewidth
);
42 int i2c_eeprom_std_probe(struct udevice
*dev
)
47 static const struct udevice_id i2c_eeprom_std_ids
[] = {
48 { .compatible
= "i2c-eeprom", .data
= 0 },
49 { .compatible
= "atmel,24c01a", .data
= 3 },
50 { .compatible
= "atmel,24c02", .data
= 3 },
51 { .compatible
= "atmel,24c04", .data
= 4 },
52 { .compatible
= "atmel,24c08a", .data
= 4 },
53 { .compatible
= "atmel,24c16a", .data
= 4 },
54 { .compatible
= "atmel,24c32", .data
= 5 },
55 { .compatible
= "atmel,24c64", .data
= 5 },
56 { .compatible
= "atmel,24c128", .data
= 6 },
57 { .compatible
= "atmel,24c256", .data
= 6 },
58 { .compatible
= "atmel,24c512", .data
= 6 },
62 U_BOOT_DRIVER(i2c_eeprom_std
) = {
64 .id
= UCLASS_I2C_EEPROM
,
65 .of_match
= i2c_eeprom_std_ids
,
66 .probe
= i2c_eeprom_std_probe
,
67 .ofdata_to_platdata
= i2c_eeprom_std_ofdata_to_platdata
,
68 .priv_auto_alloc_size
= sizeof(struct i2c_eeprom
),
69 .ops
= &i2c_eeprom_std_ops
,
72 UCLASS_DRIVER(i2c_eeprom
) = {
73 .id
= UCLASS_I2C_EEPROM
,