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