void drivers_lenovo_serial_ports_ssdt_generate(const char *scope, int have_dock_serial) { acpigen_write_scope(scope); if (drivers_lenovo_is_wacom_present()) { acpigen_write_device("DTR"); acpigen_write_name("_HID"); acpigen_emit_eisaid("WACF004"); acpigen_write_name("_CRS"); acpigen_write_resourcetemplate_header(); acpigen_write_io16(0x200, 0x200, 1, 8, 1); acpigen_write_irq((1 << 5)); acpigen_write_resourcetemplate_footer(); acpigen_write_STA(0xf); acpigen_pop_len(); } if (have_dock_serial) { acpigen_write_device("COMA"); acpigen_write_name("_HID"); acpigen_emit_eisaid("PNP0501"); acpigen_write_name("_UID"); /* Byte */ acpigen_write_byte(0x2); acpigen_write_name("_CRS"); acpigen_write_resourcetemplate_header(); acpigen_write_io16(0x3f8, 0x3f8, 1, 8, 1); acpigen_write_irq(1 << 4); acpigen_write_resourcetemplate_footer(); acpigen_write_STA(0xf); acpigen_pop_len(); } acpigen_pop_len(); }
static void i2c_tpm_fill_ssdt(struct device *dev) { struct drivers_i2c_tpm_config *config = dev->chip_info; const char *scope = acpi_device_scope(dev); struct acpi_i2c i2c = { .address = dev->path.i2c.device, .mode_10bit = dev->path.i2c.mode_10bit, .speed = config->speed ? : I2C_SPEED_FAST, .resource = scope, }; if (!dev->enabled || !scope) return; if (!config->hid) { printk(BIOS_ERR, "%s: ERROR: HID required\n", dev_path(dev)); return; } /* Device */ acpigen_write_scope(scope); acpigen_write_device(acpi_device_name(dev)); acpigen_write_name_string("_HID", config->hid); acpigen_write_name_integer("_UID", config->uid); acpigen_write_name_string("_DDN", dev->chip_ops->name); acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON); /* Resources */ acpigen_write_name("_CRS"); acpigen_write_resourcetemplate_header(); acpi_device_write_i2c(&i2c); acpi_device_write_interrupt(&config->irq); acpigen_write_resourcetemplate_footer(); acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ printk(BIOS_INFO, "%s: %s at %s\n", acpi_device_path(dev), dev->chip_ops->name, dev_path(dev)); } static const char *i2c_tpm_acpi_name(struct device *dev) { return "TPMI"; } static struct device_operations i2c_tpm_ops = { .read_resources = DEVICE_NOOP, .set_resources = DEVICE_NOOP, .enable_resources = DEVICE_NOOP, .acpi_name = &i2c_tpm_acpi_name, .acpi_fill_ssdt_generator = &i2c_tpm_fill_ssdt, }; static void i2c_tpm_enable(struct device *dev) { dev->ops = &i2c_tpm_ops; } struct chip_operations drivers_i2c_tpm_ops = { CHIP_NAME("I2C TPM") .enable_dev = &i2c_tpm_enable };
static void camera_fill_ssdt(struct device *dev) { struct drivers_intel_mipi_camera_config *config = dev->chip_info; const char *scope = acpi_device_scope(dev); struct acpi_i2c i2c = { .address = dev->path.i2c.device, .mode_10bit = dev->path.i2c.mode_10bit, .speed = I2C_SPEED_FAST, .resource = scope, }; if (!dev->enabled || !scope) return; /* Device */ acpigen_write_scope(scope); acpigen_write_device(acpi_device_name(dev)); acpigen_write_name_string("_HID", config->acpi_hid); acpigen_write_name_integer("_UID", config->acpi_uid); acpigen_write_name_string("_DDN", config->chip_name); acpigen_write_STA(acpi_device_status(dev)); /* Resources */ acpigen_write_name("_CRS"); acpigen_write_resourcetemplate_header(); acpi_device_write_i2c(&i2c); acpigen_write_resourcetemplate_footer(); /* Mark it as Camera related device */ acpigen_write_name_integer("CAMD", config->device_type); /* Create Device specific data */ if (config->device_type == INTEL_ACPI_CAMERA_SENSOR) { acpigen_write_method_serialized("SSDB", 0); acpigen_write_return_byte_buffer((uint8_t *)&config->ssdb, sizeof(config->ssdb)); acpigen_pop_len(); /* Method */ } /* Fill Power Sequencing Data */ acpigen_write_method_serialized("PWDB", 0); acpigen_write_return_byte_buffer((uint8_t *)&config->pwdb, (sizeof(struct intel_pwdb) * config->num_pwdb_entries)); acpigen_pop_len(); /* Method */ acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ printk(BIOS_INFO, "%s: %s address 0%xh\n", acpi_device_path(dev), dev->chip_ops->name, dev->path.i2c.device); } static const char *camera_acpi_name(const struct device *dev) { struct drivers_intel_mipi_camera_config *config = dev->chip_info; return config->acpi_name; } static struct device_operations camera_ops = { .read_resources = DEVICE_NOOP, .set_resources = DEVICE_NOOP, .enable_resources = DEVICE_NOOP, .acpi_name = &camera_acpi_name, .acpi_fill_ssdt_generator = &camera_fill_ssdt, }; static void camera_enable(struct device *dev) { dev->ops = &camera_ops; } struct chip_operations drivers_intel_mipi_camera_ops = { CHIP_NAME("Intel MIPI Camera Device") .enable_dev = &camera_enable };
static void nau8825_fill_ssdt(struct device *dev) { struct drivers_i2c_nau8825_config *config = dev->chip_info; const char *scope = acpi_device_scope(dev); struct acpi_i2c i2c = { .address = dev->path.i2c.device, .mode_10bit = dev->path.i2c.mode_10bit, .speed = config->bus_speed ? : I2C_SPEED_FAST, .resource = scope, }; struct acpi_dp *dp = NULL; if (!dev->enabled || !scope) return; if (config->sar_threshold_num > NAU8825_MAX_BUTTONS) return; /* Device */ acpigen_write_scope(scope); acpigen_write_device(acpi_device_name(dev)); acpigen_write_name_string("_HID", NAU8825_ACPI_HID); acpigen_write_name_integer("_UID", 0); acpigen_write_name_string("_DDN", dev->chip_ops->name); acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON); /* Resources */ acpigen_write_name("_CRS"); acpigen_write_resourcetemplate_header(); acpi_device_write_i2c(&i2c); acpi_device_write_interrupt(&config->irq); acpigen_write_resourcetemplate_footer(); /* Device Properties */ dp = acpi_dp_new_table("_DSD"); NAU8825_DP_INT("jkdet-enable", config->jkdet_enable); NAU8825_DP_INT("jkdet-pull-enable", config->jkdet_pull_enable); NAU8825_DP_INT("jkdet-pull-up", config->jkdet_pull_up); NAU8825_DP_INT("jkdet-polarity", config->jkdet_polarity); NAU8825_DP_INT("vref-impedance", config->vref_impedance); NAU8825_DP_INT("micbias-voltage", config->micbias_voltage); NAU8825_DP_INT("sar-hysteresis", config->sar_hysteresis); NAU8825_DP_INT("sar-voltage", config->sar_voltage); NAU8825_DP_INT("sar-compare-time", config->sar_compare_time); NAU8825_DP_INT("sar-sampling-time", config->sar_sampling_time); NAU8825_DP_INT("short-key-debounce", config->short_key_debounce); NAU8825_DP_INT("jack-insert-debounce", config->jack_insert_debounce); NAU8825_DP_INT("jack-eject-deboune", config->jack_eject_debounce); NAU8825_DP_INT("sar-threshold-num", config->sar_threshold_num); acpi_dp_add_integer_array(dp, "nuvoton,sar-threshold", config->sar_threshold, config->sar_threshold_num); acpi_dp_write(dp); acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ printk(BIOS_INFO, "%s: %s address 0%xh irq %d\n", acpi_device_path(dev), dev->chip_ops->name, dev->path.i2c.device, config->irq.pin); } static const char *nau8825_acpi_name(struct device *dev) { return NAU8825_ACPI_NAME; } #endif static struct device_operations nau8825_ops = { .read_resources = DEVICE_NOOP, .set_resources = DEVICE_NOOP, .enable_resources = DEVICE_NOOP, #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) .acpi_name = &nau8825_acpi_name, .acpi_fill_ssdt_generator = &nau8825_fill_ssdt, #endif }; static void nau8825_enable(struct device *dev) { dev->ops = &nau8825_ops; } struct chip_operations drivers_i2c_nau8825_ops = { CHIP_NAME("Nuvoton NAU8825 Codec") .enable_dev = &nau8825_enable };
static void max98373_fill_ssdt(struct device *dev) { struct drivers_i2c_max98373_config *config = dev->chip_info; const char *scope = acpi_device_scope(dev); struct acpi_i2c i2c = { .address = dev->path.i2c.device, .mode_10bit = dev->path.i2c.mode_10bit, .speed = config->bus_speed ? : I2C_SPEED_STANDARD, .resource = scope, }; struct acpi_dp *dp; if (!dev->enabled || !scope) { printk(BIOS_ERR, "%s: dev not enabled", __func__); return; } /* Device */ acpigen_write_scope(scope); acpigen_write_device(acpi_device_name(dev)); acpigen_write_name_string("_HID", MAX98373_ACPI_HID); acpigen_write_name_integer("_UID", config->uid); if (config->desc) acpigen_write_name_string("_DDN", config->desc); acpigen_write_STA(acpi_device_status(dev)); /* Resources */ acpigen_write_name("_CRS"); acpigen_write_resourcetemplate_header(); acpi_device_write_i2c(&i2c); acpigen_write_resourcetemplate_footer(); /* Device Properties */ dp = acpi_dp_new_table("_DSD"); if (config->interleave_mode) acpi_dp_add_integer(dp, "maxim,interleave_mode", config->interleave_mode); acpi_dp_add_integer(dp, "maxim,vmon-slot-no", config->vmon_slot_no); acpi_dp_add_integer(dp, "maxim,imon-slot-no", config->imon_slot_no); acpi_dp_write(dp); acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ printk(BIOS_INFO, "%s: %s address 0%xh\n", acpi_device_path(dev), dev->chip_ops->name, dev->path.i2c.device); } static const char *max98373_acpi_name(const struct device *dev) { struct drivers_i2c_max98373_config *config = dev->chip_info; if (config->name) return config->name; return MAX98373_ACPI_NAME; } static struct device_operations max98373_ops = { .read_resources = DEVICE_NOOP, .set_resources = DEVICE_NOOP, .enable_resources = DEVICE_NOOP, .acpi_name = &max98373_acpi_name, .acpi_fill_ssdt_generator = &max98373_fill_ssdt, }; static void max98373_enable(struct device *dev) { struct drivers_i2c_max98373_config *config = dev->chip_info; dev->ops = &max98373_ops; if (config && config->desc) { dev->name = config->desc; } } struct chip_operations drivers_i2c_max98373_ops = { CHIP_NAME("Maxim MAX98373 Codec") .enable_dev = &max98373_enable };
static void i2c_generic_fill_ssdt(struct device *dev) { struct drivers_i2c_generic_config *config = dev->chip_info; const char *scope = acpi_device_scope(dev); struct acpi_i2c i2c = { .address = dev->path.i2c.device, .mode_10bit = dev->path.i2c.mode_10bit, .speed = config->speed ? : I2C_SPEED_FAST, .resource = scope, }; if (!dev->enabled || !scope) return; if (!config->hid) { printk(BIOS_ERR, "%s: ERROR: HID required\n", dev_path(dev)); return; } /* Device */ acpigen_write_scope(scope); acpigen_write_device(acpi_device_name(dev)); acpigen_write_name_string("_HID", config->hid); acpigen_write_name_integer("_UID", config->uid); acpigen_write_name_string("_DDN", config->desc); acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON); /* Resources */ acpigen_write_name("_CRS"); acpigen_write_resourcetemplate_header(); acpi_device_write_i2c(&i2c); acpi_device_write_interrupt(&config->irq); acpigen_write_resourcetemplate_footer(); /* Wake capabilities */ if (config->wake) { acpigen_write_name_integer("_S0W", 4); acpigen_write_PRW(config->wake, 3); } acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ printk(BIOS_INFO, "%s: %s at %s\n", acpi_device_path(dev), config->desc ? : dev->chip_ops->name, dev_path(dev)); } /* Use name specified in config or build one from I2C address */ static const char *i2c_generic_acpi_name(struct device *dev) { struct drivers_i2c_generic_config *config = dev->chip_info; static char name[5]; if (config->name) return name; snprintf(name, sizeof(name), "D%03.3X", dev->path.i2c.device); name[4] = '\0'; return name; } #endif static struct device_operations i2c_generic_ops = { .read_resources = DEVICE_NOOP, .set_resources = DEVICE_NOOP, .enable_resources = DEVICE_NOOP, #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) .acpi_name = &i2c_generic_acpi_name, .acpi_fill_ssdt_generator = &i2c_generic_fill_ssdt, #endif }; static void i2c_generic_enable(struct device *dev) { struct drivers_i2c_generic_config *config = dev->chip_info; /* Check if device is present by reading GPIO */ if (config->device_present_gpio) { int present = gpio_get(config->device_present_gpio); present ^= config->device_present_gpio_invert; printk(BIOS_INFO, "%s is %spresent\n", dev->chip_ops->name, present ? "" : "not "); if (!present) { dev->enabled = 0; return; } } dev->ops = &i2c_generic_ops; } struct chip_operations drivers_i2c_generic_ops = { CHIP_NAME("I2C Device") .enable_dev = &i2c_generic_enable };