libpayload: configs: Add new config.featuretest to broaden CI
[coreboot2.git] / src / drivers / i2c / at24rf08c / at24rf08c.c
blob99ea7a47f0ef6a23df0e927570f13fc8202853c7
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/device.h>
4 #include <device/smbus.h>
5 #include <console/console.h>
7 static void at24rf08c_init(struct device *dev)
9 int i, j;
11 if (!dev->enabled)
12 return;
14 /* Ensure that EEPROM/RFID chip is not accessible through RFID.
15 Need to do it only on 5c. */
16 if (dev->path.type != DEVICE_PATH_I2C || dev->path.i2c.device != 0x5c)
17 return;
19 printk(BIOS_DEBUG, "Locking EEPROM RFID\n");
21 for (i = 0; i < 8; i++) {
22 /* After a register write AT24RF08C sometimes stops responding.
23 Retry several times in case of failure. */
24 for (j = 0; j < 100; j++)
25 if (smbus_write_byte(dev, i, 0x0f) >= 0)
26 break;
29 printk(BIOS_DEBUG, "init EEPROM done\n");
32 static struct device_operations at24rf08c_operations = {
33 .read_resources = noop_read_resources,
34 .set_resources = noop_set_resources,
35 .init = at24rf08c_init,
38 static void enable_dev(struct device *dev)
40 dev->ops = &at24rf08c_operations;
43 struct chip_operations drivers_i2c_at24rf08c_ops = {
44 .name = "AT24RF08C",
45 .enable_dev = enable_dev,