На моей плате есть I2C EEPROM, в котором хранится информация о конфигурации. UBoot читает его с помощью функции read_eeprom, показанной ниже. Я также хотел бы получить доступ к этой информации изнутри ядра Linux, чтобы мои выходные данные /proc/cpuinfo отображались правильно. Однако я не могу найти эквивалентные функции i2c_probe и i2c_read в ядре Linux. Как мне выполнить следующие функции внутри ядра? Я использую линукс 3.2.
static int read_eeprom(void)
{
/* Check if baseboard eeprom is available */
if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {
puts("Could not probe the EEPROM; something fundamentally "
"wrong on the I2C bus.\n");
return -ENODEV;
}
/* read the eeprom using i2c */
if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)&header,
sizeof(header))) {
puts("Could not read the EEPROM; something fundamentally"
" wrong on the I2C bus.\n");
return -EIO;
}
if (header.magic != 0xEE3355AA) {
/*
* read the eeprom using i2c again,
* but use only a 1 byte address
*/
if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1,
(uchar *)&header, sizeof(header))) {
puts("Could not read the EEPROM; something "
"fundamentally wrong on the I2C bus.\n");
return -EIO;
}
if (header.magic != 0xEE3355AA) {
printf("Incorrect magic number (0x%x) in EEPROM\n",
header.magic);
return -EINVAL;
}
}
return 0;
}
EEPROM_ADDR
, а затем вам нужно заполнить переменные cpuinfo; уже сделано с ATAGS. - person artless noise   schedule 13.05.2014