mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
Merge branch 'implement_set_romid' into 'master'
Implement set romid See merge request tuxedocomputers/development/packages/tuxedo-keyboard!57
This commit is contained in:
commit
896d807fcd
|
@ -36,6 +36,7 @@
|
|||
#define UNIWILL_INTERFACE_WMI_STRID "uniwill_wmi"
|
||||
|
||||
typedef int (uniwill_read_ec_ram_t)(u16, u8*);
|
||||
typedef int (uniwill_read_ec_ram_with_retry_t)(u16, u8*, int);
|
||||
typedef int (uniwill_write_ec_ram_t)(u16, u8);
|
||||
typedef int (uniwill_write_ec_ram_with_retry_t)(u16, u8, int);
|
||||
typedef void (uniwill_event_callb_t)(u32);
|
||||
|
@ -70,6 +71,10 @@ typedef void (uniwill_event_callb_t)(u32);
|
|||
#define UW_EC_REG_FEATURES_1 0x0766
|
||||
#define UW_EC_REG_FEATURES_1_BIT_1_ZONE_RGB_KB 0x04
|
||||
|
||||
#define UW_EC_REG_ROMID_START 0x0770
|
||||
#define UW_EC_REG_ROMID_SPECIAL_1 0x077e
|
||||
#define UW_EC_REG_ROMID_SPECIAL_2 0x077f
|
||||
|
||||
struct uniwill_interface_t {
|
||||
char *string_id;
|
||||
uniwill_event_callb_t *event_callb;
|
||||
|
@ -82,6 +87,7 @@ int uniwill_remove_interface(struct uniwill_interface_t *interface);
|
|||
uniwill_read_ec_ram_t uniwill_read_ec_ram;
|
||||
uniwill_write_ec_ram_t uniwill_write_ec_ram;
|
||||
uniwill_write_ec_ram_with_retry_t uniwill_write_ec_ram_with_retry;
|
||||
uniwill_read_ec_ram_with_retry_t uniwill_read_ec_ram_with_retry;
|
||||
int uniwill_get_active_interface_id(char **id_str);
|
||||
|
||||
#define UW_MODEL_PF5LUXG 0x09
|
||||
|
|
|
@ -105,6 +105,22 @@ int uniwill_read_ec_ram(u16 address, u8 *data)
|
|||
}
|
||||
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");
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
EXPORT_SYMBOL(uniwill_read_ec_ram_with_retry);
|
||||
|
||||
int uniwill_write_ec_ram(u16 address, u8 data)
|
||||
{
|
||||
int status;
|
||||
|
@ -122,8 +138,7 @@ EXPORT_SYMBOL(uniwill_write_ec_ram);
|
|||
|
||||
int uniwill_write_ec_ram_with_retry(u16 address, u8 data, int retries)
|
||||
{
|
||||
u32 status;
|
||||
int i;
|
||||
int status, i;
|
||||
u8 control_data;
|
||||
|
||||
for (i = 0; i < retries; ++i) {
|
||||
|
@ -950,6 +965,73 @@ static ssize_t uw_charging_prio_store(struct device *child,
|
|||
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) {
|
||||
int ret;
|
||||
u8 data;
|
||||
|
@ -1059,6 +1141,8 @@ static int uniwill_keyboard_probe(struct platform_device *dev)
|
|||
u8 data;
|
||||
int status;
|
||||
|
||||
set_rom_id();
|
||||
|
||||
struct uniwill_device_features_t *uw_feats = uniwill_get_device_features();
|
||||
|
||||
// FIXME Hard set balanced profile until we have implemented a way to
|
||||
|
|
Loading…
Reference in a new issue