]> git.ipfire.org Git - people/ms/u-boot.git/blame - drivers/misc/i2c_eeprom.c
drivers/phy: Add Marvell SerDes / PHY drivers used on Armada 3k
[people/ms/u-boot.git] / drivers / misc / i2c_eeprom.c
CommitLineData
20142019
SG
1/*
2 * Copyright (c) 2014 Google, Inc
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
ee5ee876 8#include <linux/err.h>
20142019
SG
9#include <dm.h>
10#include <i2c.h>
11#include <i2c_eeprom.h>
12
13static int i2c_eeprom_read(struct udevice *dev, int offset, uint8_t *buf,
14 int size)
15{
d7e28918 16 return dm_i2c_read(dev, offset, buf, size);
20142019
SG
17}
18
19static int i2c_eeprom_write(struct udevice *dev, int offset,
20 const uint8_t *buf, int size)
21{
22 return -ENODEV;
23}
24
25struct i2c_eeprom_ops i2c_eeprom_std_ops = {
26 .read = i2c_eeprom_read,
27 .write = i2c_eeprom_write,
28};
29
d7e28918 30static int i2c_eeprom_std_ofdata_to_platdata(struct udevice *dev)
31{
32 struct i2c_eeprom *priv = dev_get_priv(dev);
33 u64 data = dev_get_driver_data(dev);
34
35 /* 6 bit -> page size of up to 2^63 (should be sufficient) */
36 priv->pagewidth = data & 0x3F;
37 priv->pagesize = (1 << priv->pagewidth);
38
39 return 0;
40}
41
20142019
SG
42int i2c_eeprom_std_probe(struct udevice *dev)
43{
44 return 0;
45}
46
47static const struct udevice_id i2c_eeprom_std_ids[] = {
d7e28918 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 },
20142019
SG
59 { }
60};
61
62U_BOOT_DRIVER(i2c_eeprom_std) = {
d7e28918 63 .name = "i2c_eeprom",
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,
20142019
SG
70};
71
72UCLASS_DRIVER(i2c_eeprom) = {
73 .id = UCLASS_I2C_EEPROM,
74 .name = "i2c_eeprom",
75};