summaryrefslogtreecommitdiff
path: root/src/drivers/i2c/at24rf08c/at24rf08c.c
diff options
context:
space:
mode:
authorVladimir Serbinenko <phcoder@gmail.com>2014-01-23 09:06:08 +0100
committerRudolf Marek <r.marek@assembler.cz>2014-02-01 18:48:16 +0100
commit62adc4c6101749d59bdcc36135556fc2d2482131 (patch)
tree2ae29f5a16f5fd1fa08c133fa588b0401770c9fd /src/drivers/i2c/at24rf08c/at24rf08c.c
parent5f20dbfbe38c6a7797b578f46006299a73d1bd90 (diff)
lenovo: Handle EEPROM/RFID chip.
EEPROM/RFID chip present in thinkpad should be locked in a way to avoid any potential RFID access. Read serial number, UUID and P/N from EEPROM. This info is stored on AT24RF08 chip acessible through SMBUS. Change-Id: Ia3e766d90a094f63c8c854cd37e165221ccd8acd Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com> Reviewed-on: http://review.coreboot.org/4774 Tested-by: build bot (Jenkins) Reviewed-by: Rudolf Marek <r.marek@assembler.cz>
Diffstat (limited to 'src/drivers/i2c/at24rf08c/at24rf08c.c')
-rw-r--r--src/drivers/i2c/at24rf08c/at24rf08c.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/drivers/i2c/at24rf08c/at24rf08c.c b/src/drivers/i2c/at24rf08c/at24rf08c.c
new file mode 100644
index 0000000000..a9cf2c5031
--- /dev/null
+++ b/src/drivers/i2c/at24rf08c/at24rf08c.c
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Vladimir Serbinenko
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <types.h>
+#include <string.h>
+#include <arch/io.h>
+#include <device/device.h>
+#include <device/smbus.h>
+#include <smbios.h>
+#include <console/console.h>
+
+static void at24rf08c_init(device_t dev)
+{
+ int i, j;
+
+ if (!dev->enabled)
+ return;
+
+ /* Ensure that EEPROM/RFID chip is not accessible through RFID.
+ Need to do it only on 5c. */
+ if (dev->path.type != DEVICE_PATH_I2C || dev->path.i2c.device != 0x5c)
+ return;
+
+ printk (BIOS_DEBUG, "Locking EEPROM RFID\n");
+
+ for (i = 0; i < 8; i++)
+ {
+ /* After a register write AT24RF08C sometimes stops responding.
+ Retry several times in case of failure.
+ */
+ for (j = 0; j < 100; j++)
+ if (smbus_write_byte(dev, i, 0x0f) >= 0)
+ break;
+ }
+
+ printk (BIOS_DEBUG, "init EEPROM done\n");
+}
+
+static void at24rf08c_noop(device_t dummy)
+{
+}
+
+static struct device_operations at24rf08c_operations = {
+ .read_resources = at24rf08c_noop,
+ .set_resources = at24rf08c_noop,
+ .enable_resources = at24rf08c_noop,
+ .init = at24rf08c_init,
+};
+
+static void enable_dev(device_t dev)
+{
+ dev->ops = &at24rf08c_operations;
+}
+
+struct chip_operations drivers_i2c_at24rf08c_ops = {
+ CHIP_NAME("AT24RF08C")
+ .enable_dev = enable_dev,
+};