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