Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; version 2 of the License. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #include <arch/acpi_device.h> |
| 15 | #include <arch/acpigen.h> |
| 16 | #include <console/console.h> |
| 17 | #include <device/device.h> |
| 18 | #include <device/path.h> |
| 19 | #include <stdint.h> |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 20 | #include "chip.h" |
| 21 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 22 | #if CONFIG(HAVE_ACPI_TABLES) |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 23 | |
| 24 | #define ADAU7002_ACPI_NAME "ADAU" |
| 25 | #define ADAU7002_ACPI_HID "ADAU7002" |
| 26 | |
| 27 | static void adau7002_fill_ssdt(struct device *dev) |
| 28 | { |
Akshu Agrawal | 7ac3149 | 2019-01-08 14:06:42 +0530 | [diff] [blame] | 29 | struct drivers_generic_adau7002_config *config; |
| 30 | struct acpi_dp *dp; |
| 31 | |
Richard Spiegel | e0d3064 | 2018-02-14 09:38:11 -0700 | [diff] [blame] | 32 | if (!dev || !dev->enabled) |
| 33 | return; |
| 34 | |
| 35 | const char *scope = acpi_device_scope(dev); |
| 36 | const char *name = acpi_device_name(dev); |
| 37 | if (!scope || !name) |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 38 | return; |
| 39 | |
| 40 | /* Device */ |
Richard Spiegel | e0d3064 | 2018-02-14 09:38:11 -0700 | [diff] [blame] | 41 | acpigen_write_scope(scope); |
| 42 | acpigen_write_device(name); |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 43 | acpigen_write_name_string("_HID", ADAU7002_ACPI_HID); |
| 44 | acpigen_write_name_integer("_UID", 0); |
| 45 | acpigen_write_name_string("_DDN", dev->chip_ops->name); |
Hung-Te Lin | b4be50c | 2018-09-10 10:55:49 +0800 | [diff] [blame] | 46 | acpigen_write_STA(acpi_device_status(dev)); |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 47 | |
Akshu Agrawal | 7ac3149 | 2019-01-08 14:06:42 +0530 | [diff] [blame] | 48 | /* _DSD for devicetree properties */ |
| 49 | config = dev->chip_info; |
| 50 | dp = acpi_dp_new_table("_DSD"); |
| 51 | acpi_dp_add_integer(dp, "wakeup-delay-ms", config->wakeup_delay); |
| 52 | acpi_dp_write(dp); |
| 53 | |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 54 | acpigen_pop_len(); /* Device */ |
| 55 | acpigen_pop_len(); /* Scope */ |
| 56 | |
| 57 | printk(BIOS_INFO, "%s: %s\n", acpi_device_path(dev), |
| 58 | dev->chip_ops->name); |
| 59 | } |
| 60 | |
| 61 | static const char *adau7002_acpi_name(const struct device *dev) |
| 62 | { |
| 63 | return ADAU7002_ACPI_NAME; |
| 64 | } |
| 65 | #endif |
| 66 | |
| 67 | static struct device_operations adau7002_ops = { |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame^] | 68 | .read_resources = DEVICE_NOOP, |
| 69 | .set_resources = DEVICE_NOOP, |
| 70 | .enable_resources = DEVICE_NOOP, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 71 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame^] | 72 | .acpi_name = adau7002_acpi_name, |
| 73 | .acpi_fill_ssdt = adau7002_fill_ssdt, |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 74 | #endif |
| 75 | }; |
| 76 | |
| 77 | static void adau7002_enable(struct device *dev) |
| 78 | { |
| 79 | dev->ops = &adau7002_ops; |
| 80 | } |
| 81 | |
| 82 | struct chip_operations drivers_generic_adau7002_ops = { |
| 83 | CHIP_NAME("Analog Digital DMIC") |
Elyes HAOUAS | 2aa3b16 | 2018-11-27 17:02:10 +0100 | [diff] [blame] | 84 | .enable_dev = adau7002_enable |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 85 | }; |