| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <device/device.h> |
| 5 |
#include <ec/acpi/ec.h> |
| 6 |
|
| 7 |
#include "chip.h" |
| 8 |
|
| 9 |
#define KBC_TIMEOUT_US 1000000 // 1s |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
static int kbc1126_thermal_init(u8 cmd, u8 value) |
| 16 |
{ |
| 17 |
printk(BIOS_DEBUG, "KBC1126: initialize fan control.\n"); |
| 18 |
|
| 19 |
if (send_ec_command_timeout(cmd, KBC_TIMEOUT_US) < 0) |
| 20 |
return -1; |
| 21 |
|
| 22 |
if (send_ec_data_timeout(0x27, KBC_TIMEOUT_US) < 0) |
| 23 |
return -1; |
| 24 |
|
| 25 |
if (send_ec_data_timeout(0x01, KBC_TIMEOUT_US) < 0) |
| 26 |
return -1; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
if (send_ec_command_timeout(cmd, KBC_TIMEOUT_US) < 0) |
| 33 |
return -1; |
| 34 |
|
| 35 |
if (send_ec_data_timeout(0xd5, KBC_TIMEOUT_US) < 0) |
| 36 |
return -1; |
| 37 |
|
| 38 |
if (send_ec_data_timeout(value, KBC_TIMEOUT_US) < 0) |
| 39 |
return -1; |
| 40 |
|
| 41 |
printk(BIOS_DEBUG, "KBC1126: fan control initialized.\n"); |
| 42 |
return 0; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
static void kbc1126_kbd_led(u8 cmd, u8 val) |
| 50 |
{ |
| 51 |
if (send_ec_command_timeout(cmd, KBC_TIMEOUT_US) < 0) |
| 52 |
return; |
| 53 |
|
| 54 |
if (send_ec_data_timeout(0xf0, KBC_TIMEOUT_US) < 0) |
| 55 |
return; |
| 56 |
|
| 57 |
if (send_ec_data_timeout(val, KBC_TIMEOUT_US) < 0) |
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
static void kbc1126_enable(struct device *dev) |
| 62 |
{ |
| 63 |
struct ec_hp_kbc1126_config *conf = dev->chip_info; |
| 64 |
|
| 65 |
ec_set_ports(conf->ec_cmd_port, conf->ec_data_port); |
| 66 |
kbc1126_kbd_led(conf->ec_ctrl_reg, 0); |
| 67 |
if (kbc1126_thermal_init(conf->ec_ctrl_reg, conf->ec_fan_ctrl_value) < 0) |
| 68 |
printk(BIOS_DEBUG, "KBC1126: error when initializing fan control.\n"); |
| 69 |
} |
| 70 |
|
| 71 |
struct chip_operations ec_hp_kbc1126_ops = { |
| 72 |
.name = "SMSC KBC1126 for HP laptops", |
| 73 |
.enable_dev = kbc1126_enable |
| 74 |
}; |