Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 3 | |
| 4 | #include <arch/acpi_device.h> |
| 5 | #include <arch/acpigen.h> |
| 6 | #include <console/console.h> |
| 7 | #include <device/device.h> |
| 8 | #include <device/path.h> |
| 9 | #include <stdint.h> |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 10 | #include "chip.h" |
| 11 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 12 | #if CONFIG(HAVE_ACPI_TABLES) |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 13 | |
| 14 | #define ADAU7002_ACPI_NAME "ADAU" |
| 15 | #define ADAU7002_ACPI_HID "ADAU7002" |
| 16 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame^] | 17 | static void adau7002_fill_ssdt(const struct device *dev) |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 18 | { |
Akshu Agrawal | 7ac3149 | 2019-01-08 14:06:42 +0530 | [diff] [blame] | 19 | struct drivers_generic_adau7002_config *config; |
| 20 | struct acpi_dp *dp; |
| 21 | |
Richard Spiegel | e0d3064 | 2018-02-14 09:38:11 -0700 | [diff] [blame] | 22 | if (!dev || !dev->enabled) |
| 23 | return; |
| 24 | |
| 25 | const char *scope = acpi_device_scope(dev); |
| 26 | const char *name = acpi_device_name(dev); |
| 27 | if (!scope || !name) |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 28 | return; |
| 29 | |
| 30 | /* Device */ |
Richard Spiegel | e0d3064 | 2018-02-14 09:38:11 -0700 | [diff] [blame] | 31 | acpigen_write_scope(scope); |
| 32 | acpigen_write_device(name); |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 33 | acpigen_write_name_string("_HID", ADAU7002_ACPI_HID); |
| 34 | acpigen_write_name_integer("_UID", 0); |
| 35 | acpigen_write_name_string("_DDN", dev->chip_ops->name); |
Hung-Te Lin | b4be50c | 2018-09-10 10:55:49 +0800 | [diff] [blame] | 36 | acpigen_write_STA(acpi_device_status(dev)); |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 37 | |
Akshu Agrawal | 7ac3149 | 2019-01-08 14:06:42 +0530 | [diff] [blame] | 38 | /* _DSD for devicetree properties */ |
| 39 | config = dev->chip_info; |
| 40 | dp = acpi_dp_new_table("_DSD"); |
| 41 | acpi_dp_add_integer(dp, "wakeup-delay-ms", config->wakeup_delay); |
| 42 | acpi_dp_write(dp); |
| 43 | |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 44 | acpigen_pop_len(); /* Device */ |
| 45 | acpigen_pop_len(); /* Scope */ |
| 46 | |
| 47 | printk(BIOS_INFO, "%s: %s\n", acpi_device_path(dev), |
| 48 | dev->chip_ops->name); |
| 49 | } |
| 50 | |
| 51 | static const char *adau7002_acpi_name(const struct device *dev) |
| 52 | { |
| 53 | return ADAU7002_ACPI_NAME; |
| 54 | } |
| 55 | #endif |
| 56 | |
| 57 | static struct device_operations adau7002_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 58 | .read_resources = noop_read_resources, |
| 59 | .set_resources = noop_set_resources, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 60 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 61 | .acpi_name = adau7002_acpi_name, |
| 62 | .acpi_fill_ssdt = adau7002_fill_ssdt, |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 63 | #endif |
| 64 | }; |
| 65 | |
| 66 | static void adau7002_enable(struct device *dev) |
| 67 | { |
| 68 | dev->ops = &adau7002_ops; |
| 69 | } |
| 70 | |
| 71 | struct chip_operations drivers_generic_adau7002_ops = { |
| 72 | CHIP_NAME("Analog Digital DMIC") |
Elyes HAOUAS | 2aa3b16 | 2018-11-27 17:02:10 +0100 | [diff] [blame] | 73 | .enable_dev = adau7002_enable |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 74 | }; |