| 1 |
|
| 2 |
|
| 3 |
#include <acpi/acpi_device.h> |
| 4 |
#include <acpi/acpigen.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <device/i2c_simple.h> |
| 7 |
#include <device/device.h> |
| 8 |
#include "chip.h" |
| 9 |
|
| 10 |
#define MAX98927_ACPI_NAME "MAXI" |
| 11 |
#define MAX98927_ACPI_HID "MX98927" |
| 12 |
|
| 13 |
static void max98927_fill_ssdt(const struct device *dev) |
| 14 |
{ |
| 15 |
struct drivers_i2c_max98927_config *config = dev->chip_info; |
| 16 |
const char *scope = acpi_device_scope(dev); |
| 17 |
struct acpi_i2c i2c = { |
| 18 |
.address = dev->path.i2c.device, |
| 19 |
.mode_10bit = dev->path.i2c.mode_10bit, |
| 20 |
.speed = config->bus_speed ? : I2C_SPEED_FAST, |
| 21 |
.resource = scope, |
| 22 |
}; |
| 23 |
struct acpi_dp *dp; |
| 24 |
|
| 25 |
if (!scope) |
| 26 |
return; |
| 27 |
|
| 28 |
|
| 29 |
acpigen_write_scope(scope); |
| 30 |
acpigen_write_device(acpi_device_name(dev)); |
| 31 |
acpigen_write_name_string("_HID", MAX98927_ACPI_HID); |
| 32 |
acpigen_write_name_integer("_UID", config->uid); |
| 33 |
if (config->desc) |
| 34 |
acpigen_write_name_string("_DDN", config->desc); |
| 35 |
acpigen_write_STA(acpi_device_status(dev)); |
| 36 |
|
| 37 |
|
| 38 |
acpigen_write_name("_CRS"); |
| 39 |
acpigen_write_resourcetemplate_header(); |
| 40 |
acpi_device_write_i2c(&i2c); |
| 41 |
acpigen_write_resourcetemplate_footer(); |
| 42 |
|
| 43 |
|
| 44 |
dp = acpi_dp_new_table("_DSD"); |
| 45 |
|
| 46 |
acpi_dp_add_integer(dp, "interleave_mode", config->interleave_mode); |
| 47 |
acpi_dp_add_integer(dp, "vmon-slot-no", config->vmon_slot_no); |
| 48 |
acpi_dp_add_integer(dp, "imon-slot-no", config->imon_slot_no); |
| 49 |
|
| 50 |
acpi_dp_write(dp); |
| 51 |
|
| 52 |
acpigen_pop_len(); |
| 53 |
acpigen_pop_len(); |
| 54 |
|
| 55 |
printk(BIOS_INFO, "%s: %s address 0%xh\n", acpi_device_path(dev), |
| 56 |
dev->chip_ops->name, dev->path.i2c.device); |
| 57 |
} |
| 58 |
|
| 59 |
static const char *max98927_acpi_name(const struct device *dev) |
| 60 |
{ |
| 61 |
struct drivers_i2c_max98927_config *config = dev->chip_info; |
| 62 |
|
| 63 |
if (config->name) |
| 64 |
return config->name; |
| 65 |
|
| 66 |
return MAX98927_ACPI_NAME; |
| 67 |
} |
| 68 |
|
| 69 |
static struct device_operations max98927_ops = { |
| 70 |
.read_resources = noop_read_resources, |
| 71 |
.set_resources = noop_set_resources, |
| 72 |
.acpi_name = max98927_acpi_name, |
| 73 |
.acpi_fill_ssdt = max98927_fill_ssdt, |
| 74 |
}; |
| 75 |
|
| 76 |
static void max98927_enable(struct device *dev) |
| 77 |
{ |
| 78 |
struct drivers_i2c_max98927_config *config = dev->chip_info; |
| 79 |
|
| 80 |
dev->ops = &max98927_ops; |
| 81 |
|
| 82 |
if (config && config->desc) { |
| 83 |
dev->name = config->desc; |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
struct chip_operations drivers_i2c_max98927_ops = { |
| 88 |
.name = "Maxim MAX98927 Codec", |
| 89 |
.enable_dev = max98927_enable |
| 90 |
}; |