| 1 |
|
| 2 |
|
| 3 |
#include <acpi/acpi_device.h> |
| 4 |
#include <acpi/acpigen.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <device/i2c.h> |
| 7 |
#include <device/device.h> |
| 8 |
#include "chip.h" |
| 9 |
|
| 10 |
#define RT5663_ACPI_NAME "RT53" |
| 11 |
#define RT5663_ACPI_HID "10EC5663" |
| 12 |
|
| 13 |
#define RT5663_DP_INT(key, val) \ |
| 14 |
acpi_dp_add_integer(dp, "realtek," key, (val)) |
| 15 |
|
| 16 |
static void rt5663_fill_ssdt(const struct device *dev) |
| 17 |
{ |
| 18 |
struct drivers_i2c_rt5663_config *config = dev->chip_info; |
| 19 |
const char *scope = acpi_device_scope(dev); |
| 20 |
struct acpi_i2c i2c = { |
| 21 |
.address = dev->path.i2c.device, |
| 22 |
.mode_10bit = dev->path.i2c.mode_10bit, |
| 23 |
.speed = config->bus_speed ? : I2C_SPEED_FAST, |
| 24 |
.resource = scope, |
| 25 |
}; |
| 26 |
struct acpi_dp *dp; |
| 27 |
|
| 28 |
if (!scope) |
| 29 |
return; |
| 30 |
|
| 31 |
|
| 32 |
acpigen_write_scope(scope); |
| 33 |
acpigen_write_device(acpi_device_name(dev)); |
| 34 |
acpigen_write_name_string("_HID", RT5663_ACPI_HID); |
| 35 |
acpigen_write_name_integer("_UID", config->uid); |
| 36 |
acpigen_write_name_string("_DDN", dev->chip_ops->name); |
| 37 |
acpigen_write_STA(acpi_device_status(dev)); |
| 38 |
|
| 39 |
|
| 40 |
acpigen_write_name("_CRS"); |
| 41 |
acpigen_write_resourcetemplate_header(); |
| 42 |
acpi_device_write_i2c(&i2c); |
| 43 |
|
| 44 |
if (config->irq_gpio.pin_count) |
| 45 |
acpi_device_write_gpio(&config->irq_gpio); |
| 46 |
else |
| 47 |
acpi_device_write_interrupt(&config->irq); |
| 48 |
acpigen_write_resourcetemplate_footer(); |
| 49 |
|
| 50 |
|
| 51 |
dp = acpi_dp_new_table("_DSD"); |
| 52 |
if (config->irq_gpio.pin_count) |
| 53 |
acpi_dp_add_gpio(dp, "irq-gpios", acpi_device_path(dev), 0, 0, |
| 54 |
config->irq_gpio.active_low); |
| 55 |
RT5663_DP_INT("dc_offset_l_manual", config->dc_offset_l_manual); |
| 56 |
RT5663_DP_INT("dc_offset_r_manual", config->dc_offset_r_manual); |
| 57 |
RT5663_DP_INT("dc_offset_l_manual_mic", config->dc_offset_l_manual_mic); |
| 58 |
RT5663_DP_INT("dc_offset_r_manual_mic", config->dc_offset_r_manual_mic); |
| 59 |
acpi_dp_write(dp); |
| 60 |
|
| 61 |
acpigen_pop_len(); |
| 62 |
acpigen_pop_len(); |
| 63 |
|
| 64 |
printk(BIOS_INFO, "%s: %s address 0%xh\n", acpi_device_path(dev), |
| 65 |
dev->chip_ops->name, dev->path.i2c.device); |
| 66 |
} |
| 67 |
|
| 68 |
static const char *rt5663_acpi_name(const struct device *dev) |
| 69 |
{ |
| 70 |
return RT5663_ACPI_NAME; |
| 71 |
} |
| 72 |
|
| 73 |
static struct device_operations rt5663_ops = { |
| 74 |
.read_resources = noop_read_resources, |
| 75 |
.set_resources = noop_set_resources, |
| 76 |
.acpi_name = rt5663_acpi_name, |
| 77 |
.acpi_fill_ssdt = rt5663_fill_ssdt, |
| 78 |
}; |
| 79 |
|
| 80 |
static void rt5663_enable(struct device *dev) |
| 81 |
{ |
| 82 |
dev->ops = &rt5663_ops; |
| 83 |
} |
| 84 |
|
| 85 |
struct chip_operations drivers_i2c_rt5663_ops = { |
| 86 |
.name = "Realtek RT5663 Codec", |
| 87 |
.enable_dev = rt5663_enable |
| 88 |
}; |