smbios: Add generic type41 write function
Mainboards were defining their own SMBIOS type41
write function. Instead pull this into the generic
SMBIOS code and change the existing mainboards to
make use of it.
BUG=chrome-os-partner:19035
BRANCH=none
TEST=manual: emerge-{link,parrot,butterfly}
chromeos-coreboot-{link,parrot,butterfly}
Change-Id: I3c8a95ca51fe2a3118dc8d1154011ccfed5fbcbc
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56619
Reviewed-by: Stefan Reinauer <reinauer@google.com>
This commit is contained in:
parent
e7e2c638e4
commit
2a28bb1374
5 changed files with 81 additions and 102 deletions
|
|
@ -269,6 +269,32 @@ static int smbios_write_type32(unsigned long *current, int handle)
|
|||
return len;
|
||||
}
|
||||
|
||||
int smbios_write_type41(unsigned long *current, int *handle,
|
||||
const char *name, u8 instance, u16 segment,
|
||||
u8 bus, u8 device, u8 function)
|
||||
{
|
||||
struct smbios_type41 *t = (struct smbios_type41 *)*current;
|
||||
int len = sizeof(struct smbios_type41);
|
||||
|
||||
memset(t, 0, sizeof(struct smbios_type41));
|
||||
t->type = SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION;
|
||||
t->handle = *handle;
|
||||
t->length = len - 2;
|
||||
t->reference_designation = smbios_add_string(t->eos, name);
|
||||
t->device_type = SMBIOS_DEVICE_TYPE_OTHER;
|
||||
t->device_status = 1;
|
||||
t->device_type_instance = instance;
|
||||
t->segment_group_number = segment;
|
||||
t->bus_number = bus;
|
||||
t->device_number = device;
|
||||
t->function_number = function;
|
||||
|
||||
len = t->length + smbios_string_table_len(t->eos);
|
||||
*current += len;
|
||||
*handle += 1;
|
||||
return len;
|
||||
}
|
||||
|
||||
static int smbios_write_type127(unsigned long *current, int handle)
|
||||
{
|
||||
struct smbios_type127 *t = (struct smbios_type127 *)*current;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ unsigned long smbios_write_tables(unsigned long start);
|
|||
int smbios_add_string(char *start, const char *str);
|
||||
int smbios_string_table_len(char *start);
|
||||
|
||||
/* Used by mainboard to add an on-board device */
|
||||
int smbios_write_type41(unsigned long *current, int *handle,
|
||||
const char *name, u8 instance, u16 segment,
|
||||
u8 bus, u8 device, u8 function);
|
||||
|
||||
const char *smbios_mainboard_serial_number(void);
|
||||
const char *smbios_mainboard_version(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -343,40 +343,19 @@ static void mainboard_init(device_t dev)
|
|||
}
|
||||
}
|
||||
|
||||
static int butterfly_smbios_type41(int *handle, unsigned long *current,
|
||||
const char *name, u8 irq, u8 addr)
|
||||
{
|
||||
struct smbios_type41 *t = (struct smbios_type41 *)*current;
|
||||
int len = sizeof(struct smbios_type41);
|
||||
|
||||
memset(t, 0, sizeof(struct smbios_type41));
|
||||
t->type = SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION;
|
||||
t->handle = *handle;
|
||||
t->length = len - 2;
|
||||
t->reference_designation = smbios_add_string(t->eos, name);
|
||||
t->device_type = SMBIOS_DEVICE_TYPE_OTHER;
|
||||
t->device_status = 1;
|
||||
t->device_type_instance = irq;
|
||||
t->segment_group_number = 0;
|
||||
t->bus_number = addr;
|
||||
t->function_number = 0;
|
||||
t->device_number = 0;
|
||||
|
||||
len = t->length + smbios_string_table_len(t->eos);
|
||||
*current += len;
|
||||
*handle += 1;
|
||||
return len;
|
||||
}
|
||||
|
||||
static int butterfly_onboard_smbios_data(device_t dev, int *handle,
|
||||
unsigned long *current)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
len += butterfly_smbios_type41(handle, current,
|
||||
BUTTERFLY_TRACKPAD_NAME,
|
||||
BUTTERFLY_TRACKPAD_IRQ,
|
||||
BUTTERFLY_TRACKPAD_I2C_ADDR);
|
||||
len += smbios_write_type41(
|
||||
current, handle,
|
||||
BUTTERFLY_TRACKPAD_NAME, /* name */
|
||||
BUTTERFLY_TRACKPAD_IRQ, /* instance */
|
||||
0, /* segment */
|
||||
BUTTERFLY_TRACKPAD_I2C_ADDR, /* bus */
|
||||
0, /* device */
|
||||
0); /* function */
|
||||
|
||||
return len;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,50 +180,37 @@ static void mainboard_init(device_t dev)
|
|||
}
|
||||
}
|
||||
|
||||
static int link_smbios_type41(int *handle, unsigned long *current,
|
||||
const char *name, u8 irq, u8 addr)
|
||||
{
|
||||
struct smbios_type41 *t = (struct smbios_type41 *)*current;
|
||||
int len = sizeof(struct smbios_type41);
|
||||
|
||||
memset(t, 0, sizeof(struct smbios_type41));
|
||||
t->type = SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION;
|
||||
t->handle = *handle;
|
||||
t->length = len - 2;
|
||||
t->reference_designation = smbios_add_string(t->eos, name);
|
||||
t->device_type = SMBIOS_DEVICE_TYPE_OTHER;
|
||||
t->device_status = 1;
|
||||
t->device_type_instance = irq;
|
||||
t->segment_group_number = 0;
|
||||
t->bus_number = addr;
|
||||
t->function_number = 0;
|
||||
t->device_number = 0;
|
||||
|
||||
len = t->length + smbios_string_table_len(t->eos);
|
||||
*current += len;
|
||||
*handle += 1;
|
||||
return len;
|
||||
}
|
||||
|
||||
static int link_onboard_smbios_data(device_t dev, int *handle,
|
||||
unsigned long *current)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
len += link_smbios_type41(handle, current,
|
||||
LINK_LIGHTSENSOR_NAME,
|
||||
LINK_LIGHTSENSOR_IRQ,
|
||||
LINK_LIGHTSENSOR_I2C_ADDR);
|
||||
len += smbios_write_type41(
|
||||
current, handle,
|
||||
LINK_LIGHTSENSOR_NAME, /* name */
|
||||
LINK_LIGHTSENSOR_IRQ, /* instance */
|
||||
0, /* segment */
|
||||
LINK_LIGHTSENSOR_I2C_ADDR, /* bus */
|
||||
0, /* device */
|
||||
0); /* function */
|
||||
|
||||
len += link_smbios_type41(handle, current,
|
||||
LINK_TRACKPAD_NAME,
|
||||
LINK_TRACKPAD_IRQ,
|
||||
LINK_TRACKPAD_I2C_ADDR);
|
||||
len += smbios_write_type41(
|
||||
current, handle,
|
||||
LINK_TRACKPAD_NAME, /* name */
|
||||
LINK_TRACKPAD_IRQ, /* instance */
|
||||
0, /* segment */
|
||||
LINK_TRACKPAD_I2C_ADDR, /* bus */
|
||||
0, /* device */
|
||||
0); /* function */
|
||||
|
||||
len += link_smbios_type41(handle, current,
|
||||
LINK_TOUCHSCREEN_NAME,
|
||||
LINK_TOUCHSCREEN_IRQ,
|
||||
LINK_TOUCHSCREEN_I2C_ADDR);
|
||||
len += smbios_write_type41(
|
||||
current, handle,
|
||||
LINK_TOUCHSCREEN_NAME, /* name */
|
||||
LINK_TOUCHSCREEN_IRQ, /* instance */
|
||||
0, /* segment */
|
||||
LINK_TOUCHSCREEN_I2C_ADDR, /* bus */
|
||||
0, /* device */
|
||||
0); /* function */
|
||||
|
||||
return len;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,49 +156,31 @@ static void mainboard_init(device_t dev)
|
|||
parrot_ec_init();
|
||||
}
|
||||
|
||||
static int parrot_smbios_type41(int *handle, unsigned long *current,
|
||||
const char *name, u8 irq, u8 addr)
|
||||
{
|
||||
struct smbios_type41 *t = (struct smbios_type41 *)*current;
|
||||
int len = sizeof(struct smbios_type41);
|
||||
|
||||
memset(t, 0, sizeof(struct smbios_type41));
|
||||
t->type = SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION;
|
||||
t->handle = *handle;
|
||||
t->length = len - 2;
|
||||
t->reference_designation = smbios_add_string(t->eos, name);
|
||||
t->device_type = SMBIOS_DEVICE_TYPE_OTHER;
|
||||
t->device_status = 1;
|
||||
t->device_type_instance = irq;
|
||||
t->segment_group_number = 0;
|
||||
t->bus_number = addr;
|
||||
t->function_number = 0;
|
||||
t->device_number = 0;
|
||||
|
||||
len = t->length + smbios_string_table_len(t->eos);
|
||||
*current += len;
|
||||
*handle += 1;
|
||||
return len;
|
||||
}
|
||||
|
||||
static int parrot_onboard_smbios_data(device_t dev, int *handle,
|
||||
unsigned long *current)
|
||||
{
|
||||
int len = 0;
|
||||
u8 hardware_version = parrot_rev();
|
||||
if (hardware_version < 0x2) { /* DVT vs PVT */
|
||||
len += parrot_smbios_type41(handle, current,
|
||||
PARROT_TRACKPAD_NAME,
|
||||
PARROT_TRACKPAD_IRQ_DVT,
|
||||
PARROT_TRACKPAD_I2C_ADDR);
|
||||
len += smbios_write_type41(
|
||||
current, handle,
|
||||
PARROT_TRACKPAD_NAME, /* name */
|
||||
PARROT_TRACKPAD_IRQ_DVT, /* instance */
|
||||
0, /* segment */
|
||||
PARROT_TRACKPAD_I2C_ADDR, /* bus */
|
||||
0, /* device */
|
||||
0); /* function */
|
||||
} else {
|
||||
len += parrot_smbios_type41(handle, current,
|
||||
PARROT_TRACKPAD_NAME,
|
||||
PARROT_TRACKPAD_IRQ_PVT,
|
||||
PARROT_TRACKPAD_I2C_ADDR);
|
||||
len += smbios_write_type41(
|
||||
current, handle,
|
||||
PARROT_TRACKPAD_NAME, /* name */
|
||||
PARROT_TRACKPAD_IRQ_PVT, /* instance */
|
||||
0, /* segment */
|
||||
PARROT_TRACKPAD_I2C_ADDR, /* bus */
|
||||
0, /* device */
|
||||
0); /* function */
|
||||
}
|
||||
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue