mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
Automatically correct ROMID
This commit is contained in:
parent
cef0d4a74a
commit
587b95eb1b
|
@ -70,6 +70,11 @@ typedef void (uniwill_event_callb_t)(u32);
|
||||||
#define UW_EC_REG_FEATURES_1 0x0766
|
#define UW_EC_REG_FEATURES_1 0x0766
|
||||||
#define UW_EC_REG_FEATURES_1_BIT_1_ZONE_RGB_KB 0x04
|
#define UW_EC_REG_FEATURES_1_BIT_1_ZONE_RGB_KB 0x04
|
||||||
|
|
||||||
|
#define UW_EC_REG_ROMID_START 0x0770
|
||||||
|
#define UW_EC_REG_ROMID_END 0x077d
|
||||||
|
#define UW_EC_REG_ROMID_SPECIAL_1 0x077e
|
||||||
|
#define UW_EC_REG_ROMID_SPECIAL_2 0x077f
|
||||||
|
|
||||||
struct uniwill_interface_t {
|
struct uniwill_interface_t {
|
||||||
char *string_id;
|
char *string_id;
|
||||||
uniwill_event_callb_t *event_callb;
|
uniwill_event_callb_t *event_callb;
|
||||||
|
|
|
@ -105,6 +105,22 @@ int uniwill_read_ec_ram(u16 address, u8 *data)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(uniwill_read_ec_ram);
|
EXPORT_SYMBOL(uniwill_read_ec_ram);
|
||||||
|
|
||||||
|
int uniwill_read_ec_ram_with_retry(u16 address, u8 *data, int retries)
|
||||||
|
{
|
||||||
|
int status, i;
|
||||||
|
|
||||||
|
for (i = 0; i < retries; ++i) {
|
||||||
|
status = uniwill_read_ec_ram(address, data);
|
||||||
|
if (status != 0) {
|
||||||
|
pr_debug("uniwill_read_ec_ram(...) failed.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(uniwill_read_ec_ram_with_retry);
|
||||||
|
|
||||||
int uniwill_write_ec_ram(u16 address, u8 data)
|
int uniwill_write_ec_ram(u16 address, u8 data)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
@ -949,6 +965,73 @@ static ssize_t uw_charging_prio_store(struct device *child,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const u8 uw_romid_PH4PxX[14] = {0x0C, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
|
|
||||||
|
static const struct dmi_system_id uw_sku_romid_table[] = {
|
||||||
|
{
|
||||||
|
.matches = {
|
||||||
|
DMI_MATCH(DMI_PRODUCT_SKU, "IBP1XI08MK1"),
|
||||||
|
},
|
||||||
|
.driver_data = (void *)&uw_romid_PH4PxX
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int set_rom_id(void) {
|
||||||
|
int i, ret;
|
||||||
|
const struct dmi_system_id *uw_sku_romid;
|
||||||
|
const u8 *romid;
|
||||||
|
u8 data;
|
||||||
|
bool romid_false = false;
|
||||||
|
|
||||||
|
uw_sku_romid = dmi_first_match(uw_sku_romid_table);
|
||||||
|
if (!uw_sku_romid)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
romid = (const u8 *)uw_sku_romid->driver_data;
|
||||||
|
pr_debug("ROMID 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||||
|
romid[0], romid[1], romid[2], romid[3], romid[4], romid[5], romid[6], romid[7],
|
||||||
|
romid[8], romid[9], romid[10], romid[11], romid[12], romid[13]);
|
||||||
|
|
||||||
|
for (i = 0; i < 14; ++i) {
|
||||||
|
ret = uniwill_read_ec_ram_with_retry(UW_EC_REG_ROMID_START + i, &data, 3);
|
||||||
|
if (ret) {
|
||||||
|
pr_debug("uniwill_read_ec_ram_with_retry(...) failed.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
pr_debug("ROMID index: %d, expected value: 0x%02X, actual value: 0x%02X\n", i, romid[i], data);
|
||||||
|
if (data != romid[i]) {
|
||||||
|
pr_debug("ROMID is false. Correcting...\n");
|
||||||
|
romid_false = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (romid_false) {
|
||||||
|
ret = uniwill_write_ec_ram_with_retry(UW_EC_REG_ROMID_SPECIAL_1, 0xA5, 3);
|
||||||
|
if (ret) {
|
||||||
|
pr_debug("uniwill_write_ec_ram_with_retry(...) failed.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = uniwill_write_ec_ram_with_retry(UW_EC_REG_ROMID_SPECIAL_2, 0x78, 3);
|
||||||
|
if (ret) {
|
||||||
|
pr_debug("uniwill_write_ec_ram_with_retry(...) failed.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
for (i = 0; i < 14; ++i) {
|
||||||
|
ret = uniwill_write_ec_ram_with_retry(UW_EC_REG_ROMID_START + i, romid[i], 3);
|
||||||
|
if (ret) {
|
||||||
|
pr_debug("uniwill_write_ec_ram_with_retry(...) failed.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pr_debug("ROMID is correct.\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int has_universal_ec_fan_control(void) {
|
static int has_universal_ec_fan_control(void) {
|
||||||
int ret;
|
int ret;
|
||||||
u8 data;
|
u8 data;
|
||||||
|
@ -1058,6 +1141,8 @@ static int uniwill_keyboard_probe(struct platform_device *dev)
|
||||||
u8 data;
|
u8 data;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
set_rom_id();
|
||||||
|
|
||||||
struct uniwill_device_features_t *uw_feats = uniwill_get_device_features();
|
struct uniwill_device_features_t *uw_feats = uniwill_get_device_features();
|
||||||
|
|
||||||
// FIXME Hard set balanced profile until we have implemented a way to
|
// FIXME Hard set balanced profile until we have implemented a way to
|
||||||
|
|
Loading…
Reference in a new issue