| 1 |
|
| 2 |
|
| 3 |
#include <device/device.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <drivers/intel/gma/int15.h> |
| 6 |
#include <ec/acpi/ec.h> |
| 7 |
#include <southbridge/intel/common/gpio.h> |
| 8 |
#include <stdio.h> |
| 9 |
#include <string.h> |
| 10 |
#include <smbios.h> |
| 11 |
#include "ec.h" |
| 12 |
|
| 13 |
#include <acpi/acpi.h> |
| 14 |
|
| 15 |
static u8 mainboard_fill_ec_version(char *buf, u8 buf_len) |
| 16 |
{ |
| 17 |
u8 i, c; |
| 18 |
char str[16 + 1]; |
| 19 |
|
| 20 |
|
| 21 |
for (i = 0; i < 8; i++) { |
| 22 |
c = ec_mm_read(0xf0 + i); |
| 23 |
if (c < 0x20 || c > 0x7f) { |
| 24 |
i = snprintf(str, sizeof(str), "*INVALID"); |
| 25 |
break; |
| 26 |
} |
| 27 |
str[i] = c; |
| 28 |
} |
| 29 |
|
| 30 |
i = MIN(buf_len, i); |
| 31 |
memcpy(buf, str, i); |
| 32 |
|
| 33 |
return i; |
| 34 |
} |
| 35 |
|
| 36 |
static void mainboard_smbios_strings( |
| 37 |
struct device *dev, struct smbios_type11 *t) |
| 38 |
{ |
| 39 |
char tpec[] = "IBM ThinkPad Embedded Controller -[ ]-"; |
| 40 |
u16 fwvh, fwvl; |
| 41 |
|
| 42 |
mainboard_fill_ec_version(tpec + 35, 17); |
| 43 |
t->count = smbios_add_string(t->eos, tpec); |
| 44 |
|
| 45 |
|
| 46 |
fwvh = ec_mm_read(0xe8); |
| 47 |
fwvl = ec_mm_read(0xe9); |
| 48 |
|
| 49 |
printk(BIOS_INFO, "EC Firmware ID %.54s, Version %d.%d%d%c\n", tpec, |
| 50 |
fwvh >> 4, fwvh & 0x0f, fwvl >> 4, 0x41 + (fwvl & 0xf)); |
| 51 |
} |
| 52 |
|
| 53 |
static void mainboard_enable(struct device *dev) |
| 54 |
{ |
| 55 |
dev->ops->get_smbios_strings = mainboard_smbios_strings; |
| 56 |
|
| 57 |
install_intel_vga_int15_handler( |
| 58 |
GMA_INT15_ACTIVE_LFP_INT_LVDS, |
| 59 |
GMA_INT15_PANEL_FIT_DEFAULT, |
| 60 |
GMA_INT15_BOOT_DISPLAY_DEFAULT, |
| 61 |
0); |
| 62 |
|
| 63 |
if (!acpi_is_wakeup_s3()) |
| 64 |
lenovo_s230u_ec_init(); |
| 65 |
} |
| 66 |
|
| 67 |
struct chip_operations mainboard_ops = { |
| 68 |
.enable_dev = mainboard_enable, |
| 69 |
}; |