coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
at24rf08c.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/device.h>
4 #include <device/smbus.h>
5 #include <console/console.h>
6 
7 static void at24rf08c_init(struct device *dev)
8 {
9  int i, j;
10 
11  if (!dev->enabled)
12  return;
13 
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;
18 
19  printk(BIOS_DEBUG, "Locking EEPROM RFID\n");
20 
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;
27  }
28 
29  printk(BIOS_DEBUG, "init EEPROM done\n");
30 }
31 
34  .set_resources = noop_set_resources,
35  .init = at24rf08c_init,
36 };
37 
38 static void enable_dev(struct device *dev)
39 {
40  dev->ops = &at24rf08c_operations;
41 }
42 
44  CHIP_NAME("AT24RF08C")
45  .enable_dev = enable_dev,
46 };
static struct device_operations at24rf08c_operations
Definition: at24rf08c.c:32
static void enable_dev(struct device *dev)
Definition: at24rf08c.c:38
struct chip_operations drivers_i2c_at24rf08c_ops
Definition: at24rf08c.c:43
static void at24rf08c_init(struct device *dev)
Definition: at24rf08c.c:7
#define printk(level,...)
Definition: stdlib.h:16
#define CHIP_NAME(X)
Definition: device.h:32
static void noop_read_resources(struct device *dev)
Standard device operations function pointers shims.
Definition: device.h:73
static void noop_set_resources(struct device *dev)
Definition: device.h:74
static int smbus_write_byte(struct device *const dev, u8 addr, u8 val)
Definition: smbus.h:48
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
@ DEVICE_PATH_I2C
Definition: path.h:11
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct i2c_path i2c
Definition: path.h:118
enum device_path_type type
Definition: path.h:114
Definition: device.h:107
struct device_path path
Definition: device.h:115
struct device_operations * ops
Definition: device.h:143
unsigned int enabled
Definition: device.h:122
unsigned int device
Definition: path.h:63