lenovo: Read mainboard version from AT24RF08C.
Tablets have different mainboard version than laptop variants. Change-Id: I77a1e2b50d30dcf3fa064e0c378ceca7ccf96e89 Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com> Reviewed-on: http://review.coreboot.org/6785 Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Tested-by: build bot (Jenkins)
This commit is contained in:
parent
fc10c34266
commit
ed74dcd7f0
|
@ -26,35 +26,62 @@
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include "lenovo.h"
|
#include "lenovo.h"
|
||||||
|
|
||||||
static void at24rf08c_read_string(u8 bank, u8 start, u8 len, char *result)
|
#define ERROR_STRING "*INVALID*"
|
||||||
|
|
||||||
|
static device_t at24rf08c_find_bank(u8 bank)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
device_t dev;
|
device_t dev;
|
||||||
|
|
||||||
dev = dev_find_slot_on_smbus(1, 0x54 | bank);
|
dev = dev_find_slot_on_smbus(1, 0x54 | bank);
|
||||||
if (dev == 0) {
|
if (!dev)
|
||||||
printk(BIOS_WARNING, "EEPROM not found\n");
|
printk(BIOS_WARNING, "EEPROM not found\n");
|
||||||
memcpy(result, "*INVALID*", sizeof ("*INVALID*"));
|
return dev;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
static int at24rf08c_read_byte(device_t dev, u8 addr)
|
||||||
int t;
|
{
|
||||||
|
int t = -1;
|
||||||
int j;
|
int j;
|
||||||
/* After a register write AT24RF08C (which we issued in init function) sometimes stops responding.
|
|
||||||
Retry several times in case of failure.
|
/* 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++) {
|
for (j = 0; j < 100; j++) {
|
||||||
t = smbus_read_byte(dev, start + i);
|
t = smbus_read_byte(dev, addr);
|
||||||
if (t >= 0)
|
if (t >= 0)
|
||||||
break;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void at24rf08c_read_string_dev(device_t dev, u8 start,
|
||||||
|
u8 len, char *result)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
int t = at24rf08c_read_byte(dev, start + i);
|
||||||
|
|
||||||
if (t < 0x20 || t > 0x7f) {
|
if (t < 0x20 || t > 0x7f) {
|
||||||
memcpy(result, "*INVALID*", sizeof ("*INVALID*"));
|
memcpy(result, ERROR_STRING, sizeof (ERROR_STRING));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
result[i] = t;
|
result[i] = t;
|
||||||
}
|
}
|
||||||
|
result[len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
static void at24rf08c_read_string(u8 bank, u8 start, u8 len, char *result)
|
||||||
|
{
|
||||||
|
device_t dev;
|
||||||
|
|
||||||
|
dev = at24rf08c_find_bank(bank);
|
||||||
|
if (dev == 0) {
|
||||||
|
printk(BIOS_WARNING, "EEPROM not found\n");
|
||||||
|
memcpy(result, ERROR_STRING, sizeof (ERROR_STRING));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
at24rf08c_read_string_dev(dev, start, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *smbios_mainboard_serial_number(void)
|
const char *smbios_mainboard_serial_number(void)
|
||||||
|
@ -141,3 +168,33 @@ void smbios_mainboard_set_uuid(u8 *uuid)
|
||||||
|
|
||||||
memcpy (uuid, result, 16);
|
memcpy (uuid, result, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *smbios_mainboard_version(void)
|
||||||
|
{
|
||||||
|
static char result[100];
|
||||||
|
static int already_read;
|
||||||
|
device_t dev;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if (already_read)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
memset (result, 0, sizeof (result));
|
||||||
|
|
||||||
|
dev = at24rf08c_find_bank(2);
|
||||||
|
if (dev == 0) {
|
||||||
|
memcpy(result, ERROR_STRING, sizeof (ERROR_STRING));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = at24rf08c_read_byte(dev, 0x26) - 2;
|
||||||
|
if (len < 0 || len > sizeof(result) - 1) {
|
||||||
|
memcpy(result, ERROR_STRING, sizeof (ERROR_STRING));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
at24rf08c_read_string_dev(dev, 0x27, len, result);
|
||||||
|
|
||||||
|
already_read = 1;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -133,11 +133,6 @@ static int int15_handler(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *smbios_mainboard_version(void)
|
|
||||||
{
|
|
||||||
return "ThinkPad T520";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Audio Setup */
|
/* Audio Setup */
|
||||||
|
|
||||||
static void verb_setup(void)
|
static void verb_setup(void)
|
||||||
|
|
|
@ -133,11 +133,6 @@ static int int15_handler(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *smbios_mainboard_version(void)
|
|
||||||
{
|
|
||||||
return "ThinkPad T530";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Audio Setup */
|
/* Audio Setup */
|
||||||
|
|
||||||
static void verb_setup(void)
|
static void verb_setup(void)
|
||||||
|
|
|
@ -125,11 +125,6 @@ const char *smbios_mainboard_bios_version(void)
|
||||||
return "CBET4000 " COREBOOT_VERSION;
|
return "CBET4000 " COREBOOT_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *smbios_mainboard_version(void)
|
|
||||||
{
|
|
||||||
return "Lenovo X200";
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mainboard_smbios_data(device_t dev, int *handle, unsigned long *current)
|
static int mainboard_smbios_data(device_t dev, int *handle, unsigned long *current)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
|
@ -98,11 +98,6 @@ const char *smbios_mainboard_bios_version(void)
|
||||||
return "CBET4000 " COREBOOT_VERSION;
|
return "CBET4000 " COREBOOT_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *smbios_mainboard_version(void)
|
|
||||||
{
|
|
||||||
return "Lenovo X201";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Audio Setup */
|
/* Audio Setup */
|
||||||
|
|
||||||
static void verb_setup(void)
|
static void verb_setup(void)
|
||||||
|
|
|
@ -143,11 +143,6 @@ const char *smbios_mainboard_bios_version(void)
|
||||||
return "CBET4000 " COREBOOT_VERSION;
|
return "CBET4000 " COREBOOT_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *smbios_mainboard_version(void)
|
|
||||||
{
|
|
||||||
return "ThinkPad X220";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Audio Setup */
|
/* Audio Setup */
|
||||||
|
|
||||||
static void verb_setup(void)
|
static void verb_setup(void)
|
||||||
|
|
|
@ -143,11 +143,6 @@ const char *smbios_mainboard_bios_version(void)
|
||||||
return "CBET4000 " COREBOOT_VERSION;
|
return "CBET4000 " COREBOOT_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *smbios_mainboard_version(void)
|
|
||||||
{
|
|
||||||
return "ThinkPad X230";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Audio Setup */
|
/* Audio Setup */
|
||||||
|
|
||||||
static void verb_setup(void)
|
static void verb_setup(void)
|
||||||
|
|
Loading…
Reference in New Issue