blob: 63510cd679744ccd607cab04564b79ed49303670 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Daniel Kurtz53b62132018-02-08 11:56:14 -07002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpi_device.h>
4#include <acpi/acpigen.h>
Daniel Kurtz53b62132018-02-08 11:56:14 -07005#include <console/console.h>
6#include <device/device.h>
7#include <device/path.h>
Daniel Kurtz53b62132018-02-08 11:56:14 -07008#include "chip.h"
9
Julius Wernercd49cce2019-03-05 16:53:33 -080010#if CONFIG(HAVE_ACPI_TABLES)
Daniel Kurtz53b62132018-02-08 11:56:14 -070011
12#define ADAU7002_ACPI_NAME "ADAU"
13#define ADAU7002_ACPI_HID "ADAU7002"
14
Furquan Shaikh7536a392020-04-24 21:59:21 -070015static void adau7002_fill_ssdt(const struct device *dev)
Daniel Kurtz53b62132018-02-08 11:56:14 -070016{
Akshu Agrawal7ac31492019-01-08 14:06:42 +053017 struct drivers_generic_adau7002_config *config;
18 struct acpi_dp *dp;
19
Karthikeyan Ramasubramaniand1c0f952020-11-02 16:26:52 -070020 if (!dev)
Richard Spiegele0d30642018-02-14 09:38:11 -070021 return;
22
23 const char *scope = acpi_device_scope(dev);
24 const char *name = acpi_device_name(dev);
25 if (!scope || !name)
Daniel Kurtz53b62132018-02-08 11:56:14 -070026 return;
27
28 /* Device */
Richard Spiegele0d30642018-02-14 09:38:11 -070029 acpigen_write_scope(scope);
30 acpigen_write_device(name);
Daniel Kurtz53b62132018-02-08 11:56:14 -070031 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 DeVillier44d0a132023-10-17 15:08:20 -050034 acpigen_write_STA(ACPI_STATUS_DEVICE_HIDDEN_ON);
Daniel Kurtz53b62132018-02-08 11:56:14 -070035
Akshu Agrawal7ac31492019-01-08 14:06:42 +053036 /* _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 Kurtz53b62132018-02-08 11:56:14 -070042 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
49static const char *adau7002_acpi_name(const struct device *dev)
50{
51 return ADAU7002_ACPI_NAME;
52}
53#endif
54
55static struct device_operations adau7002_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020056 .read_resources = noop_read_resources,
57 .set_resources = noop_set_resources,
Julius Wernercd49cce2019-03-05 16:53:33 -080058#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +020059 .acpi_name = adau7002_acpi_name,
60 .acpi_fill_ssdt = adau7002_fill_ssdt,
Daniel Kurtz53b62132018-02-08 11:56:14 -070061#endif
62};
63
64static void adau7002_enable(struct device *dev)
65{
66 dev->ops = &adau7002_ops;
67}
68
69struct chip_operations drivers_generic_adau7002_ops = {
70 CHIP_NAME("Analog Digital DMIC")
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +010071 .enable_dev = adau7002_enable
Daniel Kurtz53b62132018-02-08 11:56:14 -070072};