diff options
Diffstat (limited to 'src/drivers/i2c/sx9310/sx9310.c')
-rw-r--r-- | src/drivers/i2c/sx9310/sx9310.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/drivers/i2c/sx9310/sx9310.c b/src/drivers/i2c/sx9310/sx9310.c index 8dc57a2d98..d9e5a14c5b 100644 --- a/src/drivers/i2c/sx9310/sx9310.c +++ b/src/drivers/i2c/sx9310/sx9310.c @@ -12,9 +12,16 @@ #define I2C_SX9310_ACPI_ID "STH9310" #define I2C_SX9310_ACPI_NAME "Semtech SX9310" -#define REGISTER(NAME) acpi_dp_add_integer(dsd, \ - I2C_SX9310_ACPI_ID "," #NAME, \ - config->NAME) +static const char * const i2c_sx9310_resolution[] = { + [SX9310_COARSEST] = "coarsest", + [SX9310_VERY_COARSE] = "very-coarse", + [SX9310_COARSE] = "coarse", + [SX9310_MEDIUM_COARSE] = "medium-coarse", + [SX9310_MEDIUM] = "medium", + [SX9310_FINE] = "fine", + [SX9310_VERY_FINE] = "very-fine", + [SX9310_FINEST] = "finest", +}; static void i2c_sx9310_fill_ssdt(const struct device *dev) { @@ -27,6 +34,7 @@ static void i2c_sx9310_fill_ssdt(const struct device *dev) .resource = scope, }; struct acpi_dp *dsd; + struct acpi_dp *combined_sensors; if (!scope || !config) return; @@ -56,9 +64,35 @@ static void i2c_sx9310_fill_ssdt(const struct device *dev) /* DSD */ dsd = acpi_dp_new_table("_DSD"); -#include "registers.h" - acpi_dp_write(dsd); + /* + * Format describe in linux kernel documentation. See + * https://www.kernel.org/doc/Documentation/devicetree/bindings/iio/proximity/semtech%2Csx9310.yaml + */ + acpi_dp_add_integer(dsd, "semtech,cs0-ground", config->cs0_ground); + acpi_dp_add_integer(dsd, "semtech,startup-sensor", + config->startup_sensor); + acpi_dp_add_integer(dsd, "semtech,proxraw-strength", + config->proxraw_strength); + acpi_dp_add_integer(dsd, "semtech,avg-pos-strength", + config->avg_pos_strength); + + /* Add combined_sensors package */ + if (config->combined_sensors_count > 0) { + combined_sensors = acpi_dp_new_table("semtech,combined-sensors"); + for (int i = 0; + i < config->combined_sensors_count && + i < MAX_COMBINED_SENSORS_ENTRIES; ++i) { + acpi_dp_add_integer(combined_sensors, NULL, + config->combined_sensors[i]); + } + acpi_dp_add_array(dsd, combined_sensors); + } + if (config->resolution && config->resolution < ARRAY_SIZE(i2c_sx9310_resolution)) + acpi_dp_add_string(dsd, "semtech,resolution", + i2c_sx9310_resolution[config->resolution]); + + acpi_dp_write(dsd); acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ @@ -66,8 +100,6 @@ static void i2c_sx9310_fill_ssdt(const struct device *dev) config->desc ? : dev->chip_ops->name, dev_path(dev)); } -#undef REGISTER - static const char *i2c_sx9310_acpi_name(const struct device *dev) { static char name[5]; |