2 * This file is part of the coreboot project.
4 * Copyright (C) 2013 Vladimir Serbinenko
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
19 #include <device/device.h>
20 #include <device/smbus.h>
22 #include <console/console.h>
24 static void at24rf08c_init(struct device
*dev
)
31 /* Ensure that EEPROM/RFID chip is not accessible through RFID.
32 Need to do it only on 5c. */
33 if (dev
->path
.type
!= DEVICE_PATH_I2C
|| dev
->path
.i2c
.device
!= 0x5c)
36 printk (BIOS_DEBUG
, "Locking EEPROM RFID\n");
38 for (i
= 0; i
< 8; i
++)
40 /* After a register write AT24RF08C sometimes stops responding.
41 Retry several times in case of failure.
43 for (j
= 0; j
< 100; j
++)
44 if (smbus_write_byte(dev
, i
, 0x0f) >= 0)
48 printk (BIOS_DEBUG
, "init EEPROM done\n");
51 static struct device_operations at24rf08c_operations
= {
52 .read_resources
= DEVICE_NOOP
,
53 .set_resources
= DEVICE_NOOP
,
54 .enable_resources
= DEVICE_NOOP
,
55 .init
= at24rf08c_init
,
58 static void enable_dev(struct device
*dev
)
60 dev
->ops
= &at24rf08c_operations
;
63 struct chip_operations drivers_i2c_at24rf08c_ops
= {
64 CHIP_NAME("AT24RF08C")
65 .enable_dev
= enable_dev
,