Vladimir Serbinenko (phcoder(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4774
-gerrit
commit 57a5b0b0c7ae17c6e82d55b5b63d8d3863b423fe
Author: Vladimir Serbinenko <phcoder(a)gmail.com>
Date: Thu Jan 23 09:06:08 2014 +0100
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(a)gmail.com>
---
src/drivers/i2c/Makefile.inc | 1 +
src/drivers/i2c/lenovo/Makefile.inc | 1 +
src/drivers/i2c/lenovo/eeprom.c | 193 ++++++++++++++++++++++++++++++++
src/mainboard/lenovo/t60/devicetree.cb | 25 +++++
src/mainboard/lenovo/x201/devicetree.cb | 25 +++++
src/mainboard/lenovo/x230/devicetree.cb | 28 ++++-
src/mainboard/lenovo/x60/devicetree.cb | 26 ++++-
7 files changed, 297 insertions(+), 2 deletions(-)
diff --git a/src/drivers/i2c/Makefile.inc b/src/drivers/i2c/Makefile.inc
index ef7ac4b..2cd1db0 100644
--- a/src/drivers/i2c/Makefile.inc
+++ b/src/drivers/i2c/Makefile.inc
@@ -7,3 +7,4 @@ subdirs-y += lm63
subdirs-y += rtd2132
subdirs-y += w83795
subdirs-y += w83793
+subdirs-y += lenovo
diff --git a/src/drivers/i2c/lenovo/Makefile.inc b/src/drivers/i2c/lenovo/Makefile.inc
new file mode 100644
index 0000000..87f0dbf
--- /dev/null
+++ b/src/drivers/i2c/lenovo/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_VENDOR_LENOVO) += eeprom.c
diff --git a/src/drivers/i2c/lenovo/eeprom.c b/src/drivers/i2c/lenovo/eeprom.c
new file mode 100644
index 0000000..faec7e9
--- /dev/null
+++ b/src/drivers/i2c/lenovo/eeprom.c
@@ -0,0 +1,193 @@
+/*
+ * 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 smbus_read_string(device_t dev, u8 start, u8 len, char *result)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ int t;
+ int j;
+ /* After a register write AT24RF08C (which we issued in init function) sometimes stops responding.
+ Retry several times in case of failure.
+ */
+ for (j = 0; j < 100; j++) {
+ t = smbus_read_byte(dev, start + i);
+ if (t >= 0)
+ break;
+ }
+ if (t < 0x20 || t > 0x7f) {
+ memcpy(result, "*INVALID*", sizeof ("*INVALID*"));
+ return;
+ }
+ result[i] = t;
+ }
+}
+
+const char *smbios_mainboard_serial_number(void)
+{
+ static char result[12];
+ static int already_read;
+ device_t dev;
+
+ if (already_read)
+ return result;
+
+ memset(result, 0, sizeof (result));
+
+ dev = dev_find_slot_on_smbus(1, 0x54);
+ if (dev == 0) {
+ printk(BIOS_WARNING, "eeprom not found\n");
+ already_read = 1;
+ return result;
+ }
+
+ smbus_read_string(dev, 0x2e, 7, result);
+ already_read = 1;
+ return result;
+}
+
+const char *smbios_mainboard_product_name(void)
+{
+ static char result[12];
+ static int already_read;
+ device_t dev;
+
+ if (already_read)
+ return result;
+ memset (result, 0, sizeof (result));
+
+ dev = dev_find_slot_on_smbus(1, 0x54);
+ if (dev == 0) {
+ printk(BIOS_WARNING, "eeprom not found\n");
+ already_read = 1;
+ return result;
+ }
+
+ smbus_read_string(dev, 0x27, 7, result);
+
+ already_read = 1;
+ return result;
+}
+
+void smbios_mainboard_set_uuid(u8 *uuid)
+{
+ static char result[16];
+ unsigned i;
+ static int already_read;
+ device_t dev;
+ const int remap[16] = {
+ /* UUID byteswap. */
+ 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15
+ };
+
+
+ if (already_read) {
+ memcpy (uuid, result, 16);
+ return;
+ }
+
+ memset (result, 0, sizeof (result));
+
+ dev = dev_find_slot_on_smbus(1, 0x56);
+ if (dev == 0) {
+ printk(BIOS_WARNING, "eeprom not found\n");
+ already_read = 1;
+ memset (uuid, 0, 16);
+ return;
+ }
+
+ for (i = 0; i < 16; i++) {
+ int t;
+ int j;
+ /* After a register write AT24RF08C (which we issued in init function) sometimes stops responding.
+ Retry several times in case of failure.
+ */
+ for (j = 0; j < 100; j++) {
+ t = smbus_read_byte(dev, 0x12 + i);
+ if (t >= 0)
+ break;
+ }
+ if (t < 0) {
+ memset (result, 0, sizeof (result));
+ break;
+ }
+ result[remap[i]] = t;
+ }
+
+ already_read = 1;
+
+ memcpy (uuid, result, 16);
+}
+
+static void lenovo_eeprom_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 lenovo_eeprom_noop(device_t dummy)
+{
+}
+
+static struct device_operations lenovo_eeprom_operations = {
+ .read_resources = lenovo_eeprom_noop,
+ .set_resources = lenovo_eeprom_noop,
+ .enable_resources = lenovo_eeprom_noop,
+ .init = lenovo_eeprom_init,
+};
+
+static void enable_dev(device_t dev)
+{
+ dev->ops = &lenovo_eeprom_operations;
+}
+
+struct chip_operations drivers_i2c_lenovo_ops = {
+ CHIP_NAME("Lenovo EEPROM")
+ .enable_dev = enable_dev,
+};
diff --git a/src/mainboard/lenovo/t60/devicetree.cb b/src/mainboard/lenovo/t60/devicetree.cb
index 899ea5a..3e8d531 100644
--- a/src/mainboard/lenovo/t60/devicetree.cb
+++ b/src/mainboard/lenovo/t60/devicetree.cb
@@ -213,6 +213,31 @@ chip northbridge/intel/i945
register "reg11" = "0x07"
device i2c 69 on end
end
+ # eeprom, 8 virtual devices, same chip
+ chip drivers/i2c/lenovo
+ device i2c 54 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 55 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 56 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 57 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5c on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5d on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5e on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5f on end
+ end
end
end
end
diff --git a/src/mainboard/lenovo/x201/devicetree.cb b/src/mainboard/lenovo/x201/devicetree.cb
index a8831c2..0502ad7 100644
--- a/src/mainboard/lenovo/x201/devicetree.cb
+++ b/src/mainboard/lenovo/x201/devicetree.cb
@@ -145,6 +145,31 @@ chip northbridge/intel/nehalem
end
device pci 1f.3 on # SMBUS
subsystemid 0x17aa 0x2167
+ # eeprom, 8 virtual devices, same chip
+ chip drivers/i2c/lenovo
+ device i2c 54 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 55 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 56 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 57 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5c on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5d on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5e on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5f on end
+ end
end
end
end
diff --git a/src/mainboard/lenovo/x230/devicetree.cb b/src/mainboard/lenovo/x230/devicetree.cb
index 3650b38..5e12151 100644
--- a/src/mainboard/lenovo/x230/devicetree.cb
+++ b/src/mainboard/lenovo/x230/devicetree.cb
@@ -127,7 +127,33 @@ chip northbridge/intel/sandybridge
end
end # LPC bridge
device pci 1f.2 on end # SATA Controller 1
- device pci 1f.3 on end # SMBus
+ device pci 1f.3 on
+ # eeprom, 8 virtual devices, same chip
+ chip drivers/i2c/lenovo
+ device i2c 54 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 55 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 56 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 57 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5c on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5d on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5e on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5f on end
+ end
+ end # SMBus
device pci 1f.5 off end # SATA Controller 2
device pci 1f.6 on end # Thermal
end
diff --git a/src/mainboard/lenovo/x60/devicetree.cb b/src/mainboard/lenovo/x60/devicetree.cb
index cfbb9db..5057f2e 100644
--- a/src/mainboard/lenovo/x60/devicetree.cb
+++ b/src/mainboard/lenovo/x60/devicetree.cb
@@ -190,7 +190,31 @@ chip northbridge/intel/i945
register "reg11" = "0x07"
device i2c 69 on end
end
-
+ # eeprom, 8 virtual devices, same chip
+ chip drivers/i2c/lenovo
+ device i2c 54 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 55 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 56 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 57 on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5c on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5d on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5e on end
+ end
+ chip drivers/i2c/lenovo
+ device i2c 5f on end
+ end
end
end
chip southbridge/ricoh/rl5c476
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4842
-gerrit
commit 314169af304e7032477a58c9eb0581a6ebc40a6d
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Mon Jan 27 17:41:47 2014 -0600
NOTFORMERGE: abuild: Print how much disk space we've used
YOU SHALL NOT MERGE !!!
[image of Gandalf on stone walkway]
Sorry. Gandalf is temporarily unavailable.
Change-Id: I0faa7f3952621f8591e2ebf357f866515e15a2d2
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
util/abuild/abuild | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/abuild/abuild b/util/abuild/abuild
index ec5c27b..f7b808e 100755
--- a/util/abuild/abuild
+++ b/util/abuild/abuild
@@ -660,4 +660,6 @@ else
fi
junit '</testsuite>'
+du -sch coreboot-builds
+
exit $failed
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4842
-gerrit
commit f29ad7a0707b89a2b0314e997be30d00f2c32c24
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Mon Jan 27 17:41:47 2014 -0600
NOTFORMERGE: abuild: Print how much disk space we've used
YOU SHALL NOT MERGE !!!
[image of Gandalf on stone walkway]
Change-Id: I0faa7f3952621f8591e2ebf357f866515e15a2d2
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
util/abuild/abuild | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/abuild/abuild b/util/abuild/abuild
index ec5c27b..f7b808e 100755
--- a/util/abuild/abuild
+++ b/util/abuild/abuild
@@ -660,4 +660,6 @@ else
fi
junit '</testsuite>'
+du -sch coreboot-builds
+
exit $failed
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4842
-gerrit
commit c943b34869f8dd837c90603efd97b2fb64d5f4af
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Mon Jan 27 17:41:47 2014 -0600
NOTFORMERGE: abuild: Print how much disk space we've used
YOU SHALL NOT MERGE!!!
[image of Gandalf on stone walkway]
Change-Id: I0faa7f3952621f8591e2ebf357f866515e15a2d2
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
util/abuild/abuild | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/abuild/abuild b/util/abuild/abuild
index ec5c27b..f7b808e 100755
--- a/util/abuild/abuild
+++ b/util/abuild/abuild
@@ -660,4 +660,6 @@ else
fi
junit '</testsuite>'
+du -sch coreboot-builds
+
exit $failed
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4842
-gerrit
commit 5f66b4b5e61c882a1d6d7d1325cb815d3e5e7b86
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Mon Jan 27 17:41:47 2014 -0600
NOTFORMERGE: abuild: Print how much disk space we've used
[image of Gandalf on stone walkway]
Change-Id: I0faa7f3952621f8591e2ebf357f866515e15a2d2
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
util/abuild/abuild | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/abuild/abuild b/util/abuild/abuild
index ec5c27b..f7b808e 100755
--- a/util/abuild/abuild
+++ b/util/abuild/abuild
@@ -660,4 +660,6 @@ else
fi
junit '</testsuite>'
+du -sch coreboot-builds
+
exit $failed
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4842
-gerrit
commit 7da9fbc7fe149f56a3a2491fd285cab50065a64a
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Mon Jan 27 17:41:47 2014 -0600
NOTFORMERGE: abuild: Print how much disk space we've used
Change-Id: I0faa7f3952621f8591e2ebf357f866515e15a2d2
Signed-off-by: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
---
util/abuild/abuild | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/abuild/abuild b/util/abuild/abuild
index ec5c27b..f7b808e 100755
--- a/util/abuild/abuild
+++ b/util/abuild/abuild
@@ -660,4 +660,6 @@ else
fi
junit '</testsuite>'
+du -sch coreboot-builds
+
exit $failed