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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <device/device.h>
24 #include <device/smbus.h>
26 #include <console/console.h>
28 static void at24rf08c_init(device_t dev
)
35 /* Ensure that EEPROM/RFID chip is not accessible through RFID.
36 Need to do it only on 5c. */
37 if (dev
->path
.type
!= DEVICE_PATH_I2C
|| dev
->path
.i2c
.device
!= 0x5c)
40 printk (BIOS_DEBUG
, "Locking EEPROM RFID\n");
42 for (i
= 0; i
< 8; i
++)
44 /* After a register write AT24RF08C sometimes stops responding.
45 Retry several times in case of failure.
47 for (j
= 0; j
< 100; j
++)
48 if (smbus_write_byte(dev
, i
, 0x0f) >= 0)
52 printk (BIOS_DEBUG
, "init EEPROM done\n");
55 static void at24rf08c_noop(device_t dummy
)
59 static struct device_operations at24rf08c_operations
= {
60 .read_resources
= at24rf08c_noop
,
61 .set_resources
= at24rf08c_noop
,
62 .enable_resources
= at24rf08c_noop
,
63 .init
= at24rf08c_init
,
66 static void enable_dev(device_t dev
)
68 dev
->ops
= &at24rf08c_operations
;
71 struct chip_operations drivers_i2c_at24rf08c_ops
= {
72 CHIP_NAME("AT24RF08C")
73 .enable_dev
= enable_dev
,